diff -Nru spring-96.0~14.04~ppa4/AI/CMakeLists.txt spring-98.0~14.04~ppa6/AI/CMakeLists.txt --- spring-96.0~14.04~ppa4/AI/CMakeLists.txt 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -70,9 +70,7 @@ find_package(AWK) # CUtils has to come first, because the Interfaces use it too -if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Wrappers/CUtils) - Add_Subdirectory(Wrappers/CUtils) -endif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Wrappers/CUtils) +Add_Subdirectory(Wrappers/CUtils) Add_Subdirectory(Interfaces) Add_Subdirectory(Wrappers) Add_Subdirectory(Skirmish) diff -Nru spring-96.0~14.04~ppa4/AI/Interfaces/C/CMakeLists.txt spring-98.0~14.04~ppa6/AI/Interfaces/C/CMakeLists.txt --- spring-96.0~14.04~ppa4/AI/Interfaces/C/CMakeLists.txt 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Interfaces/C/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -107,8 +107,10 @@ set(mySources "${mySourceDir}/Interface.cpp" "${mySourceDir}/InterfaceExport.cpp" + "${mySourceDir}/SSkirmishAISpecifier.cpp" ) - add_library(${myTarget} MODULE ${mySources} ${ai_common_SRC} ${CUtils_SRC} ${myVersionDepFile}) + add_library(${myTarget} MODULE ${mySources} ${ai_common_SRC} ${myVersionDepFile}) + target_link_libraries(${myTarget} CUtils) FixLibName(${myTarget}) Add_Dependencies(${myTarget} generateVersionFiles) diff -Nru spring-96.0~14.04~ppa4/AI/Interfaces/C/src/Interface.h spring-98.0~14.04~ppa6/AI/Interfaces/C/src/Interface.h --- spring-96.0~14.04~ppa4/AI/Interfaces/C/src/Interface.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Interfaces/C/src/Interface.h 2014-10-07 20:09:51.000000000 +0000 @@ -4,7 +4,7 @@ #define _INTERFACE_H #include "ExternalAI/Interface/SSkirmishAILibrary.h" -#include "CUtils/SSkirmishAISpecifier.h" +#include "SSkirmishAISpecifier.h" #include "CUtils/SharedLibrary.h" #include diff -Nru spring-96.0~14.04~ppa4/AI/Interfaces/C/src/SSkirmishAISpecifier.cpp spring-98.0~14.04~ppa6/AI/Interfaces/C/src/SSkirmishAISpecifier.cpp --- spring-96.0~14.04~ppa4/AI/Interfaces/C/src/SSkirmishAISpecifier.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Interfaces/C/src/SSkirmishAISpecifier.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,133 @@ +/* + Copyright (c) 2008 Robin Vobruba + + This program 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 2 of the License, or + (at your option) any later version. + + 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 . +*/ + +#if defined BUILDING_AI_INTERFACE + + +#include "SSkirmishAISpecifier.h" + +#include "CUtils/Util.h" + +#include "System/maindefines.h" +#include "System/SafeCStrings.h" + +#include +#include + + +struct SSkirmishAISpecifier SSkirmishAISpecifier_copy( + const struct SSkirmishAISpecifier* const orig) { + + struct SSkirmishAISpecifier copy; + + copy.shortName = util_allocStrCpy(orig->shortName); + copy.version = util_allocStrCpy(orig->version); + + return copy; +} + +void SSkirmishAISpecifier_delete(struct SSkirmishAISpecifier* spec) { + + free(const_cast(spec->shortName)); + spec->shortName = NULL; + free(const_cast(spec->version)); + spec->version = NULL; + FREE(spec); +} + + + +// by DeeViLiSh +static int string_simpleHash(const char* const input) { + + int b = 378551; // Ramdom Ranges I've chosen (can be modified) + int a = 63689; + int hash = 0; // Output hash + int i; // Temp number that scrolls through the string array + + int size = strlen(input); + for(i = 0; i < size; i++) { // Loop to convert each character + hash = hash * a + input[i]; // Algorithm that hashs + a = a * b; + } + + return (hash & 0x7FFFFFFF); // Returns the hashed string +} + +int SSkirmishAISpecifier_hash( + const struct SSkirmishAISpecifier* const spec) { + + bool useShortName = spec->shortName != NULL; + bool useVersion = spec->version != NULL; + + size_t hashString_size = 0; + if (useShortName) { + hashString_size += strlen(spec->shortName); + } + hashString_size += 1; // for the '#' char + if (useVersion) { + hashString_size += strlen(spec->version); + } + hashString_size += 1; // for the '\0' char + + char hashString[hashString_size]; + hashString[0] = '\0'; + + if (useShortName) { + STRCAT_T(hashString, hashString_size, spec->shortName); + } + STRCAT_T(hashString, hashString_size, "#"); + if (useVersion) { + STRCAT_T(hashString, hashString_size, spec->version); + } + + int keyHash = string_simpleHash(hashString); + + return keyHash; +} + +int SSkirmishAISpecifier_compare( + const struct SSkirmishAISpecifier* const specThis, + const struct SSkirmishAISpecifier* const specThat) { + + int comp = strcmp(specThis->shortName, specThat->shortName); + if (comp == 0) { + comp = strcmp(specThis->version, specThat->version); + } + return comp; +} + +bool SSkirmishAISpecifier_isUnspecified( + const struct SSkirmishAISpecifier* const spec) { + return spec->shortName == NULL || spec->version == NULL; +} + +static const SSkirmishAISpecifier unspecifiedSpec = {NULL, NULL}; +struct SSkirmishAISpecifier SSkirmishAISpecifier_getUnspecified() { + return unspecifiedSpec; +} + + +#ifdef __cplusplus +bool SSkirmishAISpecifier_Comparator::operator()( + const struct SSkirmishAISpecifier& specThis, + const struct SSkirmishAISpecifier& specThat) const { + return SSkirmishAISpecifier_compare(&specThis, &specThat) < 0; +} +#endif // defined __cplusplus + +#endif // defined BUILDING_AI_INTERFACE diff -Nru spring-96.0~14.04~ppa4/AI/Interfaces/C/src/SSkirmishAISpecifier.h spring-98.0~14.04~ppa6/AI/Interfaces/C/src/SSkirmishAISpecifier.h --- spring-96.0~14.04~ppa4/AI/Interfaces/C/src/SSkirmishAISpecifier.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Interfaces/C/src/SSkirmishAISpecifier.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,76 @@ +/* + Copyright (c) 2008 Robin Vobruba + + This program 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 2 of the License, or + (at your option) any later version. + + 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 . +*/ + +/** + * The struct and the helper functions in this file are here for convenience + * when building AI interfaces. The SSkirmishAISpecifier struct can be of use + * as key type for C++ maps or C hash maps (eg. to cache loaded Skirmish AIs). + * Engine side, we are using the C++ class SkirmishAIKey for the same purposes. + */ + +#ifndef _SSKIRMISHAISPECIFIER_H +#define _SSKIRMISHAISPECIFIER_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief struct Skirmish Artificial Intelligence specifier + */ +struct SSkirmishAISpecifier { + const char* shortName; // [may not contain: spaces, '_', '#'] + const char* version; // [may not contain: spaces, '_', '#'] +}; + +struct SSkirmishAISpecifier SSkirmishAISpecifier_copy( + const struct SSkirmishAISpecifier* const orig); + +void SSkirmishAISpecifier_delete(struct SSkirmishAISpecifier* spec); + +int SSkirmishAISpecifier_hash( + const struct SSkirmishAISpecifier* const spec); + +int SSkirmishAISpecifier_compare( + const struct SSkirmishAISpecifier* const specThis, + const struct SSkirmishAISpecifier* const specThat); + +bool SSkirmishAISpecifier_isUnspecified( + const struct SSkirmishAISpecifier* const spec); + +struct SSkirmishAISpecifier SSkirmishAISpecifier_getUnspecified(); + + +#if defined __cplusplus +struct SSkirmishAISpecifier_Comparator { + /** + * The key comparison function, a Strict Weak Ordering; + * it returns true if its first argument is less + * than its second argument, and false otherwise. + * This is also defined as map::key_compare. + */ + bool operator()(const struct SSkirmishAISpecifier& specThis, + const struct SSkirmishAISpecifier& specThat) const; +}; +#endif // defined __cplusplus + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _SSKIRMISHAISPECIFIER_H + diff -Nru spring-96.0~14.04~ppa4/AI/Interfaces/Java/bin/jni_wrappCallback.awk spring-98.0~14.04~ppa6/AI/Interfaces/Java/bin/jni_wrappCallback.awk --- spring-96.0~14.04~ppa4/AI/Interfaces/Java/bin/jni_wrappCallback.awk 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Interfaces/Java/bin/jni_wrappCallback.awk 2014-10-07 20:09:51.000000000 +0000 @@ -201,13 +201,7 @@ print("\t\t" c_paramNames[p] " = (" c_paramTypes[p] ") (*__env)->Get" capArrType "ArrayElements(__env, " jni_paramNames[p] ", NULL);") >> outFile_nc; } else if (_isString) { print("\t\t" "const int " c_paramNames[p] "_size = (int) (*__env)->GetArrayLength(__env, " jni_paramNames[p] ");") >> outFile_nc; - print("\t\t" c_paramNames[p] " = (" c_paramTypes[p] ") calloc(sizeof(char*), " c_paramNames[p] "_size);") >> outFile_nc; - print("\t\t" "int " c_paramNames[p] "_i;") >> outFile_nc; - print("\t\t" "jstring " c_paramNames[p] "_jStr;") >> outFile_nc; - print("\t\t" "for (" c_paramNames[p] "_i=0; " c_paramNames[p] "_i < " c_paramNames[p] "_size; ++" c_paramNames[p] "_i) {") >> outFile_nc; - print("\t\t\t" c_paramNames[p] "_jStr = (jstring) (*__env)->GetObjectArrayElement(__env, " jni_paramNames[p] ", " c_paramNames[p] "_i);") >> outFile_nc; - print("\t\t\t" c_paramNames[p] "[" c_paramNames[p] "_i] = (const char*) (*__env)->GetStringUTFChars(__env, " c_paramNames[p] "_jStr, NULL);") >> outFile_nc; - print("\t\t" "}") >> outFile_nc; + print("\t\t" c_paramNames[p] " = (" c_paramTypes[p] ") malloc(sizeof(char*) * " c_paramNames[p] "_size);") >> outFile_nc; } else { print("ERROR: do not know how to convert parameter type: " pType_jni); exit(1); @@ -247,7 +241,7 @@ capArrType = capitalize(capArrType); _isPrimitive = (capArrType != "Object"); - _isString = !_isPrimitive && (c_paramTypes[p] == "char**"); + _isString = !_isPrimitive && match(c_paramTypes[p], /(const )?char\*\*/); print("\t" "if (" jni_paramNames[p] " != NULL) {") >> outFile_nc; if (_isPrimitive) { @@ -256,15 +250,14 @@ print("\t\t" "(*__env)->Release" capArrType "ArrayElements(__env, " jni_paramNames[p] ", (" _elementJNativeType "*) " c_paramNames[p] ", 0 /* copy back changes and release */);") >> outFile_nc; } else if (_isString) { print("\t\t" "const int " c_paramNames[p] "_size = (int) (*__env)->GetArrayLength(__env, " jni_paramNames[p] ");") >> outFile_nc; - print("\t\t" c_paramNames[p] " = (" c_paramTypes[p] ") calloc(sizeof(char*), " c_paramNames[p] "_size);") >> outFile_nc; print("\t\t" "int " c_paramNames[p] "_i;") >> outFile_nc; print("\t\t" "jstring " c_paramNames[p] "_jStr;") >> outFile_nc; print("\t\t" "for (" c_paramNames[p] "_i=0; " c_paramNames[p] "_i < " c_paramNames[p] "_size; ++" c_paramNames[p] "_i) {") >> outFile_nc; - print("\t\t\t" c_paramNames[p] "_jStr = (jstring) (*__env)->GetObjectArrayElement(__env, " jni_paramNames[p] ", " c_paramNames[p] "_i);") >> outFile_nc; - print("\t\t\t" "(*__env)->ReleaseStringUTFChars(__env, " c_paramNames[p] "_jStr, " c_paramNames[p] "[" c_paramNames[p] "_i]);") >> outFile_nc; + print("\t\t\t" c_paramNames[p] "_jStr = (jstring) (*__env)->NewStringUTF(__env, " c_paramNames[p] "[" c_paramNames[p] "_i]);") >> outFile_nc; + print("\t\t\t" "(*__env)->SetObjectArrayElement(__env, " jni_paramNames[p] ", " c_paramNames[p] "_i, " c_paramNames[p] "_jStr);") >> outFile_nc; + print("\t\t\t" "(*__env)->DeleteLocalRef(__env, " c_paramNames[p] "_jStr);") >> outFile_nc; print("\t\t" "}") >> outFile_nc; print("\t\t" "free(" c_paramNames[p] ");") >> outFile_nc; - print("\t\t" c_paramNames[p] " = NULL;") >> outFile_nc; } print("\t" "}") >> outFile_nc; } diff -Nru spring-96.0~14.04~ppa4/AI/Interfaces/Java/CMakeLists.txt spring-98.0~14.04~ppa6/AI/Interfaces/Java/CMakeLists.txt --- spring-96.0~14.04~ppa4/AI/Interfaces/Java/CMakeLists.txt 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Interfaces/Java/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -431,7 +431,7 @@ "${myNativeSourceDir}/JavaBridge.c" "${myNativeSourceDir}/JniUtil.c" "${myNativeSourceDir}/JvmLocater_common.c" - "${myNativeSourceDir}/JvmLocater_solaris.c" + "${myNativeSourceDir}/JvmLocater_linux.c" "${myNativeSourceDir}/JvmLocater_windows.c" ) set(myNativeGeneratedSources @@ -615,9 +615,9 @@ include_directories(BEFORE ${MINGWLIBS}/include/java) endif (MINGW) include_directories(BEFORE "${rts}/lib/streflop" "${myNativeSourceDir}" "${myNativeGeneratedSourceDir}") - add_library(${myNativeTarget} MODULE ${myNativeSources} ${myNativeGeneratedSources} ${ai_common_SRC} ${CUtils_SRC} ${myVersionDepFile}) + add_library(${myNativeTarget} MODULE ${myNativeSources} ${myNativeGeneratedSources} ${ai_common_SRC} ${myVersionDepFile}) Add_Dependencies(${myNativeTarget} generateVersionFiles) - target_link_libraries(${myNativeTarget} streflop) + target_link_libraries(${myNativeTarget} CUtils streflop) set_target_properties(${myNativeTarget} PROPERTIES COMPILE_FLAGS "-DUSING_STREFLOP") set_target_properties(${myNativeTarget} PROPERTIES OUTPUT_NAME "AIInterface") FixLibName(${myNativeTarget}) diff -Nru spring-96.0~14.04~ppa4/AI/Interfaces/Java/src/main/native/JavaBridge.c spring-98.0~14.04~ppa6/AI/Interfaces/Java/src/main/native/JavaBridge.c --- spring-96.0~14.04~ppa4/AI/Interfaces/Java/src/main/native/JavaBridge.c 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Interfaces/Java/src/main/native/JavaBridge.c 2014-10-07 20:09:51.000000000 +0000 @@ -16,6 +16,7 @@ #include "ExternalAI/Interface/SSkirmishAILibrary.h" #include "ExternalAI/Interface/SSkirmishAICallback.h" #include "System/SafeCStrings.h" +#include "lib/streflop/streflopC.h" #include @@ -72,7 +73,7 @@ inline void java_establishSpringEnv() { //(*g_jvm)->DetachCurrentThread(g_jvm); - util_resetEngineEnv(); + streflop_init_Simple(); } /// The JVM sets the environment it wants automatically, so this is a no-op inline void java_establishJavaEnv() {} @@ -1154,8 +1155,6 @@ for (sai = 0; sai < skirmishAiImpl_size; ++sai) { if (skirmishAiImpl_className[sai] == NULL) { firstFree = sai; - } else if (strcmp(skirmishAiImpl_className[sai], className) == 0) { - break; } } // sai is now either the instantiated one, or a free one diff -Nru spring-96.0~14.04~ppa4/AI/Interfaces/Java/src/main/native/JvmLocater_linux.c spring-98.0~14.04~ppa6/AI/Interfaces/Java/src/main/native/JvmLocater_linux.c --- spring-96.0~14.04~ppa4/AI/Interfaces/Java/src/main/native/JvmLocater_linux.c 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Interfaces/Java/src/main/native/JvmLocater_linux.c 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,266 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#if !defined _WIN32 + +#include "JvmLocater_common.h" + +#include "System/maindefines.h" +#include "System/SafeCStrings.h" + +#include + + +#if defined APPLE +#define JVM_LIB "libjvm.dylib" +#else +#define JVM_LIB "libjvm.so" +#endif + +#if defined APPLE +#define JAVA_LIB "libjava.dylib" +#else +#define JAVA_LIB "libjava.so" +#endif + +#ifdef SPARC +# define LIBARCH32NAME "sparc" +# define LIBARCH64NAME "sparcv9" +#else // not SPARC -> LINUX or APPLE +# define LIBARCH32NAME "i386" +# define LIBARCH64NAME "amd64" +#endif // SPARC +#if defined __arch64__ +# define LIBARCHNAME LIBARCH64NAME +#else // defined __arch64__ +# define LIBARCHNAME LIBARCH32NAME +#endif // defined __arch64__ +//LIBARCH32 solaris only: sparc or i386 +//LIBARCH64 solaris only: sparcv9 or amd64 +//LIBARCH sparc, sparcv9, i386, amd64, or ia64 // last one is windows only + + +const char* GetArchPath() +{ + switch(CURRENT_DATA_MODEL) { +#ifdef DUAL_MODE + case 32: + return LIBARCH32NAME; + case 64: + return LIBARCH64NAME; +#endif // DUAL_MODE + default: + return LIBARCHNAME; + } +} + +/* + * On Solaris VM choosing is done by the launcher (java.c). + */ +bool GetJVMPath(const char* jrePath, const char* jvmType, + char* jvmPath, size_t jvmPathSize, const char* arch) +{ + if (arch == NULL) { + arch = GetArchPath(); + } + + if (*jvmType == '/') { + SNPRINTF(jvmPath, jvmPathSize, "%s/"JVM_LIB, jvmType); + } else { + SNPRINTF(jvmPath, jvmPathSize, "%s/lib/%s/%s/"JVM_LIB, jrePath, arch, + jvmType); + } + + return FileExists(jvmPath); +} + + +static bool CheckIfJREPath(const char* path, const char* arch) +{ + bool found = false; + + if (path != NULL) { + char libJava[MAXPATHLEN]; + + // Is path a JRE path? + SNPRINTF(libJava, MAXPATHLEN, "%s/lib/%s/"JAVA_LIB, path, arch); + if (access(libJava, F_OK) == 0) { + found = true; + } + } + + return found; +} + +bool GetJREPathFromBase(char* path, size_t pathSize, const char* basePath, + const char* arch) +{ + bool found = false; + + if (basePath != NULL) { + char jrePath[MAXPATHLEN]; + + // Is basePath a JRE path? + STRCPY_T(jrePath, MAXPATHLEN, basePath); + if (CheckIfJREPath(jrePath, arch)) { + STRCPY_T(path, pathSize, basePath); + found = true; + } + + // Is basePath/jre a JRE path? + STRCAT_T(jrePath, MAXPATHLEN, "/jre"); + if (CheckIfJREPath(jrePath, arch)) { + STRCPY_T(path, pathSize, jrePath); + found = true; + } + } + + return found; +} + +static size_t ExecFileSystemGlob(char** pathHits, size_t pathHits_sizeMax, + const char* globPattern) +{ + size_t pathHits_size = 0; + + // assemble the command + static const size_t cmd_sizeMax = 512; + char cmd[cmd_sizeMax]; + SNPRINTF(cmd, cmd_sizeMax, "find %s/ -maxdepth 0 2> /dev/null", globPattern); + + // execute + FILE* cmd_fp = popen(cmd, "r"); + if (cmd_fp == NULL) { + return pathHits_size; + } + + // parse results + static const size_t line_sizeMax = 512; + char line[line_sizeMax]; + while (fgets(line, line_sizeMax, cmd_fp) && (pathHits_size < pathHits_sizeMax)) { + size_t line_size = strlen(line); + if (*(line+line_size-1) == '\n') { + // remove trailing '\n' + *(line+line_size-1) = '\0'; + line_size--; + } + + simpleLog_logL(SIMPLELOG_LEVEL_FINEST, + "glob-hit \"%s\"!", line); + + if (line_size > 0 && *line == '/') { + *(line+line_size-1) = '\0'; // remove trailing '/' + pathHits[pathHits_size++] = util_allocStrCpy(line); + } + } + pclose(cmd_fp); + + return pathHits_size; +} +static bool GetJREPathInCommonLocations(char* path, size_t pathSize, const char* arch) +{ + bool found = false; + + static const size_t possLoc_sizeMax = 32; + char* possLoc[possLoc_sizeMax]; + size_t possLoc_i = 0; + + possLoc[possLoc_i++] = util_allocStrCpy("/usr/local/jdk*"); + possLoc[possLoc_i++] = util_allocStrCpy("/usr/lib/jvm/default-java"); + possLoc[possLoc_i++] = util_allocStrCpy("/usr/lib/jvm/java-?-sun"); + possLoc[possLoc_i++] = util_allocStrCpy("/usr/lib/jvm/java-?-*"); + possLoc[possLoc_i++] = util_allocStrCpy("~/jdk*"); + possLoc[possLoc_i++] = util_allocStrCpy("~/bin/jdk*"); + possLoc[possLoc_i++] = util_allocStrCpy("~/jre*"); + possLoc[possLoc_i++] = util_allocStrCpy("~/bin/jre*"); + + static const size_t globHits_sizeMax = 32; + char* globHits[globHits_sizeMax]; + size_t l, g; + for (l=0; l < possLoc_i; ++l) { + const size_t globHits_size = ExecFileSystemGlob(globHits, globHits_sizeMax, possLoc[l]); + for (g=0; g < globHits_size; ++g) { + found = GetJREPathFromBase(path, pathSize, globHits[g], arch); + if (found) { + simpleLog_logL(SIMPLELOG_LEVEL_FINER, + "JRE found common location env var \"%s\"!", + possLoc[l]); + goto locSearchEnd; + } + } + } + locSearchEnd: + + // cleanup + for (l=0; l < possLoc_i; ++l) { + free(possLoc[l]); + possLoc[l] = NULL; + } + + return found; +} + +static bool GetJREPathWhichJava(char* path, size_t pathSize, const char* arch) +{ + static const char* suf = "/bin/java"; + const size_t suf_size = strlen(suf); + + bool found = false; + + // execute + FILE* cmd_fp = popen("which java | sed 's/[\\n\\r]/K/g'", "r"); + if (cmd_fp == NULL) { + return found; + } + + // parse results + static const size_t line_sizeMax = 512; + char line[line_sizeMax]; + if (fgets(line, line_sizeMax, cmd_fp)) { + if (*line == '/') { // -> absolute path + size_t line_size = strlen(line); + if (*(line+line_size-1) == '\n') { + // remove trailing '\n' + *(line+line_size-1) = '\0'; + line_size--; + } + + simpleLog_logL(SIMPLELOG_LEVEL_FINEST, + "which line \"%s\"!", line); + + if (line_size > suf_size + && strcmp(line+(line_size-suf_size), suf) == 0) { + // line ends with suf + simpleLog_logL(SIMPLELOG_LEVEL_FINER, + "JRE found with `which java`!"); + // remove suf + *(line+(line_size-suf_size)) = '\0'; + found = GetJREPathFromBase(path, pathSize, line, arch); + } + } + } + pclose(cmd_fp); + + return found; +} + +/* + * Find path to JRE based on .exe's location or registry settings. + */ +bool GetJREPathOSSpecific(char* path, size_t pathSize, const char* arch) +{ + bool found = false; + + // check if a JRE is located in a common location + if (!found) { + found = GetJREPathInCommonLocations(path, pathSize, arch); + } + + // check if a JRE is located in a common location + if (!found) { + found = GetJREPathWhichJava(path, pathSize, arch); + } + + return found; +} + +#endif // !defined _WIN32 diff -Nru spring-96.0~14.04~ppa4/AI/Interfaces/Java/src/main/native/JvmLocater_solaris.c spring-98.0~14.04~ppa6/AI/Interfaces/Java/src/main/native/JvmLocater_solaris.c --- spring-96.0~14.04~ppa4/AI/Interfaces/Java/src/main/native/JvmLocater_solaris.c 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Interfaces/Java/src/main/native/JvmLocater_solaris.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,265 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#if !defined _WIN32 - -#include "JvmLocater_common.h" - -#include "System/maindefines.h" -#include "System/SafeCStrings.h" - -#include - - -#if defined APPLE -#define JVM_LIB "libjvm.dylib" -#else -#define JVM_LIB "libjvm.so" -#endif - -#if defined APPLE -#define JAVA_LIB "libjava.dylib" -#else -#define JAVA_LIB "libjava.so" -#endif - -#ifdef SPARC -# define LIBARCH32NAME "sparc" -# define LIBARCH64NAME "sparcv9" -#else // not SPARC -> LINUX or APPLE -# define LIBARCH32NAME "i386" -# define LIBARCH64NAME "amd64" -#endif // SPARC -#if defined __arch64__ -# define LIBARCHNAME LIBARCH64NAME -#else // defined __arch64__ -# define LIBARCHNAME LIBARCH32NAME -#endif // defined __arch64__ -//LIBARCH32 solaris only: sparc or i386 -//LIBARCH64 solaris only: sparcv9 or amd64 -//LIBARCH sparc, sparcv9, i386, amd64, or ia64 // last one is windows only - - -const char* GetArchPath() -{ - switch(CURRENT_DATA_MODEL) { -#ifdef DUAL_MODE - case 32: - return LIBARCH32NAME; - case 64: - return LIBARCH64NAME; -#endif // DUAL_MODE - default: - return LIBARCHNAME; - } -} - -/* - * On Solaris VM choosing is done by the launcher (java.c). - */ -bool GetJVMPath(const char* jrePath, const char* jvmType, - char* jvmPath, size_t jvmPathSize, const char* arch) -{ - if (arch == NULL) { - arch = GetArchPath(); - } - - if (*jvmType == '/') { - SNPRINTF(jvmPath, jvmPathSize, "%s/"JVM_LIB, jvmType); - } else { - SNPRINTF(jvmPath, jvmPathSize, "%s/lib/%s/%s/"JVM_LIB, jrePath, arch, - jvmType); - } - - return FileExists(jvmPath); -} - - -static bool CheckIfJREPath(const char* path, const char* arch) -{ - bool found = false; - - if (path != NULL) { - char libJava[MAXPATHLEN]; - - // Is path a JRE path? - SNPRINTF(libJava, MAXPATHLEN, "%s/lib/%s/"JAVA_LIB, path, arch); - if (access(libJava, F_OK) == 0) { - found = true; - } - } - - return found; -} - -bool GetJREPathFromBase(char* path, size_t pathSize, const char* basePath, - const char* arch) -{ - bool found = false; - - if (basePath != NULL) { - char jrePath[MAXPATHLEN]; - - // Is basePath a JRE path? - STRCPY_T(jrePath, MAXPATHLEN, basePath); - if (CheckIfJREPath(jrePath, arch)) { - STRCPY_T(path, pathSize, basePath); - found = true; - } - - // Is basePath/jre a JRE path? - STRCAT_T(jrePath, MAXPATHLEN, "/jre"); - if (CheckIfJREPath(jrePath, arch)) { - STRCPY_T(path, pathSize, jrePath); - found = true; - } - } - - return found; -} - -static size_t ExecFileSystemGlob(char** pathHits, size_t pathHits_sizeMax, - const char* globPattern) -{ - size_t pathHits_size = 0; - - // assemble the command - static const size_t cmd_sizeMax = 512; - char cmd[cmd_sizeMax]; - SNPRINTF(cmd, cmd_sizeMax, "find %s/ -maxdepth 0 2> /dev/null", globPattern); - - // execute - FILE* cmd_fp = popen(cmd, "r"); - if (cmd_fp == NULL) { - return pathHits_size; - } - - // parse results - static const size_t line_sizeMax = 512; - char line[line_sizeMax]; - while (fgets(line, line_sizeMax, cmd_fp) && (pathHits_size < pathHits_sizeMax)) { - size_t line_size = strlen(line); - if (*(line+line_size-1) == '\n') { - // remove trailing '\n' - *(line+line_size-1) = '\0'; - line_size--; - } - - simpleLog_logL(SIMPLELOG_LEVEL_FINEST, - "glob-hit \"%s\"!", line); - - if (line_size > 0 && *line == '/') { - *(line+line_size-1) = '\0'; // remove trailing '/' - pathHits[pathHits_size++] = util_allocStrCpy(line); - } - } - pclose(cmd_fp); - - return pathHits_size; -} -static bool GetJREPathInCommonLocations(char* path, size_t pathSize, const char* arch) -{ - bool found = false; - - static const size_t possLoc_sizeMax = 32; - char* possLoc[possLoc_sizeMax]; - size_t possLoc_i = 0; - - possLoc[possLoc_i++] = util_allocStrCpy("/usr/local/jdk*"); - possLoc[possLoc_i++] = util_allocStrCpy("/usr/lib/jvm/java-?-sun"); - possLoc[possLoc_i++] = util_allocStrCpy("/usr/lib/jvm/java-?-*"); - possLoc[possLoc_i++] = util_allocStrCpy("~/jdk*"); - possLoc[possLoc_i++] = util_allocStrCpy("~/bin/jdk*"); - possLoc[possLoc_i++] = util_allocStrCpy("~/jre*"); - possLoc[possLoc_i++] = util_allocStrCpy("~/bin/jre*"); - - static const size_t globHits_sizeMax = 32; - char* globHits[globHits_sizeMax]; - size_t l, g; - for (l=0; l < possLoc_i; ++l) { - const size_t globHits_size = ExecFileSystemGlob(globHits, globHits_sizeMax, possLoc[l]); - for (g=0; g < globHits_size; ++g) { - found = GetJREPathFromBase(path, pathSize, globHits[g], arch); - if (found) { - simpleLog_logL(SIMPLELOG_LEVEL_FINER, - "JRE found common location env var \"%s\"!", - possLoc[l]); - goto locSearchEnd; - } - } - } - locSearchEnd: - - // cleanup - for (l=0; l < possLoc_i; ++l) { - free(possLoc[l]); - possLoc[l] = NULL; - } - - return found; -} - -static bool GetJREPathWhichJava(char* path, size_t pathSize, const char* arch) -{ - static const char* suf = "/bin/java"; - const size_t suf_size = strlen(suf); - - bool found = false; - - // execute - FILE* cmd_fp = popen("which java | sed 's/[\\n\\r]/K/g'", "r"); - if (cmd_fp == NULL) { - return found; - } - - // parse results - static const size_t line_sizeMax = 512; - char line[line_sizeMax]; - if (fgets(line, line_sizeMax, cmd_fp)) { - if (*line == '/') { // -> absolute path - size_t line_size = strlen(line); - if (*(line+line_size-1) == '\n') { - // remove trailing '\n' - *(line+line_size-1) = '\0'; - line_size--; - } - - simpleLog_logL(SIMPLELOG_LEVEL_FINEST, - "which line \"%s\"!", line); - - if (line_size > suf_size - && strcmp(line+(line_size-suf_size), suf) == 0) { - // line ends with suf - simpleLog_logL(SIMPLELOG_LEVEL_FINER, - "JRE found with `which java`!"); - // remove suf - *(line+(line_size-suf_size)) = '\0'; - found = GetJREPathFromBase(path, pathSize, line, arch); - } - } - } - pclose(cmd_fp); - - return found; -} - -/* - * Find path to JRE based on .exe's location or registry settings. - */ -bool GetJREPathOSSpecific(char* path, size_t pathSize, const char* arch) -{ - bool found = false; - - // check if a JRE is located in a common location - if (!found) { - found = GetJREPathInCommonLocations(path, pathSize, arch); - } - - // check if a JRE is located in a common location - if (!found) { - found = GetJREPathWhichJava(path, pathSize, arch); - } - - return found; -} - -#endif // !defined _WIN32 diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIAirForceManager.cpp spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIAirForceManager.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIAirForceManager.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIAirForceManager.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,12 +7,21 @@ // Released under GPL license: see LICENSE.html for more information. // ------------------------------------------------------------------------- +#include + #include "AAIAirForceManager.h" +#include "AAIMap.h" #include "AAI.h" #include "AAIBuildTable.h" +#include "AAIUnitTable.h" +#include "AAIConfig.h" #include "AAIGroup.h" -#include "AAIMap.h" +#include "AAISector.h" + +#include "LegacyCpp/UnitDef.h" +using namespace springLegacyAI; + AAIAirForceManager::AAIAirForceManager(AAI *ai) { diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIAirForceManager.h spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIAirForceManager.h --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIAirForceManager.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIAirForceManager.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,15 +7,31 @@ // Released under GPL license: see LICENSE.html for more information. // ------------------------------------------------------------------------- +#ifndef AAI_AIRFORCEMANAGER_H +#define AAI_AIRFORCEMANAGER_H -#pragma once - +#include +#include "System/float3.h" #include "aidef.h" +namespace springLegacyAI { + struct UnitDef; +} +using namespace springLegacyAI; +using namespace std; + class AAI; class AAIBuildTable; -class AAIMap; +struct AAIAirTarget +{ + float3 pos; + int def_id; + int unit_id; + float cost; + float health; + UnitCategory category; +}; class AAIAirForceManager { @@ -26,34 +42,32 @@ // checks if a certain unit is worth attacking it and tries to order air units to do it (units, stationary defences) void CheckTarget(int unit, const UnitDef *def); - // checks if target is possible bombing target and adds to list of bomb targets (used for buildings e.g. stationary arty, nuke launchers..) - void CheckBombTarget(int unit_id, int def_id); - - // adds new target to bombing targets (if free space in list) - void AddTarget(int unit_id, int def_id); - // removes target from bombing target list void RemoveTarget(int unit_id); - // tries to attack units of a certain category - void BombUnitsOfCategory(UnitCategory category); - // attacks the most promising target void BombBestUnit(float cost, float danger); - // returns true if uni already in target list - bool IsTarget(int unit_id); // list of possible bombing targets vector targets; - list *air_groups; - +private: AAIGroup* GetAirGroup(float importance, UnitType group_type); -private: - AAI *ai; + // returns true if uni already in target list + bool IsTarget(int unit_id); + // tries to attack units of a certain category + void BombUnitsOfCategory(UnitCategory category); + // checks if target is possible bombing target and adds to list of bomb targets (used for buildings e.g. stationary arty, nuke launchers..) + void CheckBombTarget(int unit_id, int def_id); + // adds new target to bombing targets (if free space in list) + void AddTarget(int unit_id, int def_id); + list *air_groups; + AAI *ai; int my_team; int num_of_targets; }; + +#endif diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIAttack.cpp spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIAttack.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIAttack.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIAttack.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -9,9 +9,13 @@ #include "AAIAttack.h" #include "AAI.h" -#include "AAISector.h" +#include "AAIAttackManager.h" +#include "AAIMap.h" #include "AAIGroup.h" +#include "LegacyCpp/IAICallback.h" +using namespace springLegacyAI; + AAIAttack::AAIAttack(AAI *ai): dest(NULL), lastAttack(0), diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIAttack.h spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIAttack.h --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIAttack.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIAttack.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,10 +7,9 @@ // Released under GPL license: see LICENSE.html for more information. // ------------------------------------------------------------------------- +#ifndef AAI_ATTACK_H +#define AAI_ATTACK_H -#pragma once - -#include "aidef.h" #include using namespace std; @@ -49,9 +48,10 @@ // groups participating set combat_groups; +private: set aa_groups; set arty_groups; - -private: AAI *ai; }; + +#endif diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIAttackManager.cpp spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIAttackManager.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIAttackManager.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIAttackManager.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -11,9 +11,11 @@ #include "AAI.h" #include "AAIBrain.h" #include "AAIBuildTable.h" +#include "AAIAttack.h" +#include "AAIConfig.h" #include "AAIGroup.h" #include "AAIMap.h" -#include "AAIAttack.h" +#include "AAISector.h" AAIAttackManager::AAIAttackManager(AAI *ai, int continents) { @@ -293,7 +295,7 @@ bool AAIAttackManager::SufficientAttackPowerVS(AAISector *dest, set *combat_groups, float aggressiveness) { - if(dest && combat_groups->size() > 0) + if(dest && !combat_groups->empty()) { // check attack power float attack_power = 0.5; @@ -330,7 +332,7 @@ bool AAIAttackManager::SufficientCombatPowerAt(AAISector *dest, set *combat_groups, float aggressiveness) { - if(dest && combat_groups->size() > 0) + if(dest && !combat_groups->empty()) { // store ammount and category of involved groups; double my_power = 0, enemy_power = 0; diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIAttackManager.h spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIAttackManager.h --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIAttackManager.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIAttackManager.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,13 +7,15 @@ // Released under GPL license: see LICENSE.html for more information. // ------------------------------------------------------------------------- -#pragma once - +#ifndef AAI_ATTACKMANAGER_H +#define AAI_ATTACKMANAGER_H #include "aidef.h" #include +#include +#include -using std::set; +using namespace std; class AAI; class AAIBrain; @@ -29,28 +31,28 @@ AAIAttackManager(AAI *ai, int continents); ~AAIAttackManager(void); - void Update(); - - void GetNextDest(AAIAttack *attack); - - void LaunchAttack(); - - void StopAttack(AAIAttack *attack); - void CheckAttack(AAIAttack *attack); - // sends all groups to a rallypoint - void RallyGroups(AAIAttack *attack); + // true if units have sufficient combat power to face mobile units in dest + bool SufficientCombatPowerAt(AAISector *dest, set *combat_groups, float aggressiveness); // true if combat groups have suffiecient attack power to face stationary defences bool SufficientAttackPowerVS(AAISector *dest, set *combat_groups, float aggressiveness); - // true if units have sufficient combat power to face mobile units in dest - bool SufficientCombatPowerAt(AAISector *dest, set *combat_groups, float aggressiveness); - // true if defences have sufficient combat power to push back mobile units in dest bool SufficientDefencePowerAt(AAISector *dest, float aggressiveness); + void GetNextDest(AAIAttack *attack); + + void Update(); +private: + + void LaunchAttack(); + void StopAttack(AAIAttack *attack); + + // sends all groups to a rallypoint + void RallyGroups(AAIAttack *attack); + list attacks; // array stores number of combat groups per category (for SufficientAttackPowerVS(..) ) @@ -66,7 +68,7 @@ vector< vector > attack_power_continent; vector attack_power_global; -private: - AAI *ai; }; + +#endif diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIBrain.cpp spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIBrain.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIBrain.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIBrain.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,9 +7,18 @@ // Released under GPL license: see LICENSE.html for more information. // ------------------------------------------------------------------------- -#include "AAIBrain.h" #include "AAI.h" +#include "AAIBrain.h" +#include "AAIBuildTable.h" +#include "AAIExecute.h" +#include "AAIUnitTable.h" +#include "AAIConfig.h" #include "AAIMap.h" +#include "AAIGroup.h" +#include "AAISector.h" + +#include "LegacyCpp/UnitDef.h" +using namespace springLegacyAI; AAIBrain::AAIBrain(AAI *ai) { @@ -17,9 +26,6 @@ freeBaseSpots = false; expandable = true; - // initialize random numbers generator - srand ( time(NULL) ); - max_distance = ai->Getmap()->xSectors + ai->Getmap()->ySectors - 2; sectors.resize(max_distance); diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIBrain.h spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIBrain.h --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIBrain.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIBrain.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,17 +7,19 @@ // Released under GPL license: see LICENSE.html for more information. // ------------------------------------------------------------------------- - -#pragma once - -#include "aidef.h" -#include "AAISector.h" -#include "AAIGroup.h" +#ifndef AAI_BRAIN_H +#define AAI_BRAIN_H class AAI; class AAIBuildTable; class AAIExecute; class AIIMap; +class AAISector; + +#include "aidef.h" + +enum SectorType {UNKNOWN_SECTOR, LAND_SECTOR, LAND_WATER_SECTOR, WATER_SECTOR}; + class AAIBrain { @@ -29,10 +31,6 @@ void AddSector(AAISector *sector); void RemoveSector(AAISector *sector); - // for internal use - bool SectorInList(list mylist, AAISector *sector); - list GetSectors(); - // returns dest attack sector AAISector* GetAttackDest(bool land, bool water); @@ -59,20 +57,9 @@ void AddDefenceCapabilities(int def_id, UnitCategory category); // void SubtractDefenceCapabilities(int def_id, UnitCategory category); - // returns true if sufficient ressources to build unit are availbale - bool RessourcesForConstr(int unit, int workertime = 175); - - // returns true if enough metal for constr. - bool MetalForConstr(int unit, int workertime = 175); - - // returns true if enough energy for constr. - bool EnergyForConstr(int unit, int wokertime = 175); - // returns pos where scout schould be sent to void GetNewScoutDest(float3 *dest, int scout); - // returns true if sector is considered to be safe - bool IsSafeSector(AAISector *sector); // adds new sectors to base bool ExpandBase(SectorType sectorType); @@ -86,15 +73,10 @@ // returns true if AAI may build a mex in this sector (e.g. safe sector) bool MexConstructionAllowedInSector(AAISector *sector); - // returns ratio of cells in the current base sectors that match movement_type (e.g. 0.3 if 30% of base is covered with water and building is naval) - float GetBaseBuildspaceRatio(unsigned int building_move_type); - void DefendCommander(int attacker); void BuildUnits(); - void BuildUnitOfMovementType(unsigned int allowed_move_type, float cost, float ground_eff, float air_eff, float hover_eff, float sea_eff, float submarine_eff, float stat_eff, bool urgent); - // returns game period int GetGamePeriod(); @@ -121,8 +103,6 @@ // holding max number of units of a category spotted at the same time vector max_combat_units_spotted; - vector attacked_by; - vector defence_power_vs; // current estimations of game situation , values ranging from 0 (min) to 1 max @@ -132,5 +112,28 @@ float3 start_pos; private: + // returns true if sufficient ressources to build unit are availbale + bool RessourcesForConstr(int unit, int workertime = 175); + + // returns true if enough metal for constr. + bool MetalForConstr(int unit, int workertime = 175); + + // returns true if enough energy for constr. + bool EnergyForConstr(int unit, int wokertime = 175); + + // returns true if sector is considered to be safe + bool IsSafeSector(AAISector *sector); + + void BuildUnitOfMovementType(unsigned int allowed_move_type, float cost, float ground_eff, float air_eff, float hover_eff, float sea_eff, float submarine_eff, float stat_eff, bool urgent); + // returns ratio of cells in the current base sectors that match movement_type (e.g. 0.3 if 30% of base is covered with water and building is naval) + float GetBaseBuildspaceRatio(unsigned int building_move_type); + bool SectorInList(list mylist, AAISector *sector); + list GetSectors(); + vector defence_power_vs; + vector attacked_by; + AAI *ai; }; + +#endif + diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIBuildTable.cpp spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIBuildTable.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIBuildTable.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIBuildTable.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,27 +7,36 @@ // Released under GPL license: see LICENSE.html for more information. // ------------------------------------------------------------------------- -#include "System/FastMath.h" #include "System/Util.h" #include "AAIBuildTable.h" #include "AAI.h" +#include "AAIBrain.h" +#include "AAIExecute.h" +#include "AAIUnitTable.h" +#include "AAIConfig.h" +#include "AAIMap.h" + +#include "LegacyCpp/UnitDef.h" +#include "LegacyCpp/MoveData.h" +using namespace springLegacyAI; + // all the static vars -list* AAIBuildTable::units_of_category[MOBILE_CONSTRUCTOR+1]; +vector>> AAIBuildTable::units_of_category; char AAIBuildTable::buildtable_filename[500]; -float* AAIBuildTable::avg_cost[MOBILE_CONSTRUCTOR+1]; -float* AAIBuildTable::avg_buildtime[MOBILE_CONSTRUCTOR+1]; -float* AAIBuildTable::avg_value[MOBILE_CONSTRUCTOR+1]; -float* AAIBuildTable::max_cost[MOBILE_CONSTRUCTOR+1]; -float* AAIBuildTable::max_buildtime[MOBILE_CONSTRUCTOR+1]; -float* AAIBuildTable::max_value[MOBILE_CONSTRUCTOR+1]; -float* AAIBuildTable::min_cost[MOBILE_CONSTRUCTOR+1]; -float* AAIBuildTable::min_buildtime[MOBILE_CONSTRUCTOR+1]; -float* AAIBuildTable::min_value[MOBILE_CONSTRUCTOR+1]; -float** AAIBuildTable::avg_speed; -float** AAIBuildTable::min_speed; -float** AAIBuildTable::max_speed; -float** AAIBuildTable::group_speed; +vector> AAIBuildTable::avg_cost; +vector> AAIBuildTable::avg_buildtime; +vector> AAIBuildTable::avg_value; +vector> AAIBuildTable::max_cost; +vector> AAIBuildTable::max_buildtime; +vector> AAIBuildTable::max_value; +vector> AAIBuildTable::min_cost; +vector> AAIBuildTable::min_buildtime; +vector> AAIBuildTable::min_value; +vector> AAIBuildTable::avg_speed; +vector> AAIBuildTable::min_speed; +vector> AAIBuildTable::max_speed; +vector> AAIBuildTable::group_speed; vector< vector< vector > > AAIBuildTable::attacked_by_category_learned; vector< vector > AAIBuildTable::attacked_by_category_current; vector AAIBuildTable::units_static; @@ -58,7 +67,7 @@ for(int i = 0; i < numOfSides; ++i) { - temp = ai->Getcb()->GetUnitDef(cfg->START_UNITS[i]); + temp = ai->Getcb()->GetUnitDef(cfg->START_UNITS[i].c_str()); if(temp) startUnits[i] = temp->id; @@ -66,7 +75,7 @@ { startUnits[i] = -1; ai->LogConsole("Error: starting unit %s not found\n", - cfg->START_UNITS[i]); + cfg->START_UNITS[i].c_str()); } sideNames[i+1].assign(cfg->SIDE_NAMES[i]); @@ -82,21 +91,32 @@ // only set up static things if first aai intsance is iniatialized if(ai->GetInstances() == 1) { + avg_cost.resize(MOBILE_CONSTRUCTOR+1); + avg_buildtime.resize(MOBILE_CONSTRUCTOR+1); + avg_value.resize(MOBILE_CONSTRUCTOR+1); + max_cost.resize(MOBILE_CONSTRUCTOR+1); + max_buildtime.resize(MOBILE_CONSTRUCTOR+1); + max_value.resize(MOBILE_CONSTRUCTOR+1); + min_cost.resize(MOBILE_CONSTRUCTOR+1); + min_buildtime.resize(MOBILE_CONSTRUCTOR+1); + min_value.resize(MOBILE_CONSTRUCTOR+1); + units_of_category.resize(MOBILE_CONSTRUCTOR+1); + for(int i = 0; i <= MOBILE_CONSTRUCTOR; ++i) { // set up the unit lists - units_of_category[i] = new list[numOfSides]; + units_of_category[i].resize(numOfSides); // statistical values (mod sepcific) - avg_cost[i] = new float[numOfSides]; - avg_buildtime[i] = new float[numOfSides]; - avg_value[i] = new float[numOfSides]; - max_cost[i] = new float[numOfSides]; - max_buildtime[i] = new float[numOfSides]; - max_value[i] = new float[numOfSides]; - min_cost[i] = new float[numOfSides]; - min_buildtime[i] = new float[numOfSides]; - min_value[i] = new float[numOfSides]; + avg_cost[i].resize(numOfSides); + avg_buildtime[i].resize(numOfSides); + avg_value[i].resize(numOfSides); + max_cost[i].resize(numOfSides); + max_buildtime[i].resize(numOfSides); + max_value[i].resize(numOfSides); + min_cost[i].resize(numOfSides); + min_buildtime[i].resize(numOfSides); + min_value[i].resize(numOfSides); for(int s = 0; s < numOfSides; ++s) { @@ -125,20 +145,20 @@ }*/ // set up speed and attacked_by table - avg_speed = new float*[combat_categories]; - max_speed = new float*[combat_categories]; - min_speed = new float*[combat_categories]; - group_speed = new float*[combat_categories]; + avg_speed.resize(combat_categories); + max_speed.resize(combat_categories); + min_speed.resize(combat_categories); + group_speed.resize(combat_categories); attacked_by_category_current.resize(cfg->GAME_PERIODS, vector(combat_categories, 0)); attacked_by_category_learned.resize(3, vector< vector >(cfg->GAME_PERIODS, vector(combat_categories, 0))); for(int i = 0; i < combat_categories; ++i) { - avg_speed[i] = new float[numOfSides]; - max_speed[i] = new float[numOfSides]; - min_speed[i] = new float[numOfSides]; - group_speed[i] = new float[numOfSides]; + avg_speed[i].resize(numOfSides); + max_speed[i].resize(numOfSides); + min_speed[i].resize(numOfSides); + group_speed[i].resize(numOfSides); } // init eff stats @@ -154,39 +174,26 @@ // delete common data only if last aai instance has gone if(ai->GetInstances() == 0) { + units_of_category.clear(); - - for(int i = 0; i <= MOBILE_CONSTRUCTOR; ++i) - { - SafeDeleteArray(units_of_category[i]); - - SafeDeleteArray(avg_cost[i]); - SafeDeleteArray(avg_buildtime[i]); - SafeDeleteArray(avg_value[i]); - SafeDeleteArray(max_cost[i]); - SafeDeleteArray(max_buildtime[i]); - SafeDeleteArray(max_value[i]); - SafeDeleteArray(min_cost[i]); - SafeDeleteArray(min_buildtime[i]); - SafeDeleteArray(min_value[i]); - } + avg_cost.clear(); + avg_buildtime.clear(); + avg_value.clear(); + max_cost.clear(); + max_buildtime.clear(); + max_value.clear(); + min_cost.clear(); + min_buildtime.clear(); + min_value.clear(); /*SafeDeleteArray(max_builder_buildtime); SafeDeleteArray(max_builder_cost); SafeDeleteArray(max_builder_buildspeed);*/ - for(int i = 0; i < combat_categories; ++i) - { - SafeDeleteArray(avg_speed[i]); - SafeDeleteArray(max_speed[i]); - SafeDeleteArray(min_speed[i]); - SafeDeleteArray(group_speed[i]); - } - - SafeDeleteArray(avg_speed); - SafeDeleteArray(max_speed); - SafeDeleteArray(min_speed); - SafeDeleteArray(group_speed); + avg_speed.clear(); + max_speed.clear(); + min_speed.clear(); + group_speed.clear(); attacked_by_category_learned.clear(); attacked_by_category_current.clear(); @@ -203,9 +210,6 @@ { float max_cost = 0, min_cost = 1000000, eff; - // initialize random numbers generator - srand ( time(NULL) ); - // get number of units and alloc memory for unit list const int numOfUnits = ai->Getcb()->GetNumUnitDefs(); @@ -325,7 +329,7 @@ if(GetUnitDef(i).movedata) { - if(GetUnitDef(i).movedata->moveType == MoveData::Ground_Move) + if(GetUnitDef(i).movedata->moveFamily == MoveData::Tank || GetUnitDef(i).movedata->moveFamily == MoveData::KBot) { // check for amphibious units if(GetUnitDef(i).movedata->depth > 250) @@ -333,17 +337,19 @@ else units_static[i].movement_type |= MOVE_TYPE_GROUND; } - else if(GetUnitDef(i).movedata->moveType == MoveData::Hover_Move) + else if(GetUnitDef(i).movedata->moveFamily == MoveData::Hover) { units_static[i].movement_type |= MOVE_TYPE_HOVER; + } // ship - else if(GetUnitDef(i).movedata->moveType == MoveData::Ship_Move) + else if(GetUnitDef(i).movedata->moveFamily == MoveData::Ship) { units_static[i].movement_type |= MOVE_TYPE_SEA; - if(GetUnitDef(i).categoryString.find("UNDERWATER") != string::npos) + if(GetUnitDef(i).categoryString.find("UNDERWATER") != string::npos) { units_static[i].movement_type |= MOVE_TYPE_UNDERWATER; - else + } else { units_static[i].movement_type |= MOVE_TYPE_FLOATER; + } } } // aircraft @@ -424,7 +430,7 @@ units_static[i].category = AIR_BASE; } // check if powerplant - else if(GetUnitDef(i).energyMake > cfg->MIN_ENERGY || GetUnitDef(i).tidalGenerator || GetUnitDef(i).energyUpkeep < -cfg->MIN_ENERGY) + else if(GetUnitDef(i).energyMake > cfg->MIN_ENERGY || GetUnitDef(i).tidalGenerator || GetUnitDef(i).windGenerator || GetUnitDef(i).energyUpkeep < -cfg->MIN_ENERGY) { if(!GetUnitDef(i).isAirBase && GetUnitDef(i).radarRadius == 0 && GetUnitDef(i).sonarRadius == 0) { @@ -484,7 +490,7 @@ units_of_category[STORAGE][units_static[i].side-1].push_back(GetUnitDef(i).id); units_static[i].category = STORAGE; } - else if(GetUnitDef(i).makesMetal > 0) + else if(GetUnitDef(i).makesMetal > 0 || GetUnitDef(i).metalMake > 0 || IsMetalMaker(i)) { units_of_category[METAL_MAKER][units_static[i].side-1].push_back(GetUnitDef(i).id); units_static[i].category = METAL_MAKER; @@ -494,7 +500,9 @@ else if(GetUnitDef(i).movedata) { // ground units - if(GetUnitDef(i).movedata->moveType == MoveData::Ground_Move || GetUnitDef(i).movedata->moveType == MoveData::Hover_Move) + if(GetUnitDef(i).movedata->moveFamily == MoveData::Tank || + GetUnitDef(i).movedata->moveFamily == MoveData::KBot || + GetUnitDef(i).movedata->moveFamily == MoveData::Hover) { // units with weapons if((!GetUnitDef(i).weapons.empty() && GetMaxDamage(i) > 1) || IsAttacker(i)) @@ -509,7 +517,7 @@ // switch between arty and assault if(IsArty(i)) { - if(GetUnitDef(i).movedata->moveType == MoveData::Ground_Move) + if(GetUnitDef(i).movedata->moveFamily == MoveData::Tank || GetUnitDef(i).movedata->moveFamily == MoveData::KBot) { units_of_category[GROUND_ARTY][units_static[i].side-1].push_back(GetUnitDef(i).id); units_static[i].category = GROUND_ARTY; @@ -522,7 +530,7 @@ } else if(GetUnitDef(i).speed > 0) { - if(GetUnitDef(i).movedata->moveType == MoveData::Ground_Move) + if(GetUnitDef(i).movedata->moveFamily == MoveData::Tank || GetUnitDef(i).movedata->moveFamily == MoveData::KBot) { units_of_category[GROUND_ASSAULT][units_static[i].side-1].push_back(GetUnitDef(i).id); units_static[i].category = GROUND_ASSAULT; @@ -551,7 +559,7 @@ } } } - else if(GetUnitDef(i).movedata->moveType == MoveData::Ship_Move) + else if(GetUnitDef(i).movedata->moveFamily == MoveData::Ship) { // ship if(!GetUnitDef(i).weapons.empty()) @@ -772,12 +780,17 @@ temp = units_static[*pplant].efficiency[1]; // eff. of tidal generators have not been calculated yet (depend on map) - if(temp <= 0) + if(temp == 0) { temp = ai->Getcb()->GetTidalStrength() / units_static[*pplant].cost; units_static[*pplant].efficiency[0] = ai->Getcb()->GetTidalStrength(); units_static[*pplant].efficiency[1] = temp; + } else if (temp < 0) { + temp = (ai->Getcb()->GetMaxWind() + ai->Getcb()->GetMinWind()) * 0.5f / units_static[*pplant].cost; + + units_static[*pplant].efficiency[0] = (ai->Getcb()->GetMaxWind() + ai->Getcb()->GetMinWind()) * 0.5f; + units_static[*pplant].efficiency[1] = temp; } if(temp > max_pplant_eff[s]) @@ -816,10 +829,12 @@ for(int s = 0; s < numOfSides; s++) { // precache efficiency of power plants - for(list::iterator i = units_of_category[POWER_PLANT][s].begin(); i != units_of_category[POWER_PLANT][s].end(); i++) + for(list::iterator i = units_of_category[POWER_PLANT][s].begin(); i != units_of_category[POWER_PLANT][s].end(); ++i) { if(GetUnitDef(*i).tidalGenerator) units_static[*i].efficiency[0] = 0; + else if (GetUnitDef(*i).windGenerator) + units_static[*i].efficiency[0] = -1; else if(GetUnitDef(*i).energyMake >= cfg->MIN_ENERGY) units_static[*i].efficiency[0] = GetUnitDef(*i).energyMake; else if(GetUnitDef(*i).energyUpkeep <= -cfg->MIN_ENERGY) @@ -829,12 +844,17 @@ } // precache efficiency of extractors - for(list::iterator i = units_of_category[EXTRACTOR][s].begin(); i != units_of_category[EXTRACTOR][s].end(); i++) + for(list::iterator i = units_of_category[EXTRACTOR][s].begin(); i != units_of_category[EXTRACTOR][s].end(); ++i) units_static[*i].efficiency[0] = GetUnitDef(*i).extractsMetal; // precache efficiency of metalmakers - for(list::iterator i = units_of_category[METAL_MAKER][s].begin(); i != units_of_category[METAL_MAKER][s].end(); ++i) - units_static[*i].efficiency[0] = GetUnitDef(*i).makesMetal/(GetUnitDef(*i).energyUpkeep+1); + for(list::iterator i = units_of_category[METAL_MAKER][s].begin(); i != units_of_category[METAL_MAKER][s].end(); ++i) { + if (GetUnitDef(*i).makesMetal <= 0.1f) { + units_static[*i].efficiency[0] = 12.0f/600.0f; //FIXME: this somehow is broken... + } else { + units_static[*i].efficiency[0] = GetUnitDef(*i).makesMetal/(GetUnitDef(*i).energyUpkeep+1); + } + } // precache average metal and energy consumption of factories @@ -843,7 +863,7 @@ { average_metal = average_energy = 0; - for(list::iterator unit = units_static[*i].canBuildList.begin(); unit != units_static[*i].canBuildList.end(); unit++) + for(list::iterator unit = units_static[*i].canBuildList.begin(); unit != units_static[*i].canBuildList.end(); ++unit) { average_metal += ( GetUnitDef(*unit).metalCost * GetUnitDef(*i).buildSpeed ) / GetUnitDef(*unit).buildTime; average_energy += ( GetUnitDef(*unit).energyCost * GetUnitDef(*i).buildSpeed ) / GetUnitDef(*unit).buildTime; @@ -969,14 +989,14 @@ } // precache usage of jammers - for(list::iterator i = units_of_category[STATIONARY_JAMMER][s].begin(); i != units_of_category[STATIONARY_JAMMER][s].end(); i++) + for(list::iterator i = units_of_category[STATIONARY_JAMMER][s].begin(); i != units_of_category[STATIONARY_JAMMER][s].end(); ++i) { if(GetUnitDef(*i).energyUpkeep - GetUnitDef(*i).energyMake > 0) units_static[*i].efficiency[0] = GetUnitDef(*i).energyUpkeep - GetUnitDef(*i).energyMake; } // precache usage of radar - for(list::iterator i = units_of_category[STATIONARY_RECON][s].begin(); i != units_of_category[STATIONARY_RECON][s].end(); i++) + for(list::iterator i = units_of_category[STATIONARY_RECON][s].begin(); i != units_of_category[STATIONARY_RECON][s].end(); ++i) { if(GetUnitDef(*i).energyUpkeep - GetUnitDef(*i).energyMake > 0) units_static[*i].efficiency[0] = GetUnitDef(*i).energyUpkeep - GetUnitDef(*i).energyMake; @@ -1331,7 +1351,7 @@ bool AAIBuildTable::MemberOf(int unit_id, list unit_list) { // test all units in list - for(list::iterator i = unit_list.begin(); i != unit_list.end(); i++) + for(list::iterator i = unit_list.begin(); i != unit_list.end(); ++i) { if(*i == unit_id) return true; @@ -1392,7 +1412,7 @@ side -= 1; - for(list::iterator i = units_of_category[EXTRACTOR][side].begin(); i != units_of_category[EXTRACTOR][side].end(); i++) + for(list::iterator i = units_of_category[EXTRACTOR][side].begin(); i != units_of_category[EXTRACTOR][side].end(); ++i) { if(canBuild && units_dynamic[*i].constructorsAvailable <= 0) my_ranking = -10000; @@ -1443,7 +1463,7 @@ int best_storage = 0; float best_rating = 0, my_rating; - for(list::iterator storage = units_of_category[STORAGE][side-1].begin(); storage != units_of_category[STORAGE][side-1].end(); storage++) + for(list::iterator storage = units_of_category[STORAGE][side-1].begin(); storage != units_of_category[STORAGE][side-1].end(); ++storage) { if(canBuild && units_dynamic[*storage].constructorsAvailable <= 0) my_rating = 0; @@ -1476,18 +1496,26 @@ int best_maker = 0; float best_rating = 0, my_rating; - for(list::iterator maker = units_of_category[METAL_MAKER][side-1].begin(); maker != units_of_category[METAL_MAKER][side-1].end(); maker++) + for(list::iterator maker = units_of_category[METAL_MAKER][side-1].begin(); maker != units_of_category[METAL_MAKER][side-1].end(); ++maker) { + + //ai->LogConsole("MakesMetal: %f", GetUnitDef(*maker).makesMetal); + //this somehow got broken in spring... :( + float makesMetal = GetUnitDef(*maker).makesMetal; + if (makesMetal <= 0.1f) { + makesMetal = 12.0f/600.0f; + } + if(canBuild && units_dynamic[*maker].constructorsAvailable <= 0) my_rating = 0; else if(!water && GetUnitDef(*maker).minWaterDepth <= 0) { - my_rating = (pow((long double) efficiency * units_static[*maker].efficiency[0], (long double) 1.4) + pow((long double) metal * GetUnitDef(*maker).makesMetal, (long double) 1.6)) + my_rating = (pow((long double) efficiency * units_static[*maker].efficiency[0], (long double) 1.4) + pow((long double) metal * makesMetal, (long double) 1.6)) /(pow((long double) cost * units_static[*maker].cost,(long double) 1.4) + pow((long double) urgency * GetUnitDef(*maker).buildTime,(long double) 1.4)); } else if(water && GetUnitDef(*maker).minWaterDepth > 0) { - my_rating = (pow((long double) efficiency * units_static[*maker].efficiency[0], (long double) 1.4) + pow((long double) metal * GetUnitDef(*maker).makesMetal, (long double) 1.6)) + my_rating = (pow((long double) efficiency * units_static[*maker].efficiency[0], (long double) 1.4) + pow((long double) metal * makesMetal, (long double) 1.6)) /(pow((long double) cost * units_static[*maker].cost,(long double) 1.4) + pow((long double) urgency * GetUnitDef(*maker).buildTime,(long double) 1.4)); } else @@ -1685,7 +1713,7 @@ int best_defence = 0; - for(list::iterator i = units_of_category[STATIONARY_DEF][side-1].begin(); i != units_of_category[STATIONARY_DEF][side-1].end(); i++) + for(list::iterator i = units_of_category[STATIONARY_DEF][side-1].begin(); i != units_of_category[STATIONARY_DEF][side-1].end(); ++i) { my_rating = rand()%512; @@ -1768,7 +1796,7 @@ float my_rating, best_rating = -10000; side -= 1; - for(list::iterator i = units_of_category[STATIONARY_RECON][side].begin(); i != units_of_category[STATIONARY_RECON][side].end(); i++) + for(list::iterator i = units_of_category[STATIONARY_RECON][side].begin(); i != units_of_category[STATIONARY_RECON][side].end(); ++i) { if(GetUnitDef(*i).radarRadius > 0) { @@ -1805,7 +1833,7 @@ float my_rating, best_rating = -10000; side -= 1; - for(list::iterator i = units_of_category[STATIONARY_JAMMER][side].begin(); i != units_of_category[STATIONARY_JAMMER][side].end(); i++) + for(list::iterator i = units_of_category[STATIONARY_JAMMER][side].begin(); i != units_of_category[STATIONARY_JAMMER][side].end(); ++i) { if(canBuild && units_dynamic[*i].constructorsAvailable <= 0) my_rating = -10000; @@ -1872,7 +1900,7 @@ int best_unit = 0; - for(list::iterator i = unit_list.begin(); i != unit_list.end(); i++) + for(list::iterator i = unit_list.begin(); i != unit_list.end(); ++i) { my_rating = rand()%512; @@ -2271,7 +2299,7 @@ { my_ranking = power * combat_eff[c] / max_power; my_ranking -= cost * unit->cost / max_cost; - my_ranking += efficiency * (combat_eff[c] / unit->cost) / max_efficiency; + my_ranking += SafeDivide(efficiency * (SafeDivide(combat_eff[c], unit->cost)), max_efficiency); my_ranking += range * unit->range / max_range; my_ranking += speed * GetUnitDef(*i).speed / max_speed; my_ranking += 0.1f * ((float)(rand()%randomness)); @@ -2280,7 +2308,7 @@ { my_ranking = power * combat_eff[c] / max_power; my_ranking -= cost * unit->cost / max_cost; - my_ranking += efficiency * (combat_eff[c] / unit->cost) / max_efficiency; + my_ranking += SafeDivide(efficiency * (SafeDivide(combat_eff[c], unit->cost)), max_efficiency); my_ranking += range * unit->range / max_range; my_ranking += speed * GetUnitDef(*i).speed / max_speed; my_ranking += 0.1f * ((float)(rand()%randomness)); @@ -2464,6 +2492,11 @@ } } +std::string AAIBuildTable::GetBuildCacheFileName() +{ + return cfg->GetFileName(cfg->getUniqueName(true, true, true, true), MOD_LEARN_PATH, "_buildcache.txt", true); +} + // returns true if cache found bool AAIBuildTable::LoadBuildTable() @@ -2482,34 +2515,18 @@ } return true; - } - else // load data - { - // get filename - char buffer[500]; - STRCPY(buffer, MAIN_PATH); - STRCAT(buffer, MOD_LEARN_PATH); - const std::string modHumanName = MakeFileSystemCompatible(ai->Getcb()->GetModHumanName()); - STRCAT(buffer, modHumanName.c_str()); - STRCAT(buffer, "-"); - const std::string modHash = IntToString(ai->Getcb()->GetModHash(), "%x"); - STRCAT(buffer, modHash.c_str()); - STRCAT(buffer, ".dat"); - STRCPY(buildtable_filename, buffer); - - // this size equals the one used in "AIAICallback::GetValue(AIVAL_LOCATE_FILE_..." - char buildtable_filename_r[2048]; - STRCPY(buildtable_filename_r, buildtable_filename); - ai->Getcb()->GetValue(AIVAL_LOCATE_FILE_R, buildtable_filename_r); + } else { + // load data FILE *load_file; int tmp = 0, cat = 0; size_t bo = 0, bb = 0; - + const std::string filename = GetBuildCacheFileName(); // load units if file exists - if((load_file = fopen(buildtable_filename_r, "r"))) + if((load_file = fopen(filename.c_str(), "r"))) { + char buffer[1024]; // check if correct version fscanf(load_file, "%s", buffer); @@ -2638,12 +2655,8 @@ units_static[*builder].efficiency[5] = -1; } - // get filename - // this size equals the one used in "AIAICallback::GetValue(AIVAL_LOCATE_FILE_..." - char buildtable_filename_w[2048]; - STRCPY(buildtable_filename_w, buildtable_filename); - ai->Getcb()->GetValue(AIVAL_LOCATE_FILE_W, buildtable_filename_w); - FILE *save_file = fopen(buildtable_filename_w, "w+"); + const std::string filename = GetBuildCacheFileName(); + FILE *save_file = fopen(filename.c_str(), "w+"); // file version fprintf(save_file, "%s \n", MOD_LEARN_VERSION); @@ -2744,22 +2757,9 @@ // for debugging UnitType unitType; // this size equals the one used in "AIAICallback::GetValue(AIVAL_LOCATE_FILE_..." - char filename[2048]; - char buffer[500]; - STRCPY(buffer, MAIN_PATH); - STRCAT(buffer, AILOG_PATH); - STRCAT(buffer, "BuildTable_"); - const std::string modHumanName = MakeFileSystemCompatible(ai->Getcb()->GetModHumanName()); - STRCAT(buffer, modHumanName.c_str()); - STRCAT(buffer, "-"); - const std::string modHash = IntToString(ai->Getcb()->GetModHash(), "%x"); - STRCAT(buffer, modHash.c_str()); - STRCAT(buffer, ".txt"); - STRCPY(filename, buffer); - - ai->Getcb()->GetValue(AIVAL_LOCATE_FILE_W, filename); + const std::string filename = cfg->GetFileName(cfg->getUniqueName(true, true, true, true), MOD_LEARN_PATH, "_buildtable.txt", true); - FILE *file = fopen(filename, "w"); + FILE *file = fopen(filename.c_str(), "w"); if(file) { @@ -2879,7 +2879,7 @@ { float max_range = 0; - for(vector::const_iterator i = GetUnitDef(unit_id).weapons.begin(); i != GetUnitDef(unit_id).weapons.end(); i++) + for(vector::const_iterator i = GetUnitDef(unit_id).weapons.begin(); i != GetUnitDef(unit_id).weapons.end(); ++i) { if((*i).def->range > max_range) max_range = (*i).def->range; @@ -2917,41 +2917,13 @@ a--; strncpy (dst, "", s); - if (a>s-sizeof(MAIN_PATH)) a=s-sizeof(""); + if (a>s-sizeof("")) a=s-sizeof(""); memcpy (&dst [sizeof ("")-1], n, a); dst[a+sizeof("")]=0; strncat (dst, ext, s); } -static bool IsFSGoodChar(const char c) { - - if ((c >= '0') && (c <= '9')) { - return true; - } else if ((c >= 'a') && (c <= 'z')) { - return true; - } else if ((c >= 'A') && (c <= 'Z')) { - return true; - } else if ((c == '.') || (c == '_') || (c == '-')) { - return true; - } - - return false; -} -// declaration is in aidef.h -std::string MakeFileSystemCompatible(const std::string& str) { - - std::string cleaned = str; - - for (std::string::size_type i=0; i < cleaned.size(); i++) { - if (!IsFSGoodChar(cleaned[i])) { - cleaned[i] = '_'; - } - } - - return cleaned; -} - float AAIBuildTable::GetFactoryRating(int def_id) { // check if value already chached @@ -2971,7 +2943,7 @@ if(cfg->AIR_ONLY_MOD) { - for(list::iterator unit = units_static[def_id].canBuildList.begin(); unit != units_static[def_id].canBuildList.end(); unit++) + for(list::iterator unit = units_static[def_id].canBuildList.begin(); unit != units_static[def_id].canBuildList.end(); ++unit) { if(units_static[*unit].category >= GROUND_ASSAULT && units_static[*unit].category <= SEA_ASSAULT) { @@ -3378,7 +3350,7 @@ ai->Getut()->UnitRequested(MOBILE_CONSTRUCTOR); // set all its buildoptions buildable - for(list::iterator j = units_static[constructor].canBuildList.begin(); j != units_static[constructor].canBuildList.end(); j++) + for(list::iterator j = units_static[constructor].canBuildList.begin(); j != units_static[constructor].canBuildList.end(); ++j) units_dynamic[*j].constructorsRequested += 1; // debug @@ -3451,7 +3423,7 @@ float max_range = 0; // const WeaponDef *longest = 0; - for(vector::const_iterator weapon = GetUnitDef(id).weapons.begin(); weapon != GetUnitDef(id).weapons.end(); weapon++) + for(vector::const_iterator weapon = GetUnitDef(id).weapons.begin(); weapon != GetUnitDef(id).weapons.end(); ++weapon) { if(weapon->def->range > max_range) { @@ -3463,17 +3435,17 @@ // veh, kbot, hover or ship if(GetUnitDef(id).movedata) { - if(GetUnitDef(id).movedata->moveType == MoveData::Ground_Move) + if(GetUnitDef(id).movedata->moveFamily == MoveData::Tank || GetUnitDef(id).movedata->moveFamily == MoveData::KBot) { if(max_range > cfg->GROUND_ARTY_RANGE) return true; } - else if(GetUnitDef(id).movedata->moveType == MoveData::Ship_Move) + else if(GetUnitDef(id).movedata->moveFamily == MoveData::Ship) { if(max_range > cfg->SEA_ARTY_RANGE) return true; } - else if(GetUnitDef(id).movedata->moveType == MoveData::Hover_Move) + else if(GetUnitDef(id).movedata->moveFamily == MoveData::Hover) { if(max_range > cfg->HOVER_ARTY_RANGE) return true; @@ -3545,6 +3517,17 @@ return true; } +bool AAIBuildTable::IsMetalMaker(int id) +{ + for(list::iterator i = cfg->METAL_MAKERS.begin(); i != cfg->METAL_MAKERS.end(); ++i) + { + if(*i == id) + return true; + } + + return false; +} + bool AAIBuildTable::IsMissileLauncher(int def_id) { for(vector::const_iterator weapon = GetUnitDef(def_id).weapons.begin(); weapon != GetUnitDef(def_id).weapons.end(); ++weapon) diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIBuildTable.h spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIBuildTable.h --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIBuildTable.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIBuildTable.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,12 +7,51 @@ // Released under GPL license: see LICENSE.html for more information. // ------------------------------------------------------------------------- -#pragma once +#ifndef AAI_BUILDTABLE_H +#define AAI_BUILDTABLE_H class AAI; +namespace springLegacyAI { + struct UnitDef; +} +using namespace springLegacyAI; + + #include "aidef.h" #include +#include +#include +#include + +using namespace std; + +struct UnitTypeDynamic +{ + int under_construction; // how many units of that type are under construction + int requested; // how many units of that type have been requested + int active; // how many units of that type are currently alive + int constructorsAvailable; // how many factories/builders available being able to build that unit + int constructorsRequested; // how many factories/builders requested being able to build that unit +}; + +struct UnitTypeStatic +{ + int def_id; + int side; // 0 if side has not been set + list canBuildList; + list builtByList; + vector efficiency; // 0 -> ground assault, 1 -> air assault, 2 -> hover assault + // 3 -> sea assault, 4 -> submarine , 5 -> stat. defences + float range; // max weapon range (0 for unarmed units) + float cost; + float builder_cost; + UnitCategory category; + + unsigned int unit_type; + unsigned int movement_type; +}; + class AAIBuildTable { @@ -25,31 +64,18 @@ void Init(); void SaveBuildTable(int game_period, MapType map_type); - // cache for combat eff (needs side, thus initialized later) void InitCombatEffCache(int side); - // precaches speed/cost/buildtime/range stats - void PrecacheStats(); - - // only precaches costs (called after possible cost multipliers have been assigned) - void PrecacheCosts(); - // returns true, if a builder can build a certain unit (use UnitDef.id) bool CanBuildUnit(int id_builder, int id_unit); - // returns side of a unit - int GetSide(int unit); - // returns side of a certian unittype (use UnitDef->id) int GetSideByID(int unit_id); // return unit type (for groups) UnitType GetUnitType(int def_id); - // returns true, if unitid is in the list - bool MemberOf(int unit_id, list unit_list); - // ****************************************************************************************************** // the following functions are used to determine units that suit a certain purpose // if water == true, only water based units/buildings will be returned @@ -60,6 +86,7 @@ // returns a extractor from the list based on certain factors int GetMex(int side, float cost, float effiency, bool armed, bool water, bool canBuild); + // returns mex with the biggest yardmap int GetBiggestMex(); @@ -150,6 +177,9 @@ // returns false if unit is a member of the dont_build list bool AllowedToBuild(int id); + //sadly can't detect metal makers anymore, read them from config + bool IsMetalMaker(int id); + // returns true, if unit is a transporter bool IsTransporter(int id); @@ -195,20 +225,20 @@ static char buildtable_filename[500]; // cached values of average costs and buildtime - static float *avg_cost[MOBILE_CONSTRUCTOR+1]; - static float *avg_buildtime[MOBILE_CONSTRUCTOR+1]; - static float *avg_value[MOBILE_CONSTRUCTOR+1]; // used for different things, range of weapons, radar range, mex efficiency - static float *max_cost[MOBILE_CONSTRUCTOR+1]; - static float *max_buildtime[MOBILE_CONSTRUCTOR+1]; - static float *max_value[MOBILE_CONSTRUCTOR+1]; - static float *min_cost[MOBILE_CONSTRUCTOR+1]; - static float *min_buildtime[MOBILE_CONSTRUCTOR+1]; - static float *min_value[MOBILE_CONSTRUCTOR+1]; - - static float **avg_speed; - static float **min_speed; - static float **max_speed; - static float **group_speed; + static vector> avg_cost; + static vector> avg_buildtime; + static vector> avg_value; // used for different things, range of weapons, radar range, mex efficiency + static vector> max_cost; + static vector> max_buildtime; + static vector> max_value; + static vector> min_cost; + static vector> min_buildtime; + static vector> min_value; + + static vector> avg_speed; + static vector> min_speed; + static vector> max_speed; + static vector> group_speed; // combat categories that attacked AI in certain game period attacked_by_category_learned[map_type][period][cat] static vector< vector< vector > > attacked_by_category_learned; @@ -217,7 +247,7 @@ static vector< vector > attacked_by_category_current; // units of the different categories - static list *units_of_category[MOBILE_CONSTRUCTOR+1]; + static vector>> units_of_category; // AAI unit defs (static things like id, side, etc.) static vector units_static; @@ -269,6 +299,18 @@ const UnitDef& GetUnitDef(int i) { assert(IsValidUnitDefID(i)); return *unitList[i];} bool IsValidUnitDefID(int i) { return (i>=0) && (i<=unitList.size()); } private: + std::string GetBuildCacheFileName(); + // precaches speed/cost/buildtime/range stats + void PrecacheStats(); + + // only precaches costs (called after possible cost multipliers have been assigned) + void PrecacheCosts(); + + // returns side of a unit + int GetSide(int unit); + + // returns true, if unitid is in the list + bool MemberOf(int unit_id, list unit_list); // for internal use void CalcBuildTree(int unit); bool LoadBuildTable(); @@ -277,8 +319,11 @@ AAI * ai; - FILE *file; +// FILE *file; // all the unit defs, FIXME: this can't be made static as spring seems to free the memory returned by GetUnitDefList() std::vector unitList; }; + +#endif + diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIBuildTask.cpp spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIBuildTask.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIBuildTask.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIBuildTask.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,11 +7,20 @@ // Released under GPL license: see LICENSE.html for more information. // ------------------------------------------------------------------------- +#include +using namespace std; + #include "AAIBuildTask.h" #include "AAI.h" #include "AAIConstructor.h" +#include "AAIUnitTable.h" +#include "AAIBuildTable.h" +#include "AAIExecute.h" +#include "AAIMap.h" +#include "AAISector.h" -AAIBuildTask::AAIBuildTask(AAI *ai, int unit_id, int def_id, float3 *pos, int tick) +AAIBuildTask::AAIBuildTask(AAI *ai, int unit_id, int def_id, float3 *pos, int tick): + build_pos(*pos) { this->ai = ai; this->unit_id = unit_id; @@ -21,7 +30,6 @@ builder_id = -1; - build_pos = *pos; } AAIBuildTask::~AAIBuildTask(void) diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIBuildTask.h spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIBuildTask.h --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIBuildTask.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIBuildTask.h 2014-10-07 20:09:51.000000000 +0000 @@ -1,6 +1,17 @@ -#pragma once +// ------------------------------------------------------------------------- +// AAI +// +// A skirmish AI for the Spring engine. +// Copyright Alexander Seizinger +// +// Released under GPL license: see LICENSE.html for more information. +// ------------------------------------------------------------------------- + +#ifndef AAI_BUILDTASK_H +#define AAI_BUILDTASK_H + +#include "System/float3.h" -#include "aidef.h" class AAI; class AAIBuildTask @@ -25,3 +36,6 @@ private: AAI* ai; }; + +#endif + diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIConfig.cpp spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIConfig.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIConfig.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIConfig.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -9,6 +9,81 @@ #include "AAIConfig.h" #include "AAI.h" +#include "System/SafeCStrings.h" +#include "System/Util.h" + +// all paths +#define CFG_PATH "cfg/" +#define MOD_CFG_PATH CFG_PATH "mod/" +#define CONFIG_SUFFIX ".cfg" +#define GENERAL_CFG_FILE "general" CONFIG_SUFFIX + + +#include "LegacyCpp/UnitDef.h" +using namespace springLegacyAI; + + +static bool IsFSGoodChar(const char c) { + + if ((c >= '0') && (c <= '9')) { + return true; + } else if ((c >= 'a') && (c <= 'z')) { + return true; + } else if ((c >= 'A') && (c <= 'Z')) { + return true; + } else if ((c == '.') || (c == '_') || (c == '-')) { + return true; + } + + return false; +} + +// declaration is in aidef.h +std::string MakeFileSystemCompatible(const std::string& str) { + + std::string cleaned = str; + + for (std::string::size_type i=0; i < cleaned.size(); i++) { + if (!IsFSGoodChar(cleaned[i])) { + cleaned[i] = '_'; + } + } + + return cleaned; +} + + +int AAIConfig::GetInt(FILE* file) +{ + int val = 0; + int res = fscanf(file, "%i", &val); + if (res != 1) { + ai->Log("Error while parsing config"); + } + return val; +} + +std::string AAIConfig::GetString(FILE* file) +{ + char buf[128]; + buf[0] = 0; //safety! + int res = fscanf(file, "%s", buf); + if (res != 1) { + ai->Log("Error while parsing config"); + } + return std::string(buf); +} + +float AAIConfig::GetFloat(FILE* file) +{ + float val = 0.0f; + int res = fscanf(file, "%f", &val); + if (res != 1) { + ai->Log("Error while parsing config"); + } + return val; +} + AAIConfig::AAIConfig(void) { @@ -96,601 +171,373 @@ LAND_WATER_MAP_RATIO = 0.3f; GAME_PERIODS = 4; - + ai = NULL; initialized = false; } AAIConfig::~AAIConfig(void) { - for(int i = 0; i < SIDES; i++) - { - SafeDeleteArray(START_UNITS[i]); - SafeDeleteArray(SIDE_NAMES[i]); - } - - SafeDeleteArray(START_UNITS); - SafeDeleteArray(SIDE_NAMES); + START_UNITS.clear(); + SIDE_NAMES.clear(); } -void AAIConfig::LoadConfig(AAI *ai) + +std::string AAIConfig::GetFileName(const std::string& filename, const std::string& prefix, const std::string& suffix, bool write) const { + std::string name = prefix + MakeFileSystemCompatible(filename) + suffix; + // this size equals the one used in "AIAICallback::GetValue(AIVAL_LOCATE_FILE_..." - char filename[2048]; - char buffer[500]; + char buffer[2048]; + STRCPY_T(buffer, sizeof(buffer), name.c_str()); + if (write) { + ai->Getcb()->GetValue(AIVAL_LOCATE_FILE_W, buffer); + } else { + ai->Getcb()->GetValue(AIVAL_LOCATE_FILE_R, buffer); + } + name.assign(buffer, sizeof(buffer)); + return name; +} +void AAIConfig::LoadConfig(AAI *ai) +{ + this->ai = ai; MAX_UNITS = ai->Getcb()->GetMaxUnits(); - FILE* file = NULL; - STRCPY_T(buffer, sizeof(buffer), MAIN_PATH); - STRCAT_T(buffer, sizeof(buffer), MOD_CFG_PATH); - const std::string modHumanName = MakeFileSystemCompatible(ai->Getcb()->GetModHumanName()); - STRCAT_T(buffer, sizeof(buffer), modHumanName.c_str()); - STRCAT_T(buffer, sizeof(buffer), ".cfg"); - STRCPY_T(filename, sizeof(filename), buffer); - ai->Getcb()->GetValue(AIVAL_LOCATE_FILE_R, filename); - file = fopen(filename, "r"); - if (file == NULL) { - ai->Log("Mod config file %s not found\n", filename); - ai->Log("Now trying with legacy mod config file name ...\n"); - STRCPY_T(buffer, sizeof(buffer), MAIN_PATH); - STRCAT_T(buffer, sizeof(buffer), MOD_CFG_PATH); - const std::string modName = MakeFileSystemCompatible(ai->Getcb()->GetModName()); - STRCAT_T(buffer, sizeof(buffer), modName.c_str()); - ReplaceExtension(buffer, filename, sizeof(filename), ".cfg"); - ai->Getcb()->GetValue(AIVAL_LOCATE_FILE_R, filename); - file = fopen(filename, "r"); - } - if (file == NULL) { - ai->Log("Mod config file %s not found\n", filename); - ai->Log("Now trying with version independent mod config file name ...\n"); - STRCPY_T(buffer, sizeof(buffer), MAIN_PATH); - STRCAT_T(buffer, sizeof(buffer), MOD_CFG_PATH); - const std::string modShortName = MakeFileSystemCompatible(ai->Getcb()->GetModShortName()); - STRCAT_T(buffer, sizeof(buffer), modShortName.c_str()); - STRCAT_T(buffer, sizeof(buffer), ".cfg"); - STRCPY_T(filename, sizeof(filename), buffer); - ai->Getcb()->GetValue(AIVAL_LOCATE_FILE_R, filename); - file = fopen(filename, "r"); + std::list paths; + paths.push_back(GetFileName(ai->Getcb()->GetModHumanName(), MOD_CFG_PATH, CONFIG_SUFFIX)); + paths.push_back(GetFileName(ai->Getcb()->GetModName(), MOD_CFG_PATH, CONFIG_SUFFIX)); + paths.push_back(GetFileName(ai->Getcb()->GetModShortName(), MOD_CFG_PATH, CONFIG_SUFFIX)); + FILE* file = NULL; + std::string configfile; + for(const std::string& path: paths) { + file = fopen(path.c_str(), "r"); + if (file == NULL) { + ai->Log("Couldn't open config file %s\n", path.c_str()); + } else { + configfile = path; + break; + } } + if (file == NULL) { - ai->Log("Mod config file %s not found\n", filename); ai->Log("Give up trying to find mod config file (required).\n"); initialized = false; return; } char keyword[50]; - int ival; - float fval; - const UnitDef *def; bool error = false; // bool loaded = false; - if(file) - { - ai->Log("Using mod config file %s\n", filename); - - while(EOF != fscanf(file, "%s", keyword)) - { - if(!strcmp(keyword,"SIDES")) - { - fscanf(file, "%i", &ival); - SIDES = ival; - } - else if(!strcmp(keyword, "START_UNITS")) - { - START_UNITS = new char*[SIDES]; - - for(int i = 0; i < SIDES; i++) - { - START_UNITS[i] = new char[20]; - fscanf(file, "%s", filename); - STRCPY(START_UNITS[i], filename); - - if(!ai->Getcb()->GetUnitDef(START_UNITS[i])) - { - ai->Log("ERROR: loading starting units - could not find unit %s\n", START_UNITS[i]); - error = true; - break; - } - } - } - else if(!strcmp(keyword, "SIDE_NAMES")) - { - SIDE_NAMES = new char*[SIDES]; + if(file == NULL) + return; - for(int i = 0; i < SIDES; i++) - { - SIDE_NAMES[i] = new char[80]; - fscanf(file, "%s", filename); - STRCPY(SIDE_NAMES[i], filename); + while(EOF != fscanf(file, "%s", keyword)) + { + if(!strcmp(keyword,"SIDES")) { + SIDES = GetInt(file); + } + else if(!strcmp(keyword, "START_UNITS")) { + START_UNITS.resize(SIDES); + for(int i = 0; i < SIDES; i++) { + START_UNITS[i] = GetString(file); + if(!GetUnitDef(START_UNITS[i].c_str())) { + error = true; + break; } } - else if(!strcmp(keyword, "SCOUTS")) - { - // get number of scouts - fscanf(file, "%i", &ival); - - for(int i = 0; i < ival; ++i) - { - fscanf(file, "%s", filename); - if(ai->Getcb()->GetUnitDef(filename)) - SCOUTS.push_back(ai->Getcb()->GetUnitDef(filename)->id); - else - { - ai->Log("ERROR: loading scouts - could not find unit %s\n", filename); - error = true; - break; - } + } else if(!strcmp(keyword, "SIDE_NAMES")) { + SIDE_NAMES.resize(SIDES); + for(int i = 0; i < SIDES; i++) { + SIDE_NAMES[i] = GetString(file); + } + } else if(!strcmp(keyword, "SCOUTS")) { + // get number of scouts + const int count = GetInt(file); + for(int i = 0; i < count; ++i) { + const std::string unitdef = GetString(file); + if(GetUnitDef(unitdef)) { + SCOUTS.push_back(GetUnitDef(unitdef)->id); + } else { + error = true; + break; } } - else if(!strcmp(keyword, "ATTACKERS")) - { - // get number of attackers - fscanf(file, "%i", &ival); - - for(int i = 0; i < ival; ++i) - { - fscanf(file, "%s", filename); - if(ai->Getcb()->GetUnitDef(filename)) - ATTACKERS.push_back(ai->Getcb()->GetUnitDef(filename)->id); - else - { - ai->Log("ERROR: loading attackers - could not find unit %s\n", filename); - error = true; - break; - } + } else if(!strcmp(keyword, "ATTACKERS")) { + // get number of attackers + const int count = GetInt(file); + + for(int i = 0; i < count; ++i) { + const std::string unitdef = GetString(file); + if(GetUnitDef(unitdef)) + ATTACKERS.push_back(GetUnitDef(unitdef)->id); + else { + error = true; + break; } } - else if(!strcmp(keyword, "TRANSPORTERS")) - { - // get number of transporters - fscanf(file, "%i", &ival); - - for(int i = 0; i < ival; ++i) - { - fscanf(file, "%s", filename); - if(ai->Getcb()->GetUnitDef(filename)) - TRANSPORTERS.push_back(ai->Getcb()->GetUnitDef(filename)->id); - else - { - ai->Log("ERROR: loading transporters - could not find unit %s\n", filename); - error = true; - break; - } + } else if(!strcmp(keyword, "TRANSPORTERS")) { + // get number of transporters + const int count = GetInt(file); + + for(int i = 0; i < count; ++i) { + const std::string unitdef = GetString(file); + if(GetUnitDef(unitdef)) + TRANSPORTERS.push_back(GetUnitDef(unitdef)->id); + else { + error = true; + break; } } - else if(!strcmp(keyword, "DONT_BUILD")) - { - // get number of units that should not be built - fscanf(file, "%i", &ival); - - for(int i = 0; i < ival; ++i) - { - fscanf(file, "%s", filename); - if(ai->Getcb()->GetUnitDef(filename)) - DONT_BUILD.push_back(ai->Getcb()->GetUnitDef(filename)->id); - else - { - ai->Log("ERROR: loading dont_build units - could not find unit %s\n", filename); - error = true; - break; - } + } else if(!strcmp(keyword, "METAL_MAKERS")) { + // get number of transporters + const int count = GetInt(file); + for(int i = 0; i < count; ++i) { + const std::string unitdef = GetString(file); + if(GetUnitDef(unitdef)) + METAL_MAKERS.push_back(GetUnitDef(unitdef)->id); + else { + error = true; + break; } } - else if(!strcmp(keyword, "COST_MULTIPLIER")) - { - // get the unit def - fscanf(file, "%s", filename); - def = ai->Getcb()->GetUnitDef(filename); - - if(def) - { - fscanf(file, "%f", &fval); - - CostMultiplier temp; - temp.id = def->id; - temp.multiplier = fval; - - cost_multipliers.push_back(temp); - } - else - { - ai->Log("ERROR: could not set cost multiplier - could not find unit %s\n", filename); + } else if(!strcmp(keyword, "DONT_BUILD")) { + // get number of units that should not be built + const int count = GetInt(file); + for(int i = 0; i < count; ++i) { + const std::string unitdef = GetString(file); + if(GetUnitDef(unitdef)) + DONT_BUILD.push_back(GetUnitDef(unitdef)->id); + else { error = true; break; } } - else if(!strcmp(keyword,"SECTOR_SIZE")) - { - fscanf(file, "%f", &fval); - SECTOR_SIZE = fval; - ai->Log("SECTOR_SIZE set to %f", SECTOR_SIZE); - } - else if(!strcmp(keyword,"MIN_ENERGY")) - { - fscanf(file, "%i", &ival); - MIN_ENERGY = ival; - } - else if(!strcmp(keyword, "MAX_UNITS")) - { - fscanf(file, "%i", &ival); - MAX_UNITS = ival; - } - else if(!strcmp(keyword, "MAX_SCOUTS")) - { - fscanf(file, "%i", &ival); - MAX_SCOUTS = ival; - } - else if(!strcmp(keyword, "MAX_SECTOR_IMPORTANCE")) - { - fscanf(file, "%i", &ival); - MAX_SECTOR_IMPORTANCE = ival; - } - else if(!strcmp(keyword, "MAX_XROW")) - { - fscanf(file, "%i", &ival); - MAX_XROW = ival; - } - else if(!strcmp(keyword, "MAX_YROW")) - { - fscanf(file, "%i", &ival); - MAX_YROW = ival; - } - else if(!strcmp(keyword, "X_SPACE")) - { - fscanf(file, "%i", &ival); - X_SPACE = ival; - } - else if(!strcmp(keyword, "Y_SPACE")) - { - fscanf(file, "%i", &ival); - Y_SPACE = ival; - } - else if(!strcmp(keyword, "MAX_GROUP_SIZE")) - { - fscanf(file, "%i", &ival); - MAX_GROUP_SIZE = ival; - } - else if(!strcmp(keyword, "MAX_AIR_GROUP_SIZE")) - { - fscanf(file, "%i", &ival); - MAX_AIR_GROUP_SIZE = ival; - } - else if(!strcmp(keyword, "MAX_NAVAL_GROUP_SIZE")) - { - fscanf(file, "%i", &ival); - MAX_NAVAL_GROUP_SIZE = ival; - } - else if(!strcmp(keyword, "MAX_SUBMARINE_GROUP_SIZE")) - { - fscanf(file, "%i", &ival); - MAX_SUBMARINE_GROUP_SIZE = ival; - } - else if(!strcmp(keyword, "MAX_ANTI_AIR_GROUP_SIZE")) - { - fscanf(file, "%i", &ival); - MAX_ANTI_AIR_GROUP_SIZE = ival; - } - else if(!strcmp(keyword, "MAX_ARTY_GROUP_SIZE")) - { - fscanf(file, "%i", &ival); - MAX_ARTY_GROUP_SIZE = ival; - } - else if(!strcmp(keyword, "UNIT_SPEED_SUBGROUPS")) - { - fscanf(file, "%i", &ival); - UNIT_SPEED_SUBGROUPS = ival; - } - else if(!strcmp(keyword, "FALLBACK_DIST_RATIO")) - { - fscanf(file, "%f", &fval); - FALLBACK_DIST_RATIO = fval; - } - else if(!strcmp(keyword, "MIN_FALLBACK_RANGE")) - { - fscanf(file, "%f", &fval); - MIN_FALLBACK_RANGE = fval; - } - else if(!strcmp(keyword, "MAX_FALLBACK_RANGE")) - { - fscanf(file, "%f", &fval); - MAX_FALLBACK_RANGE = fval; - } - else if(!strcmp(keyword, "MIN_FALLBACK_TURNRATE")) - { - fscanf(file, "%f", &fval); - MIN_FALLBACK_TURNRATE = fval; - } - else if(!strcmp(keyword, "MIN_EFFICIENCY")) - { - fscanf(file, "%f", &fval); - MIN_EFFICIENCY = fval; - } - else if(!strcmp(keyword, "MIN_AIR_SUPPORT_EFFICIENCY")) - { - fscanf(file, "%f", &fval); - MIN_AIR_SUPPORT_EFFICIENCY = fval; - } - else if(!strcmp(keyword, "MAX_BUILDERS")) - { - fscanf(file, "%i", &ival); - MAX_BUILDERS = ival; - } - else if(!strcmp(keyword, "MAX_BUILDQUE_SIZE")) - { - fscanf(file, "%i", &ival); - MAX_BUILDQUE_SIZE = ival; - } - else if(!strcmp(keyword, "MAX_ASSISTANTS")) - { - fscanf(file, "%i", &ival); - MAX_ASSISTANTS = ival; - } - else if(!strcmp(keyword, "MIN_ASSISTANCE_BUILDSPEED")) - { - fscanf(file, "%i", &ival); - MIN_ASSISTANCE_BUILDSPEED = ival; - } - else if(!strcmp(keyword, "MAX_BASE_SIZE")) - { - fscanf(file, "%i", &ival); - MAX_BASE_SIZE = ival; - } - else if(!strcmp(keyword, "MAX_AIR_TARGETS")) - { - fscanf(file, "%i", &ival); - MAX_AIR_TARGETS = ival; - } - else if(!strcmp(keyword, "MIN_AIR_ATTACK_COST")) - { - fscanf(file, "%i", &ival); - MIN_AIR_ATTACK_COST = ival; - } - else if(!strcmp(keyword, "SCOUT_SPEED")) - { - fscanf(file, "%f", &fval); - SCOUT_SPEED = fval; - } - else if(!strcmp(keyword, "GROUND_ARTY_RANGE")) - { - fscanf(file, "%f", &fval); - GROUND_ARTY_RANGE = fval; - } - else if(!strcmp(keyword, "SEA_ARTY_RANGE")) - { - fscanf(file, "%f", &fval); - SEA_ARTY_RANGE = fval; - } - else if(!strcmp(keyword, "HOVER_ARTY_RANGE")) - { - fscanf(file, "%f", &fval); - HOVER_ARTY_RANGE = fval; - } - else if(!strcmp(keyword, "STATIONARY_ARTY_RANGE")) - { - fscanf(file, "%f", &fval); - STATIONARY_ARTY_RANGE = fval; - } - else if(!strcmp(keyword, "MAX_BUILDERS_PER_TYPE")) - { - fscanf(file, "%i", &ival); - MAX_BUILDERS_PER_TYPE = ival; - } - else if(!strcmp(keyword, "MAX_FACTORIES_PER_TYPE")) - { - fscanf(file, "%i", &ival); - MAX_FACTORIES_PER_TYPE = ival; - } - else if(!strcmp(keyword, "MIN_ASSISTANCE_BUILDTIME")) - { - fscanf(file, "%i", &ival); - MIN_ASSISTANCE_BUILDTIME = ival; - } - else if(!strcmp(keyword, "AIR_DEFENCE")) - { - fscanf(file, "%i", &ival); - AIR_DEFENCE = ival; - } - else if(!strcmp(keyword, "AIRCRAFT_RATE")) - { - fscanf(file, "%i", &ival); - AIRCRAFT_RATE = ival; - } - else if(!strcmp(keyword, "HIGH_RANGE_UNITS_RATE")) - { - fscanf(file, "%i", &ival); - HIGH_RANGE_UNITS_RATE = ival; - } - else if(!strcmp(keyword, "FAST_UNITS_RATE")) - { - fscanf(file, "%i", &ival); - FAST_UNITS_RATE = ival; - } - else if(!strcmp(keyword, "MAX_METAL_COST")) - { - fscanf(file, "%i", &ival); - MAX_METAL_COST = ival; - } - else if(!strcmp(keyword, "MAX_DEFENCES")) - { - fscanf(file, "%i", &ival); - MAX_DEFENCES = ival; - } - else if(!strcmp(keyword, "MIN_SECTOR_THREAT")) - { - fscanf(file, "%f", &fval); - MIN_SECTOR_THREAT = fval; - } - else if(!strcmp(keyword, "MAX_STAT_ARTY")) - { - fscanf(file, "%i", &ival); - MAX_STAT_ARTY = ival; - } - else if(!strcmp(keyword, "MAX_AIR_BASE")) - { - fscanf(file, "%i", &ival); - MAX_AIR_BASE = ival; - } - else if(!strcmp(keyword, "AIR_ONLY_MOD")) - { - fscanf(file, "%i", &ival); - AIR_ONLY_MOD = (bool)ival; - } - else if(!strcmp(keyword, "METAL_ENERGY_RATIO")) - { - fscanf(file, "%f", &fval); - METAL_ENERGY_RATIO = fval; - } - else if(!strcmp(keyword, "NON_AMPHIB_MAX_WATERDEPTH")) - { - fscanf(file, "%f", &fval); - NON_AMPHIB_MAX_WATERDEPTH = fval; - } - else if(!strcmp(keyword, "MAX_METAL_MAKERS")) - { - fscanf(file, "%i", &ival); - MAX_METAL_MAKERS = ival; - } - else if(!strcmp(keyword, "MAX_STORAGE")) - { - fscanf(file, "%i", &ival); - MAX_STORAGE = ival; - } - else if(!strcmp(keyword, "MIN_METAL_MAKER_ENERGY")) - { - fscanf(file, "%f", &fval); - MIN_METAL_MAKER_ENERGY = fval; - } - else if(!strcmp(keyword, "MAX_MEX_DISTANCE")) - { - fscanf(file, "%i", &ival); - MAX_MEX_DISTANCE = ival; - } - else if(!strcmp(keyword, "MAX_MEX_DEFENCE_DISTANCE")) - { - fscanf(file, "%i", &ival); - MAX_MEX_DEFENCE_DISTANCE = ival; - } - else if(!strcmp(keyword, "MIN_FACTORIES_FOR_DEFENCES")) - { - fscanf(file, "%i", &ival); - MIN_FACTORIES_FOR_DEFENCES = ival; - } - else if(!strcmp(keyword, "MIN_FACTORIES_FOR_STORAGE")) - { - fscanf(file, "%i", &ival); - MIN_FACTORIES_FOR_STORAGE = ival; - } - else if(!strcmp(keyword, "MIN_FACTORIES_FOR_RADAR_JAMMER")) - { - fscanf(file, "%i", &ival); - MIN_FACTORIES_FOR_RADAR_JAMMER = ival; - } - else if(!strcmp(keyword, "MIN_SUBMARINE_WATERLINE")) - { - fscanf(file, "%i", &ival); - MIN_SUBMARINE_WATERLINE = ival; - } - else if(!strcmp(keyword, "MAX_ATTACKS")) - { - fscanf(file, "%i", &ival); - MAX_ATTACKS = ival; - } - else - { + } else if(!strcmp(keyword, "COST_MULTIPLIER")) { + // get the unit def + const std::string unitdef = GetString(file); + const UnitDef* def = GetUnitDef(unitdef); + + if(def) + { + CostMultiplier temp; + temp.id = def->id; + temp.multiplier = GetFloat(file); + + cost_multipliers.push_back(temp); + } else { error = true; break; } + } else if(!strcmp(keyword,"SECTOR_SIZE")) { + SECTOR_SIZE = GetFloat(file); + ai->Log("SECTOR_SIZE set to %f", SECTOR_SIZE); + } else if(!strcmp(keyword,"MIN_ENERGY")) { + MIN_ENERGY = GetInt(file); + } else if(!strcmp(keyword, "MAX_UNITS")) { + MAX_UNITS = GetInt(file); + } else if(!strcmp(keyword, "MAX_SCOUTS")) { + MAX_SCOUTS = GetInt(file); + } else if(!strcmp(keyword, "MAX_SECTOR_IMPORTANCE")) { + MAX_SECTOR_IMPORTANCE = GetInt(file); + } else if(!strcmp(keyword, "MAX_XROW")) { + MAX_XROW = GetInt(file); + } else if(!strcmp(keyword, "MAX_YROW")) { + MAX_YROW = GetInt(file); + } else if(!strcmp(keyword, "X_SPACE")) { + X_SPACE = GetInt(file); + } else if(!strcmp(keyword, "Y_SPACE")) { + Y_SPACE = GetInt(file); + } else if(!strcmp(keyword, "MAX_GROUP_SIZE")) { + MAX_GROUP_SIZE = GetInt(file); + } else if(!strcmp(keyword, "MAX_AIR_GROUP_SIZE")) { + MAX_AIR_GROUP_SIZE = GetInt(file); + } else if(!strcmp(keyword, "MAX_NAVAL_GROUP_SIZE")) { + MAX_NAVAL_GROUP_SIZE = GetInt(file); + } else if(!strcmp(keyword, "MAX_SUBMARINE_GROUP_SIZE")) { + MAX_SUBMARINE_GROUP_SIZE = GetInt(file); + } else if(!strcmp(keyword, "MAX_ANTI_AIR_GROUP_SIZE")) { + MAX_ANTI_AIR_GROUP_SIZE = GetInt(file); + } else if(!strcmp(keyword, "MAX_ARTY_GROUP_SIZE")) { + MAX_ARTY_GROUP_SIZE = GetInt(file); + } else if(!strcmp(keyword, "UNIT_SPEED_SUBGROUPS")) { + UNIT_SPEED_SUBGROUPS = GetInt(file); + } else if(!strcmp(keyword, "FALLBACK_DIST_RATIO")) { + FALLBACK_DIST_RATIO = GetInt(file); + } else if(!strcmp(keyword, "MIN_FALLBACK_RANGE")) { + MIN_FALLBACK_RANGE = GetInt(file); + } else if(!strcmp(keyword, "MAX_FALLBACK_RANGE")) { + MAX_FALLBACK_RANGE = GetInt(file); + } else if(!strcmp(keyword, "MIN_FALLBACK_TURNRATE")) { + MIN_FALLBACK_TURNRATE = GetFloat(file); + } else if(!strcmp(keyword, "MIN_EFFICIENCY")) { + MIN_EFFICIENCY = GetFloat(file); + } else if(!strcmp(keyword, "MIN_AIR_SUPPORT_EFFICIENCY")) { + MIN_AIR_SUPPORT_EFFICIENCY = GetFloat(file); + } else if(!strcmp(keyword, "MAX_BUILDERS")) { + MAX_BUILDERS = GetInt(file); + } else if(!strcmp(keyword, "MAX_BUILDQUE_SIZE")) { + MAX_BUILDQUE_SIZE = GetInt(file); + } else if(!strcmp(keyword, "MAX_ASSISTANTS")) { + MAX_ASSISTANTS = GetInt(file); + } else if(!strcmp(keyword, "MIN_ASSISTANCE_BUILDSPEED")) { + MIN_ASSISTANCE_BUILDSPEED = GetInt(file); + } else if(!strcmp(keyword, "MAX_BASE_SIZE")) { + MAX_BASE_SIZE = GetInt(file); + } else if(!strcmp(keyword, "MAX_AIR_TARGETS")) { + MAX_AIR_TARGETS = GetInt(file); + } else if(!strcmp(keyword, "MIN_AIR_ATTACK_COST")) { + MIN_AIR_ATTACK_COST = GetInt(file); + } else if(!strcmp(keyword, "SCOUT_SPEED")) { + SCOUT_SPEED = GetFloat(file); + } else if(!strcmp(keyword, "GROUND_ARTY_RANGE")) { + GROUND_ARTY_RANGE = GetInt(file); + } else if(!strcmp(keyword, "SEA_ARTY_RANGE")) { + SEA_ARTY_RANGE = GetFloat(file); + } else if(!strcmp(keyword, "HOVER_ARTY_RANGE")) { + HOVER_ARTY_RANGE = GetFloat(file); + } else if(!strcmp(keyword, "STATIONARY_ARTY_RANGE")) { + STATIONARY_ARTY_RANGE = GetFloat(file); + } else if(!strcmp(keyword, "MAX_BUILDERS_PER_TYPE")) { + MAX_BUILDERS_PER_TYPE = GetInt(file); + } else if(!strcmp(keyword, "MAX_FACTORIES_PER_TYPE")) { + MAX_FACTORIES_PER_TYPE = GetInt(file); + } else if(!strcmp(keyword, "MIN_ASSISTANCE_BUILDTIME")) { + MIN_ASSISTANCE_BUILDTIME = GetInt(file); + } else if(!strcmp(keyword, "AIR_DEFENCE")) { + AIR_DEFENCE = GetInt(file); + } else if(!strcmp(keyword, "AIRCRAFT_RATE")) { + AIRCRAFT_RATE = GetInt(file); + } else if(!strcmp(keyword, "HIGH_RANGE_UNITS_RATE")) { + HIGH_RANGE_UNITS_RATE = GetInt(file); + } else if(!strcmp(keyword, "FAST_UNITS_RATE")) { + FAST_UNITS_RATE = GetInt(file); + } else if(!strcmp(keyword, "MAX_METAL_COST")) { + MAX_METAL_COST = GetInt(file); + } else if(!strcmp(keyword, "MAX_DEFENCES")) { + MAX_DEFENCES = GetInt(file); + } else if(!strcmp(keyword, "MIN_SECTOR_THREAT")) { + MIN_SECTOR_THREAT = GetFloat(file); + } else if(!strcmp(keyword, "MAX_STAT_ARTY")) { + MAX_STAT_ARTY = GetInt(file); + } else if(!strcmp(keyword, "MAX_AIR_BASE")) { + MAX_AIR_BASE = GetInt(file); + } else if(!strcmp(keyword, "AIR_ONLY_MOD")) { + AIR_ONLY_MOD = (bool)GetInt(file); + } else if(!strcmp(keyword, "METAL_ENERGY_RATIO")) { + METAL_ENERGY_RATIO = GetFloat(file); + } else if(!strcmp(keyword, "NON_AMPHIB_MAX_WATERDEPTH")) { + NON_AMPHIB_MAX_WATERDEPTH = GetFloat(file); + } else if(!strcmp(keyword, "MAX_METAL_MAKERS")) { + MAX_METAL_MAKERS = GetInt(file); + } else if(!strcmp(keyword, "MAX_STORAGE")) { + MAX_STORAGE = GetInt(file); + } else if(!strcmp(keyword, "MIN_METAL_MAKER_ENERGY")) { + MIN_METAL_MAKER_ENERGY = GetFloat(file); + } else if(!strcmp(keyword, "MAX_MEX_DISTANCE")) { + MAX_MEX_DISTANCE = GetInt(file); + } else if(!strcmp(keyword, "MAX_MEX_DEFENCE_DISTANCE")) { + MAX_MEX_DEFENCE_DISTANCE = GetInt(file); + } else if(!strcmp(keyword, "MIN_FACTORIES_FOR_DEFENCES")) { + MIN_FACTORIES_FOR_DEFENCES = GetInt(file); + } else if(!strcmp(keyword, "MIN_FACTORIES_FOR_STORAGE")) { + MIN_FACTORIES_FOR_STORAGE = GetInt(file); + } else if(!strcmp(keyword, "MIN_FACTORIES_FOR_RADAR_JAMMER")) { + MIN_FACTORIES_FOR_RADAR_JAMMER = GetInt(file); + } else if(!strcmp(keyword, "MIN_SUBMARINE_WATERLINE")) { + MIN_SUBMARINE_WATERLINE = GetInt(file); + } else if(!strcmp(keyword, "MAX_ATTACKS")) { + MAX_ATTACKS = GetInt(file); + } else { + error = true; + break; } + } - if(error) - { - ai->Log("Mod config file %s contains erroneous keyword %s\n", filename, keyword); - initialized = false; - return; - } - else - { -// loaded = true; - fclose(file); - ai->Log("Mod config file loaded\n"); - } + if(error) { + ai->Log("Mod config file %s contains erroneous keyword: %s\n", configfile.c_str(), keyword); + initialized = false; + return; } + fclose(file); + ai->Log("Mod config file %s loaded\n", configfile.c_str()); // load general settings - STRCPY_T(buffer, sizeof(buffer), MAIN_PATH); - STRCAT_T(buffer, sizeof(buffer), GENERAL_CFG_FILE); - ReplaceExtension(buffer, filename, sizeof(filename), ".cfg"); - ai->Getcb()->GetValue(AIVAL_LOCATE_FILE_R, filename); - file = fopen(filename, "r"); + const std::string generalcfg = GetFileName(GENERAL_CFG_FILE, CFG_PATH); + file = fopen(generalcfg.c_str(), "r"); + if(file == NULL) { + ai->Log("Couldn't load general config file %s\n", generalcfg.c_str()); + return; + } - if(file) + while(EOF != fscanf(file, "%s", keyword)) { - while(EOF != fscanf(file, "%s", keyword)) - { - if(!strcmp(keyword, "LEARN_RATE")) - { - fscanf(file, "%i", &ival); - LEARN_RATE = ival; - } - else if(!strcmp(keyword, "LEARN_SPEED")) - { - fscanf(file, "%f", &fval); - LEARN_SPEED = fval; - } - else if(!strcmp(keyword, "WATER_MAP_RATIO")) - { - fscanf(file, "%f", &fval); - WATER_MAP_RATIO = fval; - } - else if(!strcmp(keyword, "LAND_WATER_MAP_RATIO")) - { - fscanf(file, "%f", &fval); - LAND_WATER_MAP_RATIO = fval; - } - else if(!strcmp(keyword, "SCOUT_UPDATE_FREQUENCY")) - { - fscanf(file, "%i", &ival); - SCOUT_UPDATE_FREQUENCY = ival; - } - else if(!strcmp(keyword, "SCOUTING_MEMORY_FACTOR")) - { - fscanf(file, "%f", &fval); - SCOUTING_MEMORY_FACTOR = fval; - } - else - { - error = true; - break; - } + if(!strcmp(keyword, "LEARN_RATE")) { + LEARN_RATE = GetInt(file); + } else if(!strcmp(keyword, "LEARN_SPEED")) { + LEARN_SPEED = GetFloat(file); + } else if(!strcmp(keyword, "WATER_MAP_RATIO")) { + WATER_MAP_RATIO = GetFloat(file); + } else if(!strcmp(keyword, "LAND_WATER_MAP_RATIO")) { + LAND_WATER_MAP_RATIO = GetFloat(file); + } else if(!strcmp(keyword, "SCOUT_UPDATE_FREQUENCY")) { + SCOUT_UPDATE_FREQUENCY = GetInt(file);; + } else if(!strcmp(keyword, "SCOUTING_MEMORY_FACTOR")) { + SCOUTING_MEMORY_FACTOR = GetFloat(file); + } else { + error = true; + break; } + } - fclose(file); + fclose(file); - if(error) - { - ai->Log("General config file %s contains erroneous keyword %s\n", filename, keyword); - initialized = false; - return; - } + if(error) { + ai->Log("General config file contains erroneous keyword %s\n", keyword); + return; + } + ai->Log("General config file loaded\n"); + initialized = true; +} - else - { - ai->Log("General config file loaded\n"); - initialized = true; - return; - } +const UnitDef* AAIConfig::GetUnitDef(const std::string& name) +{ + const UnitDef* res = ai->Getcb()->GetUnitDef(name.c_str()); + if (res == NULL) { + ai->Log("ERROR: loading unit - could not find unit %s\n", name.c_str()); } - else - { - ai->Log("General config file %s not found\n", filename); - initialized = false; - return; + return res; +} + +std::string AAIConfig::getUniqueName(bool game, bool gamehash, bool map, bool maphash) const +{ + std::string res; + if (map) { + if (!res.empty()) + res += "-"; + std::string mapName = MakeFileSystemCompatible(ai->Getcb()->GetMapName()); + mapName.resize(mapName.size() - 4); // cut off extension + res += mapName; + } + if (maphash) { + if (!res.empty()) + res += "-"; + res += IntToString(ai->Getcb()->GetMapHash(), "%x"); + } + if (game) { + if (!res.empty()) + res += "_"; + res += MakeFileSystemCompatible(ai->Getcb()->GetModHumanName()); + } + if (gamehash) { + if (!res.empty()) + res += "-"; + res += IntToString(ai->Getcb()->GetModHash(), "%x"); } + return res; } AAIConfig *cfg = new AAIConfig(); diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIConfig.h spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIConfig.h --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIConfig.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIConfig.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,8 @@ // Released under GPL license: see LICENSE.html for more information. // ------------------------------------------------------------------------- -#pragma once +#ifndef AAI_CONFIG_H +#define AAI_CONFIG_H #include "LegacyCpp/IAICallback.h" @@ -20,6 +21,11 @@ using std::vector; class AAI; +namespace springLegacyAI { + struct UnitDef; +} + +using namespace springLegacyAI; struct CostMultiplier { @@ -27,11 +33,13 @@ float multiplier; }; +/// Converts a string to one that can be used in a file name (eg. "Abc.123 $%^*" -> "Abc.123_____") +std::string MakeFileSystemCompatible(const std::string& str); + class AAIConfig { public: AAIConfig(void); - ~AAIConfig(void); void LoadConfig(AAI *ai); @@ -55,20 +63,18 @@ int MAX_ANTI_AIR_GROUP_SIZE; int MAX_ARTY_GROUP_SIZE; float MIN_EFFICIENCY; - int MAX_BUILDERS; + int MAX_BUILDERS_PER_TYPE; // max builders of same unit type int MAX_FACTORIES_PER_TYPE; int MAX_BUILDQUE_SIZE; int MAX_ASSISTANTS; int MIN_ASSISTANCE_BUILDTIME; - int MIN_ASSISTANCE_BUILDSPEED; int MAX_BASE_SIZE; float SCOUT_SPEED; float GROUND_ARTY_RANGE; float SEA_ARTY_RANGE; float HOVER_ARTY_RANGE; float STATIONARY_ARTY_RANGE; - int AIR_DEFENCE; int AIRCRAFT_RATE; int HIGH_RANGE_UNITS_RATE; int FAST_UNITS_RATE; @@ -76,47 +82,36 @@ int MIN_ENERGY_STORAGE; int MIN_METAL_STORAGE; int MAX_METAL_COST; - int MIN_AIR_ATTACK_COST; int MAX_AIR_TARGETS; - char **START_UNITS; - char **SIDE_NAMES; + std::vector START_UNITS; + std::vector SIDE_NAMES; list SCOUTS; list ATTACKERS; list TRANSPORTERS; + list METAL_MAKERS; list DONT_BUILD; //float KBOT_MAX_SLOPE; //float VEHICLE_MAX_SLOPE; //float HOVER_MAX_SLOPE; float NON_AMPHIB_MAX_WATERDEPTH; - float SHIP_MIN_WATERDEPTH; - float METAL_ENERGY_RATIO; int MAX_DEFENCES; - float MIN_SECTOR_THREAT; int MAX_STAT_ARTY; int MAX_AIR_BASE; bool AIR_ONLY_MOD; int MAX_STORAGE; - int MAX_METAL_MAKERS; int MAX_MEX_DISTANCE; int MAX_MEX_DEFENCE_DISTANCE; - int MAX_MEX_DEFENCE_COST; float MIN_METAL_MAKER_ENERGY; int MIN_FACTORIES_FOR_DEFENCES; int MIN_FACTORIES_FOR_STORAGE; - int MIN_FACTORIES_FOR_RADAR_JAMMER; float MIN_AIR_SUPPORT_EFFICIENCY; int UNIT_SPEED_SUBGROUPS; float MAX_COST_LIGHT_ASSAULT; float MAX_COST_MEDIUM_ASSAULT; float MAX_COST_HEAVY_ASSAULT; - float LIGHT_ASSAULT_RATIO; - float MEDIUM_ASSAULT_RATIO; - float HEAVY_ASSAULT_RATIO; - float SUPER_HEAVY_ASSAULT_RATIO; - int MIN_SUBMARINE_WATERLINE; int MAX_ATTACKS; vector cost_multipliers; @@ -129,7 +124,6 @@ // internal float CLIFF_SLOPE; // cells with greater slope will be considered to be cliffs - int CONSTRUCTION_TIMEOUT; int MAX_SECTOR_IMPORTANCE; // game specific @@ -137,7 +131,47 @@ float SCOUTING_MEMORY_FACTOR; float LEARN_SPEED; int LEARN_RATE; + int GAME_PERIODS; + + /** + * open a file in springs data directory + * @param filename relative path of the file in the spring data dir + * @param mode mode file to open, see manpage of fopen + */ + std::string GetFileName(const std::string& filename, const std::string& prefix = "", const std::string& suffix = "", bool write = false) const; + std::string getUniqueName(bool game, bool gamehash, bool map, bool maphash) const; + +private: + ~AAIConfig(void); + + const UnitDef* GetUnitDef(const std::string& name); + int GetInt(FILE* file); + float GetFloat(FILE* file); + std::string GetString(FILE* file); + + AAI *ai; + int CONSTRUCTION_TIMEOUT; float WATER_MAP_RATIO; float LAND_WATER_MAP_RATIO; - int GAME_PERIODS; + float LIGHT_ASSAULT_RATIO; + int MIN_FACTORIES_FOR_RADAR_JAMMER; +// int MAX_MEX_DEFENCE_COST; + int MAX_METAL_MAKERS; + float MIN_SECTOR_THREAT; +// float SHIP_MIN_WATERDEPTH; + int MIN_AIR_ATTACK_COST; + int MAX_BUILDERS; + int MIN_ASSISTANCE_BUILDSPEED; + int AIR_DEFENCE; + float MEDIUM_ASSAULT_RATIO; + float HEAVY_ASSAULT_RATIO; + float SUPER_HEAVY_ASSAULT_RATIO; + int MIN_SUBMARINE_WATERLINE; + }; + +extern AAIConfig *cfg; + + +#endif + diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIConstructor.cpp spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIConstructor.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIConstructor.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIConstructor.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,8 +1,28 @@ +// ------------------------------------------------------------------------- +// AAI +// +// A skirmish AI for the Spring engine. +// Copyright Alexander Seizinger +// +// Released under GPL license: see LICENSE.html for more information. +// ------------------------------------------------------------------------- + +#include -#include "aidef.h" #include "AAI.h" #include "AAIConstructor.h" #include "AAIBuildTask.h" +#include "AAIExecute.h" +#include "AAIBuildTable.h" +#include "AAIUnitTable.h" +#include "AAIConfig.h" +#include "AAIMap.h" +#include "AAISector.h" + +#include "LegacyCpp/UnitDef.h" +#include "LegacyCpp/CommandQueue.h" +using namespace springLegacyAI; + AAIConstructor::AAIConstructor(AAI *ai, int unit_id, int def_id, bool factory, bool builder, bool assistant) { diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIConstructor.h spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIConstructor.h --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIConstructor.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIConstructor.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,8 @@ // Released under GPL license: see LICENSE.html for more information. // ------------------------------------------------------------------------- -#pragma once +#ifndef AAI_CONSTRUCTOR_H +#define AAI_CONSTRUCTOR_H #include "aidef.h" @@ -15,6 +16,9 @@ class AAIBuildTable; class AAIBuildTask; +#include +using namespace std; + class AAIConstructor { public: @@ -23,33 +27,21 @@ void Update(); - bool IsBusy(); - void Idle(); // checks if assisting builders needed void CheckAssistance(); - // gets the total buildtime of all units in the buildque of the factory - double GetMyQueBuildtime(); // stops all assisters from assisting this unit void ReleaseAllAssistants(); - // stops this unit from assisting another builder/factory void StopAssisting(); - // removes an assisting con unit - void RemoveAssitant(int unit_id); - void ConstructionFinished(); - void ConstructionFailed(); - void GiveConstructionOrder(int id_building, float3 pos, bool water); - void AssistConstruction(int constructor, int target_unit = -1); - // continue with construction after original builder has been killed void TakeOverConstruction(AAIBuildTask *build_task); @@ -65,7 +57,6 @@ bool factory; // can build units bool builder; // can build buildings bool assistant; // can assists construction (nanotowers, fark, etc.) - bool resurrect; // can resurrect // ids of the construction unit int unit_id; @@ -76,23 +67,26 @@ int construction_def_id; int construction_unit_id; UnitCategory construction_category; - // current task (idle, building, assisting) UnitTask task; // zero vector if none float3 build_pos; - // id of the unit, the builder currently assists (-1 if none) int assistance; - // assistant builders set assistants; // pointer to possible buildtask AAIBuildTask *build_task; - private: + // removes an assisting con unit + void RemoveAssitant(int unit_id); + // gets the total buildtime of all units in the buildque of the factory + double GetMyQueBuildtime(); + bool IsBusy(); + +// bool resurrect; // can resurrect AAI *ai; // engine tick the build order had been given int order_tick; @@ -100,3 +94,6 @@ list *buildque; }; + +#endif + diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAI.cpp spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAI.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAI.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAI.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,12 +7,33 @@ // Released under GPL license: see LICENSE.html for more information. // ------------------------------------------------------------------------- -#include #include -#include #include +#include #include "AAI.h" +#include "AAIBuildTable.h" +#include "AAIAirForceManager.h" +#include "AAIExecute.h" +#include "AAIUnitTable.h" +#include "AAIBuildTask.h" +#include "AAIBrain.h" +#include "AAIConstructor.h" +#include "AAIAttackManager.h" +#include "AIExport.h" +#include "AAIConfig.h" +#include "AAIMap.h" +#include "AAIGroup.h" +#include "AAISector.h" + + +#include "System/Util.h" + +#include "LegacyCpp/IGlobalAICallback.h" +#include "LegacyCpp/UnitDef.h" +using namespace springLegacyAI; + + #include "CUtils/SimpleProfiler.h" #define AAI_SCOPED_TIMER(part) SCOPED_TIMER(part, profiler); @@ -146,7 +167,7 @@ SNPRINTF(team_number, 3, "%d", team); - STRCPY(buffer, MAIN_PATH); + STRCPY(buffer, ""); STRCAT(buffer, AILOG_PATH); STRCAT(buffer, "AAI_log_team_"); STRCAT(buffer, team_number); diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIExecute.cpp spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIExecute.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIExecute.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIExecute.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,9 +7,23 @@ // Released under GPL license: see LICENSE.html for more information. // ------------------------------------------------------------------------- + +#include "AAI.h" #include "AAIExecute.h" #include "AAIBuildTable.h" -#include "System/FastMath.h" +#include "AAIBrain.h" +#include "AAIUnitTable.h" +#include "AAIConstructor.h" +#include "AAIBuildTask.h" +#include "AAIConfig.h" +#include "AAIMap.h" +#include "AAIGroup.h" +#include "AAISector.h" + +#include "LegacyCpp/UnitDef.h" +#include "LegacyCpp/CommandQueue.h" +using namespace springLegacyAI; + // all the static vars float AAIExecute::current = 0.5; @@ -49,8 +63,6 @@ } counter = 0; - - srand( time(NULL) ); } AAIExecute::~AAIExecute(void) @@ -396,7 +408,7 @@ float power = 0; // get ground power of all ground assault units - for(list::iterator group = ai->Getgroup_list()[GROUND_ASSAULT].begin(); group != ai->Getgroup_list()[GROUND_ASSAULT].end(); group++) + for(list::iterator group = ai->Getgroup_list()[GROUND_ASSAULT].begin(); group != ai->Getgroup_list()[GROUND_ASSAULT].end(); ++group) power += (*group)->GetCombatPowerVsCategory(0); return power; @@ -406,7 +418,7 @@ { float power = 0; - for(list::iterator group = ai->Getgroup_list()[GROUND_ASSAULT].begin(); group != ai->Getgroup_list()[GROUND_ASSAULT].end(); group++) + for(list::iterator group = ai->Getgroup_list()[GROUND_ASSAULT].begin(); group != ai->Getgroup_list()[GROUND_ASSAULT].end(); ++group) { power += (*group)->GetCombatPowerVsCategory(1); } @@ -1075,7 +1087,7 @@ ai->Getbrain()->sectors[0].sort(least_dangerous); - for(list::iterator sector = ai->Getbrain()->sectors[0].begin(); sector != ai->Getbrain()->sectors[0].end(); sector++) + for(list::iterator sector = ai->Getbrain()->sectors[0].begin(); sector != ai->Getbrain()->sectors[0].end(); ++sector) { if((*sector)->water_ratio < 0.15) { @@ -1200,7 +1212,7 @@ // urgency < 4 // float urgency = 16.0 / (ai->Getut()->activeUnits[METAL_MAKER] + ai->Getut()->futureUnits[METAL_MAKER] + 4); - for(list::iterator sector = ai->Getbrain()->sectors[0].begin(); sector != ai->Getbrain()->sectors[0].end(); sector++) + for(list::iterator sector = ai->Getbrain()->sectors[0].begin(); sector != ai->Getbrain()->sectors[0].end(); ++sector) { if((*sector)->water_ratio < 0.15) { @@ -1312,7 +1324,7 @@ AAIConstructor *builder; float3 pos; - for(list::iterator sector = ai->Getbrain()->sectors[0].begin(); sector != ai->Getbrain()->sectors[0].end(); sector++) + for(list::iterator sector = ai->Getbrain()->sectors[0].begin(); sector != ai->Getbrain()->sectors[0].end(); ++sector) { if((*sector)->water_ratio < 0.15) { @@ -2371,7 +2383,7 @@ // try to disbale some metal makers if((ai->Getut()->activeUnits[METAL_MAKER] - disabledMMakers) > 0) { - for(set::iterator maker = ai->Getut()->metal_makers.begin(); maker != ai->Getut()->metal_makers.end(); maker++) + for(set::iterator maker = ai->Getut()->metal_makers.begin(); maker != ai->Getut()->metal_makers.end(); ++maker) { if(ai->Getcb()->IsUnitActivated(*maker)) { @@ -2391,7 +2403,7 @@ // try to enable some metal makers else if(averageEnergySurplus > cfg->MIN_METAL_MAKER_ENERGY && disabledMMakers > 0) { - for(set::iterator maker = ai->Getut()->metal_makers.begin(); maker != ai->Getut()->metal_makers.end(); maker++) + for(set::iterator maker = ai->Getut()->metal_makers.begin(); maker != ai->Getut()->metal_makers.end(); ++maker) { if(!ai->Getcb()->IsUnitActivated(*maker)) { diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIExecute.h spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIExecute.h --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIExecute.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIExecute.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,17 +7,24 @@ // Released under GPL license: see LICENSE.html for more information. // ------------------------------------------------------------------------- -#pragma once +#ifndef AAI_EXECUTE_H +#define AAI_EXECUTE_H -#include "AAI.h" #include "aidef.h" -#include "AAIGroup.h" + +namespace springLegacyAI { + struct UnitDef; +} +using namespace springLegacyAI; + +enum BuildOrderStatus {BUILDORDER_FAILED, BUILDORDER_NOBUILDPOS, BUILDORDER_NOBUILDER, BUILDORDER_SUCCESFUL}; class AAI; class AAIBuildTable; class AAIBrain; class AAIMap; class AAIUnitTable; +class AAISector; class AAIExecute { @@ -30,16 +37,10 @@ // return true if building will be placed at a valid pos = inside sectors bool InitBuildingAt(const UnitDef *def, float3 *pos, bool water); - void ConstructBuildingAt(int building, int builder, float3 position); - void CreateBuildTask(int unit, const UnitDef *def, float3 *pos); void MoveUnitTo(int unit, float3 *position); - void stopUnit(int unit); - - bool IsBusy(int unit); - void AddUnitToGroup(int unit_id, int def_id, UnitCategory category); void BuildScouts(); @@ -55,10 +56,6 @@ // checks if ressources are sufficient and orders construction of new buildings void CheckRessources(); - float GetEnergyUrgency(); - float GetMetalUrgency(); - float GetEnergyStorageUrgency(); - float GetMetalStorageUrgency(); // checks if buildings of that type could be replaced with more efficient one (e.g. mex -> moho) void CheckMexUpgrade(); @@ -82,17 +79,8 @@ void CheckDefences(); // builds all kind of buildings - bool BuildFactory(); - bool BuildDefences(); + // void BuildUnit(UnitCategory category, float speed, float cost, float range, float power, float ground_eff, float air_eff, float hover_eff, float sea_eff, float submarine_eff, float stat_eff, float eff, bool urgent); - bool BuildRadar(); - bool BuildJammer(); - bool BuildExtractor(); - bool BuildMetalMaker(); - bool BuildStorage(); - bool BuildPowerPlant(); - bool BuildArty(); - bool BuildAirBase(); // called when building has been finished / contruction failed void ConstructionFailed(float3 build_pos, int def_id); @@ -107,15 +95,10 @@ void CheckFallBack(int unit_id, int def_id); - // tries to build a defence building vs category in the specified sector - // returns BUILDORDER_SUCCESFUL if succesful - BuildOrderStatus BuildStationaryDefenceVS(UnitCategory category, AAISector *dest); // tries to call support vs air (returns true if succesful) void DefendUnitVS(int unit, unsigned int enemy_movement_type, float3 *enemy_pos, int importance); - // returns true if successfully assisting construction - bool AssistConstructionOfCategory(UnitCategory category, int importance = 5); // adds a unit to the correct wishlist bool AddUnitToBuildqueue(int def_id, int number, bool urgent); @@ -123,31 +106,40 @@ // returns buildque for a certain factory list* GetBuildqueueOfFactory(int def_id); - // returns the the total ground offensive power of all units - float GetTotalGroundPower(); - // returns the the total air defence power of all units - float GetTotalAirPower(); + float3 GetRallyPoint(unsigned int unit_movement_type, int continent_id, int min_dist, int max_dist); + float3 GetUnitBuildsite(int builder, int unit); - // chooses a starting sector close to specified sector - void ChooseDifferentStartingSector(int x, int y); + int unitProductionRate; - // returns closest (taking into account movement speed) group with units of specified unit type that may reach the location - AAIGroup* GetClosestGroupForDefence(UnitType group_type, float3 *pos, int continent, int importance); + // ressource management + // tells ai, how many times additional metal/energy has been requested + float futureRequestedMetal; + float futureRequestedEnergy; + float futureAvailableMetal; + float futureAvailableEnergy; + float futureStoredMetal; + float futureStoredEnergy; + float averageMetalSurplus; + float averageEnergySurplus; + int disabledMMakers; - float3 GetRallyPoint(unsigned int unit_movement_type, int continent_id, int min_dist, int max_dist); - float3 GetRallyPointCloseTo(UnitCategory category, unsigned int unit_movement_type, int continent_id, float3 pos, int min_dist, int max_dist); - float3 GetBuildsite(int builder, int building, UnitCategory category); - float3 GetUnitBuildsite(int builder, int unit); + // urgency of construction of building of the different categories + float urgency[METAL_MAKER+1]; - void InitBuildques(); + // sector where next def vs category needs to be built (0 if none) + + // debug + void GiveOrder(Command *c, int unit, const char *owner); +private: // accelerates game startup void AddStartFactory(); // custom relations float static sector_threat(AAISector *); + bool static least_dangerous(AAISector *left, AAISector *right); bool static suitable_for_power_plant(AAISector *left, AAISector *right); bool static suitable_for_ground_factory(AAISector *left, AAISector *right); @@ -164,49 +156,74 @@ // cache to speed things up a bit float static learned; float static current; - // buildques for the factories vector > buildques; - // number of factories (both mobile and sationary) + int numOfFactories; - int unitProductionRate; + // tries to build a defence building vs category in the specified sector + // returns BUILDORDER_SUCCESFUL if succesful + BuildOrderStatus BuildStationaryDefenceVS(UnitCategory category, AAISector *dest); + + // returns true if successfully assisting construction + bool AssistConstructionOfCategory(UnitCategory category, int importance = 5); + + // returns the the total ground offensive power of all units + + + + float GetTotalGroundPower(); + + // returns the the total air defence power of all units + float GetTotalAirPower(); + + // chooses a starting sector close to specified sector + void ChooseDifferentStartingSector(int x, int y); + + // returns closest (taking into account movement speed) group with units of specified unit type that may reach the location + + AAIGroup* GetClosestGroupForDefence(UnitType group_type, float3 *pos, int continent, int importance); + float3 GetRallyPointCloseTo(UnitCategory category, unsigned int unit_movement_type, int continent_id, float3 pos, int min_dist, int max_dist); + float3 GetBuildsite(int builder, int building, UnitCategory category); + void InitBuildques(); + + void stopUnit(int unit); + void ConstructBuildingAt(int building, int builder, float3 position); + bool IsBusy(int unit); + + float GetEnergyUrgency(); + + float GetMetalUrgency(); + float GetEnergyStorageUrgency(); + float GetMetalStorageUrgency(); + + bool BuildFactory(); + bool BuildDefences(); + bool BuildRadar(); + bool BuildJammer(); + bool BuildExtractor(); + bool BuildMetalMaker(); + bool BuildStorage(); + bool BuildPowerPlant(); + bool BuildArty(); + bool BuildAirBase(); - // ressource management - // tells ai, how many times additional metal/energy has been requested - float futureRequestedMetal; - float futureRequestedEnergy; - float futureAvailableMetal; - float futureAvailableEnergy; - float futureStoredMetal; - float futureStoredEnergy; float averageMetalUsage; float averageEnergyUsage; - float averageMetalSurplus; - float averageEnergySurplus; - int disabledMMakers; - int counter; float metalSurplus[8]; float energySurplus[8]; - - // urgency of construction of building of the different categories - float urgency[METAL_MAKER+1]; - - // sector where next def vs category needs to be built (0 if none) AAISector *next_defence; UnitCategory def_category; - // debug int issued_orders; - void GiveOrder(Command *c, int unit, const char *owner); - -private: AAI *ai; // stores which buildque belongs to what kind of factory vector factory_table; - }; + +#endif + diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIGroup.cpp spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIGroup.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIGroup.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIGroup.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -8,16 +8,29 @@ // ------------------------------------------------------------------------- #include "AAIGroup.h" + #include "AAI.h" #include "AAIBuildTable.h" #include "AAIAttack.h" +#include "AAIExecute.h" +#include "AAIAttackManager.h" +#include "AAIAirForceManager.h" +#include "AAIUnitTable.h" +#include "AAIConfig.h" +#include "AAIMap.h" +#include "AAISector.h" + + +#include "LegacyCpp/UnitDef.h" +using namespace springLegacyAI; + -AAIGroup::AAIGroup(AAI *ai, const UnitDef *def, UnitType unit_type, int continent_id) +AAIGroup::AAIGroup(AAI *ai, const UnitDef *def, UnitType unit_type, int continent_id): + rally_point(ZeroVector) { this->ai = ai; attack = 0; - rally_point = ZeroVector; category = ai->Getbt()->units_static[def->id].category; combat_category = ai->Getbt()->GetIDOfAssaultCategory(category); diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIGroup.h spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIGroup.h --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIGroup.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIGroup.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,14 +7,29 @@ // Released under GPL license: see LICENSE.html for more information. // ------------------------------------------------------------------------- -#pragma once +#ifndef AAI_GROUP_H +#define AAI_GROUP_H +#include "System/type2.h" #include "aidef.h" -#include "AAISector.h" + +enum GroupTask {GROUP_IDLE, GROUP_ATTACKING, GROUP_DEFENDING, GROUP_PATROLING, GROUP_BOMBING, GROUP_RETREATING}; + +namespace springLegacyAI { + struct UnitDef; + struct Command; +} +#include "LegacyCpp/Command.h" +using namespace springLegacyAI; + +#include +#include +using namespace std; class AAI; class AAIBuildTable; class AAIAttack; +class AAISector; class AAIGroup { @@ -65,21 +80,15 @@ float3 GetGroupPos(); - // returns true if group is strong enough to attack - bool SufficientAttackPower(); - // checks if the group may participate in an attack (= idle, sufficient combat power, etc.) bool AvailableForAttack(); int maxSize; int size; - int speed_group; - float avg_speed; + float avg_speed; list units; - Command lastCommand; - int lastCommandFrame; float task_importance; // importance of current task @@ -92,8 +101,6 @@ unsigned int group_movement_type; - AAISector *target_sector; - // attack the group takes part in AAIAttack *attack; @@ -104,6 +111,16 @@ int continent; private: + // returns true if group is strong enough to attack + bool SufficientAttackPower(); + int lastCommandFrame; + Command lastCommand; + int speed_group; + AAI* ai; + AAISector *target_sector; }; + +#endif + diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAI.h spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAI.h --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAI.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAI.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,27 +7,30 @@ // Released under GPL license: see LICENSE.html for more information. // ------------------------------------------------------------------------- +#ifndef AAI_H +#define AAI_H -#pragma once - -#include "aidef.h" -#include "AAIBrain.h" -#include "AAIExecute.h" -#include "AAISector.h" -#include "AAIBuildTable.h" -#include "AAIGroup.h" -#include "AAIBuildTask.h" -#include "AAIUnitTable.h" -#include "AAIMap.h" -#include "AAIAirForceManager.h" -#include "AAIAttackManager.h" -#include "AAIConstructor.h" -#include +#include "LegacyCpp/IGlobalAI.h" +#include +#include + +namespace springLegacyAI { + class IAICallback; +} +using namespace springLegacyAI; using namespace std; class AAIExecute; class Profiler; +class AAIBrain; +class AAIBuildTask; +class AAIAirForceManager; +class AAIAttackManager; +class AAIBuildTable; +class AAIUnitTable; +class AAIMap; +class AAIGroup; class AAI : public IGlobalAI { @@ -114,3 +117,6 @@ static int aai_instance; }; + +#endif + diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIMap.cpp spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIMap.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIMap.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIMap.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -9,8 +9,16 @@ #include "AAIMap.h" #include "AAI.h" -#include "AAISector.h" #include "AAIBuildTable.h" +#include "AAIBrain.h" +#include "AAIConfig.h" +#include "AAISector.h" + +#include "System/Util.h" +#include "LegacyCpp/UnitDef.h" +using namespace springLegacyAI; + +#define MAP_CACHE_PATH "cache/" int AAIMap::xSize; int AAIMap::ySize; @@ -62,9 +70,6 @@ AAIMap::AAIMap(AAI *ai) { - // initialize random numbers generator - srand ( time(NULL) ); - this->ai = ai; initialized = false; } @@ -76,7 +81,7 @@ { Learn(); - const std::string mapLearn_filename = LocateMapLearnFile(true); + const std::string mapLearn_filename = LocateMapLearnFile(); // save map data FILE *save_file = fopen(mapLearn_filename.c_str(), "w+"); @@ -251,7 +256,7 @@ const size_t buffer_sizeMax = 512; char buffer[buffer_sizeMax]; - const std::string mapCache_filename = LocateMapCacheFile(false); + const std::string mapCache_filename = LocateMapCacheFile(); FILE *file; @@ -340,7 +345,7 @@ ////////////////////////////////////////////////////////////////////////////////////////////////////// // save mod independent map data - const std::string mapCache_filename = LocateMapCacheFile(true); + const std::string mapCache_filename = LocateMapCacheFile(); file = fopen(mapCache_filename.c_str(), "w+"); @@ -451,37 +456,16 @@ } } + + void AAIMap::ReadContinentFile() { - // this size equals the one used in "AIAICallback::GetValue(AIVAL_LOCATE_FILE_..." - static const size_t buffer_sizeMax = 2048; - char buffer[buffer_sizeMax]; - STRCPY(buffer, MAIN_PATH); - STRCAT(buffer, MAP_CACHE_PATH); - std::string mapName = MakeFileSystemCompatible(ai->Getcb()->GetMapName()); - mapName.resize(mapName.size() - 4); // cut off extension - STRCAT(buffer, mapName.c_str()); - STRCAT(buffer, "-"); - const std::string mapHash = IntToString(ai->Getcb()->GetMapHash(), "%x"); - STRCAT(buffer, mapHash.c_str()); - STRCAT(buffer, "_"); - const std::string modHumanName = MakeFileSystemCompatible(ai->Getcb()->GetModHumanName()); - STRCAT(buffer, modHumanName.c_str()); - STRCAT(buffer, "-"); - const std::string modHash = IntToString(ai->Getcb()->GetModHash(), "%x"); - STRCAT(buffer, modHash.c_str()); - STRCAT(buffer, ".dat"); - char filename[buffer_sizeMax]; - STRCPY(filename, buffer); - - // as we will have to write to the file later on anyway, - // we want it writable - ai->Getcb()->GetValue(AIVAL_LOCATE_FILE_W, filename); - - FILE* file = fopen(filename, "r"); + const std::string filename = cfg->GetFileName(cfg->getUniqueName(true, true, true, true), MAP_CACHE_PATH, "_continent.dat", true); + FILE* file = fopen(filename.c_str(), "r"); if(file != NULL) { + char buffer[4096]; // check if correct version fscanf(file, "%s ", buffer); @@ -538,17 +522,8 @@ ////////////////////////////////////////////////////////////////////////////////////////////////////// // save movement maps - STRCPY(buffer, MAIN_PATH); - STRCAT(buffer, MAP_CACHE_PATH); - STRCAT(buffer, mapName.c_str()); - STRCAT(buffer, "_"); - STRCAT(buffer, modHumanName.c_str()); - STRCAT(buffer, ".dat"); - STRCPY(filename, buffer); - - ai->Getcb()->GetValue(AIVAL_LOCATE_FILE_W, filename); - - file = fopen(filename, "w+"); + const std::string movementfile = cfg->GetFileName(cfg->getUniqueName(true, false, true, false), MAP_CACHE_PATH, "_movement.dat", true); + file = fopen(movementfile.c_str(), "w+"); fprintf(file, "%s\n", CONTINENT_DATA_VERSION); @@ -575,67 +550,20 @@ fclose(file); } -std::string AAIMap::LocateMapLearnFile(const bool forWriting) const { - - // this size equals the one used in "AIAICallback::GetValue(AIVAL_LOCATE_FILE_..." - const size_t buffer_sizeMax = 2048; - char buffer[buffer_sizeMax]; - - STRCPY(buffer, MAIN_PATH); - STRCAT(buffer, MAP_LEARN_PATH); - std::string mapName = MakeFileSystemCompatible(ai->Getcb()->GetMapName()); - mapName.resize(mapName.size() - 4); // cut off extension - STRCAT(buffer, mapName.c_str()); - STRCAT(buffer, "-"); - const std::string mapHash = IntToString(ai->Getcb()->GetMapHash(), "%x"); - STRCAT(buffer, mapHash.c_str()); - STRCAT(buffer, "_"); - const std::string modHumanName = MakeFileSystemCompatible(ai->Getcb()->GetModHumanName()); - STRCAT(buffer, modHumanName.c_str()); - STRCAT(buffer, "-"); - const std::string modHash = IntToString(ai->Getcb()->GetModHash(), "%x"); - STRCAT(buffer, modHash.c_str()); - STRCAT(buffer, ".dat"); - - if (forWriting) { - ai->Getcb()->GetValue(AIVAL_LOCATE_FILE_W, buffer); - } else { - ai->Getcb()->GetValue(AIVAL_LOCATE_FILE_R, buffer); - } - - return std::string(buffer); +std::string AAIMap::LocateMapLearnFile() const +{ + return cfg->GetFileName(cfg->getUniqueName(true, true, true, true), MAP_LEARN_PATH, "_maplearn.dat", true); } -std::string AAIMap::LocateMapCacheFile(const bool forWriting) const { - - // this size equals the one used in "AIAICallback::GetValue(AIVAL_LOCATE_FILE_..." - const size_t buffer_sizeMax = 2048; - char buffer[buffer_sizeMax]; - - STRCPY(buffer, MAIN_PATH); - STRCAT(buffer, MAP_CACHE_PATH); - std::string mapName = MakeFileSystemCompatible(ai->Getcb()->GetMapName()); - mapName.resize(mapName.size() - 4); // cut off extension - STRCAT(buffer, mapName.c_str()); - STRCAT(buffer, "-"); - const std::string mapHash = IntToString(ai->Getcb()->GetMapHash(), "%x"); - STRCAT(buffer, mapHash.c_str()); - STRCAT(buffer, ".dat"); - - if (forWriting) { - ai->Getcb()->GetValue(AIVAL_LOCATE_FILE_W, buffer); - } else { - ai->Getcb()->GetValue(AIVAL_LOCATE_FILE_R, buffer); - } - - return std::string(buffer); +std::string AAIMap::LocateMapCacheFile() const +{ + return cfg->GetFileName(cfg->getUniqueName(false, false, true, true), MAP_LEARN_PATH, "_mapcache.dat", true); } void AAIMap::ReadMapLearnFile(bool auto_set) { - const std::string mapLearn_filename = LocateMapLearnFile(false); + const std::string mapLearn_filename = LocateMapLearnFile(); - // this size equals the one used in "AIAICallback::GetValue(AIVAL_LOCATE_FILE_..." const size_t buffer_sizeMax = 2048; char buffer[buffer_sizeMax]; @@ -1987,7 +1915,12 @@ // algorithm more or less by krogothe - thx very much void AAIMap::SearchMetalSpots() { - const UnitDef* def = &ai->Getbt()->GetUnitDef(ai->Getbt()->GetBiggestMex()-1); + const int unitid = ai->Getbt()->GetBiggestMex()-1; //WTF, why -1? + if (unitid <= 0) { + ai->Log("No metal extractor unit known!"); + return; + } + const UnitDef* def = &ai->Getbt()->GetUnitDef(unitid); metalMap = false; bool Stopme = false; @@ -2021,7 +1954,6 @@ // clear variables, just in case! TotalMetal = 0; MaxMetal = 0; - Stopme = 0; SpotsFound = 0; //Load up the metal Values in each pixel @@ -2077,7 +2009,7 @@ } } if (TempMetal < MinMetalForSpot) - Stopme = 1; // if the spots get too crappy it will stop running the loops to speed it all up + Stopme = true; // if the spots get too crappy it will stop running the loops to speed it all up if (!Stopme) { @@ -2532,12 +2464,8 @@ } } - // this size equals the one used in "AIAICallback::GetValue(AIVAL_LOCATE_FILE_..." - static const size_t filename_sizeMax = 2048; - char filename[filename_sizeMax]; - STRCPY(filename, "AAIDefMap.txt"); - ai->Getcb()->GetValue(AIVAL_LOCATE_FILE_W, filename); - FILE* file = fopen(filename, "w+"); + const std::string filename = cfg->GetFileName("AAIDefMap.txt", "", "", true); + FILE* file = fopen(filename.c_str(), "w+"); for(int y = 0; y < yDefMapSize; ++y) { for(int x = 0; x < xDefMapSize; ++x) @@ -2677,12 +2605,8 @@ float range = ai->Getbt()->units_static[def->id].range / 8.0; - // this size equals the one used in "AIAICallback::GetValue(AIVAL_LOCATE_FILE_..." - static const size_t filename_sizeMax = 2048; - char filename[filename_sizeMax]; - STRCPY(filename, "AAIDebug.txt"); - ai->Getcb()->GetValue(AIVAL_LOCATE_FILE_W, filename); - FILE* file = fopen(filename, "w+"); + const std::string filename = cfg->GetFileName("AAIDebug.txt", "", "", true); + FILE* file = fopen(filename.c_str(), "w+"); fprintf(file, "Search area: (%i, %i) x (%i, %i)\n", xStart, yStart, xEnd, yEnd); fprintf(file, "Range: %g\n", range); diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIMap.h spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIMap.h --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIMap.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIMap.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,13 +7,31 @@ // Released under GPL license: see LICENSE.html for more information. // ------------------------------------------------------------------------- -#pragma once +#ifndef AAI_MAP_H +#define AAI_MAP_H #include "aidef.h" -#include "AAISector.h" +#include "System/float3.h" + +#include +#include +using namespace std; class AAIBuildTable; class AAI; +class AAISector; + +namespace springLegacyAI { + struct UnitDef; +} +using namespace springLegacyAI; + +struct AAIContinent +{ + int id; + int size; // number of cells + bool water; +}; class AAIMap { @@ -22,13 +40,6 @@ ~AAIMap(void); void Init(); - - // sets cells of the builmap to value - bool SetBuildMap(int xPos, int yPos, int xSize, int ySize, int value, int ignore_value = -1); - - // converts map-pos to unit-pos and vice versa - void Pos2BuildMapPos(float3 *pos, const UnitDef* def); - void BuildMapPos2Pos(float3 *pos, const UnitDef* def); void Pos2FinalBuildPos(float3 *pos, const UnitDef *def); // returns id of continent the cell belongs to @@ -41,14 +52,10 @@ // returns continent id with respect to the units movement type (e.g. land, non amphib unit being in shallow water will return id of nearest land continent) int GetSmartContinentID(float3 *pos, unsigned int unit_movement_type); - // true if x/y are a valid sector - bool ValidSector(int x, int y); // returns sector (0 if out of sector map -> e.g. aircraft flying outside of the map) of a position AAISector* GetSectorOfPos(float3 *pos); - // returns distance to closest edge of the map (in build_map coordinates) - int GetEdgeDistance(int xPos, int yPos); float GetEdgeDistance(float3 *pos); @@ -66,21 +73,11 @@ float3 GetClosestBuildsite(const UnitDef *def, float3 pos, int max_distance, bool water); - // returns footprint size of a building - void GetSize(const UnitDef *def, int *xSize, int *ySize); - - // prevents ai from building too many buildings in a row - void CheckRows(int xPos, int yPos, int xSize, int ySize, bool add, bool water); - - // blocks/unblocks cells (to prevent AAI from packing buildings too close to each other) - void BlockCells(int xPos, int yPos, int width, int height, bool block, bool water); - // updates buildmap ((un)block cells + insert/remove spaces) if regular building is added/removed (factories need some extra space) void UpdateBuildMap(float3 build_pos, const UnitDef *def, bool block, bool water, bool factory); // returns number of cells with big slope int GetCliffyCells(int xPos, int yPos, int xSize, int ySize); - int GetCliffyCellsInSector(AAISector *sector); // updates spotted ennemy/ally buildings/units on the map void UpdateRecon(); @@ -90,39 +87,6 @@ void UpdateSectors(); - const char* GetMapTypeTextString(MapType map_type); - const char* GetMapTypeString(MapType map_type); - - // return next cell in direction with a certain value - int GetNextX(int direction, int xPos, int yPos, int value); // 0 means left, other right; returns -1 if not found - int GetNextY(int direction, int xPos, int yPos, int value); // 0 means up, other down; returns -1 if not found - - // returns true if buildmap allows construction - bool CanBuildAt(int xPos, int yPos, int xSize, int ySize, bool water = false); - - // reads map cache file (and creates new one if necessary) - // loads mex spots, cliffs etc. from file or creates new one - void ReadMapCacheFile(); - - // reads continent cache file (and creates new one if necessary) - void ReadContinentFile(); - - // if auto_set == true, the loaded values are assigned to the current sectordata as well - void ReadMapLearnFile(bool auto_set); - - // calculates learning effect - void Learn(); - - // determines water, high slopes, defence map - void AnalyseMap(); - - // calculates which parts of the are connected - void CalculateContinentMaps(); - - void CalculateWaterRatio(); - - // determines type of map (land, land/water or water map) - void DetectMapType(); // adds/removes a defence buidling to the defence map void AddDefence(float3 *pos, int defence); @@ -131,18 +95,47 @@ // updates number of lost units in sector void UnitKilledAt(float3 *pos, UnitCategory category); - // krogothe's metal spot finder - void SearchMetalSpots(); - // sectors vector > sector; - bool initialized; + // used for scouting, used to get all friendly/enemy units in los + vector units_in_los; + static int xMapSize, yMapSize; // x and y size of the map (map coordinates) + static int xSectors, ySectors; // number of sectors + static int xSectorSize, ySectorSize; // size of sectors (in unit pos coordinates) + static int xSectorSizeMap, ySectorSizeMap; // size of sectors (in map coodrinates = 1/8 xSize) + static float land_ratio; + static int water_metal_spots; + static int land_metal_spots; + static bool metalMap; + static float water_ratio; + static MapType map_type; // 0 -> unknown ,1-> land map (default), 2 -> air map, + // 3 -> water map with land connections + // 4 -> "full water map + + static vector< vector > team_sector_map; // stores the number of ai player which has taken that sector (-1 if none) + // this helps preventing aai from expanding into sectors of other aai players + + + static vector buildmap; // map of the cells in the sector; + // 0 unoccupied, flat terrain + // 1 occupied flat terrain, + // 2 spaces between buildings + // 3 terrain not suitable for constr. + // 4 water + // 5 occupied water + static vector continents; + static int avg_water_continent_size; + static list map_categories_id; + +private: // defence maps vector defence_map; // ground/sea defence map has 1/2 of resolution of blockmap/buildmap vector air_defence_map; // air defence map has 1/2 of resolution of blockmap/buildmap vector submarine_defence_map; // submarine defence map has 1/2 of resolution of blockmap/buildmap + // converts map-pos to unit-pos and vice versa + void Pos2BuildMapPos(float3 *pos, const UnitDef* def); // stores the def_id of the building or combat unit placed on that cell (0 if none), same resolution as los map (= 1/2 resolution of buildmap) vector scout_map; @@ -150,9 +143,6 @@ // stores the frame of the last update of a cell (same resolution as los map) vector last_updated_map; - // used for scouting, used to get all friendly/enemy units in los - vector units_in_los; - // indicates whether sector is within los (to prevent unnecessary updates) 0 = no los, > 0 = los vector sector_in_los; vector sector_in_los_with_enemies; @@ -160,54 +150,81 @@ // temp for scouting vector enemy_combat_units_spotted; -private: - std::string LocateMapLearnFile(const bool forWriting) const; - std::string LocateMapCacheFile(const bool forWriting) const; + bool initialized; + // krogothe's metal spot finder + void SearchMetalSpots(); + // determines type of map (land, land/water or water map) + void DetectMapType(); + + void CalculateWaterRatio(); + + // calculates which parts of the are connected + void CalculateContinentMaps(); + + // determines water, high slopes, defence map + void AnalyseMap(); + + // calculates learning effect + void Learn(); + + // if auto_set == true, the loaded values are assigned to the current sectordata as well + void ReadMapLearnFile(bool auto_set); + + // reads continent cache file (and creates new one if necessary) + void ReadContinentFile(); + + // reads map cache file (and creates new one if necessary) + // loads mex spots, cliffs etc. from file or creates new one + void ReadMapCacheFile(); + + // returns true if buildmap allows construction + bool CanBuildAt(int xPos, int yPos, int xSize, int ySize, bool water = false); + + // return next cell in direction with a certain value + int GetNextX(int direction, int xPos, int yPos, int value); // 0 means left, other right; returns -1 if not found + int GetNextY(int direction, int xPos, int yPos, int value); // 0 means up, other down; returns -1 if not found + + const char* GetMapTypeString(MapType map_type); + + const char* GetMapTypeTextString(MapType map_type); + + int GetCliffyCellsInSector(AAISector *sector); + + // blocks/unblocks cells (to prevent AAI from packing buildings too close to each other) + void BlockCells(int xPos, int yPos, int width, int height, bool block, bool water); + + // prevents ai from building too many buildings in a row + void CheckRows(int xPos, int yPos, int xSize, int ySize, bool add, bool water); + + // returns footprint size of a building + void GetSize(const UnitDef *def, int *xSize, int *ySize); + // returns distance to closest edge of the map (in build_map coordinates) + int GetEdgeDistance(int xPos, int yPos); + // true if x/y are a valid sector + bool ValidSector(int x, int y); + // sets cells of the builmap to value + bool SetBuildMap(int xPos, int yPos, int xSize, int ySize, int value, int ignore_value = -1); + + void BuildMapPos2Pos(float3 *pos, const UnitDef* def); + + std::string LocateMapLearnFile() const; + std::string LocateMapCacheFile() const; AAI *ai; /////////////////////////////////////////////////////////////////////////////////////////////////////////////// // static (shared with other ai players) /////////////////////////////////////////////////////////////////////////////////////////////////////////////// -public: static int aai_instances; // how many AAI instances have been initialized static int xSize, ySize; // x and y size of the map (unit coordinates) - static int xMapSize, yMapSize; // x and y size of the map (map coordinates) static int losMapRes; // resolution of the LOS map static int xLOSMapSize, yLOSMapSize; // x and y size of the LOS map static int xDefMapSize, yDefMapSize; // x and y size of the defence maps (1/4 resolution of map) static int xContMapSize, yContMapSize; // x and y size of the continent maps (1/4 resolution of map) - static int xSectors, ySectors; // number of sectors - static int xSectorSize, ySectorSize; // size of sectors (in unit pos coordinates) - static int xSectorSizeMap, ySectorSizeMap; // size of sectors (in map coodrinates = 1/8 xSize) - static list metal_spots; - - static int land_metal_spots; - static int water_metal_spots; - - static float land_ratio; static float flat_land_ratio; - static float water_ratio; - - static bool metalMap; - static MapType map_type; // 0 -> unknown ,1-> land map (default), 2 -> air map, - // 3 -> water map with land connections - // 4 -> "full water map - - static vector< vector > team_sector_map; // stores the number of ai player which has taken that sector (-1 if none) - // this helps preventing aai from expanding into sectors of other aai players - - - static vector buildmap; // map of the cells in the sector; - // 0 unoccupied, flat terrain - // 1 occupied flat terrain, - // 2 spaces between buildings - // 3 terrain not suitable for constr. - // 4 water - // 5 occupied water static vector blockmap; // number of buildings which ordered a cell to blocked static vector plateau_map; // positive values indicate plateaus, 1/4 of resolution of blockmap/buildmap static vector continent_map; // id of continent a cell belongs to @@ -216,19 +233,18 @@ static vector kbot_movement_map; static vector vehicle_movement_map; static vector hover_movement_map; - - static vector continents; static int land_continents; static int water_continents; static int avg_land_continent_size; - static int avg_water_continent_size; static int max_land_continent_size; static int max_water_continent_size; static int min_land_continent_size; static int min_water_continent_size; static list map_categories; - static list map_categories_id; }; + +#endif + diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAISector.cpp spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAISector.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAISector.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAISector.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -9,8 +9,16 @@ #include "AAISector.h" #include "AAI.h" +#include "AAIBuildTable.h" +#include "AAIBrain.h" +#include "AAIConfig.h" #include "AAIMap.h" +#include "LegacyCpp/IGlobalAICallback.h" +#include "LegacyCpp/UnitDef.h" +using namespace springLegacyAI; + + AAISector::AAISector() { } @@ -169,7 +177,7 @@ AAIMetalSpot* AAISector::GetFreeMetalSpot() { // look for the first unoccupied metalspot - for(list::iterator i = metalSpots.begin(); i != metalSpots.end(); i++) + for(list::iterator i = metalSpots.begin(); i != metalSpots.end(); ++i) { // if metalspot is occupied, try next one if(!(*i)->occupied) diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAISector.h spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAISector.h --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAISector.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAISector.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,13 +7,27 @@ // Released under GPL license: see LICENSE.html for more information. // ------------------------------------------------------------------------- -#pragma once +#ifndef AAI_SECTOR_H +#define AAI_SECTOR_H + +#include "System/float3.h" #include "aidef.h" +#include +#include +using namespace std; class AAI; class AAIUnitTable; class AAIMap; +class AAIMetalSpot; + +namespace springLegacyAI { + struct UnitDef; +} +using namespace springLegacyAI; + +enum Direction {WEST, EAST, SOUTH, NORTH, CENTER, NO_DIRECTION}; struct DefenceCoverage { @@ -21,16 +35,15 @@ float defence; }; + + class AAISector { public: AAISector(); ~AAISector(void); - void SetCoordinates(int left, int right, int top, int bottom); - void SetGridLocation(int x, int y); void AddMetalSpot(AAIMetalSpot *spot); - AAIMetalSpot* GetFreeMetalSpot(); void FreeMetalSpot(float3 pos, const UnitDef *extractor); void Init(AAI *ai, int x, int y, int left, int right, int top, int bottom); @@ -50,40 +63,18 @@ float3 GetDefenceBuildsite(int building, UnitCategory category, float terrain_modifier, bool water); float3 GetRandomBuildsite(int building, int tries, bool water = false); float3 GetCenterBuildsite(int building, bool water = false); - float3 GetHighestBuildsite(int building); float3 GetRadarArtyBuildsite(int building, float range, bool water); - // gets rectangle for possible buildsite - void GetBuildsiteRectangle(int *xStart, int *xEnd, int *yStart, int *yEnd); - - // helper functions - void Pos2SectorMapPos(float3 *pos, const UnitDef* def); - void SectorMapPos2Pos(float3 *pos, const UnitDef* def); - // removes building from sector -> update own_structure & unitsOfType[] void RemoveBuildingType(int def_id); - // returns the category with the weakest defence in comparison with threat - UnitCategory GetWeakestCategory(); - // returns threat to the sector by a certain category float GetThreatBy(UnitCategory category, float learned, float current); float GetThreatByID(int combat_cat_id, float learned, float current); - float GetOverallThreat(float learned, float current); - - // returns combat power of all own/known enemy units in the sector - float GetMyCombatPower(float ground, float air, float hover, float sea, float submarine); - float GetEnemyCombatPower(float ground, float air, float hover, float sea, float submarine); - float GetMyCombatPowerAgainstCombatCategory(int combat_category); - float GetEnemyCombatPowerAgainstCombatCategory(int combat_category); - - // returns defence power of all own/known enemy stat defences in the sector - float GetMyDefencePower(float ground, float air, float hover, float sea, float submarine); float GetEnemyDefencePower(float ground, float air, float hover, float sea, float submarine); float GetMyDefencePowerAgainstAssaultCategory(int assault_category); - float GetEnemyDefencePowerAgainstAssaultCategory(int assault_category); // returns enemy combat power of all known enemy units/stat defences in the sector float GetEnemyThreatToMovementType(unsigned int movement_type); @@ -192,5 +183,39 @@ vector enemy_mobile_combat_power; // 0 ground, 1 air, 2 hover, 3 sea, 4 submarine, 5 building AAI* Getai() { return ai; } private: + float GetEnemyCombatPowerAgainstCombatCategory(int combat_category); + + float GetMyCombatPowerAgainstCombatCategory(int combat_category); + + float GetEnemyCombatPower(float ground, float air, float hover, float sea, float submarine); + + // returns combat power of all own/known enemy units in the sector + float GetMyCombatPower(float ground, float air, float hover, float sea, float submarine); + + float GetOverallThreat(float learned, float current); + + // returns the category with the weakest defence in comparison with threat + UnitCategory GetWeakestCategory(); + + // returns defence power of all own/known enemy stat defences in the sector + float GetMyDefencePower(float ground, float air, float hover, float sea, float submarine); + + float GetEnemyDefencePowerAgainstAssaultCategory(int assault_category); + + // helper functions + void Pos2SectorMapPos(float3 *pos, const UnitDef* def); + void SectorMapPos2Pos(float3 *pos, const UnitDef* def); + float3 GetHighestBuildsite(int building); + void SetCoordinates(int left, int right, int top, int bottom); + void SetGridLocation(int x, int y); + AAIMetalSpot* GetFreeMetalSpot(); + + // gets rectangle for possible buildsite + void GetBuildsiteRectangle(int *xStart, int *xEnd, int *yStart, int *yEnd); + AAI *ai; + }; + +#endif + diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIUnitTable.cpp spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIUnitTable.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIUnitTable.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIUnitTable.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,10 +7,20 @@ // Released under GPL license: see LICENSE.html for more information. // ------------------------------------------------------------------------- -#include "AAIUnitTable.h" #include "AAI.h" +#include "AAIUnitTable.h" #include "AAIExecute.h" -#include "System/FastMath.h" +#include "AAIConstructor.h" +#include "AAIBuildTable.h" +#include "AAIAirForceManager.h" +#include "AAIConfig.h" +#include "AAIMap.h" +#include "AAIGroup.h" +#include "AAIConstructor.h" + +#include "LegacyCpp/UnitDef.h" +using namespace springLegacyAI; + AAIUnitTable::AAIUnitTable(AAI *ai) { diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIUnitTable.h spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIUnitTable.h --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AAIUnitTable.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AAIUnitTable.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,16 +7,19 @@ // Released under GPL license: see LICENSE.html for more information. // ------------------------------------------------------------------------- -#pragma once +#ifndef AAI_UNITTABLE_H +#define AAI_UNITTABLE_H #include -#include "aidef.h" using std::set; +#include "aidef.h" + class AAI; class AAIBuildTable; class AAIExecute; +class AAIConstructor; class AAIUnitTable { @@ -68,7 +71,6 @@ void AssignGroupToEnemy(int unit, AAIGroup *group); // determine whether unit with specified def/unit id is commander/constrcutor - bool IsUnitCommander(int unit_id); bool IsDefCommander(int def_id); bool IsBuilder(int unit_id); @@ -95,23 +97,26 @@ // id of commander int cmdr; - - set scouts; set constructors; set metal_makers; set jammers; set recon; - set extractors; - set power_plants; - set stationary_arty; // number of active/under construction units of all different types int activeUnits[(int)MOBILE_CONSTRUCTOR+1]; int futureUnits[(int)MOBILE_CONSTRUCTOR+1]; int requestedUnits[(int)MOBILE_CONSTRUCTOR+1]; - int activeBuilders, futureBuilders; int activeFactories, futureFactories; private: + bool IsUnitCommander(int unit_id); + set scouts; + set extractors; + set power_plants; + set stationary_arty; AAI *ai; + }; + +#endif + diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/aidef.h spring-98.0~14.04~ppa6/AI/Skirmish/AAI/aidef.h --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/aidef.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/aidef.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,34 +7,12 @@ // Released under GPL license: see LICENSE.html for more information. // ------------------------------------------------------------------------- -#ifndef AIDEF_H -#define AIDEF_H +#ifndef AAI_DEF_H +#define AAI_DEF_H -#include -#include -#include -#include #include -#include "LegacyCpp/IAICheats.h" -#include "LegacyCpp/IGlobalAI.h" -#include "LegacyCpp/IGlobalAICallback.h" -#include "LegacyCpp/IAICallback.h" -#include "LegacyCpp/aibase.h" -#include "LegacyCpp/UnitDef.h" -#include "LegacyCpp/MoveData.h" -#include "LegacyCpp/WeaponDef.h" -#include "LegacyCpp/CommandQueue.h" -#include "Sim/Misc/GlobalConstants.h" -#include "System/type2.h" -#include "System/maindefines.h" -#include "System/SafeCStrings.h" -#include "System/Util.h" -#include "AAIConfig.h" -#include "AIExport.h" - -using namespace springLegacyAI; - +#include "System/float3.h" #ifdef _MSC_VER #pragma warning(disable: 4244 4018) // signed/unsigned and loss of precision... @@ -43,8 +21,6 @@ // The following two helper functions implementations are in AAIBuildTable.cpp void ReplaceExtension(const char *n, char *dst, int s, const char *ext); -/// Converts a string to one that can be used in a file name (eg. "Abc.123 $%^*" -> "Abc.123_____") -std::string MakeFileSystemCompatible(const std::string& str); #define AAI_VERSION aiexport_getVersion() #define MAP_CACHE_VERSION "MAP_DATA_0_89" @@ -52,18 +28,11 @@ #define MOD_LEARN_VERSION "MOD_LEARN_0_90" #define CONTINENT_DATA_VERSION "MOVEMENT_MAPS_0_87" -// all paths -#define MAIN_PATH "" #define AILOG_PATH "log/" -#define MOD_CFG_PATH "cfg/mod/" -#define GENERAL_CFG_FILE "cfg/general.cfg" +#define MAP_LEARN_PATH "learn/mod/" #define MOD_LEARN_PATH "learn/mod/" -#define MAP_CACHE_PATH "cache/" -#define MAP_LEARN_PATH "learn/map/" -extern AAIConfig *cfg; - class AAIMetalSpot { public: @@ -107,64 +76,17 @@ #define UNIT_TYPE_BOMBER (unsigned int) 512 #define UNIT_TYPE_GUNSHIP (unsigned int) 1024 -enum Direction {WEST, EAST, SOUTH, NORTH, CENTER, NO_DIRECTION}; - -enum MapType {LAND_MAP, LAND_WATER_MAP, WATER_MAP, UNKNOWN_MAP}; - -enum SectorType {UNKNOWN_SECTOR, LAND_SECTOR, LAND_WATER_SECTOR, WATER_SECTOR}; enum UnitCategory {UNKNOWN, STATIONARY_DEF, STATIONARY_ARTY, STORAGE, STATIONARY_CONSTRUCTOR, AIR_BASE, STATIONARY_RECON, STATIONARY_JAMMER, STATIONARY_LAUNCHER, DEFLECTION_SHIELD, POWER_PLANT, EXTRACTOR, METAL_MAKER, COMMANDER, GROUND_ASSAULT, AIR_ASSAULT, HOVER_ASSAULT, SEA_ASSAULT, SUBMARINE_ASSAULT, GROUND_ARTY, SEA_ARTY, HOVER_ARTY, SCOUT, MOBILE_TRANSPORT, MOBILE_JAMMER, MOBILE_LAUNCHER, MOBILE_CONSTRUCTOR}; -enum GroupTask {GROUP_IDLE, GROUP_ATTACKING, GROUP_DEFENDING, GROUP_PATROLING, GROUP_BOMBING, GROUP_RETREATING}; - enum UnitType {UNKNOWN_UNIT, ASSAULT_UNIT, ANTI_AIR_UNIT, BOMBER_UNIT, ARTY_UNIT}; - enum UnitTask {UNIT_IDLE, UNIT_ATTACKING, DEFENDING, GUARDING, MOVING, BUILDING, SCOUTING, ASSISTING, RECLAIMING, HEADING_TO_RALLYPOINT, UNIT_KILLED, ENEMY_UNIT, BOMB_TARGET}; - -enum BuildOrderStatus {BUILDORDER_FAILED, BUILDORDER_NOBUILDPOS, BUILDORDER_NOBUILDER, BUILDORDER_SUCCESFUL}; - -struct AAIAirTarget -{ - float3 pos; - int def_id; - int unit_id; - float cost; - float health; - UnitCategory category; -}; - -struct UnitTypeDynamic -{ - int under_construction; // how many units of that type are under construction - int requested; // how many units of that type have been requested - int active; // how many units of that type are currently alive - int constructorsAvailable; // how many factories/builders available being able to build that unit - int constructorsRequested; // how many factories/builders requested being able to build that unit -}; - -struct UnitTypeStatic -{ - int def_id; - int side; // 0 if side has not been set - list canBuildList; - list builtByList; - vector efficiency; // 0 -> ground assault, 1 -> air assault, 2 -> hover assault - // 3 -> sea assault, 4 -> submarine , 5 -> stat. defences - float range; // max weapon range (0 for unarmed units) - float cost; - float builder_cost; - UnitCategory category; - - unsigned int unit_type; - unsigned int movement_type; -}; +enum MapType {LAND_MAP, LAND_WATER_MAP, WATER_MAP, UNKNOWN_MAP}; class AAIGroup; -class AAIBuilder; -class AAIFactory; class AAIConstructor; struct AAIUnit @@ -177,13 +99,5 @@ int last_order; }; -struct AAIContinent -{ - int id; - int size; // number of cells - bool water; -}; - -typedef unsigned char uchar; - #endif + diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AIExport.h spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AIExport.h --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/AIExport.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/AIExport.h 2014-10-07 20:09:51.000000000 +0000 @@ -18,8 +18,8 @@ @author Robin Vobruba */ -#ifndef _AIEXPORT_H -#define _AIEXPORT_H +#ifndef AAI_AIEXPORT_H +#define AAI_AIEXPORT_H // check if the correct defines are set by the build system #if !defined BUILDING_SKIRMISH_AI @@ -59,3 +59,4 @@ const char* aiexport_getVersion(); #endif // _AIEXPORT_H + diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/CMakeLists.txt spring-98.0~14.04~ppa6/AI/Skirmish/AAI/CMakeLists.txt --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/CMakeLists.txt 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -2,8 +2,8 @@ # set(mySourceDirRel "") # Common values are "" or "src" -set(additionalSources ${CUtils_SRC}) +set(additionalSources "") set(additionalCompileFlags "") -set(additionalLibraries ${LegacyCpp_AIWRAPPER_TARGET}) +set(additionalLibraries ${LegacyCpp_AIWRAPPER_TARGET} CUtils) ConfigureNativeSkirmishAI(mySourceDirRel additionalSources additionalCompileFlags additionalLibraries) diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/AAI/data/cfg/mod/BA.cfg spring-98.0~14.04~ppa6/AI/Skirmish/AAI/data/cfg/mod/BA.cfg --- spring-96.0~14.04~ppa4/AI/Skirmish/AAI/data/cfg/mod/BA.cfg 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/AAI/data/cfg/mod/BA.cfg 2014-10-07 20:09:51.000000000 +0000 @@ -35,3 +35,5 @@ SCOUTS 14 CORFAV ARMFAV ARMPEEP CORFINK ARMAWAC CORAWAC ARMFLEA ARMFAST ARMSH CORSH CORPT ARMPT ARMSPY CORSPY DONT_BUILD 12 aafus cafus armmlv cormlv armfmine3 armmine1 armmine2 armmine3 corfmine3 cormine1 cormine2 cormine3 TRANSPORTERS 8 corthovr armthovr corvalk armatlas armsl armdfly cortship armtship +METAL_MAKERS 8 armfmkr cormmkr armmmkr cormakr coruwmmm corfmkr armuwmmm armmakr + diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/CppTestAI/CMakeLists.txt spring-98.0~14.04~ppa6/AI/Skirmish/CppTestAI/CMakeLists.txt --- spring-96.0~14.04~ppa4/AI/Skirmish/CppTestAI/CMakeLists.txt 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/CppTestAI/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -2,9 +2,9 @@ # set(mySourceDirRel "src") # Common values are "" or "src" -set(additionalSources ${CUtils_SRC}) +set(additionalSources "") set(additionalCompileFlags "") -set(additionalLibraries ${Cpp_AIWRAPPER_TARGET}) +set(additionalLibraries ${Cpp_AIWRAPPER_TARGET} CUtils) if (BUILD_Cpp_AIWRAPPER) diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/E323AI/CEconomy.cpp spring-98.0~14.04~ppa6/AI/Skirmish/E323AI/CEconomy.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/E323AI/CEconomy.cpp 2014-01-03 13:29:58.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/E323AI/CEconomy.cpp 2014-10-07 20:09:58.000000000 +0000 @@ -1065,23 +1065,20 @@ if (mstall || estall) return; - //bool allow; - int size; - float k; unitCategory incCats, excCats; buildType bt; - CCoverageCell::NType layer; +// CCoverageCell::NType layer; if (ai->intel->getEnemyCount(AIR) > 0 && rng.RandFloat() > 0.66f) { bt = BUILD_AA_DEFENSE; - layer = CCoverageCell::DEFENSE_ANTIAIR; +// layer = CCoverageCell::DEFENSE_ANTIAIR; // TODO: replace STATIC with DEFENSE after all config files updated incCats = STATIC|ANTIAIR; excCats = TORPEDO; } else if (ai->gamemap->IsWaterMap() && rng.RandFloat() > 0.5f) { bt = BUILD_UW_DEFENSE; - layer = CCoverageCell::DEFENSE_UNDERWATER; +// layer = CCoverageCell::DEFENSE_UNDERWATER; // TODO: replace STATIC with DEFENSE after all config files updated incCats = STATIC|TORPEDO; // NOTE: we do not support coastal torpedo launchers @@ -1090,15 +1087,17 @@ else { bt = BUILD_AG_DEFENSE; - layer = CCoverageCell::DEFENSE_GROUND; +// layer = CCoverageCell::DEFENSE_GROUND; incCats = ATTACKER|DEFENSE; excCats = ANTIAIR|TORPEDO; } - size = ai->coverage->getLayerSize(layer); - k = size / (ai->unittable->staticUnits.size() - size + 1.0f); +/* + int size = ai->coverage->getLayerSize(layer); + const float k = size / (ai->unittable->staticUnits.size() - size + 1.0f); + bool allow; -/* switch (ai->difficulty) { + switch (ai->difficulty) { case DIFFICULTY_EASY: allow = k < 0.11f; break; @@ -1108,7 +1107,8 @@ case DIFFICULTY_HARD: allow = k < 0.51f; break; - }*/ + } +*/ buildOrAssist(*group, bt, incCats, excCats); } diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/E323AI/CMakeLists.txt spring-98.0~14.04~ppa6/AI/Skirmish/E323AI/CMakeLists.txt --- spring-96.0~14.04~ppa4/AI/Skirmish/E323AI/CMakeLists.txt 2014-01-03 13:29:58.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/E323AI/CMakeLists.txt 2014-10-07 20:09:58.000000000 +0000 @@ -1,8 +1,8 @@ ### Generic native Skirmish AI config # set(mySourceDirRel "") # Common values are "" or "src" -set(additionalSources ${CUtils_SRC}) +set(additionalSources "") set(additionalCompileFlags "") -set(additionalLibraries ${LegacyCpp_AIWRAPPER_TARGET} ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY}) +set(additionalLibraries ${LegacyCpp_AIWRAPPER_TARGET} CUtils ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY}) ConfigureNativeSkirmishAI(mySourceDirRel additionalSources additionalCompileFlags additionalLibraries) diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/AIClasses.cpp spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/AIClasses.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/AIClasses.cpp 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/AIClasses.cpp 2014-10-07 20:10:02.000000000 +0000 @@ -8,7 +8,7 @@ #include "KAIK.h" extern CKAIK* KAIKStateExt; -CR_BIND(AIClasses, ); +CR_BIND(AIClasses, ) CR_REG_METADATA(AIClasses, ( CR_MEMBER(ecoTracker), CR_MEMBER(buildupHandler), @@ -23,9 +23,9 @@ CR_MEMBER(initFrame), CR_POSTLOAD(Load), CR_RESERVED(16) -)); +)) -CR_BIND(UnitType, ); +CR_BIND(UnitType, ) CR_REG_METADATA(UnitType, ( CR_MEMBER(canBuildList), CR_MEMBER(builtByList), @@ -37,15 +37,15 @@ CR_MEMBER(techLevel), CR_MEMBER(costMultiplier), CR_POSTLOAD(PostLoad) -)); +)) -CR_BIND(integer2, ); +CR_BIND(integer2, ) CR_REG_METADATA(integer2, ( CR_MEMBER(x), CR_MEMBER(y) -)); +)) -CR_BIND(BuilderTracker, ); +CR_BIND(BuilderTracker, ) CR_REG_METADATA(BuilderTracker, ( CR_MEMBER(builderID), CR_MEMBER(buildTaskId), @@ -60,9 +60,9 @@ CR_MEMBER(estimateETAforMoveingToBuildSite), CR_MEMBER(distanceToSiteBeforeItCanStartBuilding), CR_RESERVED(16) -)); +)) -CR_BIND(BuildTask, ); +CR_BIND(BuildTask, ) CR_REG_METADATA(BuildTask, ( CR_MEMBER(id), CR_ENUM_MEMBER(category), @@ -74,9 +74,9 @@ CR_MEMBER(pos), CR_RESERVED(16), CR_POSTLOAD(PostLoad) -)); +)) -CR_BIND(TaskPlan, ); +CR_BIND(TaskPlan, ) CR_REG_METADATA(TaskPlan, ( CR_MEMBER(id), CR_MEMBER(builders), @@ -88,9 +88,9 @@ CR_MEMBER(pos), CR_RESERVED(8), CR_POSTLOAD(PostLoad) -)); +)) -CR_BIND(UpgradeTask, ); +CR_BIND(UpgradeTask, ) CR_REG_METADATA(UpgradeTask, ( CR_MEMBER(oldBuildingID), CR_MEMBER(oldBuildingPos), @@ -101,30 +101,30 @@ CR_MEMBER(builderIDs), CR_RESERVED(8), CR_POSTLOAD(PostLoad) -)); +)) -CR_BIND(Factory, ); +CR_BIND(Factory, ) CR_REG_METADATA(Factory, ( CR_MEMBER(id), CR_MEMBER(supportbuilders), CR_MEMBER(supportBuilderTrackers), CR_RESERVED(8) -)); +)) -CR_BIND(NukeSilo, ); +CR_BIND(NukeSilo, ) CR_REG_METADATA(NukeSilo, ( CR_MEMBER(id), CR_MEMBER(numNukesReady), CR_MEMBER(numNukesQueued), CR_RESERVED(8) -)); +)) -CR_BIND(MetalExtractor, ); +CR_BIND(MetalExtractor, ) CR_REG_METADATA(MetalExtractor, ( CR_MEMBER(id), CR_MEMBER(buildFrame), CR_RESERVED(8) -)); +)) diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/AIClasses.hpp spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/AIClasses.hpp --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/AIClasses.hpp 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/AIClasses.hpp 2014-10-07 20:10:02.000000000 +0000 @@ -37,7 +37,7 @@ struct AIClasses { public: - CR_DECLARE_STRUCT(AIClasses); + CR_DECLARE_STRUCT(AIClasses) AIClasses(): initialized(true) { /* CREG-only */ } AIClasses(IGlobalAICallback*); @@ -126,7 +126,7 @@ // NOTE: CUNIT does not know about this structure struct UnitType { - CR_DECLARE_STRUCT(UnitType); + CR_DECLARE_STRUCT(UnitType) void PostLoad(); std::vector canBuildList; @@ -143,7 +143,7 @@ class integer2 { public: - CR_DECLARE_STRUCT(integer2); + CR_DECLARE_STRUCT(integer2) integer2(): x(0), y(0) {}; integer2(const int x,const int y): x(x), y(y) {} @@ -168,7 +168,7 @@ * tracking builders is easy (making asserts and tests) */ struct BuilderTracker { - CR_DECLARE_STRUCT(BuilderTracker); + CR_DECLARE_STRUCT(BuilderTracker) int builderID; // if not NULL then this worker belongs to this BuildTask. @@ -200,7 +200,7 @@ }; struct BuildTask { - CR_DECLARE_STRUCT(BuildTask); + CR_DECLARE_STRUCT(BuildTask) void PostLoad(void); int id; @@ -218,7 +218,7 @@ }; struct TaskPlan { - CR_DECLARE_STRUCT(TaskPlan); + CR_DECLARE_STRUCT(TaskPlan) void PostLoad(void); // this will be some smart number (a counter?) @@ -234,7 +234,7 @@ }; struct UpgradeTask { - CR_DECLARE_STRUCT(UpgradeTask); + CR_DECLARE_STRUCT(UpgradeTask) void PostLoad(void); UpgradeTask() { @@ -265,7 +265,7 @@ struct Factory { - CR_DECLARE_STRUCT(Factory); + CR_DECLARE_STRUCT(Factory) int id; // temp only, for compatibility (will be removed) @@ -274,7 +274,7 @@ }; struct NukeSilo { - CR_DECLARE_STRUCT(NukeSilo); + CR_DECLARE_STRUCT(NukeSilo) int id; int numNukesReady; @@ -282,7 +282,7 @@ }; struct MetalExtractor { - CR_DECLARE_STRUCT(MetalExtractor); + CR_DECLARE_STRUCT(MetalExtractor) int id; int buildFrame; diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/AttackGroup.cpp spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/AttackGroup.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/AttackGroup.cpp 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/AttackGroup.cpp 2014-10-07 20:10:02.000000000 +0000 @@ -26,7 +26,7 @@ -CR_BIND(CAttackGroup, (NULL, 0)); +CR_BIND(CAttackGroup, (NULL, 0)) CR_REG_METADATA(CAttackGroup, ( CR_MEMBER(ai), CR_MEMBER(units), @@ -38,7 +38,7 @@ CR_MEMBER(isShooting), CR_MEMBER(movementCounterForStuckChecking), CR_RESERVED(16) -)); +)) diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/AttackGroup.h spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/AttackGroup.h --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/AttackGroup.h 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/AttackGroup.h 2014-10-07 20:10:02.000000000 +0000 @@ -10,7 +10,7 @@ class CAttackGroup { public: - CR_DECLARE(CAttackGroup); + CR_DECLARE(CAttackGroup) CAttackGroup(); CAttackGroup(AIClasses* ai, int groupID_in); diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/AttackHandler.cpp spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/AttackHandler.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/AttackHandler.cpp 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/AttackHandler.cpp 2014-10-07 20:10:02.000000000 +0000 @@ -17,7 +17,7 @@ -CR_BIND(CAttackHandler, (NULL)); +CR_BIND(CAttackHandler, (NULL)) CR_REG_METADATA(CAttackHandler, ( CR_MEMBER(ai), @@ -39,7 +39,7 @@ CR_MEMBER(kMeansEnemyBase), CR_MEMBER(kMeansEnemyK), CR_RESERVED(16) -)); +)) diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/AttackHandler.h spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/AttackHandler.h --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/AttackHandler.h 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/AttackHandler.h 2014-10-07 20:10:02.000000000 +0000 @@ -10,7 +10,7 @@ class CAttackHandler { public: - CR_DECLARE(CAttackHandler); + CR_DECLARE(CAttackHandler) CAttackHandler(AIClasses* ai); ~CAttackHandler(void); diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/BuildUp.cpp spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/BuildUp.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/BuildUp.cpp 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/BuildUp.cpp 2014-10-07 20:10:02.000000000 +0000 @@ -4,7 +4,7 @@ #include "IncExternAI.h" #include "IncGlobalAI.h" -CR_BIND(CBuildUp, (NULL)); +CR_BIND(CBuildUp, (NULL)) CR_REG_METADATA(CBuildUp, ( CR_MEMBER(ai), CR_MEMBER(factoryTimer), @@ -12,7 +12,7 @@ CR_MEMBER(storageTimer), CR_MEMBER(nukeSiloTimer), CR_RESERVED(16) -)); +)) CBuildUp::CBuildUp(AIClasses* ai) { this->ai = ai; @@ -237,7 +237,7 @@ // FIXME: not happening often enough during res. stalls // const bool reclaimFeature = - ((frame & 1) && ai->GetUnit(econState.builderID)->ReclaimBestFeature(true, 4096)); + ((frame & 1) && ai->GetUnit(econState.builderID)->ReclaimBestFeature(true, 1024)); if (!reclaimFeature) { const bool haveNewMex = BuildUpgradeExtractor(econState.builderID); diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/BuildUp.h spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/BuildUp.h --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/BuildUp.h 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/BuildUp.h 2014-10-07 20:10:02.000000000 +0000 @@ -65,7 +65,7 @@ class CBuildUp { public: - CR_DECLARE(CBuildUp); + CR_DECLARE(CBuildUp) CBuildUp(AIClasses* ai); ~CBuildUp(); diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/CMakeLists.txt spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/CMakeLists.txt --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/CMakeLists.txt 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/CMakeLists.txt 2014-10-07 20:10:02.000000000 +0000 @@ -8,7 +8,7 @@ GetNativeSourcesRecursive(luaSources "${CMAKE_SOURCE_DIR}/rts/lib/lua/src" "") set(mySourceDirRel "") # Common values are "" or "src" -set(additionalSources ${CUtils_SRC} ${luaSources} ${CMAKE_SOURCE_DIR}/rts/System/Util) +set(additionalSources ${luaSources} ${CMAKE_SOURCE_DIR}/rts/System/Util) ## FIXME: ## "undefined symbol: _ZTIN4creg18IMemberRegistratorE" ## ("typeinfo for creg::IMemberRegistrator") on dlopen @@ -16,10 +16,9 @@ ## and/or KAIK 000c7bf2659ceb4d50666cb32b342bcf26ada243 ## set(additionalCompileFlags "-DUSING_CREG") ## set(additionalLibraries ${LegacyCpp_Creg_AIWRAPPER_TARGET}) -set(additionalLibraries ${LegacyCpp_AIWRAPPER_TARGET}) -set(additionalCompileFlags "${additionalCompileFlags} -I ${CMAKE_SOURCE_DIR}/rts/lib/lua/include/") -set(additionalCompileFlags "${additionalCompileFlags} -I ${CMAKE_SOURCE_DIR}/rts/lib/lua/src/") -set(additionalCompileFlags "${additionalCompileFlags} -I ${CMAKE_SOURCE_DIR}/rts/lib/streflop/") - +set(additionalLibraries ${LegacyCpp_AIWRAPPER_TARGET} CUtils) +include_directories("${CMAKE_SOURCE_DIR}/rts/lib/lua/include/") +include_directories("${CMAKE_SOURCE_DIR}/rts/lib/lua/src/") +include_directories("${CMAKE_SOURCE_DIR}/rts/lib/streflop/") ConfigureNativeSkirmishAI(mySourceDirRel additionalSources additionalCompileFlags additionalLibraries) diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/DefenseMatrix.cpp spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/DefenseMatrix.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/DefenseMatrix.cpp 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/DefenseMatrix.cpp 2014-10-07 20:10:02.000000000 +0000 @@ -2,7 +2,7 @@ #include "IncExternAI.h" #include "IncGlobalAI.h" -CR_BIND(CDefenseMatrix, (NULL)); +CR_BIND(CDefenseMatrix, (NULL)) CR_REG_METADATA(CDefenseMatrix, ( CR_MEMBER(ChokeMapsByMovetype), CR_MEMBER(ChokePointArray), @@ -15,7 +15,7 @@ // CR_MEMBER(defRemoveQueue), CR_RESERVED(16), CR_POSTLOAD(PostLoad) -)); +)) CDefenseMatrix::CDefenseMatrix(AIClasses* ai) : spotFinder(NULL) diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/DefenseMatrix.h spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/DefenseMatrix.h --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/DefenseMatrix.h 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/DefenseMatrix.h 2014-10-07 20:10:02.000000000 +0000 @@ -12,7 +12,7 @@ class CDefenseMatrix { public: - CR_DECLARE(CDefenseMatrix); + CR_DECLARE(CDefenseMatrix) CDefenseMatrix(AIClasses* ai); diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/DGunController.cpp spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/DGunController.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/DGunController.cpp 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/DGunController.cpp 2014-10-07 20:10:02.000000000 +0000 @@ -10,16 +10,16 @@ extern CKAIK* KAIKStateExt; -CR_BIND(CDGunController, (NULL)); +CR_BIND(CDGunController, (NULL)) CR_REG_METADATA(CDGunController, ( CR_MEMBER(ai), CR_MEMBER(state), CR_MEMBER(commanderID), CR_RESERVED(16), CR_POSTLOAD(PostLoad) -)); +)) -CR_BIND(ControllerState, ); +CR_BIND(ControllerState, ) CR_REG_METADATA(ControllerState, ( CR_MEMBER(inited), CR_MEMBER(dgunOrderFrame), @@ -29,14 +29,14 @@ CR_MEMBER(targetID), CR_MEMBER(oldTargetPos), CR_RESERVED(16) -)); +)) -CR_BIND(CDGunControllerHandler, (NULL)); +CR_BIND(CDGunControllerHandler, (NULL)) CR_REG_METADATA(CDGunControllerHandler, ( CR_MEMBER(ai), CR_MEMBER(controllers), CR_POSTLOAD(PostLoad) -)); +)) diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/DGunController.h spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/DGunController.h --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/DGunController.h 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/DGunController.h 2014-10-07 20:10:02.000000000 +0000 @@ -19,7 +19,7 @@ struct AIClasses; struct ControllerState { - CR_DECLARE_STRUCT(ControllerState); + CR_DECLARE_STRUCT(ControllerState) ControllerState(void) { inited = false; @@ -66,7 +66,7 @@ class CDGunController { public: - CR_DECLARE(CDGunController); + CR_DECLARE(CDGunController) CDGunController(AIClasses*); ~CDGunController(void) {} @@ -94,7 +94,7 @@ class CDGunControllerHandler { public: - CR_DECLARE(CDGunControllerHandler); + CR_DECLARE(CDGunControllerHandler) CDGunControllerHandler(AIClasses* aic) { ai = aic; diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/EconomyTracker.cpp spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/EconomyTracker.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/EconomyTracker.cpp 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/EconomyTracker.cpp 2014-10-07 20:10:02.000000000 +0000 @@ -24,7 +24,7 @@ CR_MEMBER(factory), CR_MEMBER(economyUnitTracker), CR_RESERVED(16) -)); +)) CR_BIND(EconomyUnitTracker, ) CR_REG_METADATA(EconomyUnitTracker, ( @@ -50,9 +50,9 @@ CR_MEMBER(estimateMetalChangeFromDefWhileOff), CR_RESERVED(16), CR_POSTLOAD(PostLoad) -)); +)) -CR_BIND(CEconomyTracker, (NULL)); +CR_BIND(CEconomyTracker, (NULL)) CR_REG_METADATA(CEconomyTracker, ( CR_MEMBER(allTheBuildingTrackers), CR_MEMBER(deadEconomyUnitTrackers), @@ -70,7 +70,7 @@ CR_MEMBER(constructionEnergySum), CR_MEMBER(constructionMetalSum), CR_RESERVED(16) -)); +)) void EconomyUnitTracker::PostLoad() { unitDef = KAIKStateExt->GetAI()->cb->GetUnitDef(economyUnitId); @@ -384,14 +384,14 @@ state2.energyUsage = constructionEnergy; state2.metalStored += state2.metalMake - constructionMetal; state2.metalUsage = constructionMetal; - bool staling = false; + //bool staling = false; if (state2.energyStored <= 0) { - staling = true; + //staling = true; state2.energyStored = 0; } if (state2.metalStored <= 0) { - staling = true; + //staling = true; state2.metalStored = 0; } if (state2.energyStored > state2.energyStorageSize) { diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/EconomyTracker.h spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/EconomyTracker.h --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/EconomyTracker.h 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/EconomyTracker.h 2014-10-07 20:10:02.000000000 +0000 @@ -8,7 +8,7 @@ struct EconomyUnitTracker; struct BuildingTracker { - CR_DECLARE_STRUCT(BuildingTracker); + CR_DECLARE_STRUCT(BuildingTracker) int unitUnderConstruction; UnitCategory category; @@ -111,7 +111,7 @@ }; struct EconomyUnitTracker { - CR_DECLARE_STRUCT(EconomyUnitTracker); + CR_DECLARE_STRUCT(EconomyUnitTracker) void PostLoad(); int economyUnitId; // Only economyUnitId and createFrame gives a correct ID @@ -169,7 +169,7 @@ class CEconomyTracker { public: - CR_DECLARE(CEconomyTracker); + CR_DECLARE(CEconomyTracker) CEconomyTracker(AIClasses* ai); ~CEconomyTracker(); diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/.gitignore spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/.gitignore --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/.gitignore 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/.gitignore 2014-10-07 20:10:02.000000000 +0000 @@ -1,4 +1,5 @@ /CMakeFiles /cmake_install.cmake /libSkirmishAI.so +/Makefile *.swp diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/KAIK.cpp spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/KAIK.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/KAIK.cpp 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/KAIK.cpp 2014-10-07 20:10:02.000000000 +0000 @@ -9,12 +9,12 @@ #include "KAIK.h" #include "IncGlobalAI.h" -CR_BIND(CKAIK, ); +CR_BIND(CKAIK, ) CR_REG_METADATA(CKAIK, ( CR_MEMBER(ai), CR_SERIALIZER(Serialize), CR_POSTLOAD(PostLoad) -)); +)) #ifdef USING_CREG CREX_REG_STATE_COLLECTOR(CKAIK, CKAIK); diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/KAIK.h spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/KAIK.h --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/KAIK.h 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/KAIK.h 2014-10-07 20:10:02.000000000 +0000 @@ -10,7 +10,7 @@ class CKAIK: public IGlobalAI { public: - CR_DECLARE(CKAIK); + CR_DECLARE(CKAIK) CKAIK(): ai(NULL) {} ~CKAIK() {} diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/MetalMaker.cpp spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/MetalMaker.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/MetalMaker.cpp 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/MetalMaker.cpp 2014-10-07 20:10:02.000000000 +0000 @@ -11,7 +11,7 @@ CR_MEMBER(addedDelay), CR_RESERVED(16), CR_POSTLOAD(PostLoad) -)); +)) CR_BIND(CMetalMaker::UnitInfo, ) CR_REG_METADATA_SUB(CMetalMaker, UnitInfo, ( @@ -20,7 +20,7 @@ CR_MEMBER(metalPerEnergy), CR_MEMBER(turnedOn), CR_RESERVED(8) -)); +)) diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/MetalMaker.h spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/MetalMaker.h --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/MetalMaker.h 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/MetalMaker.h 2014-10-07 20:10:02.000000000 +0000 @@ -7,8 +7,8 @@ class CMetalMaker { public: - CR_DECLARE(CMetalMaker); - CR_DECLARE_SUB(UnitInfo); + CR_DECLARE(CMetalMaker) + CR_DECLARE_SUB(UnitInfo) CMetalMaker(AIClasses*); ~CMetalMaker(); @@ -20,7 +20,7 @@ void Update(int); struct UnitInfo { - CR_DECLARE_STRUCT(UnitInfo); + CR_DECLARE_STRUCT(UnitInfo) int id; float energyUse; diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/MetalMap.cpp spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/MetalMap.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/MetalMap.cpp 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/MetalMap.cpp 2014-10-07 20:10:02.000000000 +0000 @@ -109,7 +109,7 @@ } void CMetalMap::Init() { - const int frame = ai->cb->GetCurrentFrame(); + //const int frame = ai->cb->GetCurrentFrame(); // leave this line if you want to use this class in your AI ai->cb->SendTextMsg("KAI Metal Class by Krogothe", 0); diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/MicroPather.cpp spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/MicroPather.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/MicroPather.cpp 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/MicroPather.cpp 2014-10-07 20:10:02.000000000 +0000 @@ -43,6 +43,7 @@ #include #include #include +#include #include "MicroPather.h" @@ -337,7 +338,7 @@ else if (y == mapSizeY) y = mapSizeY - 1; - *startNode = (void*) (y * mapSizeX + x); + *startNode = (void*) static_cast(y * mapSizeX + x); index = (size_t) *endNode; y = index / mapSizeX; x = index - y * mapSizeX; @@ -355,7 +356,7 @@ xEndNode = x; yEndNode = y; - *endNode = (void*) (y * mapSizeX + x); + *endNode = (void*) static_cast(y * mapSizeX + x); } void MicroPather::FixNode( void** Node) { @@ -377,7 +378,7 @@ else if (y == mapSizeY) y = mapSizeY - 1; - *Node = (void*) (y * mapSizeX + x); + *Node = (void*) static_cast(y * mapSizeX + x); } @@ -743,7 +744,7 @@ if (relativeX <= xend[relativeY]) { // L("Its a hit: " << counter); - GoalReached(node, startNode, (void*) (indexStart), path); + GoalReached(node, startNode, (void*) static_cast(indexStart), path); *cost = node->costFromStart; hasStartedARun = false; diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/MicroPather.h spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/MicroPather.h --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/MicroPather.h 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/MicroPather.h 2014-10-07 20:10:02.000000000 +0000 @@ -282,7 +282,7 @@ unsigned frame; // incremented with every solve, used to determine if cached data needs to be refreshed unsigned checksum; // the checksum of the last successful "Solve". }; -}; +} #endif diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/PathFinder.cpp spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/PathFinder.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/PathFinder.cpp 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/PathFinder.cpp 2014-10-07 20:10:02.000000000 +0000 @@ -241,7 +241,7 @@ void* CPathFinder::XY2Node(int x, int y) { - return (void*) (y * PathMapXSize + x); + return (void*) static_cast(y * PathMapXSize + x); } void CPathFinder::Node2XY(void* node, int* x, int* y) { @@ -261,7 +261,7 @@ } void* CPathFinder::Pos2Node(float3 pos) { - return ((void*) (int(pos.z / SQUARE_SIZE / THREATRES) * PathMapXSize + int((pos.x / SQUARE_SIZE / THREATRES)))); + return (void*) static_cast(int(pos.z / SQUARE_SIZE / THREATRES) * PathMapXSize + int((pos.x / SQUARE_SIZE / THREATRES))); } /* @@ -449,16 +449,17 @@ bool heightOK = false; bool slopeOK = false; - switch (md->moveType) { - case MoveData::Ship_Move: { + switch (md->moveFamily) { + case MoveData::Ship: { heightOK = (hgtMap[zh * WH + xh] < -md->depth); slopeOK = true; } break; - case MoveData::Ground_Move: { + case MoveData::Tank: + case MoveData::KBot: { heightOK = (hgtMap[zh * WH + xh] > -md->depth); slopeOK = (slpMap[zs * WS + xs] < md->maxSlope); } break; - case MoveData::Hover_Move: { + case MoveData::Hover: { heightOK = true; slopeOK = (slpMap[zs * WS + xs] < md->maxSlope); } break; diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/ThreatMap.cpp spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/ThreatMap.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/ThreatMap.cpp 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/ThreatMap.cpp 2014-10-07 20:10:02.000000000 +0000 @@ -13,7 +13,7 @@ CR_MEMBER(ai), CR_RESERVED(8), CR_POSTLOAD(PostLoad) -)); +)) CThreatMap::CThreatMap(AIClasses* aic): ai(aic) { if (ai) { diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/ThreatMap.h spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/ThreatMap.h --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/ThreatMap.h 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/ThreatMap.h 2014-10-07 20:10:02.000000000 +0000 @@ -8,7 +8,7 @@ class CThreatMap { public: - CR_DECLARE(CThreatMap); + CR_DECLARE(CThreatMap) CThreatMap(AIClasses* ai); ~CThreatMap(); diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/Unit.cpp spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/Unit.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/Unit.cpp 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/Unit.cpp 2014-10-07 20:10:02.000000000 +0000 @@ -13,7 +13,7 @@ CR_MEMBER(ai), CR_RESERVED(8), CR_POSTLOAD(PostLoad) -)); +)) CUNIT::CUNIT(void) { ai = NULL; diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/Unit.h spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/Unit.h --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/Unit.h 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/Unit.h 2014-10-07 20:10:02.000000000 +0000 @@ -11,7 +11,7 @@ class CUNIT { public: - CR_DECLARE(CUNIT); + CR_DECLARE(CUNIT) CUNIT(void); CUNIT(AIClasses* ai); diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/UnitHandler.cpp spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/UnitHandler.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/UnitHandler.cpp 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/UnitHandler.cpp 2014-10-07 20:10:02.000000000 +0000 @@ -5,7 +5,7 @@ #include "IncExternAI.h" #include "IncGlobalAI.h" -CR_BIND(CUnitHandler, (NULL)); +CR_BIND(CUnitHandler, (NULL)) CR_REG_METADATA(CUnitHandler, ( CR_MEMBER(IdleUnits), CR_MEMBER(BuildTasks), @@ -25,7 +25,7 @@ CR_MEMBER(ai), CR_MEMBER(taskPlanCounter), CR_RESERVED(16) -)); +)) CUnitHandler::CUnitHandler(AIClasses* ai) { diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/UnitHandler.h spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/UnitHandler.h --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/UnitHandler.h 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/UnitHandler.h 2014-10-07 20:10:02.000000000 +0000 @@ -16,7 +16,7 @@ class CUnitHandler { public: - CR_DECLARE(CUnitHandler); + CR_DECLARE(CUnitHandler) CUnitHandler(AIClasses* ai); ~CUnitHandler(); diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/UnitTable.cpp spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/UnitTable.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/UnitTable.cpp 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/UnitTable.cpp 2014-10-07 20:10:02.000000000 +0000 @@ -11,7 +11,7 @@ #include "KAIK.h" extern CKAIK* KAIKStateExt; -CR_BIND(CUnitTable, ); +CR_BIND(CUnitTable, ) CR_REG_METADATA(CUnitTable, ( CR_MEMBER(categoryData), @@ -19,9 +19,9 @@ CR_MEMBER(unitTypes), CR_POSTLOAD(PostLoad) -)); +)) -CR_BIND(CategoryData, ); +CR_BIND(CategoryData, ) CR_REG_METADATA(CategoryData, ( CR_MEMBER(groundFactories), CR_MEMBER(groundBuilders), @@ -33,7 +33,7 @@ CR_MEMBER(metalStorages), CR_MEMBER(energyStorages), CR_MEMBER(nukeSilos) -)); +)) diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/UnitTable.h spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/UnitTable.h --- spring-96.0~14.04~ppa4/AI/Skirmish/KAIK/UnitTable.h 2014-01-03 13:30:01.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/KAIK/UnitTable.h 2014-10-07 20:10:02.000000000 +0000 @@ -14,7 +14,7 @@ } // namespace springLegacyAI struct CategoryData { - CR_DECLARE_STRUCT(CategoryData); + CR_DECLARE_STRUCT(CategoryData) bool CanBuild(UnitDefCategory c) const { switch (c) { @@ -81,7 +81,7 @@ class CUnitTable { public: - CR_DECLARE(CUnitTable); + CR_DECLARE(CUnitTable) CUnitTable() {} CUnitTable(AIClasses* ai); diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/RAI/Builder.cpp spring-98.0~14.04~ppa6/AI/Skirmish/RAI/Builder.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/RAI/Builder.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/RAI/Builder.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -17,20 +17,20 @@ index=0; type=0; deletionFrame=0; -}; +} sBuildQuarry::~sBuildQuarry() { if( BL != 0 ) BL->unitsActive--; -}; +} bool sBuildQuarry::IsValid(int frame) { if( int(creationID.size()) == 0 && builderID == -1 && frame >= deletionFrame ) return false; return true; -}; +} void sBuildQuarry::SetRS(ResourceSiteExt* rs) { @@ -39,7 +39,7 @@ RS = rs; if( RS != 0 ) RS->builderID=builderID; -}; +} // ------------------------------------------------------------------------------------------------ cBuilder::cBuilder(IAICallback* callback, cRAI* global) @@ -218,7 +218,7 @@ fPos.z-=150+rand()%201; else fPos.z+=150+rand()%201; - fPos.y=cb->GetElevation(fPos.x,fPos.z); + G->CorrectPosition(fPos); c.params.push_back(fPos.x); c.params.push_back(fPos.y); c.params.push_back(fPos.z); diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/RAI/BuilderPlacement.cpp spring-98.0~14.04~ppa6/AI/Skirmish/RAI/BuilderPlacement.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/RAI/BuilderPlacement.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/RAI/BuilderPlacement.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -56,7 +56,7 @@ searchRadius=48.0f; } disApart=3; -}; +} void ResourceSiteExt::CheckBlocked() { diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/RAI/CMakeLists.txt spring-98.0~14.04~ppa6/AI/Skirmish/RAI/CMakeLists.txt --- spring-96.0~14.04~ppa4/AI/Skirmish/RAI/CMakeLists.txt 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/RAI/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -2,8 +2,8 @@ # set(mySourceDirRel "") # Common values are "" or "src" -set(additionalSources ${CUtils_SRC}) +set(additionalSources "") set(additionalCompileFlags "") -set(additionalLibraries ${LegacyCpp_AIWRAPPER_TARGET}) +set(additionalLibraries ${LegacyCpp_AIWRAPPER_TARGET} CUtils) ConfigureNativeSkirmishAI(mySourceDirRel additionalSources additionalCompileFlags additionalLibraries) diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/RAI/CombatManager.cpp spring-98.0~14.04~ppa6/AI/Skirmish/RAI/CombatManager.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/RAI/CombatManager.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/RAI/CombatManager.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -63,9 +63,12 @@ else // cant see enemy or Mod Workaround: Combat Lords - cant be given attack orders { c.id = CMD_MOVE; - c.params.push_back(EPos.x -100.0 +rand()%201 ); + EPos.x += -100.0 +rand()%201; + EPos.z += -100.0 +rand()%201; + G->CorrectPosition(EPos); + c.params.push_back(EPos.x); c.params.push_back(EPos.y); - c.params.push_back(EPos.z -100.0 +rand()%201 ); + c.params.push_back(EPos.z); } cb->GiveOrder(unit, &c); @@ -218,6 +221,7 @@ float distanceAway=(0.87*U->enemyEff->BestRange-EDis); Pos.x+=(Pos.x-EPos.x)*(distanceAway/EDis); Pos.z+=(Pos.z-EPos.z)*(distanceAway/EDis); + G->CorrectPosition(Pos); if( !G->TM->CanMoveToPos(U->area,Pos) ) return false; @@ -243,7 +247,7 @@ Command c; c.id = CMD_MOVE; c.params.push_back(Pos.x); - c.params.push_back(cb->GetElevation(Pos.x,Pos.z)); + c.params.push_back(Pos.y); c.params.push_back(Pos.z); cb->GiveOrder(unitID, &c); G->UpdateEventAdd(1,cb->GetCurrentFrame()+210,unitID,U); diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/RAI/RAI.cpp spring-98.0~14.04~ppa6/AI/Skirmish/RAI/RAI.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/RAI/RAI.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/RAI/RAI.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -18,7 +18,7 @@ namespace std { - void _xlen(){}; + void _xlen(){} } UnitInfo::UnitInfo(sRAIUnitDef* rUnitDef) @@ -827,15 +827,19 @@ c.params.clear(); c.id = CMD_MOVE; c.options = SHIFT_KEY; + float3 newPos; if( position.x < conPosition.x ) - c.params.push_back(position.x - ((position.x-conPosition.x)/position.distance2D(conPosition))*(8.0*eventList[0]->unitI->ud->xsize/2.0 +8.0*eventList[0]->unitI->BuildQ->creationUD->ud->xsize/2.0) ); + newPos.x = (position.x - ((position.x-conPosition.x)/position.distance2D(conPosition))*(8.0*eventList[0]->unitI->ud->xsize/2.0 +8.0*eventList[0]->unitI->BuildQ->creationUD->ud->xsize/2.0) ); else - c.params.push_back(position.x + ((position.x-conPosition.x)/position.distance2D(conPosition))*(8.0*eventList[0]->unitI->ud->xsize/2.0 +8.0*eventList[0]->unitI->BuildQ->creationUD->ud->xsize/2.0) ); - c.params.push_back(position.y); + newPos.x = (position.x + ((position.x-conPosition.x)/position.distance2D(conPosition))*(8.0*eventList[0]->unitI->ud->xsize/2.0 +8.0*eventList[0]->unitI->BuildQ->creationUD->ud->xsize/2.0) ); if( position.z < conPosition.z ) - c.params.push_back(position.z - ((position.z-conPosition.z)/position.distance2D(conPosition))*(8.0*eventList[0]->unitI->ud->zsize/2.0 +8.0*eventList[0]->unitI->BuildQ->creationUD->ud->zsize/2.0) ); + newPos.z = (position.z - ((position.z-conPosition.z)/position.distance2D(conPosition))*(8.0*eventList[0]->unitI->ud->zsize/2.0 +8.0*eventList[0]->unitI->BuildQ->creationUD->ud->zsize/2.0) ); else - c.params.push_back(position.z + ((position.z-conPosition.z)/position.distance2D(conPosition))*(8.0*eventList[0]->unitI->ud->zsize/2.0 +8.0*eventList[0]->unitI->BuildQ->creationUD->ud->zsize/2.0) ); + newPos.z = (position.z + ((position.z-conPosition.z)/position.distance2D(conPosition))*(8.0*eventList[0]->unitI->ud->zsize/2.0 +8.0*eventList[0]->unitI->BuildQ->creationUD->ud->zsize/2.0) ); + CorrectPosition(newPos); + c.params.push_back(newPos.x); + c.params.push_back(newPos.y); + c.params.push_back(newPos.z); cb->GiveOrder(eventList[0]->unitID,&c); } } @@ -848,16 +852,21 @@ Command c; c.id = CMD_MOVE; float f = (40.0+(rand()%401)/10.0); + float3 newPos = position; if( rand()%2 == 0 ) - c.params.push_back(position.x + f ); + newPos.x += f; else - c.params.push_back(position.x - f ); - c.params.push_back(position.y); + newPos.x -= f; f = (40.0+(rand()%401)/10.0); if( rand()%2 == 0 ) - c.params.push_back(position.z + f ); + newPos.z += f; else - c.params.push_back(position.z - f ); + newPos.z -= f; + + CorrectPosition(newPos); + c.params.push_back(newPos.x); + c.params.push_back(newPos.y); + c.params.push_back(newPos.z); cb->GiveOrder(eventList[0]->unitID,&c); *eventList[0]->lastPosition = position; } @@ -985,12 +994,12 @@ { if( position.x < 1 ) position.x = 1; - else if( position.x > 8*cb->GetMapWidth()-1 ) - position.x = 8*cb->GetMapWidth()-1; + else if( position.x > 8*cb->GetMapWidth()-2 ) + position.x = 8*cb->GetMapWidth()-2; if( position.z < 1 ) position.z = 1; - else if( position.z > 8*cb->GetMapHeight()-1 ) - position.z = 8*cb->GetMapHeight()-1; + else if( position.z > 8*cb->GetMapHeight()-2 ) + position.z = 8*cb->GetMapHeight()-2; position.y = cb->GetElevation(position.x,position.z); } @@ -1016,7 +1025,7 @@ { Pos.x=1.0 + rand()%7 + 8.0*(rand()%cb->GetMapWidth()); Pos.z=1.0 + rand()%7 + 8.0*(rand()%cb->GetMapHeight()); - Pos.y=cb->GetElevation(Pos.x,Pos.z); + CorrectPosition(Pos); return Pos; } @@ -1026,7 +1035,7 @@ int iS=Temp.at(rand()%int(Temp.size())); Pos.x=TM->sector[iS].position.x - TM->convertStoP/2-1.0 + rand()%(TM->convertStoP-1); Pos.z=TM->sector[iS].position.z - TM->convertStoP/2-1.0 + rand()%(TM->convertStoP-1); - Pos.y=cb->GetElevation(Pos.x,Pos.z); + CorrectPosition(Pos); return Pos; } diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/RAI/UnitDefHandler.cpp spring-98.0~14.04~ppa6/AI/Skirmish/RAI/UnitDefHandler.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/RAI/UnitDefHandler.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/RAI/UnitDefHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -19,7 +19,8 @@ task = Task; else task = -1; -}; +} + sRAIUnitDefBL::~sRAIUnitDefBL() { for(int iUD=0; iUDUDefSize; iUD++ ) @@ -42,7 +43,7 @@ iBL=RUD->ListSize; // end loop } } -}; +} // ------------------------------------------------------------------------------------------------ @@ -337,7 +338,7 @@ } return ud->id; -}; +} int sRAIUnitDef::GetPrerequisiteNewBuilder() { @@ -592,19 +593,19 @@ // ------------------------------------------------------------------------------------------------ -sRAIBuildList::sRAIBuildList(int MaxDefSize, cRAIUnitDefHandler *UDRHandler) +sRAIBuildList::sRAIBuildList(int MaxDefSize, cRAIUnitDefHandler *UDRHandler): + Name("Undefined"), + UDR(UDRHandler), + UDef(new sRAIUnitDefBL*[MaxDefSize]), + UDefActive(0), + UDefActiveTemp(0), + UDefSize(0), + priority(-1), + minUnits(0), + unitsActive(0), + index(UDR->BLSize), + minEfficiency(1.0) { - UDR = UDRHandler; - index = UDR->BLSize; - UDef = new sRAIUnitDefBL*[MaxDefSize]; - UDefSize=0; - UDefActive=0; - UDefActiveTemp=0; - priority=-1; - minUnits=0; - minEfficiency=1.0; - unitsActive=0; - Name = "Undefined"; } sRAIBuildList::~sRAIBuildList() diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/RAI/UnitManager.cpp spring-98.0~14.04~ppa6/AI/Skirmish/RAI/UnitManager.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/RAI/UnitManager.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/RAI/UnitManager.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -470,6 +470,7 @@ group->M->RallyPoint = GPos; else group->M->RallyPoint = pos; + G->CorrectPosition(group->M->RallyPoint); // G->DebugDrawShape(group->M->RallyPoint,100.0f,5,0,50,900); } diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/CMakeLists.txt spring-98.0~14.04~ppa6/AI/Skirmish/Shard/CMakeLists.txt --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/CMakeLists.txt 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/CMakeLists.txt 2014-10-07 20:10:05.000000000 +0000 @@ -2,9 +2,9 @@ # set(mySourceDirRel "") # Common values are "" or "src" -set(additionalSources ${CUtils_SRC}) +set(additionalSources "") set(additionalCompileFlags "") -set(additionalLibraries ${Cpp_AIWRAPPER_TARGET}) +set(additionalLibraries ${Cpp_AIWRAPPER_TARGET} CUtils) if (BUILD_Cpp_AIWRAPPER) diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/ai.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/ai.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/ai.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/ai.lua 2014-10-07 20:10:05.000000000 +0000 @@ -13,12 +13,12 @@ if next(modules) ~= nil then for i,m in ipairs(modules) do newmodule = m() + game:SendToConsole("adding "..newmodule:Name().." module") local internalname = newmodule:internalName() self[internalname] = newmodule table.insert(self.modules,newmodule) newmodule:Init() - game:SendToConsole("added "..newmodule:Name().." module") end end end @@ -35,6 +35,19 @@ end end end + +function AI:GameMessage(text) + if self.gameend == true then + return + end + for i,m in ipairs(self.modules) do + if m == nil then + game:SendToConsole("nil module!") + else + m:GameMessage(text) + end + end +end function AI:UnitCreated(engineunit) if self.gameend == true then diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/assisthandler.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/assisthandler.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/assisthandler.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/assisthandler.lua 2014-10-07 20:10:05.000000000 +0000 @@ -34,12 +34,12 @@ local f = game:Frame() if f > self.lastAllocation + 1800 then self.lastAllocation = f - local Metal = game:GetResourceByName("Metal") - if Metal.reserves > Metal.capacity * 0.33 then + if ai.Metal.full > 0.33 then ai.nonAssistantsPerName = math.max(ai.nonAssistantsPerName - 1, 2) - elseif Metal.reserves < math.min(Metal.income * 2, Metal.capacity * 0.1) then + elseif ai.Metal.tics < 2 or ai.Metal.full < 0.1 then ai.nonAssistantsPerName = math.min(ai.nonAssistantsPerName + 1, ConUnitPerTypeLimit) for fi, asstbehaviour in pairs(self.free) do + if ai.IDByName[asstbehaviour.id] == nil then self:AssignIDByName(asstbehaviour) end if ai.IDByName[asstbehaviour.id] <= ai.nonAssistantsPerName then ai.nonAssistant[asstbehaviour.id] = true asstbehaviour.unit:ElectBehaviour() diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/attackerbehaviour.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/attackerbehaviour.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/attackerbehaviour.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/attackerbehaviour.lua 2014-10-07 20:10:05.000000000 +0000 @@ -8,11 +8,6 @@ end end -local CMD_MOVE_STATE = 50 -local MOVESTATE_HOLDPOS = 0 -local MOVESTATE_MANEUVER = 1 -local MOVESTATE_ROAM = 2 - function IsAttacker(unit) local uname = unit:Internal():Name() for i,name in ipairs(attackerlist) do @@ -29,9 +24,19 @@ local mtype, network = ai.maphandler:MobilityOfUnit(self.unit:Internal()) self.mtype = mtype self.name = self.unit:Internal():Name() - self.size = unitTable[self.name].xsize * unitTable[self.name].zsize * 16 - self.range = math.max(unitTable[self.name].groundRange, unitTable[self.name].airRange, unitTable[self.name].submergedRange) + local ut = unitTable[self.name] + self.level = ut.techLevel - 1 + if self.level == 0 then self.level = 0.5 elseif self.level < 0 then self.level = 0.25 end + self.size = ut.xsize * ut.zsize * 16 + self.range = math.max(ut.groundRange, ut.airRange, ut.submergedRange) self.awayDistance = self.range * 0.9 + if ut.groundRange > 0 then + self.hits = "ground" + elseif ut.submergedRange > 0 then + self.hits = "submerged" + elseif ut.airRange > 0 then + self.hits = "air" + end end function AttackerBehaviour:UnitBuilt(unit) @@ -57,7 +62,9 @@ end function AttackerBehaviour:UnitIdle(unit) - + if unit.engineID == self.unit.engineID then + self.idle = true + end end function AttackerBehaviour:Attack(pos, realClose) @@ -76,6 +83,7 @@ if self.active then self.unit:Internal():Move(self.target) end + self.idle = nil self.unit:ElectBehaviour() end end @@ -113,6 +121,7 @@ end ordered = true end + self.idle = nil self.unit:ElectBehaviour() end return ordered @@ -122,6 +131,7 @@ self.attacking = false self.congregating = false self.target = nil + self.idle = nil self.unit:ElectBehaviour() end diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/attackhandler.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/attackhandler.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/attackhandler.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/attackhandler.lua 2014-10-07 20:10:05.000000000 +0000 @@ -25,6 +25,7 @@ function AttackHandler:Init() self.recruits = {} + self.count = {} self.squads = {} self.counter = {} self.attackSent = {} @@ -64,11 +65,16 @@ end function AttackHandler:DraftSquads() + -- if ai.incomingThreat > 0 then game:SendToConsole(ai.incomingThreat .. " " .. (ai.battleCount + ai.breakthroughCount) * 75) end + if ai.incomingThreat > (ai.battleCount + ai.breakthroughCount) * 75 then + EchoDebug("not a good time to attack") + return + end -- do not attack if we're in trouble local needtarget = {} local f = game:Frame() -- find which mtypes need targets - for mtype, recruits in pairs(self.recruits) do - if f > self.attackSent[mtype] + 1800 and #recruits >= self.counter[mtype] then + for mtype, count in pairs(self.count) do + if f > self.attackSent[mtype] + 1800 and count >= self.counter[mtype] then table.insert(needtarget, mtype) end end @@ -95,6 +101,7 @@ self.attackSent[mtype] = f table.insert(self.squads, squad) -- clear recruits + self.count[mtype] = 0 self.recruits[mtype] = {} ai.hasAttacked = ai.hasAttacked + 1 self.counter[mtype] = self.counter[mtype] + 1 @@ -106,71 +113,79 @@ function AttackHandler:ReTarget() local f = game:Frame() for is, squad in pairs(self.squads) do - if f > squad.lastReTarget + 450 then - squad.lastReTarget = f - local representative - for iu, member in pairs(squad.members) do - if member ~= nil then - if member.unit ~= nil then - representative = member.unit:Internal() - if representative ~= nil then - break + if f > squad.lastReTarget + 300 then + if squad.idle or squad.reachedTarget then + if squad.idle or f > squad.reachedTarget + 900 then + local representative + for iu, member in pairs(squad.members) do + if member ~= nil then + if member.unit ~= nil then + representative = member.unit:Internal() + if representative ~= nil then + break + end + end end end - end - end - if squad.buildingIDs ~= nil then - self:IDsWeAreNotAttacking(squad.buildingIDs) - end - if representative == nil then - self.attackSent[squad.mtype] = 0 - table.remove(self.squads, is) - else - -- find a target - local bestCell = ai.targethandler:GetBestAttackCell(representative) - if bestCell == nil then - squad.notarget = squad.notarget + 1 - if squad.target == nil or squad.notarget > 3 then - -- if no target found initially, or no target for the last three targetting checks, disassemble and recruit the squad - for iu, member in pairs(squad.members) do - self:AddRecruit(member) - end + if squad.buildingIDs ~= nil then + self:IDsWeAreNotAttacking(squad.buildingIDs) + end + if representative == nil then self.attackSent[squad.mtype] = 0 table.remove(self.squads, is) + else + -- find a target + local bestCell = ai.targethandler:GetBestAttackCell(representative) + if bestCell == nil then + -- squad.notarget = squad.notarget + 1 + -- if squad.target == nil or squad.notarget > 3 then + -- if no target found initially, or no target for the last three targetting checks, disassemble and recruit the squad + for iu, member in pairs(squad.members) do + self:AddRecruit(member) + end + self.attackSent[squad.mtype] = 0 + table.remove(self.squads, is) + -- end + else + squad.target = bestCell.pos + self:IDsWeAreAttacking(bestCell.buildingIDs, squad.mtype) + squad.buildingIDs = bestCell.buildingIDs + squad.notarget = 0 + squad.reachedTarget = nil + end end - else - squad.target = bestCell.pos - self:IDsWeAreAttacking(bestCell.buildingIDs, squad.mtype) - squad.buildingIDs = bestCell.buildingIDs - squad.notarget = 0 end end + squad.lastReTarget = f end end end function AttackHandler:DoMovement() + local f = game:Frame() for is, squad in pairs(self.squads) do -- get a representative and midpoint local representative local totalx = 0 local totalz = 0 local totalSize = 0 - for iu, member in pairs(squad.members) do - local unit - if member ~= nil then - if member.unit ~= nil then - unit = member.unit:Internal() + if squad.hasCongregated then + for iu, member in pairs(squad.members) do + local unit + if member ~= nil then + if member.unit ~= nil then + unit = member.unit:Internal() + end + end + if unit ~= nil then + if representative == nil then representative = unit end + local tmpPos = unit:GetPosition() + totalx = totalx + tmpPos.x + totalz = totalz + tmpPos.z + totalSize = totalSize + member.size + else + table.remove(squad.members, iu) end - end - if unit ~= nil then - if representative == nil then representative = unit end - local tmpPos = unit:GetPosition() - totalx = totalx + tmpPos.x - totalz = totalz + tmpPos.z - totalSize = totalSize + member.size - else - table.remove(squad.members, iu) end end @@ -179,16 +194,25 @@ table.remove(self.squads, is) else -- determine distances from midpoint - local midPos = api.Position() - midPos.x = totalx / #squad.members - midPos.z = totalz / #squad.members - midPos.y = 0 + local midPos + if squad.hasCongregated then + midPos = api.Position() + midPos.x = totalx / #squad.members + midPos.z = totalz / #squad.members + midPos.y = 0 + else + local representativeBehaviour = squad.members[#squad.members] + representative = representativeBehaviour.unit:Internal() + midPos = ai.frontPosition[representativeBehaviour.hits] or representative:GetPosition() + end local congDist = sqrt(pi * totalSize) * 2 local stragglers = 0 local damaged = 0 + local idle = 0 local maxRange = 0 for iu, member in pairs(squad.members) do if member.damaged then damaged = damaged + 1 end + if member.idle then idle = idle + 1 end if member.range > maxRange then maxRange = member.range end local unit = member.unit:Internal() local upos = unit:GetPosition() @@ -237,13 +261,21 @@ local congregate = false EchoDebug("attack squad of " .. #squad.members .. " members, " .. stragglers .. " stragglers") local tenth = math.ceil(#squad.members * 0.1) + local half = math.ceil(#squad.members * 0.5) if stragglers >= tenth and damaged < tenth then -- don't congregate if we're being shot congregate = true end local twiceMaxRange = maxRange * 2 local distToTarget = Distance(midPos, squad.target) + local reached = distToTarget < twiceMaxRange + if reached then + squad.reachedTarget = f + else + squad.reachedTarget = nil + end + squad.idle = idle > half local realClose = false - if stragglers < math.ceil(#squad.members * 0.5) and distToTarget < twiceMaxRange then + if stragglers < half and squad.reachedTarget then congregate = false realClose = true end @@ -259,6 +291,7 @@ local ordered = member:Congregate(midPos) if not ordered and squad.congregating then squad.congregating = false end end + squad.hasCongregated = true end squad.attacking = nil squad.close = nil @@ -350,6 +383,9 @@ if self.recruits[mtype] == nil then self.recruits[mtype] = {} end if self.counter[mtype] == nil then self.counter[mtype] = baseAttackCounter end if self.attackSent[mtype] == nil then self.attackSent[mtype] = 0 end + if self.count[mtype] == nil then self.count[mtype] = 0 end + local level = attkbehaviour.level + self.count[mtype] = self.count[mtype] + level table.insert(self.recruits[mtype], attkbehaviour) attkbehaviour:SetMoveState() attkbehaviour:Free() @@ -363,6 +399,8 @@ for mtype, recruits in pairs(self.recruits) do for i,v in ipairs(recruits) do if v == attkbehaviour then + local level = attkbehaviour.level + self.count[mtype] = self.count[mtype] - level table.remove(self.recruits[mtype], i) return true end @@ -373,7 +411,8 @@ function AttackHandler:NeedMore(attkbehaviour) local mtype = attkbehaviour.mtype - self.counter[mtype] = self.counter[mtype] + 0.75 + local level = attkbehaviour.level + self.counter[mtype] = self.counter[mtype] + (level * 0.7) -- 0.75 EchoDebug(mtype .. " attack counter: " .. self.counter[mtype]) end diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/behaviours.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/behaviours.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/behaviours.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/behaviours.lua 2014-10-07 20:10:05.000000000 +0000 @@ -3,7 +3,7 @@ require "attackerbehaviour" require "raiderbehaviour" require "bomberbehaviour" -require "runfromattack" +require "wardbehaviour" require "mexupgradebehaviour" require "assistbehaviour" require "reclaimbehaviour" @@ -34,11 +34,11 @@ if nanoTurretList[un] then table.insert(b, AssistBehaviour) - table.insert(b, RunFromAttackBehaviour) + table.insert(b, WardBehaviour) end if unitTable[un].isBuilding then - table.insert(b, RunFromAttackBehaviour) --tells defending units to rush to threatened buildings + table.insert(b, WardBehaviour) --tells defending units to rush to threatened buildings if nukeList[un] then table.insert(b, NukeBehaviour) elseif antinukeList[un] then @@ -64,29 +64,27 @@ ai.advCons = 0 end table.insert(b,TaskQueueBehaviour) - table.insert(b, RunFromAttackBehaviour) else table.insert(b,TaskQueueBehaviour) if unitTable[un].isBuilding then table.insert(b, FactoryRegisterBehaviour) - -- game:SendToConsole("factory register behaviour") else table.insert(b, AssistBehaviour) table.insert(b, ReclaimBehaviour) - table.insert(b, RunFromAttackBehaviour) end end + table.insert(b, WardBehaviour) elseif IsReclaimer(unit) then table.insert(b, ReclaimBehaviour) table.insert(b, DefendBehaviour) - table.insert(b, RunFromAttackBehaviour) + table.insert(b, WardBehaviour) else if IsAttacker(unit) then table.insert(b, AttackerBehaviour) - if battleList[un] or breakthroughList[un] then + -- if battleList[un] or breakthroughList[un] then -- arty and merl don't make good defense table.insert(b, DefendBehaviour) - end + -- end end if IsRaider(unit) then table.insert(b, RaiderBehaviour) @@ -98,7 +96,7 @@ end if IsScout(unit) then table.insert(b, ScoutBehaviour) - table.insert(b, RunFromAttackBehaviour) + table.insert(b, WardBehaviour) end if IsDefender(unit) then table.insert(b, DefendBehaviour) diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/bomberbehaviour.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/bomberbehaviour.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/bomberbehaviour.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/bomberbehaviour.lua 2014-10-07 20:10:05.000000000 +0000 @@ -5,8 +5,6 @@ return (bomberList[tmpName] or 0) > 0 end -local CMD_ATTACK = 20 - BomberBehaviour = class(Behaviour) function BomberBehaviour:Init() @@ -59,13 +57,12 @@ function BomberBehaviour:BombTarget(target) if target ~= nil then - pos = target:GetPosition() + local pos = target.position if pos ~= nil then - self.target = target.engineID + self.target = target.unitID self.bombing = true self.lastOrderFrame = game:Frame() if self.active then - --self.unit:Internal():Attack(pos) self:BombPosition(pos) self.targetpos = pos end @@ -90,7 +87,7 @@ self.active = true if self.target then self.lastOrderFrame = game:Frame() - self.unit:Internal():Attack(self.target) + CustomCommand(self.unit:Internal(), CMD_ATTACK, {self.target}) self.target = nil self.targetpos = nil else diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/bomberhandler.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/bomberhandler.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/bomberhandler.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/bomberhandler.lua 2014-10-07 20:10:05.000000000 +0000 @@ -60,7 +60,6 @@ else bombTarget = ai.targethandler:GetBestBomberTarget() end - if bombTarget ~= nil then EchoDebug("got target for " .. weapon) for i,recruit in ipairs(recruits) do diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/bootbehaviour.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/bootbehaviour.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/bootbehaviour.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/bootbehaviour.lua 2014-10-07 20:10:05.000000000 +0000 @@ -1,5 +1,7 @@ require "common" +-- Sends units out of factories and holds units in place who are being repaired after resurrection + BootBehaviour = class(Behaviour) local DebugEnabled = false @@ -75,40 +77,41 @@ self.factory = nil self.unit:ElectBehaviour() elseif self.active and self.lastOrderFrame and self.lastExitSide then - -- fifteen seconds after the first attempt, try a different side - if f > self.lastOrderFrame + 450 then - if self.factory.sides ~= 1 then - if self.factory.sides == 2 then - if self.lastExitSide == "south" then - self:ExitFactory("north") - elseif self.lastExitSide == "north" then - self:ExitFactory("south") - end - elseif self.factory.sides == 3 then - if self.lastExitSide == "south" then - self:ExitFactory("east") - elseif self.lastExitSide == "east" then - self:ExitFactory("west") - elseif self.lastExitSide == "west" then - self:ExitFactory("south") - end - elseif self.factory.sides == 4 then - if self.lastExitSide == "south" then - self:ExitFactory("north") - elseif self.lastExitSide == "north" then - self:ExitFactory("east") - elseif self.lastExitSide == "east" then - self:ExitFactory("west") - elseif self.lastExitSide == "west" then - self:ExitFactory("south") - end + -- twelve seconds after the first attempt, try a different side + -- if there's only one side, try it again + if f > self.lastOrderFrame + 360 then + if self.factory.sides == 1 then + self:ExitFactory("south") + elseif self.factory.sides == 2 then + if self.lastExitSide == "south" then + self:ExitFactory("north") + elseif self.lastExitSide == "north" then + self:ExitFactory("south") + end + elseif self.factory.sides == 3 then + if self.lastExitSide == "south" then + self:ExitFactory("east") + elseif self.lastExitSide == "east" then + self:ExitFactory("west") + elseif self.lastExitSide == "west" then + self:ExitFactory("south") + end + elseif self.factory.sides == 4 then + if self.lastExitSide == "south" then + self:ExitFactory("north") + elseif self.lastExitSide == "north" then + self:ExitFactory("east") + elseif self.lastExitSide == "east" then + self:ExitFactory("west") + elseif self.lastExitSide == "west" then + self:ExitFactory("south") end end end end end else - if f > self.lastInFactoryCheck + 150 then + if f > self.lastInFactoryCheck + 300 then -- units (especially construction units) can still get stuck in factories long after they're built self.lastInFactoryCheck = f self:FindMyFactory() @@ -185,7 +188,7 @@ local u = self.unit:Internal() local pos = self.factory.position local out = api.Position() - out.x = pos.x + out.x = pos.x + 0 out.y = pos.y + outX out.z = pos.z + outZ if out.x > ai.maxElmosX - 1 then diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/buildhandler.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/buildhandler.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/buildhandler.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/buildhandler.lua 1970-01-01 00:00:00.000000000 +0000 @@ -1,526 +0,0 @@ -require "common" - -local DebugEnabled = false -local DebugEnabledPlans = false -local debugPlotBuildFile - -local function EchoDebug(inStr) - if DebugEnabled then - game:SendToConsole("BuildSiteHandler: " .. inStr) - end -end - -local function EchoDebugPlans(inStr) - if DebugEnabledPlans then - game:SendToConsole("BuildSiteHandler Plans: " .. inStr) - end -end - -local function PlotRectDebug(rect) - if DebugEnabledPlans then - local label - if rect.unitName then - label = "PLAN" - else - label = "NOBUILD" - end - local string = rect.x1 .. " " .. rect.z1 .. " " .. rect.x2 .. " " .. rect.z2 .. " " .. label .. "\n" - debugPlotBuildFile:write(string) - end -end - -BuildSiteHandler = class(Module) - -local sqrt = math.sqrt - - -function BuildSiteHandler:Name() - return "BuildSiteHandler" -end - -function BuildSiteHandler:internalName() - return "buildsitehandler" -end - -function BuildSiteHandler:Init() - local mapSize = map:MapDimensions() - ai.maxElmosX = mapSize.x * 8 - ai.maxElmosZ = mapSize.z * 8 - ai.maxElmosDiag = sqrt(ai.maxElmosX^2 + ai.maxElmosZ^2) - ai.lvl1Mexes = 1 -- this way mexupgrading doesn't revert to taskqueuing before it has a chance to find mexes to upgrade - self.resurrectionRepair = {} - self.dontBuildRects = {} - self.plans = {} - self.constructing = {} - self.history = {} - self:DontBuildOnMetalOrGeoSpots() -end - -function BuildSiteHandler:PlansOverlap(position, unitName) - local rect = { position = position, unitName = unitName } - self:CalculateRect(rect) - for i, plan in pairs(self.plans) do - if RectsOverlap(rect, plan) then - return true - end - end - return false -end - --- keeps amphibious/hover cons from zigzagging from the water to the land too far -function BuildSiteHandler:LandWaterFilter(pos, unitTypeToBuild, builder) - local builderName = builder:Name() - local mtype = unitTable[builderName].mtype - if mtype ~= "amp" and mtype ~= "hov" and not commanderList[builderName] then - -- don't bother with units that aren't amphibious - return true - end - local unitName = unitTypeToBuild:Name() - if unitTable[unitName].extractsMetal > 0 or unitTable[unitName].buildOptions then - -- leave mexes and factories alone - return true - end - -- where is the con? - local builderPos = builder:GetPosition() - local water = ai.maphandler:MobilityNetworkHere("shp", builderPos) - -- is this a land or a water unit we're building? - local waterBuildOrder = unitTable[unitName].needsWater - -- if this is a movement from land to water or water to land, check the distance - if water then EchoDebug(builderName .. " is in water") else EchoDebug(builderName .. " is on land") end - if waterBuildOrder then EchoDebug(unitName .. " would be in water") else EchoDebug(unitName .. " would be on land") end - if (water and not waterBuildOrder) or (not water and waterBuildOrder) then - EchoDebug("builder would traverse the shore to build " .. unitName) - local dist = Distance(pos, builderPos) - if dist > 250 then - EchoDebug("build too far away from shore to build " .. unitName) - return false - else - return true - end - else - return true - end -end - -function BuildSiteHandler:CheckBuildPos(pos, unitTypeToBuild, builder, originalPosition) - -- make sure it's on the map - if pos ~= nil then - if unitTable[unitTypeToBuild:Name()].buildOptions then - -- don't build factories too close to south map edge because they face south - if (pos.x <= 0) or (pos.x > ai.maxElmosX) or (pos.z <= 0) or (pos.z > ai.maxElmosZ - 240) then - EchoDebug("bad position: " .. pos.x .. ", " .. pos.z) - pos = nil - end - else - if (pos.x <= 0) or (pos.x > ai.maxElmosX) or (pos.z <= 0) or (pos.z > ai.maxElmosZ) then - EchoDebug("bad position: " .. pos.x .. ", " .. pos.z) - pos = nil - end - end - end - -- sanity check: is it REALLY possible to build here? - if pos ~= nil then - local s = map:CanBuildHere(unitTypeToBuild, pos) - if not s then - EchoDebug("cannot build " .. unitTypeToBuild:Name() .. " here: " .. pos.x .. ", " .. pos.z) - pos = nil - end - end - local rect - if pos ~= nil then - rect = {position = pos, unitName = unitTypeToBuild:Name()} - self:CalculateRect(rect) - end - -- is it too far away from an amphibious constructor? - if pos ~= nil then - local lw = self:LandWaterFilter(pos, unitTypeToBuild, builder) - if not lw then - pos = nil - end - end - -- don't build where you shouldn't (metal spots, geo spots, factory lanes) - if pos ~= nil then - for i, dont in pairs(self.dontBuildRects) do - if RectsOverlap(rect, dont) then - pos = nil - break - end - end - end - -- don't build on top of current build orders - if pos ~= nil then - for i, plan in pairs(self.plans) do - if RectsOverlap(rect, plan) then - pos = nil - break - end - end - end - -- don't build where the builder can't go - if pos ~= nil then - if not ai.maphandler:UnitCanGoHere(builder, pos) then - EchoDebug(builder:Name() .. " can't go there: " .. pos.x .. "," .. pos.z) - pos = nil - end - end - if pos ~= nil then - local uname = unitTypeToBuild:Name() - if nanoTurretList[uname] then - -- don't build nanos too far away from factory - local dist = Distance(originalPosition, pos) - EchoDebug("nano distance: " .. dist) - if dist > 390 then - EchoDebug("nano too far from factory") - pos = nil - end - elseif bigPlasmaList[uname] or littlePlasmaList[uname] or nukeList[uname] then - -- don't build bombarding units outside of bombard positions - local b = ai.targethandler:IsBombardPosition(pos, uname) - if not b then - EchoDebug("bombard not in bombard position") - pos = nil - end - end - end - return pos -end - -function BuildSiteHandler:GetBuildSpacing(unitTypeToBuild) - local spacing = 1 - local name = unitTypeToBuild:Name() - if unitTable[name].isWeapon then spacing = 8 end - if unitTable[name].bigExplosion then spacing = 20 end - if unitTable[name].buildOptions then spacing = 4 end - return spacing -end - -function BuildSiteHandler:ClosestBuildSpot(builder, position, unitTypeToBuild, minimumDistance, attemptNumber, buildDistance) - -- return self:ClosestBuildSpotInSpiral(builder, unitTypeToBuild, position) - if attemptNumber == nil then EchoDebug("looking for build spot for " .. builder:Name() .. " to build " .. unitTypeToBuild:Name()) end - local minDistance = minimumDistance or self:GetBuildSpacing(unitTypeToBuild) - if buildDistance == nil then buildDistance = 100 end - local tmpAttemptNumber = attemptNumber or 0 - local pos = nil - - if tmpAttemptNumber > 0 then - local searchAngle = (tmpAttemptNumber - 1) / 3 * math.pi - local searchRadius = 2 * buildDistance / 3 - local searchPos = api.Position() - searchPos.x = position.x + searchRadius * math.sin(searchAngle) - searchPos.z = position.z + searchRadius * math.cos(searchAngle) - searchPos.y = position.y - -- EchoDebug(math.ceil(searchPos.x) .. ", " .. math.ceil(searchPos.z)) - pos = map:FindClosestBuildSite(unitTypeToBuild, searchPos, searchRadius / 2, minDistance) - else - pos = map:FindClosestBuildSite(unitTypeToBuild, position, buildDistance, minDistance) - end - - -- if pos == nil then EchoDebug("pos is nil before check") end - - -- check that we haven't got an offmap order, that it's possible to build the unit there, that it's not in front of a factory or on top of a metal spot, and that the builder can actually move there - pos = self:CheckBuildPos(pos, unitTypeToBuild, builder, position) - - if pos == nil then - -- EchoDebug("attempt number " .. tmpAttemptNumber .. " nil") - -- first try increasing tmpAttemptNumber, up to 7 - if tmpAttemptNumber < 19 then - if tmpAttemptNumber == 7 or tmpAttemptNumber == 13 then - buildDistance = buildDistance + 100 - if minDistance < 5 then - minDistance = minDistance + 2 - elseif minDistance < 21 then - minDistance = minDistance - 4 - end - end - pos = self:ClosestBuildSpot(builder, position, unitTypeToBuild, minDistance, tmpAttemptNumber + 1, buildDistance) - else - -- check manually check in a spiral - EchoDebug("trying spiral check") - pos = self:ClosestBuildSpotInSpiral(builder, unitTypeToBuild, position, minDistance * 16) - end - end - - return pos -end - -function BuildSiteHandler:ClosestBuildSpotInSpiral(builder, unitTypeToBuild, position, dist, segmentSize, direction, i) - local pos = nil - if dist == nil then - local ut = unitTable[unitTypeToBuild:Name()] - dist = math.max(ut.xsize, ut.zsize) * 8 - -- dist = 64 - end - if segmentSize == nil then segmentSize = 1 end - if direction == nil then direction = 1 end - if i == nil then i = 0 end - -- have to set it this way, otherwise both just point to the same set of data, and originalPosition doesn't stay the same - local originalPosition = api.Position() - originalPosition.x = position.x * 1 - originalPosition.y = position.y * 1 - originalPosition.z = position.z * 1 - - EchoDebug("new spiral search") - while segmentSize < 8 do - -- EchoDebug(i .. " " .. direction .. " " .. segmentSize .. " : " .. math.ceil(position.x) .. " " .. math.ceil(position.z)) - if direction == 1 then - position.x = position.x + dist - elseif direction == 2 then - position.z = position.z + dist - elseif direction == 3 then - position.x = position.x - dist - elseif direction == 4 then - position.z = position.z - dist - end - pos = self:CheckBuildPos(position, unitTypeToBuild, builder, originalPosition) - if pos ~= nil then break end - i = i + 1 - if i == segmentSize then - i = 0 - direction = direction + 1 - if direction == 3 then - segmentSize = segmentSize + 1 - elseif direction == 5 then - segmentSize = segmentSize + 1 - direction = 1 - end - end - end - - return pos -end - -function BuildSiteHandler:ClosestHighestLevelFactory(builder, maxDist) - local bpos = builder:GetPosition() - local minDist = maxDist - local maxLevel = ai.maxFactoryLevel - EchoDebug(maxLevel .. " max factory level") - local factoryPos = nil - if ai.factoriesAtLevel[maxLevel] ~= nil then - for i, factory in pairs(ai.factoriesAtLevel[maxLevel]) do - if not ai.outmodedFactoryID[factory.id] then - local dist = Distance(bpos, factory.position) - if dist < minDist then - minDist = dist - factoryPos = factory.position - end - end - end - end - return factoryPos -end - -function BuildSiteHandler:DontBuildRectangle(x1, z1, x2, z2, unitID) - x1 = math.ceil(x1) - z1 = math.ceil(z1) - x2 = math.ceil(x2) - z2 = math.ceil(z2) - table.insert(self.dontBuildRects, {x1 = x1, z1 = z1, x2 = x2, z2 = z2, unitID = unitID}) -end - --- handle deaths -function BuildSiteHandler:DoBuildRectangleByUnitID(unitID) - for i, rect in pairs(self.dontBuildRects) do - if rect.unitID == unitID then - table.remove(self.dontBuildRects, i) - end - end - self:PlotAllDebug() -end - -function BuildSiteHandler:DontBuildOnMetalOrGeoSpots() - local spots = ai.scoutSpots["air"][1] - for i, p in pairs(spots) do - self:DontBuildRectangle(p.x-40, p.z-40, p.x+40, p.z+40) - end - self:PlotAllDebug() -end - -function BuildSiteHandler:UnitCreated(unit) - local unitName = unit:Name() - local position = unit:GetPosition() - local planned = false - for i, plan in pairs(self.plans) do - if plan.unitName == unitName and PositionWithinRect(position, plan) then - if plan.resurrect then - -- so that bootbehaviour will hold it in place while it gets repaired - EchoDebug("resurrection of " .. unitName .. " begun") - self.resurrectionRepair[unit:ID()] = plan.behaviour - else - EchoDebug(plan.behaviour.name .. " began constructing " .. unitName) - if unitTable[unitName].isBuilding then - -- so that oversized factory lane rectangles will overlap with existing buildings - self:DontBuildRectangle(plan.x1, plan.z1, plan.x2, plan.z2, unit:ID()) - end - local unitID = unit:ID() - -- tell the builder behaviour that construction has begun - plan.behaviour:ConstructionBegun(unitID, plan.unitName, plan.position) - -- pass on to the table of what we're actually building - plan.frame = game:Frame() - self.constructing[unitID] = plan - table.remove(self.plans, i) - end - planned = true - break - end - end - if not planned and unitTable[unitName].isBuilding then - -- for when we're restarting the AI - local rect = { position = position, unitName = unitName } - self:CalculateRect(rect) - self:DontBuildRectangle(rect.x1, rect.z1, rect.x2, rect.z2, unit:ID()) - end - self:PlotAllDebug() -end - --- prevents duplication of expensive buildings and building more than one factory at once --- true means there's a duplicate, false means there isn't -function BuildSiteHandler:CheckForDuplicates(unitName) - if unitName == nil then return true end - if unitName == DummyUnitName then return true end - local utable = unitTable[unitName] - local isFactory = utable.isBuilding and utable.buildOptions - local isExpensive = utable.metalCost > 300 - if not isFactory and not isExpensive then return false end - EchoDebugPlans("looking for duplicate plan for " .. unitName) - for i, plan in pairs(self.plans) do - local thisIsFactory = unitTable[plan.unitName].isBuilding and unitTable[plan.unitName].buildOptions - if isFactory and thisIsFactory then return true end - if isExpensive and plan.unitName == unitName then return true end - end - EchoDebugPlans("looking for duplicate construction for " .. unitName) - for unitID, construct in pairs(self.constructing) do - local thisIsFactory = unitTable[construct.unitName].isBuilding and unitTable[construct.unitName].buildOptions - if isFactory and thisIsFactory then return true end - if isExpensive and construct.unitName == unitName then return true end - end - EchoDebugPlans("looking for duplicate history " .. unitName) - if isFactory then - -- look through history for factories built recently - local f = game:Frame() - for i, done in pairs(self.history) do - if f > done.frame + 1800 then - -- clear history older than a minute - table.remove(self.history, i) - end - local thisIsFactory = unitTable[done.unitName].isBuilding and unitTable[done.unitName].buildOptions - if thisIsFactory then - if f < done.frame + 600 then - -- don't build factories within 20 seconds of one another - EchoDebug("found a factory too recently") - return true - end - end - end - end - return false -end - -function BuildSiteHandler:UnitBuilt(unit) - local unitID = unit:ID() - local done = self.constructing[unitID] - if done then - EchoDebugPlans(done.behaviour.name .. " " .. done.behaviour.id .. " completed " .. done.unitName .. " " .. unitID) - done.behaviour:ConstructionComplete() - done.frame = game:Frame() - table.insert(self.history, done) - self.constructing[unitID] = nil - end -end - -function BuildSiteHandler:UnitDead(unit) - local unitID = unit:ID() - local construct = self.constructing[unitID] - if construct then - construct.behaviour:ConstructionComplete() - self.constructing[unitID] = nil - end - self:DoBuildRectangleByUnitID(unitID) -end - -function BuildSiteHandler:CalculateRect(rect) - local unitName = rect.unitName - if factoryExitSides[unitName] ~= nil and factoryExitSides[unitName] ~= 0 then - self:CalculateFactoryLane(rect) - return - end - local position = rect.position - local outX = unitTable[unitName].xsize * 4 - local outZ = unitTable[unitName].zsize * 4 - rect.x1 = position.x - outX - rect.z1 = position.z - outZ - rect.x2 = position.x + outX - rect.z2 = position.z + outZ -end - -function BuildSiteHandler:CalculateFactoryLane(rect) - local unitName = rect.unitName - local position = rect.position - local outX = unitTable[unitName].xsize * 4 - local outZ = unitTable[unitName].zsize * 4 - rect.x1 = position.x - outX - rect.x2 = position.x + outX - local sides = factoryExitSides[unitName] - if sides == 1 then - rect.z1 = position.z - outZ - rect.z2 = position.z + outZ * 5 - elseif sides >= 2 then - local tall = outZ * 5 - rect.z1 = position.z - tall - rect.z2 = position.z + tall - else - rect.z1 = position.z - outZ - rect.z2 = position.z + outZ - end -end - -function BuildSiteHandler:NewPlan(unitName, position, behaviour, resurrect) - if resurrect then - EchoDebugPlans("new plan to resurrect " .. unitName .. " at " .. position.x .. ", " .. position.z) - else - EchoDebugPlans(behaviour.name .. " plans to build " .. unitName .. " at " .. position.x .. ", " .. position.z) - end - local plan = {unitName = unitName, position = position, behaviour = behaviour, resurrect = resurrect} - -- positions are in the center of units, so outX and outZ are half the footprint size - self:CalculateRect(plan) - table.insert(self.plans, plan) - self:PlotAllDebug() -end - -function BuildSiteHandler:ClearMyPlans(behaviour) - for i, plan in pairs(self.plans) do - if plan.behaviour == behaviour then - table.remove(self.plans, i) - end - end - self:PlotAllDebug() -end - -function BuildSiteHandler:ClearMyConstruction(behaviour) - for unitID, construct in pairs(self.constructing) do - if construct.behaviour == behaviour then - self.constructing[unitID] = nil - end - end - self:PlotAllDebug() -end - -function BuildSiteHandler:RemoveResurrectionRepairedBy(unitID) - self.resurrectionRepair[unitID] = nil -end - -function BuildSiteHandler:ResurrectionRepairedBy(unitID) - return self.resurrectionRepair[unitID] -end - -function BuildSiteHandler:PlotAllDebug() - if DebugEnabledPlans then - debugPlotBuildFile = assert(io.open("debugbuildplot",'w'), "Unable to write debugbuildplot") - for i, plan in pairs(self.plans) do - PlotRectDebug(plan) - end - for i, rect in pairs(self.dontBuildRects) do - PlotRectDebug(rect) - end - debugPlotBuildFile:close() - end -end \ No newline at end of file diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/buildsitehandler.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/buildsitehandler.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/buildsitehandler.lua 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/buildsitehandler.lua 2014-10-07 20:10:05.000000000 +0000 @@ -0,0 +1,541 @@ +require "common" + +local DebugEnabled = false +local DebugEnabledPlans = false +local debugPlotBuildFile + +local function EchoDebug(inStr) + if DebugEnabled then + game:SendToConsole("BuildSiteHandler: " .. inStr) + end +end + +local function EchoDebugPlans(inStr) + if DebugEnabledPlans then + game:SendToConsole("BuildSiteHandler Plans: " .. inStr) + end +end + +local function PlotRectDebug(rect) + if DebugEnabledPlans then + local label + if rect.unitName then + label = "PLAN" + else + label = "NOBUILD" + end + local string = rect.x1 .. " " .. rect.z1 .. " " .. rect.x2 .. " " .. rect.z2 .. " " .. label .. "\n" + debugPlotBuildFile:write(string) + end +end + +BuildSiteHandler = class(Module) + +local sqrt = math.sqrt + + +function BuildSiteHandler:Name() + return "BuildSiteHandler" +end + +function BuildSiteHandler:internalName() + return "buildsitehandler" +end + +function BuildSiteHandler:Init() + local mapSize = map:MapDimensions() + ai.maxElmosX = mapSize.x * 8 + ai.maxElmosZ = mapSize.z * 8 + ai.maxElmosDiag = sqrt(ai.maxElmosX^2 + ai.maxElmosZ^2) + ai.lvl1Mexes = 1 -- this way mexupgrading doesn't revert to taskqueuing before it has a chance to find mexes to upgrade + self.resurrectionRepair = {} + self.dontBuildRects = {} + self.plans = {} + self.constructing = {} + self.history = {} + self:DontBuildOnMetalOrGeoSpots() +end + +function BuildSiteHandler:PlansOverlap(position, unitName) + local rect = { position = position, unitName = unitName } + self:CalculateRect(rect) + for i, plan in pairs(self.plans) do + if RectsOverlap(rect, plan) then + return true + end + end + return false +end + +-- keeps amphibious/hover cons from zigzagging from the water to the land too far +function BuildSiteHandler:LandWaterFilter(pos, unitTypeToBuild, builder) + local builderName = builder:Name() + local mtype = unitTable[builderName].mtype + if mtype ~= "amp" and mtype ~= "hov" and not commanderList[builderName] then + -- don't bother with units that aren't amphibious + return true + end + local unitName = unitTypeToBuild:Name() + if unitTable[unitName].extractsMetal > 0 or unitTable[unitName].buildOptions then + -- leave mexes and factories alone + return true + end + -- where is the con? + local builderPos = builder:GetPosition() + local water = ai.maphandler:MobilityNetworkHere("shp", builderPos) + -- is this a land or a water unit we're building? + local waterBuildOrder = unitTable[unitName].needsWater + -- if this is a movement from land to water or water to land, check the distance + if water then EchoDebug(builderName .. " is in water") else EchoDebug(builderName .. " is on land") end + if waterBuildOrder then EchoDebug(unitName .. " would be in water") else EchoDebug(unitName .. " would be on land") end + if (water and not waterBuildOrder) or (not water and waterBuildOrder) then + EchoDebug("builder would traverse the shore to build " .. unitName) + local dist = Distance(pos, builderPos) + if dist > 250 then + EchoDebug("build too far away from shore to build " .. unitName) + return false + else + return true + end + else + return true + end +end + +function BuildSiteHandler:CheckBuildPos(pos, unitTypeToBuild, builder, originalPosition) + -- make sure it's on the map + if pos ~= nil then + if unitTable[unitTypeToBuild:Name()].buildOptions then + -- don't build factories too close to south map edge because they face south + if (pos.x <= 0) or (pos.x > ai.maxElmosX) or (pos.z <= 0) or (pos.z > ai.maxElmosZ - 240) then + EchoDebug("bad position: " .. pos.x .. ", " .. pos.z) + pos = nil + end + else + if (pos.x <= 0) or (pos.x > ai.maxElmosX) or (pos.z <= 0) or (pos.z > ai.maxElmosZ) then + EchoDebug("bad position: " .. pos.x .. ", " .. pos.z) + pos = nil + end + end + end + -- sanity check: is it REALLY possible to build here? + if pos ~= nil then + local s = map:CanBuildHere(unitTypeToBuild, pos) + if not s then + EchoDebug("cannot build " .. unitTypeToBuild:Name() .. " here: " .. pos.x .. ", " .. pos.z) + pos = nil + end + end + local rect + if pos ~= nil then + rect = {position = pos, unitName = unitTypeToBuild:Name()} + self:CalculateRect(rect) + end + -- is it too far away from an amphibious constructor? + if pos ~= nil then + local lw = self:LandWaterFilter(pos, unitTypeToBuild, builder) + if not lw then + pos = nil + end + end + -- don't build where you shouldn't (metal spots, geo spots, factory lanes) + if pos ~= nil then + for i, dont in pairs(self.dontBuildRects) do + if RectsOverlap(rect, dont) then + pos = nil + break + end + end + end + -- don't build on top of current build orders + if pos ~= nil then + for i, plan in pairs(self.plans) do + if RectsOverlap(rect, plan) then + pos = nil + break + end + end + end + -- don't build where the builder can't go + if pos ~= nil then + if not ai.maphandler:UnitCanGoHere(builder, pos) then + EchoDebug(builder:Name() .. " can't go there: " .. pos.x .. "," .. pos.z) + pos = nil + end + end + if pos ~= nil then + local uname = unitTypeToBuild:Name() + if nanoTurretList[uname] then + -- don't build nanos too far away from factory + local dist = Distance(originalPosition, pos) + EchoDebug("nano distance: " .. dist) + if dist > 390 then + EchoDebug("nano too far from factory") + pos = nil + end + elseif bigPlasmaList[uname] or littlePlasmaList[uname] or nukeList[uname] then + -- don't build bombarding units outside of bombard positions + local b = ai.targethandler:IsBombardPosition(pos, uname) + if not b then + EchoDebug("bombard not in bombard position") + pos = nil + end + end + end + return pos +end + +function BuildSiteHandler:GetBuildSpacing(unitTypeToBuild) + local spacing = 1 + local name = unitTypeToBuild:Name() + if unitTable[name].isWeapon then spacing = 8 end + if unitTable[name].bigExplosion then spacing = 20 end + if unitTable[name].buildOptions then spacing = 4 end + return spacing +end + +function BuildSiteHandler:ClosestBuildSpot(builder, position, unitTypeToBuild, minimumDistance, attemptNumber, buildDistance) + -- return self:ClosestBuildSpotInSpiral(builder, unitTypeToBuild, position) + if attemptNumber == nil then EchoDebug("looking for build spot for " .. builder:Name() .. " to build " .. unitTypeToBuild:Name()) end + local minDistance = minimumDistance or self:GetBuildSpacing(unitTypeToBuild) + if buildDistance == nil then buildDistance = 100 end + local tmpAttemptNumber = attemptNumber or 0 + local pos = nil + + if tmpAttemptNumber > 0 then + local searchAngle = (tmpAttemptNumber - 1) / 3 * math.pi + local searchRadius = 2 * buildDistance / 3 + local searchPos = api.Position() + searchPos.x = position.x + searchRadius * math.sin(searchAngle) + searchPos.z = position.z + searchRadius * math.cos(searchAngle) + searchPos.y = position.y + 0 + -- EchoDebug(math.ceil(searchPos.x) .. ", " .. math.ceil(searchPos.z)) + pos = map:FindClosestBuildSite(unitTypeToBuild, searchPos, searchRadius / 2, minDistance) + else + pos = map:FindClosestBuildSite(unitTypeToBuild, position, buildDistance, minDistance) + end + + -- if pos == nil then EchoDebug("pos is nil before check") end + + -- check that we haven't got an offmap order, that it's possible to build the unit there, that it's not in front of a factory or on top of a metal spot, and that the builder can actually move there + pos = self:CheckBuildPos(pos, unitTypeToBuild, builder, position) + + if pos == nil then + -- EchoDebug("attempt number " .. tmpAttemptNumber .. " nil") + -- first try increasing tmpAttemptNumber, up to 7 + if tmpAttemptNumber < 19 then + if tmpAttemptNumber == 7 or tmpAttemptNumber == 13 then + buildDistance = buildDistance + 100 + if minDistance < 5 then + minDistance = minDistance + 2 + elseif minDistance < 21 then + minDistance = minDistance - 4 + end + end + pos = self:ClosestBuildSpot(builder, position, unitTypeToBuild, minDistance, tmpAttemptNumber + 1, buildDistance) + else + -- check manually check in a spiral + EchoDebug("trying spiral check") + pos = self:ClosestBuildSpotInSpiral(builder, unitTypeToBuild, position, minDistance * 16) + end + end + + return pos +end + +function BuildSiteHandler:ClosestBuildSpotInSpiral(builder, unitTypeToBuild, position, dist, segmentSize, direction, i) + local pos = nil + if dist == nil then + local ut = unitTable[unitTypeToBuild:Name()] + dist = math.max(ut.xsize, ut.zsize) * 8 + -- dist = 64 + end + if segmentSize == nil then segmentSize = 1 end + if direction == nil then direction = 1 end + if i == nil then i = 0 end + -- have to set it this way, otherwise both just point to the same set of data, and originalPosition doesn't stay the same + local searchPos = api.Position() + searchPos.x = position.x + 0 + searchPos.y = position.y + 0 + searchPos.z = position.z + 0 + + EchoDebug("new spiral search") + while segmentSize < 8 do + -- EchoDebug(i .. " " .. direction .. " " .. segmentSize .. " : " .. math.ceil(position.x) .. " " .. math.ceil(position.z)) + if direction == 1 then + searchPos.x = searchPos.x + dist + elseif direction == 2 then + searchPos.z = searchPos.z + dist + elseif direction == 3 then + searchPos.x = searchPos.x - dist + elseif direction == 4 then + searchPos.z = searchPos.z - dist + end + pos = self:CheckBuildPos(searchPos, unitTypeToBuild, builder, position) + if pos ~= nil then break end + i = i + 1 + if i == segmentSize then + i = 0 + direction = direction + 1 + if direction == 3 then + segmentSize = segmentSize + 1 + elseif direction == 5 then + segmentSize = segmentSize + 1 + direction = 1 + end + end + end + + return pos +end + +function BuildSiteHandler:ClosestHighestLevelFactory(builder, maxDist) + local bpos = builder:GetPosition() + local minDist = maxDist + local maxLevel = ai.maxFactoryLevel + EchoDebug(maxLevel .. " max factory level") + local factoryPos = nil + if ai.factoriesAtLevel[maxLevel] ~= nil then + for i, factory in pairs(ai.factoriesAtLevel[maxLevel]) do + if not ai.outmodedFactoryID[factory.id] then + local dist = Distance(bpos, factory.position) + if dist < minDist then + minDist = dist + factoryPos = factory.position + end + end + end + end + if factoryPos then + local newpos = api.Position() + newpos.x = factoryPos.x + newpos.z = factoryPos.z + newpos.y = factoryPos.y + return newpos + else + return + end +end + +function BuildSiteHandler:DontBuildRectangle(x1, z1, x2, z2, unitID) + x1 = math.ceil(x1) + z1 = math.ceil(z1) + x2 = math.ceil(x2) + z2 = math.ceil(z2) + table.insert(self.dontBuildRects, {x1 = x1, z1 = z1, x2 = x2, z2 = z2, unitID = unitID}) +end + +-- handle deaths +function BuildSiteHandler:DoBuildRectangleByUnitID(unitID) + for i, rect in pairs(self.dontBuildRects) do + if rect.unitID == unitID then + table.remove(self.dontBuildRects, i) + end + end + self:PlotAllDebug() +end + +function BuildSiteHandler:DontBuildOnMetalOrGeoSpots() + local spots = ai.scoutSpots["air"][1] + for i, p in pairs(spots) do + self:DontBuildRectangle(p.x-40, p.z-40, p.x+40, p.z+40) + end + self:PlotAllDebug() +end + +function BuildSiteHandler:UnitCreated(unit) + local unitName = unit:Name() + local position = unit:GetPosition() + local unitID = unit:ID() + local planned = false + for i, plan in pairs(self.plans) do + if plan.unitName == unitName and PositionWithinRect(position, plan) then + if plan.resurrect then + -- so that bootbehaviour will hold it in place while it gets repaired + EchoDebug("resurrection of " .. unitName .. " begun") + self.resurrectionRepair[unitID] = plan.behaviour + else + EchoDebug(plan.behaviour.name .. " began constructing " .. unitName) + if unitTable[unitName].isBuilding then + -- so that oversized factory lane rectangles will overlap with existing buildings + self:DontBuildRectangle(plan.x1, plan.z1, plan.x2, plan.z2, unitID) + ai.turtlehandler:PlanCreated(plan, unitID) + end + -- tell the builder behaviour that construction has begun + plan.behaviour:ConstructionBegun(unitID, plan.unitName, plan.position) + -- pass on to the table of what we're actually building + plan.frame = game:Frame() + self.constructing[unitID] = plan + table.remove(self.plans, i) + end + planned = true + break + end + end + if not planned and unitTable[unitName].isBuilding then + -- for when we're restarting the AI, or other contingency + local rect = { position = position, unitName = unitName } + self:CalculateRect(rect) + self:DontBuildRectangle(rect.x1, rect.z1, rect.x2, rect.z2, unitID) + ai.turtlehandler:NewUnit(unitName, position, unitID) + end + self:PlotAllDebug() +end + +-- prevents duplication of expensive buildings and building more than one factory at once +-- true means there's a duplicate, false means there isn't +function BuildSiteHandler:CheckForDuplicates(unitName) + if unitName == nil then return true end + if unitName == DummyUnitName then return true end + local utable = unitTable[unitName] + local isFactory = utable.isBuilding and utable.buildOptions + local isExpensive = utable.metalCost > 300 + if not isFactory and not isExpensive then return false end + EchoDebugPlans("looking for duplicate plan for " .. unitName) + for i, plan in pairs(self.plans) do + local thisIsFactory = unitTable[plan.unitName].isBuilding and unitTable[plan.unitName].buildOptions + if isFactory and thisIsFactory then return true end + if isExpensive and plan.unitName == unitName then return true end + end + EchoDebugPlans("looking for duplicate construction for " .. unitName) + for unitID, construct in pairs(self.constructing) do + local thisIsFactory = unitTable[construct.unitName].isBuilding and unitTable[construct.unitName].buildOptions + if isFactory and thisIsFactory then return true end + if isExpensive and construct.unitName == unitName then return true end + end + EchoDebugPlans("looking for duplicate history " .. unitName) + if isFactory then + -- look through history for factories built recently + local f = game:Frame() + for i, done in pairs(self.history) do + if f > done.frame + 1800 then + -- clear history older than a minute + table.remove(self.history, i) + end + local thisIsFactory = unitTable[done.unitName].isBuilding and unitTable[done.unitName].buildOptions + if thisIsFactory then + if f < done.frame + 600 then + -- don't build factories within 20 seconds of one another + EchoDebug("found a factory too recently") + return true + end + end + end + end + return false +end + +function BuildSiteHandler:UnitBuilt(unit) + local unitID = unit:ID() + local done = self.constructing[unitID] + if done then + EchoDebugPlans(done.behaviour.name .. " " .. done.behaviour.id .. " completed " .. done.unitName .. " " .. unitID) + done.behaviour:ConstructionComplete() + done.frame = game:Frame() + table.insert(self.history, done) + self.constructing[unitID] = nil + end +end + +function BuildSiteHandler:UnitDead(unit) + local unitID = unit:ID() + local construct = self.constructing[unitID] + if construct then + construct.behaviour:ConstructionComplete() + self.constructing[unitID] = nil + end + self:DoBuildRectangleByUnitID(unitID) +end + +function BuildSiteHandler:CalculateRect(rect) + local unitName = rect.unitName + if factoryExitSides[unitName] ~= nil and factoryExitSides[unitName] ~= 0 then + self:CalculateFactoryLane(rect) + return + end + local position = rect.position + local outX = unitTable[unitName].xsize * 4 + local outZ = unitTable[unitName].zsize * 4 + rect.x1 = position.x - outX + rect.z1 = position.z - outZ + rect.x2 = position.x + outX + rect.z2 = position.z + outZ +end + +function BuildSiteHandler:CalculateFactoryLane(rect) + local unitName = rect.unitName + local position = rect.position + local outX = unitTable[unitName].xsize * 4 + local outZ = unitTable[unitName].zsize * 4 + rect.x1 = position.x - outX + rect.x2 = position.x + outX + local tall = outZ * 7 + local sides = factoryExitSides[unitName] + if sides == 1 then + rect.z1 = position.z - outZ + rect.z2 = position.z + tall + elseif sides >= 2 then + rect.z1 = position.z - tall + rect.z2 = position.z + tall + else + rect.z1 = position.z - outZ + rect.z2 = position.z + outZ + end +end + +function BuildSiteHandler:NewPlan(unitName, position, behaviour, resurrect) + if resurrect then + EchoDebugPlans("new plan to resurrect " .. unitName .. " at " .. position.x .. ", " .. position.z) + else + EchoDebugPlans(behaviour.name .. " plans to build " .. unitName .. " at " .. position.x .. ", " .. position.z) + end + local plan = {unitName = unitName, position = position, behaviour = behaviour, resurrect = resurrect} + self:CalculateRect(plan) + if not resurrect and unitTable[unitName].isBuilding then + ai.turtlehandler:NewUnit(unitName, position, plan) + end + table.insert(self.plans, plan) + self:PlotAllDebug() +end + +function BuildSiteHandler:ClearMyPlans(behaviour) + for i, plan in pairs(self.plans) do + if plan.behaviour == behaviour then + if not plan.resurrect and unitTable[plan.unitName].isBuilding then + ai.turtlehandler:PlanCancelled(plan) + end + table.remove(self.plans, i) + end + end + self:PlotAllDebug() +end + +function BuildSiteHandler:ClearMyConstruction(behaviour) + for unitID, construct in pairs(self.constructing) do + if construct.behaviour == behaviour then + self.constructing[unitID] = nil + end + end + self:PlotAllDebug() +end + +function BuildSiteHandler:RemoveResurrectionRepairedBy(unitID) + self.resurrectionRepair[unitID] = nil +end + +function BuildSiteHandler:ResurrectionRepairedBy(unitID) + return self.resurrectionRepair[unitID] +end + +function BuildSiteHandler:PlotAllDebug() + if DebugEnabledPlans then + debugPlotBuildFile = assert(io.open("debugbuildplot",'w'), "Unable to write debugbuildplot") + for i, plan in pairs(self.plans) do + PlotRectDebug(plan) + end + for i, rect in pairs(self.dontBuildRects) do + PlotRectDebug(rect) + end + debugPlotBuildFile:close() + end +end \ No newline at end of file diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/commonfunctions.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/commonfunctions.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/commonfunctions.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/commonfunctions.lua 2014-10-07 20:10:05.000000000 +0000 @@ -6,13 +6,44 @@ cos = math.cos sin = math.sin atan2 = math.atan2 +floor = math.floor +ceil = math.ceil +abs = math.abs +min = math.min +max = math.max + +CMD_ATTACK = 20 +CMD_RECLAIM = 90 +CMD_GUARD = 25 +CMD_MOVE_STATE = 50 +MOVESTATE_HOLDPOS = 0 +MOVESTATE_MANEUVER = 1 +MOVESTATE_ROAM = 2 + +local mapBuffer = 32 + +local layerNames = {"ground", "air", "submerged"} +local unitThreatLayers = {} +local whatHurtsUnit = {} +local whatHurtsMtype = {} +local unitWeaponLayers = {} +local unitWeaponMtypes = {} + +local quadX = { -1, 1, -1, 1 } +local quadZ = { -1, -1, 1, 1 } + +function ConstrainToMap(x, z) + x = max(min(x, ai.maxElmosX-mapBuffer), mapBuffer) + z = max(min(z, ai.maxElmosZ-mapBuffer), mapBuffer) + return x, z +end function RandomAway(pos, dist, opposite, angle) if angle == nil then angle = random() * twicePi end local away = api.Position() away.x = pos.x + dist * cos(angle) away.z = pos.z - dist * sin(angle) - away.y = pos.y + away.y = pos.y + 0 if away.x < 1 then away.x = 1 elseif away.x > ai.maxElmosX - 1 then @@ -38,6 +69,12 @@ return dist end +function DistanceXZ(x1, z1, x2, z2) + local xd = x1 - x2 + local zd = z1 - z2 + return sqrt(xd*xd + zd*zd) +end + function ManhattanDistance(pos1,pos2) local xd = math.abs(pos1.x-pos2.x) local yd = math.abs(pos1.z-pos2.z) @@ -45,6 +82,26 @@ return dist end +function ApplyVector(x, z, vx, vz, frames) + if frames == nil then frames = 30 end + return ConstrainToMap(x + (vx *frames), z + (vz * frames)) +end + +function AngleDist(angle1, angle2) + return abs((angle1 + pi - angle2) % twicePi - pi) + -- Spring.Echo(math.floor(angleDist * 57.29), math.floor(high * 57.29), math.floor(low * 57.29)) +end + +function AngleAdd(angle1, angle2) + return (angle1 + angle2) % twicePi +end + +function AngleAtoB(x1, z1, x2, z2) + local dx = x2 - x1 + local dz = z2 - z1 + return atan2(-dz, dx) +end + function CheckRect(rect) local new = {} if rect.x1 > rect.x2 then @@ -90,4 +147,162 @@ end end return iter +end + +function CustomCommand(unit, cmdID, cmdParams) + local floats = api.vectorFloat() + for i = 1, #cmdParams do + floats:push_back(cmdParams[i]) + end + return unit:ExecuteCustomCommand(cmdID, floats) +end + +function ThreatRange(unitName, groundAirSubmerged) + local threatLayers = unitThreatLayers[unitName] + if groundAirSubmerged ~= nil and threatLayers ~= nil then + local layer = threatLayers[groundAirSubmerged] + if layer ~= nil then + return layer.threat, layer.range + end + end + if antinukeList[unitName] or nukeList[unitName] or bigPlasmaList[unitName] or shieldList[unitName] then + return 0, 0 + end + local utable = unitTable[unitName] + if groundAirSubmerged == nil then + if utable.groundRange > utable.airRange and utable.groundRange > utable.submergedRange then + groundAirSubmerged = "ground" + elseif utable.airRange > utable.groundRange and utable.airRange > utable.submergedRange then + groundAirSubmerged = "air" + elseif utable.submergedRange > utable.groundRange and utable.submergedRange > utable.airRange then + groundAirSubmerged = "submerged" + end + if groundAirSubmerged == nil then + return 0, 0 + end + end + if threatLayers ~= nil then + local layer = threatLayers[groundAirSubmerged] + if layer ~= nil then + return layer.threat, layer.range + end + end + local threat = 0 + local range = 0 + if groundAirSubmerged == "ground" then + range = utable.groundRange + elseif groundAirSubmerged == "air" then + range = utable.airRange + elseif groundAirSubmerged == "submerged" then + range = utable.submergedRange + end + if range > 0 and threat == 0 then + threat = utable.metalCost + end + -- double the threat if it's a building (buildings are more bang for your buck) + if threat > 0 and utable.isBuilding then threat = threat + threat end + if unitThreatLayers[unitName] == nil then unitThreatLayers[unitName] = {} end + unitThreatLayers[unitName][groundAirSubmerged] = { threat = threat, range = range } + return threat, range +end + +function UnitThreatRangeLayers(unitName) + local threatLayers = unitThreatLayers[unitName] + if threatLayers ~= nil then + if #threatLayers == 3 then return threatLayers end + end + threatLayers = {} + for i, layerName in pairs(layerNames) do + local threat, range = ThreatRange(unitName, layerName) + threatLayers[layerName] = { threat = threat, range = range } + end + unitThreatLayers[unitName] = threatLayers + return threatLayers +end + +function UnitWeaponLayerList(unitName) + local weaponLayers = unitWeaponLayers[unitName] + if weaponLayers then return weaponLayers end + weaponLayers = {} + local ut = unitTable[unitName] + if not ut then + return weaponLayers + end + if ut.groundRange > 0 then + table.insert(weaponLayers, "ground") + end + if ut.airRange > 0 then + table.insert(weaponLayers, "air") + end + if ut.submergedRange > 0 then + table.insert(weaponLayers, "submerged") + end + unitWeaponLayers[unitName] = weaponLayers + return weaponLayers +end + +function UnitWeaponMtypeList(unitName) + if unitName == nil then return {} end + if unitName == DummyUnitName then return {} end + local mtypes = unitWeaponMtypes[unitName] + if mtypes then return mtypes end + local utable = unitTable[unitName] + mtypes = {} + if utable.groundRange > 0 then + table.insert(mtypes, "veh") + table.insert(mtypes, "bot") + table.insert(mtypes, "amp") + table.insert(mtypes, "hov") + table.insert(mtypes, "shp") + end + if utable.airRange > 0 then + table.insert(mtypes, "air") + end + if utable.submergedRange > 0 then + table.insert(mtypes, "sub") + table.insert(mtypes, "shp") + table.insert(mtypes, "amp") + end + unitWeaponMtypes[unitName] = mtypes + return mtypes +end + +function WhatHurtsUnit(unitName, mtype, position) + local hurts = whatHurtsMtype[mtype] or whatHurtsUnit[unitName] + if hurts ~= nil then return hurts else hurts = {} end + if unitName then + local ut = unitTable[unitName] + if ut then + mtype = ut.mtype + end + end + if mtype == "veh" or mtype == "bot" or mtype == "amp" or mtype == "hov" or mtype == "shp" then + hurts["ground"] = true + end + if mtype == "air" then + hurts["air"] = true + end + if mtype == "sub" or mtype == "shp" or mtype == "amp" then + hurts["submerged"] = true + end + if unitName then whatHurtsUnit[unitName] = hurts end + if mtype then whatHurtsMtype[mtype] = hurts end + if mtype == "amp" and position ~= nil then + -- special case: amphibious need to check whether underwater or not + local underwater = ai.maphandler:IsUnderWater(position) + if underwater then + return { ground = false, air = false, submerged = true} + else + return { ground = true, air = false, submerged = true } + end + end + return hurts +end + +function BehaviourPosition(behaviour) + if behaviour == nil then return end + if behaviour.unit == nil then return end + local unit = behaviour.unit:Internal() + if unit == nil then return end + return unit:GetPosition() end \ No newline at end of file diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/countbehaviour.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/countbehaviour.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/countbehaviour.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/countbehaviour.lua 2014-10-07 20:10:05.000000000 +0000 @@ -28,6 +28,9 @@ if unitTable[self.name].extractsMetal > 0 then self.isMex = true end if battleList[self.name] then self.isBattle = true end if breakthroughList[self.name] then self.isBreakthrough = true end + if self.isCombat and not battleList[self.name] and not breakthroughList[self.name] then + self.isSiege = true + end if reclaimerList[self.name] then self.isReclaimer = true end if assistList[self.name] then self.isAssist = true end if ai.nameCount[self.name] == nil then @@ -59,6 +62,7 @@ if self.isCombat then ai.combatCount = ai.combatCount + 1 end if self.isBattle then ai.battleCount = ai.battleCount + 1 end if self.isBreakthrough then ai.breakthroughCount = ai.breakthroughCount + 1 end + if self.isSiege then ai.siegeCount = ai.siegeCount + 1 end if self.isReclaimer then ai.reclaimerCount = ai.reclaimerCount + 1 end if self.isAssist then ai.assistCount = ai.assistCount + 1 end ai.lastNameFinished[self.name] = game:Frame() @@ -96,6 +100,7 @@ if self.isCombat then ai.combatCount = ai.combatCount - 1 end if self.isBattle then ai.battleCount = ai.battleCount - 1 end if self.isBreakthrough then ai.breakthroughCount = ai.breakthroughCount - 1 end + if self.isSiege then ai.siegeCount = ai.siegeCount - 1 end if self.isReclaimer then ai.reclaimerCount = ai.reclaimerCount - 1 end if self.isAssist then ai.assistCount = ai.assistCount - 1 end end diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/counthandler.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/counthandler.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/counthandler.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/counthandler.lua 2014-10-07 20:10:05.000000000 +0000 @@ -34,6 +34,7 @@ ai.combatCount = 0 ai.battleCount = 0 ai.breakthroughCount = 0 + ai.siegeCount = 0 ai.reclaimerCount = 0 ai.assistCount = 0 diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/damagehandler.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/damagehandler.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/damagehandler.lua 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/damagehandler.lua 2014-10-07 20:10:05.000000000 +0000 @@ -0,0 +1,61 @@ +require "common" + +-- keeps track of hits to our units + +local DebugEnabled = false + +local function EchoDebug(inStr) + if DebugEnabled then + game:SendToConsole("DamageHandler: " .. inStr) + end +end + +DamageHandler = class(Module) + +function DamageHandler:Name() + return "DamageHandler" +end + +function DamageHandler:internalName() + return "damagehandler" +end + +function DamageHandler:Init() + self.lastHealth = {} +end + +-- note: the attacker is always nil if it's on any team other than the AI's (not even allies register) +-- note: unitdamaged will not be called on self-destruct +--[[ +function DamageHandler:UnitDamaged(unit, attacker) + -- if unit ~= nil then game:SendToConsole(unit:Team() .. " attacked (" .. game:GetTeamID() .. ")") end + -- if attacker ~= nil then game:SendToConsole("by " .. attacker:Team() .. " (" .. game:GetTeamID() .. ")") end + local friendlyFire = false + if attacker ~= nil then + if ai.friendlyTeamID[attacker:Team()] then friendlyFire = true end + end + if unit ~= nil and not friendlyFire then + local unitID = unit:ID() + local health = unit:GetHealth() + local last = self.lastHealth[unitID] + if last then + local damage = self.lastHealth[unitID] - health + -- game:SendToConsole(damage .. " damage to " .. unit:Name()) + -- self:DamageReport(damage, unit:GetPosition(), unit:Name()) + end + self.lastHealth[unitID] = health + end +end +]]-- + +function DamageHandler:UnitBuilt(unit) + local unitID = unit:ID() + self.lastHealth[unitID] = unit:GetHealth() +end + +function DamageHandler:UnitDead(unit) + local unitID = unit:ID() + self.lastHealth[unitID] = nil +end + +-- DangerCheck(attackerName, attackerID) diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/defendbehaviour.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/defendbehaviour.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/defendbehaviour.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/defendbehaviour.lua 2014-10-07 20:10:05.000000000 +0000 @@ -17,8 +17,9 @@ -- not does it defend, but is it a dedicated defender function IsDefender(unit) + local un = unit:Internal():Name() for i,name in ipairs(defenderList) do - if name == unit:Internal():Name() then + if name == un then return true end end @@ -26,9 +27,24 @@ end function DefendBehaviour:Init() + self.moving = {} + self.unmoved = 0 + self.lastPos = self.unit:Internal():GetPosition() self.active = false + self.id = self.unit:Internal():ID() self.name = self.unit:Internal():Name() + local ut = unitTable[self.name] + self.tough = battleList[self.name] or breakthroughList[self.name] + self.isDefender = IsDefender(self.unit) self.mtype = unitTable[self.name].mtype + -- defenders need to be sorted into only one type of weapon + if ut.groundRange > 0 then + self.hits = "ground" + elseif ut.submergedRange > 0 then + self.hits = "submerged" + elseif ut.airRange > 0 then + self.hits = "air" + end for i, name in pairs(raiderList) do if name == self.name then EchoDebug(self.name .. " is scramble") @@ -64,54 +80,78 @@ end function DefendBehaviour:Update() + if self.unit == nil then return end + local unit = self.unit:Internal() + if unit == nil then return end if self.active then local f = game:Frame() if math.mod(f,60) == 0 then - if self.target ~= nil then - self.moving = nil - self.patroling = nil - if self.guarding ~= self.target then - local floats = api.vectorFloat() - floats:push_back(self.target) - self.unit:Internal():ExecuteCustomCommand(CMD_GUARD, floats) - self.guarding = self.target + if self.target == nil then return end + local targetPos = self.target.position or BehaviourPosition(self.target.behaviour) + if targetPos == nil then return end + targetPos.y = 0 + local guardDistance = self.target.guardDistance + if not self.tough then guardDistance = guardDistance * 0.33 end + local guardPos = RandomAway(targetPos, guardDistance, false, self.guardAngle) + local safe = ai.defendhandler:WardSafe(self.target) + -- if targetPos.y > 100 then game:SendToConsole(targetPos.y .. " " .. type(self.target.behaviour)) end + local unitPos = unit:GetPosition() + local dist = Distance(unitPos, guardPos) + local behaviour = self.target.behaviour + if self.perpendicular then + guardPos = RandomAway(guardPos, self.perpDist, false, self.perpendicular) + end + if behaviour ~= nil then + if dist > 500 then + if self.guarding ~= behaviour.id then + -- move toward mobile wards that are far away with guard order + CustomCommand(self.unit:Internal(), CMD_GUARD, {behaviour.id}) + self.guarding = behaviour.id + end + elseif not safe then + if dist > 250 then + unit:Move(guardPos) + self.guarding = nil + end + elseif dist > 25 then + unit:Move(guardPos) + self.guarding = nil end - elseif self.targetPos ~= nil then + self.moving = {} + else self.guarding = nil - if self.patroling == nil or self.patroling.x ~= self.targetPos.x or self.patroling.z ~= self.targetPos.z then - local right = api.Position() - right.x = self.targetPos.x + 100 - right.y = self.targetPos.y - right.z = self.targetPos.z - if self.moving == nil or self.moving.x ~= right.x or self.moving.z ~= right.z then - self.unit:Internal():Move(right) - self.moving = right - else - local dist = Distance(self.unit:Internal():GetPosition(), right) - EchoDebug(dist) - if dist < 200 then - local floats = api.vectorFloat() - floats:push_back(self.targetPos.x - 200) - floats:push_back(self.targetPos.y) - floats:push_back(self.targetPos.z) - self.unit:Internal():ExecuteCustomCommand(CMD_PATROL, floats) - self.patroling = self.targetPos - end - end + local boredNow = ai.targethandler:IsSafePosition(unitPos, unit) + if self.moving.x ~= targetPos.x or self.moving.z ~= targetPos.z or (self.unmoved > 5 and boredNow) or (not self.tough and dist > self.target.guardDistance) then + unit:Move(guardPos) + self.moving.x = targetPos.x + self.moving.z = targetPos.z end end + if self.lastPos.x == unitPos.x and self.lastPos.z == unitPos.z then + self.unmoved = self.unmoved + 1 + else + self.unmoved = 0 + end + self.lastPos = api.Position() + self.lastPos.x, self.lastPos.z = unitPos.x+0, unitPos.z+0 + self.unit:ElectBehaviour() end - self.unit:ElectBehaviour() end end -function DefendBehaviour:Assign(defendee) - if defendee == nil then +function DefendBehaviour:Assign(ward, angle, dist) + if ward == nil then self.target = nil - self.targetPos = nil else - self.target = defendee.uid - self.targetPos = defendee.position + self.target = ward + self.guardAngle = angle or math.random() * twicePi + if dist then + self.perpendicular = AngleAdd(angle, halfPi) + self.perpDist = dist + else + self.perpendicular = nil + self.perpDist = nil + end end end @@ -133,8 +173,6 @@ self.target = nil self.targetPos = nil self.guarding = nil - self.moving = nil - self.patroling = nil ai.defendhandler:AddDefender(self) self:SetMoveState() end @@ -145,8 +183,6 @@ self.target = nil self.targetPos = nil self.guarding = nil - self.moving = nil - self.patroling = nil ai.defendhandler:RemoveDefender(self) end diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/defendhandler.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/defendhandler.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/defendhandler.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/defendhandler.lua 2014-10-07 20:10:05.000000000 +0000 @@ -1,6 +1,5 @@ require "common" - local DebugEnabled = false local function EchoDebug(inStr) @@ -9,10 +8,19 @@ end end --- local factoryPriority = 3 -local threatenedPriority = 4 local techLevelPriority = 1 local commanderPriority = 2 +local threatenedPriority = 4 + +local canDefend = { + air = { air = 1, bot = 1, veh = 1, amp = 1, hov = 1, shp = 1, sub = 1 }, + bot = { bot = 1, veh = 1 }, + veh = { veh = 1, bot = 1 }, + amp = { bot = 1, veh = 1 }, -- theoretically, gimp and pelican could defend amp, shp, sub. not sure how to resolve that + hov = { hov = 1, bot = 1, veh = 1, shp = 1, sub = 1 }, + shp = { shp = 1, sub = 1 }, + sub = { sub = 1, shp = 1 }, +} DefendHandler = class(Module) @@ -25,51 +33,85 @@ end function DefendHandler:Init() - self.defenders = {} - self.defendees = {} - self.scrambles = {} - self.totalPriority = 0 - self.lastThreats = 0 -end - -function DefendHandler:AddDefendee(behaviour) - if behaviour == nil then return end - if behaviour.unit == nil then return end - if behaviour.name == nil then behaviour.name = behaviour.unit:Internal():Name() end - if behaviour.id == nil then behaviour.id = behaviour.unit:Internal():ID() end - local un = behaviour.name - local utable = unitTable[un] - local priority = 0 - priority = priority + utable.techLevel * techLevelPriority - -- if utable.isBuilding then - -- priority = priority + factoryPriority - if un == "corcom" or un == "armcom" then - priority = priority + commanderPriority - end - if priority ~= 0 then - table.insert(self.defendees, {uid = behaviour.id, behaviour = behaviour, priority = priority, threatened = nil}) - self.totalPriority = self.totalPriority + priority - self:AssignAll() + self.defenders = {} + self.wards = {} + self.scrambles = {} + self.loiterers = { veh = {}, bot = {}, hov = {}, amp = {}, shp = {}, sub = {} } + self.totalPriority = { ground = 0, air = 0, submerged = 0 } + self.lastAssignFrame = { ground = {}, air = {}, submerged = {} } + self.needAssignment = { ground = {}, air = {}, submerged = {} } + self.needLoitererAssignment = {} + for mtype, can in pairs(canDefend) do + self.lastAssignFrame.ground[mtype] = 0 + self.lastAssignFrame.air[mtype] = 0 + self.lastAssignFrame.submerged[mtype] = 0 + end + self.wardsByDefenderID = {} + self.defendersByID = {} + self.unitGuardDistances = {} + ai.frontPosition = {} +end + +function DefendHandler:AddWard(behaviour, turtle) + local priority = { ground = 0, air = 0, submerged = 0 } + local ward + if behaviour ~= nil then + if behaviour.unit == nil then return end + if behaviour.name == nil then behaviour.name = behaviour.unit:Internal():Name() end + if behaviour.id == nil then behaviour.id = behaviour.unit:Internal():ID() end + local un = behaviour.name + local utable = unitTable[un] + priority.air = utable.techLevel * techLevelPriority + if commanderList[un] then priority.air = commanderPriority end + local mtype = behaviour.mtype + if mtype == "air" then + -- already zero + elseif mtype == "sub" or mtype == "shp" then + priority.submerged = priority.air + 0 + elseif mtype == "amp" then + priority.submerged = priority.air + 0 + priority.ground = priority.air + 0 + else + priority.ground = priority.air + 0 + end + local frontNumber = { ground = 0, air = 0, submerged = 0 } + ward = { uid = behaviour.id, behaviour = behaviour, priority = priority, frontNumber = frontNumber, threatened = nil, defenders = {}, guardDistance = self:GetGuardDistance(un) } + elseif turtle ~= nil then + priority.air = turtle.priority + if turtle.air > 0 then priority.air = priority.air + (turtle.air / 100) end + ward = { turtle = turtle, position = turtle.position, priority = priority, threatened = f, defenders = {}, guardDistance = turtle.size, scrambleForMe = turtle.priority > 4 } + end + if ward ~= nil then + table.insert(self.wards, ward) + for GAS, p in pairs(priority) do + if p > 0 then + self.totalPriority[GAS] = self.totalPriority[GAS] + p + self:MarkAllMtypesForAssignment(GAS) + end + end end end -function DefendHandler:UnitDead(unit) - -- local unit = u:Internal() - local uid = unit:ID() - for i, defendee in pairs(self.defendees) do - if uid == defendee.uid then - EchoDebug("defendee with id " .. uid .. " dead. there are " .. #self.defendees .. " defendees total") - for di, dfndbehaviour in pairs(self.defenders) do - if dfndbehaviour.target ~= nil then - if dfndbehaviour.target == uid then +function DefendHandler:RemoveWard(behaviour, turtle) + for i, ward in pairs(self.wards) do + -- either behaviour or turtle should be nil + if behaviour == ward.behaviour and turtle == ward.turtle then + for unitID, checkWard in pairs(self.wardsByDefenderID) do + if ward == checkWard then + local dfndbehaviour = self.defendersByID[unitID] + if dfndbehaviour ~= nil then dfndbehaviour:Assign(nil) + self.needAssignment[dfndbehaviour.hits][dfndbehaviour.mtype] = true + self.wardsByDefenderID[unitID] = nil end end end - self.totalPriority = self.totalPriority - defendee.priority - table.remove(self.defendees, i) - EchoDebug("defendee removed from table. there are " .. #self.defendees .. " defendees total") - self:AssignAll() + for GAS, p in pairs(ward.priority) do + self.totalPriority[GAS] = self.totalPriority[GAS] - p + self:MarkAllMtypesForAssignment(GAS) + end + table.remove(self.wards, i) + EchoDebug("ward removed from table. there are " .. #self.wards .. " wards total") break end end @@ -78,19 +120,70 @@ function DefendHandler:Update() local f = game:Frame() if f % 30 == 0 then - local threats = 0 local scrambleCalls = 0 - for i, defendee in pairs(self.defendees) do - if defendee.threatened ~= nil then - threats = threats + 1 - if defendee.scrambleForMe then scrambleCalls = scrambleCalls + 1 end - -- defend threatened for thirty seconds after they've stopped being within range of fire or fired at - if f > defendee.threatened + 900 then - defendee.priority = defendee.priority - threatenedPriority - self.totalPriority = self.totalPriority - threatenedPriority - defendee.threatened = nil - if defendee.priority == 0 then - table.remove(self.defendees, i) + for i, ward in pairs(self.wards) do + if ward.behaviour ~= nil then + if not ward.behaviour.isScout then + if ward.threatened then + if not ward.behaviour.underFire then + local groundDiff = ward.priority.air - ward.priority.ground + local submergedDiff = ward.priority.air - ward.priority.submerged + if groundDiff > 0 then + self:MarkAllMtypesForAssignment("ground") + self.totalPriority.ground = self.totalPriority.ground + groundDiff + end + if submergedDiff > 0 then + self:MarkAllMtypesForAssignment("submerged") + self.totalPriority.submerged = self.totalPriority.submerged + submergedDiff + end + ward.threatened = nil + end + else + if ward.behaviour.withinTurtle then + if ward.prioritySnap == nil then + ward.prioritySnap = {} + for GAS, p in pairs(ward.priority) do + ward.prioritySnap[GAS] = p+0 + self.totalPriority[GAS] = self.totalPriority[GAS] - p + ward.priority[GAS] = 0 + self:MarkAllMtypesForAssignment(GAS) + end + end + else + if ward.prioritySnap ~= nil then + for GAS, p in pairs(ward.prioritySnap) do + ward.priority[GAS] = p+0 + self.totalPriority[GAS] = self.totalPriority[GAS] + p + self:MarkAllMtypesForAssignment(GAS) + end + ward.prioritySnap = nil + end + if ward.behaviour.underFire then + if ward.behaviour.response then + for GAS, r in pairs(ward.behaviour.response) do + if r > 0 then + ward.priority[GAS] = ward.priority[GAS] + threatenedPriority + self.totalPriority[GAS] = self.totalPriority[GAS] + threatenedPriority + self:MarkAllMtypesForAssignment(GAS) + ward.threatened = f + end + end + end + end + end + end + end + elseif ward.turtle ~= nil then + if ward.threatened ~= nil then + -- defend threatened turtles for ten seconds after they've stopped being threatened + if f > ward.threatened + 300 then + self.totalPriority.ground = self.totalPriority.ground - ward.priority.ground + self.totalPriority.submerged = self.totalPriority.submerged - ward.priority.submerged + if ward.priority.ground > 0 then self:MarkAllMtypesForAssignment("ground") end + if ward.priority.submerged > 0 then self:MarkAllMtypesForAssignment("submerged") end + ward.priority.ground, ward.priority.submerged = 0, 0 + else + if ward.scrambleForMe then scrambleCalls = scrambleCalls + 1 end end end end @@ -100,38 +193,66 @@ else self:Unscramble() end - if threats ~= self.lastThreats then - self:AssignAll() + if self.frontWardWater ~= self.lastFrontWardWater then self:AssignLoiterers(self.frontWardWater) end + if self.frontWardLand ~= self.lastFrontWardLand then self:AssignLoiterers(self.frontWardLand) end + self.lastFrontWardWater = self.frontWardWater + self.lastFrontWardLand = self.frontWardLand + end + for GAS, mtypes in pairs(self.needAssignment) do + for mtype, needAssignment in pairs(mtypes) do + if needAssignment and f > self.lastAssignFrame[GAS][mtype] + 60 then + -- only reassign every two seconds + self:AssignAll(GAS, mtype) + self.lastAssignFrame[GAS][mtype] = f + self.needAssignment[GAS][mtype] = nil + end end - self.lastThreats = threats end end -function DefendHandler:AssignAll() - if #self.defenders == 0 then return end - EchoDebug("assigning all defenders...") - if #self.defendees == 0 then +function DefendHandler:AssignAll(GAS, mtype) -- Ground Air Submerged (weapon), mobility type + if #self.wards == 0 then -- if nothing to defend, make sure defenders aren't defending ghosts (this causes a crash) - for di, dfndbehaviour in pairs(self.defenders) do + EchoDebug("nothing to defend") + for di, dfndbehaviour in pairs(self.defenders[GAS][mtype]) do dfndbehaviour:Assign(nil) + self.wardsByDefenderID[dfndbehaviour.id] = nil end + return end - -- assign defenders to defendees - local defendersPerPriority = #self.defenders / self.totalPriority + EchoDebug("assigning all defenders...") + -- assign defenders to wards + local defenders = self.defenders[GAS][mtype] + local defendersPerPriority = #defenders / self.totalPriority[GAS] local defendersToAssign = {} local defendersToRemove = {} - for nothing, dfndbehaviour in pairs(self.defenders) do + for nothing, dfndbehaviour in pairs(defenders) do table.insert(defendersToAssign, dfndbehaviour) end - local notDefended = {} - for i, defendee in pairs(self.defendees) do - local number = math.floor(defendee.priority * defendersPerPriority) + local notDefended + local wardsAffected = {} + for i, ward in pairs(self.wards) do + local wardMtype + if ward.behaviour ~= nil then + wardMtype = ward.behaviour.mtype + elseif ward.turtle ~= nil then + if ward.turtle.water then wardMtype = "shp" else wardMtype = "veh" end + end + local number = 0 + if canDefend[mtype][wardMtype] then + number = math.floor(ward.priority[GAS] * defendersPerPriority) + end if number ~= 0 and #defendersToAssign ~= 0 then - local defendeePos = defendee.position - if defendeePos == nil then - if defendee.behaviour ~= nil then - if defendee.behaviour.unit ~= nil then - defendeePos = defendee.behaviour.unit:Internal():GetPosition() + self:FreeDefenders(ward, GAS, mtype) + table.insert(wardsAffected, ward) + local wardPos = ward.position + if wardPos == nil and ward.behaviour ~= nil then + if ward.behaviour ~= nil then + if ward.behaviour.unit ~= nil then + wardUnit = ward.behaviour.unit:Internal() + if wardUnit ~= nil then + wardPos = wardUnit:GetPosition() + end end end end @@ -155,9 +276,9 @@ end if okay then local defender = dfndbehaviour.unit:Internal() - if ai.maphandler:UnitCanGoHere(defender, defendeePos) then + if ai.maphandler:UnitCanGoHere(defender, wardPos) then local defenderPos = defender:GetPosition() - local dist = Distance(defenderPos, defendeePos) + local dist = Distance(defenderPos, wardPos) bydistance[dist] = dfndbehaviour -- the probability of the same distance is near zero end end @@ -166,7 +287,8 @@ local n = 0 for dist, dfndbehaviour in pairsByKeys(bydistance) do if n < number then - dfndbehaviour:Assign(defendee) + self.wardsByDefenderID[dfndbehaviour.id] = ward + table.insert(ward.defenders, dfndbehaviour) table.insert(defendersToRemove, dfndbehaviour) else break @@ -174,42 +296,121 @@ n = n + 1 end elseif number == 0 then - notDefended[i] = true + notDefended = ward end end if #defendersToAssign ~= 0 then - for i, tf in pairs(notDefended) do - local defendee = self.defendees[i] - if #defendersToAssign ~= 0 then + local ward = notDefended + if ward ~= nil then + while #defendersToAssign > 0 do local dfndbehaviour = table.remove(defendersToAssign) - dfndbehaviour:Assign(defendee) + self.wardsByDefenderID[dfndbehaviour.id] = ward + table.insert(ward.defenders, dfndbehaviour) + end + end + end + -- find angles for each defender + for i, ward in pairs(wardsAffected) do + local divisor = #ward.defenders + if divisor > 0 then + if ward.angle == nil then + local angleAdd = twicePi / divisor + local angle = math.random() * twicePi + for nothing, dfndbehaviour in pairs(ward.defenders) do + dfndbehaviour:Assign(ward, angle) + angle = angle + angleAdd + if angle > twicePi then angle = angle - twicePi end + end else - break + local angle = ward.angle + local d = -ward.guardDistance + local dAdd = (ward.guardDistance * 2) / divisor + for nothing, dfndbehaviour in pairs(ward.defenders) do + dfndbehaviour:Assign(ward, angle, d) + d = d + dAdd + end end end end EchoDebug("all defenders assigned") end -function DefendHandler:IsDefendingMe(defenderUnit, defendeeUnit) - local defenderID = defenderUnit:ID() - local defendeeID = defendeeUnit:ID() - for i, dfndbehaviour in pairs(self.defenders) do - if dfndbehaviour.unit ~= nil then - if dfndbehaviour.unit:Internal():ID() == defenderID then - if dfndbehaviour.target ~= nil then - if dfndbehaviour.target == defendeeID then - return true - end +function DefendHandler:AssignLoiterers(ward) + -- assign siege units to hang around near the front + if ward == nil then return end + local mtypes, protection + if ward.turtle.water then + mtypes = { "sub", "shp", "hov" } + protection = ward.turtle.submerged + (#ward.defenders * 200) + else + mtypes = { "veh", "bot", "amp", "hov" } + protection = ward.turtle.ground + (#ward.defenders * 200) + end + local totalLoiterers = 0 + for i, mtype in pairs(mtypes) do totalLoiterers = totalLoiterers + #self.loiterers[mtype] end + if protection > totalLoiterers * 200 then + for i, mtype in pairs(mtypes) do + local loiterers = self.loiterers[mtype] + if #loiterers > 0 then + local d = -ward.guardDistance * 0.5 + local dAdd = ward.guardDistance / totalLoiterers + for li = 1, #loiterers do + local dfndbehaviour = loiterers[li] + dfndbehaviour:Assign(ward, ward.angle, d) + self.wardsByDefenderID[dfndbehaviour.id] = ward + d = d + dAdd end end end end - return false +end + +function DefendHandler:FreeDefenders(ward, GAS, mtype) + for i, dfndbehaviour in pairs(ward.defenders) do + if dfndbehaviour.hits == GAS and dfndbehaviour.mtype == mtype then + table.remove(ward.defenders, i) + end + end +end + +function DefendHandler:MarkAllMtypesForAssignment(GAS) + if self.defenders[GAS] == nil then return end + for mtype, defenders in pairs(self.defenders[GAS]) do + self.needAssignment[GAS][mtype] = true + end +end + +function DefendHandler:IsDefendingMe(defenderUnit, wardBehaviour) + local ward = self.wardsByDefenderID[defenderUnit:ID()] + if ward ~= nil then + return ward.behaviour == wardBehaviour + else + return false + end end function DefendHandler:IsDefender(dfndbehaviour) - for i, db in pairs(self.defenders) do + if self.defenders[dfndbehaviour.hits] == nil then + self.defenders[dfndbehaviour.hits] = {} + end + if self.defenders[dfndbehaviour.hits][dfndbehaviour.mtype] == nil then + self.defenders[dfndbehaviour.hits][dfndbehaviour.mtype] = {} + return false + end + for i, db in pairs(self.defenders[dfndbehaviour.hits][dfndbehaviour.mtype]) do + if db == dfndbehaviour then + return true + end + end + return false +end + +function DefendHandler:IsLoiterer(dfndbehaviour) + if self.loiterers[dfndbehaviour.mtype] == nil then + self.loiterers[dfndbehaviour.mtype] = {} + return false + end + for i, db in pairs(self.loiterers[dfndbehaviour.mtype]) do if db == dfndbehaviour then return true end @@ -218,18 +419,35 @@ end function DefendHandler:AddDefender(dfndbehaviour) - if not self:IsDefender(dfndbehaviour) then - table.insert(self.defenders, dfndbehaviour) - self:AssignAll() + if dfndbehaviour.tough or dfndbehaviour.hits == "air" then + if not self:IsDefender(dfndbehaviour) then + table.insert(self.defenders[dfndbehaviour.hits][dfndbehaviour.mtype], dfndbehaviour) + self.needAssignment[dfndbehaviour.hits][dfndbehaviour.mtype] = true + end + else + if not self:IsLoiterer(dfndbehaviour) then + table.insert(self.loiterers[dfndbehaviour.mtype], dfndbehaviour) + self.needLoitererAssignment[dfndbehaviour.mtype] = true + end end end function DefendHandler:RemoveDefender(dfndbehaviour) - for i, db in pairs(self.defenders) do - if db == dfndbehaviour then - table.remove(self.defenders, i) - self:AssignAll() - break + if dfndbehaviour.tough or dfndbehaviour.hits == "air" then + for i, db in pairs(self.defenders[dfndbehaviour.hits][dfndbehaviour.mtype]) do + if db == dfndbehaviour then + table.remove(self.defenders[dfndbehaviour.hits][dfndbehaviour.mtype], i) + self.needAssignment[dfndbehaviour.hits][dfndbehaviour.mtype] = true + return + end + end + else + for i, db in pairs(self.loiterers[dfndbehaviour.mtype]) do + if db == dfndbehaviour then + table.remove(self.loiterers[dfndbehaviour.mtype], i) + self.needLoitererAssignment[dfndbehaviour.mtype] = true + return + end end end end @@ -279,33 +497,124 @@ end end --- receive a signal that a unit is threatened -function DefendHandler:Danger(behaviour) - if behaviour == nil then return end - if behaviour.unit == nil then return end - if behaviour.name == nil then behaviour.name = behaviour.unit:Internal():Name() end - if behaviour.id == nil then behaviour.id = behaviour.unit:Internal():ID() end - for i, defendee in pairs(self.defendees) do - if defendee.uid == behaviour.id then - if not defendee.threatened then - EchoDebug("defendee threatened") - defendee.threatened = game:Frame() - defendee.priority = defendee.priority + threatenedPriority - self.totalPriority = self.totalPriority + threatenedPriority - end - return - end - end - -- if it's not a defendee, make it one - local defendee = {priority = threatenedPriority, threatened = game:Frame()} - local uname = behaviour.name - if unitTable[uname].buildOptions then defendee.scrambleForMe = true end - if unitTable[uname].isBuilding then - defendee.position = defendeeUnit:GetPosition() - else - defendee.behaviour = behaviour - defendee.uid = behaviour.id +function DefendHandler:FindFronts(troublingCells) + local number = #troublingCells + for n = 1, number do + local tcells = troublingCells[n] + for GAS, cell in pairs(tcells) do + if GAS ~= "air" and cell ~= nil then + local water = GAS == "submerged" + local nearestMobileDist = 100000 + local nearestMobile + local nearestTurtleDist = 100000 + local nearestTurtle + for wi, ward in pairs(self.wards) do + if ward.behaviour ~= nil then + local behaviour = ward.behaviour + if water == behaviour.water then + local dist = Distance(behaviour.unit:Internal():GetPosition(), cell.pos) + if dist < nearestMobileDist then + nearestMobileDist = dist + nearestMobile = ward + end + end + if ward.frontNumber[GAS] > 0 then self:SetDangerZone(ward, 0, number, GAS) end + elseif n == 1 and ward.turtle ~= nil then + local turtle = ward.turtle + turtle.threatForecastAngle = nil + turtle.front = nil + if water == turtle.water then + if turtle.priority > 1 then + local dist = Distance(turtle.position, cell.pos) + if dist < nearestTurtleDist then + nearestTurtleDist = dist + nearestTurtle = ward + end + end + end + end + end + if n == 1 then + if nearestTurtle ~= nil then + local turtle = nearestTurtle.turtle + turtle.threatForecastAngle = AngleAtoB(turtle.position.x, turtle.position.z, cell.pos.x, cell.pos.z) + turtle.front = true + self:Danger(nil, turtle, GAS) + ai.incomingThreat = cell.response[GAS] + ai.frontPosition[GAS] = turtle.position + else + ai.incomingThreat = 0 + end + end + if nearestMobile ~= nil then + self:SetDangerZone(nearestMobile, n, number, GAS) + end + end + end end - table.insert(self.defendees, defendee) - self.totalPriority = self.totalPriority + threatenedPriority +end + +function DefendHandler:SetDangerZone(ward, n, number, GAS) + local setPriority = ward.priority.air + 1 + (number - n) + local priorityDiff = setPriority - ward.priority[GAS] + if priorityDiff > 0 then + ward.priority[GAS] = setPriority + self.totalPriority[GAS] = self.totalPriority[GAS] + priorityDiff + self:MarkAllMtypesForAssignment(GAS) + end + ward.frontNumber[GAS] = n +end + +-- receive a signal that a building is threatened or a turtle is on the front +function DefendHandler:Danger(behaviour, turtle, GAS) + local f = game:Frame() + if turtle == nil and behaviour ~= nil then turtle = ai.turtlehandler:GetUnitTurtle(behaviour.id) end + if turtle ~= nil then + for i, ward in pairs(self.wards) do + if ward.turtle == turtle then + ward.threatened = f + if ward.priority[GAS] == 0 then + if turtle.front then + ward.priority[GAS] = self.totalPriority[GAS]+0 + ward.angle = turtle.threatForecastAngle + ward.scrambleForMe = turtle.priority > 4 + self.totalPriority[GAS] = self.totalPriority[GAS] + self.totalPriority[GAS] + if GAS == "ground" then + self.frontWardLand = ward + elseif GAS == "submerged" then + self.frontWardWater = ward + end + else + local priority = turtle.priority + ward.priority[GAS] = priority + ward.scrambleForMe = turtle.priority > 4 + self.totalPriority[GAS] = self.totalPriority[GAS] + priority + end + self:MarkAllMtypesForAssignment(GAS) + end + return + end + end + end +end + +function DefendHandler:WardSafe(ward) + local f = game:Frame() + local behaviour = ward.behaviour + local threatened = ward.threatened + if behaviour ~= nil then + return not behaviour.underFire + elseif threatened ~= nil then + return f > threatened + 300 + end + return true +end + +function DefendHandler:GetGuardDistance(unitName) + local dist = self.unitGuardDistances[unitName] + if dist ~= nil then return dist end + local utable = unitTable[unitName] + dist = (math.max(utable.xsize, utable.zsize) * 4) + 100 + self.unitGuardDistances[unitName] = dist + return dist end \ No newline at end of file diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/econhandler.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/econhandler.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/econhandler.lua 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/econhandler.lua 2014-10-07 20:10:05.000000000 +0000 @@ -0,0 +1,89 @@ +require "common" + +local DebugEnabled = false + +local function EchoDebug(inStr) + if DebugEnabled then + game:SendToConsole("EconHandler: " .. inStr) + end +end + +EconHandler = class(Module) + +function EconHandler:Name() + return "EconHandler" +end + +function EconHandler:internalName() + return "econhandler" +end + +function EconHandler:Init() + self.resourceNames = { "Energy", "Metal" } + self.lastFrame = -16 -- so that it updates immediately even on the first frame + self.hasData = false -- so that it gets data immediately + self.samples = {} + ai.Energy = {} + ai.Metal = {} + self:Update() +end + +function EconHandler:Update() + local f = game:Frame() + if f > self.lastFrame + 15 then + local sample = {} + -- because resource data is stored as userdata + for i, name in pairs(self.resourceNames) do + local udata = game:GetResourceByName(name) + sample[name] = { income = udata.income, usage = udata.usage, reserves = udata.reserves, capacity = udata.capacity } + end + table.insert(self.samples, sample) + if not self.hasData or #self.samples == 6 then self:Average() end + self.lastFrame = f + end +end + +function EconHandler:Average() + local reset = false + for i, sample in pairs(self.samples) do + for name, resource in pairs(sample) do + for property, value in pairs(resource) do + if not reset then ai[name][property] = 0 end + ai[name][property] = ai[name][property] + value + end + end + if not reset then reset = true end + end + local totalSamples = #self.samples + for name, resource in pairs(self.samples[1]) do + for property, value in pairs(resource) do + ai[name][property] = ai[name][property] / totalSamples + end + ai[name].extra = ai[name].income - ai[name].usage + if ai[name].capacity == 0 then + ai[name].full = math.inf + else + ai[name].full = ai[name].reserves / ai[name].capacity + end + if ai[name].income == 0 then + ai[name].tics = math.inf + else + ai[name].tics = ai[name].reserves / ai[name].income + end + end + if not self.hasData then self.hasData = true end + self.samples = {} + self:DebugAll() +end + +function EconHandler:DebugAll() + if DebugEnabled then + for i, name in pairs(self.resourceNames) do + local resource = ai[name] + for property, value in pairs(resource) do + EchoDebug(name .. "." .. property .. ": " .. value) + end + end + end +end + diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/featuretable.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/featuretable.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/featuretable.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/featuretable.lua 2014-10-07 20:10:05.000000000 +0000 @@ -38,6 +38,12 @@ featureTable["ad0_senegal_6_large"] = { reclaimable = true, blocking = true, energy = 90, metal = 0, } featureTable["ad0_senegal_7"] = { reclaimable = true, blocking = true, energy = 90, metal = 0, } featureTable["ad0_senegal_7_large"] = { reclaimable = true, blocking = true, energy = 90, metal = 0, } +featureTable["ad0_bush_2_l"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["ad0_bush_2_m"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["ad0_bush_2_s"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["ad0_bushes_l_3"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["ad0_bushes_m_3"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["ad0_bushes_s_3"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } featureTable["ajuno_dead"] = { reclaimable = true, blocking = true, unitName = "ajuno", energy = 0, metal = 352, } featureTable["ajuno_heap"] = { reclaimable = true, blocking = false, energy = 0, metal = 145, } featureTable["armaak_dead"] = { reclaimable = true, blocking = true, unitName = "armaak", energy = 0, metal = 314, } @@ -314,10 +320,24 @@ featureTable["aseadragon_dead"] = { reclaimable = true, blocking = false, unitName = "aseadragon", energy = 0, metal = 20879, } featureTable["aseadragon_heap"] = { reclaimable = true, blocking = false, energy = 0, metal = 5066, } featureTable["asubpen_dead"] = { reclaimable = true, blocking = false, unitName = "asubpen", energy = 0, metal = 559, } +featureTable["brock_1"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["brock_2"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["brock_3"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["brock_6"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["brock_7"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["brock_8"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["brock_9"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["btreechi_3"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["btreechi_4"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["btreeclo_1"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["btreeclo_2"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["btreeclo_4"] = { reclaimable = true, blocking = true, energy = 1, metal = 0, } featureTable["cafus_dead"] = { reclaimable = true, blocking = true, unitName = "cafus", energy = 0, metal = 6440, } featureTable["cafus_heap"] = { reclaimable = true, blocking = false, energy = 0, metal = 2576, } featureTable["cjuno_dead"] = { reclaimable = true, blocking = true, unitName = "cjuno", energy = 0, metal = 388, } featureTable["cjuno_heap"] = { reclaimable = true, blocking = false, energy = 0, metal = 192, } +featureTable["cluster1_dead"] = { reclaimable = true, blocking = true, energy = 1, metal = 0, } +featureTable["cluster2_dead"] = { reclaimable = true, blocking = true, energy = 1, metal = 0, } featureTable["consul_dead"] = { reclaimable = true, blocking = true, unitName = "consul", energy = 0, metal = 153, } featureTable["consul_heap"] = { reclaimable = true, blocking = false, energy = 0, metal = 61, } featureTable["coraak_dead"] = { reclaimable = true, blocking = true, unitName = "coraak", energy = 0, metal = 395, } @@ -581,6 +601,11 @@ featureTable["csubpen_dead"] = { reclaimable = true, blocking = false, unitName = "csubpen", energy = 0, metal = 596, } featureTable["decade_dead"] = { reclaimable = true, blocking = false, unitName = "decade", energy = 0, metal = 197, } featureTable["decade_heap"] = { reclaimable = true, blocking = false, energy = 0, metal = 97, } +featureTable["espire1"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["espire2"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["espire3"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["espire4"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["espire5"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } featureTable["gorg_dead"] = { reclaimable = true, blocking = true, unitName = "gorg", energy = 0, metal = 13959, } featureTable["gorg_heap"] = { reclaimable = true, blocking = false, energy = 0, metal = 2793, } featureTable["hllt_dead"] = { reclaimable = true, blocking = true, unitName = "hllt", energy = 0, metal = 120, } @@ -595,6 +620,21 @@ featureTable["marauder_heap"] = { reclaimable = true, blocking = false, energy = 0, metal = 237, } featureTable["mercury_dead"] = { reclaimable = true, blocking = true, unitName = "mercury", energy = 0, metal = 1022, } featureTable["mercury_heap"] = { reclaimable = true, blocking = false, energy = 0, metal = 409, } +featureTable["mushroom11"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["mushroom13"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["mushroom14"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["mushroom15"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["mushroom16"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["mushroom19"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["mushroom21"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["mushroom22"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["mushroom23"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["mushroom24"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["mushroom25"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["mushroom26"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["mushroom27"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["mushroom28"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["mushroom29"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } featureTable["nsaclash_dead"] = { reclaimable = true, blocking = false, unitName = "nsaclash", energy = 0, metal = 390, } featureTable["nsaclash_heap"] = { reclaimable = true, blocking = false, energy = 0, metal = 156, } featureTable["packo_dead"] = { reclaimable = true, blocking = true, unitName = "packo", energy = 0, metal = 275, } @@ -605,6 +645,8 @@ featureTable["screamer_heap"] = { reclaimable = true, blocking = false, energy = 0, metal = 458, } featureTable["shiva_dead"] = { reclaimable = true, blocking = true, unitName = "shiva", energy = 0, metal = 937, } featureTable["shiva_heap"] = { reclaimable = true, blocking = false, energy = 0, metal = 375, } +featureTable["smothdeadtree1"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } +featureTable["smothtree123dead"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } featureTable["tawf001_dead"] = { reclaimable = true, blocking = true, unitName = "tawf001", energy = 0, metal = 114, } featureTable["tawf001_heap"] = { reclaimable = true, blocking = false, energy = 0, metal = 46, } featureTable["tawf009_dead"] = { reclaimable = true, blocking = false, unitName = "tawf009", energy = 0, metal = 1332, } @@ -633,4 +675,4 @@ featureTable["zero_ad0_senegal_7"] = { reclaimable = false, blocking = true, energy = 0, metal = 0, } featureTable["zero_ad0_senegal_7_large"] = { reclaimable = false, blocking = true, energy = 0, metal = 0, } featureTable["zero_rock1"] = { reclaimable = true, blocking = true, energy = 0, metal = 0, } -featureTable["geovent"] = { reclaimable = false, blocking = false, energy = 0, metal = 0, } +featureTable["geovent"] = { reclaimable = false, blocking = false, energy = 0, metal = 0, } \ No newline at end of file diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/loshandler.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/loshandler.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/loshandler.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/loshandler.lua 2014-10-07 20:10:05.000000000 +0000 @@ -57,36 +57,15 @@ return "loshandler" end -local function WhatUnitHurts(unitName) - if unitName == nil then return {} end - if unitName == DummyUnitName then return {} end - local utable = unitTable[unitName] - local mtypes = {} - if utable.groundRange > 0 then - table.insert(mtypes, "veh") - table.insert(mtypes, "bot") - table.insert(mtypes, "amp") - table.insert(mtypes, "hov") - table.insert(mtypes, "shp") - end - if utable.airRange > 0 then - table.insert(mtypes, "air") - end - if utable.submergedRange > 0 then - table.insert(mtypes, "sub") - table.insert(mtypes, "shp") - table.insert(mtypes, "amp") - end - return mtypes -end - function LosHandler:Init() self.losGrid = {} - self.knownEnemies = {} - self.knownWrecks = {} - self.ghosts = {} - self.enemyNames = {} + ai.knownEnemies = {} + ai.knownWrecks = {} ai.wreckCount = 0 + ai.enemyList = {} + ai.blips = {} + ai.lastLOSUpdate = 0 + ai.friendlyTeamID = {} self:Update() end @@ -98,17 +77,17 @@ debugPlotLosFile = assert(io.open("debuglosplot",'w'), "Unable to write debuglosplot") end -- game:SendToConsole("updating los") - local ownUnits = game:GetFriendlies() - if ownUnits == nil then - ownUnits = {} - end - ai.friendlyCount = #ownUnits self.losGrid = {} - ai.friendlyCount = 0 - local ownUnits = game:GetFriendlies() - if ownUnits ~= nil then - ai.friendlyCount = table.getn(ownUnits) - for _, unit in pairs(ownUnits) do + -- note: this could be more effecient by using a behaviour + -- if the unit is a building, we know it's LOS contribution forever + -- if the unit moves, the behaviours can be polled rather than GetFriendlies() + -- except for allies' units + local friendlies = game:GetFriendlies() + ai.friendlyTeamID = {} + ai.friendlyTeamID[game:GetTeamID()] = true + if friendlies ~= nil then + for _, unit in pairs(friendlies) do + ai.friendlyTeamID[unit:Team()] = true -- because I can't get allies' teamIDs directly local uname = unit:Name() local utable = unitTable[uname] local upos = unit:GetPosition() @@ -128,91 +107,96 @@ end end end - -- update enemy jamming + -- update enemy jamming and populate list of enemies local enemies = game:GetEnemies() if enemies ~= nil then - for _, e in pairs(enemies) do - local utable = unitTable[e:Name()] + local tracking + local enemyList = {} + for i, e in pairs(enemies) do + local uname = e:Name() + local utable = unitTable[uname] + local upos = e:GetPosition() if utable.jammerRadius > 0 then - local upos = e:GetPosition() self:FillCircle(upos.x, upos.z, utable.jammerRadius, 1, true) end + -- so that we only have to poll GetEnemies() once + table.insert(enemyList, { unitName = uname, position = upos, unitID = e:ID(), cloaked = e:IsCloaked(), beingBuilt = e:IsBeingBuilt(), health = e:GetHealth(), los = 0 }) end -- update known enemies - self:UpdateEnemies() + self:UpdateEnemies(enemyList) end -- update known wrecks self:UpdateWrecks() + ai.lastLOSUpdate = f if DebugEnabled then debugPlotLosFile:close() end end end -function LosHandler:UpdateEnemies() - local enemies = game:GetEnemies() - if enemies == nil then return end - if #enemies == 0 then return end +function LosHandler:UpdateEnemies(enemyList) + if enemyList == nil then return end + if #enemyList == 0 then return end -- game:SendToConsole("updating known enemies") local known = {} local exists = {} - if self.knownEnemies == nil then self.knownEnemies = {} end - for i, e in pairs(enemies) do - if e ~= nil then - local id = e:ID() - local ename = e:Name() - self.enemyNames[id] = ename - local pos = e:GetPosition() - exists[id] = pos - if not e:IsCloaked() then - local lt = self:AllLos(pos) - local los = 0 - local persist = false - local underWater = (unitTable[ename].mtype == "sub") - if underWater then - if lt[3] then - -- sonar - los = 2 - end - else - if lt[1] and not lt[2] and not unitTable[ename].stealth then - los = 1 - elseif lt[2] then - los = 2 - elseif lt[4] and unitTable[ename].mtype == "air" then - -- air los - los = 2 - end - end - if los == 0 and unitTable[ename].isBuilding then - -- don't remove from knownenemies if it's a building that was once seen - persist = true - elseif los == 1 then - -- don't remove from knownenemies if it's a now blip - persist = true - elseif los == 2 then - known[id] = los - self.knownEnemies[id] = los - end - if persist == true then - if self.knownEnemies[id] ~= nil then - if self.knownEnemies[id] == 2 then - known[id] = self.knownEnemies[id] - end + for i, e in pairs(enemyList) do + local id = e.unitID + local ename = e.unitName + local pos = e.position + exists[id] = pos + if not e.cloaked then + local lt = self:AllLos(pos) + local los = 0 + local persist = false + local underWater = (unitTable[ename].mtype == "sub") + if underWater then + if lt[3] then + -- sonar + los = 2 + end + else + if lt[1] and not lt[2] and not unitTable[ename].stealth then + los = 1 + elseif lt[2] then + los = 2 + elseif lt[4] and unitTable[ename].mtype == "air" then + -- air los + los = 2 + end + end + if los == 0 and unitTable[ename].isBuilding then + -- don't remove from knownenemies if it's a building that was once seen + persist = true + elseif los == 1 then + -- don't remove from knownenemies if it's a now blip + persist = true + elseif los == 2 then + known[id] = los + ai.knownEnemies[id] = e + e.los = los + end + if persist == true then + if ai.knownEnemies[id] ~= nil then + if ai.knownEnemies[id].los == 2 then + known[id] = ai.knownEnemies[id].los end end - if los == 1 then - self.knownEnemies[id] = los - known[id] = los - end - if self.knownEnemies[id] ~= nil and DebugEnabled then - if known[id] == 2 and self.knownEnemies[id] == 2 then PlotDebug(pos.x, pos.z, "known") end - end + end + if los == 1 then + ai.knownEnemies[id] = e + e.los = los + known[id] = los + end + if ai.knownEnemies[id] ~= nil and DebugEnabled then + if known[id] == 2 and ai.knownEnemies[id].los == 2 then PlotDebug(pos.x, pos.z, "known") end end end end -- remove unit ghosts outside of radar range and building ghosts if they don't exist -- this is cheating a little bit, because dead units outside of sight will automatically be removed + -- also populate moving blips (whether in radar or in sight) for analysis + local blips = {} local f = game:Frame() - for id, los in pairs(self.knownEnemies) do + for id, e in pairs(ai.knownEnemies) do if not exists[id] then -- enemy died if ai.IDsWeAreAttacking[id] then @@ -221,53 +205,68 @@ if ai.IDsWeAreRaiding[id] then ai.raidhandler:TargetDied(ai.IDsWeAreRaiding[id]) end - local uname = self.enemyNames[id] - EchoDebug("enemy " .. uname .. " died!") - local mtypes = WhatUnitHurts(uname) + EchoDebug("enemy " .. e.unitName .. " died!") + local mtypes = UnitWeaponMtypeList(e.unitName) for i, mtype in pairs(mtypes) do ai.raidhandler:NeedMore(mtype) ai.attackhandler:NeedLess(mtype) if mtype == "air" then ai.bomberhandler:NeedLess() end end - self.knownEnemies[id] = nil - self.ghosts[id] = nil - elseif not known[id] then - self.knownEnemies[id] = nil - if not self.ghosts[id] then - self.ghosts[id] = { frame = f, position = exists[id] } + ai.knownEnemies[id] = nil + elseif not known[id] then + if not e.ghost then + e.ghost = { frame = f, position = e.position } + else + -- expire ghost + if f > e.ghost.frame + 600 then + ai.knownEnemies[id] = nil + end end else - self.ghosts[id] = nil - end - end - -- expire ghosts - for id, g in pairs(self.ghosts) do - if f > g.frame + 900 then - self.ghosts[id] = nil + if not unitTable[e.unitName].isBuilding then + local count = true + if e.los == 2 then + -- if we know what kind of unit it is, only count as a potential threat blip if it's a hurty unit + -- air doesn't count because there are no buildings in the air + local threatLayers = UnitThreatRangeLayers(e.unitName) + if threatLayers.ground.threat == 0 and threatLayers.submerged.threat == 0 then + count = false + end + end + if count then table.insert(blips, e) end + end + e.ghost = nil end end + -- send blips off for analysis + ai.tacticalhandler:NewEnemyPositions(blips) end function LosHandler:UpdateWrecks() local wrecks = game.map:GetMapFeatures() - if wrecks == nil then return end - if #wrecks == 0 then return end + if wrecks == nil then + ai.knownWrecks = {} + return + end + if #wrecks == 0 then + ai.knownWrecks = {} + return + end -- game:SendToConsole("updating known wrecks") local known = {} - if self.knownWrecks == nil then self.knownWrecks = {} end - for i, w in pairs(wrecks) do - if w ~= nil then - local wname = w:Name() + for i, feature in pairs(wrecks) do + if feature ~= nil then + local featureName = feature:Name() -- only count features that aren't geovents and that are known to be reclaimable or guessed to be so local okay = false - if wname ~= "geovent" then - if featureTable[wname] then - if featureTable[wname].reclaimable then + if featureName ~= "geovent" then -- don't get geo spots + if featureTable[featureName] then + if featureTable[featureName].reclaimable then okay = true end else for findString, metalValue in pairs(baseFeatureMetal) do - if string.find(wname, findString) then + if string.find(featureName, findString) then okay = true break end @@ -275,22 +274,22 @@ end end if okay then - -- don't get geo spots - local pos = w:GetPosition() - local los = self:GroundLos(pos) - local id = w:ID() + local position = feature:GetPosition() + local los = self:GroundLos(position) + local id = feature:ID() local persist = false + local wreck = { los = los, featureName = featureName, position = position } if los == 0 or los == 1 then -- don't remove from knownenemies if it was once seen persist = true elseif los == 2 then - known[id] = los - self.knownWrecks[id] = los + known[id] = true + ai.knownWrecks[id] = wreck end if persist == true then - if self.knownWrecks[id] ~= nil then - if self.knownWrecks[id] == 2 then - known[id] = self.knownWrecks[id] + if ai.knownWrecks[id] ~= nil then + if ai.knownWrecks[id].los == 2 then + known[id] = true end end end @@ -299,11 +298,11 @@ end ai.wreckCount = 0 -- remove wreck ghosts that aren't there anymore - for id, los in pairs(self.knownWrecks) do + for id, los in pairs(ai.knownWrecks) do -- game:SendToConsole("known enemy " .. id .. " " .. los) if known[id] == nil then -- game:SendToConsole("removed") - self.knownWrecks[id] = nil + ai.knownWrecks[id] = nil else ai.wreckCount = ai.wreckCount + 1 end @@ -403,8 +402,8 @@ function LosHandler:IsKnownEnemy(unit) local id = unit:ID() - if self.knownEnemies[id] then - return self.knownEnemies[id] + if ai.knownEnemies[id] then + return ai.knownEnemies[id].los else return 0 end @@ -412,8 +411,8 @@ function LosHandler:IsKnownWreck(feature) local id = feature:ID() - if self.knownWrecks[id] then - return self.knownWrecks[id] + if ai.knownWrecks[id] then + return ai.knownWrecks[id] else return 0 end @@ -421,9 +420,10 @@ function LosHandler:GhostPosition(unit) local id = unit:ID() - if self.ghosts[id] then - return self.ghosts[id].position - else - return nil + if ai.knownEnemies[id] then + if ai.knownEnemies[id].ghost then + return ai.knownEnemies[id].position + end end + return nil end diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/maphandler.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/maphandler.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/maphandler.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/maphandler.lua 2014-10-07 20:10:05.000000000 +0000 @@ -20,6 +20,11 @@ local minDefenseNetworkSize = 100000 +local function MapDataFilename() + local mapName = string.gsub(map:MapName(), "%W", "_") + return "cache/Shard-" .. game:GameName() .. "-" .. mapName .. ".lua" +end + local function serialize (o, keylist) if keylist == nil then keylist = "" end if type(o) == "number" then @@ -104,9 +109,6 @@ MapHandler = class(Module) -local sqrt = math.sqrt -local MapDataPath = "AI/Skirmish/Shard/yuri2BA/BA/mapdata/" - local function MiddleOfTwo(pos1, pos2) local deltax = pos2.x - pos1.x local deltaz = pos2.z - pos1.z @@ -409,38 +411,40 @@ end function MapHandler:SaveMapData() - local mdfilename = "cache/Shard-BA-" .. map:MapName() .. ".lua" + local mdfilename = MapDataFilename() EchoDebug("saving map data to " .. mdfilename) - -- io.output(map:MapName() .. ".lua") - mapdatafile = assert(io.open(mdfilename,'w'), "Unable to write " .. mdfilename) - EchoData("ai.mobilityGridSize", ai.mobilityGridSize) - -- EchoData("ai.factoryListMap", ai.factoryListMap) - EchoData("ai.mobilityGridMaxX", ai.mobilityGridMaxX) - EchoData("ai.mobilityGridMaxZ", ai.mobilityGridMaxZ) - EchoData("ai.waterMap", ai.waterMap) - EchoData("ai.mapHasGeothermal", ai.mapHasGeothermal) - EchoData("ai.mobilityRatingFloor", ai.mobilityRatingFloor) - EchoData("ai.hasUWSpots", ai.hasUWSpots) - EchoData("ai.mobilityGridSizeHalf", ai.mobilityGridSizeHalf) - EchoData("ai.mobilityGridArea", ai.mobilityGridArea) - EchoData("ai.mobRating", ai.mobRating) - EchoData("ai.mobCount", ai.mobCount) - EchoData("ai.mobNetworks", ai.mobNetworks) - EchoData("ai.networkSize", ai.networkSize) - EchoData("ai.landMetalSpots", ai.landMetalSpots) - EchoData("ai.UWMetalSpots", ai.UWMetalSpots) - EchoData("ai.geoSpots", ai.geoSpots) - EchoData("ai.startLocations", ai.startLocations) - EchoData("ai.mobNetworkMetals", ai.mobNetworkMetals) - EchoData("ai.scoutSpots", ai.scoutSpots) - EchoData("ai.topology", ai.topology) - mapdatafile:close() + mapdatafile = io.open(mdfilename,'w') + if mapdatafile ~= nil then + EchoData("ai.mobilityGridSize", ai.mobilityGridSize) + EchoData("ai.mobilityGridMaxX", ai.mobilityGridMaxX) + EchoData("ai.mobilityGridMaxZ", ai.mobilityGridMaxZ) + EchoData("ai.waterMap", ai.waterMap) + EchoData("ai.mapHasGeothermal", ai.mapHasGeothermal) + EchoData("ai.mobilityRatingFloor", ai.mobilityRatingFloor) + EchoData("ai.hasUWSpots", ai.hasUWSpots) + EchoData("ai.mobilityGridSizeHalf", ai.mobilityGridSizeHalf) + EchoData("ai.mobilityGridArea", ai.mobilityGridArea) + EchoData("ai.mobRating", ai.mobRating) + EchoData("ai.mobCount", ai.mobCount) + EchoData("ai.mobNetworks", ai.mobNetworks) + EchoData("ai.networkSize", ai.networkSize) + EchoData("ai.landMetalSpots", ai.landMetalSpots) + EchoData("ai.UWMetalSpots", ai.UWMetalSpots) + EchoData("ai.geoSpots", ai.geoSpots) + EchoData("ai.startLocations", ai.startLocations) + EchoData("ai.mobNetworkMetals", ai.mobNetworkMetals) + EchoData("ai.scoutSpots", ai.scoutSpots) + EchoData("ai.topology", ai.topology) + mapdatafile:close() + else + EchoDebug("unable to write map data file " .. mdfilename) + end end function MapHandler:LoadMapData() -- check for existing map data and load it local dataloaded = false - local mdfilename = "cache/Shard-BA-" .. map:MapName() .. ".lua" + local mdfilename = MapDataFilename() local mapdatafile = io.open(mdfilename ,"r") if mapdatafile ~= nil then mapdatafile:close() @@ -824,11 +828,11 @@ function MapHandler:OutmodedFactoryHere(mtype, position, network) if mtype == "air" then return false end - if position then + if position and network == nil then network = self:MobilityNetworkHere(mtype, position) end if network == nil then - return true + return false else if ai.networkSize[mtype][network] < ai.mobCount[mtype] * 0.67 and ai.mobNetworks[mtype] > 1 then return true @@ -859,45 +863,3 @@ return true end end - - --[[ - -- testing repeated table loops - local units = game:GetUnits() - local testunit - for nothing, u in pairs(units) do - if u ~= nil then - testunit = u - break - end - end - local test = {} - for x = 1, 9 do - for z = 1, 9 do - local pos = api.Position() - pos.y = 0 - pos.x = x + 0.5 - pos.z = z + 0.12345 - table.insert(test, pos) - end - end - local utype = game:GetTypeByName("armpeep") - local thing - local success - for n = 1, 9 do - local thistest = test - EchoDebug("LOOP " .. n .. " START") - for i, p in pairs(thistest) do - EchoDebug("#" .. i .. " " .. p.x .. " , " .. p.z) - local on = n + 1 - if on == 10 then on = 1 end - local dist = Distance(p, thistest[on]) - local build = game.map:CanBuildHere(utype, p) - local safe = ai.targethandler:IsSafePosition(p, testunit) - thing = p - success = testunit:Build(utype, p) - end - EchoDebug("LOOP " .. n .. " END") - EchoDebug(" ") - end - - ]]-- diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/modules.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/modules.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/modules.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/modules.lua 2014-10-07 20:10:05.000000000 +0000 @@ -1,5 +1,5 @@ require "maphandler" -require "buildhandler" +require "buildsitehandler" require "counthandler" require "unithandler" require "attackhandler" @@ -12,5 +12,8 @@ require "assisthandler" require "defendhandler" require "turtlehandler" +require "econhandler" +require "tacticalhandler" +require "damagehandler" -modules = { Sleep, MapHandler, AttackHandler, BomberHandler, RaidHandler, BuildSiteHandler, CountHandler, LosHandler, TargetHandler, ScoutHandler, AssistHandler, DefendHandler, TurtleHandler, UnitHandler } +modules = { Sleep, MapHandler, EconHandler, AttackHandler, BomberHandler, RaidHandler, BuildSiteHandler, CountHandler, TurtleHandler, TacticalHandler, LosHandler, TargetHandler, DamageHandler, ScoutHandler, AssistHandler, DefendHandler, UnitHandler } diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/raiderbehaviour.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/raiderbehaviour.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/raiderbehaviour.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/raiderbehaviour.lua 2014-10-07 20:10:05.000000000 +0000 @@ -27,6 +27,13 @@ local mtype, network = ai.maphandler:MobilityOfUnit(self.unit:Internal()) self.mtype = mtype self.name = self.unit:Internal():Name() + local utable = unitTable[self.name] + if self.mtype == "sub" then + self.range = utable.submergedRange + else + self.range = utable.groundRange + end + self.id = self.unit:Internal():ID() self.disarmer = raiderDisarms[self.name] if ai.raiderCount[mtype] == nil then ai.raiderCount[mtype] = 1 @@ -72,25 +79,19 @@ end ai.raidhandler:IDsWeAreRaiding(cell.buildingIDs, self.mtype) self.buildingIDs = cell.buildingIDs - local utable = unitTable[self.name] - if self.mtype == "sub" then - range = utable.submergedRange - else - range = utable.groundRange - end - self.target = RandomAway(cell.pos, range * 0.5) + self.target = RandomAway(cell.pos, self.range * 0.5) if self.mtype == "air" then if self.disarmer then self.unitTarget = cell.disarmTarget else - self.unitTarget = cell.airTarget + self.unitTarget = cell.targets.air.ground end - EchoDebug("air raid target: " .. tostring(self.unitTarget)) + EchoDebug("air raid target: " .. tostring(self.unitTarget.unitName)) end if self.active then if self.mtype == "air" then if self.unitTarget ~= nil then - self.unit:Internal():Attack(self.unitTarget) + CustomCommand(self.unit:Internal(), CMD_ATTACK, {self.unitTarget.unitID}) end else self.unit:Internal():Move(self.target) @@ -115,7 +116,7 @@ if self.target then if self.mtype == "air" then if self.unitTarget ~= nil then - self.unit:Internal():Attack(self.unitTarget) + CustomCommand(self.unit:Internal(), CMD_ATTACK, {self.unitTarget.unitID}) end else self.unit:Internal():Move(self.target) @@ -136,6 +137,7 @@ if math.mod(f, 89) == 0 then local unit = self.unit:Internal() local bestCell = ai.targethandler:GetBestRaidCell(unit) + ai.targethandler:RaiderHere(self) EchoDebug(self.name .. " targetting...") if bestCell then EchoDebug(self.name .. " got target") @@ -155,11 +157,12 @@ attackTarget = ai.targethandler:NearbyVulnerable(unit) end if attackTarget then - unit:Attack(attackTarget) + CustomCommand(unit, CMD_ATTACK, {attackTarget.unitID}) else -- evade enemies on the way to the target, if possible if self.target ~= nil then local newPos, arrived = ai.targethandler:BestAdjacentPosition(unit, self.target) + ai.targethandler:RaiderHere(self) if newPos then EchoDebug(self.name .. " evading") unit:Move(newPos) @@ -173,7 +176,7 @@ -- return to course to target after evading if self.mtype == "air" then if self.unitTarget ~= nil then - self.unit:Internal():Attack(self.unitTarget) + CustomCommand(self.unit:Internal(), CMD_ATTACK, {self.unitTarget.unitID}) end else self.unit:Internal():Move(self.target) diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/reclaimbehaviour.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/reclaimbehaviour.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/reclaimbehaviour.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/reclaimbehaviour.lua 2014-10-07 20:10:05.000000000 +0000 @@ -126,20 +126,14 @@ end if vulnerable ~= nil then EchoDebug("reclaiming enemy...") - self.unit:Internal():Reclaim(vulnerable) + CustomCommand(self.unit:Internal(), CMD_RECLAIM, {vulnerable.unitID}) elseif self.targetResurrection ~= nil and not self.resurrecting then EchoDebug("resurrecting...") - local resPosition = self.targetResurrection:GetPosition() - local unitName = featureTable[self.targetResurrection:Name()].unitName + local resPosition = self.targetResurrection.position + local unitName = featureTable[self.targetResurrection.featureName].unitName EchoDebug(unitName) - local floats = api.vectorFloat() - --floats:push_back(self.targetResurrection:ID()) - floats:push_back(resPosition.x) - floats:push_back(resPosition.y) - floats:push_back(resPosition.z) - floats:push_back(15) - self.unit:Internal():ExecuteCustomCommand(CMD_RESURRECT, floats) - ai.buildsitehandler:NewPlan(unitName, self.targetResurrection:GetPosition(), self, true) + CustomCommand(self.unit:Internal(), CMD_RESURRECT, {resPosition.x, resPosition.y, resPosition.z, 15}) + ai.buildsitehandler:NewPlan(unitName, resPosition, self, true) self.resurrecting = true else EchoDebug("reclaiming area...") diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/runfromattack.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/runfromattack.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/runfromattack.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/runfromattack.lua 1970-01-01 00:00:00.000000000 +0000 @@ -1,137 +0,0 @@ -require "common" - - -local DebugEnabled = false - -local function EchoDebug(inStr) - if DebugEnabled then - game:SendToConsole("RunFromAttackBehaviour: " .. inStr) - end -end - -RunFromAttackBehaviour = class(Behaviour) - -function RunFromAttackBehaviour:Init() - self.active = false - self.underfire = false - self.lastAttackedFrame = game:Frame() - -- this is where we will retreat - self.initialLocation = self.unit:Internal():GetPosition() - self.name = self.unit:Internal():Name() - self.mobile = not unitTable[self.name].isBuilding - EchoDebug("RunFromAttackBehaviour: added to unit "..self.name) -end - -function RunFromAttackBehaviour:UnitIdle(unit) - if unit:Internal():ID() == self.unit:Internal():ID() then - if self:IsActive() then - self.underfire = false - self.unit:ElectBehaviour() - end - end -end - -function RunFromAttackBehaviour:Update() - local f = game:Frame() - - -- timeout on underfire condition - if self.underfire then - if f > self.lastAttackedFrame + 300 then - self.underfire = false - end - else - if f % 30 == 0 then - -- run away preemptively from positions within range of enemy weapons, and notify defenders that the unit is in danger - local unit = self.unit:Internal() - local safe - if commanderList[self.name] then - safe = ai.targethandler:IsSafePosition(unit:GetPosition(), unit, 0.2) - else - safe = ai.targethandler:IsSafePosition(unit:GetPosition(), unit, 2) - end - if safe then - self.underfire = false - self.unit:ElectBehaviour() - else - self.underfire = true - self.lastAttackedFrame = game:Frame() - ai.defendhandler:Danger(unit) - self.unit:ElectBehaviour() - end - end - end -end - -function RunFromAttackBehaviour:Activate() - EchoDebug("RunFromAttackBehaviour: activated on unit "..self.name) - - -- can we move at all? - if self.mobile then - -- run to the most defended base location - local salvation = ai.turtlehandler:MostTurtled(self.unit:Internal()) - if salvation == nil then - -- if no turtle, find the nearest combat unit - salvation = self:NearestCombat() - end - if salvation == nil then - -- if none found, just go to where we were built - salvation = self.initialLocation - end - self.unit:Internal():Move(RandomAway(salvation,150)) - - self.active = true - EchoDebug("RunFromAttackBehaviour: unit ".. self.name .." runs away from danger") - end -end - -function RunFromAttackBehaviour:NearestCombat() - local best - local ownUnits = game:GetFriendlies() - local fleeing = self.unit:Internal() - local fn = fleeing:Name() - local fid = fleeing:ID() - local fpos = fleeing:GetPosition() - local bestDistance = 10000 - for i,unit in pairs(ownUnits) do - local un = unit:Name() - if unit:ID() ~= fid and un ~= "corcom" and un ~= "armcom" and not ai.defendhandler:IsDefendingMe(unit, fleeing) then - if unitTable[un].isWeapon and (battleList[un] or breakthroughList[un]) and unitTable[un].metalCost > unitTable[fn].metalCost * 1.5 then - local upos = unit:GetPosition() - if ai.targethandler:IsSafePosition(upos, fleeing) and unit:GetHealth() > unit:GetMaxHealth() * 0.9 and ai.maphandler:UnitCanGetToUnit(fleeing, unit) and not unit:IsBeingBuilt() then - local dist = Distance(fpos, upos) - unitTable[un].metalCost - if dist < bestDistance then - bestDistance = dist - best = upos - end - end - end - end - end - return best -end - -function RunFromAttackBehaviour:Deactivate() - EchoDebug("RunFromAttackBehaviour: deactivated on unit "..self.name) - self.active = false - self.underfire = false -end - -function RunFromAttackBehaviour:Priority() - if self.underfire and self.mobile then - return 110 - else - return 0 - end -end - -function RunFromAttackBehaviour:UnitDamaged(unit,attacker) - if unit:Internal():ID() == self.unit:Internal():ID() then - if not self.underfire then - self.underfire = true - self.lastAttackedFrame = game:Frame() - ai.defendhandler:Danger(unit:Internal()) - self.unit:ElectBehaviour() - end - end -end - diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/scoutbehaviour.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/scoutbehaviour.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/scoutbehaviour.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/scoutbehaviour.lua 2014-10-07 20:10:05.000000000 +0000 @@ -10,12 +10,12 @@ end function IsScout(unit) - for i,name in ipairs(scoutList) do - if name == unit:Internal():Name() then - return true - end + local unitName = unit:Internal():Name() + if scoutList[unitName] then + return true + else + return false end - return false end ScoutBehaviour = class(Behaviour) @@ -82,7 +82,7 @@ end end if attackTarget and not self.attacking then - unit:Attack(attackTarget) + CustomCommand(unit, CMD_ATTACK, {attackTarget.unitID}) self.target = nil self.evading = false self.attacking = true diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/tacticalhandler.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/tacticalhandler.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/tacticalhandler.lua 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/tacticalhandler.lua 2014-10-07 20:10:05.000000000 +0000 @@ -0,0 +1,130 @@ +require "common" + +-- keeps track of where enemy units seem to be moving + +local DebugEnabled = false +local debugPlotTacticalFile + +local function EchoDebug(inStr) + if DebugEnabled then + game:SendToConsole("TacticalHandler: " .. inStr) + end +end + +local function PlotDebug(x1, z1, vx, vz, label) + if DebugEnabled then + local x2 = x1 + vx * 1200 + local z2 = z1 + vz * 1200 + debugPlotTacticalFile:write(ceil(x1) .. " " .. ceil(z1) .. " " .. ceil(x2) .. " " .. ceil(z2) .. " " .. label .. "\n") + end +end + +TacticalHandler = class(Module) + +function TacticalHandler:Name() + return "TacticalHandler" +end + +function TacticalHandler:internalName() + return "tacticalhandler" +end + +function TacticalHandler:Init() + self.lastPositionsFrame = 0 + self.lastAverageFrame = 0 + self.lastPositions = {} + self.lastKnownPositions = {} + self.lastKnownVectors = {} + self.unitSamples = {} + self.threatLayerNames = { "ground", "air", "submerged" } + ai.incomingThreat = 0 + if DebugEnabled then debugPlotTacticalFile = assert(io.open("debugtacticalplot",'w'), "Unable to write debugtacticalplot") end +end + +function TacticalHandler:NewEnemyPositions(positions) + local f = game:Frame() + local since = f - self.lastPositionsFrame + local update = {} + for i, e in pairs(positions) do + local le = self.lastPositions[e.unitID] + if le then + local vx = e.position.x - le.position.x + local vz = e.position.z - le.position.z + if abs(vx) > 0 or abs(vz) > 0 then + vx = vx / since + vz = vz / since + if not self.unitSamples[e.unitID] then + self.unitSamples[e.unitID] = {} + end + table.insert(self.unitSamples[e.unitID], { vx = vx, vz = vz }) + end + self.lastKnownPositions[e.unitID] = e + end + update[e.unitID] = e + end + self.lastPositions = update + self.lastPositionsFrame = f + self:AverageSamples() +end + +function TacticalHandler:AverageUnitSamples(samples) + local totalVX = 0 + local totalVZ = 0 + for i, sample in pairs(samples) do + totalVX = totalVX + sample.vx + totalVZ = totalVZ + sample.vz + end + local vx = totalVX / #samples + local vz = totalVZ / #samples + return vx, vz +end + +function TacticalHandler:AverageSamples() + local f = game:Frame() + local since = f - self.lastAverageFrame + if since < 300 then return end + if DebugEnabled then debugPlotTacticalFile:close() end + if DebugEnabled then debugPlotTacticalFile = assert(io.open("debugtacticalplot",'w'), "Unable to write debugtacticalplot") end + -- ai.turtlehandler:ResetThreatForecast() + for unitID, samples in pairs(self.unitSamples) do + local e = self.lastKnownPositions[unitID] + if e then + local vx, vz = self:AverageUnitSamples(samples) + self.lastKnownVectors[unitID] = { vx = vx, vz = vz } -- so that anyone using this unit table as a target will be able to lead a little + PlotDebug(e.position.x, e.position.z, vx, vz, "THREAT") + -- ai.turtlehandler:AddThreatVector(e, vx, vz) + end + end + -- ai.turtlehandler:AlertDangers() + self.unitSamples = {} + self.lastAverageFrame = f +end + +-- for raider and other targetting export +function TacticalHandler:PredictPosition(unitID, frames) + local vector = self.lastKnownVectors[unitID] + if vector == nil then return end + local e = self.lastKnownPositions[unitID] + if e == nil then return end + return ApplyVector(e.position.x, e.position.z, vector.vx, vector.vz, frames) +end + +-- so our tables don't bloat +function TacticalHandler:UnitDead(unit) + local unitID = unit:ID() + self.lastKnownPositions[unitID] = nil + self.lastKnownVectors[unitID] = nil + self.unitSamples[unitID] = nil +end + +function TacticalHandler:PlotPositionDebug(position, label) + if DebugEnabled then + debugPlotTacticalFile:write(ceil(position.x) .. " " .. ceil(position.z) .. " " .. label .. "\n") + end +end + +function TacticalHandler:PlotABDebug(x1, z1, x2, z2, label) + if DebugEnabled then + debugPlotTacticalFile:write(ceil(x1) .. " " .. ceil(z1) .. " " .. ceil(x2) .. " " .. ceil(z2) .. " " .. label .. "\n") + end +end \ No newline at end of file diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/targethandler.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/targethandler.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/targethandler.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/targethandler.lua 2014-10-07 20:10:05.000000000 +0000 @@ -66,14 +66,18 @@ local wreckMult = 100 local vulnerableReclaimDistMod = 100 local badCellThreat = 300 +local attackDistMult = 0.5 -- between 0 and 1, the lower number, the less distance matters local factoryValue = 1000 local conValue = 300 -local techValue = 100 +local techValue = 50 +local energyOutValue = 2 local minNukeValue = factoryValue + techValue + 500 local feintRepeatMod = 25 +local unitValue = {} + local enemyAlreadyCounted = {} local currentEnemyThreatCount = 0 local currentEnemyImmobileThreatCount = 0 @@ -90,45 +94,25 @@ local dangers = {} -local lastUpdateFrame = 0 - local function NewCell(px, pz) - local newcell = {value = 0, groundValue = 0, airValue = 0, submergedValue = 0, bomberValue = 0, torpedoBomberValue = 0, groundThreat = 0, airThreat = 0, submergedThreat = 0, buildingIDs = {}, bomberTargets = {}, torpedoBomberTargets = {}, resurrectables = {}, metal = 0, energy = 0, friendlyValue = 0, friendlyBuildings = 0, friendlyLandCombats = 0, friendlyAirCombats = 0, friendlyWaterCombats = 0, x = px, z = pz} + local values = { + ground = {ground = 0, air = 0, submerged = 0, value = 0}, + air = {ground = 0, air = 0, submerged = 0, value = 0}, + submerged = {ground = 0, air = 0, submerged = 0, value = 0}, + } -- value to our units first to who can be hurt by those things, then to those who have those kinds of weapons + -- [GAS].value is just everything that doesn't hurt that kind of thing + local targets = { ground = {}, air = {}, submerged = {}, } -- just one target for each [GAS][hurtGAS] + local vulnerables = { ground = {}, air = {}, submerged = {}, } -- just one vulnerable for each [GAS][hurtGAS] + local threat = { ground = 0, air = 0, submerged = 0 } -- threats (including buildings) by what they hurt + local response = { ground = 0, air = 0, submerged = 0 } -- count mobile threat by what can hurt it + local preresponse = { ground = 0, air = 0, submerged = 0 } -- count where mobile threat will probably be by what can hurt it + local newcell = { value = 0, explosionValue = 0, values = values, threat = threat, response = response, buildingIDs = {}, targets = targets, vulnerables = vulnerables, resurrectables = {}, lastDisarmThreat = 0, metal = 0, energy = 0, x = px, z = pz } return newcell end -local function ThreatRange(unitName, groundAirSubmerged, enemy) - if antinukeList[unitName] or nukeList[unitName] or bigPlasmaList[unitName] or shieldList[unitName] then - return 0, 0 - end - local utable = unitTable[unitName] - if groundAirSubmerged == nil then - if utable.groundRange > utable.airRange and utable.groundRange > utable.submergedRange then - groundAirSubmerged = "ground" - elseif utable.airRange > utable.groundRange and utable.airRange > utable.submergedRange then - groundAirSubmerged = "air" - elseif utable.submergedRange > utable.groundRange and utable.submergedRange > utable.airRange then - groundAirSubmerged = "submerged" - end - end - local threat = 0 - local range = 0 - if groundAirSubmerged == "ground" and (utable.mtype ~= "air" or not enemy) then -- air units ignored because they move too fast for their position to matter for ground threat calculations. however our own air units need to count - range = utable.groundRange - elseif groundAirSubmerged == "air" then - range = utable.airRange - elseif groundAirSubmerged == "submerged" then - range = utable.submergedRange - end - if range > 0 and threat == 0 then - threat = utable.metalCost - end - -- double the threat if it's a building (buildings are more bang for your buck) - if threat > 0 and utable.isBuilding then threat = threat + threat end - return threat, range -end - local function Value(unitName) + local v = unitValue[unitName] + if v then return v end local utable = unitTable[unitName] if not utable then return 0 end local val = utable.metalCost + (utable.techLevel * techValue) @@ -145,86 +129,42 @@ val = val + 800000 * utable.extractsMetal end if utable.totalEnergyOut > 0 then - val = val + utable.totalEnergyOut + val = val + (utable.totalEnergyOut * energyOutValue) end + unitValue[unitName] = val return val end -local function WhatHurtsUnit(unitName, mtype) - if unitName then - local ut = unitTable[unitName] - if ut then - mtype = ut.mtype - end - end - local hurts = {} - if mtype == "veh" or mtype == "bot" or mtype == "amp" or mtype == "hov" or mtype == "shp" then - hurts["ground"] = true - end - if mtype == "air" then - hurts["air"] = true - end - if mtype == "sub" or mtype == "shp" or mtype == "amp" then - hurts["submerged"] = true - end - return hurts -end - ---[[ -local function WhereUnitGoes(unit) - local mtype = unitTable[unit:Name()].mtype - local law = {} - if mtype == "veh" or mtype == "bot" or mtype == "hov" or mtype == "amp" then - law["land"] = true - end - if mtype == "air" then - law["air"] = true - end - if mtype == "sub" or mtype == "shp" or mtype == "hov" or mtype == "amp" then - law["water"] = true - end - return law -end -]]-- - +-- need to change because: amphibs can't be hurt by non-submerged threats in water, and can't be hurt by anything but ground on land local function CellValueThreat(unitName, cell) if cell == nil then return 0, 0 end - local gas + local gas, weapons if unitName == "ALL" then - gas = {} - gas["ground"] = true - gas["air"] = true - gas["submerged"] = true + gas = { ground = true, air = true, submerged = true } + weapons = { "ground", "air", "submerged" } unitName = "nothing" else - gas = WhatHurtsUnit(unitName) + gas = WhatHurtsUnit(unitName, nil, cell.pos) + weapons = UnitWeaponLayerList(unitName) end local threat = 0 local value = 0 - if gas["ground"] then - threat = threat + cell.groundThreat - value = value + cell.groundValue - end - if gas["air"] then - threat = threat + cell.airThreat - -- ground weapons can hurt gunships sometimes - if raiderList[unitName] and not raiderDisarms[unitName] then - threat = threat + cell.groundThreat * 0.1 - end - value = value + cell.airValue - end - if gas["submerged"] then - threat = threat + cell.submergedThreat - value = value + cell.submergedValue + local notThreat = 0 + for GAS, yes in pairs(gas) do + if yes then + threat = threat + cell.threat[GAS] + for i, weaponGAS in pairs(weapons) do + value = value + cell.values[GAS][weaponGAS] + end + elseif raiderDisarms[unitName] then + notThreat = notThreat + cell.threat[GAS] + end + end + if gas.air and raiderList[unitName] and not raiderDisarms[unitName] then + threat = threat + cell.threat.ground * 0.1 end if raiderDisarms[unitName] then - local notThreat = 0 - if not gas["ground"] then notThreat = notThreat + cell.groundThreat end - if not gas["air"] then notThreat = notThreat + cell.airThreat end - if not gas["submerged"] then notThreat = notThreat + cell.submergedThreat end - if notThreat == 0 then - value = 0 - end + if notThreat == 0 then value = 0 end end return value, threat, gas end @@ -242,6 +182,19 @@ end end +local function GetOrCreateCellHere(pos) + local px, pz = GetCellPosition(pos) + if cells[px] == nil then cells[px] = {} end + if cells[px][pz] == nil then + local cell = NewCell(px, pz) + cell.pos = pos + cells[px][pz] = cell + table.insert(cellList, cell) + return cell + end + return cells[px][pz] +end + function TargetHandler:Name() return "TargetHandler" end @@ -250,7 +203,7 @@ return "targethandler" end -local function HorizontalLine(x, z, tx, groundAirSubmerged, val) +local function HorizontalLine(x, z, tx, threatResponse, groundAirSubmerged, val) -- EchoDebug("horizontal line from " .. x .. " to " .. tx .. " along z " .. z .. " with value " .. val .. " in " .. groundAirSubmerged) for ix = x, tx do if cells[ix] == nil then cells[ix] = {} end @@ -259,24 +212,18 @@ cells[ix][z] = NewCell(ix, z) if DebugEnabled then table.insert(cellList, cells[ix][z]) end end - if groundAirSubmerged == "ground" then - cells[ix][z].groundThreat = cells[ix][z].groundThreat + val - elseif groundAirSubmerged == "air" then - cells[ix][z].airThreat = cells[ix][z].airThreat + val - elseif groundAirSubmerged == "submerged" then - cells[ix][z].submergedThreat = cells[ix][z].submergedThreat + val - end + cells[ix][z][threatResponse][groundAirSubmerged] = cells[ix][z][threatResponse][groundAirSubmerged] + val end end -local function Plot4(cx, cz, x, z, groundAirSubmerged, val) - HorizontalLine(cx - x, cz + z, cx + x, groundAirSubmerged, val) +local function Plot4(cx, cz, x, z, threatResponse, groundAirSubmerged, val) + HorizontalLine(cx - x, cz + z, cx + x, threatResponse, groundAirSubmerged, val) if x ~= 0 and z ~= 0 then - HorizontalLine(cx - x, cz - z, cx + x, groundAirSubmerged, val) + HorizontalLine(cx - x, cz - z, cx + x, threatResponse, groundAirSubmerged, val) end end -local function FillCircle(cx, cz, radius, groundAirSubmerged, val) +local function FillCircle(cx, cz, radius, threatResponse, groundAirSubmerged, val) local radius = math.ceil(radius / cellElmos) if radius > 0 then local err = -radius @@ -287,9 +234,9 @@ err = err + z z = z + 1 err = err + z - Plot4(cx, cz, x, lastZ, groundAirSubmerged, val) + Plot4(cx, cz, x, lastZ, threatResponse, groundAirSubmerged, val) if err >= 0 then - if x ~= lastZ then Plot4(cx, cz, lastZ, x, groundAirSubmerged, val) end + if x ~= lastZ then Plot4(cx, cz, lastZ, x, threatResponse, groundAirSubmerged, val) end err = err - x x = x - 1 err = err - x @@ -298,44 +245,38 @@ end end -local function CheckHorizontalLine(x, z, tx, groundAirSubmerged) +local function CheckHorizontalLine(x, z, tx, threatResponse, groundAirSubmerged) -- EchoDebug("horizontal line from " .. x .. " to " .. tx .. " along z " .. z .. " in " .. groundAirSubmerged) local value = 0 local threat = 0 for ix = x, tx do if cells[ix] ~= nil then if cells[ix][z] ~= nil then - if groundAirSubmerged == "ground" then - value = value + cells[ix][z].groundValue - threat = threat + cells[ix][z].groundThreat - elseif groundAirSubmerged == "air" then - value = value + cells[ix][z].airValue - threat = threat + cells[ix][z].airThreat - elseif groundAirSubmerged == "submerged" then - value = value + cells[ix][z].submergedValue - threat = threat + cells[ix][z].submergedThreat - end + local cell = cells[ix][z] + local value = cell.values[groundAirSubmerged].value -- can't hurt it + local threat = cell[threatResponse][groundAirSubmerged] + return value, threat end end end return value, threat end -local function Check4(cx, cz, x, z, groundAirSubmerged) +local function Check4(cx, cz, x, z, threatResponse, groundAirSubmerged) local value = 0 local threat = 0 - local v, t = CheckHorizontalLine(cx - x, cz + z, cx + x, groundAirSubmerged) + local v, t = CheckHorizontalLine(cx - x, cz + z, cx + x, threatResponse, groundAirSubmerged) value = value + v threat = threat + t if x ~= 0 and z ~= 0 then - local v, t = CheckHorizontalLine(cx - x, cz - z, cx + x, groundAirSubmerged) + local v, t = CheckHorizontalLine(cx - x, cz - z, cx + x, threatResponse, groundAirSubmerged) value = value + v threat = threat + t end return value, threat end -local function CheckInRadius(cx, cz, radius, groundAirSubmerged) +local function CheckInRadius(cx, cz, radius, threatResponse, groundAirSubmerged) local radius = math.ceil(radius / cellElmos) local value = 0 local threat = 0 @@ -348,12 +289,12 @@ err = err + z z = z + 1 err = err + z - local v, t = Check4(cx, cz, x, lastZ, groundAirSubmerged) + local v, t = Check4(cx, cz, x, lastZ, threatResponse, groundAirSubmerged) value = value + v threat = threat + t if err >= 0 then if x ~= lastZ then - local v, t = Check4(cx, cz, lastZ, x, groundAirSubmerged) + local v, t = Check4(cx, cz, lastZ, x, threatResponse, groundAirSubmerged) value = value + v threat = threat + t end @@ -366,15 +307,15 @@ return value, threat end -local function CountEnemyThreat(e, threat) - if not enemyAlreadyCounted[e] then +local function CountEnemyThreat(unitID, unitName, threat) + if not enemyAlreadyCounted[unitID] then currentEnemyThreatCount = currentEnemyThreatCount + threat - if unitTable[e:Name()].isBuilding then + if unitTable[unitName].isBuilding then currentEnemyImmobileThreatCount = currentEnemyImmobileThreatCount + threat else currentEnemyMobileThreatCount = currentEnemyMobileThreatCount + threat end - enemyAlreadyCounted[e] = true + enemyAlreadyCounted[unitID] = true end end @@ -480,26 +421,18 @@ local function UpdateEnemies() ai.enemyMexSpots = {} - local enemies = game:GetEnemies() - if enemies == nil then return end - if #enemies == 0 then return end - - -- figure out where all the enemies are! + -- where is/are the party/parties tonight? local highestValue = minNukeValue local highestValueCell - for i, e in pairs(enemies) do - local los = ai.loshandler:IsKnownEnemy(e) - local ghost = ai.loshandler:GhostPosition(e) - local name = e:Name() + for unitID, e in pairs(ai.knownEnemies) do + local los = e.los + local ghost = e.ghost + local name = e.unitName + local ut = unitTable[name] -- only count those we know about and that aren't being built - if (los ~= 0 or ghost) and not e:IsBeingBuilt() then + if (los ~= 0 or ghost) and not e.beingBuilt then local pos - if ghost then - EchoDebug("using ghost position") - pos = ghost - else - pos = e:GetPosition() - end + if ghost then pos = ghost.position else pos = e.position end local px, pz = GetCellPosition(pos) if cells[px] == nil then cells[px] = {} @@ -510,79 +443,64 @@ end cell = cells[px][pz] if los == 1 then - if unitTable[name].isBuilding then + if ut.isBuilding then cell.value = cell.value + baseBuildingValue else -- if it moves, assume it's out to get you - FillCircle(px, pz, baseUnitRange, "ground", baseUnitThreat) - FillCircle(px, pz, baseUnitRange, "air", baseUnitThreat) - FillCircle(px, pz, baseUnitRange, "submerged", baseUnitThreat) + FillCircle(px, pz, baseUnitRange, "threat", "ground", baseUnitThreat) + FillCircle(px, pz, baseUnitRange, "threat", "air", baseUnitThreat) + FillCircle(px, pz, baseUnitRange, "threat", "submerged", baseUnitThreat) end elseif los == 2 then - DangerCheck(name, e:ID()) + local mtype = ut.mtype + DangerCheck(name, e.unitID) local value = Value(name) if unitTable[name].extractsMetal ~= 0 then table.insert(ai.enemyMexSpots, { position = pos, unit = e }) end if unitTable[name].isBuilding then - table.insert(cell.buildingIDs, e:ID()) + table.insert(cell.buildingIDs, e.unitID) end - for i, groundAirSubmerged in pairs(threatTypes) do - local threat, range = ThreatRange(name, groundAirSubmerged, true) - -- EchoDebug(name .. " " .. groundAirSubmerged .. " " .. threat .. " " .. range) + local hurtBy = WhatHurtsUnit(name) + local threatLayers = UnitThreatRangeLayers(name) + local threatToTurtles = threatLayers.ground.threat + threatLayers.submerged.threat + local maxRange = max(threatLayers.ground.range, threatLayers.submerged.range) + for groundAirSubmerged, layer in pairs(threatLayers) do + if threatToTurtles ~= 0 and hurtBy[groundAirSubmerged] then + FillCircle(px, pz, maxRange, "response", groundAirSubmerged, threatToTurtles) + end + local threat, range = layer.threat, layer.range + if mtype == "air" and groundAirSubmerged == "ground" or groundAirSubmerged == "submerged" then threat = 0 end -- because air units are pointless to run from if threat ~= 0 then - FillCircle(px, pz, range, groundAirSubmerged, threat) - CountEnemyThreat(e, threat) - elseif unitTable[name].mtype ~= "air" then - -- for those times when you need to attack the unit itself, not the ground - local health = e:GetHealth() - local mtype = unitTable[name].mtype - if groundAirSubmerged == "ground" then - if mtype ~= "air" and mtype ~= "sub" then - cell.groundTarget = e - if health < vulnerableHealth then - cell.groundVulnerable = e - end - cell.groundValue = cell.groundValue + value - end - elseif groundAirSubmerged == "air" then - if mtype == "sub" then - table.insert(cell.torpedoBomberTargets, e) - cell.torpedoBomberValue = cell.torpedoBomberValue + value - if unitTable[name].bigExplosion then cell.torpedoBomberValue = cell.torpedoBomberValue + bomberExplosionValue end + FillCircle(px, pz, range, "threat", groundAirSubmerged, threat) + CountEnemyThreat(e.unitID, name, threat) + elseif mtype ~= "air" then -- air units are too hard to attack + local health = e.health + for hurtGAS, hit in pairs(hurtBy) do + cell.values[groundAirSubmerged][hurtGAS] = cell.values[groundAirSubmerged][hurtGAS] + value + if cell.targets[groundAirSubmerged][hurtGAS] == nil then + cell.targets[groundAirSubmerged][hurtGAS] = e else - if mtype == "shp" then - table.insert(cell.torpedoBomberTargets, e) - cell.torpedoBomberValue = cell.torpedoBomberValue + value - if unitTable[name].bigExplosion then cell.torpedoBomberValue = cell.torpedoBomberValue + bomberExplosionValue end - end - cell.airTarget = e - table.insert(cell.bomberTargets, e) - if health < vulnerableHealth then - cell.airVulnerable = e + if value > Value(cell.targets[groundAirSubmerged][hurtGAS].unitName) then + cell.targets[groundAirSubmerged][hurtGAS] = e end - local gt, gr = ThreatRange(name, "ground", true) - if gt > 0 then - if cell.disarmTarget then - local ogt, ogr = ThreatRange(cell.disarmTarget:Name(), "ground", true) - if gt > ogt then - cell.disarmTarget = e - end - else - cell.disarmTarget = e - end - end - cell.airValue = cell.airValue + value - cell.bomberValue = cell.bomberValue + value - if unitTable[name].bigExplosion then cell.bomberValue = cell.bomberValue + bomberExplosionValue end end - elseif groundAirSubmerged == "submerged" then - if mtype == "sub" or mtype == "shp" then - cell.submergedTarget = e - if health < vulnerableHealth then - cell.submergedVulnerable = e + if health < vulnerableHealth then + cell.vulnerables[groundAirSubmerged][hurtGAS] = e + end + if groundAirSubmerged == "air" and hurtGAS == "ground" and threatLayers.ground.threat > cell.lastDisarmThreat then + cell.disarmTarget = e + cell.lastDisarmThreat = threatLayers.ground.threat + end + end + if ut.bigExplosion then + cell.explosionValue = cell.explosionValue + bomberExplosionValue + if cell.explosiveTarget == nil then + cell.explosiveTarget = e + else + if value > Value(cell.explosiveTarget.unitName) then + cell.explosiveTarget = e end - cell.submergedValue = cell.submergedValue + value end end end @@ -592,8 +510,7 @@ highestValue = cell.value highestValueCell = cell end - end - + end -- we dont want to target the center of the cell encase its a ledge with nothing -- on it etc so target this units position instead cell.pos = pos @@ -608,121 +525,83 @@ end end ---[[ -local function UpdateFriendlies() - ai.totalFriendlyThreat = 0 - local friendlies = game:GetFriendlies() - if friendlies == nil then return end - if #friendlies == 0 then return end - -- figure out where all the friendlies are! - for i, f in pairs(friendlies) do - local name = f:Name() - local pos = f:GetPosition() - local px, pz = GetCellPosition(pos) - if cells[px] == nil then - cells[px] = {} - end - if cells[px][pz] == nil then - cells[px][pz] = NewCell(px, pz) - table.insert(cellList, cells[px][pz]) - end - cell = cells[px][pz] - cell.friendlyValue = cell.friendlyValue + Value(name) - if unitTable[name].isBuilding then - cell.friendlyBuildings = cell.friendlyBuildings + 1 - end - local threat, range = ThreatRange(name) - -- EchoDebug(name .. " " .. groundAirSubmerged .. " " .. threat .. " " .. range) - if threat ~= 0 then - ai.totalFriendlyThreat = ai.totalFriendlyThreat + threat - if not unitTable[name].isBuilding then - local mtype = unitTable[name].mtype - -- count mobile combat units in cell - if mtype == "veh" or mtype == "bot" or mtype == "hov" or mtype == "amp" then - cell.friendlyLandCombats = cell.friendlyLandCombats + 1 - end - if mtype == "air" then - cell.friendlyAirCombats = cell.friendlyAirCombats + 1 - end - if mtype == "sub" or mtype == "shp" or mtype == "hov" or mtype == "amp" then - cell.friendlyWaterCombats = cell.friendlyWaterCombats + 1 - end - end - end - if cell.pos == nil then cell.pos = pos end - end -end -]]-- - local function UpdateBadPositions() local f = game:Frame() - -- game:SendToConsole(f .. ": " .. #badPositions .. " bad positions before") for i, r in pairs(badPositions) do if cells[r.px] then cell = cells[r.px][r.pz] if cell then - if r.groundAirSubmerged == "ground" then - cell.groundThreat = cell.groundThreat + badCellThreat - elseif r.groundAirSubmerged == "air" then - cell.airThreat = cell.airThreat + badCellThreat - elseif r.groundAirSubmerged == "submerged" then - cell.submergedThreat = cell.submergedThreat + badCellThreat - end + cell.threat[r.groundAirSubmerged] = cell.threat[r.groundAirSubmerged] + r.threat end end - if f > r.frame + 1800 then + if f > r.frame + r.duration then -- remove bad positions after 1 minute table.remove(badPositions, i) - -- game:SendToConsole("bad position #" .. i .. " removed") end end - -- game:SendToConsole(f .. ": " .. #badPositions .. " bad positions after") end local function UpdateWrecks() -- figure out where all the wrecks are - local wrecks = map:GetMapFeatures() - if wrecks == nil then return end - if #wrecks == 0 then return end - for i, w in pairs(wrecks) do - if ai.loshandler:IsKnownWreck(w) then - -- will need to check if reclaimer can get to wreck later - -- ai.maphandler:UnitCanGoHere(representative, pos) - local pos = w:GetPosition() - -- EchoDebug("wreck position" .. pos.x .. " " .. pos.z) - local px, pz = GetCellPosition(pos) - if cells[px] == nil then - cells[px] = {} - end - if cells[px][pz] == nil then - cells[px][pz] = NewCell(px, pz) - table.insert(cellList, cells[px][pz]) + for id, w in pairs(ai.knownWrecks) do + -- will need to check if reclaimer can get to wreck later + local pos = w.position + local cell = GetOrCreateCellHere(pos) + local wname = w.featureName + local ftable = featureTable[wname] + if ftable ~= nil then + cell.metal = cell.metal + ftable.metal + cell.energy = cell.energy + ftable.energy + if ftable.unitName ~= nil then + local rut = unitTable[ftable.unitName] + if rut.isWeapon or rut.extractsMetal > 0 then + table.insert(cell.resurrectables, w) + end end - cell = cells[px][pz] - if cell.pos == nil then - cell.pos = pos + else + for findString, metalValue in pairs(baseFeatureMetal) do + if string.find(wname, findString) then + cell.metal = cell.metal + metalValue + break + end end - local wname = w:Name() - local ftable = featureTable[wname] - if ftable ~= nil then - cell.metal = cell.metal + ftable.metal - cell.energy = cell.energy + ftable.energy - if ftable.unitName ~= nil then - local rut = unitTable[ftable.unitName] - if rut.isWeapon or rut.extractsMetal > 0 then - table.insert(cell.resurrectables, w) + end + end +end + +local function UpdateFronts(number) + local highestCells = {} + local highestResponses = {} + for n = 1, number do + local highestCell = {} + local highestResponse = { ground = 0, air = 0, submerged = 0 } + for i = 1, #cellList do + local cell = cellList[i] + for groundAirSubmerged, response in pairs(cell.response) do + local okay = true + if n > 1 then + local highCell = highestCells[n-1][groundAirSubmerged] + if highCell ~= nil then + if cell == highCell then + okay = false + elseif response >= highestResponses[n-1][groundAirSubmerged] then + okay = false + else + local dist = DistanceXZ(highCell.x, highCell.z, cell.x, cell.z) + if dist < 2 then okay = false end + end end end - else - for findString, metalValue in pairs(baseFeatureMetal) do - if string.find(wname, findString) then - cell.metal = cell.metal + metalValue - break - end + if okay and response > highestResponse[groundAirSubmerged] then + highestResponse[groundAirSubmerged] = response + highestCell[groundAirSubmerged] = cell end end end + highestResponses[n] = highestResponse + highestCells[n] = highestCell end + ai.defendhandler:FindFronts(highestCells) end local function UpdateDebug() @@ -739,17 +618,17 @@ end end +--[[ function TargetHandler:UnitDamaged(unit, attacker) -- even if the attacker can't be seen, human players know what weapons look like -- but attacker is nil if it's an enemy unit, so this is useless - --[[ if attacker ~= nil then local attackerName = attacker:Name() local attackerID = attacker:ID() DangerCheck(attackerName, attackerID) end - ]]-- end +]]-- function TargetHandler:Init() ai.enemyMexSpots = {} @@ -766,6 +645,8 @@ InitializeDangers() self.lastEnemyThreatUpdateFrame = 0 self.feints = {} + self.raiderCounted = {} + self.lastUpdateFrame = 0 end function TargetHandler:Update() @@ -785,9 +666,11 @@ end end -function TargetHandler:AddBadPosition(position, mtype) +function TargetHandler:AddBadPosition(position, mtype, threat, duration) + if threat == nil then threat = badCellThreat end + if duration == nil then duration = 1800 end local px, pz = GetCellPosition(position) - local gas = WhatHurtsUnit(nil, mtype) + local gas = WhatHurtsUnit(nil, mtype, position) local f = game:Frame() for groundAirSubmerged, yes in pairs(gas) do if yes then @@ -795,8 +678,10 @@ { px = px, pz = pz, - groundAirsSubmerged = groundAirSubmerged, + groundAirSubmerged = groundAirSubmerged, frame = f, + threat = threat, + duration = duration, } table.insert(badPositions, newRecord) end @@ -804,8 +689,8 @@ end function TargetHandler:UpdateMap() - local f = game:Frame() - if f > lastUpdateFrame + 30 then + if ai.lastLOSUpdate > self.lastUpdateFrame then + self.raiderCounted = {} cells = {} cellList = {} UpdateEnemies() @@ -813,37 +698,35 @@ -- UpdateFriendlies() UpdateBadPositions() UpdateWrecks() + UpdateFronts(3) UpdateDebug() - lastUpdateFrame = f + self.lastUpdateFrame = game:Frame() end end -local function CellVulnerable(cell, gas) +local function CellVulnerable(cell, hurtByGAS, weaponsGAS) if cell == nil then return end - -- check this cell - local vulnerable = nil - if not gas["ground"] and cell.groundVulnerable and cell.groundThreat == 0 then - vulnerable = cell.groundVulnerable - end - if vulnerable == nil and not gas["air"] and cell.airVulnerable and cell.airThreat == 0 then - vulnerable = cell.airVulnerable - end - if vulnerable == nil and not gas["submerged"] and cell.submergedVulnerable and cell.submergedThreat == 0 then - vulnerable = cell.submergedVulnerable + for GAS, yes in pairs(hurtByGAS) do + for i, wGAS in pairs(weaponsGAS) do + local vulnerable = cell.vulnerables[GAS][wGAS] + if vulnerable ~= nil then return vulnerable end + end end - return vulnerable end function TargetHandler:NearbyVulnerable(unit) if unit == nil then return end self:UpdateMap() - local px, pz = GetCellPosition(unit:GetPosition()) - local gas = WhatHurtsUnit(unit:Name()) + local position = unit:GetPosition() + local px, pz = GetCellPosition(position) + local unitName = unit:Name() + local gas = WhatHurtsUnit(unitName, nil, position) + local weapons = UnitWeaponLayerList(unitName) -- check this cell local vulnerable = nil if cells[px] ~= nil then if cells[px][pz] ~= nil then - vulnerable = CellVulnerable(cells[px][pz], gas) + vulnerable = CellVulnerable(cells[px][pz], gas, weapons) end end -- check adjacent cells @@ -852,7 +735,7 @@ for iz = pz - 1, pz + 1 do if cells[ix] ~= nil then if cells[ix][iz] ~= nil then - vulnerable = CellVulnerable(cells[ix][iz], gas) + vulnerable = CellVulnerable(cells[ix][iz], gas, weapons) if vulnerable then break end end end @@ -867,6 +750,13 @@ if not representative then return end self:UpdateMap() local rpos = representative:GetPosition() + local inCell = GetCellHere(rpos) + local threatReduction = 0 + if inCell ~= nil then + -- if we're near more raiders, these raiders can target more threatening targets together + if inCell.raiderHere then threatReduction = threatReduction + inCell.raiderHere end + if inCell.raiderAdjacent then threatReduction = threatReduction + inCell.raiderAdjacent end + end local rname = representative:Name() local maxThreat = baseUnitThreat local rthreat, rrange = ThreatRange(rname) @@ -876,6 +766,10 @@ local bestDist = 99999 for i, cell in pairs(cellList) do local value, threat, gas = CellValueThreat(rname, cell) + -- cells with other raiders in or nearby are better places to go for raiders + if cell.raiderHere then threat = threat - cell.raiderHere end + if cell.raiderAdjacent then threat = threat - cell.raiderAdjacent end + threat = threat - threatReduction -- EchoDebug(value .. " " .. threat) if value > 0 and threat <= maxThreat then if ai.maphandler:UnitCanGoHere(representative, cell.pos) then @@ -901,30 +795,44 @@ local bestThreatCell local bestThreat = 0 local name = representative:Name() + local rpos = representative:GetPosition() local longrange = unitTable[name].groundRange > 1000 local mtype = unitTable[name].mtype if mtype ~= "sub" and longrange then longrange = true end + local possibilities = {} + local highestDist = 0 + local lowestDist = 100000 for i, cell in pairs(cellList) do if cell.pos then if ai.maphandler:UnitCanGoHere(representative, cell.pos) or longrange then local value, threat = CellValueThreat(name, cell) - if value > 750 then - value = 0 - threat - if value > bestValue then - bestValueCell = cell - bestValue = value - end - elseif value > 0 then - value = 0 - threat - if value > bestAnyValue then - bestAnyValueCell = cell - bestAnyValue = value - end - elseif threat > bestThreat then - bestThreatCell = cell - bestThreat = threat - end + local dist = Distance(rpos, cell.pos) + if dist > highestDist then highestDist = dist end + if dist < lowestDist then lowestDist = dist end + table.insert(possibilities, { cell = cell, value = value, threat = threat, dist = dist }) + end + end + end + local distRange = highestDist - lowestDist + for i, pb in pairs(possibilities) do + local fraction = 1.5 - ((pb.dist - lowestDist) / distRange) + local value = pb.value * fraction + local threat = pb.threat + if pb.value > 750 then + value = 0 - threat + if value > bestValue then + bestValueCell = pb.cell + bestValue = value end + elseif pb.value > 0 then + value = 0 - threat + if value > bestAnyValue then + bestAnyValueCell = pb.cell + bestAnyValue = value + end + elseif threat > bestThreat then + bestThreatCell = pb.cell + bestThreat = threat end end local best @@ -972,9 +880,8 @@ if enemyBaseCell and not ignoreValue then local dist = Distance(position, enemyBaseCell.pos) if dist < range then - local value, threat = CellValueThreat("ALL", cell) - local valuethreat = value + threat - return enemyBaseCell, valuethreat + local value = cell.values.ground.ground + cell.values.air.ground + cell.values.submerged.ground + return enemyBaseCell, value + cell.response.ground end end local best @@ -983,10 +890,10 @@ for i, cell in pairs(cellList) do local dist = Distance(position, cell.pos) if dist < range then - local value, threat = CellValueThreat("ALL", cell) + local value = cell.values.ground.ground + cell.values.air.ground + cell.values.submerged.ground local valuethreat = 0 if not ignoreValue then valuethreat = valuethreat + value end - if not ignoreThreat then valuethreat = valuethreat + threat end + if not ignoreThreat then valuethreat = valuethreat + cell.response.ground end if valuethreat > bestValueThreat then best = cell bestValueThreat = valuethreat @@ -1001,14 +908,14 @@ local best local bestValue = 0 for i, cell in pairs(cellList) do - local value = 0 + local value = cell.explosionValue if torpedo then - value = cell.torpedoBomberValue + value = value + cell.values.air.submerged else - value = cell.bomberValue + value = value + cell.values.air.ground end if value > 0 then - value = value - cell.airThreat + value = value - cell.threat.air if value > bestValue then best = cell bestValue = value @@ -1018,26 +925,15 @@ if best then local bestTarget bestValue = 0 - local targets - if torpedo then - targets = best.torpedoBomberTargets - else - targets = best.bomberTargets - end - for i, e in pairs(targets) do - local name = e:Name() - local value = Value(name) - if name then - if unitTable[name] then - if unitTable[name].bigExplosion then value = value + bomberExplosionValue end - end - end - if value > bestValue then - bestTarget = e - bestValue = value + local target = best.explosiveTarget + if target == nil then + if torpedo then + target = best.targets.air.submerged + else + target = best.targets.air.ground end end - return bestTarget + return target end end @@ -1058,7 +954,7 @@ else mod = cell.metal end - local vulnerable = CellVulnerable(cell, gas) + local vulnerable = CellVulnerable(cell, gas, UnitWeaponLayerList(rname)) if vulnerable then mod = mod + vulnerableReclaimDistMod end if mod > 0 then local dist = Distance(rpos, cell.pos) - mod @@ -1100,12 +996,18 @@ local bestMetalCost = 0 for i, w in pairs(best.resurrectables) do if w ~= nil then - local wname = w:Name() + local wname = w.featureName if wname ~= nil then - local metalCost = unitTable[featureTable[wname].unitName].metalCost - if metalCost > bestMetalCost then - bestWreck = w - bestMetalCost = metalCost + local ft = featureTable[wname] + if ft ~= nil then + local ut = unitTable[ft.unitName] + if ut ~= nil then + local metalCost = ut.metalCost + if metalCost > bestMetalCost then + bestWreck = w + bestMetalCost = metalCost + end + end end end end @@ -1117,17 +1019,18 @@ end function TargetHandler:NearestVulnerableCell(representative) - if not representative then return end + if representative == nil then return end self:UpdateMap() local rpos = representative:GetPosition() local rname = representative:Name() local best local bestDist = 99999 + local weapons = UnitWeaponLayerList(rname) for i, cell in pairs(cellList) do local value, threat, gas = CellValueThreat(rname, cell) if threat == 0 and cell.pos then if ai.maphandler:UnitCanGoHere(representative, cell.pos) then - if cell.groundVulnerable or cell.airVulnerable or cell.submergedVulnerable then + if CellVulnerable(cell, gas, weapons) ~= nil then local dist = Distance(rpos, cell.pos) if dist < bestDist then best = cell @@ -1144,8 +1047,8 @@ self:UpdateMap() local px, pz = GetCellPosition(position) local radius = unitTable[unitName].groundRange - local groundValue, groundThreat = CheckInRadius(px, pz, radius, "ground") - if groundValue + groundThreat > Value(unitName) * 2 then + local groundValue, groundThreat = CheckInRadius(px, pz, radius, "threat", "ground") + if groundValue + groundThreat > Value(unitName) * 1.5 then return true else return false @@ -1158,11 +1061,12 @@ local uname = unit:Name() if uname == nil then game:SendToConsole("nil unit name") end local cell = GetCellHere(position) + if cell == nil then return 0, 0 end local value, threat = CellValueThreat(uname, cell) if threshold then - return threat < unitTable[uname].metalCost * threshold + return threat < unitTable[uname].metalCost * threshold, cell.response else - return threat == 0 + return threat == 0, cell.response end end @@ -1195,6 +1099,11 @@ if cells[x] ~= nil then if cells[x][z] ~= nil then local value, threat = CellValueThreat(uname, cells[x][z]) + if raiderList[uname] then + -- cells with other raiders in or nearby are better places to go for raiders + if cells[x][z].raiderHere then threat = threat - cells[x][z].raiderHere end + if cells[x][z].raiderAdjacent then threat = threat - cells[x][z].raiderAdjacent end + end if threat > maxThreat then -- if it's below baseUnitThreat, it's probably a lone construction unit dist = dist + threat @@ -1231,7 +1140,45 @@ end end if best and notsafe then + local mtype = unitTable[uname].mtype + self:AddBadPosition(targetPosition, mtype, 16, 1200) -- every thing to avoid on the way to the target increases its threat a tiny bit table.insert(self.feints, {x = best.x, z = best.z, px = px, pz = pz, tx = tx, tz = tz, frame = f}) return best.pos end +end + +function TargetHandler:RaiderHere(raidbehaviour) + if raidbehaviour == nil then return end + if raidbehaviour.unit == nil then return end + if self.raiderCounted[raidbehaviour.id] then return end + local unit = raidbehaviour.unit:Internal() + if unit == nil then return end + local uthreat, urange = ThreatRange(unit:Name()) + local position = unit:GetPosition() + local px, pz = GetCellPosition(position) + local inCell + if cells[px] then + inCell = cells[px][pz] + end + if inCell ~= nil then + if inCell.raiderHere == nil then inCell.raiderHere = 0 end + inCell.raiderHere = inCell.raiderHere + (uthreat * 0.67) + end + local adjacentThreatReduction = uthreat * 0.33 + for x = px - 1, px + 1 do + if cells[x] ~= nil then + for z = pz - 1, pz + 1 do + if x == px and z == pz then + -- ignore center cell + else + local cell = cells[x][z] + if cell ~= nil then + if cell.raiderAdjacent == nil then cell.raiderAdjacent = 0 end + cell.raiderAdjacent = cell.raiderAdjacent + adjacentThreatReduction + end + end + end + end + end + self.raiderCounted[raidbehaviour.id] = true -- reset with UpdateMap() end \ No newline at end of file diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/taskqueuebehaviour.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/taskqueuebehaviour.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/taskqueuebehaviour.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/taskqueuebehaviour.lua 2014-10-07 20:10:05.000000000 +0000 @@ -11,26 +11,24 @@ local CMD_GUARD = 25 -local Energy, Metal, extraEnergy, extraMetal, energyTooLow, energyOkay, metalTooLow, metalOkay, metalBelowHalf, metalAboveHalf, notEnoughCombats, farTooFewCombats +local extraEnergy, extraMetal, energyTooLow, energyOkay, metalTooLow, metalOkay, metalBelowHalf, metalAboveHalf, notEnoughCombats, farTooFewCombats local function GetEcon() - Energy = game:GetResourceByName("Energy") - Metal = game:GetResourceByName("Metal") - extraEnergy = Energy.income - Energy.usage - extraMetal = Metal.income - Metal.usage - local enoughMetalReserves = math.min(Metal.income, Metal.capacity * 0.1) - local lotsMetalReserves = math.min(Metal.income * 10, Metal.capacity * 0.5) - local enoughEnergyReserves = math.min(Energy.income * 2, Energy.capacity * 0.25) - -- local lotsEnergyReserves = math.min(Energy.income * 3, Energy.capacity * 0.5) - energyTooLow = Energy.reserves < enoughEnergyReserves or Energy.income < 40 - energyOkay = Energy.reserves >= enoughEnergyReserves and Energy.income >= 40 - metalTooLow = Metal.reserves < enoughMetalReserves - metalOkay = Metal.reserves >= enoughMetalReserves - metalBelowHalf = Metal.reserves < lotsMetalReserves - metalAboveHalf = Metal.reserves >= lotsMetalReserves + extraEnergy = ai.Energy.income - ai.Energy.usage + extraMetal = ai.Metal.income - ai.Metal.usage + local enoughMetalReserves = math.min(ai.Metal.income, ai.Metal.capacity * 0.1) + local lotsMetalReserves = math.min(ai.Metal.income * 10, ai.Metal.capacity * 0.5) + local enoughEnergyReserves = math.min(ai.Energy.income * 2, ai.Energy.capacity * 0.25) + -- local lotsEnergyReserves = math.min(ai.Energy.income * 3, ai.Energy.capacity * 0.5) + energyTooLow = ai.Energy.reserves < enoughEnergyReserves or ai.Energy.income < 40 + energyOkay = ai.Energy.reserves >= enoughEnergyReserves and ai.Energy.income >= 40 + metalTooLow = ai.Metal.reserves < enoughMetalReserves + metalOkay = ai.Metal.reserves >= enoughMetalReserves + metalBelowHalf = ai.Metal.reserves < lotsMetalReserves + metalAboveHalf = ai.Metal.reserves >= lotsMetalReserves local attackCounter = ai.attackhandler:GetCounter() - notEnoughCombats = ai.combatCount < attackCounter * 0.75 - farTooFewCombats = ai.combatCount < attackCounter * 0.25 + notEnoughCombats = ai.combatCount < attackCounter * 0.6 + farTooFewCombats = ai.combatCount < attackCounter * 0.2 end TaskQueueBehaviour = class(Behaviour) @@ -39,8 +37,8 @@ if value == nil then return DummyUnitName end if value == DummyUnitName then return DummyUnitName end EchoDebug(value .. " (before econ filter)") - -- EchoDebug("Energy: " .. Energy.reserves .. " " .. Energy.capacity .. " " .. Energy.income .. " " .. Energy.usage) - -- EchoDebug("Metal: " .. Metal.reserves .. " " .. Metal.capacity .. " " .. Metal.income .. " " .. Metal.usage) + -- EchoDebug("ai.Energy: " .. ai.Energy.reserves .. " " .. ai.Energy.capacity .. " " .. ai.Energy.income .. " " .. ai.Energy.usage) + -- EchoDebug("ai.Metal: " .. ai.Metal.reserves .. " " .. ai.Metal.capacity .. " " .. ai.Metal.income .. " " .. ai.Metal.usage) if nanoTurretList[value] then -- nano turret EchoDebug(" nano turret") @@ -59,7 +57,7 @@ if unitTable[value].extractsMetal > 0 then -- metal extractor EchoDebug(" mex") - if energyTooLow and Metal.income > 3 then + if energyTooLow and ai.Metal.income > 3 then value = DummyUnitName end elseif value == "corwin" or value == "armwin" or value == "cortide" or value == "armtide" or (unitTable[value].totalEnergyOut > 0 and not unitTable[value].buildOptions) then @@ -69,13 +67,13 @@ -- big energy plant EchoDebug(" big energy plant") -- don't build big energy plants until we have the resources to do so - if energyOkay or metalTooLow or Energy.income < 400 or Metal.income < 35 then + if energyOkay or metalTooLow or ai.Energy.income < 400 or ai.Metal.income < 35 then value = DummyUnitName end - if self.name == "coracv" and value == "corfus" and Energy.income > 4000 then + if self.name == "coracv" and value == "corfus" and ai.Energy.income > 4000 then -- build advanced fusion value = "cafus" - elseif self.name == "armacv" and value == "armfus" and Energy.income > 4000 then + elseif self.name == "armacv" and value == "armfus" and ai.Energy.income > 4000 then -- build advanced fusion value = "aafus" end @@ -94,7 +92,7 @@ -- factory EchoDebug(" factory") EchoDebug(ai.factories) - if ai.factories - ai.outmodedFactories <= 0 and metalOkay and energyOkay and Metal.income > 3 and Metal.reserves > unitTable[value].metalCost * 0.7 then + if ai.factories - ai.outmodedFactories <= 0 and metalOkay and energyOkay and ai.Metal.income > 3 and ai.Metal.reserves > unitTable[value].metalCost * 0.7 then EchoDebug(" first factory") -- build the first factory elseif advFactories[value] and metalOkay and energyOkay then @@ -104,12 +102,12 @@ else if ai.couldAttack >= 1 or ai.couldBomb >= 1 then -- other factory after attack - if metalTooLow or Metal.income < (ai.factories - ai.outmodedFactories) * 8 or energyTooLow or (ai.needAdvanced and not ai.haveAdvFactory) then + if metalTooLow or ai.Metal.income < (ai.factories - ai.outmodedFactories) * 8 or energyTooLow or (ai.needAdvanced and not ai.haveAdvFactory) then value = DummyUnitName end else -- other factory before attack more stringent - if metalBelowHalf or Metal.income < (ai.factories - ai.outmodedFactories) * 12 or energyTooLow or (ai.needAdvanced and not ai.haveAdvFactory) then + if metalBelowHalf or ai.Metal.income < (ai.factories - ai.outmodedFactories) * 12 or energyTooLow or (ai.needAdvanced and not ai.haveAdvFactory) then value = DummyUnitName end end @@ -119,16 +117,16 @@ EchoDebug(" defense") if bigPlasmaList[value] or nukeList[value] then -- long-range plasma and nukes aren't really defense - if metalTooLow or energyTooLow or Metal.income < 35 or ai.factories == 0 or notEnoughCombats then + if metalTooLow or energyTooLow or ai.Metal.income < 35 or ai.factories == 0 or notEnoughCombats then value = DummyUnitName end elseif littlePlasmaList[value] then -- plasma turrets need units to back them up - if metalTooLow or energyTooLow or Metal.income < 10 or ai.factories == 0 or notEnoughCombats then + if metalTooLow or energyTooLow or ai.Metal.income < 10 or ai.factories == 0 or notEnoughCombats then value = DummyUnitName end else - if metalTooLow or Metal.income < (unitTable[value].metalCost / 35) + 2 or energyTooLow or ai.factories == 0 then + if metalTooLow or ai.Metal.income < (unitTable[value].metalCost / 35) + 2 or energyTooLow or ai.factories == 0 then value = DummyUnitName end end @@ -141,7 +139,7 @@ else -- other building EchoDebug(" other building") - if notEnoughCombats or metalTooLow or energyTooLow or Energy.income < 200 or Metal.income < 8 or ai.factories == 0 then + if notEnoughCombats or metalTooLow or energyTooLow or ai.Energy.income < 200 or ai.Metal.income < 8 or ai.factories == 0 then value = DummyUnitName end end @@ -160,7 +158,7 @@ end elseif ai.nameCount[value] == 1 then -- build another fairly easily - if metalTooLow or energyTooLow or Metal.income < 18 or (farTooFewCombats and not self.outmodedFactory) then + if metalTooLow or energyTooLow or ai.Metal.income < 18 or (farTooFewCombats and not self.outmodedFactory) then value = DummyUnitName end else @@ -172,12 +170,12 @@ -- build at least one of each type elseif assistList[value] then -- build enough assistants - if metalBelowHalf or energyTooLow or ai.assistCount > Metal.income * 0.125 then + if metalBelowHalf or energyTooLow or ai.assistCount > ai.Metal.income * 0.125 then value = DummyUnitName end elseif value == "corcv" and ai.nameCount["coracv"] ~= 0 and ai.nameCount["coracv"] ~= nil and (ai.nameCount["coralab"] == 0 or ai.nameCount["coralab"] == nil) then -- core doesn't have consuls, so treat lvl1 con vehicles like assistants, if there are no other alternatives - if metalBelowHalf or energyTooLow or ai.conCount > Metal.income * 0.15 then + if metalBelowHalf or energyTooLow or ai.conCount > ai.Metal.income * 0.15 then value = DummyUnitName end else @@ -228,17 +226,20 @@ self.isFactory = true local upos = u:GetPosition() self.position = upos + local outmoded = true for i, mtype in pairs(factoryMobilities[self.name]) do - if mtype ~= nil then - if ai.maphandler:OutmodedFactoryHere(mtype, upos) then - self.outmodedFactory = true - ai.outmodedFactoryID[self.id] = true - ai.outmodedFactories = ai.outmodedFactories + 1 - ai.outmodedFactories = 1 - break - end - if mtype == "air" then self.isAirFactory = true end - end + if not ai.maphandler:OutmodedFactoryHere(mtype, upos) then + -- just one non-outmoded mtype will cause the factory to act normally + outmoded = false + end + if mtype == "air" then self.isAirFactory = true end + end + if outmoded then + EchoDebug("outmoded " .. self.name) + self.outmodedFactory = true + ai.outmodedFactoryID[self.id] = true + ai.outmodedFactories = ai.outmodedFactories + 1 + ai.outmodedFactories = 1 end end @@ -273,9 +274,6 @@ if self.unit == nil then return end if unit.engineID == self.unit.engineID then if self:IsActive() then self.progress = true end - if not self.isFactory then - ai.defendhandler:AddDefendee(self) - end end end @@ -415,60 +413,57 @@ EchoDebug("no factory found") utype = nil end - elseif unitTable[value].isBuilding and unitTable[value].buildOptions then - -- build factories at a turtle (this shouldn't come up, because BestFactory finds a location) - EchoDebug("looking for most turtled position for factory") - local turtlePos = ai.turtlehandler:MostTurtled(builder) - if turtlePos then - p = ai.buildsitehandler:ClosestBuildSpot(builder, turtlePos, utype) - end - if p == nil then - EchoDebug("no turtle position found, trying next to factory") - local factoryPos = ai.buildsitehandler:ClosestHighestLevelFactory(builder, 5000) - if factoryPos then - p = ai.buildsitehandler:ClosestBuildSpot(builder, factoryPos, utype) + elseif nukeList[value] or bigPlasmaList[value] or littlePlasmaList[value] then + -- bombarders + EchoDebug("seeking bombard build spot") + local turtlePosList = ai.turtlehandler:MostTurtled(builder, value, value) + if turtlePosList then + EchoDebug("got sorted turtle list") + if #turtlePosList ~= 0 then + EchoDebug("turtle list has turtles") + for i, turtlePos in ipairs(turtlePosList) do + p = ai.buildsitehandler:ClosestBuildSpot(builder, turtlePos, utype) + if p ~= nil then break end + end end end if p == nil then - EchoDebug("no turtle position found, trying next to builder") - local builderPos = builder:GetPosition() - p = ai.buildsitehandler:ClosestBuildSpot(builder, builderPos, utype) + utype = nil + EchoDebug("could not find bombard build spot") + else + EchoDebug("found bombard build spot") end elseif shieldList[value] or antinukeList[value] or unitTable[value].jammerRadius ~= 0 or unitTable[value].radarRadius ~= 0 or unitTable[value].sonarRadius ~= 0 or (unitTable[value].isWeapon and unitTable[value].isBuilding and not nukeList[value] and not bigPlasmaList[value] and not littlePlasmaList[value]) then -- shields, defense, antinukes, jammer towers, radar, and sonar - EchoDebug("looking for least turtled position") - local turtlePos = ai.turtlehandler:LeastTurtled(builder, value) - if turtlePos then - EchoDebug("found turtle position") - p = ai.buildsitehandler:ClosestBuildSpot(builder, turtlePos, utype) - if p == nil then - EchoDebug("did NOT find build spot near turtle position") - utype = nil + EchoDebug("looking for least turtled positions") + local turtlePosList = ai.turtlehandler:LeastTurtled(builder, value) + if turtlePosList then + if #turtlePosList ~= 0 then + EchoDebug("found turtle positions") + for i, turtlePos in ipairs(turtlePosList) do + p = ai.buildsitehandler:ClosestBuildSpot(builder, turtlePos, utype) + if p ~= nil then break end + end end - else + end + if p == nil then + EchoDebug("did NOT find build spot near turtle position") utype = nil end elseif unitTable[value].isBuilding then -- buildings in defended positions - local bombard = false - if nukeList[value] or bigPlasmaList[value] or littlePlasmaList[value] then - bombard = value - end - local turtlePos = ai.turtlehandler:MostTurtled(builder, bombard) - if turtlePos then - p = ai.buildsitehandler:ClosestBuildSpot(builder, turtlePos, utype) - else - local builderPos = builder:GetPosition() - p = ai.buildsitehandler:ClosestBuildSpot(builder, builderPos, utype) - end - if p == nil and bombard then - utype = nil + local turtlePosList = ai.turtlehandler:MostTurtled(builder, value) + if turtlePosList then + if #turtlePosList ~= 0 then + for i, turtlePos in ipairs(turtlePosList) do + p = ai.buildsitehandler:ClosestBuildSpot(builder, turtlePos, utype) + if p ~= nil then break end + end + end end - else - local builderPos = builder:GetPosition() - p = ai.buildsitehandler:ClosestBuildSpot(builder, builderPos, utype) end - if utype ~=nil and p == nil then + -- last ditch placement + if utype ~= nil and p == nil then local builderPos = builder:GetPosition() p = ai.buildsitehandler:ClosestBuildSpot(builder, builderPos, utype) if p == nil then @@ -487,10 +482,7 @@ for i, factoryName in pairs(factoryNames) do local buildMe = true local isAdvanced = advFactories[factoryName] - local isExperimental = expFactories[factoryName] or leadsToExpFactories[factoryName] - - -- if isExperimental or ai.needExperimental then DebugEnabled = true end - + local isExperimental = expFactories[factoryName] or leadsToExpFactories[factoryName] if ai.needAdvanced and not ai.haveAdvFactory then if not isAdvanced then buildMe = false end end @@ -503,14 +495,27 @@ if not ai.needExperimental then if expFactories[factoryName] then buildMe = false end end - if buildMe and ai.nameCount[factoryName] == 0 then + --[[ + -- this probably isn't a good idea, there are better ways to use up excess metal + if ai.Metal.income > 10 and ai.Metal.extra > 5 and ai.Metal.full > 0.9 then + -- don't include built factories if we've got tons of metal + -- if we include factories we already have, this algo will tend to spit out subpar factories + if ai.nameCount[factoryName] > 0 then buildMe = false end + end + ]]-- + if buildMe then local utype = game:GetTypeByName(factoryName) local builderPos = builder:GetPosition() local p EchoDebug("looking for most turtled position for " .. factoryName) - local turtlePos = ai.turtlehandler:MostTurtled(builder) - if turtlePos then - p = ai.buildsitehandler:ClosestBuildSpot(builder, turtlePos, utype) + local turtlePosList = ai.turtlehandler:MostTurtled(builder, factoryName) + if turtlePosList then + if #turtlePosList ~= 0 then + for i, turtlePos in ipairs(turtlePosList) do + p = ai.buildsitehandler:ClosestBuildSpot(builder, turtlePos, utype) + if p ~= nil then break end + end + end end if p == nil then EchoDebug("no turtle position found, trying next to factory") @@ -549,10 +554,20 @@ EchoDebug(factoryName .. " " .. mtype .. " has enough spots (" .. numberOfSpots .. ") and a score of " .. score .. " (" .. spotPercentage .. " " .. dist .. ")") if score > bestScore then local okay = true - if mtype == "veh" then - if ai.maphandler:OutmodedFactoryHere("veh", builderPos) and not ai.maphandler:OutmodedFactoryHere("bot", builderPos) then - -- don't build a not very useful vehicle plant if a bot factory can be built instead - okay = false + if okay then + if mtype == "veh" then + if ai.maphandler:OutmodedFactoryHere("veh", builderPos) and not ai.maphandler:OutmodedFactoryHere("bot", builderPos) then + -- don't build a not very useful vehicle plant if a bot factory can be built instead + okay = false + end + end + end + if okay then + if mtype == "bot" and not ai.needExperimental then + -- don't built a bot lab senselessly to slow us down + if not ai.maphandler:OutmodedFactoryHere("veh", builderPos) and (ai.nameCount["armvp"] >= 1 or ai.nameCount["corvp"] >= 1) then + okay = false + end end end if okay then @@ -570,7 +585,10 @@ -- DebugEnabled = false end end - if bestName ~= nil then EchoDebug("best factory: " .. bestName) end + if bestName ~= nil then + if ai.nameCount[bestName] > 0 then return nil, nil end + EchoDebug("best factory: " .. bestName) + end return bestPos, bestName end @@ -586,8 +604,8 @@ end self.outmodedTechLevel = false if outmodedTaskqueues[self.name] ~= nil and not got then - if self.isFactory and unitTable[self.name].techLevel < ai.maxFactoryLevel and Metal.reserves < Metal.capacity * 0.8 then - -- stop buidling lvl1 attackers if we have a lvl2, unless we've got lots of metal, in which case use it up + if self.isFactory and unitTable[self.name].techLevel < ai.maxFactoryLevel and ai.Metal.reserves < ai.Metal.capacity * 0.95 then + -- stop buidling lvl1 attackers if we have a lvl2, unless we're about to waste metal, in which case use it up q = outmodedTaskqueues[self.name] got = true self.outmodedTechLevel = true @@ -678,6 +696,7 @@ if type(value) == "table" then -- not using this else + -- if bigPlasmaList[value] or littlePlasmaList[value] then DebugEnabled = true end -- debugging plasma local p if value == FactoryUnitName then -- build the best factory this builder can build @@ -715,7 +734,8 @@ if utype ~= nil and p ~= nil then if type(value) == "table" and value[1] == "ReclaimEnemyMex" then EchoDebug("reclaiming enemy mex...") - success = self.unit:Internal():Reclaim(value[2]) + -- success = self.unit:Internal():Reclaim(value[2]) + success = CustomCommand(self.unit:Internal(), CMD_RECLAIM, {value[2].unitID}) value = value[1] else local helpValue = self:GetHelp(value, p) @@ -733,6 +753,7 @@ game:SendToConsole(self.name .. " cannot build:"..value..", couldnt grab the unit type from the engine") end end + -- DebugEnabled = false -- debugging plasma if success then if self.isFactory then if not self.outmodedTechLevel then diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/taskqueues.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/taskqueues.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/taskqueues.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/taskqueues.lua 2014-10-07 20:10:05.000000000 +0000 @@ -123,33 +123,27 @@ end lastSiegeCheckFrame = f - local Metal = game:GetResourceByName("Metal") - if Metal.reserves < 0.5 * Metal.capacity and ai.wreckCount > 0 then - ai.needToReclaim = true - else - ai.needToReclaim = false - end + ai.needToReclaim = ai.Metal.full < 0.5 and ai.wreckCount > 0 AAUnitPerTypeLimit = math.ceil(ai.turtlehandler:GetTotalPriority() / 4) - heavyPlasmaLimit = math.ceil(ai.combatCount / 7) - nukeLimit = math.ceil(ai.combatCount / 20) - tacticalNukeLimit = math.ceil(ai.combatCount / 12) + heavyPlasmaLimit = math.ceil(ai.combatCount / 10) + nukeLimit = math.ceil(ai.combatCount / 50) + tacticalNukeLimit = math.ceil(ai.combatCount / 40) local attackCounter = ai.attackhandler:GetCounter() local couldAttack = ai.couldAttack >= 1 or ai.couldBomb >= 1 local bombingTooExpensive = ai.bomberhandler:GetCounter() == maxBomberCounter local attackTooExpensive = attackCounter == maxAttackCounter - local plentyOfCombatUnits = ai.combatCount > attackCounter * 0.9 local controlMetalSpots = ai.mexCount > #ai.mobNetworkMetals["air"][1] * 0.4 - local needUpgrade = plentyOfCombatUnits or couldAttack or bombingTooExpensive or attackTooExpensive - local lotsOfMetal = Metal.income > 20 or controlMetalSpots + local needUpgrade = couldAttack or bombingTooExpensive or attackTooExpensive + local lotsOfMetal = ai.Metal.income > 25 or controlMetalSpots EchoDebug(ai.totalEnemyThreat .. " " .. ai.totalEnemyImmobileThreat .. " " .. ai.totalEnemyMobileThreat) -- build siege units if the enemy is turtling, if a lot of our attackers are getting destroyed, or if we control over 40% of the metal spots needSiege = (ai.totalEnemyImmobileThreat > ai.totalEnemyMobileThreat * 3.5 and ai.totalEnemyImmobileThreat > 50000) or attackCounter >= siegeAttackCounter or controlMetalSpots - ai.needAdvanced = (Metal.income > 10 or controlMetalSpots) and ai.factories > 0 and (needUpgrade or lotsOfMetal) + ai.needAdvanced = (ai.Metal.income > 10 or controlMetalSpots) and ai.factories > 0 and (needUpgrade or lotsOfMetal) ai.needExperimental = false ai.needNukes = false - if Metal.income > 50 and ai.haveAdvFactory and needUpgrade and ai.enemyBasePosition then + if ai.Metal.income > 50 and ai.haveAdvFactory and needUpgrade and ai.enemyBasePosition then if not ai.haveExpFactory then for i, factory in pairs(ai.factoriesAtLevel[ai.maxFactoryLevel]) do if ai.maphandler:MobilityNetworkHere("bot", factory.position) == ai.maphandler:MobilityNetworkHere("bot", ai.enemyBasePosition) then @@ -161,10 +155,10 @@ ai.needNukes = true end EchoDebug("need experimental? " .. tostring(ai.needExperimental) .. ", need nukes? " .. tostring(ai.needNukes) .. ", have advanced? " .. tostring(ai.haveAdvFactory) .. ", need upgrade? " .. tostring(needUpgrade) .. ", have enemy base position? " .. tostring(ai.enemyBasePosition)) - EchoDebug("metal income: " .. Metal.income .. " combat units: " .. ai.combatCount) + EchoDebug("metal income: " .. ai.Metal.income .. " combat units: " .. ai.combatCount) EchoDebug("have advanced? " .. tostring(ai.haveAdvFactory) .. " have experimental? " .. tostring(ai.haveExpFactory)) EchoDebug("need advanced? " .. tostring(ai.needAdvanced) .. " need experimental? " .. tostring(ai.needExperimental)) - EchoDebug("need advanced? " .. tostring(ai.needAdvanced) .. ", need upgrade? " .. tostring(needUpgrade) .. ", have attacked enough? " .. tostring(couldAttack) .. " (" .. ai.couldAttack .. "), have " .. ai.factories .. " factories, " .. math.floor(Metal.income) .. " metal income") + EchoDebug("need advanced? " .. tostring(ai.needAdvanced) .. ", need upgrade? " .. tostring(needUpgrade) .. ", have attacked enough? " .. tostring(couldAttack) .. " (" .. ai.couldAttack .. "), have " .. ai.factories .. " factories, " .. math.floor(ai.Metal.income) .. " metal income") end end @@ -248,8 +242,7 @@ function BuildWindSolarIfNeeded() -- check if we need power - local res = game:GetResourceByName("Energy") - if res.income < res.usage then + if ai.Energy.extra < 0 then retVal = WindSolar EchoDebug("BuildWindSolarIfNeeded: income "..res.income..", usage "..res.usage..", building more energy") else @@ -274,61 +267,62 @@ -- build conversion or storage function DoSomethingForTheEconomy(self) - local Energy = game:GetResourceByName("Energy") - local extraE = Energy.income - Energy.usage - local Metal = game:GetResourceByName("Metal") - local extraM = Metal.income - Metal.usage + local highEnergy = ai.Energy.full > 0.9 + local lowEnergy = ai.Energy.full < 0.1 + local highMetal = ai.Metal.full > 0.9 + local lowMetal = ai.Metal.full < 0.1 local isWater = unitTable[self.unit:Internal():Name()].needsWater local unitName = DummyUnitName -- maybe we need conversion? - if extraE > 60 and extraM < 0 and Energy.income > 300 then + if ai.Energy.extra > 80 and highEnergy and lowMetal and ai.Metal.extra < 0 and ai.Energy.income > 300 then + local converterLimit = math.min(math.floor(ai.Energy.income / 200), 4) if isWater then if ai.mySide == CORESideName then - unitName = BuildWithLimitedNumber("corfmkr", 8) + unitName = BuildWithLimitedNumber("corfmkr", converterLimit) else - unitName = BuildWithLimitedNumber("armfmkr", 8) + unitName = BuildWithLimitedNumber("armfmkr", converterLimit) end else if ai.mySide == CORESideName then - unitName = BuildWithLimitedNumber("cormakr", 8) + unitName = BuildWithLimitedNumber("cormakr", converterLimit) else - unitName = BuildWithLimitedNumber("armmakr", 8) + unitName = BuildWithLimitedNumber("armmakr", converterLimit) end end end -- maybe we need storage? if unitName == DummyUnitName then -- energy storage - if Energy.reserves >= 0.9 * Energy.capacity and extraE > 100 then + if ai.Energy.extra > 150 and highEnergy and not lowMetal then if isWater then if ai.mySide == CORESideName then - unitName = BuildWithLimitedNumber("coruwes", 3) + unitName = BuildWithLimitedNumber("coruwes", 2) else - unitName = BuildWithLimitedNumber("armuwes", 3) + unitName = BuildWithLimitedNumber("armuwes", 2) end else if ai.mySide == CORESideName then - unitName = BuildWithLimitedNumber("corestor", 3) + unitName = BuildWithLimitedNumber("corestor", 2) else - unitName = BuildWithLimitedNumber("armestor", 3) + unitName = BuildWithLimitedNumber("armestor", 2) end end end end if unitName == DummyUnitName then -- metal storage - if Metal.reserves >= 0.9 * Metal.capacity and extraM > 3 then + if ai.Metal.extra > 5 and highMetal and highEnergy then if isWater then if ai.mySide == CORESideName then - unitName = BuildWithLimitedNumber("coruwms", 3) + unitName = BuildWithLimitedNumber("coruwms", 2) else - unitName = BuildWithLimitedNumber("armuwms", 3) + unitName = BuildWithLimitedNumber("armuwms", 2) end else if ai.mySide == CORESideName then - unitName = BuildWithLimitedNumber("cormstor", 3) + unitName = BuildWithLimitedNumber("cormstor", 2) else - unitName = BuildWithLimitedNumber("armmstor", 3) + unitName = BuildWithLimitedNumber("armmstor", 2) end end end @@ -340,33 +334,36 @@ -- build advanced conversion or storage function DoSomethingAdvancedForTheEconomy(self) - local Energy = game:GetResourceByName("Energy") - local extraE = Energy.income - Energy.usage - local Metal = game:GetResourceByName("Metal") - local extraM = Metal.income - Metal.usage + local highEnergy = ai.Energy.full > 0.9 + local lowEnergy = ai.Energy.full < 0.1 + local highMetal = ai.Metal.full > 0.9 + local lowMetal = ai.Metal.full < 0.1 local unitName = self.unit:Internal():Name() local isWater = unitTable[unitName].needsWater or seaplaneConList[unitName] local unitName = DummyUnitName -- maybe we need conversion? - if extraE > 600 and extraM < 0 and Energy.income > 2000 then + if ai.Energy.extra > 800 and highEnergy and lowMetal and ai.Metal.extra < 0 and ai.Energy.income > 2000 then + local converterLimit = math.floor(ai.Energy.income / 1000) if isWater then if ai.mySide == CORESideName then - unitName = BuildWithLimitedNumber("armuwmmm", Energy.income / 1000) + unitName = BuildWithLimitedNumber("armuwmmm", converterLimit) else - unitName = BuildWithLimitedNumber("armuwmmm", Energy.income / 1000) + unitName = BuildWithLimitedNumber("armuwmmm", converterLimit) end else if ai.mySide == CORESideName then - unitName = BuildWithLimitedNumber("cormmkr", Energy.income / 1000) + unitName = BuildWithLimitedNumber("cormmkr", converterLimit) else - unitName = BuildWithLimitedNumber("armmmkr", Energy.income / 1000) + unitName = BuildWithLimitedNumber("armmmkr", converterLimit) end end end + -- building big storage is a waste + --[[ -- maybe we need storage? if unitName == DummyUnitName then -- energy storage - if Energy.reserves >= 0.9 * Energy.capacity and extraE > 1000 then + if ai.Energy.extra > 1500 and highEnergy and not lowMetal then if ai.mySide == CORESideName then unitName = BuildWithLimitedNumber("coruwadves", 1) else @@ -376,7 +373,7 @@ end if unitName == DummyUnitName then -- metal storage - if Metal.reserves >= 0.9 * Metal.capacity and extraM > 10 then + if ai.Metal.extra > 25 and highMetal and highEnergy then if ai.mySide == CORESideName then unitName = BuildWithLimitedNumber("coruwadvms", 1) else @@ -384,6 +381,7 @@ end end end + ]]-- return unitName end @@ -411,7 +409,9 @@ function BuildSiegeIfNeeded(unitName) if unitName == DummyUnitName then return DummyUnitName end if IsSiegeEquipmentNeeded() then - return BuildWithLimitedNumber(unitName, math.ceil((ai.battleCount + ai.breakthroughCount) * 0.3)) + if ai.siegeCount < (ai.battleCount + ai.breakthroughCount) * 0.35 then + return unitName + end end return DummyUnitName end @@ -428,6 +428,7 @@ return DummyUnitName end else + if ai.battleCount <= minBattleCount then return DummyUnitName end local attackCounter = ai.attackhandler:GetCounter(mtype) if attackCounter == maxAttackCounter then return unitName @@ -626,6 +627,13 @@ function BuildRaiderIfNeeded(unitName) if unitName == DummyUnitName or unitName == nil then return DummyUnitName end local mtype = unitTable[unitName].mtype + if ai.factoriesAtLevel[3] ~= nil and ai.factoriesAtLevel[3] ~= {} then + -- if we have a level 2 factory, don't build raiders until we have some battle units + local attackCounter = ai.attackhandler:GetCounter(mtype) + if ai.battleCount + ai.breakthroughCount < attackCounter / 2 then + return DummyUnitName + end + end local counter = ai.raidhandler:GetCounter(mtype) if counter == minRaidCounter then return DummyUnitName end if ai.raiderCount[mtype] == nil then @@ -765,11 +773,15 @@ local mtype = unitTable[unitName].mtype local attackCounter = ai.attackhandler:GetCounter(mtype) EchoDebug(mtype .. " " .. attackCounter .. " " .. maxAttackCounter) - if attackCounter == maxAttackCounter then return DummyUnitName end + if attackCounter == maxAttackCounter and ai.battleCount > minBattleCount then return DummyUnitName end if mtype == "veh" and ai.mySide == CORESideName and (ai.factoriesAtLevel[1] == nil or ai.factoriesAtLevel[1] == {}) then -- core only has a lvl1 vehicle raider, so this prevents getting stuck return unitName end + if ai.factoriesAtLevel[3] ~= nil and ai.factoriesAtLevel[3] ~= {} then + -- if we have a level 2 factory, don't wait to build raiders first + return unitName + end local raidCounter = ai.raidhandler:GetCounter(mtype) EchoDebug(mtype .. " " .. raidCounter .. " " .. maxRaidCounter) if raidCounter == minRaidCounter then return unitName end @@ -1193,47 +1205,6 @@ end end --- how many of our own unitName there are in a radius around a position -function CountOwnUnitsInRadius(unitName, pos, radius, maxCount) - local ownUnits = game:GetFriendlies() - local unitCount = 0 - -- optimisation: there is always 0 null units on map - if unitName == DummyUnitName then - return 0 - end - for _, u in pairs(ownUnits) do - if u:Name() == unitName then - local upos = u:GetPosition() - if Distance(pos, upos) < radius then - unitCount = unitCount + 1 - end - -- optimisation: if the limit is already exceeded, don't count further - if unitCount >= maxCount then - break - end - end - end - return unitCount -end - -local function CheckAreaLimit(unitName, builder, unitLimit, range) - -- this is special case, it means the unit will not be built anyway - if unitName == DummyUnitName then - return unitName - end - local pos = builder:GetPosition() - if range == nil then range = AreaCheckRange end - -- now check how many of the wanted unit is nearby - local NumberOfUnits = CountOwnUnitsInRadius(unitName, pos, range, unitLimit) - local AllowBuilding = NumberOfUnits < unitLimit - EchoDebug(""..unitName.." wanted, with range limit of "..unitLimit..", with "..NumberOfUnits.." already there. The check is: "..tostring(AllowBuilding)) - if AllowBuilding then - return unitName - else - return DummyUnitName - end -end - local function GroundDefenseIfNeeded(unitName, builder) if not ai.needGroundDefense then return DummyUnitName @@ -1795,20 +1766,6 @@ end end -local function CheckForOwnUnit(name) - local ownUnits = game:GetFriendlies() - for _, u in pairs(ownUnits) do - local un = u:Name() - if un == name then - local ut = u:Team() - if ut == ownTeamID then - return true - end - end - end - return false -end - local function BuildAppropriateFactory() return FactoryUnitName end @@ -2012,22 +1969,22 @@ } local anyAdvConUnit = { + BuildAppropriateFactory, + BuildFusion, + BuildNukeIfNeeded, + BuildAdvancedRadar, + BuildHeavyPlasma, + BuildAntinuke, BuildLvl2PopUp, BuildHeavyAA, - BuildAntinuke, BuildLvl2Plasma, BuildTachyon, - BuildHeavyPlasma, - BuildTacticalNuke, - BuildFusion, - BuildAdvancedRadar, - BuildLvl2Jammer, - BuildAppropriateFactory, - BuildNukeIfNeeded, + -- BuildTacticalNuke, BuildExtraHeavyAA, + BuildLvl2Jammer, BuildMohoGeo, BuildMohoMex, - DoSomethingAdvancedForTheEconomy, + -- DoSomethingAdvancedForTheEconomy, } local anyConSeaplane = { @@ -2037,7 +1994,7 @@ BuildAdvancedSonar, BuildHeavyTorpedo, BuildAppropriateFactory, - DoSomethingAdvancedForTheEconomy, + -- DoSomethingAdvancedForTheEconomy, } local anyAdvConSub = { @@ -2046,7 +2003,7 @@ BuildUWFusion, BuildAdvancedSonar, BuildHeavyTorpedo, - DoSomethingAdvancedForTheEconomy, + -- DoSomethingAdvancedForTheEconomy, } local anyNavalEngineer = { diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/turtlehandler.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/turtlehandler.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/turtlehandler.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/turtlehandler.lua 2014-10-07 20:10:05.000000000 +0000 @@ -11,26 +11,79 @@ end local function PlotPointDebug(x, z, label) - label = string.format("%.1f", label) + if type(label) ~= "string" then label = string.format("%.1f", label) end debugPlotTurtleFile:write(math.ceil(x) .. " " .. math.ceil(z) .. " " .. label .. "\n") end -local maxOrganDistance = 200 +local maxOrganDistance = 400 -local antinukeMod = 1000 -local shieldMod = 1000 -local jamMod = 1000 -local radarMod = 1000 -local sonarMod = 1000 -local missingFactoryDefenseMod = 1500 -- if a turtle with a factory has no defense, subtract this much from distance -local distanceMod = 1.5 +local babySize = 200 +local outpostSize = 250 +local baseSize = 300 + +local outpostLimbs = 2 +local baseLimbs = 3 + +local layerMod = { + ground = 1, + air = 1, + submerged = 1, + antinuke = 1000, + shield = 1000, + jam = 1000, + radar = 1000, + sonar = 1000, +} + +local missingFactoryDefenseDistance = 1500 -- if a turtle with a factory has no defense, subtract this much from distance +local modDistance = 1 local factoryPriority = 4 -- added to tech level. above this priority allows two of the same type of defense tower. --- this is added to the turtle's priority if a shell of this layer is added to it -local layerPriority = {} -layerPriority["jam"] = 1 -layerPriority["shield"] = 2 +local basePriority = factoryPriority + 1 +local outpostPriority = 2 + +local exteriorLayer = { ground = 1, submerged = 1 } +local interiorLayer = { air = 1, antinuke = 1, shield = 1, jam = 1, radar = 1, sonar = 1 } +local hurtyLayer = { ground = 1, submerged = 1, air = 1 } + +local unitPriorities = {} + +local function Priority(unitName) + local p = unitPriorities[unitName] + if p then return p end + local priority = 0 + local ut = unitTable[unitName] + if turtleList[unitName] then + priority = turtleList[unitName] + elseif antinukeList[unitName] then + priority = 2 + elseif shieldList[unitName] then + priority = 2 + else + if ut.buildOptions then + priority = priority + factoryPriority + ut.techLevel + end + if ut.extractsMetal > 0 then + priority = priority + (ut.extractsMetal * 1000) + end + if ut.totalEnergyOut > 0 then + priority = priority + (ut.totalEnergyOut / 200) + end + if ut.jammerRadius > 0 then + priority = priority + (ut.jammerRadius / 700) + end + if ut.radarRadius > 0 then + priority = priority + (ut.radarRadius / 3500) + end + if ut.sonarRadius > 0 then + priority = priority + (ut.sonarRadius / 2400) + end + priority = priority + (ut.metalCost / 1000) + end + unitPriorities[unitName] = p + return priority +end TurtleHandler = class(Module) @@ -44,94 +97,121 @@ function TurtleHandler:Init() self.turtles = {} -- zones to protect - self.looseOrgans = {} -- things to protect not yet in a protected zone self.shells = {} -- defense buildings, shields, and jamming + self.planned = {} + self.turtlesByUnitID = {} self.totalPriority = 0 end -function TurtleHandler:UnitCreated(unit) - local un = unit:Name() - local ut = unitTable[un] +-- received from buildsitehandler +-- also applies to plans, in which case the plan is the unitID +function TurtleHandler:NewUnit(unitName, position, unitID) + local ut = unitTable[unitName] if ut.isBuilding then - local upos = unit:GetPosition() - local uid = unit:ID() - if ut.isWeapon and not ut.buildOptions and not antinukeList[un] and not nukeList[un] and not bigPlasmaList[un] then - self:AddDefense(upos, uid, un) + if ut.isWeapon and not ut.buildOptions and not antinukeList[unitName] and not nukeList[unitName] and not bigPlasmaList[unitName] then + self:AddDefense(position, unitID, unitName) else - if antinukeList[un] then - self:AddShell(upos, uid, un, 1, "antinuke", 72000) - elseif shieldList[un] then - self:AddShell(upos, uid, un, 1, "shield", 450) + if antinukeList[unitName] then + self:AddShell(position, unitID, unitName, 1, "antinuke", 72000) + elseif shieldList[unitName] then + self:AddShell(position, unitID, unitName, 1, "shield", 450) elseif ut.jammerRadius ~= 0 then - self:AddShell(upos, uid, un, 1, "jam", ut.jammerRadius) + self:AddShell(position, unitID, unitName, 1, "jam", ut.jammerRadius) elseif ut.radarRadius ~= 0 then - self:AddShell(upos, uid, un, 1, "radar", ut.radarRadius * 0.67) + self:AddShell(position, unitID, unitName, 1, "radar", ut.radarRadius * 0.67) elseif ut.sonarRadius ~= 0 then - self:AddShell(upos, uid, un, 1, "sonar", ut.sonarRadius * 0.67) + self:AddShell(position, unitID, unitName, 1, "sonar", ut.sonarRadius * 0.67) end - self:AddOrgan(upos, uid, un) + self:AddOrgan(position, unitID, unitName) end end end -function TurtleHandler:UnitDead(unit) - local un = unit:Name() - local ut = unitTable[un] - local uid = unit:ID() +-- received from buildsitehandler +function TurtleHandler:PlanCreated(plan, unitID) + local found = false + local unitName = plan.unitName + local ut = unitTable[unitName] if ut.isBuilding then - if ut.isWeapon or shieldList[un] then - self:RemoveShell(uid) + if ut.isWeapon or shieldList[unitName] then + for si, shell in pairs(self.shells) do + if shell.unitID == plan then + shell.unitID = unitID + found = true + break + end + end else - self:RemoveOrgan(uid) + for ti, turtle in pairs(self.turtles) do + for oi, organ in pairs(turtle.organs) do + if organ.unitID == plan then + organ.unitID = unitID + found = true + break + end + end + if found then break end + end end end + return found end -function TurtleHandler:AddOrgan(position, unitID, unitName) - -- calculate priority - local priority = 0 +-- received from buildsitehandler +function TurtleHandler:PlanCancelled(plan) + local unitName = plan.unitName local ut = unitTable[unitName] - if turtleList[unitName] then - priority = turtleList[unitName] - elseif antinukeList[unitName] then - priority = 2 - elseif shieldList[unitName] then - priority = 2 - else - if ut.buildOptions then - priority = priority + factoryPriority + ut.techLevel - end - if ut.extractsMetal > 0 then - priority = priority + (ut.extractsMetal * 1000) - end - if ut.totalEnergyOut > 0 then - priority = priority + (ut.totalEnergyOut / 200) - end - if ut.jammerRadius > 0 then - priority = priority + (ut.jammerRadius / 700) - end - if ut.radarRadius > 0 then - priority = priority + (ut.radarRadius / 3500) + if ut.isBuilding then + if ut.isWeapon or shieldList[unitName] then + self:RemoveShell(plan) + else + self:RemoveOrgan(plan) end - if ut.sonarRadius > 0 then - priority = priority + (ut.sonarRadius / 2400) + self.turtlesByUnitID[plan] = nil + end +end + +function TurtleHandler:UnitDead(unit) + local unitName = unit:Name() + local ut = unitTable[unitName] + local unitID = unit:ID() + if ut.isBuilding then + if ut.isWeapon or shieldList[unitName] then + self:RemoveShell(unitID) + else + self:RemoveOrgan(unitID) end - priority = priority + (ut.metalCost / 1000) + self.turtlesByUnitID[unitID] = nil end +end + +function TurtleHandler:AddOrgan(position, unitID, unitName) + -- calculate priority + local priority = Priority(unitName) + local ut = unitTable[unitName] -- create the organ - local organ = { priority = priority, position = position, uid = unitID } + local organ = { priority = priority, position = position, unitID = unitID } -- find a turtle to attach to local nearestDist = maxOrganDistance local nearestTurtle for i, turtle in pairs(self.turtles) do if turtle.water == ut.needsWater then local dist = Distance(position, turtle.position) - if dist < nearestDist then - nearestDist = dist - nearestTurtle = turtle + if dist < turtle.size then + if dist < nearestDist then + nearestDist = dist + nearestTurtle = turtle + end + elseif #turtle.organs == 1 then + if (turtle.priority + priority >= basePriority and dist < baseSize * 2) or (turtle.priority + priority >= outpostPriority and dist < outpostSize * 2) then + -- merge into an outpost or base + nearestDist = dist + nearestTurtle = turtle + end end end end + -- make a new turtle if necessary if nearestTurtle == nil then nearestTurtle = self:AddTurtle(position, ut.needsWater) end @@ -139,17 +219,18 @@ self:PlotAllDebug() end -function TurtleHandler:RemoveOrgan(uid) +function TurtleHandler:RemoveOrgan(unitID) local foundOrgan = false local emptyTurtle = false for ti, turtle in pairs(self.turtles) do for oi, organ in pairs(turtle.organs) do - if organ.uid == uid then + if organ.unitID == unitID then turtle.priority = turtle.priority - organ.priority self.totalPriority = self.totalPriority - organ.priority table.remove(turtle.organs, oi) if #turtle.organs == 0 then emptyTurtle = turtle + ai.defendhandler:RemoveWard(nil, turtle) table.remove(self.turtles, ti) end foundOrgan = true @@ -167,99 +248,185 @@ end end end + self.turtlesByUnitID[unitID] = nil self:PlotAllDebug() end function TurtleHandler:Transplant(turtle, organ) table.insert(turtle.organs, organ) turtle.priority = turtle.priority + organ.priority - if turtle.priority > factoryPriority then turtle.nameLimit = 2 end + if #turtle.organs > 1 then + if #turtle.limbs < baseLimbs and turtle.priority >= basePriority then + self:Base(turtle, baseSize, baseLimbs) + elseif #turtle.limbs < outpostLimbs and turtle.priority >= outpostPriority then + self:Base(turtle, outpostSize, outpostLimbs) + end + end self.totalPriority = self.totalPriority + organ.priority + self.turtlesByUnitID[organ.unitID] = turtle end -function TurtleHandler:Attach(turtle, shell) +function TurtleHandler:Attach(limb, shell) + local turtle = limb.turtle turtle[shell.layer] = turtle[shell.layer] + shell.value if turtle.nameCounts[shell.uname] == nil then turtle.nameCounts[shell.uname] = 1 else turtle.nameCounts[shell.uname] = turtle.nameCounts[shell.uname] + 1 end - local priorityAddition = layerPriority[shell.layer] or 0 - turtle.priority = turtle.priority + priorityAddition - if turtle.priority > factoryPriority then turtle.nameLimit = 2 end - self.totalPriority = self.totalPriority + priorityAddition - table.insert(shell.attachments, turtle) + limb[shell.layer] = limb[shell.layer] + shell.value + if limb.nameCounts[shell.uname] == nil then + limb.nameCounts[shell.uname] = 1 + else + limb.nameCounts[shell.uname] = limb.nameCounts[shell.uname] + 1 + end + self.turtlesByUnitID[shell.unitID] = turtle + table.insert(shell.attachments, limb) end -function TurtleHandler:Detach(turtle, shell) +function TurtleHandler:Detach(limb, shell) + local turtle = limb.turtle turtle[shell.layer] = turtle[shell.layer] - shell.value turtle.nameCounts[shell.uname] = turtle.nameCounts[shell.uname] - 1 - local priorityAddition = layerPriority[shell.layer] or 0 - turtle.priority = turtle.priority - priorityAddition - if turtle.priority <= factoryPriority then turtle.nameLimit = 1 end - self.totalPriority = self.totalPriority - priorityAddition + limb[shell.layer] = limb[shell.layer] - shell.value + limb.nameCounts[shell.uname] = limb.nameCounts[shell.uname] - 1 + self.turtlesByUnitID[shell.unitID] = nil +end + +function TurtleHandler:InitializeInteriorLayers(limb) + for layer, nothing in pairs(interiorLayer) do + limb[layer] = 0 + end +end + +function TurtleHandler:Base(turtle, size, limbs) + turtle.size = size + for li, limb in pairs(turtle.limbs) do + if limb ~= turtle.firstLimb then + self:InitializeInteriorLayers(limb) + table.insert(turtle.interiorLimbs, limb) + end + end + turtle.limbs = {} + -- average the turtle's position + local totalX = 0 + local totalZ = 0 + for oi, organ in pairs(turtle.organs) do + totalX = totalX + organ.position.x + totalZ = totalZ + organ.position.z + end + turtle.position.x = totalX / #turtle.organs + turtle.position.z = totalZ / #turtle.organs + local angleAdd = twicePi / limbs + local angle = math.random() * twicePi + for l = 1, limbs do + local limb = { turtle = turtle, nameCounts = {}, ground = 0, submerged = 0 } + -- make sure the limb is in an acceptable position (not near the map edge, and not inside another turtle) + for aroundTheClock = 1, 12 do + local offMapCheck = RandomAway(turtle.position, size * 1.33, false, angle) + if offMapCheck.x ~= 1 and offMapCheck.x ~= ai.maxElmosX - 1 and offMapCheck.z ~= 1 and offMapCheck.z ~= ai.maxElmosZ - 1 then + limb.position = RandomAway(turtle.position, size, false, angle) + local inAnotherTurtle = false + for ti, turt in pairs(self.turtles) do + if turt ~= turtle then + local dist = Distance(turt.position, limb.position) + if dist < turt.size then + inAnotherTurtle = true + break + end + end + end + if not inAnotherTurtle then break end + end + angle = angle + twicePi / 12 + if angle > twicePi then angle = angle - twicePi end + end + if limb.position then + for i, shell in pairs(self.shells) do + if exteriorLayer[shell.layer] then + local dist = Distance(limb.position, shell.position) + if dist < shell.radius then + self:Attach(limb, shell) + end + end + end + table.insert(turtle.limbs, limb) + end + angle = angle + angleAdd + if angle > twicePi then angle = angle - twicePi end + end end function TurtleHandler:AddTurtle(position, water, priority) if priority == nil then priority = 0 end - local nameLimit = 1 - if priority > factoryPriority then nameLimit = 2 end - local turtle = {position = position, organs = {}, water = water, nameCounts = {}, nameLimit = nameLimit, priority = priority, ground = 0, air = 0, submerged = 0, antinuke = 0, shield = 0, jam = 0, radar = 0, sonar = 0} + local firstLimb = { position = position, nameCounts = {}, ground = 0, submerged = 0 } + self:InitializeInteriorLayers(firstLimb) + local turtle = {position = position, size = babySize, organs = {}, limbs = { firstLimb }, interiorLimbs = { firstLimb }, firstLimb = firstLimb, water = water, nameCounts = {}, priority = priority, ground = 0, air = 0, submerged = 0, antinuke = 0, shield = 0, jam = 0, radar = 0, sonar = 0} + firstLimb.turtle = turtle for i, shell in pairs(self.shells) do local dist = Distance(position, shell.position) if dist < shell.radius then - self:Attach(turtle, shell) + self:Attach(turtle.firstLimb, shell) end end table.insert(self.turtles, turtle) self.totalPriority = self.totalPriority + priority + ai.defendhandler:AddWard(nil, turtle) return turtle end -function TurtleHandler:AddDefense(position, uid, unitName) +function TurtleHandler:AddDefense(position, unitID, unitName) local ut = unitTable[unitName] -- effective defense ranges are less than actual ranges, because if a building is just inside a weapon range, it's not defended local defense = ut.metalCost if ut.groundRange ~= 0 then - self:AddShell(position, uid, unitName, defense, "ground", ut.groundRange * 0.5) + self:AddShell(position, unitID, unitName, defense, "ground", ut.groundRange * 0.5) end if ut.airRange ~= 0 then - self:AddShell(position, uid, unitName, defense, "air", ut.airRange * 0.5) + self:AddShell(position, unitID, unitName, defense, "air", ut.airRange * 0.5) end if ut.submergedRange ~= 0 then - self:AddShell(position, uid, unitName, defense, "submerged", ut.submergedRange * 0.5) + self:AddShell(position, unitID, unitName, defense, "submerged", ut.submergedRange * 0.5) end end -function TurtleHandler:AddShell(position, uid, uname, value, layer, radius) - local shell = {position = position, uid = uid, uname = uname, value = value, layer = layer, radius = radius, attachments = {}} +function TurtleHandler:AddShell(position, unitID, uname, value, layer, radius) + local shell = {position = position, unitID = unitID, uname = uname, value = value, layer = layer, radius = radius, attachments = {}} local nearestDist = radius * 3 - local nearestTurtle + local nearestLimb local attached = false for i, turtle in pairs(self.turtles) do - local dist = Distance(position, turtle.position) - if dist < radius then - self:Attach(turtle, shell) - attached = true - end - if not attached and dist < nearestDist then - nearestDist = dist - nearestTurtle = turtle + local checkThese + if exteriorLayer[layer] then + checkThese = turtle.limbs + else + checkThese = turtle.interiorLimbs + end + for li, limb in pairs(checkThese) do + local dist = Distance(position, limb.position) + if dist < radius then + self:Attach(limb, shell) + attached = true + end + if not attached and dist < nearestDist then + nearestDist = dist + nearestLimb = limb + end end end -- if nothing is close enough, attach to the nearest turtle, so that we don't end up building infinite laser towers at the same turtle if not attached and nearestTurtle then - self:Attach(nearestTurtle, shell) + self:Attach(nearestLimb, shell) end table.insert(self.shells, shell) self:PlotAllDebug() end -function TurtleHandler:RemoveShell(uid) +function TurtleHandler:RemoveShell(unitID) for si, shell in pairs(self.shells) do - if shell.uid == uid then - for ti, turtle in pairs(shell.attachments) do - self:Detach(turtle, shell) + if shell.unitID == unitID then + for li, limb in pairs(shell.attachments) do + self:Detach(limb, shell) end table.remove(self.shells, si) end @@ -267,116 +434,143 @@ self:PlotAllDebug() end -function TurtleHandler:LeastTurtled(builder, unitName, bombard) +function TurtleHandler:LeastTurtled(builder, unitName, bombard, oneOnly) if builder == nil then return end EchoDebug("checking for least turtled from " .. builder:Name() .. " for " .. tostring(unitName) .. " bombard: " .. tostring(bombard)) if unitName == nil then return end local position = builder:GetPosition() local ut = unitTable[unitName] local Metal = game:GetResourceByName("Metal") - local ground, air, submerged, antinuke, shield, jam, radar, sonar local priorityFloor = 1 + local layer if ut.isWeapon and not antinukeList[unitName] then if ut.groundRange ~= 0 then - ground = true - end - if ut.airRange ~= 0 then - air = true - end - if ut.submergedRange ~= 0 then - submerged = true + layer = "ground" + elseif ut.airRange ~= 0 then + layer = "air" + elseif ut.submergedRange ~= 0 then + layer = "submerged" end elseif antinukeList[unitName] then - antinuke = true + layer = "antinuke" priorityFloor = 5 elseif shieldList[unitName] then - shield = true + layer = "shield" priorityFloor = 5 elseif ut.jammerRadius ~= 0 then - jam = true + layer = "jam" priorityFloor = 5 elseif ut.radarRadius ~= 0 then - radar = true + layer = "radar" elseif ut.sonarRadius ~= 0 then - sonar = true + layer = "sonar" end local bestDist = 100000 local best + local bydistance = {} for i, turtle in pairs(self.turtles) do local important = turtle.priority >= priorityFloor -- so that for example we don't build shields where there's just a mex - local enough = false local isLocal = true - if unitName ~= nil and important then - if turtle.nameCounts[unitName] == nil or turtle.nameCounts[unitName] == 0 then - -- not enough - elseif turtle.nameCounts[unitName] >= turtle.nameLimit then - EchoDebug("too many " .. unitName .. " at turtle") - enough = true - end - end - if not enough and (ground or air or submerged) and important then + if important then -- don't build land shells on water turtles or water shells on land turtles isLocal = unitTable[unitName].needsWater == turtle.water end - if not enough and isLocal and important then - local okay = ai.maphandler:UnitCanGoHere(builder, turtle.position) - if okay and bombard and unitName ~= nil then - okay = ai.targethandler:IsBombardPosition(turtle.position, unitName) - end - if okay and (radar or sonar or shield or antinuke or jammer) then - -- only build these things at already defended spots - okay = turtle.ground + turtle.air + turtle.submerged > 0 + if isLocal and important then + local modLimit = 10000 + if hurtyLayer[layer] then + modLimit = (turtle.priority / self.totalPriority) * Metal.income * 60 + modLimit = math.floor(modLimit) + end + local checkThese + if interiorLayer[layer] then + if layer == "air" or turtle.ground + turtle.air + turtle.submerged > 0 then + checkThese = turtle.interiorLimbs + else + checkThese = {} + end + else + checkThese = turtle.limbs end - if okay then - local mod = 0 - if ground then mod = mod + turtle.ground end - if air then mod = mod + turtle.air end - if submerged then mod = mod + turtle.submerged end - if antinuke then mod = mod + turtle.antinuke * antinukeMod end - if shield then mod = mod + turtle.shield * shieldMod end - if jam then mod = mod + turtle.jam * jamMod end - if radar then mod = mod + turtle.radar * radarMod end - if sonar then mod = mod + turtle.sonar * sonarMod end - local modLimit = 10000 - if ground or air or submerged then - modLimit = (turtle.priority / self.totalPriority) * Metal.income * 65 - modLimit = math.floor(modLimit) - end - local modDefecit = modLimit - mod - EchoDebug("turtled: " .. mod .. ", limit: " .. tostring(modLimit) .. ", priority: " .. turtle.priority .. ", total priority: " .. self.totalPriority) - if mod == 0 or mod < ut.metalCost or (mod < modLimit and modDefecit < ut.metalCost * 3) then - local dist = Distance(position, turtle.position) - dist = dist - (modDefecit * distanceMod) - if (ground or air or submerged) and mod == 0 and turtle.priority > factoryPriority then - dist = dist - missingFactoryDefenseMod + for li, limb in pairs(checkThese) do + local enough + if interiorLayer[layer] then + enough = turtle.nameCounts[unitName] ~= nil and turtle.nameCounts[unitName] ~= 0 + else + local turtleEnough = false + if turtle.nameCounts[unitName] ~= nil then + turtleEnough = turtle.nameCounts[unitName] >= #turtle.limbs end - EchoDebug("distance: " .. dist) - if dist < bestDist then - EchoDebug("best distance") - bestDist = dist - best = turtle.position + enough = (limb.nameCounts[unitName] ~= nil and limb.nameCounts[unitName] ~= 0) or turtleEnough + end + local okay = false + if not enough then + okay = ai.maphandler:UnitCanGoHere(builder, limb.position) + end + if okay and bombard and unitName ~= nil then + okay = ai.targethandler:IsBombardPosition(limb.position, unitName) + end + if okay then + local mod + if interiorLayer[layer] then + mod = turtle[layer] + else + mod = limb[layer] + end + mod = mod * layerMod[layer] + local modDefecit = modLimit - mod + EchoDebug("turtled: " .. mod .. ", limit: " .. tostring(modLimit) .. ", priority: " .. turtle.priority .. ", total priority: " .. self.totalPriority) + if mod == 0 or mod < ut.metalCost or mod < modLimit then + local dist = Distance(position, limb.position) + dist = dist - (modDefecit * modDistance) + if hurtyLayer[layer] and limb[layer] == 0 and turtle.priority > factoryPriority then dist = dist - missingFactoryDefenseDistance end + EchoDebug("distance: " .. dist) + if oneOnly then + if dist < bestDist then + EchoDebug("best distance") + bestDist = dist + best = limb.position + end + else + bydistance[dist] = limb.position + end end end end end end - if best then - local newpos = api.Position() - newpos.x = best.x - newpos.z = best.z - newpos.y = best.y - return newpos + if oneOnly then + if best then + local newpos = api.Position() + newpos.x = best.x + newpos.z = best.z + newpos.y = best.y + return newpos + else + return nil + end else - return nil + local sorted = {} + for dist, pos in pairsByKeys(bydistance) do + local newpos = api.Position() + newpos.x = pos.x+0 + newpos.z = pos.z+0 + newpos.y = pos.y+0 + table.insert(sorted, newpos) + end + EchoDebug("outputting " .. #sorted .. " least turtles") + return sorted end end -function TurtleHandler:MostTurtled(builder, bombard) +function TurtleHandler:MostTurtled(builder, unitName, bombard, oneOnly) + local modDist = modDistance + if unitName then modDist = modDist * Priority(unitName) end if builder == nil then return end EchoDebug("checking for most turtled from " .. builder:Name() .. ", bombard: " .. tostring(bombard)) local position = builder:GetPosition() local bestDist = 100000 local best + local bydistance = {} for i, turtle in pairs(self.turtles) do if ai.maphandler:UnitCanGoHere(builder, turtle.position) then local okay = true @@ -384,41 +578,86 @@ okay = ai.targethandler:IsBombardPosition(turtle.position, bombard) end if okay then - local mod = turtle.ground + turtle.air + turtle.submerged + (turtle.shield * shieldMod) + (turtle.jam * jamMod) + local mod = turtle.ground + turtle.air + turtle.submerged + (turtle.shield * layerMod["shield"]) + (turtle.jam * layerMod["jam"]) EchoDebug("turtled: " .. mod .. ", priority: " .. turtle.priority .. ", total priority: " .. self.totalPriority) if mod ~= 0 then local dist = Distance(position, turtle.position) - dist = dist - (mod * distanceMod * 2) + dist = dist - (mod * modDist) EchoDebug("distance: " .. dist) - if dist < bestDist then - EchoDebug("best distance") - bestDist = dist - best = turtle.position + if oneOnly then + if dist < bestDist then + EchoDebug("best distance") + bestDist = dist + best = turtle.position + end + else + bydistance[dist] = turtle.position end end end end end - if best then - local newpos = api.Position() - newpos.x = best.x - newpos.z = best.z - newpos.y = best.y - return newpos + if oneOnly then + if best then + local newpos = api.Position() + newpos.x = best.x+0 + newpos.z = best.z+0 + newpos.y = best.y+0 + return newpos + else + return nil + end else - return nil + local sorted = {} + for dist, pos in pairsByKeys(bydistance) do + local newpos = api.Position() + newpos.x = pos.x+0 + newpos.z = pos.z+0 + newpos.y = pos.y+0 + table.insert(sorted, newpos) + end + EchoDebug("outputting " .. #sorted .. " most turtles") + return sorted + end +end + +function TurtleHandler:SafeWithinTurtle(position, unitName) + local gas = WhatHurtsUnit(unitName) + local cost = unitTable[unitName].metalCost + for i = 1, #self.turtles do + local turtle = self.turtles[i] + local safety = 0 + for GAS, yes in pairs(gas) do safety = safety + turtle[GAS] end + if safety > cost then + local dist = Distance(position, turtle.position) + if dist < turtle.size + 100 then + return true + end + end end + return false end + function TurtleHandler:GetTotalPriority() return self.totalPriority end +function TurtleHandler:GetUnitTurtle(unitID) + return self.turtlesByUnitID[unitID] +end + function TurtleHandler:PlotAllDebug() if DebugPlotEnabled then debugPlotTurtleFile= assert(io.open("debugturtleplot",'w'), "Unable to write debugturtleplot") for i, turtle in pairs(self.turtles) do PlotPointDebug(turtle.position.x, turtle.position.z, turtle.priority) + for li, limb in pairs(turtle.limbs) do + PlotPointDebug(limb.position.x, limb.position.z, "LIMB") + end + if turtle.front then + PlotPointDebug(turtle.position.x, turtle.position.z, "DANGER") + end end debugPlotTurtleFile:close() end diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/unitlists.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/unitlists.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/unitlists.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/unitlists.lua 2014-10-07 20:10:05.000000000 +0000 @@ -44,7 +44,7 @@ shp = 1, bot = 0.9, sub = 0.9, - hov = 0.75, + hov = 0.7, amp = 0.4, air = 0.55, } @@ -342,17 +342,17 @@ scoutList = { - "corfink", - "armpeep", - "corfav", - "armfav", - "armflea", - "corawac", - "armawac", - "corpt", - "armpt", - "corhunt", - "armsehak", + corfink = 1, + armpeep = 1, + corfav = 1, + armfav = 1, + armflea = 1, + corawac = 1, + armawac = 1, + corpt = 1, + armpt = 1, + corhunt = 1, + armsehak = 1, } antinukeList = { @@ -522,7 +522,8 @@ maxAttackCounter = 30 baseAttackCounter = 15 breakthroughAttackCounter = 16 -- build heavier battle units -siegeAttackCounter = 22 -- build siege units +siegeAttackCounter = 20 -- build siege units +minBattleCount = 4 -- how many battle units to build before building any breakthroughs, even if counter is too high minBomberCounter = 0 maxBomberCounter = 16 baseBomberCounter = 2 @@ -548,7 +549,7 @@ UWMetalSpotCheckUnit = "coruwmex" mobUnitName = {} -mobUnitName["veh"] = "armflash" +mobUnitName["veh"] = "armllt" -- this looks wrong, but it gives us a better picture of where vehicles can go mobUnitName["bot"] = "corck" mobUnitName["amp"] = "cormuskrat" mobUnitName["hov"] = "corsh" diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/unittable.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/unittable.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/unittable.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/unittable.lua 2014-10-07 20:10:05.000000000 +0000 @@ -7,7 +7,7 @@ unitTable["amgeo"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.19921875, losRadius = 8.53125, sonarRadius = 0, metalCost = 1520, xsize = 10, totalEnergyOut = 1250, jammerRadius = 0, wreckName = "", zsize = 16, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armaak"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 7.2265625, losRadius = 12.5, sonarRadius = 0, metalCost = 483, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armaak_dead", zsize = 4, mtype = "bot", airRange = 875, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = true, } unitTable["armaap"] = { radarRadius = 0, techLevel = 3, isBuilding = true, factoriesCanBuild = { }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.65625, losRadius = 9.75, wreckName = "armaap_dead", sonarRadius = 0, metalCost = 3006, xsize = 16, totalEnergyOut = 0, jammerRadius = 0, zsize = 12, buildOptions = true, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } -unitTable["armaas"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 7.03125, losRadius = 14.84375, sonarRadius = 0, metalCost = 658, xsize = 6, totalEnergyOut = 5.5, jammerRadius = 0, wreckName = "armaas_dead", zsize = 6, mtype = "shp", airRange = 840, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = true, } +unitTable["armaas"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 7.03125, losRadius = 14.84375, sonarRadius = 0, metalCost = 658, xsize = 6, totalEnergyOut = 5, jammerRadius = 0, wreckName = "armaas_dead", zsize = 6, mtype = "shp", airRange = 840, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = true, } unitTable["armaca"] = { radarRadius = 50, techLevel = 4, isBuilding = false, factoriesCanBuild = { "armap", "armaap", "armplat", }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.494140625, losRadius = 11.984375, wreckName = "", sonarRadius = 0, metalCost = 220, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, zsize = 4, buildOptions = true, mtype = "air", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armack"] = { radarRadius = 50, techLevel = 4, isBuilding = false, factoriesCanBuild = { "armshltx", "armlab", "armalab", }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.7933595180511, losRadius = 10.11562538147, wreckName = "armack_dead", sonarRadius = 0, metalCost = 290, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, zsize = 4, buildOptions = true, mtype = "bot", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armacsub"] = { radarRadius = 50, techLevel = 4, isBuilding = false, factoriesCanBuild = { "armplat", "armsy", "armasy", "asubpen", }, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 1.828125, losRadius = 4.875, wreckName = "armacsub_dead", sonarRadius = 0, metalCost = 695, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, zsize = 6, buildOptions = true, mtype = "sub", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } @@ -32,22 +32,22 @@ unitTable["armavp"] = { radarRadius = 50, techLevel = 3, isBuilding = true, factoriesCanBuild = { }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.3210935592651, losRadius = 8.8562498092651, wreckName = "armavp_dead", sonarRadius = 0, metalCost = 2698, xsize = 14, totalEnergyOut = 0, jammerRadius = 0, zsize = 12, buildOptions = true, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armawac"] = { radarRadius = 2500, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 14.94140625, losRadius = 39.84375, sonarRadius = 1200, metalCost = 165, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 6, mtype = "air", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armbanth"] = { radarRadius = 0, techLevel = 6, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 8.59375, losRadius = 19.28125, sonarRadius = 0, metalCost = 12691, xsize = 6, totalEnergyOut = 12, jammerRadius = 0, wreckName = "armbanth_dead", zsize = 6, mtype = "bot", airRange = 800, submergedRange = 0, stealth = false, groundRange = 800, isWeapon = true, } -unitTable["armbats"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.33203125, losRadius = 14.21875, sonarRadius = 0, metalCost = 5181, xsize = 12, totalEnergyOut = 57.5, jammerRadius = 0, wreckName = "armbats_dead", zsize = 12, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 1240, isWeapon = true, } +unitTable["armbats"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.33203125, losRadius = 14.21875, sonarRadius = 0, metalCost = 5181, xsize = 12, totalEnergyOut = 57, jammerRadius = 0, wreckName = "armbats_dead", zsize = 12, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 1240, isWeapon = true, } unitTable["armbeaver"] = { radarRadius = 0, techLevel = 2, isBuilding = false, factoriesCanBuild = { "armlab", "armvp", "armap", "armhp", "armfhp", "armsy", "asubpen", }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.1171875, losRadius = 8.3125, wreckName = "armbeaver_dead", sonarRadius = 0, metalCost = 141, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, zsize = 6, buildOptions = true, mtype = "amp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armbrawl"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 6.4453125, losRadius = 17.1875, sonarRadius = 0, metalCost = 294, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 6, mtype = "air", airRange = 0, submergedRange = 0, stealth = false, groundRange = 380, isWeapon = true, } unitTable["armbrtha"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = true, airLosRadius = 3.19921875, losRadius = 8.53125, sonarRadius = 0, metalCost = 4184, xsize = 8, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armbrtha_dead", zsize = 8, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 4650, isWeapon = true, } unitTable["armbull"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.7890625, losRadius = 15.4375, sonarRadius = 0, metalCost = 844, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armbull_dead", zsize = 6, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 460, isWeapon = true, } unitTable["armca"] = { radarRadius = 0, techLevel = 2, isBuilding = false, factoriesCanBuild = { "armaap", "armlab", "armvp", "armap", "armhp", "armsy", }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.5703125, losRadius = 12.1875, wreckName = "", sonarRadius = 0, metalCost = 105, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, zsize = 4, buildOptions = true, mtype = "air", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } -unitTable["armcarry"] = { radarRadius = 2950, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 12.94921875, losRadius = 34.53125, sonarRadius = 760, metalCost = 1600, xsize = 12, totalEnergyOut = 230.5, jammerRadius = 0, wreckName = "armcarry_dead", zsize = 12, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 72000, isWeapon = false, } +unitTable["armcarry"] = { radarRadius = 2950, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 12.94921875, losRadius = 34.53125, sonarRadius = 760, metalCost = 1600, xsize = 12, totalEnergyOut = 230, jammerRadius = 0, wreckName = "armcarry_dead", zsize = 12, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 72000, isWeapon = false, } unitTable["armch"] = { radarRadius = 50, techLevel = 4, isBuilding = false, factoriesCanBuild = { "armlab", "armvp", "armap", "armhp", "armfhp", "armsy", "asubpen", }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.11328125, losRadius = 10.96875, wreckName = "armch_dead", sonarRadius = 0, metalCost = 136, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, zsize = 6, buildOptions = true, mtype = "hov", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } -unitTable["armcir"] = { radarRadius = 0, techLevel = 3, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 7.8125, losRadius = 10.9375, sonarRadius = 0, metalCost = 702, xsize = 8, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armcir_dead", zsize = 8, mtype = "veh", airRange = 1250, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = true, } +unitTable["armcir"] = { radarRadius = 0, techLevel = 3, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 7.8125, losRadius = 10.9375, sonarRadius = 0, metalCost = 702, xsize = 8, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armcir_dead", zsize = 8, mtype = "veh", airRange = 1050, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = true, } unitTable["armck"] = { radarRadius = 0, techLevel = 2, isBuilding = false, factoriesCanBuild = { "armalab", "armlab", "armvp", "armap", "armhp", "armsy", }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.57421875, losRadius = 9.53125, wreckName = "armck_dead", sonarRadius = 0, metalCost = 102, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, zsize = 4, buildOptions = true, mtype = "bot", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armckfus"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = true, airLosRadius = 3.19921875, losRadius = 8.53125, sonarRadius = 0, metalCost = 4369, xsize = 10, totalEnergyOut = 1000, jammerRadius = 0, wreckName = "armckfus_dead", zsize = 8, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armclaw"] = { radarRadius = 0, techLevel = 3, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.15625, losRadius = 13.75, sonarRadius = 0, metalCost = 315, xsize = 4, totalEnergyOut = 0, jammerRadius = 8, wreckName = "armclaw_dead", zsize = 4, mtype = "veh", airRange = 0, submergedRange = 0, stealth = true, groundRange = 440, isWeapon = true, } unitTable["armcom"] = { radarRadius = 700, techLevel = 0, isBuilding = false, factoriesCanBuild = { "armlab", "armvp", "armap", "armsy", }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.2734375, losRadius = 14.0625, wreckName = "armcom_dead", sonarRadius = 300, metalCost = 2500, xsize = 4, totalEnergyOut = 25, jammerRadius = 0, zsize = 4, buildOptions = true, mtype = "veh", airRange = 0, submergedRange = 260, stealth = false, groundRange = 300, isWeapon = true, } unitTable["armcroc"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.359375, losRadius = 11.625, sonarRadius = 0, metalCost = 467, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armcroc_dead", zsize = 6, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 480, isWeapon = true, } -unitTable["armcrus"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 6.703125, losRadius = 17.875, sonarRadius = 375, metalCost = 1719, xsize = 8, totalEnergyOut = 5.5999999046326, jammerRadius = 0, wreckName = "armcrus_dead", zsize = 8, mtype = "shp", airRange = 0, submergedRange = 500, stealth = false, groundRange = 740, isWeapon = true, } -unitTable["armcs"] = { radarRadius = 0, techLevel = 2, isBuilding = false, factoriesCanBuild = { "armsy", "armasy", "armfhp", "asubpen", "armplat", }, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.4125001430511, losRadius = 9.1000003814697, wreckName = "armcs_dead", sonarRadius = 0, metalCost = 255, xsize = 6, totalEnergyOut = 20.5, jammerRadius = 0, zsize = 6, buildOptions = true, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } +unitTable["armcrus"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 6.703125, losRadius = 17.875, sonarRadius = 375, metalCost = 1719, xsize = 8, totalEnergyOut = 5.0999999046326, jammerRadius = 0, wreckName = "armcrus_dead", zsize = 8, mtype = "shp", airRange = 0, submergedRange = 500, stealth = false, groundRange = 740, isWeapon = true, } +unitTable["armcs"] = { radarRadius = 0, techLevel = 2, isBuilding = false, factoriesCanBuild = { "armsy", "armasy", "armfhp", "asubpen", "armplat", }, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.4125001430511, losRadius = 9.1000003814697, wreckName = "armcs_dead", sonarRadius = 0, metalCost = 255, xsize = 6, totalEnergyOut = 20, jammerRadius = 0, zsize = 6, buildOptions = true, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armcsa"] = { radarRadius = 0, techLevel = 4, isBuilding = false, factoriesCanBuild = { "armap", "armaap", "armplat", "armsy", "armasy", }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.265625, losRadius = 11.375, wreckName = "", sonarRadius = 0, metalCost = 154, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, zsize = 4, buildOptions = true, mtype = "air", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armcv"] = { radarRadius = 50, techLevel = 2, isBuilding = false, factoriesCanBuild = { "armavp", "armlab", "armvp", "armap", "armhp", "armsy", }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 2.96484375, losRadius = 7.90625, wreckName = "armcv_dead", sonarRadius = 0, metalCost = 128, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, zsize = 6, buildOptions = true, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armcybr"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.33203125, losRadius = 14.21875, sonarRadius = 0, metalCost = 2103, xsize = 6, totalEnergyOut = -40, jammerRadius = 0, wreckName = "", zsize = 6, mtype = "air", airRange = 0, submergedRange = 0, stealth = false, groundRange = 500, isWeapon = true, } @@ -74,7 +74,7 @@ unitTable["armflak"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 7.8125, losRadius = 16.40625, sonarRadius = 0, metalCost = 769, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armflak_dead", zsize = 4, mtype = "veh", airRange = 775, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = true, } unitTable["armflash"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.50390625, losRadius = 9.34375, sonarRadius = 0, metalCost = 109, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armflash_dead", zsize = 4, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 180, isWeapon = true, } unitTable["armflea"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 6.4453125, losRadius = 17.1875, sonarRadius = 0, metalCost = 14, xsize = 2, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armflea_dead", zsize = 2, mtype = "bot", airRange = 0, submergedRange = 0, stealth = false, groundRange = 140, isWeapon = true, } -unitTable["armfmine3"] = { radarRadius = 0, techLevel = 5, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 0.9140625, losRadius = 2.4375, sonarRadius = 0, metalCost = 25, xsize = 2, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 2, mtype = "veh", airRange = 0, submergedRange = 0, stealth = true, groundRange = 64, isWeapon = true, } +unitTable["armfmine3"] = { radarRadius = 0, techLevel = 5, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 0.9140625, losRadius = 2.4375, sonarRadius = 0, metalCost = 25, xsize = 2, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 2, mtype = "hov", airRange = 0, submergedRange = 0, stealth = true, groundRange = 64, isWeapon = true, } unitTable["armfmkr"] = { radarRadius = 0, techLevel = 1, isBuilding = true, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.19921875, losRadius = 8.53125, sonarRadius = 0, metalCost = 1, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 6, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armfort"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 1.5234375, losRadius = 4.0625, sonarRadius = 0, metalCost = 37, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armfort_fortification", zsize = 4, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armfrad"] = { radarRadius = 2100, techLevel = 1, isBuilding = true, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 8.90625, losRadius = 23.75, sonarRadius = 0, metalCost = 127, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armfrad_dead", zsize = 6, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } @@ -108,11 +108,11 @@ unitTable["armmine1"] = { radarRadius = 0, techLevel = 3, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 0.97499996423721, losRadius = 2.5999999046326, sonarRadius = 0, metalCost = 5, xsize = 2, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 2, mtype = "veh", airRange = 0, submergedRange = 0, stealth = true, groundRange = 64, isWeapon = true, } unitTable["armmine2"] = { radarRadius = 0, techLevel = 5, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 0.97499996423721, losRadius = 2.5999999046326, sonarRadius = 0, metalCost = 15, xsize = 2, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 2, mtype = "veh", airRange = 0, submergedRange = 0, stealth = true, groundRange = 64, isWeapon = true, } unitTable["armmine3"] = { radarRadius = 0, techLevel = 3, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 0.97499996423721, losRadius = 2.5999999046326, sonarRadius = 0, metalCost = 20, xsize = 2, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 2, mtype = "veh", airRange = 0, submergedRange = 0, stealth = true, groundRange = 64, isWeapon = true, } -unitTable["armmls"] = { radarRadius = 0, techLevel = 4, isBuilding = false, factoriesCanBuild = { "armsy", "armfhp", "asubpen", }, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.046875, losRadius = 8.125, wreckName = "armmls_dead", sonarRadius = 0, metalCost = 213, xsize = 6, totalEnergyOut = 5.5, jammerRadius = 0, zsize = 6, buildOptions = true, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } +unitTable["armmls"] = { radarRadius = 0, techLevel = 4, isBuilding = false, factoriesCanBuild = { "armsy", "armfhp", "asubpen", }, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.046875, losRadius = 8.125, wreckName = "armmls_dead", sonarRadius = 0, metalCost = 213, xsize = 6, totalEnergyOut = 5, jammerRadius = 0, zsize = 6, buildOptions = true, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armmlv"] = { radarRadius = 0, techLevel = 2, isBuilding = false, factoriesCanBuild = { }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 2.35546875, losRadius = 6.28125, wreckName = "armmlv_dead", sonarRadius = 0, metalCost = 53, xsize = 4, totalEnergyOut = 0, jammerRadius = 64, zsize = 4, buildOptions = true, mtype = "veh", airRange = 0, submergedRange = 0, stealth = true, groundRange = 200, isWeapon = false, } unitTable["armmmkr"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.19921875, losRadius = 8.53125, sonarRadius = 0, metalCost = 358, xsize = 8, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armmmkr_dead", zsize = 8, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armmoho"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0.0040000001899898, bigExplosion = false, airLosRadius = 3.19921875, losRadius = 8.53125, sonarRadius = 0, metalCost = 582, xsize = 10, totalEnergyOut = -25, jammerRadius = 0, wreckName = "armmoho_dead", zsize = 10, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } -unitTable["armmship"] = { radarRadius = 1400, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.732421875, losRadius = 9.953125, sonarRadius = 0, metalCost = 2648, xsize = 8, totalEnergyOut = 5.5, jammerRadius = 0, wreckName = "armmship_dead", zsize = 8, mtype = "shp", airRange = 710, submergedRange = 0, stealth = false, groundRange = 1550, isWeapon = true, } +unitTable["armmship"] = { radarRadius = 1400, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.732421875, losRadius = 9.953125, sonarRadius = 0, metalCost = 2648, xsize = 8, totalEnergyOut = 5, jammerRadius = 0, wreckName = "armmship_dead", zsize = 8, mtype = "shp", airRange = 710, submergedRange = 0, stealth = false, groundRange = 1550, isWeapon = true, } unitTable["armmstor"] = { radarRadius = 0, techLevel = 1, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.19921875, losRadius = 8.53125, sonarRadius = 0, metalCost = 305, xsize = 8, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armmstor_dead", zsize = 8, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armnanotc"] = { radarRadius = 0, techLevel = 3, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.453125, losRadius = 11.875, sonarRadius = 0, metalCost = 197, xsize = 6, totalEnergyOut = -30, jammerRadius = 0, wreckName = "", zsize = 6, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armorco"] = { radarRadius = 0, techLevel = -1, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 10.6640625, losRadius = 28.4375, sonarRadius = 0, metalCost = 35467, xsize = 10, totalEnergyOut = 40, jammerRadius = 0, wreckName = "armorco_dead", zsize = 10, mtype = "bot", airRange = 775, submergedRange = 0, stealth = false, groundRange = 925, isWeapon = true, } @@ -121,7 +121,7 @@ unitTable["armpincer"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 2.8125, losRadius = 7.5, sonarRadius = 0, metalCost = 187, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armpincer_dead", zsize = 6, mtype = "amp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 305, isWeapon = true, } unitTable["armplat"] = { radarRadius = 50, techLevel = 3, isBuilding = true, factoriesCanBuild = { }, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 1.98046875, losRadius = 5.28125, wreckName = "armplat_dead", sonarRadius = 0, metalCost = 2667, xsize = 14, totalEnergyOut = 0, jammerRadius = 0, zsize = 14, buildOptions = true, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armpnix"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.046875, losRadius = 8.125, sonarRadius = 0, metalCost = 229, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 6, mtype = "air", airRange = 0, submergedRange = 0, stealth = false, groundRange = 1280, isWeapon = true, } -unitTable["armpt"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 6.25, losRadius = 20.3125, sonarRadius = 0, metalCost = 100, xsize = 4, totalEnergyOut = 5.5, jammerRadius = 0, wreckName = "armpt_dead", zsize = 4, mtype = "shp", airRange = 760, submergedRange = 0, stealth = false, groundRange = 260, isWeapon = true, } +unitTable["armpt"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 6.25, losRadius = 20.3125, sonarRadius = 0, metalCost = 100, xsize = 4, totalEnergyOut = 5, jammerRadius = 0, wreckName = "armpt_dead", zsize = 4, mtype = "shp", airRange = 760, submergedRange = 0, stealth = false, groundRange = 260, isWeapon = true, } unitTable["armptl"] = { radarRadius = 0, techLevel = 1, isBuilding = true, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.515625, losRadius = 9.375, sonarRadius = 0, metalCost = 302, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armptl_dead", zsize = 6, mtype = "sub", airRange = 0, submergedRange = 550, stealth = false, groundRange = 0, isWeapon = true, } unitTable["armpw"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.02734375, losRadius = 13.40625, sonarRadius = 0, metalCost = 45, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armpw_dead", zsize = 4, mtype = "bot", airRange = 0, submergedRange = 0, stealth = false, groundRange = 180, isWeapon = true, } unitTable["armrad"] = { radarRadius = 2100, techLevel = 1, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 7.96875, losRadius = 21.25, sonarRadius = 0, metalCost = 54, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armrad_dead", zsize = 4, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } @@ -131,7 +131,7 @@ unitTable["armrectr"] = { radarRadius = 50, techLevel = 2, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.0390625, losRadius = 13.4375, sonarRadius = 0, metalCost = 102, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armrectr_dead", zsize = 4, mtype = "bot", airRange = 0, submergedRange = 0, stealth = true, groundRange = 0, isWeapon = false, } unitTable["armrl"] = { radarRadius = 0, techLevel = 1, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.46875, losRadius = 14.21875, sonarRadius = 0, metalCost = 79, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armrl_dead", zsize = 6, mtype = "veh", airRange = 765, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = true, } unitTable["armrock"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.9609375, losRadius = 10.5625, sonarRadius = 0, metalCost = 97, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armrock_dead", zsize = 4, mtype = "bot", airRange = 0, submergedRange = 0, stealth = false, groundRange = 475, isWeapon = true, } -unitTable["armroy"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.7421875, losRadius = 15.3125, sonarRadius = 400, metalCost = 987, xsize = 6, totalEnergyOut = 5.5, jammerRadius = 0, wreckName = "armroy_dead", zsize = 6, mtype = "shp", airRange = 0, submergedRange = 400, stealth = false, groundRange = 700, isWeapon = true, } +unitTable["armroy"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.7421875, losRadius = 15.3125, sonarRadius = 400, metalCost = 987, xsize = 6, totalEnergyOut = 5, jammerRadius = 0, wreckName = "armroy_dead", zsize = 6, mtype = "shp", airRange = 0, submergedRange = 400, stealth = false, groundRange = 700, isWeapon = true, } unitTable["armsaber"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 6.97265625, losRadius = 18.59375, sonarRadius = 0, metalCost = 192, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 6, mtype = "air", airRange = 0, submergedRange = 0, stealth = false, groundRange = 420, isWeapon = true, } unitTable["armsam"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 7.03125, losRadius = 19.375, sonarRadius = 0, metalCost = 140, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armsam_dead", zsize = 6, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 600, isWeapon = true, } unitTable["armsb"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.33203125, losRadius = 14.21875, sonarRadius = 0, metalCost = 169, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 6, mtype = "air", airRange = 0, submergedRange = 0, stealth = false, groundRange = 1280, isWeapon = true, } @@ -145,7 +145,7 @@ unitTable["armshltx"] = { radarRadius = 0, techLevel = 5, isBuilding = true, factoriesCanBuild = { }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.19921875, losRadius = 8.53125, wreckName = "armshltx_armshlt_dead", sonarRadius = 0, metalCost = 7396, xsize = 18, totalEnergyOut = 0, jammerRadius = 0, zsize = 18, buildOptions = true, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armshock"] = { radarRadius = 0, techLevel = 6, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 7.32421875, losRadius = 19.53125, sonarRadius = 0, metalCost = 3120, xsize = 8, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armshock_dead", zsize = 8, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 1325, isWeapon = true, } unitTable["armsilo"] = { radarRadius = 50, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = true, airLosRadius = 5.33203125, losRadius = 14.21875, sonarRadius = 0, metalCost = 7625, xsize = 14, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armsilo_dead", zsize = 14, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 72000, isWeapon = true, } -unitTable["armsjam"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.5703125, losRadius = 12.1875, sonarRadius = 0, metalCost = 131, xsize = 6, totalEnergyOut = 5.5, jammerRadius = 980, wreckName = "armsjam_dead", zsize = 6, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 800, isWeapon = false, } +unitTable["armsjam"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.5703125, losRadius = 12.1875, sonarRadius = 0, metalCost = 131, xsize = 6, totalEnergyOut = 5, jammerRadius = 980, wreckName = "armsjam_dead", zsize = 6, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 800, isWeapon = false, } unitTable["armsl"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.046875, losRadius = 8.125, sonarRadius = 0, metalCost = 344, xsize = 8, totalEnergyOut = 3, jammerRadius = 0, wreckName = "", zsize = 8, mtype = "air", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armsnipe"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.33203125, losRadius = 14.21875, sonarRadius = 0, metalCost = 535, xsize = 4, totalEnergyOut = 0, jammerRadius = 10, wreckName = "armsnipe_dead", zsize = 4, mtype = "bot", airRange = 0, submergedRange = 0, stealth = false, groundRange = 900, isWeapon = true, } unitTable["armsolar"] = { radarRadius = 0, techLevel = 1, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.19921875, losRadius = 8.53125, sonarRadius = 0, metalCost = 145, xsize = 10, totalEnergyOut = 20, jammerRadius = 0, wreckName = "armsolar_dead", zsize = 10, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } @@ -161,9 +161,9 @@ unitTable["armtarg"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.19921875, losRadius = 8.53125, sonarRadius = 0, metalCost = 757, xsize = 8, totalEnergyOut = -100, jammerRadius = 0, wreckName = "armtarg_dead", zsize = 8, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armthovr"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.80859375, losRadius = 10.15625, sonarRadius = 0, metalCost = 665, xsize = 8, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armthovr_dead", zsize = 8, mtype = "hov", airRange = 0, submergedRange = 0, stealth = false, groundRange = 400, isWeapon = true, } unitTable["armthund"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 2.28515625, losRadius = 6.09375, sonarRadius = 0, metalCost = 145, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 6, mtype = "air", airRange = 0, submergedRange = 0, stealth = false, groundRange = 1280, isWeapon = true, } -unitTable["armtide"] = { radarRadius = 0, techLevel = 1, isBuilding = true, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 1.5234375, losRadius = 4.0625, sonarRadius = 0, metalCost = 82, xsize = 6, totalEnergyOut = 18, jammerRadius = 0, wreckName = "armtide_dead", zsize = 6, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } +unitTable["armtide"] = { radarRadius = 0, techLevel = 1, isBuilding = true, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 1.5234375, losRadius = 4.0625, sonarRadius = 0, metalCost = 82, xsize = 6, totalEnergyOut = 21, jammerRadius = 0, wreckName = "armtide_dead", zsize = 6, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armtl"] = { radarRadius = 0, techLevel = 3, isBuilding = true, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.33203125, losRadius = 14.21875, sonarRadius = 0, metalCost = 302, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armtl_dead", zsize = 6, mtype = "shp", airRange = 0, submergedRange = 550, stealth = false, groundRange = 0, isWeapon = true, } -unitTable["armtship"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 6.4453125, losRadius = 17.1875, sonarRadius = 0, metalCost = 735, xsize = 8, totalEnergyOut = 5.5, jammerRadius = 0, wreckName = "armtship_dead", zsize = 8, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = true, } +unitTable["armtship"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 6.4453125, losRadius = 17.1875, sonarRadius = 0, metalCost = 735, xsize = 8, totalEnergyOut = 5, jammerRadius = 0, wreckName = "armtship_dead", zsize = 8, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = true, } unitTable["armuwadves"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = true, airLosRadius = 1.98046875, losRadius = 5.28125, sonarRadius = 0, metalCost = 773, xsize = 8, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armuwadves_dead", zsize = 8, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armuwadvms"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 2.28515625, losRadius = 6.09375, sonarRadius = 0, metalCost = 705, xsize = 8, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armuwadvms_dead", zsize = 8, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armuwes"] = { radarRadius = 0, techLevel = 1, isBuilding = true, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 2.1328125, losRadius = 5.6875, sonarRadius = 0, metalCost = 284, xsize = 8, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armuwes_dead", zsize = 8, mtype = "sub", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } @@ -177,10 +177,10 @@ unitTable["armvp"] = { radarRadius = 50, techLevel = 1, isBuilding = true, factoriesCanBuild = { }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.19921875, losRadius = 8.53125, wreckName = "armvp_dead", sonarRadius = 0, metalCost = 743, xsize = 16, totalEnergyOut = 0, jammerRadius = 0, zsize = 12, buildOptions = true, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armvulc"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 8.203125, losRadius = 21.875, sonarRadius = 0, metalCost = 42363, xsize = 16, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armvulc_dead", zsize = 16, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 5750, isWeapon = true, } unitTable["armwar"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.1015625, losRadius = 10.9375, sonarRadius = 0, metalCost = 248, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armwar_dead", zsize = 4, mtype = "bot", airRange = 0, submergedRange = 0, stealth = false, groundRange = 330, isWeapon = true, } -unitTable["armwin"] = { radarRadius = 0, techLevel = 1, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.19921875, losRadius = 8.53125, sonarRadius = 0, metalCost = 35, xsize = 6, totalEnergyOut = 5.5, jammerRadius = 0, wreckName = "armwin_dead", zsize = 6, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } +unitTable["armwin"] = { radarRadius = 0, techLevel = 1, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.19921875, losRadius = 8.53125, sonarRadius = 0, metalCost = 35, xsize = 6, totalEnergyOut = 5, jammerRadius = 0, wreckName = "armwin_dead", zsize = 6, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["armyork"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 7.03125, losRadius = 12.1875, sonarRadius = 0, metalCost = 425, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "armyork_dead", zsize = 6, mtype = "veh", airRange = 800, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = true, } unitTable["armzeus"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.884765625, losRadius = 10.359375, sonarRadius = 0, metalCost = 329, xsize = 4, totalEnergyOut = 3.5, jammerRadius = 0, wreckName = "armzeus_dead", zsize = 4, mtype = "bot", airRange = 0, submergedRange = 0, stealth = false, groundRange = 280, isWeapon = true, } -unitTable["aseadragon"] = { radarRadius = 1530, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = true, airLosRadius = 8.07421875, losRadius = 21.53125, sonarRadius = 0, metalCost = 32122, xsize = 12, totalEnergyOut = 5.5, jammerRadius = 0, wreckName = "aseadragon_dead", zsize = 12, mtype = "shp", airRange = 775, submergedRange = 0, stealth = false, groundRange = 2450, isWeapon = true, } +unitTable["aseadragon"] = { radarRadius = 1530, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = true, airLosRadius = 8.07421875, losRadius = 21.53125, sonarRadius = 0, metalCost = 32122, xsize = 12, totalEnergyOut = 5, jammerRadius = 0, wreckName = "aseadragon_dead", zsize = 12, mtype = "shp", airRange = 775, submergedRange = 0, stealth = false, groundRange = 2450, isWeapon = true, } unitTable["asubpen"] = { radarRadius = 0, techLevel = 3, isBuilding = true, factoriesCanBuild = { }, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 2.7421875, losRadius = 7.3125, wreckName = "asubpen_dead", sonarRadius = 0, metalCost = 1118, xsize = 16, totalEnergyOut = 0, jammerRadius = 0, zsize = 16, buildOptions = true, mtype = "sub", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["blade"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 7.3125, losRadius = 19.5, sonarRadius = 0, metalCost = 1192, xsize = 4, totalEnergyOut = -0.099999964237213, jammerRadius = 0, wreckName = "", zsize = 4, mtype = "air", airRange = 0, submergedRange = 0, stealth = false, groundRange = 420, isWeapon = true, } unitTable["bladew"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.265625, losRadius = 11.375, sonarRadius = 0, metalCost = 54, xsize = 4, totalEnergyOut = 2, jammerRadius = 0, wreckName = "", zsize = 4, mtype = "air", airRange = 0, submergedRange = 0, stealth = false, groundRange = 220, isWeapon = true, } @@ -203,27 +203,27 @@ unitTable["corap"] = { radarRadius = 510, techLevel = 1, isBuilding = true, factoriesCanBuild = { }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.19921875, losRadius = 8.53125, wreckName = "corap_dead", sonarRadius = 0, metalCost = 830, xsize = 16, totalEnergyOut = 0, jammerRadius = 0, zsize = 12, buildOptions = true, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["corape"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 6.4453125, losRadius = 17.1875, sonarRadius = 0, metalCost = 345, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 6, mtype = "air", airRange = 0, submergedRange = 0, stealth = false, groundRange = 410, isWeapon = true, } unitTable["corarad"] = { radarRadius = 3500, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 9.140625, losRadius = 24.375, sonarRadius = 0, metalCost = 522, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corarad_dead", zsize = 4, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } -unitTable["corarch"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 7.03125, losRadius = 14.53125, sonarRadius = 0, metalCost = 614, xsize = 6, totalEnergyOut = 5.5, jammerRadius = 0, wreckName = "corarch_dead", zsize = 6, mtype = "shp", airRange = 840, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = true, } +unitTable["corarch"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 7.03125, losRadius = 14.53125, sonarRadius = 0, metalCost = 614, xsize = 6, totalEnergyOut = 5, jammerRadius = 0, wreckName = "corarch_dead", zsize = 6, mtype = "shp", airRange = 840, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = true, } unitTable["corason"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 2.4609375, losRadius = 6.5625, sonarRadius = 2400, metalCost = 152, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corason_dead", zsize = 6, mtype = "sub", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["corasp"] = { radarRadius = 0, techLevel = 3, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.189453125, losRadius = 11.171875, sonarRadius = 0, metalCost = 378, xsize = 18, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corasp_dead", zsize = 18, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["corasy"] = { radarRadius = 50, techLevel = 3, isBuilding = true, factoriesCanBuild = { }, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.5343751907349, losRadius = 9.4250001907349, wreckName = "corasy_dead", sonarRadius = 0, metalCost = 3345, xsize = 24, totalEnergyOut = 25, jammerRadius = 0, zsize = 24, buildOptions = true, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["coratl"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 6.85546875, losRadius = 18.28125, sonarRadius = 0, metalCost = 1079, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "coratl_dead", zsize = 6, mtype = "shp", airRange = 0, submergedRange = 890, stealth = false, groundRange = 0, isWeapon = true, } unitTable["coravp"] = { radarRadius = 50, techLevel = 3, isBuilding = true, factoriesCanBuild = { }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.3515625, losRadius = 8.9375, wreckName = "coravp_dead", sonarRadius = 0, metalCost = 2647, xsize = 18, totalEnergyOut = 0, jammerRadius = 0, zsize = 14, buildOptions = true, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["corawac"] = { radarRadius = 2400, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 14.6484375, losRadius = 39.0625, sonarRadius = 1200, metalCost = 169, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 6, mtype = "air", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } -unitTable["corbats"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.33203125, losRadius = 14.21875, sonarRadius = 0, metalCost = 5404, xsize = 12, totalEnergyOut = 7.5, jammerRadius = 0, wreckName = "corbats_dead", zsize = 12, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 1320, isWeapon = true, } +unitTable["corbats"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.33203125, losRadius = 14.21875, sonarRadius = 0, metalCost = 5404, xsize = 12, totalEnergyOut = 7, jammerRadius = 0, wreckName = "corbats_dead", zsize = 12, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 1320, isWeapon = true, } unitTable["corbhmth"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 7.6171875, losRadius = 20.3125, sonarRadius = 0, metalCost = 2949, xsize = 10, totalEnergyOut = 450, jammerRadius = 0, wreckName = "corbhmth_dead", zsize = 10, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 1650, isWeapon = true, } -unitTable["corblackhy"] = { radarRadius = 1510, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = true, airLosRadius = 7.6171875, losRadius = 20.3125, sonarRadius = 0, metalCost = 34585, xsize = 12, totalEnergyOut = -9.5, jammerRadius = 0, wreckName = "corblackhy_dead", zsize = 12, mtype = "shp", airRange = 950, submergedRange = 0, stealth = false, groundRange = 2450, isWeapon = true, } +unitTable["corblackhy"] = { radarRadius = 1510, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = true, airLosRadius = 7.6171875, losRadius = 20.3125, sonarRadius = 0, metalCost = 34585, xsize = 12, totalEnergyOut = -10, jammerRadius = 0, wreckName = "corblackhy_dead", zsize = 12, mtype = "shp", airRange = 950, submergedRange = 0, stealth = false, groundRange = 2450, isWeapon = true, } unitTable["corbuzz"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 8.203125, losRadius = 21.875, sonarRadius = 0, metalCost = 40575, xsize = 16, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corbuzz_dead", zsize = 16, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 6100, isWeapon = true, } unitTable["corca"] = { radarRadius = 50, techLevel = 2, isBuilding = false, factoriesCanBuild = { "coraap", "corlab", "corvp", "corap", "corhp", "corsy", }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.11328125, losRadius = 10.96875, wreckName = "", sonarRadius = 0, metalCost = 110, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, zsize = 6, buildOptions = true, mtype = "air", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["corcan"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.1015625, losRadius = 10.9375, sonarRadius = 0, metalCost = 522, xsize = 4, totalEnergyOut = 7.5, jammerRadius = 0, wreckName = "corcan_dead", zsize = 4, mtype = "bot", airRange = 0, submergedRange = 0, stealth = false, groundRange = 275, isWeapon = true, } -unitTable["corcarry"] = { radarRadius = 2700, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 12.1875, losRadius = 32.5, sonarRadius = 740, metalCost = 1600, xsize = 12, totalEnergyOut = 230.5, jammerRadius = 0, wreckName = "corcarry_dead", zsize = 12, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 72000, isWeapon = false, } +unitTable["corcarry"] = { radarRadius = 2700, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 12.1875, losRadius = 32.5, sonarRadius = 740, metalCost = 1600, xsize = 12, totalEnergyOut = 230, jammerRadius = 0, wreckName = "corcarry_dead", zsize = 12, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 72000, isWeapon = false, } unitTable["corch"] = { radarRadius = 50, techLevel = 4, isBuilding = false, factoriesCanBuild = { "corlab", "corvp", "corap", "corhp", "corfhp", "corsy", "csubpen", }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.9609375, losRadius = 10.5625, wreckName = "corch_dead", sonarRadius = 0, metalCost = 154, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, zsize = 6, buildOptions = true, mtype = "hov", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["corck"] = { radarRadius = 0, techLevel = 2, isBuilding = false, factoriesCanBuild = { "coralab", "corlab", "corvp", "corap", "corhp", "corsy", }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.50390625, losRadius = 9.34375, wreckName = "corck_dead", sonarRadius = 0, metalCost = 113, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, zsize = 4, buildOptions = true, mtype = "bot", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["corcom"] = { radarRadius = 700, techLevel = 0, isBuilding = false, factoriesCanBuild = { "corlab", "corvp", "corap", "corsy", }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.2734375, losRadius = 14.0625, wreckName = "corcom_dead", sonarRadius = 300, metalCost = 2500, xsize = 4, totalEnergyOut = 25, jammerRadius = 0, zsize = 4, buildOptions = true, mtype = "veh", airRange = 0, submergedRange = 260, stealth = false, groundRange = 300, isWeapon = true, } unitTable["corcrash"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 6.25, losRadius = 11.862500190735, sonarRadius = 0, metalCost = 116, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corcrash_dead", zsize = 4, mtype = "bot", airRange = 800, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = true, } -unitTable["corcrus"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 6.24609375, losRadius = 16.65625, sonarRadius = 375, metalCost = 1794, xsize = 8, totalEnergyOut = 5.5, jammerRadius = 0, wreckName = "corcrus_dead", zsize = 8, mtype = "shp", airRange = 0, submergedRange = 500, stealth = false, groundRange = 785, isWeapon = true, } +unitTable["corcrus"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 6.24609375, losRadius = 16.65625, sonarRadius = 375, metalCost = 1794, xsize = 8, totalEnergyOut = 5, jammerRadius = 0, wreckName = "corcrus_dead", zsize = 8, mtype = "shp", airRange = 0, submergedRange = 500, stealth = false, groundRange = 785, isWeapon = true, } unitTable["corcrw"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.7890625, losRadius = 15.4375, sonarRadius = 0, metalCost = 4758, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 6, mtype = "air", airRange = 0, submergedRange = 0, stealth = false, groundRange = 575, isWeapon = true, } -unitTable["corcs"] = { radarRadius = 0, techLevel = 2, isBuilding = false, factoriesCanBuild = { "corsy", "corasy", "corfhp", "csubpen", "corplat", }, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.3515625, losRadius = 8.9375, wreckName = "corcs_dead", sonarRadius = 0, metalCost = 260, xsize = 6, totalEnergyOut = 20.5, jammerRadius = 0, zsize = 6, buildOptions = true, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } +unitTable["corcs"] = { radarRadius = 0, techLevel = 2, isBuilding = false, factoriesCanBuild = { "corsy", "corasy", "corfhp", "csubpen", "corplat", }, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.3515625, losRadius = 8.9375, wreckName = "corcs_dead", sonarRadius = 0, metalCost = 260, xsize = 6, totalEnergyOut = 20, jammerRadius = 0, zsize = 6, buildOptions = true, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["corcsa"] = { radarRadius = 50, techLevel = 4, isBuilding = false, factoriesCanBuild = { "corap", "coraap", "corplat", "corsy", "corasy", }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.11328125, losRadius = 10.96875, wreckName = "", sonarRadius = 0, metalCost = 156, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, zsize = 4, buildOptions = true, mtype = "air", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["corcut"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 6.97265625, losRadius = 18.59375, sonarRadius = 0, metalCost = 220, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 6, mtype = "air", airRange = 0, submergedRange = 0, stealth = false, groundRange = 430, isWeapon = true, } unitTable["corcv"] = { radarRadius = 50, techLevel = 2, isBuilding = false, factoriesCanBuild = { "coravp", "corlab", "corvp", "corap", "corhp", "corsy", }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.046875, losRadius = 8.125, wreckName = "corcv_dead", sonarRadius = 0, metalCost = 134, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, zsize = 6, buildOptions = true, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } @@ -232,9 +232,9 @@ unitTable["cordoom"] = { radarRadius = 1200, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 9.140625, losRadius = 24.375, sonarRadius = 0, metalCost = 2478, xsize = 8, totalEnergyOut = 0, jammerRadius = 0, wreckName = "cordoom_dead", zsize = 8, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 950, isWeapon = true, } unitTable["cordrag"] = { radarRadius = 0, techLevel = 1, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 1.5234375, losRadius = 4.0625, sonarRadius = 0, metalCost = 10, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, wreckName = "cordrag_dragonsteeth_core", zsize = 4, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["corenaa"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 7.8125, losRadius = 17.1875, sonarRadius = 0, metalCost = 832, xsize = 8, totalEnergyOut = -0.10000000149012, jammerRadius = 0, wreckName = "corenaa_dead", zsize = 8, mtype = "shp", airRange = 775, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = true, } -unitTable["corerad"] = { radarRadius = 0, techLevel = 3, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 7.8125, losRadius = 10.9375, sonarRadius = 0, metalCost = 748, xsize = 8, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corerad_dead", zsize = 8, mtype = "veh", airRange = 1250, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = true, } +unitTable["corerad"] = { radarRadius = 0, techLevel = 3, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 7.8125, losRadius = 10.9375, sonarRadius = 0, metalCost = 748, xsize = 8, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corerad_dead", zsize = 8, mtype = "veh", airRange = 1045, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = true, } unitTable["corestor"] = { radarRadius = 0, techLevel = 1, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.19921875, losRadius = 8.53125, sonarRadius = 0, metalCost = 166, xsize = 8, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corestor_dead", zsize = 8, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } -unitTable["coresupp"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.02734375, losRadius = 13.40625, sonarRadius = 0, metalCost = 294, xsize = 6, totalEnergyOut = 8.5, jammerRadius = 0, wreckName = "coresupp_dead", zsize = 6, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 320, isWeapon = true, } +unitTable["coresupp"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.02734375, losRadius = 13.40625, sonarRadius = 0, metalCost = 294, xsize = 6, totalEnergyOut = 8, jammerRadius = 0, wreckName = "coresupp_dead", zsize = 6, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 320, isWeapon = true, } unitTable["coreter"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.50390625, losRadius = 9.34375, sonarRadius = 0, metalCost = 100, xsize = 6, totalEnergyOut = -100, jammerRadius = 450, wreckName = "coreter_dead", zsize = 6, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 800, isWeapon = false, } unitTable["corexp"] = { radarRadius = 0, techLevel = 3, isBuilding = true, needsWater = false, extractsMetal = 0.0010000000474975, bigExplosion = false, airLosRadius = 5.33203125, losRadius = 14.21875, sonarRadius = 0, metalCost = 220, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corexp_dead", zsize = 6, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 430, isWeapon = false, } unitTable["coreyes"] = { radarRadius = 0, techLevel = 1, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 6.328125, losRadius = 16.875, sonarRadius = 0, metalCost = 30, xsize = 2, totalEnergyOut = -5, jammerRadius = 0, wreckName = "coreyes_cdragonseyes_dead", zsize = 2, mtype = "veh", airRange = 0, submergedRange = 0, stealth = true, groundRange = 0, isWeapon = false, } @@ -248,7 +248,7 @@ unitTable["corfink"] = { radarRadius = 1120, techLevel = 2, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 9.78515625, losRadius = 26.09375, sonarRadius = 0, metalCost = 26, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 4, mtype = "air", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["corflak"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 7.8125, losRadius = 16.40625, sonarRadius = 0, metalCost = 792, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corflak_dead", zsize = 4, mtype = "veh", airRange = 775, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = true, } unitTable["corfmd"] = { radarRadius = 50, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 2.28515625, losRadius = 6.09375, sonarRadius = 0, metalCost = 1400, xsize = 8, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corfmd_dead", zsize = 8, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 72000, isWeapon = true, } -unitTable["corfmine3"] = { radarRadius = 0, techLevel = 5, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 0.837890625, losRadius = 2.234375, sonarRadius = 0, metalCost = 25, xsize = 2, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 2, mtype = "veh", airRange = 0, submergedRange = 0, stealth = true, groundRange = 64, isWeapon = true, } +unitTable["corfmine3"] = { radarRadius = 0, techLevel = 5, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 0.837890625, losRadius = 2.234375, sonarRadius = 0, metalCost = 25, xsize = 2, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 2, mtype = "hov", airRange = 0, submergedRange = 0, stealth = true, groundRange = 64, isWeapon = true, } unitTable["corfmkr"] = { radarRadius = 0, techLevel = 1, isBuilding = true, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.19921875, losRadius = 8.53125, sonarRadius = 0, metalCost = 1, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 6, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["corfort"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 1.5234375, losRadius = 4.0625, sonarRadius = 0, metalCost = 36, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corfort_fortification_core", zsize = 4, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["corfrad"] = { radarRadius = 2100, techLevel = 1, isBuilding = true, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 8.671875, losRadius = 23.125, sonarRadius = 0, metalCost = 123, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corfrad_dead", zsize = 6, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } @@ -283,20 +283,21 @@ unitTable["cormine1"] = { radarRadius = 0, techLevel = 3, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 0.97499996423721, losRadius = 2.5999999046326, sonarRadius = 0, metalCost = 5, xsize = 2, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 2, mtype = "veh", airRange = 0, submergedRange = 0, stealth = true, groundRange = 64, isWeapon = true, } unitTable["cormine2"] = { radarRadius = 0, techLevel = 5, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 0.97499996423721, losRadius = 2.5999999046326, sonarRadius = 0, metalCost = 15, xsize = 2, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 2, mtype = "veh", airRange = 0, submergedRange = 0, stealth = true, groundRange = 64, isWeapon = true, } unitTable["cormine3"] = { radarRadius = 0, techLevel = 3, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 0.97499996423721, losRadius = 2.5999999046326, sonarRadius = 0, metalCost = 20, xsize = 2, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 2, mtype = "veh", airRange = 0, submergedRange = 0, stealth = true, groundRange = 64, isWeapon = true, } +unitTable["cormine4"] = { radarRadius = 0, techLevel = 5, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 0.97499996423721, losRadius = 2.5999999046326, sonarRadius = 0, metalCost = 15, xsize = 2, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 2, mtype = "veh", airRange = 0, submergedRange = 0, stealth = true, groundRange = 64, isWeapon = true, } unitTable["cormist"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 7.03125, losRadius = 19.375, sonarRadius = 0, metalCost = 146, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "cormist_dead", zsize = 6, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 600, isWeapon = true, } -unitTable["cormls"] = { radarRadius = 0, techLevel = 4, isBuilding = false, factoriesCanBuild = { "corsy", "corfhp", "csubpen", }, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.046875, losRadius = 8.125, wreckName = "cormls_dead", sonarRadius = 0, metalCost = 241, xsize = 6, totalEnergyOut = 5.5, jammerRadius = 0, zsize = 6, buildOptions = true, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } +unitTable["cormls"] = { radarRadius = 0, techLevel = 4, isBuilding = false, factoriesCanBuild = { "corsy", "corfhp", "csubpen", }, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.046875, losRadius = 8.125, wreckName = "cormls_dead", sonarRadius = 0, metalCost = 241, xsize = 6, totalEnergyOut = 5, jammerRadius = 0, zsize = 6, buildOptions = true, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["cormlv"] = { radarRadius = 0, techLevel = 2, isBuilding = false, factoriesCanBuild = { }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 2.203125, losRadius = 5.875, wreckName = "cormlv_dead", sonarRadius = 0, metalCost = 57, xsize = 4, totalEnergyOut = 0, jammerRadius = 64, zsize = 4, buildOptions = true, mtype = "veh", airRange = 0, submergedRange = 0, stealth = true, groundRange = 200, isWeapon = false, } unitTable["cormmkr"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.19921875, losRadius = 8.53125, sonarRadius = 0, metalCost = 351, xsize = 8, totalEnergyOut = 0, jammerRadius = 0, wreckName = "cormmkr_dead", zsize = 8, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["cormoho"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0.0040000001899898, bigExplosion = false, airLosRadius = 3.19921875, losRadius = 8.53125, sonarRadius = 0, metalCost = 598, xsize = 10, totalEnergyOut = -25, jammerRadius = 0, wreckName = "cormoho_dead", zsize = 10, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["cormort"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.515625, losRadius = 9.375, sonarRadius = 0, metalCost = 382, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, wreckName = "cormort_dead", zsize = 4, mtype = "bot", airRange = 0, submergedRange = 0, stealth = false, groundRange = 850, isWeapon = true, } -unitTable["cormship"] = { radarRadius = 1400, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.732421875, losRadius = 9.953125, sonarRadius = 0, metalCost = 2583, xsize = 8, totalEnergyOut = 5.5, jammerRadius = 0, wreckName = "cormship_dead", zsize = 8, mtype = "shp", airRange = 710, submergedRange = 0, stealth = false, groundRange = 1550, isWeapon = true, } +unitTable["cormship"] = { radarRadius = 1400, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.732421875, losRadius = 9.953125, sonarRadius = 0, metalCost = 2583, xsize = 8, totalEnergyOut = 5, jammerRadius = 0, wreckName = "cormship_dead", zsize = 8, mtype = "shp", airRange = 710, submergedRange = 0, stealth = false, groundRange = 1550, isWeapon = true, } unitTable["cormstor"] = { radarRadius = 0, techLevel = 1, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.19921875, losRadius = 8.53125, sonarRadius = 0, metalCost = 320, xsize = 10, totalEnergyOut = 0, jammerRadius = 0, wreckName = "cormstor_dead", zsize = 10, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["cormuskrat"] = { radarRadius = 0, techLevel = 2, isBuilding = false, factoriesCanBuild = { "corlab", "corvp", "corap", "corhp", "csubpen", "corsy", "csubpen", }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.046875, losRadius = 8.125, wreckName = "cormuskrat_dead", sonarRadius = 0, metalCost = 161, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, zsize = 6, buildOptions = true, mtype = "amp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["cornanotc"] = { radarRadius = 0, techLevel = 3, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.453125, losRadius = 11.875, sonarRadius = 0, metalCost = 197, xsize = 6, totalEnergyOut = -30, jammerRadius = 0, wreckName = "", zsize = 6, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["cornecro"] = { radarRadius = 50, techLevel = 2, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.0390625, losRadius = 13.4375, sonarRadius = 0, metalCost = 102, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, wreckName = "cornecro_dead", zsize = 4, mtype = "bot", airRange = 0, submergedRange = 0, stealth = true, groundRange = 0, isWeapon = false, } unitTable["corparrow"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.51171875, losRadius = 12.03125, sonarRadius = 0, metalCost = 988, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corparrow_dead", zsize = 6, mtype = "amp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 575, isWeapon = true, } unitTable["corplat"] = { radarRadius = 50, techLevel = 3, isBuilding = true, factoriesCanBuild = { }, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 1.98046875, losRadius = 5.28125, wreckName = "corplat_dead", sonarRadius = 0, metalCost = 2760, xsize = 14, totalEnergyOut = 0, jammerRadius = 0, zsize = 14, buildOptions = true, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } -unitTable["corpt"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 6.25, losRadius = 18.28125, sonarRadius = 0, metalCost = 95, xsize = 4, totalEnergyOut = 5.5, jammerRadius = 0, wreckName = "corpt_dead", zsize = 4, mtype = "shp", airRange = 760, submergedRange = 0, stealth = false, groundRange = 260, isWeapon = true, } +unitTable["corpt"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 6.25, losRadius = 18.28125, sonarRadius = 0, metalCost = 95, xsize = 4, totalEnergyOut = 5, jammerRadius = 0, wreckName = "corpt_dead", zsize = 4, mtype = "shp", airRange = 760, submergedRange = 0, stealth = false, groundRange = 260, isWeapon = true, } unitTable["corptl"] = { radarRadius = 0, techLevel = 1, isBuilding = true, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.515625, losRadius = 9.375, sonarRadius = 0, metalCost = 316, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corptl_dead", zsize = 6, mtype = "sub", airRange = 0, submergedRange = 550, stealth = false, groundRange = 0, isWeapon = true, } unitTable["corpun"] = { radarRadius = 0, techLevel = 3, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.33203125, losRadius = 14.21875, sonarRadius = 0, metalCost = 1468, xsize = 8, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corpun_dead", zsize = 8, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 1245, isWeapon = true, } unitTable["corpyro"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.7265625, losRadius = 9.9375, sonarRadius = 0, metalCost = 189, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corpyro_heap", zsize = 4, mtype = "bot", airRange = 0, submergedRange = 0, stealth = false, groundRange = 230, isWeapon = true, } @@ -306,7 +307,7 @@ unitTable["correcl"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.0390625, losRadius = 13.4375, sonarRadius = 270, metalCost = 395, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 4, mtype = "sub", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["corrl"] = { radarRadius = 0, techLevel = 1, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.46875, losRadius = 14.21875, sonarRadius = 0, metalCost = 76, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corrl_dead", zsize = 6, mtype = "veh", airRange = 765, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = true, } unitTable["corroach"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.046875, losRadius = 8.125, sonarRadius = 0, metalCost = 65, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 4, mtype = "bot", airRange = 0, submergedRange = 0, stealth = false, groundRange = 80, isWeapon = true, } -unitTable["corroy"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.7421875, losRadius = 15.3125, sonarRadius = 400, metalCost = 1021, xsize = 6, totalEnergyOut = 5.5, jammerRadius = 0, wreckName = "corroy_dead", zsize = 6, mtype = "shp", airRange = 0, submergedRange = 400, stealth = false, groundRange = 710, isWeapon = true, } +unitTable["corroy"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.7421875, losRadius = 15.3125, sonarRadius = 400, metalCost = 1021, xsize = 6, totalEnergyOut = 5, jammerRadius = 0, wreckName = "corroy_dead", zsize = 6, mtype = "shp", airRange = 0, submergedRange = 400, stealth = false, groundRange = 710, isWeapon = true, } unitTable["corsb"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.33203125, losRadius = 14.21875, sonarRadius = 0, metalCost = 182, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 6, mtype = "air", airRange = 0, submergedRange = 0, stealth = false, groundRange = 1280, isWeapon = true, } unitTable["corsd"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 2.63671875, losRadius = 7.03125, sonarRadius = 0, metalCost = 698, xsize = 8, totalEnergyOut = -125, jammerRadius = 0, wreckName = "corsd_dead", zsize = 8, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["corseal"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.67578125, losRadius = 12.46875, sonarRadius = 0, metalCost = 450, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corseal_dead", zsize = 6, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 440, isWeapon = true, } @@ -318,7 +319,7 @@ unitTable["corshark"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.5703125, losRadius = 12.1875, sonarRadius = 525, metalCost = 956, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corshark_dead", zsize = 6, mtype = "sub", airRange = 0, submergedRange = 600, stealth = false, groundRange = 0, isWeapon = true, } unitTable["corshroud"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 1.81640625, losRadius = 4.84375, sonarRadius = 0, metalCost = 124, xsize = 4, totalEnergyOut = -125, jammerRadius = 700, wreckName = "corshroud_dead", zsize = 4, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["corsilo"] = { radarRadius = 50, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = true, airLosRadius = 5.33203125, losRadius = 14.21875, sonarRadius = 0, metalCost = 7187, xsize = 14, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corsilo_dead", zsize = 14, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 72000, isWeapon = true, } -unitTable["corsjam"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.72265625, losRadius = 12.59375, sonarRadius = 0, metalCost = 135, xsize = 6, totalEnergyOut = 5.5, jammerRadius = 900, wreckName = "corsjam_dead", zsize = 6, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 800, isWeapon = false, } +unitTable["corsjam"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.72265625, losRadius = 12.59375, sonarRadius = 0, metalCost = 135, xsize = 6, totalEnergyOut = 5, jammerRadius = 900, wreckName = "corsjam_dead", zsize = 6, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 800, isWeapon = false, } unitTable["corsktl"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.046875, losRadius = 8.125, sonarRadius = 0, metalCost = 506, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 4, mtype = "bot", airRange = 0, submergedRange = 0, stealth = false, groundRange = 80, isWeapon = true, } unitTable["corsnap"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.75390625, losRadius = 15.34375, sonarRadius = 0, metalCost = 296, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corsnap_dead", zsize = 6, mtype = "hov", airRange = 0, submergedRange = 0, stealth = false, groundRange = 320, isWeapon = true, } unitTable["corsolar"] = { radarRadius = 0, techLevel = 1, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.19921875, losRadius = 8.53125, sonarRadius = 0, metalCost = 141, xsize = 10, totalEnergyOut = 20, jammerRadius = 0, wreckName = "corsolar_dead", zsize = 10, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } @@ -334,12 +335,12 @@ unitTable["cortermite"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.453125, losRadius = 11.875, sonarRadius = 0, metalCost = 725, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "cortermite_dead", zsize = 6, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 340, isWeapon = true, } unitTable["corthovr"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.80859375, losRadius = 10.15625, sonarRadius = 0, metalCost = 650, xsize = 8, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corthovr_dead", zsize = 8, mtype = "hov", airRange = 0, submergedRange = 0, stealth = false, groundRange = 400, isWeapon = true, } unitTable["corthud"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.453125, losRadius = 11.875, sonarRadius = 0, metalCost = 132, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corthud_dead", zsize = 4, mtype = "bot", airRange = 0, submergedRange = 0, stealth = false, groundRange = 380, isWeapon = true, } -unitTable["cortide"] = { radarRadius = 0, techLevel = 1, isBuilding = true, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 1.5234375, losRadius = 4.0625, sonarRadius = 0, metalCost = 81, xsize = 6, totalEnergyOut = 18, jammerRadius = 0, wreckName = "cortide_dead", zsize = 6, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } +unitTable["cortide"] = { radarRadius = 0, techLevel = 1, isBuilding = true, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 1.5234375, losRadius = 4.0625, sonarRadius = 0, metalCost = 81, xsize = 6, totalEnergyOut = 21, jammerRadius = 0, wreckName = "cortide_dead", zsize = 6, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["cortitan"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.33203125, losRadius = 14.21875, sonarRadius = 0, metalCost = 318, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "", zsize = 6, mtype = "air", airRange = 0, submergedRange = 500, stealth = false, groundRange = 0, isWeapon = true, } unitTable["cortl"] = { radarRadius = 0, techLevel = 3, isBuilding = true, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.33203125, losRadius = 14.21875, sonarRadius = 0, metalCost = 316, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "cortl_dead", zsize = 6, mtype = "shp", airRange = 0, submergedRange = 550, stealth = false, groundRange = 0, isWeapon = true, } unitTable["cortoast"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.875, losRadius = 13, sonarRadius = 0, metalCost = 2318, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "cortoast_dead", zsize = 6, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 1335, isWeapon = true, } unitTable["cortron"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = true, airLosRadius = 5.33203125, losRadius = 14.21875, sonarRadius = 0, metalCost = 754, xsize = 8, totalEnergyOut = 0, jammerRadius = 0, wreckName = "cortron_dead", zsize = 8, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 3000, isWeapon = true, } -unitTable["cortship"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 6.4453125, losRadius = 17.1875, sonarRadius = 0, metalCost = 710, xsize = 8, totalEnergyOut = 5.5, jammerRadius = 0, wreckName = "cortship_dead", zsize = 8, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = true, } +unitTable["cortship"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 6.4453125, losRadius = 17.1875, sonarRadius = 0, metalCost = 710, xsize = 8, totalEnergyOut = 5, jammerRadius = 0, wreckName = "cortship_dead", zsize = 8, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = true, } unitTable["coruwadves"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = true, airLosRadius = 2.25, losRadius = 6, sonarRadius = 0, metalCost = 790, xsize = 10, totalEnergyOut = 0, jammerRadius = 0, wreckName = "coruwadves_dead", zsize = 10, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["coruwadvms"] = { radarRadius = 0, techLevel = 5, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 2.1328125, losRadius = 5.6875, sonarRadius = 0, metalCost = 710, xsize = 8, totalEnergyOut = 0, jammerRadius = 0, wreckName = "coruwadvms_dead", zsize = 8, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["coruwes"] = { radarRadius = 0, techLevel = 1, isBuilding = true, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 1.98046875, losRadius = 5.28125, sonarRadius = 0, metalCost = 280, xsize = 8, totalEnergyOut = 0, jammerRadius = 0, wreckName = "coruwes_dead", zsize = 8, mtype = "sub", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } @@ -356,10 +357,10 @@ unitTable["corvp"] = { radarRadius = 50, techLevel = 1, isBuilding = true, factoriesCanBuild = { }, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.26953125, losRadius = 8.71875, wreckName = "corvp_dead", sonarRadius = 0, metalCost = 723, xsize = 14, totalEnergyOut = 0, jammerRadius = 0, zsize = 14, buildOptions = true, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["corvrad"] = { radarRadius = 2200, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 10.546875, losRadius = 28.125, sonarRadius = 0, metalCost = 86, xsize = 6, totalEnergyOut = -12, jammerRadius = 0, wreckName = "corvrad_dead", zsize = 6, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["corvroc"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 2.58984375, losRadius = 6.90625, sonarRadius = 0, metalCost = 827, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corvroc_dead", zsize = 6, mtype = "veh", airRange = 0, submergedRange = 0, stealth = true, groundRange = 1240, isWeapon = true, } -unitTable["corwin"] = { radarRadius = 0, techLevel = 1, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.19921875, losRadius = 8.53125, sonarRadius = 0, metalCost = 42, xsize = 6, totalEnergyOut = 5.5, jammerRadius = 0, wreckName = "corwin_dead", zsize = 6, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } +unitTable["corwin"] = { radarRadius = 0, techLevel = 1, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.19921875, losRadius = 8.53125, sonarRadius = 0, metalCost = 42, xsize = 6, totalEnergyOut = 5, jammerRadius = 0, wreckName = "corwin_dead", zsize = 6, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } unitTable["corwolv"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.50390625, losRadius = 9.34375, sonarRadius = 0, metalCost = 159, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, wreckName = "corwolv_dead", zsize = 4, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 710, isWeapon = true, } unitTable["csubpen"] = { radarRadius = 0, techLevel = 3, isBuilding = true, factoriesCanBuild = { }, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 2.8125, losRadius = 7.5, wreckName = "csubpen_dead", sonarRadius = 0, metalCost = 1192, xsize = 16, totalEnergyOut = 0, jammerRadius = 0, zsize = 16, buildOptions = true, mtype = "sub", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = false, } -unitTable["decade"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.02734375, losRadius = 13.40625, sonarRadius = 0, metalCost = 302, xsize = 6, totalEnergyOut = 5.5, jammerRadius = 0, wreckName = "decade_dead", zsize = 6, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 310, isWeapon = true, } +unitTable["decade"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.02734375, losRadius = 13.40625, sonarRadius = 0, metalCost = 302, xsize = 6, totalEnergyOut = 5, jammerRadius = 0, wreckName = "decade_dead", zsize = 6, mtype = "shp", airRange = 0, submergedRange = 0, stealth = false, groundRange = 310, isWeapon = true, } unitTable["gorg"] = { radarRadius = 0, techLevel = 6, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 8.4375, losRadius = 22.5, sonarRadius = 0, metalCost = 18705, xsize = 10, totalEnergyOut = 35, jammerRadius = 0, wreckName = "gorg_dead", zsize = 10, mtype = "bot", airRange = 0, submergedRange = 0, stealth = false, groundRange = 590, isWeapon = true, } unitTable["hllt"] = { radarRadius = 0, techLevel = 3, isBuilding = true, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.56640625, losRadius = 14.84375, sonarRadius = 0, metalCost = 185, xsize = 4, totalEnergyOut = 0, jammerRadius = 0, wreckName = "hllt_dead", zsize = 4, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 475, isWeapon = true, } unitTable["intruder"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 3.421875, losRadius = 9.125, sonarRadius = 0, metalCost = 1264, xsize = 6, totalEnergyOut = -0.30000019073486, jammerRadius = 0, wreckName = "intruder_dead", zsize = 6, mtype = "hov", airRange = 0, submergedRange = 0, stealth = false, groundRange = 0, isWeapon = true, } @@ -375,4 +376,4 @@ unitTable["tawf009"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = true, extractsMetal = 0, bigExplosion = false, airLosRadius = 5.484375, losRadius = 14.625, sonarRadius = 550, metalCost = 1686, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "tawf009_dead", zsize = 6, mtype = "sub", airRange = 0, submergedRange = 690, stealth = false, groundRange = 0, isWeapon = true, } unitTable["tawf013"] = { radarRadius = 0, techLevel = 2, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.265625, losRadius = 11.375, sonarRadius = 0, metalCost = 142, xsize = 6, totalEnergyOut = 0, jammerRadius = 0, wreckName = "tawf013_dead", zsize = 6, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 710, isWeapon = true, } unitTable["tawf114"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 6.3984375, losRadius = 17.0625, sonarRadius = 0, metalCost = 939, xsize = 8, totalEnergyOut = 0, jammerRadius = 0, wreckName = "tawf114_dead", zsize = 8, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 800, isWeapon = true, } -unitTable["trem"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.11328125, losRadius = 10.96875, sonarRadius = 0, metalCost = 1951, xsize = 8, totalEnergyOut = 0, jammerRadius = 0, wreckName = "trem_dead", zsize = 8, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 1275, isWeapon = true, } +unitTable["trem"] = { radarRadius = 0, techLevel = 4, isBuilding = false, needsWater = false, extractsMetal = 0, bigExplosion = false, airLosRadius = 4.11328125, losRadius = 10.96875, sonarRadius = 0, metalCost = 1951, xsize = 8, totalEnergyOut = 0, jammerRadius = 0, wreckName = "trem_dead", zsize = 8, mtype = "veh", airRange = 0, submergedRange = 0, stealth = false, groundRange = 1275, isWeapon = true, } \ No newline at end of file diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/wardbehaviour.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/wardbehaviour.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/BA/wardbehaviour.lua 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/BA/wardbehaviour.lua 2014-10-07 20:10:05.000000000 +0000 @@ -0,0 +1,170 @@ +require "common" + +local DebugEnabled = false + +local function EchoDebug(inStr) + if DebugEnabled then + game:SendToConsole("WardBehaviour: " .. inStr) + end +end + +WardBehaviour = class(Behaviour) + +function WardBehaviour:Init() + self.active = false + self.underFire = false + self.lastAttackedFrame = game:Frame() + self.initialLocation = self.unit:Internal():GetPosition() + self.name = self.unit:Internal():Name() + self.id = self.unit:Internal():ID() + self.mtype = unitTable[self.name].mtype + self.water = self.mtype == "sub" or self.mtype == "shp" or self.mtype == "amp" -- can be hurt by submerged weapons + self.isCommander = commanderList[self.name] + self.mobile = not unitTable[self.name].isBuilding and not nanoTurretList[self.name] -- for some reason nano turrets are not buildings + self.isScout = scoutList[self.name] + if self.isCommander then + self.threshold = 0.25 + elseif self.isScout then + self.threshold = 1 + elseif self.mobile then + self.threshold = 1.5 + end + -- any threat whatsoever will trigger for buildings + EchoDebug("WardBehaviour: added to unit "..self.name) +end + +function WardBehaviour:UnitBuilt(unit) + if unit.engineID == self.unit.engineID then + if self.mobile and not self.isScout then + ai.defendhandler:AddWard(self) -- just testing + end + end +end + +function WardBehaviour:UnitDead(unit) + if unit.engineID == self.unit.engineID then + if self.mobile and not self.isScout then + ai.defendhandler:RemoveWard(self) -- just testing + end + end +end + +function WardBehaviour:UnitIdle(unit) + if unit.engineID == self.unit.engineID then + if self:IsActive() then + self.underFire = false + self.unit:ElectBehaviour() + end + end +end + +function WardBehaviour:Update() + local f = game:Frame() + + -- timeout on underFire condition + if self.underFire then + if f > self.lastAttackedFrame + 300 then + self.underFire = false + end + else + if f % 30 == 0 then + -- run away preemptively from positions within range of enemy weapons, and notify defenders that the unit is in danger + local unit = self.unit:Internal() + if not self.mobile then + position = self.initialLocation + else + position = unit:GetPosition() + end + local safe, response = ai.targethandler:IsSafePosition(position, unit, self.threshold) + if safe then + self.underFire = false + self.response = nil + self.unit:ElectBehaviour() + else + EchoDebug(self.name .. " is not safe") + self.underFire = true + self.response = response + self.lastAttackedFrame = game:Frame() + if not self.mobile then ai.defendhandler:Danger(self) end + self.unit:ElectBehaviour() + end + if self.mobile then self.withinTurtle = ai.turtlehandler:SafeWithinTurtle(position, self.name) end + end + end +end + +function WardBehaviour:Activate() + EchoDebug("WardBehaviour: activated on unit "..self.name) + + -- can we move at all? + if self.mobile then + -- run to the most defended base location + local salvation = ai.turtlehandler:MostTurtled(self.unit:Internal(), nil, nil, true) + if salvation == nil then + -- if no turtle, find the nearest combat unit + salvation = self:NearestCombat() + end + if salvation == nil then + -- if none found, just go to where we were built + salvation = self.initialLocation + end + self.unit:Internal():Move(RandomAway(salvation,150)) + + self.active = true + EchoDebug("WardBehaviour: unit ".. self.name .." runs away from danger") + end +end + +function WardBehaviour:NearestCombat() + local best + local ownUnits = game:GetFriendlies() + local fleeing = self.unit:Internal() + local fn = fleeing:Name() + local fid = fleeing:ID() + local fpos = fleeing:GetPosition() + local bestDistance = 10000 + for i,unit in pairs(ownUnits) do + local un = unit:Name() + if unit:ID() ~= fid and un ~= "corcom" and un ~= "armcom" and not ai.defendhandler:IsDefendingMe(unit, self) then + if unitTable[un].isWeapon and (battleList[un] or breakthroughList[un]) and unitTable[un].metalCost > unitTable[fn].metalCost * 1.5 then + local upos = unit:GetPosition() + if ai.targethandler:IsSafePosition(upos, fleeing) and unit:GetHealth() > unit:GetMaxHealth() * 0.9 and ai.maphandler:UnitCanGetToUnit(fleeing, unit) and not unit:IsBeingBuilt() then + local dist = Distance(fpos, upos) - unitTable[un].metalCost + if dist < bestDistance then + bestDistance = dist + best = upos + end + end + end + end + end + return best +end + +function WardBehaviour:Deactivate() + EchoDebug("WardBehaviour: deactivated on unit "..self.name) + self.active = false + self.underFire = false +end + +function WardBehaviour:Priority() + if self.underFire and self.mobile then + return 110 + else + return 0 + end +end + +function WardBehaviour:UnitDamaged(unit,attacker) + if unit:Internal():ID() == self.unit:Internal():ID() then + if not self.underFire then + if unit:Internal():GetHealth() < unit:Internal():GetMaxHealth() * 0.8 then + self.underFire = true + self.lastAttackedFrame = game:Frame() + if not self.mobile then ai.defendhandler:Danger(self) end + self.unit:ElectBehaviour() + end + end + end +end + diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/EvoRTS/missingfactorybehaviour.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/EvoRTS/missingfactorybehaviour.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/EvoRTS/missingfactorybehaviour.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/EvoRTS/missingfactorybehaviour.lua 2014-10-07 20:10:05.000000000 +0000 @@ -49,10 +49,7 @@ end function MissingFactoryBehaviour:UnitDead(unit) - if unit:Internal():Name() == "ecommandfactory" then - self.build = true - --game:SendToConsole("missingfactory activated") - elseif unit:Internal():Name() == "ebasefactory" then + if unit:Internal():Name() == "ebasefactory" then self.build = true --game:SendToConsole("missingfactory activated") end diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/EvoRTS/taskqueues.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/EvoRTS/taskqueues.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/EvoRTS/taskqueues.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/EvoRTS/taskqueues.lua 2014-10-07 20:10:05.000000000 +0000 @@ -31,11 +31,13 @@ end local function StartFactory() - local r = math.random(0,1) + local r = math.random(0,2) if r == 0 then - return "ebasefactory" - else - return "eminifac" + return "ebasefactory" + elseif r == 1 then + return "eamphibfac" + else + return "eminifac" end end @@ -51,19 +53,12 @@ "elighttank3", "elighttank3", "eriottank2", - - "eflametank", "elighttank3", - "eflametank", "elighttank3", - "eflametank", "eriottank2", "eengineer5", "eriottank2", "eheavytank3", - "emediumtank3", - "emediumtank3", - "emediumtank3", "eaatank", "eaatank", "eaatank", @@ -75,37 +70,19 @@ "eheavytank3", "eheavytank3", "eheavytank3", - "efatso2", - "efatso2", - "efatso2", - "efatso2", - "efatso2", - "emediumtank3", "eaatank", - "emediumtank3", - "emediumtank3", - "emediumtank3", "eengineer5", - "efatso2", "elighttank3", - "eflametank", "elighttank3", "eaatank", - "eflametank", "elighttank3", "eartytank", - "eflametank", "eriottank2", "eriottank2", - "efatso2", - "efatso2", "eartytank", - "efatso2", "eheavytank3", "emissiletank", - "efatso2", "emissiletank", - "efatso2", "emissiletank", { action="wait",frames=200}, } diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/preload/aibase.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/preload/aibase.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/preload/aibase.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/preload/aibase.lua 2014-10-07 20:10:05.000000000 +0000 @@ -13,6 +13,9 @@ function AIBase:GameEnd() end +function AIBase:GameMessage(text) +end + function AIBase:UnitCreated(engineunit) end @@ -34,4 +37,4 @@ function AIBase:UnitDamaged(engineunit,attacker) end function AIBase:UnitMoveFailed(engineunit) -end \ No newline at end of file +end diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/preload/api.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/preload/api.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/preload/api.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/preload/api.lua 2014-10-07 20:10:05.000000000 +0000 @@ -73,7 +73,7 @@ return e end end - + function game:GetUnits() local fv = game_engine:GetUnits() local f = {} @@ -85,7 +85,7 @@ fv = nil return f end - + function game:GetFriendlies() local has_friendlies = game_engine:HasFriendlies() if has_friendlies ~= true then @@ -102,38 +102,39 @@ return f end end - - + function game:GameName() -- returns the shortname of this game -- return game_engine:GameName() end - + function game:AddMarker(position,label) -- adds a marker -- return game_engine:AddMarker(position,label) end - - + function game:SendToContent(stringvar) -- returns a string passed from any lua gadgets -- return game_engine:SendToContent(stringvar) end - + function game:GetResource(idx) -- returns a Resource object return game_engine:GetResource(idx) end - + function game:GetResourceCount() -- return the number of resources return game_engine:GetResourceCount() end - + function game:GetResourceByName(name) -- returns a Resource object, takes the name of the resource return game_engine:GetResourceByName(name) end - + + function game:GetUnitByID( unit_id ) -- returns a Shard unit when given an engine unit ID number + return game_engine:getUnitByID( unit_id ) + end + function game:GetResources() -- returns a table of Resource objects, takes the name of the resource - local rcount = game_engine:GetResourceCount() if(rcount > 0) then diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/unit.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/unit.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/unit.lua 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/unit.lua 2014-10-07 20:10:05.000000000 +0000 @@ -88,6 +88,9 @@ end function Unit:ElectBehaviour() + if self.behaviours == nil then --probably we are dead. + return + end local bestbeh = nil local bestscore = -1 if #self.behaviours > 0 then diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/ZK/assistbehaviour.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/ZK/assistbehaviour.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/ZK/assistbehaviour.lua 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/ZK/assistbehaviour.lua 2014-10-07 20:10:05.000000000 +0000 @@ -0,0 +1,57 @@ +-- require "taskqueues" +require "commonfunctions" + +nanoTurretList = { + armnanotc = 1, +} + +local function EchoDebug(inStr) + if DebugEnabled then + game:SendToConsole("AssistBehaviour: " .. inStr) + end +end + +local CMD_GUARD = 25 +local CMD_PATROL = 15 + +AssistBehaviour = class(Behaviour) + +function AssistBehaviour:DoIAssist() + if self.isNanoTurret then + return true + else + return false + end +end + +function AssistBehaviour:Init() + local uname = self.unit:Internal():Name() + self.name = uname + if nanoTurretList[uname] then self.isNanoTurret = true end +end + +function AssistBehaviour:UnitBuilt(unit) + if unit.engineID == self.unit.engineID then + if self.isNanoTurret then + -- set nano turrets to patrol + local upos = RandomAway(self.unit:Internal():GetPosition(), 50) + local floats = api.vectorFloat() + -- populate with x, y, z of the position + self.havenPos = upos + floats:push_back(upos.x) + floats:push_back(upos.y) + floats:push_back(upos.z) + self.unit:Internal():ExecuteCustomCommand(CMD_PATROL, floats) + game:SendToContent("sethaven|"..upos.x..'|'..upos.y..'|'..upos.z); + end + end +end + +function AttackerBehaviour:UnitDead(unit) + if unit.engineID == self.unit.engineID then + if(self.havenPos) then + local upos = self.havenPos + game:SendToContent("sethaven|"..upos.x..'|'..upos.y..'|'..upos.z); + end + end +end diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/ZK/attackerbehaviour.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/ZK/attackerbehaviour.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/ZK/attackerbehaviour.lua 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/ZK/attackerbehaviour.lua 2014-10-07 20:10:05.000000000 +0000 @@ -0,0 +1,88 @@ +require "attackers" + +function IsAttacker(unit) + for i,name in ipairs(attackerlist) do + if name == unit:Internal():Name() then + return true + end + end + return false +end + +AttackerBehaviour = class(Behaviour) + +function AttackerBehaviour:Init() + --game:SendToConsole("attacker!") +end + +function AttackerBehaviour:UnitBuilt(unit) + if unit.engineID == self.unit.engineID then + self:SetInitialState() + self.attacking = false + ai.attackhandler:AddRecruit(self) + end +end + + +function AttackerBehaviour:UnitDead(unit) + if unit.engineID == self.unit.engineID then + ai.attackhandler:RemoveRecruit(self) + end +end + +function AttackerBehaviour:UnitIdle(unit) + if unit.engineID == self.unit.engineID then + self.attacking = false + ai.attackhandler:AddRecruit(self) + end +end + +function AttackerBehaviour:AttackCell(cell) + p = api.Position() + p.x = cell.posx + p.z = cell.posz + p.y = 0 + self.target = p + self.attacking = true + if self.active then + self.unit:Internal():MoveAndFire(self.target) + else + self.unit:ElectBehaviour() + end +end + +function AttackerBehaviour:Priority() + if not self.attacking then + return 0 + else + return 100 + end +end + +function AttackerBehaviour:Activate() + self.active = true + if self.target then + self.unit:Internal():MoveAndFire(self.target) + self.target = nil + else + --ai.attackhandler:AddRecruit(self) + end +end + +function AttackerBehaviour:SetInitialState() + local CMD_FIRE_STATE = 45 + local CMD_MOVE_STATE = 50 + local CMD_RETREAT = 34223 + local thisUnit = self.unit + if thisUnit then + local floats = api.vectorFloat() + floats:push_back(2) + thisUnit:Internal():ExecuteCustomCommand(CMD_MOVE_STATE, floats) + thisUnit:Internal():ExecuteCustomCommand(CMD_FIRE_STATE, floats) + + local isHeavy = thisUnit:Internal():GetMaxHealth() >= 1250 + if (isHeavy) then + thisUnit:Internal():ExecuteCustomCommand(CMD_RETREAT, floats) + end + end +end diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/ZK/attackers.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/ZK/attackers.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/ZK/attackers.lua 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/ZK/attackers.lua 2014-10-07 20:10:05.000000000 +0000 @@ -0,0 +1,34 @@ +--[[ +Attackers! +]]-- + +attackerlist = { + "corak", + "armpw", + "corgator", + "corthud", + "corkrog", + "armham", + "armrock", + "armpw", + "armfav", + "armflash", + "armstump", + "armjanus", + "armham", + "corraid", + "armjeth", + "armwar", + "capturecar", + "corlevlr", + "armpnix", + "bomberdive", + "gunshipsupport", + "armzeus", + "fighter", + "armsnipe", + "hoverriot", + "hoverassault", + "nsaclash", + "armmanni" +} diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/ZK/behaviours.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/ZK/behaviours.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/ZK/behaviours.lua 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/ZK/behaviours.lua 2014-10-07 20:10:05.000000000 +0000 @@ -0,0 +1,29 @@ + +require "taskqueues" +require "taskqueuebehaviour" +require "attackerbehaviour" +require "assistbehaviour" + +behaviours = { + commbasic = { + TaskQueueBehaviour, + }, +} + +function defaultBehaviours(unit) + b = {} + u = unit:Internal() + if u:Name() == "armnanotc" then + table.insert(b,AssistBehaviour) + else + if u:CanBuild() then + table.insert(b,TaskQueueBehaviour) + + else + if IsAttacker(unit) then + table.insert(b,AttackerBehaviour) + end + end + end + return b +end diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/ZK/commonfunctions.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/ZK/commonfunctions.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/ZK/commonfunctions.lua 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/ZK/commonfunctions.lua 2014-10-07 20:10:05.000000000 +0000 @@ -0,0 +1,308 @@ +sqrt = math.sqrt +random = math.random +pi = math.pi +halfPi = pi / 2 +twicePi = pi * 2 +cos = math.cos +sin = math.sin +atan2 = math.atan2 +floor = math.floor +ceil = math.ceil +abs = math.abs +min = math.min +max = math.max + +CMD_ATTACK = 20 +CMD_RECLAIM = 90 +CMD_GUARD = 25 +CMD_MOVE_STATE = 50 +MOVESTATE_HOLDPOS = 0 +MOVESTATE_MANEUVER = 1 +MOVESTATE_ROAM = 2 + +local mapBuffer = 32 + +local layerNames = {"ground", "air", "submerged"} +local unitThreatLayers = {} +local whatHurtsUnit = {} +local whatHurtsMtype = {} +local unitWeaponLayers = {} +local unitWeaponMtypes = {} + +local quadX = { -1, 1, -1, 1 } +local quadZ = { -1, -1, 1, 1 } + +function ConstrainToMap(x, z) + x = max(min(x, ai.maxElmosX-mapBuffer), mapBuffer) + z = max(min(z, ai.maxElmosZ-mapBuffer), mapBuffer) + return x, z +end + +function RandomAway(pos, dist, opposite, angle) + if angle == nil then angle = random() * twicePi end + local away = api.Position() + away.x = pos.x + dist * cos(angle) + away.z = pos.z - dist * sin(angle) + away.y = pos.y + 0 + if away.x < 1 then + away.x = 1 +-- elseif away.x > ai.maxElmosX - 1 then +-- away.x = ai.maxElmosX - 1 + end + if away.z < 1 then + away.z = 1 +-- elseif away.z > ai.maxElmosZ - 1 then +-- away.z = ai.maxElmosZ - 1 + end + if opposite then + angle = twicePi - angle + return away, RandomAway(pos, dist, false, angle) + else + return away + end +end + +function Distance(pos1,pos2) + local xd = pos1.x-pos2.x + local yd = pos1.z-pos2.z + local dist = sqrt(xd*xd + yd*yd) + return dist +end + +function DistanceXZ(x1, z1, x2, z2) + local xd = x1 - x2 + local zd = z1 - z2 + return sqrt(xd*xd + zd*zd) +end + +function ManhattanDistance(pos1,pos2) + local xd = math.abs(pos1.x-pos2.x) + local yd = math.abs(pos1.z-pos2.z) + local dist = xd + yd + return dist +end + +function ApplyVector(x, z, vx, vz, frames) + if frames == nil then frames = 30 end + return ConstrainToMap(x + (vx *frames), z + (vz * frames)) +end + +function AngleDist(angle1, angle2) + return abs((angle1 + pi - angle2) % twicePi - pi) + -- Spring.Echo(math.floor(angleDist * 57.29), math.floor(high * 57.29), math.floor(low * 57.29)) +end + +function AngleAdd(angle1, angle2) + return (angle1 + angle2) % twicePi +end + +function AngleAtoB(x1, z1, x2, z2) + local dx = x2 - x1 + local dz = z2 - z1 + return atan2(-dz, dx) +end + +function CheckRect(rect) + local new = {} + if rect.x1 > rect.x2 then + new.x1 = rect.x2 * 1 + new.x2 = rect.x1 * 1 + else + new.x1 = rect.x1 * 1 + new.x2 = rect.x2 * 1 + end + if rect.z1 > rect.z2 then + new.z1 = rect.z2 * 1 + new.z2 = rect.z1 * 1 + else + new.z1 = rect.z1 * 1 + new.z2 = rect.z2 * 1 + end + rect.x1 = new.x1 + rect.z1 = new.z1 + rect.x2 = new.x2 + rect.z2 = new.z2 +end + +function PositionWithinRect(position, rect) + return position.x > rect.x1 and position.x < rect.x2 and position.z > rect.z1 and position.z < rect.z2 +end + +function RectsOverlap(rectA, rectB) + return rectA.x1 < rectB.x2 and + rectB.x1 < rectA.x2 and + rectA.z1 < rectB.z2 and + rectB.z1 < rectA.z2 +end + +function pairsByKeys(t, f) + local a = {} + for n in pairs(t) do table.insert(a, n) end + table.sort(a, f) + local i = 0 -- iterator variable + local iter = function () -- iterator function + i = i + 1 + if a[i] == nil then return nil + else return a[i], t[a[i]] + end + end + return iter +end + +function CustomCommand(unit, cmdID, cmdParams) + local floats = api.vectorFloat() + for i = 1, #cmdParams do + floats:push_back(cmdParams[i]) + end + return unit:ExecuteCustomCommand(cmdID, floats) +end + +function ThreatRange(unitName, groundAirSubmerged) + local threatLayers = unitThreatLayers[unitName] + if groundAirSubmerged ~= nil and threatLayers ~= nil then + local layer = threatLayers[groundAirSubmerged] + if layer ~= nil then + return layer.threat, layer.range + end + end + if antinukeList[unitName] or nukeList[unitName] or bigPlasmaList[unitName] or shieldList[unitName] then + return 0, 0 + end + local utable = unitTable[unitName] + if groundAirSubmerged == nil then + if utable.groundRange > utable.airRange and utable.groundRange > utable.submergedRange then + groundAirSubmerged = "ground" + elseif utable.airRange > utable.groundRange and utable.airRange > utable.submergedRange then + groundAirSubmerged = "air" + elseif utable.submergedRange > utable.groundRange and utable.submergedRange > utable.airRange then + groundAirSubmerged = "submerged" + end + if groundAirSubmerged == nil then + return 0, 0 + end + end + if threatLayers ~= nil then + local layer = threatLayers[groundAirSubmerged] + if layer ~= nil then + return layer.threat, layer.range + end + end + local threat = 0 + local range = 0 + if groundAirSubmerged == "ground" then + range = utable.groundRange + elseif groundAirSubmerged == "air" then + range = utable.airRange + elseif groundAirSubmerged == "submerged" then + range = utable.submergedRange + end + if range > 0 and threat == 0 then + threat = utable.metalCost + end + -- double the threat if it's a building (buildings are more bang for your buck) + if threat > 0 and utable.isBuilding then threat = threat + threat end + if unitThreatLayers[unitName] == nil then unitThreatLayers[unitName] = {} end + unitThreatLayers[unitName][groundAirSubmerged] = { threat = threat, range = range } + return threat, range +end + +function UnitThreatRangeLayers(unitName) + local threatLayers = unitThreatLayers[unitName] + if threatLayers ~= nil then + if #threatLayers == 3 then return threatLayers end + end + threatLayers = {} + for i, layerName in pairs(layerNames) do + local threat, range = ThreatRange(unitName, layerName) + threatLayers[layerName] = { threat = threat, range = range } + end + unitThreatLayers[unitName] = threatLayers + return threatLayers +end + +function UnitWeaponLayerList(unitName) + local weaponLayers = unitWeaponLayers[unitName] + if weaponLayers then return weaponLayers end + weaponLayers = {} + local ut = unitTable[unitName] + if not ut then + return weaponLayers + end + if ut.groundRange > 0 then + table.insert(weaponLayers, "ground") + end + if ut.airRange > 0 then + table.insert(weaponLayers, "air") + end + if ut.submergedRange > 0 then + table.insert(weaponLayers, "submerged") + end + unitWeaponLayers[unitName] = weaponLayers + return weaponLayers +end + +function UnitWeaponMtypeList(unitName) + if unitName == nil then return {} end + if unitName == DummyUnitName then return {} end + local mtypes = unitWeaponMtypes[unitName] + if mtypes then return mtypes end + local utable = unitTable[unitName] + mtypes = {} + if utable.groundRange > 0 then + table.insert(mtypes, "veh") + table.insert(mtypes, "bot") + table.insert(mtypes, "amp") + table.insert(mtypes, "hov") + table.insert(mtypes, "shp") + end + if utable.airRange > 0 then + table.insert(mtypes, "air") + end + if utable.submergedRange > 0 then + table.insert(mtypes, "sub") + table.insert(mtypes, "shp") + table.insert(mtypes, "amp") + end + unitWeaponMtypes[unitName] = mtypes + return mtypes +end + +function WhatHurtsUnit(unitName, mtype, position) + local hurts = whatHurtsMtype[mtype] or whatHurtsUnit[unitName] + if hurts ~= nil then return hurts else hurts = {} end + if unitName then + local ut = unitTable[unitName] + if ut then + mtype = ut.mtype + end + end + if mtype == "veh" or mtype == "bot" or mtype == "amp" or mtype == "hov" or mtype == "shp" then + hurts["ground"] = true + end + if mtype == "air" then + hurts["air"] = true + end + if mtype == "sub" or mtype == "shp" or mtype == "amp" then + hurts["submerged"] = true + end + if unitName then whatHurtsUnit[unitName] = hurts end + if mtype then whatHurtsMtype[mtype] = hurts end + if mtype == "amp" and position ~= nil then + -- special case: amphibious need to check whether underwater or not + local underwater = ai.maphandler:IsUnderWater(position) + if underwater then + return { ground = false, air = false, submerged = true} + else + return { ground = true, air = false, submerged = true } + end + end + return hurts +end + +function BehaviourPosition(behaviour) + if behaviour == nil then return end + if behaviour.unit == nil then return end + local unit = behaviour.unit:Internal() + if unit == nil then return end + return unit:GetPosition() +end diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/ZK/json.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/ZK/json.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/ZK/json.lua 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/ZK/json.lua 2014-10-07 20:10:05.000000000 +0000 @@ -0,0 +1,387 @@ +----------------------------------------------------------------------------- +-- JSON4Lua: JSON encoding / decoding support for the Lua language. +-- json Module. +-- Author: Craig Mason-Jones +-- Homepage: http://json.luaforge.net/ +-- Version: 0.9.20 +-- This module is released under the The GNU General Public License (GPL). +-- Please see LICENCE.txt for details. +-- +-- USAGE: +-- This module exposes two functions: +-- encode(o) +-- Returns the table / string / boolean / number / nil / json.null value as a JSON-encoded string. +-- decode(json_string) +-- Returns a Lua object populated with the data encoded in the JSON string json_string. +-- +-- REQUIREMENTS: +-- compat-5.1 if using Lua 5.0 +-- +-- CHANGELOG +-- 0.9.20 Introduction of local Lua functions for private functions (removed _ function prefix). +-- Fixed Lua 5.1 compatibility issues. +-- Introduced json.null to have null values in associative arrays. +-- encode() performance improvement (more than 50%) through table.concat rather than .. +-- Introduced decode ability to ignore /**/ comments in the JSON string. +-- 0.9.10 Fix to array encoding / decoding to correctly manage nil/null values in arrays. +----------------------------------------------------------------------------- + +----------------------------------------------------------------------------- +-- Imports and dependencies +----------------------------------------------------------------------------- +local math = math +local string = string +local table = table +local base = _G + +----------------------------------------------------------------------------- +-- Module declaration +----------------------------------------------------------------------------- + +-- Public functions + +-- Private functions +local decode_scanArray +local decode_scanComment +local decode_scanConstant +local decode_scanNumber +local decode_scanObject +local decode_scanString +local decode_scanWhitespace +local encodeString +local isArray +local isEncodable + +----------------------------------------------------------------------------- +-- PUBLIC FUNCTIONS +----------------------------------------------------------------------------- +--- Encodes an arbitrary Lua object / variable. +-- @param v The Lua object / variable to be JSON encoded. +-- @return String containing the JSON encoding in internal Lua string format (i.e. not unicode) +function encode (v) + -- Handle nil values + if v==nil then + return "null" + end + + local vtype = base.type(v) + + -- Handle strings + if vtype=='string' then + return '"' .. encodeString(v) .. '"' -- Need to handle encoding in string + end + + -- Handle booleans + if vtype=='number' or vtype=='boolean' then + return base.tostring(v) + end + + -- Handle tables + if vtype=='table' then + local rval = {} + -- Consider arrays separately + local bArray, maxCount = isArray(v) + if bArray then + for i = 1,maxCount do + table.insert(rval, encode(v[i])) + end + else -- An object, not an array + for i,j in base.pairs(v) do + if isEncodable(i) and isEncodable(j) then + table.insert(rval, '"' .. encodeString(i) .. '":' .. encode(j)) + end + end + end + if bArray then + return '[' .. table.concat(rval,',') ..']' + else + return '{' .. table.concat(rval,',') .. '}' + end + end + + -- Handle null values + if vtype=='function' and v==null then + return 'null' + end + + base.assert(false,'encode attempt to encode unsupported type ' .. vtype .. ':' .. base.tostring(v)) +end + + +--- Decodes a JSON string and returns the decoded value as a Lua data structure / value. +-- @param s The string to scan. +-- @param [startPos] Optional starting position where the JSON string is located. Defaults to 1. +-- @param Lua object, number The object that was scanned, as a Lua table / string / number / boolean or nil, +-- and the position of the first character after +-- the scanned JSON object. +function decode(s, startPos) + startPos = startPos and startPos or 1 + startPos = decode_scanWhitespace(s,startPos) + base.assert(startPos<=string.len(s), 'Unterminated JSON encoded object found at position in [' .. s .. ']') + local curChar = string.sub(s,startPos,startPos) + -- Object + if curChar=='{' then + return decode_scanObject(s,startPos) + end + -- Array + if curChar=='[' then + return decode_scanArray(s,startPos) + end + -- Number + if string.find("+-0123456789.e", curChar, 1, true) then + return decode_scanNumber(s,startPos) + end + -- String + if curChar==[["]] or curChar==[[']] then + return decode_scanString(s,startPos) + end + if string.sub(s,startPos,startPos+1)=='/*' then + return decode(s, decode_scanComment(s,startPos)) + end + -- Otherwise, it must be a constant + return decode_scanConstant(s,startPos) +end + +--- The null function allows one to specify a null value in an associative array (which is otherwise +-- discarded if you set the value with 'nil' in Lua. Simply set t = { first=json.null } +function null() + return null -- so json.null() will also return null ;-) +end +----------------------------------------------------------------------------- +-- Internal, PRIVATE functions. +-- Following a Python-like convention, I have prefixed all these 'PRIVATE' +-- functions with an underscore. +----------------------------------------------------------------------------- + +--- Scans an array from JSON into a Lua object +-- startPos begins at the start of the array. +-- Returns the array and the next starting position +-- @param s The string being scanned. +-- @param startPos The starting position for the scan. +-- @return table, int The scanned array as a table, and the position of the next character to scan. +function decode_scanArray(s,startPos) + local array = {} -- The return value + local stringLen = string.len(s) + base.assert(string.sub(s,startPos,startPos)=='[','decode_scanArray called but array does not start at position ' .. startPos .. ' in string:\n'..s ) + startPos = startPos + 1 + -- Infinite loop for array elements + repeat + startPos = decode_scanWhitespace(s,startPos) + base.assert(startPos<=stringLen,'JSON String ended unexpectedly scanning array.') + local curChar = string.sub(s,startPos,startPos) + if (curChar==']') then + return array, startPos+1 + end + if (curChar==',') then + startPos = decode_scanWhitespace(s,startPos+1) + end + base.assert(startPos<=stringLen, 'JSON String ended unexpectedly scanning array.') + object, startPos = decode(s,startPos) + table.insert(array,object) + until false +end + +--- Scans a comment and discards the comment. +-- Returns the position of the next character following the comment. +-- @param string s The JSON string to scan. +-- @param int startPos The starting position of the comment +function decode_scanComment(s, startPos) + base.assert( string.sub(s,startPos,startPos+1)=='/*', "decode_scanComment called but comment does not start at position " .. startPos) + local endPos = string.find(s,'*/',startPos+2) + base.assert(endPos~=nil, "Unterminated comment in string at " .. startPos) + return endPos+2 +end + +--- Scans for given constants: true, false or null +-- Returns the appropriate Lua type, and the position of the next character to read. +-- @param s The string being scanned. +-- @param startPos The position in the string at which to start scanning. +-- @return object, int The object (true, false or nil) and the position at which the next character should be +-- scanned. +function decode_scanConstant(s, startPos) + local consts = { ["true"] = true, ["false"] = false, ["null"] = nil } + local constNames = {"true","false","null"} + + for i,k in base.pairs(constNames) do + --print ("[" .. string.sub(s,startPos, startPos + string.len(k) -1) .."]", k) + if string.sub(s,startPos, startPos + string.len(k) -1 )==k then + return consts[k], startPos + string.len(k) + end + end + base.assert(nil, 'Failed to scan constant from string ' .. s .. ' at starting position ' .. startPos) +end + +--- Scans a number from the JSON encoded string. +-- (in fact, also is able to scan numeric +- eqns, which is not +-- in the JSON spec.) +-- Returns the number, and the position of the next character +-- after the number. +-- @param s The string being scanned. +-- @param startPos The position at which to start scanning. +-- @return number, int The extracted number and the position of the next character to scan. +function decode_scanNumber(s,startPos) + local endPos = startPos+1 + local stringLen = string.len(s) + local acceptableChars = "+-0123456789.e" + while (string.find(acceptableChars, string.sub(s,endPos,endPos), 1, true) + and endPos<=stringLen + ) do + endPos = endPos + 1 + end + local stringValue = 'return ' .. string.sub(s,startPos, endPos-1) + local stringEval = base.loadstring(stringValue) + base.assert(stringEval, 'Failed to scan number [ ' .. stringValue .. '] in JSON string at position ' .. startPos .. ' : ' .. endPos) + return stringEval(), endPos +end + +--- Scans a JSON object into a Lua object. +-- startPos begins at the start of the object. +-- Returns the object and the next starting position. +-- @param s The string being scanned. +-- @param startPos The starting position of the scan. +-- @return table, int The scanned object as a table and the position of the next character to scan. +function decode_scanObject(s,startPos) + local object = {} + local stringLen = string.len(s) + local key, value + base.assert(string.sub(s,startPos,startPos)=='{','decode_scanObject called but object does not start at position ' .. startPos .. ' in string:\n' .. s) + startPos = startPos + 1 + repeat + startPos = decode_scanWhitespace(s,startPos) + base.assert(startPos<=stringLen, 'JSON string ended unexpectedly while scanning object.') + local curChar = string.sub(s,startPos,startPos) + if (curChar=='}') then + return object,startPos+1 + end + if (curChar==',') then + startPos = decode_scanWhitespace(s,startPos+1) + end + base.assert(startPos<=stringLen, 'JSON string ended unexpectedly scanning object.') + -- Scan the key + key, startPos = decode(s,startPos) + base.assert(startPos<=stringLen, 'JSON string ended unexpectedly searching for value of key ' .. key) + startPos = decode_scanWhitespace(s,startPos) + base.assert(startPos<=stringLen, 'JSON string ended unexpectedly searching for value of key ' .. key) + base.assert(string.sub(s,startPos,startPos)==':','JSON object key-value assignment mal-formed at ' .. startPos) + startPos = decode_scanWhitespace(s,startPos+1) + base.assert(startPos<=stringLen, 'JSON string ended unexpectedly searching for value of key ' .. key) + value, startPos = decode(s,startPos) + object[key]=value + until false -- infinite loop while key-value pairs are found +end + +--- Scans a JSON string from the opening inverted comma or single quote to the +-- end of the string. +-- Returns the string extracted as a Lua string, +-- and the position of the next non-string character +-- (after the closing inverted comma or single quote). +-- @param s The string being scanned. +-- @param startPos The starting position of the scan. +-- @return string, int The extracted string as a Lua string, and the next character to parse. +function decode_scanString(s,startPos) + base.assert(startPos, 'decode_scanString(..) called without start position') + local startChar = string.sub(s,startPos,startPos) + base.assert(startChar==[[']] or startChar==[["]],'decode_scanString called for a non-string') + local escaped = false + local endPos = startPos + 1 + local bEnded = false + local stringLen = string.len(s) + repeat + local curChar = string.sub(s,endPos,endPos) + if not escaped then + if curChar==[[\]] then + escaped = true + else + bEnded = curChar==startChar + end + else + -- If we're escaped, we accept the current character come what may + escaped = false + end + endPos = endPos + 1 + base.assert(endPos <= stringLen+1, "String decoding failed: unterminated string at position " .. endPos) + until bEnded + local stringValue = 'return ' .. string.sub(s, startPos, endPos-1) + local stringEval = base.loadstring(stringValue) + base.assert(stringEval, 'Failed to load string [ ' .. stringValue .. '] in JSON4Lua.decode_scanString at position ' .. startPos .. ' : ' .. endPos) + return stringEval(), endPos +end + +--- Scans a JSON string skipping all whitespace from the current start position. +-- Returns the position of the first non-whitespace character, or nil if the whole end of string is reached. +-- @param s The string being scanned +-- @param startPos The starting position where we should begin removing whitespace. +-- @return int The first position where non-whitespace was encountered, or string.len(s)+1 if the end of string +-- was reached. +function decode_scanWhitespace(s,startPos) + local whitespace=" \n\r\t" + local stringLen = string.len(s) + while ( string.find(whitespace, string.sub(s,startPos,startPos), 1, true) and startPos <= stringLen) do + startPos = startPos + 1 + end + return startPos +end + +--- Encodes a string to be JSON-compatible. +-- This just involves back-quoting inverted commas, back-quotes and newlines, I think ;-) +-- @param s The string to return as a JSON encoded (i.e. backquoted string) +-- @return The string appropriately escaped. +function encodeString(s) + s = string.gsub(s,'\\','\\\\') + s = string.gsub(s,'"','\\"') + s = string.gsub(s,"'","\\'") + s = string.gsub(s,'\n','\\n') + s = string.gsub(s,'\t','\\t') + return s +end + +-- Determines whether the given Lua type is an array or a table / dictionary. +-- We consider any table an array if it has indexes 1..n for its n items, and no +-- other data in the table. +-- I think this method is currently a little 'flaky', but can't think of a good way around it yet... +-- @param t The table to evaluate as an array +-- @return boolean, number True if the table can be represented as an array, false otherwise. If true, +-- the second returned value is the maximum +-- number of indexed elements in the array. +function isArray(t) + +-- +-- CA modification (to reduce the size of the strings -> save network bandwidth) +-- + local array_count = #t + local table_count = 0 + for _ in base.pairs(t) do + table_count = table_count + 1 + end + return (array_count == table_count), array_count + +--[[ + -- Next we count all the elements, ensuring that any non-indexed elements are not-encodable + -- (with the possible exception of 'n') + local maxIndex = 0 + for k,v in base.pairs(t) do + if (base.type(k)=='number' and math.floor(k)==k and 1<=k) then -- k,v is an indexed pair + if (not isEncodable(v)) then return false end -- All array elements must be encodable + maxIndex = math.max(maxIndex,k) + else + if (k=='n') then + if v ~= table.getn(t) then return false end -- False if n does not hold the number of elements + else -- Else of (k=='n') + if isEncodable(v) then return false end + end -- End of (k~='n') + end -- End of k,v not an indexed pair + end -- End of loop across all pairs + return true, maxIndex +--]] +end + +--- Determines whether the given Lua object / table / variable can be JSON encoded. The only +-- types that are JSON encodable are: string, boolean, number, nil, table and json.null. +-- In this implementation, all other types are ignored. +-- @param o The object to examine. +-- @return boolean True if the object should be JSON encoded, false if it should be ignored. +function isEncodable(o) + local t = base.type(o) + return (t=='string' or t=='boolean' or t=='number' or t=='nil' or t=='table') or (t=='function' and o==null) +end + diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/ZK/spothandler.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/ZK/spothandler.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/ZK/spothandler.lua 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/ZK/spothandler.lua 2014-10-07 20:10:05.000000000 +0000 @@ -0,0 +1,60 @@ +require "json" + +MetalSpotHandler = class(Module) + +function MetalSpotHandler:Name() + return "MetalSpotHandler" +end + +function MetalSpotHandler:internalName() + return "metalspothandler" +end + +function MetalSpotHandler:Init() + self.spots = game.map:GetMetalSpots() + for i,v in ipairs(self.spots) do + v.x = v.x+64; + v.z = v.z+64; + end +end + +function distance(pos1,pos2) + local xd = pos1.x-pos2.x + local yd = pos1.z-pos2.z + dist = math.sqrt(xd*xd + yd*yd) + return dist +end + +function MetalSpotHandler:GameMessage(message) + local headerLength = string.len("METAL_SPOTS:"); + if (string.sub(message, 1, headerLength) == "METAL_SPOTS:") then + local content = string.sub(message,headerLength+1); + local spots = decode(content); + self.spots={} + for i,v in pairs(spots) do + local newpos = api.Position(); + newpos.x = tonumber(v.x); + newpos.y = tonumber(v.y); + newpos.z = tonumber(v.z); + self.spots[i] = newpos; + end + end +end + +function MetalSpotHandler:ClosestFreeSpot(unittype,position) + local pos = nil + local bestDistance = 10000 + + spotCount = game.map:SpotCount() + for i,v in ipairs(self.spots) do + local p = v + local dist = distance(position,p) + if dist < bestDistance then + if game.map:CanBuildHere(unittype,p) then + bestDistance = dist + pos = p + end + end + end + return pos +end diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/ZK/taskqueuebehaviour.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/ZK/taskqueuebehaviour.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/ZK/taskqueuebehaviour.lua 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/ZK/taskqueuebehaviour.lua 2014-10-07 20:10:05.000000000 +0000 @@ -0,0 +1,176 @@ +TaskQueueBehaviour = class(Behaviour) + +function TaskQueueBehaviour:Init() + self.active = false + u = self.unit + u = u:Internal() + self.name = u:Name() + self.countdown = 0 + if self:HasQueues() then + self.queue = self:GetQueue() + end + + self.waiting = {} + local CMD_FIRE_STATE = 45 + local CMD_MOVE_STATE = 50 + local CMD_RETREAT = 34223 + + local floats = api.vectorFloat() + floats:push_back(2) + u:ExecuteCustomCommand(CMD_MOVE_STATE, floats) + u:ExecuteCustomCommand(CMD_FIRE_STATE, floats) + u:ExecuteCustomCommand(CMD_RETREAT, floats) + +end + +function TaskQueueBehaviour:HasQueues() + return (taskqueues[self.name] ~= nil) +end + +function TaskQueueBehaviour:UnitBuilt(unit) + if not self:IsActive() then + return + end + if unit.engineID == self.unit.engineID then + self.progress = true + end +end + +function TaskQueueBehaviour:UnitIdle(unit) + if not self:IsActive() then + return + end + if unit.engineID == self.unit.engineID then + self.progress = true + self.countdown = 0 + --self.unit:ElectBehaviour() + end +end + +function TaskQueueBehaviour:UnitMoveFailed(unit) + if not self:IsActive() then + return + end + self:UnitIdle(unit) +end + +function TaskQueueBehaviour:UnitDead(unit) + if self.unit ~= nil then + if unit.engineID == self.unit.engineID then + if self.waiting ~= nil then + for k,v in pairs(self.waiting) do + ai.modules.sleep.Kill(self.waiting[k]) + end + end + self.waiting = nil + self.unit = nil + end + end +end + +function TaskQueueBehaviour:GetQueue() + q = taskqueues[self.name] + if type(q) == "function" then + q = q(self) + end + return q +end + +function TaskQueueBehaviour:Update() + if not self:IsActive() then + return + end + local f = game:Frame() + local s = self.countdown + if self.progress == true then + --if math.mod(f,3) == 0 then + if (ai.tqblastframe ~= f) or (ai.tqblastframe == nil) or (self.countdown == 15) then + self.countdown = 0 + ai.tqblastframe = f + self:ProgressQueue() + else + if self.countdown == nil then + self.countdown = 1 + else + self.countdown = self.countdown + 1 + end + end + end +end +TaskQueueWakeup = class(function(a,tqb) + a.tqb = tqb +end) +function TaskQueueWakeup:wakeup() + game:sendtoconsole("advancing queue from sleep1") + self.tqb:ProgressQueue() +end +function TaskQueueBehaviour:ProgressQueue() + self.progress = false + if self.queue ~= nil then + local idx, val = next(self.queue,self.idx) + self.idx = idx + if idx == nil then + self.queue = self:GetQueue(name) + self.progress = true + return + end + + local utype = nil + local value = val + if type(val) == "table" then + local action = value.action + if action == "wait" then + t = TaskQueueWakeup(self) + tqb = self + ai.sleep:Wait({ wakeup = function() tqb:ProgressQueue() end, },value.frames) + return + end + else + if type(val) == "function" then + value = val(self) + end + if utype ~= "next" then + utype = game:GetTypeByName(value) + if utype ~= nil then + unit = self.unit:Internal() + if unit:CanBuild(utype) then + if value == "cormex" then + -- find a free spot! + + p = unit:GetPosition() + p = ai.metalspothandler:ClosestFreeSpot(utype,p) + if p ~= nil then + success = self.unit:Internal():Build(utype,p) + self.progress = not success + else + self.progress = true + end + else + self.progress = not self.unit:Internal():Build(utype) + end + else + self.progress = true + end + else + game:SendToConsole("Cannot build:"..value..", couldnt grab the unit type from the engine") + self.progress = true + end + else + self.progress = true + end + end + end +end + +function TaskQueueBehaviour:Activate() + self.progress = true + self.active = true +end + +function TaskQueueBehaviour:Deactivate() + self.active = false +end + +function TaskQueueBehaviour:Priority() + return 50 +end diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/ZK/taskqueues.lua spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/ZK/taskqueues.lua --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/data/ai/ZK/taskqueues.lua 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/data/ai/ZK/taskqueues.lua 2014-10-07 20:10:05.000000000 +0000 @@ -0,0 +1,222 @@ +--[[ + Task Queues! +]]-- + +local armcommander = { + "factorycloak", + "cormex", + "cormex", + "armsolar", + "cormex", + "armsolar", + "armsolar", + "corrl", + "corrl", + "corrl", + "armnanotc", + "corrad", + "armwin", + "armwin", + "armwin", + "armwin", + "armwin", + "armwin", + "armwin", + "corrl", + "corrl", + "armestor", + "armwin", + "armwin", + "armwin", + "armwin", + "corrl", + "corrl", + "armwin", + "armwin", + "armwin", + "armwin", + "armsolar", + "armsolar", + "factoryplane", + "armasp", + "armsolar", + "armwin", + "armwin", + "corrl", + "corrl", + "armwin", + "armwin", + "armnanotc", + "armestor", + "armwin", + "armwin", + "armwin", + "armwin", + "armwin", + "armwin", + "armwin", + "armwin", + "armwin", + "armwin", + "corrl", + "corrl", + "corrl", + "armestor", + "corhlt", + "corllt", + "corrl", + "armfus", + "cormex", + "cormex", + "cormex", + "armsolar", + "armsolar", + "corrl", + "corrl", + "corrl", + "armnanotc", + "corrad", + "armwin", + "armwin", + "armwin", + "armestor", + "armwin", + "armwin", + "armwin", + "armwin", + "corrl", + "corrl", + "factoryvehicle", + "armwin", + "armwin", + "armwin", + "armwin", + "corrl", + "corrl", + "armwin", + "armwin", + "armestor", + "armwin", + "armwin", + "armsolar", + "armsolar", + "armsolar", + "armwin", + "armwin", + "corrl", + "corrl", + "armwin", + "armwin", + "armnanotc", + "armestor", + "armfus", + "armwin", + "armwin", + "armwin", + "armwin", + "armwin", + "armwin", + "armwin", + "armwin", + "armwin", + "armwin", + "corrl", + "corrl", + "corrl", + "armestor", + "factorygunship", +} +taskqueues = { + commbasic = armcommander, + armcom1 = armcommander, + factorycloak = { + "armpw", + "armpw", + "armrectr", + "armpw", + "armpw", + "armpw", + "armpw", + "armpw", + "armpw", + "armpw", + "armpw", + "armrectr", + "armrock", + "armrectr", + "armrock", + "armrock", + "armrock", + "armrock", + "armrock", + "armrock", + "armzeus", + "armrock", + "armrock", + "armrock", + "armjeth", + "armsnipe" + }, + factoryplane = { + "bomberdive", + }, + armrectr = { + "cormex", + "armnanotc", + "cormex", + "corrl", + "armwin", + "armwin", + "cormex", + "corrl", + "corrad", + "corrl", + "armsolar", + "cormex", + "armwin", + "armsolar", + "corllt", + "corrl", + "corrl", + "corrl", + "corllt", + "corhlt", + "armestor", + "corrl", + "armwin", + "armestor", + "armsolar", + "armsolar", + "armsolar", + "corrl", + "corrl", + "armestor", + "corrl", + "corrl", + "corhlt", + "armwin", + "armwin", + "armwin", + "armwin", + "corrl", + "corrl", + "corbhmth", + "factoryhover" + }, + factorygunship = { + "gunshipsupport", + "armbrawl", + }, + factoryveh = { + "corgator", + "corraid", + "corlevlr", + "capturecar", + }, + factoryhover = { + "corsh", + "hoverriot", + "hoverassault", + "armmanni", + }, +} diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/README.md spring-98.0~14.04~ppa6/AI/Skirmish/Shard/README.md --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/README.md 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/README.md 2014-10-07 20:10:05.000000000 +0000 @@ -10,4 +10,22 @@ ## Writing AIs With Shard -If you have a prebuilt copy of Shard ( as comes with every install of the Spring Engine ), you don't need to build Shard to use it, you need only a text editor and knowledge of lua. \ No newline at end of file +If you have a prebuilt copy of Shard ( as comes with every install of the Spring Engine ), you don't need to build Shard to use it, you need only a text editor and knowledge of lua. + +## Directory Structure + +### data + +This folder contains the lua AI, and is copied as is into the target AI folder by the spring engines make files. This is also where you will find the AIInfo.lua etc + +### lib + +This contains the dependent libraries specific to the AI. Currently only the lua 5 VM is present. The Spring Engine API and headers are included with the game engine itself. Some of these headers and APIs are automatically generated by AWK scripts when the engine is built. + +### src + +This folder contains the stub AI itself, the C++ component that interfaces with the engine and provides the lua environment Shards AI logic runs in. cpptestai is the main object that handles the engines events and translates them, wrapping unit objects etc. CTestAI is the object that calls the lua environment etc. If you're building a pure C++ AI, you may want to replace this class with your own and remove or repurpose the lua code. + +### vstudio + +A Visual Studio 2010 project. It may work but it's recommended you use the Spring Engine build system diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/api_wrap.cpp spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/api_wrap.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/api_wrap.cpp 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/api_wrap.cpp 2014-10-07 20:10:05.000000000 +0000 @@ -1,14 +1,15 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 2.0.4 - * - * This file is not intended to be easily readable and contains a number of + * Version 2.0.11 + * + * This file is not intended to be easily readable and contains a number of * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. * ----------------------------------------------------------------------------- */ #define SWIGLUA +#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_LUA #define SWIG_LUA_MODULE_GLOBAL @@ -66,28 +67,28 @@ #ifndef SWIGUNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) +# define SWIGUNUSED __attribute__ ((__unused__)) # else # define SWIGUNUSED # endif # elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) +# define SWIGUNUSED __attribute__ ((__unused__)) # else -# define SWIGUNUSED +# define SWIGUNUSED # endif #endif #ifndef SWIG_MSC_UNSUPPRESS_4505 # if defined(_MSC_VER) # pragma warning(disable : 4505) /* unreferenced local function has been removed */ -# endif +# endif #endif #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) # else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# define SWIGUNUSEDPARM(p) p SWIGUNUSED # endif #endif @@ -130,7 +131,7 @@ # define SWIGSTDCALL __stdcall # else # define SWIGSTDCALL -# endif +# endif #endif /* Deal with Microsoft's attempt at deprecating C standard runtime functions */ @@ -168,7 +169,7 @@ You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for creating a static or dynamic library from the SWIG runtime code. In 99.9% of the cases, SWIG just needs to declare them as 'static'. - + But only do this if strictly necessary, ie, if you have problems with your compiler or suchlike. */ @@ -194,16 +195,16 @@ #define SWIG_POINTER_OWN 0x1 -/* +/* Flags/methods for returning states. - - The SWIG conversion methods, as ConvertPtr, return an integer + + The SWIG conversion methods, as ConvertPtr, return an integer that tells if the conversion was successful or not. And if not, an error code can be returned (see swigerrors.swg for the codes). - + Use the following macros/flags to set or process the returning states. - + In old versions of SWIG, code such as the following was usually written: if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { @@ -236,23 +237,23 @@ } else { // fail code } - + I.e., now SWIG_ConvertPtr can return new objects and you can identify the case and take care of the deallocation. Of course that also requires SWIG_ConvertPtr to return new result values, such as - int SWIG_ConvertPtr(obj, ptr,...) { - if () { - if () { - *ptr = ; - return SWIG_NEWOBJ; - } else { - *ptr = ; - return SWIG_OLDOBJ; - } - } else { - return SWIG_BADOBJ; - } + int SWIG_ConvertPtr(obj, ptr,...) { + if () { + if () { + *ptr = ; + return SWIG_NEWOBJ; + } else { + *ptr = ; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } } Of course, returning the plain '0(success)/-1(fail)' still works, but you can be @@ -266,17 +267,17 @@ int fooi(int); and you call - + food(1) // cast rank '1' (1 -> 1.0) fooi(1) // cast rank '0' just use the SWIG_AddCast()/SWIG_CheckState() */ -#define SWIG_OK (0) +#define SWIG_OK (0) #define SWIG_ERROR (-1) #define SWIG_IsOK(r) (r >= 0) -#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) /* The CastRankLimit says how many bits are used for the cast rank */ #define SWIG_CASTRANKLIMIT (1 << 8) @@ -307,14 +308,14 @@ # endif # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) -SWIGINTERNINLINE int SWIG_AddCast(int r) { +SWIGINTERNINLINE int SWIG_AddCast(int r) { return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; } -SWIGINTERNINLINE int SWIG_CheckState(int r) { - return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; } #else /* no cast-rank mode */ -# define SWIG_AddCast +# define SWIG_AddCast(r) (r) # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) #endif @@ -358,7 +359,7 @@ void *clientdata; /* Language specific module data */ } swig_module_info; -/* +/* Compare two type names skipping the space characters, therefore "char*" == "char *" and "Class" == "Class", etc. @@ -378,18 +379,18 @@ /* Check type equivalence in a name list like ||... - Return 0 if not equal, 1 if equal + Return 0 if equal, -1 if nb < tb, 1 if nb > tb */ SWIGRUNTIME int -SWIG_TypeEquiv(const char *nb, const char *tb) { - int equiv = 0; +SWIG_TypeCmp(const char *nb, const char *tb) { + int equiv = 1; const char* te = tb + strlen(tb); const char* ne = nb; - while (!equiv && *ne) { + while (equiv != 0 && *ne) { for (nb = ne; *ne; ++ne) { if (*ne == '|') break; } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + equiv = SWIG_TypeNameComp(nb, ne, tb, te); if (*ne) ++ne; } return equiv; @@ -397,24 +398,13 @@ /* Check type equivalence in a name list like ||... - Return 0 if equal, -1 if nb < tb, 1 if nb > tb + Return 0 if not equal, 1 if equal */ SWIGRUNTIME int -SWIG_TypeCompare(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; +SWIG_TypeEquiv(const char *nb, const char *tb) { + return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; } - /* Check the typename */ @@ -442,7 +432,7 @@ return 0; } -/* +/* Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison */ SWIGRUNTIME swig_cast_info * @@ -477,7 +467,7 @@ return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); } -/* +/* Dynamic pointer casting. Down an inheritance hierarchy */ SWIGRUNTIME swig_type_info * @@ -521,7 +511,7 @@ return type->name; } -/* +/* Set the clientdata field for a type */ SWIGRUNTIME void @@ -529,14 +519,14 @@ swig_cast_info *cast = ti->cast; /* if (ti->clientdata == clientdata) return; */ ti->clientdata = clientdata; - + while (cast) { if (!cast->converter) { swig_type_info *tc = cast->type; if (!tc->clientdata) { SWIG_TypeClientData(tc, clientdata); } - } + } cast = cast->next; } } @@ -545,18 +535,18 @@ SWIG_TypeClientData(ti, clientdata); ti->owndata = 1; } - + /* Search for a swig_type_info structure only by mangled name Search is a O(log #types) - - We start searching at module start, and finish searching when start == end. + + We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * -SWIG_MangledTypeQueryModule(swig_module_info *start, - swig_module_info *end, +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, const char *name) { swig_module_info *iter = start; do { @@ -565,11 +555,11 @@ register size_t r = iter->size - 1; do { /* since l+r >= 0, we can (>> 1) instead (/ 2) */ - register size_t i = (l + r) >> 1; + register size_t i = (l + r) >> 1; const char *iname = iter->types[i]->name; if (iname) { register int compare = strcmp(name, iname); - if (compare == 0) { + if (compare == 0) { return iter->types[i]; } else if (compare < 0) { if (i) { @@ -594,14 +584,14 @@ Search for a swig_type_info structure for either a mangled name or a human readable name. It first searches the mangled names of the types, which is a O(log #types) If a type is not found it then searches the human readable names, which is O(#types). - - We start searching at module start, and finish searching when start == end. + + We start searching at module start, and finish searching when start == end. Note: if start == end at the beginning of the function, we go all the way around the circular list. */ SWIGRUNTIME swig_type_info * -SWIG_TypeQueryModule(swig_module_info *start, - swig_module_info *end, +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, const char *name) { /* STEP 1: Search the name field using binary search */ swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); @@ -620,12 +610,12 @@ iter = iter->next; } while (iter != end); } - + /* neither found a match */ return 0; } -/* +/* Pack binary data into a string */ SWIGRUNTIME char * @@ -641,7 +631,7 @@ return c; } -/* +/* Unpack binary data from a string */ SWIGRUNTIME const char * @@ -655,21 +645,21 @@ uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = ((d - ('a'-10)) << 4); - else + else return (char *) 0; d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (d - ('a'-10)); - else + else return (char *) 0; *u = uu; } return c; } -/* +/* Pack 'void *' into a string buffer. */ SWIGRUNTIME char * @@ -746,6 +736,92 @@ #include /* for a few sanity tests */ /* ----------------------------------------------------------------------------- + * Lua flavors + * ----------------------------------------------------------------------------- */ + +#define SWIG_LUA_FLAVOR_LUA 1 +#define SWIG_LUA_FLAVOR_ELUA 2 +#define SWIG_LUA_FLAVOR_ELUAC 3 + +#if !defined(SWIG_LUA_TARGET) +# error SWIG_LUA_TARGET not defined +#endif + +#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC) +# define SWIG_LUA_CONSTTAB_INT(B, C) LSTRKEY(B), LNUMVAL(C) +# define SWIG_LUA_CONSTTAB_FLOAT(B, C) LSTRKEY(B), LNUMVAL(C) +# define SWIG_LUA_CONSTTAB_STRING(B, C) LSTRKEY(B), LSTRVAL(C) +# define SWIG_LUA_CONSTTAB_CHAR(B, C) LSTRKEY(B), LNUMVAL(C) +#else /* SWIG_LUA_FLAVOR_LUA */ +# define SWIG_LUA_CONSTTAB_INT(B, C) SWIG_LUA_INT, (char *)B, (long)C, 0, 0, 0 +# define SWIG_LUA_CONSTTAB_FLOAT(B, C) SWIG_LUA_FLOAT, (char *)B, 0, (double)C, 0, 0 +# define SWIG_LUA_CONSTTAB_STRING(B, C) SWIG_LUA_STRING, (char *)B, 0, 0, (void *)C, 0 +# define SWIG_LUA_CONSTTAB_CHAR(B, C) SWIG_LUA_CHAR, (char *)B, (long)C, 0, 0, 0 +#endif + +#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC) +# define LRO_STRVAL(v) {{.p = (char *) v}, LUA_TSTRING} +# define LSTRVAL LRO_STRVAL +#endif + +/* ----------------------------------------------------------------------------- + * compatibility defines + * ----------------------------------------------------------------------------- */ + +/* History of Lua C API length functions: In Lua 5.0 (and before?) + there was "lua_strlen". In Lua 5.1, this was renamed "lua_objlen", + but a compatibility define of "lua_strlen" was added. In Lua 5.2, + this function was again renamed, to "lua_rawlen" (to emphasize that + it doesn't call the "__len" metamethod), and the compatibility + define of lua_strlen was removed. All SWIG uses have been updated + to "lua_rawlen", and we add our own defines of that here for older + versions of Lua. */ +#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 +# define lua_rawlen lua_strlen +#elif LUA_VERSION_NUM == 501 +# define lua_rawlen lua_objlen +#endif + + +/* lua_pushglobaltable is the recommended "future-proof" way to get + the global table for Lua 5.2 and later. Here we define + lua_pushglobaltable ourselves for Lua versions before 5.2. */ +#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 502 +# define lua_pushglobaltable(L) lua_pushvalue(L, LUA_GLOBALSINDEX) +#endif + + +/* -------------------------------------------------------------------------- + * Helper functions for error handling + * -------------------------------------------------------------------------- */ + +/* Push the string STR on the Lua stack, like lua_pushstring, but + prefixed with the the location of the innermost Lua call-point + (as formated by luaL_where). */ +SWIGRUNTIME void +SWIG_Lua_pusherrstring (lua_State *L, const char *str) +{ + luaL_where (L, 1); + lua_pushstring (L, str); + lua_concat (L, 2); +} + +/* Push a formatted string generated from FMT and following args on + the Lua stack, like lua_pushfstring, but prefixed with the the + location of the innermost Lua call-point (as formated by luaL_where). */ +SWIGRUNTIME void +SWIG_Lua_pushferrstring (lua_State *L, const char *fmt, ...) +{ + va_list argp; + va_start(argp, fmt); + luaL_where(L, 1); + lua_pushvfstring(L, fmt, argp); + va_end(argp); + lua_concat(L, 2); +} + + +/* ----------------------------------------------------------------------------- * global swig types * ----------------------------------------------------------------------------- */ /* Constant table */ @@ -784,6 +860,15 @@ lua_CFunction setmethod; } swig_lua_attribute; +// Can be used to create namespaces. Currently used to +// wrap class static methods/variables/constants +typedef struct { + const char *name; + swig_lua_method *ns_methods; + swig_lua_attribute *ns_attributes; + swig_lua_const_info *ns_constants; +} swig_lua_namespace; + typedef struct swig_lua_class { const char *name; swig_type_info **type; @@ -791,11 +876,12 @@ void (*destructor)(void *); swig_lua_method *methods; swig_lua_attribute *attributes; + swig_lua_namespace cls_static; struct swig_lua_class **bases; const char **base_names; } swig_lua_class; -/* this is the struct for wrappering all pointers in SwigLua +/* this is the struct for wrapping all pointers in SwigLua */ typedef struct { swig_type_info *type; @@ -803,7 +889,7 @@ void *ptr; } swig_lua_userdata; -/* this is the struct for wrapping arbitary packed binary data +/* this is the struct for wrapping arbitrary packed binary data (currently it is only used for member function pointers) the data ordering is similar to swig_lua_userdata, but it is currently not possible to tell the two structures apart within SWIG, other than by looking at the type @@ -829,19 +915,20 @@ /* Contract support */ #define SWIG_contract_assert(expr, msg) \ - if (!(expr)) { lua_pushstring(L, (char *) msg); goto fail; } else + if (!(expr)) { SWIG_Lua_pusherrstring(L, (char *) msg); goto fail; } else + /* helper #defines */ #define SWIG_fail {goto fail;} #define SWIG_fail_arg(func_name,argnum,type) \ - {lua_pushfstring(L,"Error in %s (arg %d), expected '%s' got '%s'",\ + {SWIG_Lua_pushferrstring(L,"Error in %s (arg %d), expected '%s' got '%s'",\ func_name,argnum,type,SWIG_Lua_typename(L,argnum));\ goto fail;} #define SWIG_fail_ptr(func_name,argnum,type) \ SWIG_fail_arg(func_name,argnum,(type && type->str)?type->str:"void*") #define SWIG_check_num_args(func_name,a,b) \ if (lua_gettop(L)b) \ - {lua_pushfstring(L,"Error in %s expected %d..%d args, got %d",func_name,a,b,lua_gettop(L));\ + {SWIG_Lua_pushferrstring(L,"Error in %s expected %d..%d args, got %d",func_name,a,b,lua_gettop(L));\ goto fail;} @@ -887,15 +974,14 @@ * ----------------------------------------------------------------------------- */ /* this function is called when trying to set an immutable. -default value is to print an error. +default action is to print an error. This can removed with a compile flag SWIGLUA_IGNORE_SET_IMMUTABLE */ SWIGINTERN int SWIG_Lua_set_immutable(lua_State* L) { /* there should be 1 param passed in: the new value */ #ifndef SWIGLUA_IGNORE_SET_IMMUTABLE lua_pop(L,1); /* remove it */ - lua_pushstring(L,"This variable is immutable"); - lua_error(L); + luaL_error(L,"This variable is immutable"); #endif return 0; /* should not return anything */ } @@ -911,12 +997,24 @@ lua_tostring(L,2)); */ /* get the metatable */ - assert(lua_istable(L,1)); /* just in case */ +#if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)) + assert(lua_isrotable(L,1)); /* just in case */ +#else + assert(lua_istable(L,1)); /* default Lua action */ +#endif lua_getmetatable(L,1); /* get the metatable */ - assert(lua_istable(L,-1)); /* just in case */ +#if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)) + assert(lua_isrotable(L,-1)); /* just in case */ +#else + assert(lua_istable(L,-1)); +#endif SWIG_Lua_get_table(L,".get"); /* get the .get table */ lua_remove(L,3); /* remove metatable */ +#if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)) + if (lua_isrotable(L,-1)) +#else if (lua_istable(L,-1)) +#endif { /* look for the key in the .get table */ lua_pushvalue(L,2); /* key */ @@ -931,7 +1029,7 @@ } lua_pop(L,1); /* remove the .get */ lua_pushnil(L); /* return a nil */ - return 1; + return 1; } /* the module.set method used for setting linked data */ @@ -943,12 +1041,24 @@ (3) any for the new value */ /* get the metatable */ - assert(lua_istable(L,1)); /* just in case */ +#if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)) + assert(lua_isrotable(L,1)); /* just in case */ +#else + assert(lua_istable(L,1)); /* default Lua action */ +#endif lua_getmetatable(L,1); /* get the metatable */ - assert(lua_istable(L,-1)); /* just in case */ +#if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)) + assert(lua_isrotable(L,-1)); /* just in case */ +#else + assert(lua_istable(L,-1)); +#endif SWIG_Lua_get_table(L,".set"); /* get the .set table */ lua_remove(L,4); /* remove metatable */ +#if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)) + if (lua_isrotable(L,-1)) +#else if (lua_istable(L,-1)) +#endif { /* look for the key in the .set table */ lua_pushvalue(L,2); /* key */ @@ -960,6 +1070,11 @@ lua_call(L,1,0); return 0; } +#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) + else { + return 0; // Exits stoically if an invalid key is initialized. + } +#endif } lua_settop(L,3); /* reset back to start */ /* we now have the table, key & new value, so just set directly */ @@ -967,6 +1082,7 @@ return 0; } +#if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)) /* registering a module in lua. Pushes the module table on the stack. */ SWIGINTERN void SWIG_Lua_module_begin(lua_State* L,const char* name) { @@ -1021,6 +1137,7 @@ } lua_pop(L,1); /* tidy stack (remove meta) */ } +#endif /* adding a function module */ SWIGINTERN void SWIG_Lua_module_add_function(lua_State* L,const char* name,lua_CFunction fn) @@ -1029,6 +1146,137 @@ } /* ----------------------------------------------------------------------------- + * global variable support code: namespaces + * ----------------------------------------------------------------------------- */ + +SWIGINTERN int SWIG_Lua_namespace_get(lua_State* L) +{ +/* there should be 2 params passed in + (1) table (not the meta table) + (2) string name of the attribute +*/ + assert(lua_istable(L,-2)); /* just in case */ + lua_getmetatable(L,-2); + assert(lua_istable(L,-1)); + SWIG_Lua_get_table(L,".get"); /* find the .get table */ + assert(lua_istable(L,-1)); + /* look for the key in the .get table */ + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); + lua_remove(L,-2); /* stack tidy, remove .get table */ + if (lua_iscfunction(L,-1)) + { /* found it so call the fn & return its value */ + lua_call(L,0,1); /* 1 value in (userdata),1 out (result) */ + lua_remove(L,-2); /* stack tidy, remove metatable */ + return 1; + } + lua_pop(L,1); /* remove whatever was there */ + /* ok, so try the .fn table */ + SWIG_Lua_get_table(L,".fn"); /* find the .get table */ + assert(lua_istable(L,-1)); /* just in case */ + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); /* look for the fn */ + lua_remove(L,-2); /* stack tidy, remove .fn table */ + if (lua_isfunction(L,-1)) /* note: whether it's a C function or lua function */ + { /* found it so return the fn & let lua call it */ + lua_remove(L,-2); /* stack tidy, remove metatable */ + return 1; + } + lua_pop(L,1); /* remove whatever was there */ + return 0; +} + +SWIGINTERN int SWIG_Lua_namespace_set(lua_State* L) +{ +/* there should be 3 params passed in + (1) table (not the meta table) + (2) string name of the attribute + (3) any for the new value +*/ + + assert(lua_istable(L,1)); + lua_getmetatable(L,1); /* get the meta table */ + assert(lua_istable(L,-1)); + + SWIG_Lua_get_table(L,".set"); /* find the .set table */ + if (lua_istable(L,-1)) + { + /* look for the key in the .set table */ + lua_pushvalue(L,2); /* key */ + lua_rawget(L,-2); + if (lua_iscfunction(L,-1)) + { /* found it so call the fn & return its value */ + lua_pushvalue(L,3); /* value */ + lua_call(L,1,0); + return 0; + } + lua_pop(L,1); /* remove the value */ + } + lua_pop(L,1); /* remove the value .set table */ + return 0; +} + +SWIGINTERN void SWIG_Lua_InstallConstants(lua_State* L, swig_lua_const_info constants[]); // forward declaration +SWIGINTERN void SWIG_Lua_add_class_variable(lua_State* L,const char* name,lua_CFunction getFn,lua_CFunction setFn); // forward declaration + +/* helper function - register namespace methods and attributes into namespace */ +SWIGINTERN int SWIG_Lua_add_namespace_details(lua_State* L, swig_lua_namespace* ns) +{ + int i = 0; + assert(lua_istable(L,-1)); + /* There must be table at the top of the stack */ + SWIG_Lua_InstallConstants(L, ns->ns_constants); + + lua_getmetatable(L,-1); + + /* add fns */ + for(i=0;ns->ns_attributes[i].name;i++){ + SWIG_Lua_add_class_variable(L,ns->ns_attributes[i].name,ns->ns_attributes[i].getmethod,ns->ns_attributes[i].setmethod); + } + + /* add methods to the metatable */ + SWIG_Lua_get_table(L,".fn"); /* find the .fn table */ + assert(lua_istable(L,-1)); /* just in case */ + for(i=0;ns->ns_methods[i].name;i++){ + SWIG_Lua_add_function(L,ns->ns_methods[i].name,ns->ns_methods[i].method); + } + lua_pop(L,1); + + /* clear stack - remove metatble */ + lua_pop(L,1); + +} + +/* helper function. creates namespace table and add it to module table */ +SWIGINTERN int SWIG_Lua_namespace_register(lua_State* L, swig_lua_namespace* ns) +{ + assert(lua_istable(L,-1)); /* just in case. This is supposed to be module table */ + lua_checkstack(L,5); + lua_pushstring(L, ns->name); + lua_newtable(L); /* namespace itself */ + lua_newtable(L); /* metatable for namespace */ + + /* add a table called ".get" */ + lua_pushstring(L,".get"); + lua_newtable(L); + lua_rawset(L,-3); + /* add a table called ".set" */ + lua_pushstring(L,".set"); + lua_newtable(L); + lua_rawset(L,-3); + /* add a table called ".fn" */ + lua_pushstring(L,".fn"); + lua_newtable(L); + lua_rawset(L,-3); + + /* add accessor fns for using the .get,.set&.fn */ + SWIG_Lua_add_function(L,"__index",SWIG_Lua_namespace_get); + SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_namespace_set); + + lua_setmetatable(L,-2); /* set metatable */ + lua_rawset(L,-3); /* add namespace to module table */ +} +/* ----------------------------------------------------------------------------- * global variable support code: classes * ----------------------------------------------------------------------------- */ @@ -1150,6 +1398,56 @@ return 0; } +/* the class.__tostring method called by the interpreter and print */ +SWIGINTERN int SWIG_Lua_class_tostring(lua_State* L) +{ +/* there should be 1 param passed in + (1) userdata (not the metatable) */ + assert(lua_isuserdata(L,1)); /* just in case */ + unsigned long userData = (unsigned long)lua_touserdata(L,1); /* get the userdata address for later */ + lua_getmetatable(L,1); /* get the meta table */ + assert(lua_istable(L,-1)); /* just in case */ + + lua_getfield(L, -1, ".type"); + const char* className = lua_tostring(L, -1); + + char output[256]; + sprintf(output, "<%s userdata: %lX>", className, userData); + + lua_pushstring(L, (const char*)output); + return 1; +} + +/* to manually disown some userdata */ +SWIGINTERN int SWIG_Lua_class_disown(lua_State* L) +{ +/* there should be 1 params passed in + (1) userdata (not the meta table) */ + swig_lua_userdata* usr; + assert(lua_isuserdata(L,-1)); /* just in case */ + usr=(swig_lua_userdata*)lua_touserdata(L,-1); /* get it */ + + usr->own = 0; /* clear our ownership */ + return 0; +} + +/* Constructor proxy. Used when class name entry in module is not class constructor, +but special table instead. */ +SWIGINTERN int SWIG_Lua_constructor_proxy(lua_State* L) +{ + /* unlimited number of parameters + First one is our proxy table and we should remove it + Other we should pass to real constructor + */ + assert(lua_istable(L,1)); + lua_pushstring(L,".constructor"); + lua_rawget(L,1); + assert(!lua_isnil(L,-1)); + lua_replace(L,1); /* replace our table with real constructor */ + lua_call(L,lua_gettop(L)-1,1); + return 1; +} + /* gets the swig class registry (or creates it) */ SWIGINTERN void SWIG_Lua_get_class_registry(lua_State* L) { @@ -1194,6 +1492,21 @@ } } +/* helper to recursively add class static details (static attributes, operations and constants) */ +SWIGINTERN void SWIG_Lua_add_class_static_details(lua_State* L, swig_lua_class* clss) +{ + int i = 0; + /* The class namespace table must be on the top of the stack */ + assert(lua_istable(L,-1)); + /* call all the base classes first: we can then override these later: */ + for(i=0;clss->bases[i];i++) + { + SWIG_Lua_add_class_static_details(L,clss->bases[i]); + } + + SWIG_Lua_add_namespace_details(L, &clss->cls_static); +} + /* helper to recursively add class details (attributes & operations) */ SWIGINTERN void SWIG_Lua_add_class_details(lua_State* L,swig_lua_class* clss) { @@ -1244,18 +1557,45 @@ swig_type_info *info = SWIG_TypeQueryModule(module,module,clss->base_names[i]); if (info) clss->bases[i] = (swig_lua_class *) info->clientdata; } - } + } } -/* performs the entire class registration process */ -SWIGINTERN void SWIG_Lua_class_register(lua_State* L,swig_lua_class* clss) +/* Register class static methods,attributes etc as well as constructor proxy */ +SWIGINTERN void SWIG_Lua_class_register_static(lua_State* L, swig_lua_class* clss) { + lua_checkstack(L,5); /* just in case */ + assert(lua_istable(L,-1)); /* just in case */ + assert(strcmp(clss->name, clss->cls_static.name) == 0); /* in class those 2 must be equal */ + + SWIG_Lua_namespace_register(L,&clss->cls_static); + + SWIG_Lua_get_table(L,clss->name); // Get namespace table back + assert(lua_istable(L,-1)); /* just in case */ + /* add its constructor to module with the name of the class so you can do MyClass(...) as well as new_MyClass(...) BUT only if a constructor is defined (this overcomes the problem of pure virtual classes without constructors)*/ if (clss->constructor) - SWIG_Lua_add_function(L,clss->name,clss->constructor); + { + SWIG_Lua_add_function(L,".constructor", clss->constructor); + lua_getmetatable(L,-1); + assert(lua_istable(L,-1)); /* just in case */ + SWIG_Lua_add_function(L,"__call", SWIG_Lua_constructor_proxy); + lua_pop(L,1); + } + + assert(lua_istable(L,-1)); /* just in case */ + SWIG_Lua_add_class_static_details(L, clss); + + /* clear stack */ + lua_pop(L,1); +} + +/* performs the entire class registration process */ +SWIGINTERN void SWIG_Lua_class_register(lua_State* L,swig_lua_class* clss) +{ + SWIG_Lua_class_register_static(L,clss); SWIG_Lua_get_class_registry(L); /* get the registry */ lua_pushstring(L,clss->name); /* get the name */ @@ -1275,11 +1615,15 @@ /* add a table called ".fn" */ lua_pushstring(L,".fn"); lua_newtable(L); + /* add manual disown method */ + SWIG_Lua_add_function(L,"__disown",SWIG_Lua_class_disown); lua_rawset(L,-3); /* add accessor fns for using the .get,.set&.fn */ SWIG_Lua_add_function(L,"__index",SWIG_Lua_class_get); SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_class_set); SWIG_Lua_add_function(L,"__gc",SWIG_Lua_class_destruct); + /* add tostring method for better output */ + SWIG_Lua_add_function(L,"__tostring",SWIG_Lua_class_tostring); /* add it */ lua_rawset(L,-3); /* metatable into registry */ lua_pop(L,1); /* tidy stack (remove registry) */ @@ -1322,7 +1666,9 @@ usr->ptr=ptr; /* set the ptr */ usr->type=type; usr->own=own; +#if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) _SWIG_Lua_AddMetatable(L,type); /* add metatable */ +#endif } /* takes a object from the lua stack & converts it into an object of the correct type @@ -1360,9 +1706,8 @@ int argnum,const char* func_name){ void* result; if (!SWIG_IsOK(SWIG_ConvertPtr(L,index,&result,type,flags))){ - lua_pushfstring(L,"Error in %s, expected a %s at argument number %d\n", - func_name,(type && type->str)?type->str:"void*",argnum); - lua_error(L); + luaL_error (L,"Error in %s, expected a %s at argument number %d\n", + func_name,(type && type->str)?type->str:"void*",argnum); } return result; } @@ -1435,6 +1780,7 @@ * global variable support code: class/struct typemap functions * ----------------------------------------------------------------------------- */ +#if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)) /* Install Constants */ SWIGINTERN void SWIG_Lua_InstallConstants(lua_State* L, swig_lua_const_info constants[]) { @@ -1476,6 +1822,7 @@ } } } +#endif /* ----------------------------------------------------------------------------- * executing lua code from within the wrapper @@ -1484,8 +1831,8 @@ #ifndef SWIG_DOSTRING_FAIL /* Allows redefining of error function */ #define SWIG_DOSTRING_FAIL(S) fprintf(stderr,"%s\n",S) #endif -/* Executes a C string in Lua a really simple way of calling lua from C -Unfortunately lua keeps changing its API's, so we need a conditional compile +/* Executes a C string in Lua which is a really simple way of calling lua from C +Unfortunately lua keeps changing its APIs, so we need a conditional compile In lua 5.0.X its lua_dostring() In lua 5.1.X its luaL_dostring() */ @@ -1513,18 +1860,18 @@ /* ------------------------------ end luarun.swg ------------------------------ */ /* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 #define SWIG_SystemError -10 #define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 +#define SWIG_MemoryError -12 #define SWIG_NullReferenceError -13 @@ -1561,7 +1908,6 @@ #define SWIG_LUACODE luaopen_api_luacode - namespace swig { typedef struct{} LANGUAGE_OBJ; } @@ -1618,12 +1964,12 @@ SWIGINTERN TYPE* SWIG_get_##NAME##_num_array_fixed(lua_State* L, int index, int size){\ TYPE *array;\ if (!lua_istable(L,index) || SWIG_itable_size(L,index) != size) {\ - lua_pushfstring(L,"expected a table of size %d",size);\ + SWIG_Lua_pushferrstring(L,"expected a table of size %d",size);\ return 0;\ }\ array=SWIG_ALLOC_ARRAY(TYPE,size);\ if (!SWIG_read_##NAME##_num_array(L,index,array,size)){\ - lua_pushstring(L,"table must contain numbers");\ + SWIG_Lua_pusherrstring(L,"table must contain numbers");\ SWIG_FREE_ARRAY(array);\ return 0;\ }\ @@ -1633,17 +1979,17 @@ {\ TYPE *array;\ if (!lua_istable(L,index)) {\ - lua_pushstring(L,"expected a table");\ + SWIG_Lua_pusherrstring(L,"expected a table");\ return 0;\ }\ *size=SWIG_itable_size(L,index);\ if (*size<1){\ - lua_pushstring(L,"table appears to be empty");\ + SWIG_Lua_pusherrstring(L,"table appears to be empty");\ return 0;\ }\ array=SWIG_ALLOC_ARRAY(TYPE,*size);\ if (!SWIG_read_##NAME##_num_array(L,index,array,*size)){\ - lua_pushstring(L,"table must contain numbers");\ + SWIG_Lua_pusherrstring(L,"table must contain numbers");\ SWIG_FREE_ARRAY(array);\ return 0;\ }\ @@ -1684,12 +2030,12 @@ SWIGINTERN void** SWIG_get_ptr_array_fixed(lua_State* L, int index, int size,swig_type_info *type){ void **array; if (!lua_istable(L,index) || SWIG_itable_size(L,index) != size) { - lua_pushfstring(L,"expected a table of size %d",size); + SWIG_Lua_pushferrstring(L,"expected a table of size %d",size); return 0; } array=SWIG_ALLOC_ARRAY(void*,size); if (!SWIG_read_ptr_array(L,index,array,size,type)){ - lua_pushfstring(L,"table must contain pointers of type %s",type->name); + SWIG_Lua_pushferrstring(L,"table must contain pointers of type %s",type->name); SWIG_FREE_ARRAY(array); return 0; } @@ -1698,17 +2044,17 @@ SWIGINTERN void** SWIG_get_ptr_array_var(lua_State* L, int index, int* size,swig_type_info *type){ void **array; if (!lua_istable(L,index)) { - lua_pushstring(L,"expected a table"); + SWIG_Lua_pusherrstring(L,"expected a table"); return 0; } *size=SWIG_itable_size(L,index); if (*size<1){ - lua_pushstring(L,"table appears to be empty"); + SWIG_Lua_pusherrstring(L,"table appears to be empty"); return 0; } array=SWIG_ALLOC_ARRAY(void*,*size); if (!SWIG_read_ptr_array(L,index,array,*size,type)){ - lua_pushfstring(L,"table must contain pointers of type %s",type->name); + SWIG_Lua_pushferrstring(L,"table must contain pointers of type %s",type->name); SWIG_FREE_ARRAY(array); return 0; } @@ -1724,7 +2070,7 @@ } - #include +#include SWIGINTERN int SWIG_lua_isnilstring(lua_State *L, int idx) { @@ -1860,7 +2206,7 @@ } } - lua_pushstring(L,"Wrong arguments for overloaded function 'new_string'\n" + SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_string'\n" " Possible C/C++ prototypes are:\n" " std::string::string()\n" " std::string::string(char const *)\n"); @@ -2030,11 +2376,46 @@ static swig_lua_attribute swig_std_string_attributes[] = { {0,0,0} }; +static swig_lua_attribute swig_std_string_cls_attributes[] = { + {0,0,0} +}; +static swig_lua_method swig_std_string_cls_methods[] = { + {0,0} +}; +static swig_lua_const_info swig_std_string_cls_constants[] = { + {0,0,0,0,0,0} +}; static swig_lua_class *swig_std_string_bases[] = {0}; static const char *swig_std_string_base_names[] = {0}; -static swig_lua_class _wrap_class_std_string = { "string", &SWIGTYPE_p_std__string,_wrap_new_string, swig_delete_string, swig_std_string_methods, swig_std_string_attributes, swig_std_string_bases, swig_std_string_base_names }; +static swig_lua_class _wrap_class_std_string = { "string", &SWIGTYPE_p_std__string,_wrap_new_string, swig_delete_string, swig_std_string_methods, swig_std_string_attributes, { "string", swig_std_string_cls_methods, swig_std_string_cls_attributes, swig_std_string_cls_constants }, swig_std_string_bases, swig_std_string_base_names }; -static int _wrap_new_Position(lua_State* L) { +static int _wrap_new_Position__SWIG_0(lua_State* L) { + int SWIG_arg = 0; + float arg1 ; + float arg2 ; + float arg3 ; + Position *result = 0 ; + + SWIG_check_num_args("Position::Position",3,3) + if(!lua_isnumber(L,1)) SWIG_fail_arg("Position::Position",1,"float"); + if(!lua_isnumber(L,2)) SWIG_fail_arg("Position::Position",2,"float"); + if(!lua_isnumber(L,3)) SWIG_fail_arg("Position::Position",3,"float"); + arg1 = (float)lua_tonumber(L, 1); + arg2 = (float)lua_tonumber(L, 2); + arg3 = (float)lua_tonumber(L, 3); + result = (Position *)new Position(arg1,arg2,arg3); + SWIG_NewPointerObj(L,result,SWIGTYPE_p_Position,1); SWIG_arg++; + return SWIG_arg; + + if(0) SWIG_fail; + +fail: + lua_error(L); + return SWIG_arg; +} + + +static int _wrap_new_Position__SWIG_1(lua_State* L) { int SWIG_arg = 0; Position *result = 0 ; @@ -2051,6 +2432,44 @@ } +static int _wrap_new_Position(lua_State* L) { + int argc; + int argv[4]={ + 1,2,3,4 + }; + + argc = lua_gettop(L); + if (argc == 0) { + return _wrap_new_Position__SWIG_1(L); + } + if (argc == 3) { + int _v; + { + _v = lua_isnumber(L,argv[0]); + } + if (_v) { + { + _v = lua_isnumber(L,argv[1]); + } + if (_v) { + { + _v = lua_isnumber(L,argv[2]); + } + if (_v) { + return _wrap_new_Position__SWIG_0(L); + } + } + } + } + + SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_Position'\n" + " Possible C/C++ prototypes are:\n" + " Position::Position(float,float,float)\n" + " Position::Position()\n"); + lua_error(L);return 0; +} + + static int _wrap_Position_x_set(lua_State* L) { int SWIG_arg = 0; Position *arg1 = (Position *) 0 ; @@ -2214,9 +2633,18 @@ { "z", _wrap_Position_z_get, _wrap_Position_z_set}, {0,0,0} }; +static swig_lua_attribute swig_Position_cls_attributes[] = { + {0,0,0} +}; +static swig_lua_method swig_Position_cls_methods[] = { + {0,0} +}; +static swig_lua_const_info swig_Position_cls_constants[] = { + {0,0,0,0,0,0} +}; static swig_lua_class *swig_Position_bases[] = {0}; static const char *swig_Position_base_names[] = {0}; -static swig_lua_class _wrap_class_Position = { "Position", &SWIGTYPE_p_Position,_wrap_new_Position, swig_delete_Position, swig_Position_methods, swig_Position_attributes, swig_Position_bases, swig_Position_base_names }; +static swig_lua_class _wrap_class_Position = { "Position", &SWIGTYPE_p_Position,_wrap_new_Position, swig_delete_Position, swig_Position_methods, swig_Position_attributes, { "Position", swig_Position_cls_methods, swig_Position_cls_attributes, swig_Position_cls_constants }, swig_Position_bases, swig_Position_base_names }; static int _wrap_new_SResourceData(lua_State* L) { int SWIG_arg = 0; @@ -2299,7 +2727,7 @@ SWIG_fail_ptr("SResourceData_name_set",1,SWIGTYPE_p_SResourceData); } - temp2.assign(lua_tostring(L,2),lua_strlen(L,2)); arg2=&temp2; + temp2.assign(lua_tostring(L,2),lua_rawlen(L,2)); arg2=&temp2; if (arg1) (arg1)->name = *arg2; return SWIG_arg; @@ -2603,9 +3031,18 @@ { "gameframe", _wrap_SResourceData_gameframe_get, _wrap_SResourceData_gameframe_set}, {0,0,0} }; +static swig_lua_attribute swig_SResourceData_cls_attributes[] = { + {0,0,0} +}; +static swig_lua_method swig_SResourceData_cls_methods[] = { + {0,0} +}; +static swig_lua_const_info swig_SResourceData_cls_constants[] = { + {0,0,0,0,0,0} +}; static swig_lua_class *swig_SResourceData_bases[] = {0}; static const char *swig_SResourceData_base_names[] = {0}; -static swig_lua_class _wrap_class_SResourceData = { "SResourceData", &SWIGTYPE_p_SResourceData,_wrap_new_SResourceData, swig_delete_SResourceData, swig_SResourceData_methods, swig_SResourceData_attributes, swig_SResourceData_bases, swig_SResourceData_base_names }; +static swig_lua_class _wrap_class_SResourceData = { "SResourceData", &SWIGTYPE_p_SResourceData,_wrap_new_SResourceData, swig_delete_SResourceData, swig_SResourceData_methods, swig_SResourceData_attributes, { "SResourceData", swig_SResourceData_cls_methods, swig_SResourceData_cls_attributes, swig_SResourceData_cls_constants }, swig_SResourceData_bases, swig_SResourceData_base_names }; static int _wrap_new_SResourceTransfer(lua_State* L) { int SWIG_arg = 0; @@ -2894,9 +3331,18 @@ { "gameframe", _wrap_SResourceTransfer_gameframe_get, _wrap_SResourceTransfer_gameframe_set}, {0,0,0} }; +static swig_lua_attribute swig_SResourceTransfer_cls_attributes[] = { + {0,0,0} +}; +static swig_lua_method swig_SResourceTransfer_cls_methods[] = { + {0,0} +}; +static swig_lua_const_info swig_SResourceTransfer_cls_constants[] = { + {0,0,0,0,0,0} +}; static swig_lua_class *swig_SResourceTransfer_bases[] = {0}; static const char *swig_SResourceTransfer_base_names[] = {0}; -static swig_lua_class _wrap_class_SResourceTransfer = { "SResourceTransfer", &SWIGTYPE_p_SResourceTransfer,_wrap_new_SResourceTransfer, swig_delete_SResourceTransfer, swig_SResourceTransfer_methods, swig_SResourceTransfer_attributes, swig_SResourceTransfer_bases, swig_SResourceTransfer_base_names }; +static swig_lua_class _wrap_class_SResourceTransfer = { "SResourceTransfer", &SWIGTYPE_p_SResourceTransfer,_wrap_new_SResourceTransfer, swig_delete_SResourceTransfer, swig_SResourceTransfer_methods, swig_SResourceTransfer_attributes, { "SResourceTransfer", swig_SResourceTransfer_cls_methods, swig_SResourceTransfer_cls_attributes, swig_SResourceTransfer_cls_constants }, swig_SResourceTransfer_bases, swig_SResourceTransfer_base_names }; static int _wrap_IMapFeature_ID(lua_State* L) { int SWIG_arg = 0; @@ -3039,9 +3485,18 @@ static swig_lua_attribute swig_IMapFeature_attributes[] = { {0,0,0} }; +static swig_lua_attribute swig_IMapFeature_cls_attributes[] = { + {0,0,0} +}; +static swig_lua_method swig_IMapFeature_cls_methods[] = { + {0,0} +}; +static swig_lua_const_info swig_IMapFeature_cls_constants[] = { + {0,0,0,0,0,0} +}; static swig_lua_class *swig_IMapFeature_bases[] = {0}; static const char *swig_IMapFeature_base_names[] = {0}; -static swig_lua_class _wrap_class_IMapFeature = { "IMapFeature", &SWIGTYPE_p_IMapFeature,0, swig_delete_IMapFeature, swig_IMapFeature_methods, swig_IMapFeature_attributes, swig_IMapFeature_bases, swig_IMapFeature_base_names }; +static swig_lua_class _wrap_class_IMapFeature = { "IMapFeature", &SWIGTYPE_p_IMapFeature,0, swig_delete_IMapFeature, swig_IMapFeature_methods, swig_IMapFeature_attributes, { "IMapFeature", swig_IMapFeature_cls_methods, swig_IMapFeature_cls_attributes, swig_IMapFeature_cls_constants }, swig_IMapFeature_bases, swig_IMapFeature_base_names }; static int _wrap_IMap_MapName(lua_State* L) { int SWIG_arg = 0; @@ -3593,9 +4048,18 @@ static swig_lua_attribute swig_IMap_attributes[] = { {0,0,0} }; +static swig_lua_attribute swig_IMap_cls_attributes[] = { + {0,0,0} +}; +static swig_lua_method swig_IMap_cls_methods[] = { + {0,0} +}; +static swig_lua_const_info swig_IMap_cls_constants[] = { + {0,0,0,0,0,0} +}; static swig_lua_class *swig_IMap_bases[] = {0}; static const char *swig_IMap_base_names[] = {0}; -static swig_lua_class _wrap_class_IMap = { "IMap", &SWIGTYPE_p_IMap,0, swig_delete_IMap, swig_IMap_methods, swig_IMap_attributes, swig_IMap_bases, swig_IMap_base_names }; +static swig_lua_class _wrap_class_IMap = { "IMap", &SWIGTYPE_p_IMap,0, swig_delete_IMap, swig_IMap_methods, swig_IMap_attributes, { "IMap", swig_IMap_cls_methods, swig_IMap_cls_attributes, swig_IMap_cls_constants }, swig_IMap_bases, swig_IMap_base_names }; static int _wrap_IUnitType_Name(lua_State* L) { int SWIG_arg = 0; @@ -3813,9 +4277,18 @@ static swig_lua_attribute swig_IUnitType_attributes[] = { {0,0,0} }; +static swig_lua_attribute swig_IUnitType_cls_attributes[] = { + {0,0,0} +}; +static swig_lua_method swig_IUnitType_cls_methods[] = { + {0,0} +}; +static swig_lua_const_info swig_IUnitType_cls_constants[] = { + {0,0,0,0,0,0} +}; static swig_lua_class *swig_IUnitType_bases[] = {0}; static const char *swig_IUnitType_base_names[] = {0}; -static swig_lua_class _wrap_class_IUnitType = { "IUnitType", &SWIGTYPE_p_IUnitType,0, swig_delete_IUnitType, swig_IUnitType_methods, swig_IUnitType_attributes, swig_IUnitType_bases, swig_IUnitType_base_names }; +static swig_lua_class _wrap_class_IUnitType = { "IUnitType", &SWIGTYPE_p_IUnitType,0, swig_delete_IUnitType, swig_IUnitType_methods, swig_IUnitType_attributes, { "IUnitType", swig_IUnitType_cls_methods, swig_IUnitType_cls_attributes, swig_IUnitType_cls_constants }, swig_IUnitType_bases, swig_IUnitType_base_names }; static int _wrap_IUnit_ID(lua_State* L) { int SWIG_arg = 0; @@ -4342,7 +4815,7 @@ SWIG_fail_ptr("IUnit_Build",1,SWIGTYPE_p_IUnit); } - (&arg2)->assign(lua_tostring(L,2),lua_strlen(L,2)); + (&arg2)->assign(lua_tostring(L,2),lua_rawlen(L,2)); result = (bool)(arg1)->Build(arg2); lua_pushboolean(L,(int)(result!=0)); SWIG_arg++; return SWIG_arg; @@ -4372,7 +4845,7 @@ SWIG_fail_ptr("IUnit_Build",1,SWIGTYPE_p_IUnit); } - (&arg2)->assign(lua_tostring(L,2),lua_strlen(L,2)); + (&arg2)->assign(lua_tostring(L,2),lua_rawlen(L,2)); if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&argp3,SWIGTYPE_p_Position,0))){ SWIG_fail_ptr("IUnit_Build",3,SWIGTYPE_p_Position); @@ -4450,7 +4923,7 @@ SWIG_fail_ptr("IUnit_Build",1,SWIGTYPE_p_IUnit); } - (&arg2)->assign(lua_tostring(L,2),lua_strlen(L,2)); + (&arg2)->assign(lua_tostring(L,2),lua_rawlen(L,2)); if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&argp3,SWIGTYPE_p_Position,0))){ SWIG_fail_ptr("IUnit_Build",3,SWIGTYPE_p_Position); @@ -4700,7 +5173,7 @@ } } - lua_pushstring(L,"Wrong arguments for overloaded function 'IUnit_Build'\n" + SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'IUnit_Build'\n" " Possible C/C++ prototypes are:\n" " IUnit::Build(IUnitType *)\n" " IUnit::Build(std::string)\n" @@ -4866,7 +5339,7 @@ } } - lua_pushstring(L,"Wrong arguments for overloaded function 'IUnit_Reclaim'\n" + SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'IUnit_Reclaim'\n" " Possible C/C++ prototypes are:\n" " IUnit::Reclaim(IMapFeature *)\n" " IUnit::Reclaim(IUnit *)\n"); @@ -5167,7 +5640,7 @@ } } - lua_pushstring(L,"Wrong arguments for overloaded function 'IUnit_CanBuild'\n" + SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'IUnit_CanBuild'\n" " Possible C/C++ prototypes are:\n" " IUnit::CanBuild()\n" " IUnit::CanBuild(IUnitType *)\n"); @@ -5429,7 +5902,7 @@ } } - lua_pushstring(L,"Wrong arguments for overloaded function 'IUnit_ExecuteCustomCommand'\n" + SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'IUnit_ExecuteCustomCommand'\n" " Possible C/C++ prototypes are:\n" " IUnit::ExecuteCustomCommand(int,std::vector< float >,short,int)\n" " IUnit::ExecuteCustomCommand(int,std::vector< float >,short)\n" @@ -5480,9 +5953,18 @@ static swig_lua_attribute swig_IUnit_attributes[] = { {0,0,0} }; +static swig_lua_attribute swig_IUnit_cls_attributes[] = { + {0,0,0} +}; +static swig_lua_method swig_IUnit_cls_methods[] = { + {0,0} +}; +static swig_lua_const_info swig_IUnit_cls_constants[] = { + {0,0,0,0,0,0} +}; static swig_lua_class *swig_IUnit_bases[] = {0}; static const char *swig_IUnit_base_names[] = {0}; -static swig_lua_class _wrap_class_IUnit = { "IUnit", &SWIGTYPE_p_IUnit,0, swig_delete_IUnit, swig_IUnit_methods, swig_IUnit_attributes, swig_IUnit_bases, swig_IUnit_base_names }; +static swig_lua_class _wrap_class_IUnit = { "IUnit", &SWIGTYPE_p_IUnit,0, swig_delete_IUnit, swig_IUnit_methods, swig_IUnit_attributes, { "IUnit", swig_IUnit_cls_methods, swig_IUnit_cls_attributes, swig_IUnit_cls_constants }, swig_IUnit_bases, swig_IUnit_base_names }; static int _wrap_IGame_SendToConsole(lua_State* L) { int SWIG_arg = 0; @@ -5497,7 +5979,7 @@ SWIG_fail_ptr("IGame_SendToConsole",1,SWIGTYPE_p_IGame); } - (&arg2)->assign(lua_tostring(L,2),lua_strlen(L,2)); + (&arg2)->assign(lua_tostring(L,2),lua_rawlen(L,2)); (arg1)->SendToConsole(arg2); return SWIG_arg; @@ -5596,7 +6078,7 @@ SWIG_fail_ptr("IGame_GetTypeByName",1,SWIGTYPE_p_IGame); } - (&arg2)->assign(lua_tostring(L,2),lua_strlen(L,2)); + (&arg2)->assign(lua_tostring(L,2),lua_rawlen(L,2)); result = (IUnitType *)(arg1)->GetTypeByName(arg2); SWIG_NewPointerObj(L,result,SWIGTYPE_p_IUnitType,0); SWIG_arg++; return SWIG_arg; @@ -5647,7 +6129,7 @@ SWIG_fail_ptr("IGame_ReadFile",1,SWIGTYPE_p_IGame); } - (&arg2)->assign(lua_tostring(L,2),lua_strlen(L,2)); + (&arg2)->assign(lua_tostring(L,2),lua_rawlen(L,2)); result = (arg1)->ReadFile(arg2); lua_pushlstring(L,(&result)->data(),(&result)->size()); SWIG_arg++; return SWIG_arg; @@ -5882,7 +6364,7 @@ SWIG_fail_ptr("IGame_FileExists",1,SWIGTYPE_p_IGame); } - (&arg2)->assign(lua_tostring(L,2),lua_strlen(L,2)); + (&arg2)->assign(lua_tostring(L,2),lua_rawlen(L,2)); result = (bool)(arg1)->FileExists(arg2); lua_pushboolean(L,(int)(result!=0)); SWIG_arg++; return SWIG_arg; @@ -5917,7 +6399,7 @@ } arg2 = *argp2; - (&arg3)->assign(lua_tostring(L,3),lua_strlen(L,3)); + (&arg3)->assign(lua_tostring(L,3),lua_rawlen(L,3)); (arg1)->AddMarker(arg2,arg3); return SWIG_arg; @@ -5944,7 +6426,7 @@ SWIG_fail_ptr("IGame_SendToContent",1,SWIGTYPE_p_IGame); } - (&arg2)->assign(lua_tostring(L,2),lua_strlen(L,2)); + (&arg2)->assign(lua_tostring(L,2),lua_rawlen(L,2)); result = (arg1)->SendToContent(arg2); lua_pushlstring(L,(&result)->data(),(&result)->size()); SWIG_arg++; return SWIG_arg; @@ -6025,7 +6507,7 @@ SWIG_fail_ptr("IGame_GetResourceByName",1,SWIGTYPE_p_IGame); } - (&arg2)->assign(lua_tostring(L,2),lua_strlen(L,2)); + (&arg2)->assign(lua_tostring(L,2),lua_rawlen(L,2)); result = (arg1)->GetResourceByName(arg2); { SResourceData * resultptr = new SResourceData((const SResourceData &) result); @@ -6065,6 +6547,33 @@ } +static int _wrap_IGame_getUnitByID(lua_State* L) { + int SWIG_arg = 0; + IGame *arg1 = (IGame *) 0 ; + int arg2 ; + IUnit *result = 0 ; + + SWIG_check_num_args("IGame::getUnitByID",2,2) + if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("IGame::getUnitByID",1,"IGame *"); + if(!lua_isnumber(L,2)) SWIG_fail_arg("IGame::getUnitByID",2,"int"); + + if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_IGame,0))){ + SWIG_fail_ptr("IGame_getUnitByID",1,SWIGTYPE_p_IGame); + } + + arg2 = (int)lua_tonumber(L, 2); + result = (IUnit *)(arg1)->getUnitByID(arg2); + SWIG_NewPointerObj(L,result,SWIGTYPE_p_IUnit,0); SWIG_arg++; + return SWIG_arg; + + if(0) SWIG_fail; + +fail: + lua_error(L); + return SWIG_arg; +} + + static void swig_delete_IGame(void *obj) { IGame *arg1 = (IGame *) obj; delete arg1; @@ -6092,14 +6601,24 @@ {"GetResourceCount", _wrap_IGame_GetResourceCount}, {"GetResourceByName", _wrap_IGame_GetResourceByName}, {"Me", _wrap_IGame_Me}, + {"getUnitByID", _wrap_IGame_getUnitByID}, {0,0} }; static swig_lua_attribute swig_IGame_attributes[] = { {0,0,0} }; +static swig_lua_attribute swig_IGame_cls_attributes[] = { + {0,0,0} +}; +static swig_lua_method swig_IGame_cls_methods[] = { + {0,0} +}; +static swig_lua_const_info swig_IGame_cls_constants[] = { + {0,0,0,0,0,0} +}; static swig_lua_class *swig_IGame_bases[] = {0}; static const char *swig_IGame_base_names[] = {0}; -static swig_lua_class _wrap_class_IGame = { "IGame", &SWIGTYPE_p_IGame,0, swig_delete_IGame, swig_IGame_methods, swig_IGame_attributes, swig_IGame_bases, swig_IGame_base_names }; +static swig_lua_class _wrap_class_IGame = { "IGame", &SWIGTYPE_p_IGame,0, swig_delete_IGame, swig_IGame_methods, swig_IGame_attributes, { "IGame", swig_IGame_cls_methods, swig_IGame_cls_attributes, swig_IGame_cls_constants }, swig_IGame_bases, swig_IGame_base_names }; static int _wrap_IAI_Init(lua_State* L) { int SWIG_arg = 0; @@ -6170,6 +6689,32 @@ } +static int _wrap_IAI_GameMessage(lua_State* L) { + int SWIG_arg = 0; + IAI *arg1 = (IAI *) 0 ; + char *arg2 = (char *) 0 ; + + SWIG_check_num_args("IAI::GameMessage",2,2) + if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("IAI::GameMessage",1,"IAI *"); + if(!SWIG_lua_isnilstring(L,2)) SWIG_fail_arg("IAI::GameMessage",2,"char const *"); + + if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_IAI,0))){ + SWIG_fail_ptr("IAI_GameMessage",1,SWIGTYPE_p_IAI); + } + + arg2 = (char *)lua_tostring(L, 2); + (arg1)->GameMessage((char const *)arg2); + + return SWIG_arg; + + if(0) SWIG_fail; + +fail: + lua_error(L); + return SWIG_arg; +} + + static int _wrap_IAI_UnitCreated(lua_State* L) { int SWIG_arg = 0; IAI *arg1 = (IAI *) 0 ; @@ -6395,6 +6940,7 @@ {"Init", _wrap_IAI_Init}, {"Update", _wrap_IAI_Update}, {"GameEnd", _wrap_IAI_GameEnd}, + {"GameMessage", _wrap_IAI_GameMessage}, {"UnitCreated", _wrap_IAI_UnitCreated}, {"UnitBuilt", _wrap_IAI_UnitBuilt}, {"UnitDead", _wrap_IAI_UnitDead}, @@ -6407,9 +6953,18 @@ static swig_lua_attribute swig_IAI_attributes[] = { {0,0,0} }; +static swig_lua_attribute swig_IAI_cls_attributes[] = { + {0,0,0} +}; +static swig_lua_method swig_IAI_cls_methods[] = { + {0,0} +}; +static swig_lua_const_info swig_IAI_cls_constants[] = { + {0,0,0,0,0,0} +}; static swig_lua_class *swig_IAI_bases[] = {0}; static const char *swig_IAI_base_names[] = {0}; -static swig_lua_class _wrap_class_IAI = { "IAI", &SWIGTYPE_p_IAI,0, swig_delete_IAI, swig_IAI_methods, swig_IAI_attributes, swig_IAI_bases, swig_IAI_base_names }; +static swig_lua_class _wrap_class_IAI = { "IAI", &SWIGTYPE_p_IAI,0, swig_delete_IAI, swig_IAI_methods, swig_IAI_attributes, { "IAI", swig_IAI_cls_methods, swig_IAI_cls_attributes, swig_IAI_cls_constants }, swig_IAI_bases, swig_IAI_base_names }; static int _wrap_new_vectorUnitTypes__SWIG_0(lua_State* L) { int SWIG_arg = 0; @@ -6554,7 +7109,7 @@ } } - lua_pushstring(L,"Wrong arguments for overloaded function 'new_vectorUnitTypes'\n" + SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_vectorUnitTypes'\n" " Possible C/C++ prototypes are:\n" " std::vector< IUnitType * >::vector()\n" " std::vector< IUnitType * >::vector(unsigned int)\n" @@ -6854,9 +7409,18 @@ static swig_lua_attribute swig_std_vector_Sl_IUnitType_Sm__Sg__attributes[] = { {0,0,0} }; +static swig_lua_attribute swig_std_vector_Sl_IUnitType_Sm__Sg__cls_attributes[] = { + {0,0,0} +}; +static swig_lua_method swig_std_vector_Sl_IUnitType_Sm__Sg__cls_methods[] = { + {0,0} +}; +static swig_lua_const_info swig_std_vector_Sl_IUnitType_Sm__Sg__cls_constants[] = { + {0,0,0,0,0,0} +}; static swig_lua_class *swig_std_vector_Sl_IUnitType_Sm__Sg__bases[] = {0}; static const char *swig_std_vector_Sl_IUnitType_Sm__Sg__base_names[] = {0}; -static swig_lua_class _wrap_class_std_vector_Sl_IUnitType_Sm__Sg_ = { "vectorUnitTypes", &SWIGTYPE_p_std__vectorT_IUnitType_p_t,_wrap_new_vectorUnitTypes, swig_delete_vectorUnitTypes, swig_std_vector_Sl_IUnitType_Sm__Sg__methods, swig_std_vector_Sl_IUnitType_Sm__Sg__attributes, swig_std_vector_Sl_IUnitType_Sm__Sg__bases, swig_std_vector_Sl_IUnitType_Sm__Sg__base_names }; +static swig_lua_class _wrap_class_std_vector_Sl_IUnitType_Sm__Sg_ = { "vectorUnitTypes", &SWIGTYPE_p_std__vectorT_IUnitType_p_t,_wrap_new_vectorUnitTypes, swig_delete_vectorUnitTypes, swig_std_vector_Sl_IUnitType_Sm__Sg__methods, swig_std_vector_Sl_IUnitType_Sm__Sg__attributes, { "vectorUnitTypes", swig_std_vector_Sl_IUnitType_Sm__Sg__cls_methods, swig_std_vector_Sl_IUnitType_Sm__Sg__cls_attributes, swig_std_vector_Sl_IUnitType_Sm__Sg__cls_constants }, swig_std_vector_Sl_IUnitType_Sm__Sg__bases, swig_std_vector_Sl_IUnitType_Sm__Sg__base_names }; static int _wrap_new_vectorUnits__SWIG_0(lua_State* L) { int SWIG_arg = 0; @@ -7001,7 +7565,7 @@ } } - lua_pushstring(L,"Wrong arguments for overloaded function 'new_vectorUnits'\n" + SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_vectorUnits'\n" " Possible C/C++ prototypes are:\n" " std::vector< IUnit * >::vector()\n" " std::vector< IUnit * >::vector(unsigned int)\n" @@ -7301,9 +7865,18 @@ static swig_lua_attribute swig_std_vector_Sl_IUnit_Sm__Sg__attributes[] = { {0,0,0} }; +static swig_lua_attribute swig_std_vector_Sl_IUnit_Sm__Sg__cls_attributes[] = { + {0,0,0} +}; +static swig_lua_method swig_std_vector_Sl_IUnit_Sm__Sg__cls_methods[] = { + {0,0} +}; +static swig_lua_const_info swig_std_vector_Sl_IUnit_Sm__Sg__cls_constants[] = { + {0,0,0,0,0,0} +}; static swig_lua_class *swig_std_vector_Sl_IUnit_Sm__Sg__bases[] = {0}; static const char *swig_std_vector_Sl_IUnit_Sm__Sg__base_names[] = {0}; -static swig_lua_class _wrap_class_std_vector_Sl_IUnit_Sm__Sg_ = { "vectorUnits", &SWIGTYPE_p_std__vectorT_IUnit_p_t,_wrap_new_vectorUnits, swig_delete_vectorUnits, swig_std_vector_Sl_IUnit_Sm__Sg__methods, swig_std_vector_Sl_IUnit_Sm__Sg__attributes, swig_std_vector_Sl_IUnit_Sm__Sg__bases, swig_std_vector_Sl_IUnit_Sm__Sg__base_names }; +static swig_lua_class _wrap_class_std_vector_Sl_IUnit_Sm__Sg_ = { "vectorUnits", &SWIGTYPE_p_std__vectorT_IUnit_p_t,_wrap_new_vectorUnits, swig_delete_vectorUnits, swig_std_vector_Sl_IUnit_Sm__Sg__methods, swig_std_vector_Sl_IUnit_Sm__Sg__attributes, { "vectorUnits", swig_std_vector_Sl_IUnit_Sm__Sg__cls_methods, swig_std_vector_Sl_IUnit_Sm__Sg__cls_attributes, swig_std_vector_Sl_IUnit_Sm__Sg__cls_constants }, swig_std_vector_Sl_IUnit_Sm__Sg__bases, swig_std_vector_Sl_IUnit_Sm__Sg__base_names }; static int _wrap_new_vectorFloat__SWIG_0(lua_State* L) { int SWIG_arg = 0; @@ -7439,7 +8012,7 @@ } } - lua_pushstring(L,"Wrong arguments for overloaded function 'new_vectorFloat'\n" + SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_vectorFloat'\n" " Possible C/C++ prototypes are:\n" " std::vector< float >::vector()\n" " std::vector< float >::vector(unsigned int)\n" @@ -7731,9 +8304,18 @@ static swig_lua_attribute swig_std_vector_Sl_float_Sg__attributes[] = { {0,0,0} }; +static swig_lua_attribute swig_std_vector_Sl_float_Sg__cls_attributes[] = { + {0,0,0} +}; +static swig_lua_method swig_std_vector_Sl_float_Sg__cls_methods[] = { + {0,0} +}; +static swig_lua_const_info swig_std_vector_Sl_float_Sg__cls_constants[] = { + {0,0,0,0,0,0} +}; static swig_lua_class *swig_std_vector_Sl_float_Sg__bases[] = {0}; static const char *swig_std_vector_Sl_float_Sg__base_names[] = {0}; -static swig_lua_class _wrap_class_std_vector_Sl_float_Sg_ = { "vectorFloat", &SWIGTYPE_p_std__vectorT_float_t,_wrap_new_vectorFloat, swig_delete_vectorFloat, swig_std_vector_Sl_float_Sg__methods, swig_std_vector_Sl_float_Sg__attributes, swig_std_vector_Sl_float_Sg__bases, swig_std_vector_Sl_float_Sg__base_names }; +static swig_lua_class _wrap_class_std_vector_Sl_float_Sg_ = { "vectorFloat", &SWIGTYPE_p_std__vectorT_float_t,_wrap_new_vectorFloat, swig_delete_vectorFloat, swig_std_vector_Sl_float_Sg__methods, swig_std_vector_Sl_float_Sg__attributes, { "vectorFloat", swig_std_vector_Sl_float_Sg__cls_methods, swig_std_vector_Sl_float_Sg__cls_attributes, swig_std_vector_Sl_float_Sg__cls_constants }, swig_std_vector_Sl_float_Sg__bases, swig_std_vector_Sl_float_Sg__base_names }; static int _wrap_new_vectorInt__SWIG_0(lua_State* L) { int SWIG_arg = 0; @@ -7869,7 +8451,7 @@ } } - lua_pushstring(L,"Wrong arguments for overloaded function 'new_vectorInt'\n" + SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_vectorInt'\n" " Possible C/C++ prototypes are:\n" " std::vector< int >::vector()\n" " std::vector< int >::vector(unsigned int)\n" @@ -8161,9 +8743,18 @@ static swig_lua_attribute swig_std_vector_Sl_int_Sg__attributes[] = { {0,0,0} }; +static swig_lua_attribute swig_std_vector_Sl_int_Sg__cls_attributes[] = { + {0,0,0} +}; +static swig_lua_method swig_std_vector_Sl_int_Sg__cls_methods[] = { + {0,0} +}; +static swig_lua_const_info swig_std_vector_Sl_int_Sg__cls_constants[] = { + {0,0,0,0,0,0} +}; static swig_lua_class *swig_std_vector_Sl_int_Sg__bases[] = {0}; static const char *swig_std_vector_Sl_int_Sg__base_names[] = {0}; -static swig_lua_class _wrap_class_std_vector_Sl_int_Sg_ = { "vectorInt", &SWIGTYPE_p_std__vectorT_int_t,_wrap_new_vectorInt, swig_delete_vectorInt, swig_std_vector_Sl_int_Sg__methods, swig_std_vector_Sl_int_Sg__attributes, swig_std_vector_Sl_int_Sg__bases, swig_std_vector_Sl_int_Sg__base_names }; +static swig_lua_class _wrap_class_std_vector_Sl_int_Sg_ = { "vectorInt", &SWIGTYPE_p_std__vectorT_int_t,_wrap_new_vectorInt, swig_delete_vectorInt, swig_std_vector_Sl_int_Sg__methods, swig_std_vector_Sl_int_Sg__attributes, { "vectorInt", swig_std_vector_Sl_int_Sg__cls_methods, swig_std_vector_Sl_int_Sg__cls_attributes, swig_std_vector_Sl_int_Sg__cls_constants }, swig_std_vector_Sl_int_Sg__bases, swig_std_vector_Sl_int_Sg__base_names }; static int _wrap_new_vectorMapFeature__SWIG_0(lua_State* L) { int SWIG_arg = 0; @@ -8308,7 +8899,7 @@ } } - lua_pushstring(L,"Wrong arguments for overloaded function 'new_vectorMapFeature'\n" + SWIG_Lua_pusherrstring(L,"Wrong arguments for overloaded function 'new_vectorMapFeature'\n" " Possible C/C++ prototypes are:\n" " std::vector< IMapFeature * >::vector()\n" " std::vector< IMapFeature * >::vector(unsigned int)\n" @@ -8608,15 +9199,24 @@ static swig_lua_attribute swig_std_vector_Sl_IMapFeature_Sm__Sg__attributes[] = { {0,0,0} }; +static swig_lua_attribute swig_std_vector_Sl_IMapFeature_Sm__Sg__cls_attributes[] = { + {0,0,0} +}; +static swig_lua_method swig_std_vector_Sl_IMapFeature_Sm__Sg__cls_methods[] = { + {0,0} +}; +static swig_lua_const_info swig_std_vector_Sl_IMapFeature_Sm__Sg__cls_constants[] = { + {0,0,0,0,0,0} +}; static swig_lua_class *swig_std_vector_Sl_IMapFeature_Sm__Sg__bases[] = {0}; static const char *swig_std_vector_Sl_IMapFeature_Sm__Sg__base_names[] = {0}; -static swig_lua_class _wrap_class_std_vector_Sl_IMapFeature_Sm__Sg_ = { "vectorMapFeature", &SWIGTYPE_p_std__vectorT_IMapFeature_p_t,_wrap_new_vectorMapFeature, swig_delete_vectorMapFeature, swig_std_vector_Sl_IMapFeature_Sm__Sg__methods, swig_std_vector_Sl_IMapFeature_Sm__Sg__attributes, swig_std_vector_Sl_IMapFeature_Sm__Sg__bases, swig_std_vector_Sl_IMapFeature_Sm__Sg__base_names }; +static swig_lua_class _wrap_class_std_vector_Sl_IMapFeature_Sm__Sg_ = { "vectorMapFeature", &SWIGTYPE_p_std__vectorT_IMapFeature_p_t,_wrap_new_vectorMapFeature, swig_delete_vectorMapFeature, swig_std_vector_Sl_IMapFeature_Sm__Sg__methods, swig_std_vector_Sl_IMapFeature_Sm__Sg__attributes, { "vectorMapFeature", swig_std_vector_Sl_IMapFeature_Sm__Sg__cls_methods, swig_std_vector_Sl_IMapFeature_Sm__Sg__cls_attributes, swig_std_vector_Sl_IMapFeature_Sm__Sg__cls_constants }, swig_std_vector_Sl_IMapFeature_Sm__Sg__bases, swig_std_vector_Sl_IMapFeature_Sm__Sg__base_names }; #ifdef __cplusplus } #endif -static const struct luaL_reg swig_commands[] = { +static const struct luaL_Reg swig_commands[] = { {0,0} }; @@ -8707,18 +9307,18 @@ /* ----------------------------------------------------------------------------- * Type initialization: - * This problem is tough by the requirement that no dynamic - * memory is used. Also, since swig_type_info structures store pointers to + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to * swig_cast_info structures and swig_cast_info structures store pointers back - * to swig_type_info structures, we need some lookup code at initialization. - * The idea is that swig generates all the structures that are needed. - * The runtime then collects these partially filled structures. - * The SWIG_InitializeModule function takes these initial arrays out of + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of * swig_module, and does all the lookup, filling in the swig_module.types * array with the correct data and linking the correct swig_cast_info * structures together. * - * The generated swig_type_info structures are assigned staticly to an initial + * The generated swig_type_info structures are assigned staticly to an initial * array. We just loop through that array, and handle each type individually. * First we lookup if this type has been already loaded, and if so, use the * loaded structure instead of the generated one. Then we have to fill in the @@ -8728,17 +9328,17 @@ * a column is one of the swig_cast_info structures for that type. * The cast_initial array is actually an array of arrays, because each row has * a variable number of columns. So to actually build the cast linked list, - * we find the array of casts associated with the type, and loop through it + * we find the array of casts associated with the type, and loop through it * adding the casts to the list. The one last trick we need to do is making * sure the type pointer in the swig_cast_info struct is correct. * - * First off, we lookup the cast->type name to see if it is already loaded. + * First off, we lookup the cast->type name to see if it is already loaded. * There are three cases to handle: * 1) If the cast->type has already been loaded AND the type we are adding * casting info to has not been loaded (it is in this module), THEN we * replace the cast->type pointer with the type pointer that has already * been loaded. - * 2) If BOTH types (the one we are adding casting info to, and the + * 2) If BOTH types (the one we are adding casting info to, and the * cast->type) are loaded, THEN the cast info has already been loaded by * the previous module so we just ignore it. * 3) Finally, if cast->type has not already been loaded, then we add that @@ -8764,8 +9364,6 @@ swig_module_info *module_head, *iter; int found, init; - clientdata = clientdata; - /* check to see if the circular list has been setup, if not, set it up */ if (swig_module.next==0) { /* Initialize the swig_module */ @@ -8803,7 +9401,7 @@ module_head->next = &swig_module; } - /* When multiple interpeters are used, a module could have already been initialized in + /* When multiple interpreters are used, a module could have already been initialized in a different interpreter, but not yet have a pointer in this interpreter. In this case, we do not want to continue adding types... everything should be set up already */ @@ -8817,7 +9415,7 @@ swig_type_info *type = 0; swig_type_info *ret; swig_cast_info *cast; - + #ifdef SWIGRUNTIME_DEBUG printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); #endif @@ -8844,7 +9442,7 @@ /* Insert casting types */ cast = swig_module.cast_initial[i]; while (cast->type) { - + /* Don't need to add information already in the list */ ret = 0; #ifdef SWIGRUNTIME_DEBUG @@ -8952,16 +9550,24 @@ #endif /* this is the initialization function added at the very end of the code - the function is always called SWIG_init, but an eariler #define will rename it + the function is always called SWIG_init, but an earlier #define will rename it */ -SWIGEXPORT int SWIG_init(lua_State* L) +#if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC)) +LUALIB_API int SWIG_init(lua_State* L) +#else +SWIGEXPORT int SWIG_init(lua_State* L) /* default Lua action */ +#endif { +#if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) /* valid for both Lua and eLua */ int i; /* start with global table */ - lua_pushvalue(L,LUA_GLOBALSINDEX); + lua_pushglobaltable (L); /* SWIG's internal initalisation */ SWIG_InitializeModule((void*)L); SWIG_PropagateClientData(); +#endif + +#if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)) /* add a global fn */ SWIG_Lua_add_function(L,"swig_type",SWIG_Lua_type); SWIG_Lua_add_function(L,"swig_equals",SWIG_Lua_equal); @@ -8975,7 +9581,10 @@ for (i = 0; swig_variables[i].name; i++){ SWIG_Lua_module_add_variable(L,swig_variables[i].name,swig_variables[i].get,swig_variables[i].set); } - /* set up base class pointers (the hierachy) */ +#endif + +#if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) + /* set up base class pointers (the hierarchy) */ for (i = 0; swig_types[i]; i++){ if (swig_types[i]->clientdata){ SWIG_Lua_init_base_class(L,(swig_lua_class*)(swig_types[i]->clientdata)); @@ -8987,8 +9596,14 @@ SWIG_Lua_class_register(L,(swig_lua_class*)(swig_types[i]->clientdata)); } } +#endif + +#if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)) /* constants */ SWIG_Lua_InstallConstants(L,swig_constants); +#endif + +#if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) /* invoke user-specific initialization */ SWIG_init_user(L); /* end module */ @@ -8996,6 +9611,9 @@ point, we have the globals table and out module table on the stack. Returning one value makes the module table the result of the require command. */ return 1; +#else + return 0; +#endif } #ifdef __cplusplus diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/interfaces/IAI.h spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/interfaces/IAI.h --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/interfaces/IAI.h 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/interfaces/IAI.h 2014-10-07 20:10:05.000000000 +0000 @@ -6,6 +6,7 @@ virtual void Init()=0; virtual void Update()=0; virtual void GameEnd()=0; + virtual void GameMessage(const char* text)=0; virtual void UnitCreated(IUnit* unit)=0; virtual void UnitBuilt(IUnit* unit)=0; diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/interfaces/IGame.h spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/interfaces/IGame.h --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/interfaces/IGame.h 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/interfaces/IGame.h 2014-10-07 20:10:05.000000000 +0000 @@ -29,10 +29,8 @@ virtual std::vector GetEnemies()=0; virtual std::vector GetFriendlies()=0; virtual std::vector GetUnits()=0; - virtual std::string GameName()=0; - virtual bool FileExists(std::string filename)=0; @@ -45,6 +43,8 @@ virtual SResourceData GetResourceByName(std::string name)=0; virtual IAI* Me()=0; + + virtual IUnit* getUnitByID( int unit_id )=0; }; #endif diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/Makefile spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/Makefile --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/Makefile 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/Makefile 2014-10-07 20:10:05.000000000 +0000 @@ -1,2 +1,9 @@ +.PHONY: api_wrap.cpp swig.h + +all: api_wrap.cpp swig.h + api_wrap.cpp: swig -c++ -lua -o api_wrap.cpp api.i + +swig.h: + swig -lua -external-runtime swig.h diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/spring/SpringGame.cpp spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/spring/SpringGame.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/spring/SpringGame.cpp 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/spring/SpringGame.cpp 2014-10-07 20:10:05.000000000 +0000 @@ -5,11 +5,16 @@ #include "spring_api.h" #include "AI/Wrappers/Cpp/src-generated/SkirmishAI.h" +#include "AI/Wrappers/Cpp/src-generated/WrappUnit.h" CSpringGame::CSpringGame(springai::OOAICallback* callback) -: callback(callback){ +: callback(callback), datadirs(callback->GetDataDirs()), + economy(callback->GetEconomy()), resources(callback->GetResources()), + game(callback->GetGame()), lastUnitUpdate(-1) { ai = new CTestAI(this); - callback->GetCheats()->SetEnabled(true); + springai::Cheats* cheat = callback->GetCheats(); + cheat->SetEnabled(true); + delete cheat; std::vector defs = callback->GetUnitDefs(); if(!defs.empty()){ @@ -28,6 +33,20 @@ CSpringGame::~CSpringGame(){ delete ai; delete map; + std::map::iterator iter = definitions.begin(); + while(iter != definitions.end()) { + delete iter->second; + ++iter; + } + for (int i = 0; i < resources.size(); i += 1) { + delete resources[i]; + } + delete datadirs; + delete economy; + delete game; + for (std::map::iterator i = aliveUnits.begin(); i != aliveUnits.end(); ++i) { + delete i->second; + } } IMap* CSpringGame::Map(){ @@ -40,15 +59,15 @@ } void CSpringGame::SendToConsole(std::string message){ - callback->GetGame()->SendTextMessage(message.c_str(), 0); + game->SendTextMessage(message.c_str(), 0); } int CSpringGame::Frame(){ - return callback->GetGame()->GetCurrentFrame(); + return game->GetCurrentFrame(); } bool CSpringGame::IsPaused(){ - return callback->GetGame()->IsPaused(); + return game->IsPaused(); } @@ -63,7 +82,7 @@ } const char* CSpringGame::ConfigFolderPath(){ - return callback->GetDataDirs()->GetConfigDir(); + return datadirs->GetConfigDir(); } std::string CSpringGame::ReadFile(std::string filename){ @@ -73,7 +92,7 @@ //cerr << "Couldn't open input file" << endl; return ""; } - + std::string s =""; // create reader objects @@ -92,7 +111,10 @@ } std::string CSpringGame::GameName(){ - return callback->GetMod()->GetShortName(); + springai::Mod* mod = callback->GetMod(); + std::string name = mod->GetShortName(); + delete mod; + return name; } @@ -111,7 +133,7 @@ static const size_t absPath_sizeMax = 2048; char absPath[absPath_sizeMax]; const bool dir = !filename.empty() && (*filename.rbegin() == '/' || *filename.rbegin() == '\\'); - const bool located = callback->GetDataDirs()->LocatePath(absPath, absPath_sizeMax, filename.c_str(), false /*writable*/, false /*create*/, dir, false /*common*/); + const bool located = datadirs->LocatePath(absPath, absPath_sizeMax, filename.c_str(), false /*writable*/, false /*create*/, dir, false /*common*/); if (located){ filename=absPath; } @@ -120,11 +142,18 @@ void CSpringGame::AddMarker(Position p,std::string label){ const springai::AIFloat3 pos(p.x, p.y, p.z); - callback->GetMap()->GetDrawer()->AddPoint(pos, label.c_str()); + springai::Map* map = callback->GetMap(); + springai::Drawer* drawer = map->GetDrawer(); + drawer->AddPoint(pos, label.c_str()); + delete drawer; + delete map; } std::string CSpringGame::SendToContent(std::string data){ - return callback->GetLua()->CallRules(data.c_str(), -1); + springai::Lua* lua = callback->GetLua(); + std::string res = lua->CallRules(data.c_str(), -1); + delete lua; + return res; } @@ -138,60 +167,153 @@ } } +CSpringUnit* CSpringGame::CreateUnit(int id) { + if (id < 0) { + SendToConsole("shard-runtime warning: tried to create unit with id < 0"); + return NULL; + } + springai::Unit* unit = springai::WrappUnit::GetInstance(callback->GetSkirmishAIId(), id); + if (unit) { + return CreateUnit(unit); + } else { + SendToConsole("shard-runtime warning: Could not create unit, WrappUnit returned NULL."); + return NULL; + } +} + + +CSpringUnit* CSpringGame::CreateUnit(springai::Unit* unit, bool addToVectors) { + std::map::iterator i = aliveUnits.find(unit->GetUnitId()); + if (i == aliveUnits.end()) { + CSpringUnit* u = new CSpringUnit(callback, unit, this); + aliveUnits[unit->GetUnitId()] = u; + + if (addToVectors) { + if (u->Team() == GetTeamID()) { + teamUnits.push_back(u); + friendlyUnits.push_back(u); + } else if (u->IsAlly(game->GetMyAllyTeam())) { + friendlyUnits.push_back(u); + } else { + enemyUnits.push_back(u); + } + } + + return u; + } else { + delete unit; + return i->second; + } +} + +void CSpringGame::DestroyUnit(int id) { + CSpringUnit* u = GetUnitById(id); + if (u) { + u->SetDead(true); + } +} + +CSpringUnit* CSpringGame::GetUnitById(int id) { + if (id < 0) { + return NULL; + } + + std::map::iterator i = aliveUnits.find(id); + if (i == aliveUnits.end()) { + return NULL; + } else { + return i->second; + } +} + +void CSpringGame::FillUnitVector(std::vector& target, std::vector source) +{ + target.clear(); + + std::vector::iterator i = source.begin(); + for(;i != source.end(); ++i){ + if (!(*i)) { + continue; + } + + CSpringUnit* unit = GetUnitById((*i)->GetUnitId()); + if (!unit) { + unit = CreateUnit(*i, false); + } else { + delete (*i); + } + + if (unit) { + target.push_back(unit); + } + } +} + +void CSpringGame::UpdateUnits() +{ + if (lastUnitUpdate < Frame()) + { + /* deleting dead units seems not really necessary. + Also the fillunitvector methods below will add them back again, anyways. + std::map::iterator i = aliveUnits.begin(); + while(i != aliveUnits.end()) { + if (!i->second->IsAlive() && i->second->Died() < Frame() - 100) { //delete dead units after 100 frames. + i = aliveUnits.erase(i); + } else { + ++i; + } + }*/ + + FillUnitVector(enemyUnits, callback->GetEnemyUnits()); //events about enemy unit seem to not reach us. + FillUnitVector(friendlyUnits, callback->GetFriendlyUnits()); + FillUnitVector(teamUnits, callback->GetTeamUnits()); + + /*if (lastUnitUpdate % 500 == 0) { + std::stringstream msg; + msg << "Friendlies: " << friendlyUnits.size() << " Team: " << teamUnits.size() << " Enemies: " << enemyUnits.size(); + SendToConsole(msg.str()); + }*/ + + lastUnitUpdate = Frame(); + } +} + bool CSpringGame::HasEnemies(){ - std::vector enemies = callback->GetEnemyUnits(); - return !enemies.empty(); + UpdateUnits(); + return !enemyUnits.empty(); } std::vector CSpringGame::GetEnemies(){ - std::vector enemiesv; - - std::vector enemies = callback->GetEnemyUnits(); - std::vector::iterator i = enemies.begin(); - for(;i != enemies.end(); ++i){ - CSpringUnit* unit = new CSpringUnit(callback,*i,this); - enemiesv.push_back(unit); - } - return enemiesv; + UpdateUnits(); + return enemyUnits; } + bool CSpringGame::HasFriendlies(){ - std::vector friendlies = callback->GetFriendlyUnits(); - return !friendlies.empty(); + UpdateUnits(); + return !friendlyUnits.empty(); } + std::vector CSpringGame::GetFriendlies(){ - std::vector friendliesv; - - std::vector friendlies = callback->GetFriendlyUnits(); - std::vector::iterator i = friendlies.begin(); - for(;i != friendlies.end(); ++i){ - CSpringUnit* unit = new CSpringUnit(callback,*i,this); - friendliesv.push_back(unit); - } - return friendliesv; + UpdateUnits(); + return friendlyUnits; } int CSpringGame::GetTeamID(){ - return callback->GetSkirmishAI()->GetTeamId(); + springai::SkirmishAI* ai = callback->GetSkirmishAI(); + int id = ai->GetTeamId(); + delete ai; + return id; } std::vector CSpringGame::GetUnits(){ - std::vector friendliesv; - - std::vector friendlies = callback->GetTeamUnits(); - std::vector::iterator i = friendlies.begin(); - for(;i != friendlies.end(); ++i){ - CSpringUnit* unit = new CSpringUnit(callback,*i,this); - friendliesv.push_back(unit); - } - return friendliesv; + UpdateUnits(); + return teamUnits; } SResourceData CSpringGame::GetResource(int idx){ SResourceData res; - std::vector resources = callback->GetResources(); if(!resources.empty()){ - std::vector::iterator i = resources.begin(); for(;i != resources.end();++i){ springai::Resource* r = *i; @@ -199,10 +321,10 @@ res.id = r->GetResourceId(); res.name = r->GetName(); res.gameframe = this->Frame(); - res.income = callback->GetEconomy()->GetIncome(r); - res.usage = callback->GetEconomy()->GetUsage(r); - res.capacity = callback->GetEconomy()->GetStorage(r); - res.reserves = callback->GetEconomy()->GetCurrent(r); + res.income = economy->GetIncome(r); + res.usage = economy->GetUsage(r); + res.capacity = economy->GetStorage(r); + res.reserves = economy->GetCurrent(r); return res; } } @@ -211,7 +333,6 @@ } int CSpringGame::GetResourceCount(){ - std::vector resources = callback->GetResources(); if(resources.empty()){ return 0; }else{ @@ -222,9 +343,7 @@ SResourceData CSpringGame::GetResourceByName(std::string name){ SResourceData res; - std::vector resources = callback->GetResources(); if(!resources.empty()){ - std::vector::iterator i = resources.begin(); for(;i != resources.end();++i){ springai::Resource* r = *i; @@ -233,13 +352,27 @@ res.name = rname; res.id = r->GetResourceId(); res.gameframe = this->Frame(); - res.income = callback->GetEconomy()->GetIncome(r); - res.usage = callback->GetEconomy()->GetUsage(r); - res.capacity = callback->GetEconomy()->GetStorage(r); - res.reserves = callback->GetEconomy()->GetCurrent(r); + res.income = economy->GetIncome(r); + res.usage = economy->GetUsage(r); + res.capacity = economy->GetStorage(r); + res.reserves = economy->GetCurrent(r); return res; } } } return res; } + +IUnit* CSpringGame::getUnitByID( int unit_id ) { + return ai->GetGame()->getUnitByID( unit_id ); +} + +/*void CSpringGame::removeUnit( IUnit* dead_unit ) { + std::map::iterator i = aliveUnits.find(evt->unit); + if(i != aliveUnits.end()){ + CSpringUnit* u = i->second; + game->Me()->UnitDead(u); + aliveUnits.erase(i); + delete u; + } +}*/ diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/spring/SpringGame.h spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/spring/SpringGame.h --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/spring/SpringGame.h 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/spring/SpringGame.h 2014-10-07 20:10:05.000000000 +0000 @@ -4,6 +4,7 @@ #include "../../TestAI.h" #include "SpringMap.h" +#include "SpringUnit.h" #include "SpringUnitType.h" #include "SpringMapFeature.h" @@ -11,7 +12,7 @@ public: CSpringGame(springai::OOAICallback* callback); virtual ~CSpringGame(); - + virtual IMap* Map(); virtual std::string GameID(); @@ -20,27 +21,30 @@ virtual bool IsPaused(); virtual IUnitType* GetTypeByName(std::string typeName); - + virtual const char* ConfigFolderPath(); virtual std::string ReadFile(std::string filename); virtual bool LocatePath(std::string& filename); virtual int GetTeamID(); - + virtual bool HasEnemies(); virtual bool HasFriendlies(); virtual std::vector GetEnemies(); virtual std::vector GetFriendlies(); virtual std::vector GetUnits(); - + virtual CSpringUnit* CreateUnit(int id); + virtual CSpringUnit* CreateUnit(springai::Unit* unit, bool addToVectors = true); + virtual void DestroyUnit(int id); + virtual CSpringUnit* GetUnitById(int id); virtual IAI* Me(); virtual std::string GameName(); virtual bool FileExists(std::string filename); - + virtual void AddMarker(Position p,std::string label); virtual std::string SendToContent(std::string data); @@ -49,12 +53,30 @@ virtual SResourceData GetResource(int idx); virtual int GetResourceCount(); virtual SResourceData GetResourceByName(std::string name); - + IUnitType* ToIUnitType(springai::UnitDef* def); + + virtual void UpdateUnits(); + + virtual IUnit* getUnitByID( int unit_id ); + /*virtual void removeUnit( IUnit* dead_unit );*/ protected: + //helper functions to managing unit vectors. + //vectors are updated at maximum once per frame. + //if unit vectors are required, best call "UpdateUnits" before. + virtual void FillUnitVector(std::vector& target, std::vector source); CSpringMap* map; springai::OOAICallback* callback; CTestAI* ai; std::map definitions; + springai::DataDirs* datadirs; + springai::Economy* economy; + std::vector resources; + springai::Game* game; + std::map aliveUnits; + std::vector friendlyUnits; + std::vector teamUnits; + std::vector enemyUnits; + int lastUnitUpdate; }; diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/spring/SpringMap.cpp spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/spring/SpringMap.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/spring/SpringMap.cpp 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/spring/SpringMap.cpp 2014-10-07 20:10:05.000000000 +0000 @@ -1,3 +1,4 @@ + #include "spring_api.h" #include @@ -11,7 +12,7 @@ CSpringMap::CSpringMap(springai::OOAICallback* callback, CSpringGame* game) : callback(callback), game(game), - metal(NULL) { + metal(NULL), map(callback->GetMap()), lastMapFeaturesUpdate(-1) { std::vector resources = callback->GetResources(); if ( !resources.empty() ) { @@ -23,11 +24,12 @@ if(name == "Metal"){ this->metal = r; break; + } else { + delete r; } } } - if(metal){ this->GetMetalSpots(); } @@ -37,6 +39,13 @@ this->metalspots.clear(); game = NULL; callback = NULL; + delete map; + map = NULL; + delete metal; + for (std::vector::iterator i = mapFeatures.begin(); i != mapFeatures.end(); ++i) { + delete (*i); + } + mapFeatures.clear(); } Position CSpringMap::FindClosestBuildSite(IUnitType* t, Position builderPos, double searchRadius, double minimumDistance){ @@ -49,7 +58,7 @@ } CSpringUnitType* ut = static_cast(t); const springai::AIFloat3 bPos(builderPos.x, builderPos.y, builderPos.z); - const springai::AIFloat3 pos = callback->GetMap()->FindClosestBuildSite(ut->GetUnitDef(), bPos, searchRadius, minimumDistance, facing); + const springai::AIFloat3 pos = map->FindClosestBuildSite(ut->GetUnitDef(), bPos, searchRadius, minimumDistance, facing); Position p; p.x = pos.x; p.y = pos.y; @@ -64,7 +73,7 @@ bool CSpringMap::CanBuildHereFacing(IUnitType* t, Position p, int facing){ CSpringUnitType* ut = static_cast(t); const springai::AIFloat3 pos(p.x, p.y, p.z); - return callback->GetMap()->IsPossibleToBuildAt( ut->GetUnitDef(), pos, facing ); + return map->IsPossibleToBuildAt( ut->GetUnitDef(), pos, facing ); } int CSpringMap::SpotCount(){ @@ -78,7 +87,7 @@ std::vector& CSpringMap::GetMetalSpots(){ metal = this->GetMetalResource(); metalspots.clear(); - std::vector positions = callback->GetMap()->GetResourceMapSpotsPositions( metal ); + std::vector positions = map->GetResourceMapSpotsPositions( metal ); if ( !positions.empty() ) { std::vector::iterator j = positions.begin(); for(;j != positions.end();++j){ @@ -93,68 +102,102 @@ } Position CSpringMap::MapDimensions(){ - Position p; - p.x = callback->GetMap()->GetWidth(); - p.z = callback->GetMap()->GetHeight(); - + p.x = map->GetWidth(); + p.z = map->GetHeight(); + return p; } std::string CSpringMap::MapName(){ - return callback->GetMap()->GetName(); + return map->GetName(); } float CSpringMap::MaximumHeight(){ - return callback->GetMap()->GetMaxHeight(); + return map->GetMaxHeight(); } float CSpringMap::MinimumHeight(){ - return callback->GetMap()->GetMinHeight(); + return map->GetMinHeight(); } double CSpringMap::AverageWind(){ - float minwind = callback->GetMap()->GetMinWind(); - float maxwind = callback->GetMap()->GetMaxWind(); + float minwind = map->GetMinWind(); + float maxwind = map->GetMaxWind(); return (minwind+maxwind)/2; } double CSpringMap::MinimumWindSpeed(){ - return callback->GetMap()->GetMinWind(); + return map->GetMinWind(); } double CSpringMap::MaximumWindSpeed(){ - return callback->GetMap()->GetMaxWind(); + return map->GetMaxWind(); } double CSpringMap::TidalStrength(){ - return callback->GetMap()->GetTidalStrength(); + return map->GetTidalStrength(); } +std::vector::iterator CSpringMap::GetMapFeatureIteratorById(int id) { + for (std::vector::iterator i = mapFeatures.begin(); i != mapFeatures.end(); ++i) { + if ((*i)->ID() == id) { + return i; + } + } + return mapFeatures.end(); +} -std::vector CSpringMap::GetMapFeatures(){ - std::vector< IMapFeature*> mapFeatures; - - std::vector features = callback->GetFeatures(); - std::vector::iterator i = features.begin(); - for(;i != features.end(); ++i){ - CSpringMapFeature* f = new CSpringMapFeature(callback,*i,game); - mapFeatures.push_back(f); +void CSpringMap::UpdateMapFeatures() { + std::vector newMapFeatures; + if(lastMapFeaturesUpdate != game->Frame()) { + std::vector features = callback->GetFeatures(); + std::vector::iterator i = features.begin(); + + for(;i != features.end(); ++i){ + std::vector::iterator obj = GetMapFeatureIteratorById((*i)->GetFeatureId()); + if(obj != mapFeatures.end()) { //feature was already present, keep old object. + newMapFeatures.push_back(*obj); + mapFeatures.erase(obj); //remove from old map. + } else { //feature was not yet presend, add new one. + CSpringMapFeature* f = new CSpringMapFeature(callback,*i,game); + newMapFeatures.push_back(f); + } + } + + //clear up old features that spring api did not deliver => they got deleted. + for(std::vector::iterator i = mapFeatures.begin(); i != mapFeatures.end(); ++i) { + delete (*i); + } + + mapFeatures = newMapFeatures; + lastMapFeaturesUpdate = game->Frame(); } +} + +std::vector CSpringMap::GetMapFeatures(){ + UpdateMapFeatures(); return mapFeatures; } std::vector CSpringMap::GetMapFeaturesAt(Position p, double radius){ const springai::AIFloat3 pos(p.x, p.y, p.z); - std::vector< IMapFeature*> mapFeatures; - + UpdateMapFeatures(); + std::vector results; + std::vector features = callback->GetFeaturesIn(pos,radius); std::vector::iterator i = features.begin(); for(;i != features.end(); ++i){ - CSpringMapFeature* f = new CSpringMapFeature(callback,*i,game); - mapFeatures.push_back(f); + std::vector::iterator obj = GetMapFeatureIteratorById((*i)->GetFeatureId()); + if(obj != mapFeatures.end()) { + results.push_back(*obj); + } else { //can this ever happen? + CSpringMapFeature* f = new CSpringMapFeature(callback,*i,game); + mapFeatures.push_back(f); + results.push_back(f); + } } - return mapFeatures; + return results; } springai::Resource* CSpringMap::GetMetalResource(){ diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/spring/SpringMapFeature.cpp spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/spring/SpringMapFeature.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/spring/SpringMapFeature.cpp 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/spring/SpringMapFeature.cpp 2014-10-07 20:10:05.000000000 +0000 @@ -1,14 +1,16 @@ #include "spring_api.h" CSpringMapFeature::CSpringMapFeature(springai::OOAICallback* callback, springai::Feature* f, IGame* game) -:feature(f),callback(callback),game(game){ +:feature(f),callback(callback),game(game), def(f->GetDef()) { // } CSpringMapFeature::~CSpringMapFeature(){ + delete feature; feature = NULL; callback = NULL; game = NULL; + delete def; } int CSpringMapFeature::ID(){ @@ -19,10 +21,10 @@ } std::string CSpringMapFeature::Name(){ - if ((feature == NULL) || (feature->GetDef()==NULL)) { + if ((feature == NULL) || (def==NULL)) { return ""; } - return feature->GetDef()->GetName(); + return def->GetName(); } Position CSpringMapFeature::GetPosition(){ @@ -38,20 +40,22 @@ float CSpringMapFeature::ResourceValue(int idx){ std::vector resources = callback->GetResources(); + float res = -1; if(!resources.empty()){ std::vector::iterator i = resources.begin(); for(;i != resources.end();++i){ springai::Resource* r = *i; if(r->GetResourceId() == idx){ - return feature->GetDef()->GetContainedResource(r); + res = def->GetContainedResource(r); } + delete r; } } - return -1; + return res; } bool CSpringMapFeature::Reclaimable(){ - if (feature==NULL) + if (feature==NULL || def == NULL) return false; - return feature->GetDef()->IsReclaimable(); + return def->IsReclaimable(); } diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/spring/SpringMapFeature.h spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/spring/SpringMapFeature.h --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/spring/SpringMapFeature.h 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/spring/SpringMapFeature.h 2014-10-07 20:10:05.000000000 +0000 @@ -24,6 +24,7 @@ protected: springai::OOAICallback* callback; IGame* game; + springai::FeatureDef* def; }; diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/spring/SpringMap.h spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/spring/SpringMap.h --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/spring/SpringMap.h 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/spring/SpringMap.h 2014-10-07 20:10:05.000000000 +0000 @@ -33,15 +33,23 @@ virtual bool CanBuildHere(IUnitType* t, Position pos); virtual bool CanBuildHereFacing(IUnitType* t, Position pos,int facing); - + springai::Resource* GetMetalResource(); protected: + std::vector::iterator GetMapFeatureIteratorById(int id); + void UpdateMapFeatures(); + springai::OOAICallback* callback; CSpringGame* game; - + std::vector metalspots; springai::Resource* metal; + springai::Map* map; + std::vector< IMapFeature*> mapFeatures; + int lastMapFeaturesUpdate; }; #endif + + diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/spring/SpringUnit.cpp spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/spring/SpringUnit.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/spring/SpringUnit.cpp 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/spring/SpringUnit.cpp 2014-10-07 20:10:05.000000000 +0000 @@ -1,20 +1,32 @@ #include "spring_api.h" #include "AI/Wrappers/Cpp/src-generated/WrappResource.h" +#include "AI/Wrappers/Cpp/src-generated/WrappWeaponMount.h" #include "ExternalAI/Interface/AISCommands.h" // for UNIT_COMMAND_BUILD_NO_FACING #include CSpringUnit::CSpringUnit(springai::OOAICallback* callback, springai::Unit* u, IGame* game) -: callback(callback), unit(u), dead(false), game(game){ +: callback(callback), unit(u), dead(false), game(game) { if(u == 0){ throw std::runtime_error("springai::unit must never be null when passed into the constructor of a CSpringUnit object! Bad bad coder"); } - + def = u->GetDef(); + if(def) { + buildoptions = def->GetBuildOptions(); + } else { + game->SendToConsole("shard-runtime warning: UnitDef was NULL in CSpringUnit."); + } } CSpringUnit::~CSpringUnit(){ + delete unit; unit = NULL; callback = NULL; // + delete def; + def = NULL; + for (int i = 0; i < buildoptions.size(); i += 1) { + delete buildoptions[i]; + } } int CSpringUnit::ID(){ @@ -32,7 +44,7 @@ if (unit == NULL) { return ""; } - springai::UnitDef* u = unit->GetDef(); + springai::UnitDef* u = def; if(u == NULL){ return ""; } @@ -47,7 +59,19 @@ return dead; } +bool CSpringUnit::IsAlly(int allyTeamId) { + if (!unit) { + game->SendToConsole("shard-runtime warning: Unit was NULL in IsAlly"); + return false; + } + return allyTeamId == unit->GetAllyTeam(); +} + bool CSpringUnit::IsCloaked(){ + if (!unit) { + game->SendToConsole("shard-runtime warning: Unit was NULL in IsCloaked"); + return false; + } return this->unit->IsCloaked(); } @@ -59,14 +83,16 @@ return false; } - IUnitType* CSpringUnit::Type(){ return 0; } bool CSpringUnit::CanMove(){ - return unit->GetDef()->IsAbleToMove(); + if (def != NULL) + return def->IsAbleToMove(); + game->SendToConsole("shard-runtime warning: UnitDef was NULL in CanMove"); + return false; } bool CSpringUnit::CanDeploy(){ @@ -74,12 +100,19 @@ } bool CSpringUnit::CanBuild(){ - return (unit->GetDef()->GetBuildOptions().size() > 0); + if (def != NULL) { + return (buildoptions.size() > 0); + } + game->SendToConsole("shard-runtime warning: UnitDef was NULL in CanBuild"); + return false; } bool CSpringUnit::CanAssistBuilding(IUnit* unit){ - return this->unit->GetDef()->IsAbleToAssist(); + if (def != NULL) + return def->IsAbleToAssist(); + game->SendToConsole("shard-runtime warning: UnitDef was NULL in CanAssistBuilding"); + return false; } @@ -102,24 +135,53 @@ void CSpringUnit::Wait(int timeout){ + if (!unit) { + game->SendToConsole("shard-runtime warning: Unit was NULL in Wait"); + return; + } + this->unit->Wait(timeout); } void CSpringUnit::Stop(){ + if (!unit) { + game->SendToConsole("shard-runtime warning: Unit was NULL in Stop"); + return; + } + this->unit->Stop(); } void CSpringUnit::Move(Position p){ + if (!unit) { + game->SendToConsole("shard-runtime warning: Unit was NULL in Move"); + return; + } + const springai::AIFloat3 pos(p.x, p.y, p.z); - this->unit->MoveTo(pos); + try { + this->unit->MoveTo(pos); + } catch (springai::CallbackAIException& e) { + game->SendToConsole(std::string("shard-runtime warning: Failed in MoveTo. Reason: ") + std::string(e.what())); + } } void CSpringUnit::MoveAndFire(Position p){ + if (!unit) { + game->SendToConsole("shard-runtime warning: Unit was NULL in MoveAndFire"); + return; + } + const springai::AIFloat3 pos(p.x, p.y, p.z); this->unit->Fight(pos); } bool CSpringUnit::Build(IUnitType* t){ + if(!unit) { + game->SendToConsole("shard-runtime warning: Unit was NULL in Build(IUnitType)"); + return false; + } + Position p = this->GetPosition(); CSpringUnitType* type = static_cast(t); springai::UnitDef* ud = type->GetUnitDef(); @@ -174,6 +236,10 @@ } bool CSpringUnit::Build(IUnitType* t, Position p, int facing){ + if(!unit) { + game->SendToConsole("shard-runtime warning: Unit was NULL in Build(IUnitType, Position, int)"); + return false; + } if(t){ CSpringUnitType* st = static_cast(t); springai::UnitDef* ud = st->GetUnitDef(); @@ -195,30 +261,50 @@ } bool CSpringUnit::Reclaim(IMapFeature* mapFeature){ + if(!unit) { + game->SendToConsole("shard-runtime warning: Unit was NULL in Reclaim(IMapFeature)"); + return false; + } springai::Feature* f = static_cast(mapFeature)->feature; this->unit->ReclaimFeature(f); return true; } bool CSpringUnit::AreaReclaim(Position p, double radius){ + if(!unit) { + game->SendToConsole("shard-runtime warning: Unit was NULL in AreaReclaim"); + return false; + } const springai::AIFloat3 pos(p.x, p.y, p.z); this->unit->ReclaimInArea(pos, radius); return true; } bool CSpringUnit::Reclaim(IUnit* unit){ + if(!unit) { + game->SendToConsole("shard-runtime warning: Unit was NULL in Reclaim"); + return false; + } springai::Unit* u = static_cast(unit)->unit; this->unit->ReclaimUnit(u); return true; } bool CSpringUnit::Attack(IUnit* unit){ + if(!unit) { + game->SendToConsole("shard-runtime warning: Unit was NULL in Attack"); + return false; + } springai::Unit* u = static_cast(unit)->unit; this->unit->Attack(u); return true; } bool CSpringUnit::Repair(IUnit* unit){ + if(!unit) { + game->SendToConsole("shard-runtime warning: Unit was NULL in Repair"); + return false; + } springai::Unit* u = static_cast(unit)->unit; this->unit->Repair(u); return true; @@ -232,6 +318,10 @@ [23:20:55] <[RoX]knorke> local CMD_JUMP = 38521 */ bool CSpringUnit::MorphInto(IUnitType* t){ + if(!unit) { + game->SendToConsole("shard-runtime warning: Unit was NULL in MorphInto"); + return false; + } std::vector params_list; unit->ExecuteCustomCommand(31210, params_list); return true; @@ -239,6 +329,10 @@ Position CSpringUnit::GetPosition(){ Position p; + if(!unit) { + game->SendToConsole("shard-runtime warning: Unit was NULL in GetPosition"); + return p; + } const springai::AIFloat3 pos = unit->GetPos(); p.x = pos.x; p.y = pos.y; @@ -248,22 +342,46 @@ bool CSpringUnit::IsBeingBuilt(){ + if(!unit) { + game->SendToConsole("shard-runtime warning: Unit was NULL in IsBeingBuilt"); + return false; + } return unit->IsBeingBuilt(); } float CSpringUnit::GetHealth(){ + if(!unit) { + game->SendToConsole("shard-runtime warning: Unit was NULL in GetHealth"); + return 0.0f; + } return unit->GetHealth(); } float CSpringUnit::GetMaxHealth(){ + if(!unit) { + game->SendToConsole("shard-runtime warning: Unit was NULL in GetMaxHealth"); + return 0.0f; + } return unit->GetMaxHealth(); } int CSpringUnit::WeaponCount(){ - return unit->GetDef()->GetWeaponMounts().size(); + if (def != NULL) { + std::vector wm = def->GetWeaponMounts(); + int n = wm.size(); + for (int i = 0; i < wm.size(); i += 1) { + delete wm[i]; + } + return n; + } + return 0; } float CSpringUnit::MaxWeaponsRange(){ + if(!unit) { + game->SendToConsole("shard-runtime warning: Unit was NULL in MaxWeaponsRange"); + return 0.0f; + } return unit->GetMaxRange(); } @@ -272,12 +390,13 @@ return false; } if(unit == 0){ + game->SendToConsole("shard-runtime warning: Unit was NULL in CanBuild"); return false; } - if(unit->GetDef() == 0){ + if(def == 0){ return false; } - std::vector options = unit->GetDef()->GetBuildOptions(); + std::vector options = buildoptions; if(!options.empty()){ // std::vector::iterator i = options.begin(); @@ -305,5 +424,13 @@ void CSpringUnit::ExecuteCustomCommand(int cmdId, std::vector params_list, short options = 0, int timeOut = INT_MAX){ - this->unit->ExecuteCustomCommand(cmdId,params_list,options,timeOut); + if (!unit) { + game->SendToConsole("shard-runtime warning: Unit was NULL in ExecuteCustomCommand"); + return; + } + try { + this->unit->ExecuteCustomCommand(cmdId,params_list,options,timeOut); + } catch (springai::CallbackAIException& e) { + game->SendToConsole(std::string("shard-runtime warning: Failed to executeCustomCommand. Reason: ") + std::string(e.what())); + } } diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/spring/SpringUnit.h spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/spring/SpringUnit.h --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/spring/SpringUnit.h 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/spring/SpringUnit.h 2014-10-07 20:10:05.000000000 +0000 @@ -15,6 +15,7 @@ virtual void SetDead(bool dead=true); virtual bool IsAlive(); + virtual bool IsAlly(int allyTeamId); virtual bool IsCloaked(); @@ -80,4 +81,6 @@ springai::Unit* unit; bool dead; IGame* game; + springai::UnitDef* def; + std::vector buildoptions; }; diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/spring/SpringUnitType.cpp spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/spring/SpringUnitType.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/spring/SpringUnitType.cpp 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/spring/SpringUnitType.cpp 2014-10-07 20:10:05.000000000 +0000 @@ -11,15 +11,30 @@ #include "SpringGame.h" #include "SpringUnitType.h" -CSpringUnitType::CSpringUnitType(CSpringGame* game, springai::OOAICallback* callback, springai::UnitDef* unitDef) -: game(game), callback(callback), unitDef(unitDef){ - boptions = unitDef->GetBuildOptions(); +CSpringUnitType::CSpringUnitType(CSpringGame* game, springai::OOAICallback* callback, springai::UnitDef* unitDef): + boptions(unitDef->GetBuildOptions()), + game(game), + callback(callback), + unitDef(unitDef), + resources(callback->GetResources()), + weaponMounts(unitDef->GetWeaponMounts()) +{ } CSpringUnitType::~CSpringUnitType(){ game = NULL; callback = NULL; + delete unitDef; //same as in SpringUnit.cpp unitDef = NULL; + for (int i = 0; i < resources.size(); i += 1) { + delete resources[i]; + } + for (int i = 0; i < weaponMounts.size(); i += 1) { + delete weaponMounts[i]; + } + for (int i = 0; i < boptions.size(); i += 1) { + delete boptions[i]; + } } std::string CSpringUnitType::Name(){ @@ -31,7 +46,6 @@ } float CSpringUnitType::ResourceCost(int idx){ - std::vector resources = callback->GetResources(); if(!resources.empty()){ std::vector::iterator i = resources.begin(); for(;i != resources.end();++i){ @@ -54,18 +68,21 @@ } int CSpringUnitType::WeaponCount(){ - return unitDef->GetWeaponMounts().size(); + return weaponMounts.size(); } float CSpringUnitType::MaxWeaponDamage(){ - std::vector weaponMounts = unitDef->GetWeaponMounts(); if(!weaponMounts.empty()){ float output = 0; std::vector::iterator i = weaponMounts.begin(); for(; i != weaponMounts.begin();++i){ springai::WeaponMount* m = *i; - float damage = *(m->GetWeaponDef()->GetDamage()->GetTypes().begin()); + springai::WeaponDef* def = m->GetWeaponDef(); + springai::Damage* d = def->GetDamage(); + float damage = *(d->GetTypes().begin()); output += damage; + delete d; + delete def; } return output; } @@ -86,6 +103,7 @@ springai::UnitDef* u = *i; IUnitType* ut = game->ToIUnitType(u); options.push_back(ut); + delete u; } } return options; diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/spring/SpringUnitType.h spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/spring/SpringUnitType.h --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/API/spring/SpringUnitType.h 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/API/spring/SpringUnitType.h 2014-10-07 20:10:05.000000000 +0000 @@ -32,4 +32,6 @@ CSpringGame* game; springai::OOAICallback* callback; springai::UnitDef* unitDef; + std::vector resources; + std::vector weaponMounts; }; diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/CppTestAI.cpp spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/CppTestAI.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/CppTestAI.cpp 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/CppTestAI.cpp 2014-10-07 20:10:05.000000000 +0000 @@ -1,3 +1,4 @@ + /* Copyright (c) 2008 Robin Vobruba @@ -62,12 +63,18 @@ game->SendToConsole("shard-runtime warning: unitgiven evt->unit < 0"); break; } - // it might not have been given to us! Could have been given to another team - springai::Unit* unit = springai::WrappUnit::GetInstance(skirmishAIId, evt->unitId); - if(callback->GetSkirmishAI()->GetTeamId() == unit->GetTeam()){ - CSpringUnit* u = new CSpringUnit(callback,unit,game); - aliveUnits[evt->unitId] = u; - game->Me()->UnitGiven(u); + CSpringUnit* u = game->GetUnitById(evt->unitId); + if (!u) { + u = game->CreateUnit(evt->unitId); + } + + if (u) { + // it might not have been given to us! Could have been given to another team + if(game->GetTeamID() == u->Team()){ + game->Me()->UnitGiven(u); + } + } else { + game->SendToConsole("shard-runtime warning: unitgiven unit NULL"); } break; } @@ -77,11 +84,11 @@ game->SendToConsole("shard-runtime warning: unitcreated evt->unit < 0"); break; } - springai::Unit* unit = springai::WrappUnit::GetInstance(skirmishAIId, evt->unit); - if(unit != NULL){ - CSpringUnit* u = new CSpringUnit(callback,unit,game); - aliveUnits[evt->unit] = u; + CSpringUnit* u = game->CreateUnit(evt->unit); + if (u) { game->Me()->UnitCreated(u); + } else { + game->SendToConsole("shard-runtime warning: unitcreated unit NULL"); } break; } @@ -91,19 +98,14 @@ game->SendToConsole("shard-runtime warning: unitfinished evt->unit < 0"); break; } - CSpringUnit* u = 0; - if(aliveUnits.find(evt->unit) != aliveUnits.end()){ - u = aliveUnits[evt->unit]; - } - if( u == 0){ - springai::Unit* unit = springai::WrappUnit::GetInstance(skirmishAIId, evt->unit); - if(unit != NULL){ - u = new CSpringUnit(callback,unit,game); - aliveUnits[evt->unit] = u; - } + CSpringUnit* u = game->GetUnitById(evt->unit); + if(u == 0){ + u = game->CreateUnit(evt->unit); } if(u != 0){ game->Me()->UnitBuilt(u); + } else { + game->SendToConsole("shard-runtime warning: unitfinished unit NULL"); } break; } @@ -113,30 +115,70 @@ game->SendToConsole("shard-runtime warning: unitdestroyed evt->unit < 0"); break; } - std::map::iterator i = aliveUnits.find(evt->unit); - if(i != aliveUnits.end()){ - CSpringUnit* u = i->second; + CSpringUnit* u = game->GetUnitById(evt->unit); + if(!u) { + u = game->CreateUnit(evt->unit); + } + if(u){ game->Me()->UnitDead(u); - aliveUnits.erase(i); - delete u; + game->DestroyUnit(evt->unit); + } else { + game->SendToConsole("shard-runtime warning: unitdestroyed unit NULL"); } break; } + case EVENT_ENEMY_DESTROYED: { + struct SEnemyDestroyedEvent* evt = (struct SEnemyDestroyedEvent*) data; + if(evt->enemy < 0){ + game->SendToConsole("shard-runtime warning: enemydestroyed evt->unit < 0"); + break; + } + CSpringUnit* u = game->GetUnitById(evt->enemy); + if (!u) { + u = game->CreateUnit(evt->enemy); + } + /*if(u){ + // @TODO: Add enemy dead event + game->Me()->UnitDead(u); + }*/ + game->DestroyUnit(evt->enemy); + break; + } + case EVENT_ENEMY_CREATED: { + struct SEnemyCreatedEvent* evt = (struct SEnemyCreatedEvent*) data; + game->CreateUnit(evt->enemy); + break; + } + case EVENT_ENEMY_FINISHED: { + struct SEnemyFinishedEvent* evt = (struct SEnemyFinishedEvent*) data; + game->CreateUnit(evt->enemy); + break; + } case EVENT_UNIT_DAMAGED: { struct SUnitDamagedEvent* evt = (struct SUnitDamagedEvent*) data; if(evt->unit < 0){ game->SendToConsole("shard-runtime warning: unitdamaged evt->unit < 0"); break; } - CSpringUnit* u = 0; - if (aliveUnits.find(evt->unit) != aliveUnits.end()){ - u = aliveUnits[evt->unit]; - } - CSpringUnit* a = 0; - if (aliveUnits.find(evt->attacker) != aliveUnits.end()){ - a = aliveUnits[evt->attacker]; + CSpringUnit* u = game->GetUnitById(evt->unit); + if (!u) { + u = game->CreateUnit(evt->unit); + } + + //attacker is allowed to be -1 if attacker cannot be seen or determined. + CSpringUnit* a = NULL; + if (evt->attacker >= 0) { + a = game->GetUnitById(evt->attacker); + if (!a) { + game->CreateUnit(evt->attacker); + } + } + if(u) { + game->Me()->UnitDamaged(u,a); + } else { + if (!u) + game->SendToConsole("shard-runtime warning: attacked unit not found."); } - game->Me()->UnitDamaged(u,a); break; } case EVENT_UNIT_IDLE: { @@ -145,8 +187,15 @@ game->SendToConsole("shard-runtime warning: unitidle evt->unit < 0"); break; } - CSpringUnit* u = aliveUnits[evt->unit]; - game->Me()->UnitIdle(u); + CSpringUnit* u = game->GetUnitById(evt->unit); + if (!u) { + game->CreateUnit(evt->unit); + } + if (u) { + game->Me()->UnitIdle(u); + } else { + game->SendToConsole("shard-runtime warning: unitidle unit was NULL"); + } break; } case EVENT_UNIT_MOVE_FAILED: { @@ -155,8 +204,21 @@ game->SendToConsole("shard-runtime warning: SUnitMoveFailedEvent evt->unit < 0"); break; } - CSpringUnit* u = aliveUnits[evt->unit]; - game->Me()->UnitMoveFailed(u); + CSpringUnit* u = game->GetUnitById(evt->unit); + if (!u) { + u = game->CreateUnit(evt->unit); + } + if (u) { + game->Me()->UnitMoveFailed(u); + } else { + game->SendToConsole("shard-runtime warning: Did not now about move failed unit"); + } + break; + } + case EVENT_LUA_MESSAGE: { + struct SLuaMessageEvent* evt = (struct SLuaMessageEvent*) data; + game->Me()->GameMessage(evt->inData); + break; } default: { @@ -167,6 +229,11 @@ // signal: everything went OK return 0; } + +CSpringUnit* cpptestai::CCppTestAI::getUnitByID( int unit_id ) { + return game->GetUnitById(unit_id); +} + /*EVENT_NULL = 0, EVENT_INIT = 1, EVENT_RELEASE = 2, @@ -196,4 +263,4 @@ EVENT_ENEMY_FINISHED = 26, EVENT_LUA_MESSAGE = 27, - */ \ No newline at end of file + */ diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/CppTestAI.h spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/CppTestAI.h --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/CppTestAI.h 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/CppTestAI.h 2014-10-07 20:10:05.000000000 +0000 @@ -34,12 +34,12 @@ springai::OOAICallback* callback; int skirmishAIId; CSpringGame* game; - std::map aliveUnits; - public: CCppTestAI(springai::OOAICallback* callback); ~CCppTestAI(); + CSpringUnit* getUnitByID( int unit_id ); + int HandleEvent(int topic, const void* data); }; // class CCppTestAI diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/TestAI.cpp spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/TestAI.cpp --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/TestAI.cpp 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/TestAI.cpp 2014-10-07 20:10:05.000000000 +0000 @@ -85,6 +85,7 @@ luaopen_api(this->L); unittype = SWIG_TypeQuery(this->L,"IUnit *"); + // Push in our IGame pointer swig_type_info* type = SWIG_TypeQuery(this->L,"IGame *"); SWIG_NewPointerObj(this->L,game,type,0); @@ -178,6 +179,17 @@ } } +void CTestAI::GameMessage(const char* text){ + lua_getglobal(this->L, "ai"); + lua_getfield(this->L, -1, "GameMessage"); + lua_getglobal(this->L, "ai"); + lua_pushstring(this->L,text); + //SWIG_NewPointerObj(this->L,text,(char *),0); + if(lua_isfunction(this->L,-3)){ + lua_epcall(this->L, 2); + } +} + void CTestAI::UnitGiven(IUnit* unit){ lua_getglobal(this->L, "ai"); lua_getfield(this->L, -1, "UnitGiven"); diff -Nru spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/TestAI.h spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/TestAI.h --- spring-96.0~14.04~ppa4/AI/Skirmish/Shard/src/TestAI.h 2014-01-03 13:30:03.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Skirmish/Shard/src/TestAI.h 2014-10-07 20:10:05.000000000 +0000 @@ -19,6 +19,7 @@ virtual void Init(); virtual void Update(); virtual void GameEnd(); + virtual void GameMessage(const char* text); virtual void UnitCreated(IUnit* unit); virtual void UnitBuilt(IUnit* unit); @@ -35,10 +36,11 @@ void PushIUnit(IUnit* unit); static IAI* ai; + IGame* GetGame() const { return game; } protected: swig_type_info* unittype; bool LoadLuaFile(std::string filename); + IGame* game; - }; diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/CMakeLists.txt spring-98.0~14.04~ppa6/AI/Wrappers/CMakeLists.txt --- spring-96.0~14.04~ppa4/AI/Wrappers/CMakeLists.txt 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -25,7 +25,7 @@ # exclude CUtils here, as it was already included before if (NOT "${aiWrapperDir}" STREQUAL "CUtils") Add_Subdirectory(${aiWrapperDir}) + list(APPEND DEPS_AI_WRAPPERS ${aiWrapperDir}-AIWrapper) endif (NOT "${aiWrapperDir}" STREQUAL "CUtils") - list(APPEND DEPS_AI_WRAPPERS ${aiWrapperDir}-AIWrapper) endforeach (aiWrapperDir) MakeGlobal(DEPS_AI_WRAPPERS) diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/Cpp/bin/combine_wrappCommands.awk spring-98.0~14.04~ppa6/AI/Wrappers/Cpp/bin/combine_wrappCommands.awk --- spring-96.0~14.04~ppa4/AI/Wrappers/Cpp/bin/combine_wrappCommands.awk 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/Cpp/bin/combine_wrappCommands.awk 2014-10-07 20:09:51.000000000 +0000 @@ -229,20 +229,15 @@ print("\t" "internal_ret = id_clb[skirmishAIId]->Engine_handleCommand(skirmishAIId, COMMAND_TO_ID_ENGINE, -1, " topicName ", &commandData);") >> outFile_nc; print("") >> outFile_nc; - if (retParam != "") { - print("\t" "internal_ret = commandData." retParam ";") >> outFile_nc; - } - if (hasRetType) { - # this is unused, delete print("\t" "if (internal_ret == 0) {") >> outFile_nc; - print("\t\t" "internal_ret = commandData." retParam ";") >> outFile_nc; + print("\t\t" "return commandData." retParam ";") >> outFile_nc; print("\t" "} else {") >> outFile_nc; - print("\t\t" "internal_ret = 0;") >> outFile_nc; + print("\t\t" "return (" retType ")0;") >> outFile_nc; print("\t" "}") >> outFile_nc; + } else { + print("\t" "return internal_ret;") >> outFile_nc; } - - print("\t" "return internal_ret;") >> outFile_nc; print("}") >> outFile_nc; if (match(fullName, /^Unit_/)) { diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/Cpp/bin/wrappCallback.awk spring-98.0~14.04~ppa6/AI/Wrappers/Cpp/bin/wrappCallback.awk --- spring-96.0~14.04~ppa4/AI/Wrappers/Cpp/bin/wrappCallback.awk 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/Cpp/bin/wrappCallback.awk 2014-10-07 20:09:51.000000000 +0000 @@ -305,7 +305,7 @@ fSetterName_tr = fName_tr; sub(/^(Get|Is)/, "Set", fSetterName_tr); print("private:") >> outFile_stb_h_tr; - print("\t" fRet_tr " " propName_tr ";/* = " nullTypeValue_tr "*/; // TODO: FIXME: put this into a constructor") >> outFile_stb_h_tr; + print("\t" fRet_tr " " propName_tr ";/* = " nullTypeValue_tr ";*/ // TODO: FIXME: put this into a constructor") >> outFile_stb_h_tr; print("public:") >> outFile_stb_h_tr; print("\t" "virtual " "void " fSetterName_tr "(" fRet_tr " " propName_tr ")" ";") >> outFile_stb_h_tr; @@ -1028,7 +1028,7 @@ } _hasRetInd = 0; _refObj = _refObj"*"; - if (retType != "void") { + if (retType != "void" && split(innerParams, _, ",") == addInds_size_m) { _hasRetInd = 1; } for (ai=1; ai <= (addInds_size_m-_hasRetInd); ai++) { diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/Cpp/CMakeLists.txt spring-98.0~14.04~ppa6/AI/Wrappers/Cpp/CMakeLists.txt --- spring-96.0~14.04~ppa4/AI/Wrappers/Cpp/CMakeLists.txt 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/Cpp/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -78,6 +78,7 @@ ${myGeneratedSourceDir}/AbstractFile.cpp ${myGeneratedSourceDir}/AbstractFlankingBonus.cpp ${myGeneratedSourceDir}/AbstractGame.cpp + ${myGeneratedSourceDir}/AbstractGameRulesParam.cpp ${myGeneratedSourceDir}/AbstractGroup.cpp ${myGeneratedSourceDir}/AbstractGui.cpp ${myGeneratedSourceDir}/AbstractInfo.cpp @@ -86,7 +87,6 @@ ${myGeneratedSourceDir}/AbstractLua.cpp ${myGeneratedSourceDir}/AbstractMap.cpp ${myGeneratedSourceDir}/AbstractMod.cpp - ${myGeneratedSourceDir}/AbstractModParam.cpp ${myGeneratedSourceDir}/AbstractMoveData.cpp ${myGeneratedSourceDir}/AbstractOOAICallback.cpp ${myGeneratedSourceDir}/AbstractOptionValues.cpp @@ -100,8 +100,11 @@ ${myGeneratedSourceDir}/AbstractShield.cpp ${myGeneratedSourceDir}/AbstractSkirmishAI.cpp ${myGeneratedSourceDir}/AbstractSkirmishAIs.cpp + ${myGeneratedSourceDir}/AbstractTeam.cpp + ${myGeneratedSourceDir}/AbstractTeamRulesParam.cpp ${myGeneratedSourceDir}/AbstractTeams.cpp ${myGeneratedSourceDir}/AbstractUnit.cpp + ${myGeneratedSourceDir}/AbstractUnitRulesParam.cpp ${myGeneratedSourceDir}/AbstractUnitDef.cpp ${myGeneratedSourceDir}/AbstractVersion.cpp ${myGeneratedSourceDir}/AbstractWeaponDef.cpp @@ -121,6 +124,7 @@ ${myGeneratedSourceDir}/StubFile.cpp ${myGeneratedSourceDir}/StubFlankingBonus.cpp ${myGeneratedSourceDir}/StubGame.cpp + ${myGeneratedSourceDir}/StubGameRulesParam.cpp ${myGeneratedSourceDir}/StubGroup.cpp ${myGeneratedSourceDir}/StubGui.cpp ${myGeneratedSourceDir}/StubInfo.cpp @@ -129,7 +133,6 @@ ${myGeneratedSourceDir}/StubLua.cpp ${myGeneratedSourceDir}/StubMap.cpp ${myGeneratedSourceDir}/StubMod.cpp - ${myGeneratedSourceDir}/StubModParam.cpp ${myGeneratedSourceDir}/StubMoveData.cpp ${myGeneratedSourceDir}/StubOOAICallback.cpp ${myGeneratedSourceDir}/StubOptionValues.cpp @@ -143,8 +146,11 @@ ${myGeneratedSourceDir}/StubShield.cpp ${myGeneratedSourceDir}/StubSkirmishAI.cpp ${myGeneratedSourceDir}/StubSkirmishAIs.cpp + ${myGeneratedSourceDir}/StubTeam.cpp + ${myGeneratedSourceDir}/StubTeamRulesParam.cpp ${myGeneratedSourceDir}/StubTeams.cpp ${myGeneratedSourceDir}/StubUnit.cpp + ${myGeneratedSourceDir}/StubUnitRulesParam.cpp ${myGeneratedSourceDir}/StubUnitDef.cpp ${myGeneratedSourceDir}/StubVersion.cpp ${myGeneratedSourceDir}/StubWeaponDef.cpp @@ -164,6 +170,7 @@ ${myGeneratedSourceDir}/WrappFile.cpp ${myGeneratedSourceDir}/WrappFlankingBonus.cpp ${myGeneratedSourceDir}/WrappGame.cpp + ${myGeneratedSourceDir}/WrappGameRulesParam.cpp ${myGeneratedSourceDir}/WrappGraphDrawer.cpp ${myGeneratedSourceDir}/WrappGraphLine.cpp ${myGeneratedSourceDir}/WrappGroup.cpp @@ -175,7 +182,6 @@ ${myGeneratedSourceDir}/WrappLua.cpp ${myGeneratedSourceDir}/WrappMap.cpp ${myGeneratedSourceDir}/WrappMod.cpp - ${myGeneratedSourceDir}/WrappModParam.cpp ${myGeneratedSourceDir}/WrappMoveData.cpp ${myGeneratedSourceDir}/WrappOOAICallback.cpp ${myGeneratedSourceDir}/WrappOptionValues.cpp @@ -189,8 +195,11 @@ ${myGeneratedSourceDir}/WrappShield.cpp ${myGeneratedSourceDir}/WrappSkirmishAI.cpp ${myGeneratedSourceDir}/WrappSkirmishAIs.cpp + ${myGeneratedSourceDir}/WrappTeam.cpp + ${myGeneratedSourceDir}/WrappTeamRulesParam.cpp ${myGeneratedSourceDir}/WrappTeams.cpp ${myGeneratedSourceDir}/WrappUnit.cpp + ${myGeneratedSourceDir}/WrappUnitRulesParam.cpp ${myGeneratedSourceDir}/WrappUnitDef.cpp ${myGeneratedSourceDir}/WrappUnitSupportedCommand.cpp ${myGeneratedSourceDir}/WrappVersion.cpp diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/CUtils/CMakeLists.txt spring-98.0~14.04~ppa6/AI/Wrappers/CUtils/CMakeLists.txt --- spring-96.0~14.04~ppa4/AI/Wrappers/CUtils/CMakeLists.txt 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/CUtils/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -13,10 +13,9 @@ "${mySourceDir}/SharedLibrary.c" "${mySourceDir}/SimpleLog.c" "${mySourceDir}/SimpleProfiler.cpp" - "${mySourceDir}/SSkirmishAISpecifier.cpp" "${mySourceDir}/Util.c" "${mySourceDir}/TimeUtil.cpp" ) -SetGlobal(${myName}_SRC "${mySources}") +add_library(CUtils STATIC ${mySources}) AIMessage(STATUS "Found AI Wrapper: ${myName} (sources only wrapper)") diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/CUtils/SharedLibrary.c spring-98.0~14.04~ppa6/AI/Wrappers/CUtils/SharedLibrary.c --- spring-96.0~14.04~ppa4/AI/Wrappers/CUtils/SharedLibrary.c 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/CUtils/SharedLibrary.c 2014-10-07 20:09:51.000000000 +0000 @@ -52,11 +52,11 @@ if ((lib = LoadLibrary(libFilePath)) == NULL) { fprintf(stderr, "[SharedLibrary.c::sharedLib_load(%s)] LoadLibrary() error %d\n", libFilePath, GetLastError()); } -#else // defined _WIN32 +#else /* defined _WIN32 */ if ((lib = dlopen(libFilePath, RTLD_LAZY)) == NULL) { fprintf(stderr, "[SharedLibrary.c::sharedLib_load(%s)] dlopen() error %s\n", libFilePath, dlerror()); } -#endif // else defined _WIN32 +#endif /* else defined _WIN32 */ return lib; } @@ -68,9 +68,9 @@ #if defined _WIN32 FreeLibrary(sharedLib); -#else // defined _WIN32 +#else /* defined _WIN32 */ dlclose(sharedLib); -#endif // else defined _WIN32 +#endif /* else defined _WIN32 */ sharedLib = NULL; } @@ -86,7 +86,7 @@ #if defined _WIN32 return (void*) GetProcAddress(sharedLib, symbol); -#else // defined _WIN32 +#else /* defined _WIN32 */ return dlsym(sharedLib, symbol); -#endif // else defined _WIN32 +#endif /* else defined _WIN32 */ } diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/CUtils/SharedLibrary.h spring-98.0~14.04~ppa6/AI/Wrappers/CUtils/SharedLibrary.h --- spring-96.0~14.04~ppa4/AI/Wrappers/CUtils/SharedLibrary.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/CUtils/SharedLibrary.h 2014-10-07 20:09:51.000000000 +0000 @@ -25,7 +25,7 @@ #ifndef bool #include #endif -#include // for NULL +#include /* for NULL */ #ifdef _WIN32 #include @@ -82,4 +82,4 @@ } // extern "C" #endif -#endif // _SHAREDLIBRARY_H +#endif /* _SHAREDLIBRARY_H */ diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/CUtils/SimpleLog.h spring-98.0~14.04~ppa6/AI/Wrappers/CUtils/SimpleLog.h --- spring-96.0~14.04~ppa4/AI/Wrappers/CUtils/SimpleLog.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/CUtils/SimpleLog.h 2014-10-07 20:09:51.000000000 +0000 @@ -31,7 +31,7 @@ SIMPLELOG_LEVEL_FINEST = 10 }; -#include // bool, true, false +#include /* bool, true, false */ #define EXTERNAL_LOGGER(msg) log(msg); @@ -70,4 +70,4 @@ } // extern "C" #endif -#endif // _LOG_H +#endif /* _LOG_H */ diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/CUtils/SimpleProfiler.cpp spring-98.0~14.04~ppa6/AI/Wrappers/CUtils/SimpleProfiler.cpp --- spring-96.0~14.04~ppa4/AI/Wrappers/CUtils/SimpleProfiler.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/CUtils/SimpleProfiler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -58,12 +58,9 @@ ScopedTimer::ScopedTimer(const char* const part, Profiler* profiler) : part(part) - , profiler(profiler) + , profiler(profiler ? profiler : Profiler::GetDefault()) , startTime(timeUtil_getCurrentTimeMillis()) { - if (profiler == NULL) { - profiler = Profiler::GetDefault(); - } } ScopedTimer::~ScopedTimer() diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/CUtils/SSkirmishAISpecifier.cpp spring-98.0~14.04~ppa6/AI/Wrappers/CUtils/SSkirmishAISpecifier.cpp --- spring-96.0~14.04~ppa4/AI/Wrappers/CUtils/SSkirmishAISpecifier.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/CUtils/SSkirmishAISpecifier.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,133 +0,0 @@ -/* - Copyright (c) 2008 Robin Vobruba - - This program 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 2 of the License, or - (at your option) any later version. - - 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 . -*/ - -#if defined BUILDING_AI_INTERFACE - - -#include "SSkirmishAISpecifier.h" - -#include "Util.h" - -#include "System/maindefines.h" -#include "System/SafeCStrings.h" - -#include -#include - - -struct SSkirmishAISpecifier SSkirmishAISpecifier_copy( - const struct SSkirmishAISpecifier* const orig) { - - struct SSkirmishAISpecifier copy; - - copy.shortName = util_allocStrCpy(orig->shortName); - copy.version = util_allocStrCpy(orig->version); - - return copy; -} - -void SSkirmishAISpecifier_delete(struct SSkirmishAISpecifier* spec) { - - free(const_cast(spec->shortName)); - spec->shortName = NULL; - free(const_cast(spec->version)); - spec->version = NULL; - FREE(spec); -} - - - -// by DeeViLiSh -static int string_simpleHash(const char* const input) { - - int b = 378551; // Ramdom Ranges I've chosen (can be modified) - int a = 63689; - int hash = 0; // Output hash - int i; // Temp number that scrolls through the string array - - int size = strlen(input); - for(i = 0; i < size; i++) { // Loop to convert each character - hash = hash * a + input[i]; // Algorithm that hashs - a = a * b; - } - - return (hash & 0x7FFFFFFF); // Returns the hashed string -} - -int SSkirmishAISpecifier_hash( - const struct SSkirmishAISpecifier* const spec) { - - bool useShortName = spec->shortName != NULL; - bool useVersion = spec->version != NULL; - - size_t hashString_size = 0; - if (useShortName) { - hashString_size += strlen(spec->shortName); - } - hashString_size += 1; // for the '#' char - if (useVersion) { - hashString_size += strlen(spec->version); - } - hashString_size += 1; // for the '\0' char - - char hashString[hashString_size]; - hashString[0] = '\0'; - - if (useShortName) { - STRCAT_T(hashString, hashString_size, spec->shortName); - } - STRCAT_T(hashString, hashString_size, "#"); - if (useVersion) { - STRCAT_T(hashString, hashString_size, spec->version); - } - - int keyHash = string_simpleHash(hashString); - - return keyHash; -} - -int SSkirmishAISpecifier_compare( - const struct SSkirmishAISpecifier* const specThis, - const struct SSkirmishAISpecifier* const specThat) { - - int comp = strcmp(specThis->shortName, specThat->shortName); - if (comp == 0) { - comp = strcmp(specThis->version, specThat->version); - } - return comp; -} - -bool SSkirmishAISpecifier_isUnspecified( - const struct SSkirmishAISpecifier* const spec) { - return spec->shortName == NULL || spec->version == NULL; -} - -static const SSkirmishAISpecifier unspecifiedSpec = {NULL, NULL}; -struct SSkirmishAISpecifier SSkirmishAISpecifier_getUnspecified() { - return unspecifiedSpec; -} - - -#ifdef __cplusplus -bool SSkirmishAISpecifier_Comparator::operator()( - const struct SSkirmishAISpecifier& specThis, - const struct SSkirmishAISpecifier& specThat) const { - return SSkirmishAISpecifier_compare(&specThis, &specThat) < 0; -} -#endif // defined __cplusplus - -#endif // defined BUILDING_AI_INTERFACE diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/CUtils/SSkirmishAISpecifier.h spring-98.0~14.04~ppa6/AI/Wrappers/CUtils/SSkirmishAISpecifier.h --- spring-96.0~14.04~ppa4/AI/Wrappers/CUtils/SSkirmishAISpecifier.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/CUtils/SSkirmishAISpecifier.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -/* - Copyright (c) 2008 Robin Vobruba - - This program 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 2 of the License, or - (at your option) any later version. - - 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 . -*/ - -/** - * The struct and the helper functions in this file are here for convenience - * when building AI interfaces. The SSkirmishAISpecifier struct can be of use - * as key type for C++ maps or C hash maps (eg. to cache loaded Skirmish AIs). - * Engine side, we are using the C++ class SkirmishAIKey for the same purposes. - */ -#if defined BUILDING_AI_INTERFACE - -#ifndef _SSKIRMISHAISPECIFIER_H -#define _SSKIRMISHAISPECIFIER_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief struct Skirmish Artificial Intelligence specifier - */ -struct SSkirmishAISpecifier { - const char* shortName; // [may not contain: spaces, '_', '#'] - const char* version; // [may not contain: spaces, '_', '#'] -}; - -struct SSkirmishAISpecifier SSkirmishAISpecifier_copy( - const struct SSkirmishAISpecifier* const orig); - -void SSkirmishAISpecifier_delete(struct SSkirmishAISpecifier* spec); - -int SSkirmishAISpecifier_hash( - const struct SSkirmishAISpecifier* const spec); - -int SSkirmishAISpecifier_compare( - const struct SSkirmishAISpecifier* const specThis, - const struct SSkirmishAISpecifier* const specThat); - -bool SSkirmishAISpecifier_isUnspecified( - const struct SSkirmishAISpecifier* const spec); - -struct SSkirmishAISpecifier SSkirmishAISpecifier_getUnspecified(); - - -#if defined __cplusplus -struct SSkirmishAISpecifier_Comparator { - /** - * The key comparison function, a Strict Weak Ordering; - * it returns true if its first argument is less - * than its second argument, and false otherwise. - * This is also defined as map::key_compare. - */ - bool operator()(const struct SSkirmishAISpecifier& specThis, - const struct SSkirmishAISpecifier& specThat) const; -}; -#endif // defined __cplusplus - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _SSKIRMISHAISPECIFIER_H - -#endif // defined BUILDING_AI_INTERFACE diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/CUtils/Util.c spring-98.0~14.04~ppa6/AI/Wrappers/CUtils/Util.c --- spring-96.0~14.04~ppa4/AI/Wrappers/CUtils/Util.c 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/CUtils/Util.c 2014-10-07 20:09:51.000000000 +0000 @@ -33,11 +33,6 @@ #include "System/maindefines.h" #include "System/SafeCStrings.h" -#if defined USING_STREFLOP -#include "lib/streflop/streflopC.h" // for streflop_init_Simple() -#else -#include -#endif char* util_allocStr(unsigned int length) { @@ -919,13 +914,4 @@ return value; } -void util_resetEngineEnv() { -#if defined USING_STREFLOP - streflop_init_Simple(); -#else - // Error: streflop should be imported if this function has to be called - assert(0); -#endif -} - void util_finalize() {} diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/CUtils/Util.h spring-98.0~14.04~ppa6/AI/Wrappers/CUtils/Util.h --- spring-96.0~14.04~ppa4/AI/Wrappers/CUtils/Util.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/CUtils/Util.h 2014-10-07 20:09:51.000000000 +0000 @@ -207,21 +207,6 @@ const char* key); /** - * Reestablishes the environment that is needed by the engine. - * Whenever an AI Iterface, or a VM running in it, - * changes the programm environment, this function should be called - * before CPU controll goes back to the engine. - * Currently handled changes: - * - changing the state of the FPU - * - * For an exampe of when to call this function, - * look for it in the Java AI Interface native code. - * If you use this function, you will need to link against - * the streflop static library. - */ -void util_resetEngineEnv(); - -/** * Free memory. * Some of the other functions will not work anymore, * after calling this function. diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/JavaOO/bin/wrappCallback.awk spring-98.0~14.04~ppa6/AI/Wrappers/JavaOO/bin/wrappCallback.awk --- spring-96.0~14.04~ppa4/AI/Wrappers/JavaOO/bin/wrappCallback.awk 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/JavaOO/bin/wrappCallback.awk 2014-10-07 20:09:51.000000000 +0000 @@ -810,7 +810,8 @@ _retVar_out_new = retVar_out_m "_out"; _wrappGetInst_params = myWrapVar; _hasRetInd = 0; - if (retType != "void") { + _inPa_size = split(innerParams, _, ","); + if (retType != "void" && (_inPa_size == addInds_size_m || _inPa_size == 0)) { _hasRetInd = 1; } for (ai=1; ai <= (addInds_size_m-_hasRetInd); ai++) { @@ -886,15 +887,15 @@ # convert to a HashMap conversionCode_post = conversionCode_post "\t\t" _mapVar_oo " = new " _mapType_impl "();" "\n"; conversionCode_post = conversionCode_post "\t\t" "for (int i=0; i < " _mapVar_size "; i++) {" "\n"; - if (_isObj) { - if (_isRetSize) { +# if (_isObj) { +# if (_isRetSize) { conversionCode_post = conversionCode_post "\t\t\t" _mapVar_oo ".put(" _mapVar_keys "[i], " _mapVar_values "[i]);" "\n"; - } else { +# } else { #conversionCode_post = conversionCode_post "\t\t\t" _mapVar_oo ".put(" myPkgA ".Wrapp" _refObj ".getInstance(" myWrapVar _addWrappVars ", " _arrayPaNa "[i]));" "\n"; - } - } else if (_isNative) { +# } +# } else if (_isNative) { #conversionCode_post = conversionCode_post "\t\t\t" _arrayListVar ".add(" _arrayPaNa "[i]);" "\n"; - } +# } conversionCode_post = conversionCode_post "\t\t" "}" "\n"; retParamType = _mapType_int; diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/JavaOO/CMakeLists.txt spring-98.0~14.04~ppa6/AI/Wrappers/JavaOO/CMakeLists.txt --- spring-96.0~14.04~ppa4/AI/Wrappers/JavaOO/CMakeLists.txt 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/JavaOO/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -121,6 +121,7 @@ "Figure" "FlankingBonus" "Game" + "GameRulesParam" "GraphDrawer" "GraphLine" "Group" @@ -131,7 +132,6 @@ # "Lua" "Map" "Mod" - "ModParam" "MoveData" "OOAICallback" "OptionValues" @@ -144,10 +144,13 @@ "Shield" "SkirmishAI" "SkirmishAIs" + "Team" + "TeamRulesParam" "Teams" "OverlayTexture" "UnitDef" "Unit" + "UnitRulesParam" "Version" "WeaponDef" "WeaponMount" diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/LegacyCpp/AIAICallback.cpp spring-98.0~14.04~ppa6/AI/Wrappers/LegacyCpp/AIAICallback.cpp --- spring-96.0~14.04~ppa4/AI/Wrappers/LegacyCpp/AIAICallback.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/LegacyCpp/AIAICallback.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1690,8 +1690,9 @@ int springLegacyAI::CAIAICallback::InitPath(float3 start, float3 end, int pathType, float goalRadius) { float start_f3[3]; - start.copyInto(start_f3); float end_f3[3]; + + start.copyInto(start_f3); end.copyInto(end_f3); SInitPathCommand cmd = {start_f3, end_f3, pathType, goalRadius}; @@ -1710,12 +1711,14 @@ float springLegacyAI::CAIAICallback::GetPathLength(float3 start, float3 end, int pathType, float goalRadius) { float start_f3[3]; - start.copyInto(start_f3); float end_f3[3]; + + start.copyInto(start_f3); end.copyInto(end_f3); SGetApproximateLengthPathCommand cmd = {start_f3, end_f3, pathType, goalRadius}; - sAICallback->Engine_handleCommand(skirmishAIId, COMMAND_TO_ID_ENGINE, -1, COMMAND_PATH_GET_APPROXIMATE_LENGTH, &cmd); return cmd.ret_approximatePathLength; + sAICallback->Engine_handleCommand(skirmishAIId, COMMAND_TO_ID_ENGINE, -1, COMMAND_PATH_GET_APPROXIMATE_LENGTH, &cmd); + return cmd.ret_approximatePathLength; } void springLegacyAI::CAIAICallback::FreePath(int pathId) { diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/LegacyCpp/CMakeLists.txt spring-98.0~14.04~ppa6/AI/Wrappers/LegacyCpp/CMakeLists.txt --- spring-96.0~14.04~ppa4/AI/Wrappers/LegacyCpp/CMakeLists.txt 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/LegacyCpp/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -65,6 +65,7 @@ # Compile the Legacy C++ AI wrapper static library with creg support add_library(${myCregTarget} STATIC ${mySources} ${sources_engine_System_creg}) + Add_Dependencies(${myCregTarget} generateVersionFiles) set_target_properties(${myCregTarget} PROPERTIES OUTPUT_NAME "${myName}Creg") set_target_properties(${myCregTarget} PROPERTIES COMPILE_FLAGS "-DUSING_CREG") endif (BUILD_${myName}_AIWRAPPER) diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/LegacyCpp/Command.cpp spring-98.0~14.04~ppa6/AI/Wrappers/LegacyCpp/Command.cpp --- spring-96.0~14.04~ppa4/AI/Wrappers/LegacyCpp/Command.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/LegacyCpp/Command.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ namespace springLegacyAI { -CR_BIND(Command, ); +CR_BIND(Command, ) CR_REG_METADATA(Command, ( CR_MEMBER(id), CR_MEMBER(options), @@ -15,9 +15,9 @@ CR_MEMBER(tag), CR_MEMBER(timeOut), CR_RESERVED(16) - )); + )) -CR_BIND(CommandDescription, ); +CR_BIND(CommandDescription, ) CR_REG_METADATA(CommandDescription, ( CR_MEMBER(id), CR_MEMBER(type), @@ -32,7 +32,7 @@ CR_MEMBER(onlyTexture), CR_MEMBER(params), CR_RESERVED(32) - )); + )) } // namespace springLegacyAI diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/LegacyCpp/Command.h spring-98.0~14.04~ppa6/AI/Wrappers/LegacyCpp/Command.h --- spring-96.0~14.04~ppa4/AI/Wrappers/LegacyCpp/Command.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/LegacyCpp/Command.h 2014-10-07 20:09:51.000000000 +0000 @@ -108,13 +108,9 @@ struct Command { private: - CR_DECLARE_STRUCT(Command); + CR_DECLARE_STRUCT(Command) /* TODO check if usage of System/MemPool.h for this struct improves performance - #if !(defined(USE_GML) && GML_ENABLE_SIM) - inline void* operator new(size_t size) { return mempool.Alloc(size); } - inline void operator delete(void* p, size_t size) { mempool.Free(p, size); } - #endif */ public: @@ -346,7 +342,7 @@ struct CommandDescription { private: - CR_DECLARE_STRUCT(CommandDescription); + CR_DECLARE_STRUCT(CommandDescription) public: CommandDescription(): diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/LegacyCpp/CommandQueue.h spring-98.0~14.04~ppa6/AI/Wrappers/LegacyCpp/CommandQueue.h --- spring-96.0~14.04~ppa4/AI/Wrappers/LegacyCpp/CommandQueue.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/LegacyCpp/CommandQueue.h 2014-10-07 20:09:51.000000000 +0000 @@ -15,7 +15,7 @@ friend class CAIAICallback; // the C++ AI interface wrapper // see CommandAI.cpp for further creg stuff for this class - CR_DECLARE_STRUCT(CCommandQueue); + CR_DECLARE_STRUCT(CCommandQueue) public: enum QueueType { diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/LegacyCpp/DamageArray.cpp spring-98.0~14.04~ppa6/AI/Wrappers/LegacyCpp/DamageArray.cpp --- spring-96.0~14.04~ppa4/AI/Wrappers/LegacyCpp/DamageArray.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/LegacyCpp/DamageArray.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ #ifdef USING_CREG namespace springLegacyAI { -CR_BIND(DamageArray, ); +CR_BIND(DamageArray, ) CR_REG_METADATA(DamageArray, ( CR_MEMBER(paralyzeDamageTime), @@ -18,7 +18,7 @@ CR_MEMBER(numTypes), CR_RESERVED(16), CR_SERIALIZER(creg_Serialize) // damages -)); +)) } // namespace springLegacyAI diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/LegacyCpp/DamageArray.h spring-98.0~14.04~ppa6/AI/Wrappers/LegacyCpp/DamageArray.h --- spring-96.0~14.04~ppa4/AI/Wrappers/LegacyCpp/DamageArray.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/LegacyCpp/DamageArray.h 2014-10-07 20:09:51.000000000 +0000 @@ -11,7 +11,7 @@ struct DamageArray { - CR_DECLARE_STRUCT(DamageArray); + CR_DECLARE_STRUCT(DamageArray) public: diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/LegacyCpp/FeatureDef.h spring-98.0~14.04~ppa6/AI/Wrappers/LegacyCpp/FeatureDef.h --- spring-96.0~14.04~ppa4/AI/Wrappers/LegacyCpp/FeatureDef.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/LegacyCpp/FeatureDef.h 2014-10-07 20:09:51.000000000 +0000 @@ -18,7 +18,7 @@ struct FeatureDef { - CR_DECLARE_STRUCT(FeatureDef); + CR_DECLARE_STRUCT(FeatureDef) FeatureDef() : id(-1) diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/LegacyCpp/MoveData.cpp spring-98.0~14.04~ppa6/AI/Wrappers/LegacyCpp/MoveData.cpp --- spring-96.0~14.04~ppa4/AI/Wrappers/LegacyCpp/MoveData.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/LegacyCpp/MoveData.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -8,7 +8,7 @@ namespace springLegacyAI { -CR_BIND(MoveData, ); +CR_BIND(MoveData, ) CR_REG_METADATA(MoveData, ( CR_ENUM_MEMBER(moveType), @@ -37,7 +37,7 @@ CR_MEMBER(subMarine), CR_RESERVED(16) -)); +)) } // namespace springLegacyAI diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/LegacyCpp/MoveData.h spring-98.0~14.04~ppa6/AI/Wrappers/LegacyCpp/MoveData.h --- spring-96.0~14.04~ppa4/AI/Wrappers/LegacyCpp/MoveData.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/LegacyCpp/MoveData.h 2014-10-07 20:09:51.000000000 +0000 @@ -14,7 +14,7 @@ // FIXME: this is a million years behind the engine version now struct MoveData { - CR_DECLARE_STRUCT(MoveData); + CR_DECLARE_STRUCT(MoveData) MoveData() : moveType(MoveData::Ground_Move) diff -Nru spring-96.0~14.04~ppa4/AI/Wrappers/LegacyCpp/WeaponDef.h spring-98.0~14.04~ppa6/AI/Wrappers/LegacyCpp/WeaponDef.h --- spring-96.0~14.04~ppa4/AI/Wrappers/LegacyCpp/WeaponDef.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/AI/Wrappers/LegacyCpp/WeaponDef.h 2014-10-07 20:09:51.000000000 +0000 @@ -16,7 +16,7 @@ struct WeaponDef { private: - CR_DECLARE_STRUCT(WeaponDef); + CR_DECLARE_STRUCT(WeaponDef) public: WeaponDef() diff -Nru spring-96.0~14.04~ppa4/buildbot/master/master.cfg spring-98.0~14.04~ppa6/buildbot/master/master.cfg --- spring-96.0~14.04~ppa4/buildbot/master/master.cfg 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/buildbot/master/master.cfg 2014-10-07 20:09:51.000000000 +0000 @@ -91,7 +91,7 @@ treeStableTimer=60, fileIsImportant=changeIsImportant, change_filter=ChangeFilter(branch_re='develop|release|post_release'), - builderNames=["full-windows-test", "quick-macosx", "validationtests", "linux-static-x32"])) + builderNames=["full-windows-test", "quick-macosx", "validationtests", "linux-static-x64"])) c['schedulers'].append(basic.AnyBranchScheduler( name="release-sched", @@ -104,7 +104,7 @@ branch='develop', fileIsImportant=changeIsImportant, onlyIfChanged=True, - builderNames=["cppcheck", "doxygen", "full-macosx", "latest-boost", "linux-static-x64", "full-clang"], hour=6, minute=0)) + builderNames=["cppcheck", "doxygen", "full-macosx", "latest-boost", "linux-static-x32", "full-clang"], hour=6, minute=0)) @@ -300,7 +300,7 @@ name = "validation test" warnOnWarnings = True command = ['./buildbot/slave/validation/tests-run.sh', WithConfig(), WithBranch(), 'script.txt'] - warningPattern = "(.*Error:|^#\d+ |^ ).*" + warningPattern = "(.*Error:|^#\d+ ).*" def __init__(self, game, map, ai, version, **kwargs): self.game = game self.map = map @@ -668,6 +668,7 @@ ' -DMINGWLIBS:PATH=/slave/mingwlibs' ' -DCMAKE_FIND_ROOT_PATH:PATH=/opt/mxe/usr/libexec/gcc/i686-w64-mingw32/4.8.1;/usr/i686-w64-mingw32' ' -DCMAKE_SYSTEM_NAME:STRING=Windows' + ' -DUSERDOCS_PLAIN:BOOL=ON' ' -G Ninja', 'CXX' : '/opt/mxe/usr/bin/i686-w64-mingw32-g++', 'CC' : '/opt/mxe/usr/bin/i686-w64-mingw32-gcc', @@ -710,7 +711,9 @@ 'factory': MacOSXFullBuildFactory(), 'env': { 'OUTPUTDIR' : 'osx64', - 'MAKE' : 'make' + 'MAKE' : 'make', + 'CMAKEPARAM': + ' -DUSERDOCS_PLAIN:BOOL=ON' } } @@ -742,6 +745,7 @@ 'MAKE' : 'ninja', 'LDFLAGS': '-Wl,-rpath /usr/lib/gcc/i686-pc-linux-gnu/4.7.2', 'LD_LIBRARY_PATH': '/lib32:/usr/i686-pc-linux-gnu/lib:/usr/i686-pc-linux-gnu/usr/lib:/usr/lib/gcc/i686-pc-linux-gnu/4.7.2', + 'JAVA_HOME': '/usr/i686-pc-linux-gnu/opt/oracle-jdk-bin-1.7.0.65/', 'CMAKEPARAM': ' -DCMAKE_TOOLCHAIN_FILE:PATH=../../buildbot/slave/linux/linuxStatic.cmake' ' -DCMAKE_SYSTEM_NAME:STRING=Linux' @@ -749,6 +753,7 @@ ' -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM:STRING=NEVER' ' -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY:STRING=ONLY' ' -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE:STRING=ONLY' + ' -DUSERDOCS_PLAIN:BOOL=ON' ' -G Ninja' } @@ -823,7 +828,7 @@ mingwlibs_builder = { 'name': 'mingwlibs', - 'slavenames': ['abma2'], + 'slavenames': ['jk1', 'abma2'], 'builddir': 'mingwlibs', 'factory': MingwLibsBuildFactory(), 'properties': {'branch': 'master'} diff -Nru spring-96.0~14.04~ppa4/buildbot/slave/cppcheck/cppcheck.supress spring-98.0~14.04~ppa6/buildbot/slave/cppcheck/cppcheck.supress --- spring-96.0~14.04~ppa4/buildbot/slave/cppcheck/cppcheck.supress 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/buildbot/slave/cppcheck/cppcheck.supress 2014-10-07 20:09:51.000000000 +0000 @@ -1,2 +1,5 @@ //hide "SYNCDEBUG is already guaranteed to be defined" preprocessor914 +passedByValue +invalidPointerCast +invalidscanf diff -Nru spring-96.0~14.04~ppa4/buildbot/slave/prepare.sh spring-98.0~14.04~ppa6/buildbot/slave/prepare.sh --- spring-96.0~14.04~ppa4/buildbot/slave/prepare.sh 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/buildbot/slave/prepare.sh 2014-10-07 20:09:51.000000000 +0000 @@ -47,3 +47,9 @@ VERSION_="${CONFIG_}${BRANCH_}${REV}" VERSION=`echo "${VERSION_}" | tr '<>:\"/\\|?*' -` + +if [ -z "${MAKE}" ]; then + echo "MAKE isn't set, using 'make' as default" + MAKE=make +fi + diff -Nru spring-96.0~14.04~ppa4/buildbot/slave/validation/tests-prepare.sh spring-98.0~14.04~ppa6/buildbot/slave/validation/tests-prepare.sh --- spring-96.0~14.04~ppa4/buildbot/slave/validation/tests-prepare.sh 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/buildbot/slave/validation/tests-prepare.sh 2014-10-07 20:09:51.000000000 +0000 @@ -14,7 +14,7 @@ echo "Creating script: test/validation/prepare.sh \"$GAME1\" \"$MAP\" \"$AI\" \"$AIVER\"" ${SOURCEDIR}/test/validation/prepare.sh "$GAME1" "$MAP" "$AI" "$AIVER" > ${CONTENT_DIR}/script.txt -${SOURCEDIR}/test/validation/prepare-client.sh ValidationClient 127.0.0.1 8452 >${CONTENT_DIR}/connect.txt +${SOURCEDIR}/test/validation/prepare-client.sh ValidationClient localhost 8452 >${CONTENT_DIR}/connect.txt #install required files into spring dir cd ${SOURCEDIR} diff -Nru spring-96.0~14.04~ppa4/buildbot/version_list/list.php spring-98.0~14.04~ppa6/buildbot/version_list/list.php --- spring-96.0~14.04~ppa4/buildbot/version_list/list.php 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/buildbot/version_list/list.php 2014-10-07 20:09:51.000000000 +0000 @@ -6,7 +6,7 @@ */ $allowed = array( - '94.23.255.23', # springfiles.com + '37.187.92.174', # springfiles.com ); $ip = $_SERVER['REMOTE_ADDR']; diff -Nru spring-96.0~14.04~ppa4/CMakeLists.txt spring-98.0~14.04~ppa6/CMakeLists.txt --- spring-96.0~14.04~ppa4/CMakeLists.txt 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -6,12 +6,10 @@ # + support for SOURCES attribute of add_custom_target() (not required anymore) # CMake 2.8 # + works around command line length limited by using an @objectFilesList.txt parameter when linking -if (WIN32) - set(MIN_CMAKE_VERSION 2.8) -else (WIN32) - set(MIN_CMAKE_VERSION 2.6) -endif (WIN32) -cmake_minimum_required(VERSION ${MIN_CMAKE_VERSION}) +# CMake 2.8.10 +# + adds support for CMAKE_CXX_COMPILER_ID (which is ignored with older cmake) +cmake_minimum_required(VERSION 2.8) + SET(CMAKE_MODULES_SPRING "${CMAKE_CURRENT_SOURCE_DIR}/rts/build/cmake") LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_MODULES_SPRING}") @@ -28,6 +26,20 @@ CheckMinCMakeVersion(CUSTOM_TARGET_SOURCES_SUPPORT 2 6 3) +# check for minimal gcc version +set(MIN_GCC_VER "4.7") +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + if(NOT ${CMAKE_CXX_COMPILER_VERSION} STREQUAL "") + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${MIN_GCC_VER}") + message(FATAL_ERROR "gcc >=${MIN_GCC_VER} required") + else() + message(STATUS "gcc ${CMAKE_CXX_COMPILER_VERSION} detected") + endif() + else() + message(WARNING "cmake version <2.8.10 found, couldn't check for gcc ${MIN_GCC_VER}") + endif() +endif() + # set some internal vars If ("${CMAKE_BUILD_TYPE}" MATCHES "^DEBUG") Set(DEBUG_BUILD TRUE) @@ -35,18 +47,14 @@ Set(DEBUG_BUILD FALSE) EndIf ("${CMAKE_BUILD_TYPE}" MATCHES "^DEBUG") -# MSVC needs the default flags -if(NOT MSVC) - ### Strip C[XX]_FLAGS - option(CUSTOM_CFLAGS "If false all C[XX]_FLAGS are cleared (more reliable to sync/safer for online play)." FALSE) - if (CUSTOM_CFLAGS) - Message(WARNING "Using custom CXX_FLAGS! this build will very likely not sync in online mode!") - else (CUSTOM_CFLAGS) - set(CMAKE_C_FLAGS "") - set(CMAKE_CXX_FLAGS "") - endif (CUSTOM_CFLAGS) -endif(NOT MSVC) +if(NOT "${CMAKE_C_FLAGS}" STREQUAL "") + Message(WARNING "Using custom C_FLAGS: ${CMAKE_C_FLAGS} this build will very likely not sync in online mode!") +endif() + +if(NOT "${CMAKE_CXX_FLAGS}" STREQUAL "") + Message(WARNING "Using custom CXX_FLAGS: ${CMAKE_CXX_FLAGS} this build will very likely not sync in online mode!") +endif() set (CUSTOM_COMPILER_DEFINITIONS "" CACHE STRING "Custom flags can be defined here") if (CUSTOM_COMPILER_DEFINITIONS) @@ -125,7 +133,7 @@ if(MSVC) set(CMAKE_LIBRARY_PATH ${MINGWLIBS}) set(CMAKE_FIND_ROOT_PATH - ${MINGWLIBS}/SDL + ${MINGWLIBS}/SDL2 ${MINGWLIBS}/DevIL ${MINGWLIBS}/zlib ${MINGWLIBS}/ogg_vorbis @@ -231,7 +239,7 @@ ### external libs if (MINGW) - set(SDL_INCLUDE_DIR "${MINGWLIBS}/include/SDL") + set(SDL2_INCLUDE_DIR "${MINGWLIBS}/include/SDL2") endif (MINGW) FIND_PACKAGE(Boost 1.47.0 COMPONENTS thread regex program_options system chrono signals filesystem REQUIRED) @@ -256,7 +264,11 @@ # Note the missing REQUIRED, as headless & dedi may not depend on those. # So req. checks are done in the build target's CMakeLists.txt. -FIND_PACKAGE(SDL) +FIND_PACKAGE(SDL2) +if("${SDL2_VERSION_STRING}" VERSION_LESS "2") + message(FATAL_ERROR "Found SDL v${SDL2_VERSION_STRING} while 2 is required!") +endif() + FIND_PACKAGE_STATIC(DevIL) IF (PREFER_STATIC_LIBS) # dependencies of DevIL @@ -270,7 +282,6 @@ FIND_PACKAGE(Windres) SET(CMAKE_RC_COMPILER ${WINDRES_BIN}) FIND_PACKAGE(Win32Libs REQUIRED) - FIND_LIBRARY(WINMM_LIBRARY NAMES winmm) endif (WIN32) if (WIN32) @@ -294,13 +305,15 @@ INCLUDE(TestCXXFlags) ## 32bit or 64bit? +set(MARCH_FLAG ${MARCH} CACHE STRING "CPU optimization (use i686 for generic optimization)") if (CMAKE_SIZEOF_VOID_P EQUAL 8) - message (STATUS "Building Spring for 64bit environment") - set(MARCH_FLAG ${MARCH} CACHE STRING "CPU optimization (use i686 for generic optimization)") + Message(STATUS "Building Spring for 64bit environment") set(MARCH_BITS 64 INTERNAL) + if (MINGW) + Message(FATAL_ERROR "Spring's MinGWLibs don't include 64bit libraries (yet). Please, compile as 32bit.") + endif (MINGW) else (CMAKE_SIZEOF_VOID_P EQUAL 8) - message (STATUS "Building Spring for 32bit environment") - set(MARCH_FLAG ${MARCH} CACHE STRING "CPU optimization (use i686 for generic optimization)") + Message(STATUS "Building Spring for 32bit environment") set(MARCH_BITS 32 INTERNAL) endif (CMAKE_SIZEOF_VOID_P EQUAL 8) @@ -376,16 +389,14 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -axK") # SSE1 set(CXX_FLAGS_DEBUG_ADDITIONAL "-g -debug full") elseif (CMAKE_COMPILER_IS_GNUCXX) - if (NOT CUSTOM_CFLAGS) - if (MARCH_FLAG) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${MARCH_FLAG}") - Message(STATUS "using march=${MARCH_FLAG}") - else (MARCH_FLAG) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=generic") - Message(STATUS "using mtune=generic (unsure if it will sync in online gaming)") - endif (MARCH_FLAG) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SSE_FLAGS}") # SSE1 - endif (NOT CUSTOM_CFLAGS) + if (MARCH_FLAG) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${MARCH_FLAG}") + Message(STATUS "using march=${MARCH_FLAG}") + else (MARCH_FLAG) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=generic") + Message(STATUS "using mtune=generic (unsure if it will sync in online gaming)") + endif (MARCH_FLAG) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SSE_FLAGS}") # SSE1 elseif (MSVC) # nothing to be done here else (MSVC) diff -Nru spring-96.0~14.04~ppa4/cont/base/springcontent/gamedata/weapondefs_post.lua spring-98.0~14.04~ppa6/cont/base/springcontent/gamedata/weapondefs_post.lua --- spring-96.0~14.04~ppa4/cont/base/springcontent/gamedata/weapondefs_post.lua 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/cont/base/springcontent/gamedata/weapondefs_post.lua 2014-10-07 20:09:51.000000000 +0000 @@ -150,6 +150,10 @@ end end + if (not wd.craterareaofeffect) then + wd.craterareaofeffect = tonumber(wd.areaofeffect or 0) * 1.5 + end + if (tobool(wd.ballistic) or tobool(wd.dropped)) then wd.gravityaffected = true end diff -Nru spring-96.0~14.04~ppa4/cont/base/springcontent/LuaGadgets/actions.lua spring-98.0~14.04~ppa6/cont/base/springcontent/LuaGadgets/actions.lua --- spring-96.0~14.04~ppa4/cont/base/springcontent/LuaGadgets/actions.lua 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/cont/base/springcontent/LuaGadgets/actions.lua 2014-10-07 20:09:51.000000000 +0000 @@ -1,3 +1,4 @@ +-- $Id: actions.lua 2491 2008-07-17 13:36:51Z det $ -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- -- @@ -30,7 +31,7 @@ local function MakeWords(line) local words = {} - for w in string.gmatch(line, "[^%s]+") do + for w in line:gmatch("[^%s]+") do table.insert(words, w) end return words @@ -47,7 +48,7 @@ local layer = gadget.ghInfo.layer local index = 1 for i,ci in ipairs(callInfoList) do - local g = ci[1] + local g = ci[2] if (g == gadget) then return false -- already in the table end @@ -79,7 +80,7 @@ local function RemoveCallInfo(callInfoList, gadget) local count = 0 for i,callInfo in ipairs(callInfoList) do - local g = callInfo[1] + local g = callInfo[2] if (g == gadget) then table.remove(callInfoList, i) count = count + 1 @@ -151,7 +152,7 @@ -------------------------------------------------------------------------------- local function EchoLines(msg) - for line in string.gmatch(msg, '([^\n]+)\n?') do + for line in msg:gmatch('([^\n]+)\n?') do Spring.Echo(line) end end @@ -215,7 +216,7 @@ -- remove the command from the words list and the raw line table.remove(words, 1) - local _,_,msg = string.find(msg, "[%s]*[^%s]+[%s]+(.*)") + local _,_,msg = msg:find("[%s]*[^%s]+[%s]+(.*)") if (msg == nil) then msg = "" -- no args end @@ -232,8 +233,7 @@ end -local function RecvFromSynced(...) - local arg1, arg2 = ... +local function RecvFromSynced(arg1,arg2,...) if (type(arg1) == 'string') then -- a raw sync msg local callInfoList = syncActions[arg1] @@ -244,21 +244,13 @@ for i,callInfo in ipairs(callInfoList) do local func = callInfo[1] -- local gadget = callInfo[2] - if (func(...)) then + if (func(arg1,arg2,...)) then return true end end return false end - if (type(arg1) == 'number') then - -- a proxied chat msg - if (type(arg2) == 'string') then - return GotChatMsg(arg2, arg1) - end - return false - end - return false -- unknown type end diff -Nru spring-96.0~14.04~ppa4/cont/base/springcontent/LuaGadgets/callins.lua spring-98.0~14.04~ppa6/cont/base/springcontent/LuaGadgets/callins.lua --- spring-96.0~14.04~ppa4/cont/base/springcontent/LuaGadgets/callins.lua 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/cont/base/springcontent/LuaGadgets/callins.lua 2014-10-07 20:09:51.000000000 +0000 @@ -99,6 +99,7 @@ "AllowResourceLevel", "AllowResourceTransfer", "AllowDirectUnitControl", + "AllowBuilderHoldFire", "AllowWeaponTargetCheck", "AllowWeaponTarget", "AllowWeaponInterceptTarget", diff -Nru spring-96.0~14.04~ppa4/cont/base/springcontent/LuaGadgets/gadgets.lua spring-98.0~14.04~ppa6/cont/base/springcontent/LuaGadgets/gadgets.lua --- spring-96.0~14.04~ppa4/cont/base/springcontent/LuaGadgets/gadgets.lua 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/cont/base/springcontent/LuaGadgets/gadgets.lua 2014-10-07 20:09:51.000000000 +0000 @@ -886,10 +886,6 @@ end end - if (IsSyncedCode()) then - SendToUnsynced(player, msg) - end - return false end @@ -1157,6 +1153,16 @@ return false end end + return true +end + + +function gadgetHandler:AllowBuilderHoldFire(unitID, unitDefID, action) + for _,g in ipairs(self.AllowBuilderHoldFire) do + if (not AllowBuilderHoldFire(unitID, unitDefID, action)) then + return false + end + end return true end diff -Nru spring-96.0~14.04~ppa4/cont/base/springcontent/shaders/GLSL/GrassFragProg.glsl spring-98.0~14.04~ppa6/cont/base/springcontent/shaders/GLSL/GrassFragProg.glsl --- spring-96.0~14.04~ppa4/cont/base/springcontent/shaders/GLSL/GrassFragProg.glsl 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/cont/base/springcontent/shaders/GLSL/GrassFragProg.glsl 2014-10-07 20:09:51.000000000 +0000 @@ -1,43 +1,64 @@ +//#define FLAT_SHADING uniform sampler2D shadingTex; uniform sampler2D grassShadingTex; uniform sampler2D bladeTex; -#ifdef HAVE_SHADOW +#ifdef HAVE_SHADOWS uniform sampler2DShadow shadowMap; +uniform float groundShadowDensity; #endif #ifdef HAVE_INFOTEX uniform sampler2D infoMap; #endif +uniform samplerCube specularTex; +uniform vec3 specularLightColor; +uniform vec3 ambientLightColor; +uniform vec3 camDir; + +varying vec3 normal; +varying vec4 shadingTexCoords; +varying vec2 bladeTexCoords; +varying vec3 ambientDiffuseLightTerm; +#if defined(HAVE_SHADOWS) || defined(SHADOW_GEN) + varying vec4 shadowTexCoords; +#endif + + void main() { - #ifdef SHADOW_GEN +#ifdef SHADOW_GEN { - #ifdef DISTANCE_FAR - gl_FragColor = texture2D(bladeTex, gl_TexCoord[3].st); - #else - gl_FragColor = vec4(1.0); - #endif + #ifdef DISTANCE_FAR + gl_FragColor = texture2D(bladeTex, bladeTexCoords); + #else + gl_FragColor = vec4(1.0); + #endif return; } - #endif +#endif - //FIXME add diffuse lighting -> needs normal that is unavailable atm + vec4 matColor = texture2D(bladeTex, bladeTexCoords); + matColor.rgb *= texture2D(grassShadingTex, shadingTexCoords.pq).rgb; + matColor.rgb *= texture2D(shadingTex, shadingTexCoords.st).rgb * 2.0; + +#if defined(FLAT_SHADING) || defined(DISTANCE_FAR) + vec3 specular = vec3(0.0); +#else + vec3 reflectDir = reflect(camDir, normalize(normal)); + vec3 specular = textureCube(specularTex, reflectDir).rgb; +#endif + gl_FragColor.rgb = matColor.rgb * ambientDiffuseLightTerm + 0.1 * specular * specularLightColor; //TODO make `0.1` specular distr. customizable? + gl_FragColor.a = matColor.a * gl_Color.a; - gl_FragColor.a = 1.0; - gl_FragColor.rgb = texture2D(shadingTex, gl_TexCoord[0].st).rgb * 2.0; - gl_FragColor.rgb *= texture2D(grassShadingTex, gl_TexCoord[2].st).rgb; - gl_FragColor *= texture2D(bladeTex, gl_TexCoord[3].st) * gl_Color; - -#ifdef HAVE_SHADOW - float shadowCoeff = shadow2DProj(shadowMap, gl_TexCoord[1]).a; - gl_FragColor.rgb *= mix(gl_TextureEnvColor[1].rgb, vec3(1.0), shadowCoeff); +#ifdef HAVE_SHADOWS + float shadowCoeff = clamp(shadow2DProj(shadowMap, shadowTexCoords).a + groundShadowDensity, 0., 1.); + gl_FragColor.rgb *= mix(ambientLightColor, vec3(1.0), shadowCoeff); #endif #ifdef HAVE_INFOTEX - gl_FragColor.rgb += texture2D(infoMap, gl_TexCoord[0].st).rgb; - gl_FragColor.rgb -= vec3(0.5, 0.5, 0.5); + gl_FragColor.rgb += texture2D(infoMap, shadingTexCoords.st).rgb - 0.5; #endif gl_FragColor.rgb = mix(gl_Fog.color.rgb, gl_FragColor.rgb, gl_FogFragCoord); diff -Nru spring-96.0~14.04~ppa4/cont/base/springcontent/shaders/GLSL/GrassVertProg.glsl spring-98.0~14.04~ppa6/cont/base/springcontent/shaders/GLSL/GrassVertProg.glsl --- spring-96.0~14.04~ppa4/cont/base/springcontent/shaders/GLSL/GrassVertProg.glsl 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/cont/base/springcontent/shaders/GLSL/GrassVertProg.glsl 2014-10-07 20:09:51.000000000 +0000 @@ -5,85 +5,154 @@ uniform vec4 shadowParams; uniform vec3 camPos; +uniform vec3 camUp; +uniform vec3 camRight; -uniform float simFrame; +uniform float frame; uniform vec3 windSpeed; +uniform vec3 sunDir; +uniform vec3 ambientLightColor; +uniform vec3 diffuseLightColor; + +varying vec3 normal; +varying vec4 shadingTexCoords; +varying vec2 bladeTexCoords; +varying vec3 ambientDiffuseLightTerm; +#if defined(HAVE_SHADOWS) || defined(SHADOW_GEN) + varying vec4 shadowTexCoords; +#endif + + const float PI = 3.14159265358979323846264; + +////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// +// Crytek - foliage animation +// src: http://http.developer.nvidia.com/GPUGems3/gpugems3_ch16.html +// + +// This bends the entire plant in the direction of the wind. +// vPos: The world position of the plant *relative* to the base of the plant. +vec3 ApplyMainBending(in vec3 vPos, in vec2 vWind, in float fBendScale) +{ + float fLength = length(vPos); + float fBF = vPos.y * fBendScale + 1.0; + fBF *= fBF; + fBF = fBF * fBF - fBF; + vPos.xz += vWind.xy * fBF; + return normalize(vPos) * fLength; +} + +vec2 SmoothCurve( vec2 x ) { + return x * x * (3.0 - 2.0 * x); +} +vec2 TriangleWave( vec2 x ) { + return abs( fract( x + 0.5 ) * 1.99 - 1.0 ); +} +vec2 SmoothTriangleWave( vec2 x ) { + // similar to sine wave, but faster + return SmoothCurve( TriangleWave( x ) ); +} + +const vec2 V_FREQ = vec2(1.975, 0.793); + +// This provides "chaotic" motion for leaves and branches (the entire plant, really) +void ApplyDetailBending(inout vec3 vPos, vec3 vNormal, float fDetailPhase, float fTime, float fSpeed, float fDetailAmp) +{ + float vWavesIn = fTime + fDetailPhase; + vec2 vWaves = (fract( vec2(vWavesIn) * V_FREQ ) * 2.0 - 1.0 ) * fSpeed; + vWaves = SmoothTriangleWave( vWaves ); + vPos.xyz += vNormal.xyz * vWaves.xxy * fDetailAmp; +} + + +////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// + + void main() { - vec2 texOffset = vec2(0.,0.); + vec2 texOffset = vec2(0.); + gl_FrontColor = gl_Color; - #ifdef DISTANCE_NEAR - #ifdef SHADOW_GEN - vec4 vertexPos = gl_Vertex; - #else - vec4 vertexPos = gl_ModelViewMatrix * gl_Vertex; - #endif - #ifdef ANIMATION - vec2 windScale; - windScale.x = sin((simFrame + gl_MultiTexCoord0.s) * 5.0 / (10.0 + floor(gl_MultiTexCoord0.s))) * 0.01; - windScale.y = (1.0 + sin((vertexPos.x + vertexPos.z) / 45.0 + simFrame / 15.0)) * 0.025; - windScale *= gl_MultiTexCoord0.tt; - - vertexPos.x += dot(windSpeed.zx, windScale); - vertexPos.z += dot(windSpeed.xz, windScale); - #endif - - vec4 worldPos = vertexPos; - #endif - - #ifdef DISTANCE_FAR - vec4 worldPos = gl_Vertex; - vec3 billboardDirZ = normalize(gl_Vertex.xyz - camPos.xyz); - vec3 billboardDirX = normalize(cross(billboardDirZ, vec3(0.,1.,0.))); - vec3 billboardDirY = cross(billboardDirX, billboardDirZ); - float ang = acos(billboardDirZ.y); - texOffset.x = clamp(floor((ang + PI / 16.0 - PI / 2.0) / PI * 30.0), 0.0, 15.0) / 16.0; - - #ifdef ANIMATION - float windScale = - 0.005 * (1.0 + sin((worldPos.x + worldPos.z) / 45.0 + simFrame / 15.0)) * - gl_Normal.y * (1.0 - texOffset.x); - - worldPos.xz += (windSpeed.xz * windScale); - #endif - - worldPos.xyz += billboardDirX * gl_Normal.x * (1.0 + windScale); - worldPos.xyz += billboardDirY * gl_Normal.y * (1.0 + windScale); - worldPos.xyz += billboardDirZ; - - vec4 vertexPos = gl_ModelViewMatrix * worldPos; - #endif - - #if defined(HAVE_SHADOW) || defined(SHADOW_GEN) - vec2 p17 = vec2(shadowParams.z, shadowParams.z); - vec2 p18 = vec2(shadowParams.w, shadowParams.w); - #ifdef SHADOW_GEN - vec4 vertexShadowPos = gl_ModelViewMatrix * worldPos; - #else - vec4 vertexShadowPos = shadowMatrix * worldPos; - #endif - vertexShadowPos.st *= (inversesqrt(abs(vertexShadowPos.st) + p17) + p18); - vertexShadowPos.st += shadowParams.xy; +#ifndef DISTANCE_FAR + // mesh grass + normal = gl_NormalMatrix * gl_Normal; + vec4 worldPos = gl_ModelViewMatrix * gl_Vertex; + + // anim + vec3 objPos = mat3(gl_ModelViewMatrix) * gl_Vertex.xyz; + worldPos.xyz += ApplyMainBending(objPos, windSpeed.xz, gl_MultiTexCoord0.s * 0.004 + 0.007) - objPos; + ApplyDetailBending(worldPos.xyz, normal, + gl_MultiTexCoord0.s, + frame / 30.0, + 0.3, + gl_MultiTexCoord0.t * 0.4); + + // compute ambient & diffuse lighting per-vertex, specular is per-pixel + float fNdotL = dot(normal, sunDir); + float diffuseTerm = fNdotL * 0.4 + 0.6; // front surface //TODO make constants customizable? + diffuseTerm = max(diffuseTerm, ((-fNdotL) * 0.3 + 0.7) * 0.8); // back surface //TODO make constants customizable? + ambientDiffuseLightTerm = ambientLightColor + diffuseTerm * diffuseLightColor; +#else + // billboards + gl_FrontColor.a *= gl_Normal.z; // alpha blend far turfs + vec4 worldPos = /* gl_ModelViewMatrix * */ gl_Vertex; // MVM is empty in far draw pass + + // get the camera angle on the billboard and select the corresponding sprite + float cosCamAngle = normalize(camPos.xyz - worldPos.xyz).y; + float ang = acos(-cosCamAngle); + texOffset.s = clamp(floor((ang + PI / 16.0 - PI / 2.0) / PI * 30.0), 0.0, 15.0) / 16.0; + + // billboard size + vec2 billboardSize = gl_Normal.xy; + + // cut of lower half in horizontal views (the fartexture is empty in lower 50% in horizontal view!) + billboardSize.y = max(billboardSize.y, billboardSize.y * cosCamAngle); + + // span the billboard + worldPos.xyz += camRight * billboardSize.x; + worldPos.xyz += camUp * billboardSize.y; + + // adjust texcoord for cut of billboard + texOffset.t = max((0.5 * cosCamAngle - 0.5), -gl_MultiTexCoord0.t); + + // anim + float seed = fract(abs(dot(gl_Vertex.xyz, vec3(1.0)))); + vec3 objPos = (worldPos.xyz - gl_Vertex.xyz); + worldPos.xyz += ApplyMainBending(objPos, windSpeed.xz, seed * 0.006 + 0.01) - objPos; + ApplyDetailBending(worldPos.xyz, vec3(1., 0., 1.), + seed, + frame / 30.0, + 0.3, + 0.5 * max(1.0 - gl_MultiTexCoord0.t, cosCamAngle)); + + // move up when looking down (to fix clipping issues) + worldPos.y += 5.0 * cosCamAngle; + + // compute ambient & diffuse lighting per-vertex + ambientDiffuseLightTerm = ambientLightColor + diffuseLightColor; +#endif - gl_TexCoord[1] = vertexShadowPos; - #endif +#if defined(HAVE_SHADOWS) || defined(SHADOW_GEN) + vec4 vertexShadowPos = shadowMatrix * worldPos; + vertexShadowPos.st += shadowParams.xy; + shadowTexCoords = vertexShadowPos; +#endif - #ifdef SHADOW_GEN +#ifdef SHADOW_GEN { - gl_TexCoord[3].st = gl_MultiTexCoord0.st + texOffset; + bladeTexCoords = gl_MultiTexCoord0.st + texOffset; gl_Position = gl_ProjectionMatrix * vertexShadowPos; return; } - #endif +#endif - gl_TexCoord[0].st = worldPos.xz * mapSizePO2; - gl_TexCoord[2].st = worldPos.xz * mapSize; - gl_TexCoord[3].st = gl_MultiTexCoord0.st + texOffset; + shadingTexCoords = worldPos.xzxz * vec4(mapSizePO2, mapSize); + bladeTexCoords = gl_MultiTexCoord0.st + texOffset; - gl_FrontColor = gl_Color; - gl_Position = gl_ProjectionMatrix * vertexPos; + gl_Position = gl_ProjectionMatrix * worldPos; gl_FogFragCoord = distance(camPos, worldPos.xyz); gl_FogFragCoord = (gl_Fog.end - gl_FogFragCoord) * gl_Fog.scale; diff -Nru spring-96.0~14.04~ppa4/cont/base/springcontent/shaders/GLSL/SMFFragProg.glsl spring-98.0~14.04~ppa6/cont/base/springcontent/shaders/GLSL/SMFFragProg.glsl --- spring-96.0~14.04~ppa4/cont/base/springcontent/shaders/GLSL/SMFFragProg.glsl 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/cont/base/springcontent/shaders/GLSL/SMFFragProg.glsl 2014-10-07 20:09:51.000000000 +0000 @@ -1,77 +1,101 @@ -#define SSMF_UNCOMPRESSED_NORMALS 0 -#define SMF_SHALLOW_WATER_DEPTH (10.0 ) -#define SMF_SHALLOW_WATER_DEPTH_INV ( 1.0 / SMF_SHALLOW_WATER_DEPTH) -#define SMF_DETAILTEX_RES 0.02 +#version 120 + +#ifdef NOSPRING + #define SMF_INTENSITY_MULT (210.0 / 255.0) + #define SMF_TEXSQUARE_SIZE 1024.0 + #define MAX_DYNAMIC_MAP_LIGHTS 4 + #define BASE_DYNAMIC_MAP_LIGHT 0 + #define GBUFFER_NORMTEX_IDX 0 + #define GBUFFER_DIFFTEX_IDX 1 + #define GBUFFER_SPECTEX_IDX 2 + #define GBUFFER_EMITTEX_IDX 3 + #define GBUFFER_MISCTEX_IDX 4 +#endif + + +/***********************************************************************/ +// Consts + +const float SMF_SHALLOW_WATER_DEPTH = 10.0; +const float SMF_SHALLOW_WATER_DEPTH_INV = 1.0 / SMF_SHALLOW_WATER_DEPTH; +const float SMF_DETAILTEX_RES = 0.02; + + +/***********************************************************************/ +// Uniforms + Varyings uniform sampler2D diffuseTex; uniform sampler2D normalsTex; uniform sampler2D detailTex; -uniform sampler2D infoTex; uniform vec2 normalTexGen; // either 1.0/mapSize (when NPOT are supported) or 1.0/mapSizePO2 uniform vec2 specularTexGen; // 1.0/mapSize -#if (SMF_ARB_LIGHTING == 0) - uniform sampler2D specularTex; -#endif - -#if (HAVE_SHADOWS == 1) -uniform sampler2DShadow shadowTex; -uniform mat4 shadowMat; -uniform vec4 shadowParams; -#endif - uniform vec3 groundAmbientColor; uniform vec3 groundDiffuseColor; uniform vec3 groundSpecularColor; uniform float groundShadowDensity; -#if (SMF_WATER_ABSORPTION == 1) +uniform vec2 mapHeights; // min & max height on the map + +uniform vec4 lightDir; +uniform vec3 cameraPos; + +varying vec3 halfDir; +varying float fogFactor; +varying vec4 vertexWorldPos; +varying vec2 diffuseTexCoords; + +#ifdef HAVE_INFOTEX + uniform sampler2D infoTex; + uniform float infoTexIntensityMul; + uniform vec2 infoTexGen; // 1.0/(pwr2map{x,z} * SQUARE_SIZE) +#endif + +#ifndef SMF_ARB_LIGHTING + uniform sampler2D specularTex; +#endif + +#ifdef HAVE_SHADOWS + uniform sampler2DShadow shadowTex; + uniform mat4 shadowMat; + uniform vec4 shadowParams; +#endif + +#ifdef SMF_WATER_ABSORPTION uniform vec3 waterMinColor; uniform vec3 waterBaseColor; uniform vec3 waterAbsorbColor; #endif -#if (SMF_DETAIL_TEXTURE_SPLATTING == 1) +#ifdef SMF_DETAIL_TEXTURE_SPLATTING uniform sampler2D splatDetailTex; uniform sampler2D splatDistrTex; uniform vec4 splatTexMults; // per-channel splat intensity multipliers uniform vec4 splatTexScales; // defaults to SMF_DETAILTEX_RES per channel #endif - -#if (SMF_SKY_REFLECTIONS == 1) +#ifdef SMF_SKY_REFLECTIONS uniform samplerCube skyReflectTex; uniform sampler2D skyReflectModTex; #endif -#if (SMF_DETAIL_NORMALS == 1) +#ifdef SMF_DETAIL_NORMALS uniform sampler2D detailNormalTex; #endif -#if (SMF_LIGHT_EMISSION == 1) +#ifdef SMF_LIGHT_EMISSION uniform sampler2D lightEmissionTex; #endif -#if (SMF_PARALLAX_MAPPING == 1) +#ifdef SMF_PARALLAX_MAPPING uniform sampler2D parallaxHeightTex; #endif -#if (HAVE_INFOTEX == 1) -uniform float infoTexIntensityMul; -uniform vec2 infoTexGen; // 1.0/(pwr2map{x,z} * SQUARE_SIZE) -#endif - -uniform vec4 lightDir; -uniform vec3 cameraPos; -varying vec3 halfDir; - -varying float fogFactor; -varying vec4 vertexWorldPos; -varying vec2 diffuseTexCoords; - +/***********************************************************************/ +// Helper functions -#if (SMF_PARALLAX_MAPPING == 1) +#ifdef SMF_PARALLAX_MAPPING vec2 GetParallaxUVOffset(vec2 uv, vec3 dir) { vec4 texel = texture2D(parallaxHeightTex, uv); @@ -79,11 +103,11 @@ // B: scale in [ 0.0, 1.0] (256 strata), eg. 0.04 (~10.0/256.0) // A: bias in [-0.5, 0.5] (256 strata), eg. -0.02 (~75.0/256.0) // - #define RMUL 65280.0 // 255 * 256 - #define GMUL 256.0 - #define HDIV 65536.0 + const float RMUL = 255.0 * 256.0; + const float GMUL = 256.0; + const float HDIV = 65536.0; - float heightValue = (texel.r * RMUL + texel.g * GMUL) / HDIV; + float heightValue = dot(texel.rg, vec2(RMUL, GMUL)) / HDIV; float heightScale = texel.b; float heightBias = texel.a - 0.5; float heightOffset = heightValue * heightScale + heightBias; @@ -94,94 +118,132 @@ vec3 GetFragmentNormal(vec2 uv) { vec3 normal; - - #if (SSMF_UNCOMPRESSED_NORMALS == 1) - normal = normalize(texture2D(normalsTex, uv).xyz); - #else - normal.xz = texture2D(normalsTex, uv).ra; - normal.y = sqrt(1.0 - dot(normal.xz, normal.xz)); - #endif - +#ifdef SSMF_UNCOMPRESSED_NORMALS + normal = normalize(texture2D(normalsTex, uv).xyz); +#else + normal.xz = texture2D(normalsTex, uv).ra; + normal.y = sqrt(1.0 - dot(normal.xz, normal.xz)); +#endif return normal; } vec4 GetDetailTextureColor(vec2 uv) { - #if (SMF_DETAIL_TEXTURE_SPLATTING == 0) - vec2 detailTexCoord = vertexWorldPos.xz * vec2(SMF_DETAILTEX_RES); - vec4 detailCol = (texture2D(detailTex, detailTexCoord) * 2.0) - 1.0; - #else - vec4 splatTexCoord0 = vertexWorldPos.xzxz * splatTexScales.rrgg; - vec4 splatTexCoord1 = vertexWorldPos.xzxz * splatTexScales.bbaa; - vec4 splatDetails; - splatDetails.r = texture2D(splatDetailTex, splatTexCoord0.st).r; - splatDetails.g = texture2D(splatDetailTex, splatTexCoord0.pq).g; - splatDetails.b = texture2D(splatDetailTex, splatTexCoord1.st).b; - splatDetails.a = texture2D(splatDetailTex, splatTexCoord1.pq).a; - splatDetails = (splatDetails * 2.0) - 1.0; +#ifndef SMF_DETAIL_TEXTURE_SPLATTING + vec2 detailTexCoord = vertexWorldPos.xz * vec2(SMF_DETAILTEX_RES); + vec4 detailCol = (texture2D(detailTex, detailTexCoord) * 2.0) - 1.0; +#else + vec4 splatTexCoord0 = vertexWorldPos.xzxz * splatTexScales.rrgg; + vec4 splatTexCoord1 = vertexWorldPos.xzxz * splatTexScales.bbaa; + vec4 splatDetails; + splatDetails.r = texture2D(splatDetailTex, splatTexCoord0.st).r; + splatDetails.g = texture2D(splatDetailTex, splatTexCoord0.pq).g; + splatDetails.b = texture2D(splatDetailTex, splatTexCoord1.st).b; + splatDetails.a = texture2D(splatDetailTex, splatTexCoord1.pq).a; + splatDetails = (splatDetails * 2.0) - 1.0; - vec4 splatCofac = texture2D(splatDistrTex, uv) * splatTexMults; - vec4 detailCol = vec4(dot(splatDetails, splatCofac)); - #endif + vec4 splatCofac = texture2D(splatDistrTex, uv) * splatTexMults; + vec4 detailCol = vec4(dot(splatDetails, splatCofac)); +#endif return detailCol; } vec4 GetShadeInt(float groundLightInt, float groundShadowCoeff, float groundDiffuseAlpha) { vec4 groundShadeInt = vec4(0.0, 0.0, 0.0, 1.0); - vec4 waterShadeInt = vec4(0.0, 0.0, 0.0, 1.0); groundShadeInt.rgb = groundAmbientColor + groundDiffuseColor * (groundLightInt * groundShadowCoeff); - groundShadeInt.rgb *= SMF_INTENSITY_MULT; + groundShadeInt.rgb *= vec3(SMF_INTENSITY_MULT); - #if (SMF_VOID_WATER == 1) +#ifdef SMF_VOID_WATER // cut out all underwater fragments indiscriminately groundShadeInt.a = float(vertexWorldPos.y >= 0.0); - #endif +#endif - #if (SMF_VOID_GROUND == 1) +#ifdef SMF_VOID_GROUND // assume the map(per)'s diffuse texture provides sensible alphas // note that voidground overrides voidwater if *both* are enabled // (limiting it to just above-water fragments would be arbitrary) groundShadeInt.a = groundDiffuseAlpha; - #endif +#endif - #if (SMF_WATER_ABSORPTION == 1) - { +#ifdef SMF_WATER_ABSORPTION + // use alpha of groundShadeInt cause: + // allow voidground maps to create holes in the seabed + // (SMF_WATER_ABSORPTION == 1 implies voidwater is not + // enabled but says nothing about the voidground state) + vec4 waterShadeInt = vec4(waterBaseColor.rgb, groundShadeInt.a); + if (mapHeights.x <= 0.0) { float waterShadeAlpha = abs(vertexWorldPos.y) * SMF_SHALLOW_WATER_DEPTH_INV; float waterShadeDecay = 0.2 + (waterShadeAlpha * 0.1); - float vertexStepHeight = min(1023.0, -floor(vertexWorldPos.y)); - float waterLightInt = min((groundLightInt + 0.2) * 2.0, 1.0); + float vertexStepHeight = min(1023.0, -vertexWorldPos.y); + float waterLightInt = min(groundLightInt * 2.0 + 0.4, 1.0); // vertex below shallow water depth --> alpha=1 // vertex above shallow water depth --> alpha=waterShadeAlpha - // waterShadeAlpha = min(1.0, waterShadeAlpha + float(vertexWorldPos.y <= -SMF_SHALLOW_WATER_DEPTH)); - waterShadeInt.rgb = waterBaseColor.rgb - (waterAbsorbColor.rgb * vertexStepHeight); - waterShadeInt.rgb = max(waterMinColor.rgb, waterShadeInt.rgb); - waterShadeInt.rgb *= (SMF_INTENSITY_MULT * waterLightInt); - - // allow voidground maps to create holes in the seabed - // (SMF_WATER_ABSORPTION == 1 implies voidwater is not - // enabled but says nothing about the voidground state) - waterShadeInt.a = groundShadeInt.a; + waterShadeInt.rgb -= (waterAbsorbColor.rgb * vertexStepHeight); + waterShadeInt.rgb = max(waterMinColor.rgb, waterShadeInt.rgb); + waterShadeInt.rgb *= vec3(SMF_INTENSITY_MULT * waterLightInt); // make shadowed areas darker over deeper water - waterShadeInt.rgb -= (waterShadeInt.rgb * waterShadeDecay * (1.0 - groundShadowCoeff)); + waterShadeInt.rgb *= (1.0 - waterShadeDecay * (1.0 - groundShadowCoeff)); // if depth is greater than _SHALLOW_ depth, select waterShadeInt // otherwise interpolate between groundShadeInt and waterShadeInt // (both are already cosine-weighted) waterShadeInt.rgb = mix(groundShadeInt.rgb, waterShadeInt.rgb, waterShadeAlpha); } - return mix(groundShadeInt, waterShadeInt, float(vertexWorldPos.y < 0.0)); - #else +#else return groundShadeInt; - #endif +#endif } +vec3 DynamicLighting(vec3 normal, vec3 diffuseCol, vec3 specularCol, float specularExp) { + vec3 light = vec3(0.0); +#if !defined(DEFERRED_MODE) && (MAX_DYNAMIC_MAP_LIGHTS > 0) + for (int i = 0; i < MAX_DYNAMIC_MAP_LIGHTS; i++) { + vec3 lightVec = gl_LightSource[BASE_DYNAMIC_MAP_LIGHT + i].position.xyz - vertexWorldPos.xyz; + vec3 halfVec = gl_LightSource[BASE_DYNAMIC_MAP_LIGHT + i].halfVector.xyz; + + float lightRadius = gl_LightSource[BASE_DYNAMIC_MAP_LIGHT + i].constantAttenuation; + float lightDistance = length(lightVec); + float lightScale = float(lightDistance <= lightRadius); + float lightCosAngDiff = clamp(dot(normal, lightVec / lightDistance), 0.0, 1.0); + float lightCosAngSpec = clamp(dot(normal, normalize(halfVec)), 0.0, 1.0); + #ifdef OGL_SPEC_ATTENUATION + float lightAttenuation = + (gl_LightSource[BASE_DYNAMIC_MAP_LIGHT + i].constantAttenuation) + + (gl_LightSource[BASE_DYNAMIC_MAP_LIGHT + i].linearAttenuation * lightDistance) + + (gl_LightSource[BASE_DYNAMIC_MAP_LIGHT + i].quadraticAttenuation * lightDistance * lightDistance); + + lightAttenuation = 1.0 / max(lightAttenuation, 1.0); + #else + float lightAttenuation = 1.0 - min(1.0, ((lightDistance * lightDistance) / (lightRadius * lightRadius))); + #endif + + float vectorDot = -dot((lightVec / lightDistance), gl_LightSource[BASE_DYNAMIC_MAP_LIGHT + i].spotDirection); + float cutoffDot = gl_LightSource[BASE_DYNAMIC_MAP_LIGHT + i].spotCosCutoff; + + float lightSpecularPow = 0.0; + #ifndef SMF_ARB_LIGHTING + lightSpecularPow = max(0.0, pow(lightCosAngSpec, specularExp)); + #endif + + lightScale *= float(vectorDot >= cutoffDot); + + light += (lightScale * gl_LightSource[BASE_DYNAMIC_MAP_LIGHT + i].ambient.rgb); + light += (lightScale * lightAttenuation * (diffuseCol.rgb * gl_LightSource[BASE_DYNAMIC_MAP_LIGHT + i].diffuse.rgb * lightCosAngDiff)); + light += (lightScale * lightAttenuation * (specularCol.rgb * gl_LightSource[BASE_DYNAMIC_MAP_LIGHT + i].specular.rgb * lightSpecularPow)); + } +#endif + return light; +} + +/***********************************************************************/ +// main() void main() { vec2 diffTexCoords = diffuseTexCoords; @@ -192,37 +254,34 @@ vec3 cameraDir = vertexWorldPos.xyz - cameraPos; vec3 normal = GetFragmentNormal(normTexCoords); - #if (SMF_DETAIL_NORMALS == 1 || SMF_PARALLAX_MAPPING == 1) + #if defined(SMF_DETAIL_NORMALS) || defined(SMF_PARALLAX_MAPPING) // detail-normals are (assumed to be) defined within STN space // (for a regular vertex normal equal to <0, 1, 0>, the S- and // T-tangents are aligned with Spring's +x and +z (!) axes) - vec3 tTangent = cross(normal, vec3(-1.0, 0.0, 0.0)); + vec3 tTangent = normalize(cross(normal, vec3(-1.0, 0.0, 0.0))); vec3 sTangent = cross(normal, tTangent); mat3 stnMatrix = mat3(sTangent, tTangent, normal); #endif - #if (SMF_PARALLAX_MAPPING == 1) + #ifdef SMF_PARALLAX_MAPPING { // use specular-texture coordinates to index parallaxHeightTex // (ie. specularTex and parallaxHeightTex must have equal size) // cameraDir does not need to be normalized, x/z and y/z ratios // do not change vec2 uvOffset = GetParallaxUVOffset(specTexCoords, transpose(stnMatrix) * cameraDir); - vec2 normTexSize = 1.0 / normalTexGen; - vec2 specTexSize = 1.0 / specularTexGen; // scale the parallax offset since it is in spectex-space - diffTexCoords += (uvOffset * (specTexSize / SMF_TEXSQUARE_SIZE)); - normTexCoords += (uvOffset * (specTexSize / normTexSize)); + diffTexCoords += (uvOffset / (SMF_TEXSQUARE_SIZE * specularTexGen)); + normTexCoords += (uvOffset * (normalTexGen / specularTexGen)); specTexCoords += (uvOffset); normal = GetFragmentNormal(normTexCoords); } #endif - - #if (SMF_DETAIL_NORMALS == 1) + #ifdef SMF_DETAIL_NORMALS { vec4 dtSample = texture2D(detailNormalTex, normTexCoords); vec3 dtNormal = (dtSample.xyz * 2.0) - 1.0; @@ -232,10 +291,10 @@ } #endif - #if (DEFERRED_MODE == 0) - float cosAngleDiffuse = clamp(dot(normalize(lightDir.xyz), normal), 0.0, 1.0); +#ifndef DEFERRED_MODE + float cosAngleDiffuse = clamp(dot(lightDir.xyz, normal), 0.0, 1.0); float cosAngleSpecular = clamp(dot(normalize(halfDir), normal), 0.0, 1.0); - #endif +#endif vec4 diffuseCol = texture2D(diffuseTex, diffTexCoords); vec4 detailCol = GetDetailTextureColor(specTexCoords); @@ -243,7 +302,7 @@ vec4 specularCol = vec4(0.5, 0.5, 0.5, 1.0); vec4 emissionCol = vec4(0.0, 0.0, 0.0, 0.0); - #if (DEFERRED_MODE == 0 && SMF_SKY_REFLECTIONS == 1) + #if !defined(DEFERRED_MODE) && defined(SMF_SKY_REFLECTIONS) { // cameraDir does not need to be normalized for reflect() vec3 reflectDir = reflect(cameraDir, normal); @@ -253,22 +312,24 @@ diffuseCol.rgb = mix(diffuseCol.rgb, reflectCol, reflectMod); } #endif - #if (DEFERRED_MODE == 0 && HAVE_INFOTEX == 1) + #if !defined(DEFERRED_MODE) && defined(HAVE_INFOTEX) + { // increase contrast and brightness for the overlays // TODO: make the multiplier configurable by users? vec2 infoTexCoords = vertexWorldPos.xz * infoTexGen; diffuseCol.rgb += (texture2D(infoTex, infoTexCoords).rgb * infoTexIntensityMul); diffuseCol.rgb -= (vec3(0.5, 0.5, 0.5) * float(infoTexIntensityMul == 1.0)); + } #endif float shadowCoeff = 1.0; - #if (DEFERRED_MODE == 0 && HAVE_SHADOWS == 1) + #if !defined(DEFERRED_MODE) && defined(HAVE_SHADOWS) { - vec2 p17 = vec2(shadowParams.z, shadowParams.z); - vec2 p18 = vec2(shadowParams.w, shadowParams.w); + vec2 p17 = shadowParams.zz; + vec2 p18 = shadowParams.ww; vec4 vertexShadowPos = shadowMat * vertexWorldPos; vertexShadowPos.st *= (inversesqrt(abs(vertexShadowPos.st) + p17) + p18); @@ -280,7 +341,7 @@ } #endif - #if (DEFERRED_MODE == 0) + #ifndef DEFERRED_MODE { // GroundMaterialAmbientDiffuseColor * LightAmbientDiffuseColor vec4 shadeInt = GetShadeInt(cosAngleDiffuse, shadowCoeff, diffuseCol.a); @@ -290,21 +351,21 @@ } #endif - #if (SMF_LIGHT_EMISSION == 1) + #ifdef SMF_LIGHT_EMISSION { // apply self-illumination aka. glow, not masked by shadows emissionCol = texture2D(lightEmissionTex, specTexCoords); - #if (DEFERRED_MODE == 0) + #ifndef DEFERRED_MODE gl_FragColor.rgb = gl_FragColor.rgb * (1.0 - emissionCol.a) + emissionCol.rgb; #endif } #endif - #if (SMF_ARB_LIGHTING == 0) - specularCol = texture2D(specularTex, specTexCoords); +#ifndef SMF_ARB_LIGHTING + specularCol = texture2D(specularTex, specTexCoords); - #if (DEFERRED_MODE == 0) + #ifndef DEFERRED_MODE // sun specular lighting contribution float specularExp = specularCol.a * 16.0; float specularPow = pow(cosAngleSpecular, specularExp); @@ -314,58 +375,24 @@ // no need to multiply by groundSpecularColor anymore gl_FragColor.rgb += specularInt; - #endif - #endif - - #if (DEFERRED_MODE == 0 && MAX_DYNAMIC_MAP_LIGHTS > 0) - for (int i = 0; i < MAX_DYNAMIC_MAP_LIGHTS; i++) { - vec3 lightVec = gl_LightSource[BASE_DYNAMIC_MAP_LIGHT + i].position.xyz - vertexWorldPos.xyz; - vec3 halfVec = gl_LightSource[BASE_DYNAMIC_MAP_LIGHT + i].halfVector.xyz; - - float lightRadius = gl_LightSource[BASE_DYNAMIC_MAP_LIGHT + i].constantAttenuation; - float lightDistance = length(lightVec); - float lightScale = float(lightDistance <= lightRadius); - float lightCosAngDiff = clamp(dot(normal, lightVec / lightDistance), 0.0, 1.0); - float lightCosAngSpec = clamp(dot(normal, normalize(halfVec)), 0.0, 1.0); - #ifdef OGL_SPEC_ATTENUATION - float lightAttenuation = - (gl_LightSource[BASE_DYNAMIC_MAP_LIGHT + i].constantAttenuation) + - (gl_LightSource[BASE_DYNAMIC_MAP_LIGHT + i].linearAttenuation * lightDistance) + - (gl_LightSource[BASE_DYNAMIC_MAP_LIGHT + i].quadraticAttenuation * lightDistance * lightDistance); - lightAttenuation = 1.0 / max(lightAttenuation, 1.0); - #else - float lightAttenuation = 1.0 - min(1.0, ((lightDistance * lightDistance) / (lightRadius * lightRadius))); - #endif - - float vectorDot = dot((-lightVec / lightDistance), gl_LightSource[BASE_DYNAMIC_MAP_LIGHT + i].spotDirection); - float cutoffDot = gl_LightSource[BASE_DYNAMIC_MAP_LIGHT + i].spotCosCutoff; - - #if (SMF_ARB_LIGHTING == 0) - float lightSpecularPow = max(0.0, pow(lightCosAngSpec, specularExp)); - #else - float lightSpecularPow = 0.0; + #if (MAX_DYNAMIC_MAP_LIGHTS > 0) + gl_FragColor.rgb += DynamicLighting(normal, diffuseCol.rgb, specularCol.rgb, specularExp); #endif - - lightScale *= float(vectorDot >= cutoffDot); - - gl_FragColor.rgb += (lightScale * gl_LightSource[BASE_DYNAMIC_MAP_LIGHT + i].ambient.rgb); - gl_FragColor.rgb += (lightScale * lightAttenuation * (diffuseCol.rgb * gl_LightSource[BASE_DYNAMIC_MAP_LIGHT + i].diffuse.rgb * lightCosAngDiff)); - gl_FragColor.rgb += (lightScale * lightAttenuation * (specularCol.rgb * gl_LightSource[BASE_DYNAMIC_MAP_LIGHT + i].specular.rgb * lightSpecularPow)); - } #endif +#endif - #if (DEFERRED_MODE == 1) +#ifdef DEFERRED_MODE gl_FragData[GBUFFER_NORMTEX_IDX] = vec4((normal + vec3(1.0, 1.0, 1.0)) * 0.5, 1.0); gl_FragData[GBUFFER_DIFFTEX_IDX] = diffuseCol + detailCol; gl_FragData[GBUFFER_SPECTEX_IDX] = specularCol; gl_FragData[GBUFFER_EMITTEX_IDX] = emissionCol; - gl_FragData[GBUFFER_MISCTEX_IDX] = vec4(0.0, 0.0, 0.0, 0.0); + gl_FragData[GBUFFER_MISCTEX_IDX] = vec4(0.0); // linearly transform the eye-space depths, might be more useful? // gl_FragDepth = gl_FragCoord.z / gl_FragCoord.w; - #else +#else gl_FragColor.rgb = mix(gl_Fog.color.rgb, gl_FragColor.rgb, fogFactor); - #endif +#endif } diff -Nru spring-96.0~14.04~ppa4/cont/base/springcontent/shaders/GLSL/SMFVertProg.glsl spring-98.0~14.04~ppa6/cont/base/springcontent/shaders/GLSL/SMFVertProg.glsl --- spring-96.0~14.04~ppa4/cont/base/springcontent/shaders/GLSL/SMFVertProg.glsl 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/cont/base/springcontent/shaders/GLSL/SMFVertProg.glsl 2014-10-07 20:09:51.000000000 +0000 @@ -1,10 +1,6 @@ #define SMF_TEXSQR_SIZE 1024.0 #define SMF_DETAILTEX_RES 0.02 -// uniform vec2 mapSizePO2; // pwr2map{x,z} * SQUARE_SIZE (TODO programmatically #define this) -// uniform vec2 mapSize; // map{x,z} * SQUARE_SIZE (TODO programmatically #define this) -// uniform vec2 mapHeights; // readmap->curr{Min, Max}Height - uniform ivec2 texSquare; uniform vec3 cameraPos; uniform vec4 lightDir; // mapInfo->light.sunDir @@ -26,19 +22,14 @@ diffuseTexCoords = (floor(gl_Vertex.xz) / SMF_TEXSQR_SIZE) - vec2(texSquare); // transform vertex pos - gl_Position = gl_ModelViewMatrix * gl_Vertex; - gl_ClipVertex = gl_Position; - - #if (DEFERRED_MODE == 0) - float fogCoord = length(gl_Position.xyz); - #endif - - gl_Position = gl_ProjectionMatrix * gl_Position; + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex; - #if (DEFERRED_MODE == 0) +#ifndef DEFERRED_MODE // emulate linear fog + float fogCoord = length(gl_ClipVertex.xyz); fogFactor = (gl_Fog.end - fogCoord) * gl_Fog.scale; // gl_Fog.scale == 1.0 / (gl_Fog.end - gl_Fog.start) fogFactor = clamp(fogFactor, 0.0, 1.0); - #endif +#endif } diff -Nru spring-96.0~14.04~ppa4/cont/base/springcontent/shaders/GLSL/TreeFragProg.glsl spring-98.0~14.04~ppa6/cont/base/springcontent/shaders/GLSL/TreeFragProg.glsl --- spring-96.0~14.04~ppa4/cont/base/springcontent/shaders/GLSL/TreeFragProg.glsl 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/cont/base/springcontent/shaders/GLSL/TreeFragProg.glsl 2014-10-07 20:09:51.000000000 +0000 @@ -1,24 +1,25 @@ -#if (defined(TREE_NEAR_SHADOW) || defined(TREE_DIST_SHADOW)) uniform sampler2DShadow shadowTex; uniform sampler2D diffuseTex; uniform vec3 groundAmbientColor; uniform float groundShadowDensity; -varying float fogFactor; +#if !(defined(TREE_NEAR_SHADOW) || defined(TREE_DIST_SHADOW)) + varying float fogFactor; +#endif void main() { - vec4 shadowInt = shadow2DProj(shadowTex, gl_TexCoord[0]); - shadowInt.x = max(0.0, min(shadowInt.x + groundShadowDensity, 1.0)); - vec3 shadeInt = mix(groundAmbientColor.rgb, gl_Color.rgb, shadowInt.x); vec4 diffuseCol = texture2D(diffuseTex, gl_TexCoord[1].st); + float shadowInt = shadow2DProj(shadowTex, gl_TexCoord[0]).a; + shadowInt = clamp(shadowInt + groundShadowDensity, 0.0, 1.0); + vec3 shadeInt = mix(groundAmbientColor.rgb, gl_Color.rgb, shadowInt); + gl_FragColor.rgb = diffuseCol.rgb * shadeInt.rgb; - #if (defined(TREE_NEAR_SHADOW) || defined(TREE_DIST_SHADOW)) +#if !(defined(TREE_NEAR_SHADOW) || defined(TREE_DIST_SHADOW)) gl_FragColor.rgb = mix(gl_Fog.color.rgb, gl_FragColor.rgb, fogFactor); - #endif +#endif gl_FragColor.a = diffuseCol.a; } -#endif diff -Nru spring-96.0~14.04~ppa4/cont/base/springcontent/shaders/GLSL/TreeVertProg.glsl spring-98.0~14.04~ppa6/cont/base/springcontent/shaders/GLSL/TreeVertProg.glsl --- spring-96.0~14.04~ppa4/cont/base/springcontent/shaders/GLSL/TreeVertProg.glsl 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/cont/base/springcontent/shaders/GLSL/TreeVertProg.glsl 2014-10-07 20:09:51.000000000 +0000 @@ -38,8 +38,8 @@ #endif #if (defined(TREE_NEAR_SHADOW) || defined(TREE_DIST_SHADOW)) - vec2 p17 = vec2(shadowParams.z, shadowParams.z); - vec2 p18 = vec2(shadowParams.w, shadowParams.w); + vec2 p17 = shadowParams.zz; + vec2 p18 = shadowParams.ww; vec4 vertexShadowPos = shadowMatrix * vertexPos; vertexShadowPos.st *= (inversesqrt(abs(vertexShadowPos.st) + p17) + p18); diff -Nru spring-96.0~14.04~ppa4/cont/CMakeLists.txt spring-98.0~14.04~ppa6/cont/CMakeLists.txt --- spring-96.0~14.04~ppa4/cont/CMakeLists.txt 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/cont/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -58,10 +58,10 @@ #install(FILES ${STDCXX_LIBRARY} DESTINATION ${BINDIR}) # pthreadGC2 is a dependency of ThreadPool - find_library(PTHREADGC2_LIBRARY NAMES pthreadGC2) - if(NOT EXISTS ${PTHREADGC2_LIBRARY}) - message(SEND_ERROR "pthreadGC2 not found!") - endif() - install(FILES ${PTHREADGC2_LIBRARY} DESTINATION ${BINDIR}) +# find_library(PTHREADGC2_LIBRARY NAMES pthreadGC2) +# if(NOT EXISTS ${PTHREADGC2_LIBRARY}) +# message(SEND_ERROR "pthreadGC2 not found!") +# endif() +# install(FILES ${PTHREADGC2_LIBRARY} DESTINATION ${BINDIR}) endif (MINGW) diff -Nru spring-96.0~14.04~ppa4/cont/freedesktop/applications/spring.desktop spring-98.0~14.04~ppa6/cont/freedesktop/applications/spring.desktop --- spring-96.0~14.04~ppa4/cont/freedesktop/applications/spring.desktop 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/cont/freedesktop/applications/spring.desktop 2014-10-07 20:09:51.000000000 +0000 @@ -1,11 +1,10 @@ [Desktop Entry] Name=Spring -MimeType=application/x-spring-demo; +MimeType=application/x-spring-demo;x-scheme-handler/spring; Comment=An open source RTS with similar gameplay to TA Comment[de]=Open-Source Multiplayerstrategie Comment[it]=Un gioco di strategia in tempo reale multi giocatore simile a TA -TryExec=spring -Exec=spring %f +Exec=spring %u Icon=spring Terminal=false Type=Application diff -Nru spring-96.0~14.04~ppa4/cont/LuaUI/widgets.lua spring-98.0~14.04~ppa6/cont/LuaUI/widgets.lua --- spring-96.0~14.04~ppa4/cont/LuaUI/widgets.lua 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/cont/LuaUI/widgets.lua 2014-10-07 20:09:51.000000000 +0000 @@ -1686,9 +1686,9 @@ -- Unit call-ins -- -function widgetHandler:UnitCreated(unitID, unitDefID, unitTeam) +function widgetHandler:UnitCreated(unitID, unitDefID, unitTeam, builderID) for _,w in ipairs(self.UnitCreatedList) do - w:UnitCreated(unitID, unitDefID, unitTeam) + w:UnitCreated(unitID, unitDefID, unitTeam, builderID) end return end diff -Nru spring-96.0~14.04~ppa4/debian/changelog spring-98.0~14.04~ppa6/debian/changelog --- spring-96.0~14.04~ppa4/debian/changelog 2014-02-16 23:57:19.000000000 +0000 +++ spring-98.0~14.04~ppa6/debian/changelog 2014-10-16 08:18:09.000000000 +0000 @@ -1,8 +1,8 @@ -spring (96.0~14.04~ppa4) trusty; urgency=low +spring (98.0~14.04~ppa6) trusty; urgency=low * new upstream release - -- Rene Milk Mon, 17 Feb 2014 00:57:19 +0100 + -- Rene Milk Thu, 16 Oct 2014 10:18:09 +0200 spring (91.0~12.10~ppa2) quantal; urgency=low diff -Nru spring-96.0~14.04~ppa4/debian/control spring-98.0~14.04~ppa6/debian/control --- spring-96.0~14.04~ppa4/debian/control 2014-02-16 23:57:15.000000000 +0000 +++ spring-98.0~14.04~ppa6/debian/control 2014-10-16 08:18:04.000000000 +0000 @@ -24,7 +24,7 @@ libglew-dev, libogg-dev, libopenal-dev, - libsdl-dev, + libsdl2-dev, libvorbis-dev, libxcursor-dev, p7zip-full, diff -Nru spring-96.0~14.04~ppa4/doc/changelog.txt spring-98.0~14.04~ppa6/doc/changelog.txt --- spring-96.0~14.04~ppa4/doc/changelog.txt 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/doc/changelog.txt 2014-10-07 20:09:51.000000000 +0000 @@ -2,6 +2,200 @@ (since 85.0: "!" prefix indicate backward compability broke) (numbers in brackets normally mean the mantis ticket ID) +-- 98.0 --------------------------------------------------------- +Major: + - vaporized PathFinder's runtime precache cpu usage + + +Cmdline Arguments: + - allow ./spring --game rapid://ba:stable --map DeltaSiegeDry + - give correct error message when cmdline given filepath wasn't quoted and contained spaces + +GameServer: + - rename BypassScriptPasswordCheck to AllowSpectatorJoin and default to true + +Lua: + - added SetAlly(firstAllyTeamId, secondAllyTeamId, ally) + - added VFS.UnmapArchive(string fileName) + - added VFS.GetMaps(), VFS.GetGames(), VFS.GetAllArchives(), VFS.HasArchive(archiveName) + - added VFS.GetArchiveInfo(archiveName) + - added VFS.GetArchiveChecksum(archiveName) + - added VFS.GetArchiveDependencies(archiveName), VFS.GetArchiveReplaces(archiveName) + - allow tcp connections by luasocket as default (udp is still restricted) + - add callin DrawInMiniMapBackground(sizex, sizey) -> nil + - add callin AllowBuilderHoldFire(unitID, unitDefID, action) --> boolean + action is one of: + Build -1 + Repair 40 (CMD_REPAIR) + Reclaim 90 (CMD_RECLAIM) + Restore 110 (CMD_RESTORE) + Resurrect 125 (CMD_RESURRECT) + Capture 130 (CMD_CAPTURE) + +Rendering: + - glFont: make inlined colorcodes reuse current set alpha value + +Pather: + - make lowRes PathEstimator using medRes PE instead of maxRes PathFinder (massively reducing cputime) + - massive cleanup & modularization + - reduced memory usage + - modrules: add system.pathFinderUpdateRate tag + - fixed/reduced PathEstimator update rate + - crashing aircraft doesn't spam PE updates anymore (#4500) + +CEG: + ! fixed booleans in CEGs (sometimes they were randomly overriden with random data) + +Weapons: + - Beamlasers respect repulser-shields' armorclass (pullrequest by sprunk) + ! move magic number to weapondef_post.lua: crater were 1.5x of craterAreaOfEffect while decals are 1.0x -> make them _both same size_ + ! fixed #4523: typo in craterAoE loading + +Sim: + - GroundBlocking: don't align immobile objects to even squares + - reduce load in Collisions handling (by doing blocked ground squares scans only every 2nd frame) + +Misc: + - AI is initializated earlier: no more hang on game start + - add /set GrassDetail to console + - slightly speed up scanning for archives + - add HostIPDefault, HostPortDefault to set default host ip/port + - reduce default spintime of ThreadPool workers to 1ms (from 5ms) + +Bugfixes: + - fix #4417 (spring spring://username:passwd@hostname:port doesn't work) + - fix #4413 (widget:GameProgress() was no longer called for rejoining player) + - fix #4407 (SetUnitRotation broken for buildings) + - fix #4406 (crash at start) + - fix #4377 (compile with cmake 3.0) + - fix #3677 (bounceExplosionGenerator tag does not work for bouncing aircraftbomb weapon types) + - fix #4483 (Spring.SetProjectileAlwaysVisible doesn't always make a projectile always visible) + - KingRaptor found the cause of a _very_ old bug: fix green screen tint in startselector stage + - PE: fix bug where buildings weren't registered as blocking, cause they were not snapped to ground when the PE update was called (c03022cc) + +AI: + - fixed return-type and value of Pathing::GetApproximateLength (pullrequest by rlcevg) + +Buildprocess: + - fixes for CMake 3.0 + - heavily reduced files which are compiled multiple times + ! add check for gcc >=4.7 at configure + + +-- 97.0 --------------------------------------------------------- +Major: + - utf8 support (kudos go to N0U) + - switch from sdl to sdl2: + - added /fullscreen (alt+enter) command ingame + - fixes some window manager bugs/problems + - KeyChains (kudos go to MajBoredom) + - split LuaRules & LuaGaia into their synced/unsynced luaStates + + +Cmdline Arguments: + - added new `spring spring://username:passwd@hostname:port` syntax (all except hostname are optional, i.e. spring://localhost does work fine) + - Should in longterm replace script.txt for clients, so script.txt is only needed for hosts. + -> No need to create a file on the filesystem to start spring as a client. + - Spring links spring:// URL scheme in the OS, so you can start such URLs from browser (as UT99 did). + E.g. you can place a spectator link on your website to join your autohosts and/or you can use it for weblobbies. + ! changed -s/--server argument to take a param (the ip/hostname listen to) + ! removed -c/--client argument (was only needed in times when clients didn't retrieved their script.txt from the server) + +Hosting & Connecting: + - fixed direct connect in SelectMenu + - by default listen to localhost:8452 now, so you can always connect to localhost started matches + +Misc: + - improve debug draw (alt+[b]) + ! demofile string in infolog changed "recording demo: %s" -> "Recording demo to: %s" + - demo filehandle is now opened on start, so you can use lsof to readback the used filename + +Buildprocess: + - fix freetype not found on windows / mingw + ! add check for gcc >=4.6 at configure + - optional fontconfig support + ! SDL2 dependency + +Rendering: + - `DebugGL` configtag works now (cause of SDL2 switch) + +KeyBindings/uikeys.txt: + ! removed /keyset + ! removed /hotbind (Ctrl+insert) + - new KeyChains support: + - example: /bind Ctrl+a,Ctrl+b say Hello World! + - you can double bind a button this way, e.g.: + - "/bind e,e say Bar", "/bind e say Foo" -> 1st press prints Foo, 2nd press prints Bar + - use KeyChains for defaults: + ! double hitting drawbutton sets label + ! switching between ally,spec & all chat is now done by double hitting alt,shift or ctrl + ! alt+return now toggles fullscreen (default shortcut e.g. in mediaplayers) + +LuaDefs: + - the parser now checks the returned tables for NaNs & Infs and prints a warning if it finds some (they are sources of desyncs!) + +UnitDefs: + - add new "harvestStorage" unitdef tag, UnitHarvestStorageFull lua callin and Spring.GetUnitHarvestStorage(unitid) callout + it's for engine assisted starcraft/c&c like feature harvesting (atm only metal is supported) + NOTE: the unload command still needs to be implemented in lua (much less work than the reclaiming one) + +Lua: + - LuaRules & LuaGaia are now splitted into their synced & unsynced parts, and each one got its own luaState + ! this way unsynced parts of gadgets now get `synced` callins like 'UnitCreated' etc. w/o SendToUnsynced from their synced part + - LuaRules & LuaGaia are now ~equal (except a very minor subset of differences) and get the same callins esp. all AllowXYZ callins + - LuaUI now has a GotChatMsg too (same as LuaRules always had), it's similar to the now deprecated LuaUI-only ConfigCommand callin, but is called more often + - fixed a lot bugs in Spring's c-lua code + - use lua's original math.random() code and only use streflop for it in synced luaStates + - always make math.randomseed() available (synced & unsynced) + - in future this will also allow multithreading of the different luaStates + ! SYNCED. does a copy on access now and so is slow: + - bad: for i=1,100 do ... SYNCED.foo[i] ... end + - good: local foo = SYNCED.foo; for i=1,100 do ... foo[i] ... end + ! SYNCED. can't be localized in global scope anymore: + - bad: local foo = SYNCED.foo; function gadget:DrawWorld() ... foo ... end + - good: function gadget:DrawWorld() local foo = SYNCED.foo; ... foo ... end + ! moved Spring.GetGameSpeed() from SyncedRead to UnsyncedRead cause it was causing desyncs in demos + - fix Spring.Restart on windows + ! new TextInput(utf8char) callin, needed cause of changed unicode handling in SDL2 + - added Spring.SetUnitHarvestStorage(unitid, metal) & Spring.GetUnitHarvestStorage(unitid) + ! prevent triggering of ATi driver bugs + ! gl.LineWidth & gl.PointSize throw an error when called with incorrect argument (<=0) + ! gl.Scissor & gl.CreateTexture throw an error on incorrect sizes, too + ! fix gl.Viewport + - add missing colvol tags to Unit-/FeatureDefs: + - .collisionVolume.type = {"ellipsoid" | "cylinder" | "box"} + - .collisionVolume.scale{X|Y|Z} + - .collisionVolume.offset{X|Y|Z} + - .collisionVolume.boundingRadius + - .collisionVolume.defaultToSphere + - .collisionVolume.defaultToFootPrint + - .collisionVolume.defaultToPieceTree + - add optional 4th argument to Spring.GetUnitSeperation to calc the distance between the unitsphere surfaces instead of their midpos + ! fix wrong coords & crash in Spring.RemoveGrass + - added new LOG.NOTICE (should be used instead of LOG.INFO) + - improve Spring.GetKeyBindings output (backward compatible) + - added Script.IsEngineMinVersion(major [,minor [,commits]]) + - added Spring.GetClipboard() & Spring.SetClipboard(string text) + - allow to connect to lobby.springrts.com:8200 by luasocket as default + +LUS: + - SetUnitValue now accepts booleans, too + +Demos: + - fixed desync checker + +StartScript: + - added GAME/MUTATOR{0..9} so you can load arbitrary mutator archives before the game + - make GameID the only seed of the synced random generator + so you can define the gameid in a luaAI battle startscript and you will always get a syncing match + +Installer: + ! disallow to install spring over existing installations / ask for uninstall first + - don't associate .sdf with spring.exe any more + +Linux: + ! new BlockCompositing configtag (default true). Disables kwin compositing to fix tearing. + -- 96.0 --------------------------------------------------------- diff -Nru spring-96.0~14.04~ppa4/doc/CMakeLists.txt spring-98.0~14.04~ppa6/doc/CMakeLists.txt --- spring-96.0~14.04~ppa4/doc/CMakeLists.txt 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/doc/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -13,9 +13,9 @@ OUTPUT_QUIET ERROR_STRIP_TRAILING_WHITESPACE) if (ASCIIDOC_RESULT EQUAL 0) - set(CREATE_MAN_PAGES TRUE) + MakeGlobalVar(CREATE_MAN_PAGES TRUE) else (ASCIIDOC_RESULT EQUAL 0) - set(CREATE_MAN_PAGES FALSE) + MakeGlobalVar(CREATE_MAN_PAGES FALSE) message(STATUS "MAN pages will not be generated/installed (utility asciidoc is broken)") endif (ASCIIDOC_RESULT EQUAL 0) else (SEVENZIP_FOUND AND ASCIIDOC_FOUND AND XSLTPROC_FOUND AND DOCBOOK_FOUND) diff -Nru spring-96.0~14.04~ppa4/doc/manpages/spring.6.txt spring-98.0~14.04~ppa6/doc/manpages/spring.6.txt --- spring-96.0~14.04~ppa4/doc/manpages/spring.6.txt 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/doc/manpages/spring.6.txt 2014-10-07 20:09:51.000000000 +0000 @@ -12,8 +12,8 @@ Synopsis -------- -ifndef::GUILESS[*{BINARY}* [-f|--fullscreen] [-w|--window] [-x|--xresolution 'SIZE'] [-y|--yresolution 'SIZE'] [-m|--minimise] [--safemode] [[-c|--client] | [-s|--server]] [-p|--projectiledump] [-t|--textureatlas] [--benchmark 'TIME' [--benchmarkstart 'TIME']] [-i|--isolation] [--isolation-dir 'PATH'] [-n|--name 'STRING'] [-C|--config 'FILE'] ['SCRIPT']] -ifdef::HEADLESS[*{BINARY}* [--safemode] [[-c|--client] | [-s|--server]] [-p|--projectiledump] [--benchmark 'TIME' [--benchmarkstart 'TIME']] [-i|--isolation] [--isolation-dir 'PATH'] [-n|--name 'STRING'] [-C|--config 'FILE'] SCRIPT] +ifndef::GUILESS[*{BINARY}* [-f|--fullscreen] [-w|--window] [-x|--xresolution 'SIZE'] [-y|--yresolution 'SIZE'] [-m|--minimise] [--safemode] [-s|--server 'IP_OR_HOSTNAME'] [-p|--projectiledump] [-t|--textureatlas] [--benchmark 'TIME' [--benchmarkstart 'TIME']] [-i|--isolation] [--isolation-dir 'PATH'] [-n|--name 'STRING'] [-C|--config 'FILE'] ['SCRIPT']] +ifdef::HEADLESS[*{BINARY}* [--safemode] [-s|--server 'IP_OR_HOSTNAME'] [-p|--projectiledump] [--benchmark 'TIME' [--benchmarkstart 'TIME']] [-i|--isolation] [--isolation-dir 'PATH'] [-n|--name 'STRING'] [-C|--config 'FILE'] SCRIPT] ifdef::DEDICATED[*{BINARY}* [-i|--isolation] [--isolation-dir 'PATH'] [-C|--config 'FILE'] SCRIPT] ifndef::DEDICATED[] @@ -102,11 +102,8 @@ ifndef::DEDICATED[*--safemode*::] ifndef::DEDICATED[ Turns off many things that are known to cause problems (i.e. on PC/Mac's with lower-end graphic cards)] ifndef::DEDICATED[ ] -ifndef::DEDICATED[*-s, --server*::] -ifndef::DEDICATED[ Run as a server] -ifndef::DEDICATED[ ] -ifndef::DEDICATED[*-c, --client*::] -ifndef::DEDICATED[ Run as a client] +ifndef::DEDICATED[*-s, --server*::'IP_OR_HOSTNAME'::] +ifndef::DEDICATED[ Run as a server on the given address] ifndef::GUILESS[ ] ifndef::GUILESS[*-t, --textureatlas*::] ifndef::GUILESS[ Dump each finalised textureatlas into textureatlasN.tga] diff -Nru spring-96.0~14.04~ppa4/doc/releasechecklist.txt spring-98.0~14.04~ppa6/doc/releasechecklist.txt --- spring-96.0~14.04~ppa4/doc/releasechecklist.txt 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/doc/releasechecklist.txt 2014-10-07 20:09:51.000000000 +0000 @@ -32,7 +32,7 @@ git reset --hard origin/master git merge release --no-ff 2) Tag the release: - export REL_VERS=95.0 + export REL_VERS=96.0 git tag -a -m "${REL_VERS} release [changed APIs: Lua, unitsync, AI]" ${REL_VERS} Make sure it looks correct: gitk master develop release & @@ -70,81 +70,15 @@ rsync --progress -h spring_${REL_VERS}* USER,springrts@frs.sourceforge.net:/home/frs/project/s/sp/springrts/springrts/spring-${REL_VERS}/ 10) Post the news post. -11) After a week, enforce it on the server, if it is a sync relevant change. +11) After a week, set it as default version on the server: + Ask a lobby admin to set the default version on the lobby server: + http://springrts.com/wiki/Uberserver#set_spring_version + Update download page by chaning the version templates on the Wiki. + http://springrts.com/mediawiki/index.php?title=Template:EngineVersion:Stable:Major&action=edit + http://springrts.com/mediawiki/index.php?title=Template:EngineVersion:Stable:Minor&action=edit + http://springrts.com/mediawiki/index.php?title=Template:EngineVersion:Stable:ReleaseDate&action=edit + Update the default downloads for each platform on SF. + Installer .exe for Windows, .tar.gz for all other platforms. + Do so through the file(s) properties on this page: + https://sourceforge.net/projects/springrts/files/springrts/spring-${REL_VERS}/ - -Enforcing on server -------------------- - -This only needs to be done if it is a sync relevant change. - -1) Ask a lobby admin to enforce the new version. -2) Update download page by chaning the version templates on the Wiki. - http://springrts.com/mediawiki/index.php?title=Template:EngineVersion:Stable:Major&action=edit - http://springrts.com/mediawiki/index.php?title=Template:EngineVersion:Stable:Minor&action=edit - http://springrts.com/mediawiki/index.php?title=Template:EngineVersion:Stable:ReleaseDate&action=edit -3) Update the default downloads for each platform on SF. - Installer .exe for Windows, .tar.gz for all other platforms. - Do so through the file(s) properties on this page: - https://sourceforge.net/projects/springrts/files/springrts/spring-${REL_VERS}/ - - - - -Old stuff, to be cleaned up later -================================= - -Checklist of stuff that needs to be doing at release time, -not necessarily in the optimal order, but I tried to make it pretty much right. - -Spring engine: -Before you start: -- if necessary, increase PATHESTIMATOR_VERSION to force repathing -- make sure changelog is up to date (including version number!) -- talk to people to fix their apps which get included in the installer (Lobby, Downloader...) - -Then proceed: -- make sure all packages build correctly (test building on buildbot, test-generate source packages (and check them if they work)) -- set buildbot to only produce builds if forced to (comment out schedulers) -- test source package linux (or not if you feel brave) -- test source package windows (ditto) -- test installer (NEVER EVER SKIP THIS NO MATTER HOW SMALL THE CHANGES) - -- bump version number in rts/Game/GameVersion.cpp -- tag the released revision in GIT as e.g. "0.78.0" -- have buildbot compile installer and make source packages -- upload installer to fnord.clan-sy.com -- upload installer to the big Spring file sites (watch out for notification bots, - it can create chaos if you upload early in release process and the upload gets - widely announced already.) -- upload spring_X.XXbX_src.tar.bz2 to fnord.clan-sy.com -- upload spring_X.XXbX_src.zip to fnord.clan-sy.com -- upload spring_X.XXbX_src.tar.bz2 to Berlios (not too important) -- upload spring_X.XXbX_src.zip to Berlios (ditto) -- make news post (don't forget to thank contributors, link to installer and source) -- bump version number in rts/Game/GameVersion.cpp to e.g. "0.76b1+" (note the plus) -- enable automatic builds in buildbot again - -TASServer (when only spring update): -- update updates.xml with OFFERFILE entries for current Spring version. -- as admin, do "reloadupdateproperties" in TASServer ($Local in TASClient) -- as admin, do "setlatestspringversion 0.76b1" (replace version!) -- as admin, "broadcast" a message that everyone will be kicked due to upgrade -- as admin, kick all users from the server ("killall [reason]") -- set correct Spring version in the shell script that starts server, so it - won't boot people if it ever gets restarted (e.g. power outage) - -TASServer (full update, ie. Spring+TASServer): -- easiest is probably to release Spring separately, but usually this is - impossible due to compatibility things. -- update updates.xml with OFFERFILE entries for current lobby version(s) - and current Spring version. -- set correct spring version in the shell script that starts server. -- update sourcecode to latest version -- stop server -- compile server -- do whatever is needed to migrate data, if anything. -- start server -- hotfix the issues that usually arise during TASServer upgrade :-) -- commit the hotfixes -- tag the used server in SVN as e.g. "tags/Lobby/TASServer 0.35" diff -Nru spring-96.0~14.04~ppa4/doc/uikeys.txt spring-98.0~14.04~ppa6/doc/uikeys.txt --- spring-96.0~14.04~ppa4/doc/uikeys.txt 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/doc/uikeys.txt 2014-10-07 20:09:51.000000000 +0000 @@ -40,13 +40,6 @@ // - the can be a currently recognized keysym // (ex: "keysym menu 0x13F" or "keysym radar r") // -// keyset -// ---------------------- -// - specifies a named keyset -// - name must start with a letter, and only contain letters, numbers, and '_' -// - named keysets may be accessed by prepending the '&' character to the name -// (ex: "keyset myKeySet Ctrl+x" then "bind &myKeySet myAction" ) -// // fakemeta // ----------------- // - assign an auxiliary key for the Meta modifier ("space" is a good choice) @@ -88,15 +81,11 @@ // bind C+a fake_action // bind Ctrl+Shift+a fake_action // bind *+a fake_action -// bind &my_keyset fake_action // // The format then goes like this: // // [+]...[+] // -// or -// -// & (for named keysets) // // The modifiers (and their abbreviations), are: // diff -Nru spring-96.0~14.04~ppa4/.gitmodules spring-98.0~14.04~ppa6/.gitmodules --- spring-96.0~14.04~ppa4/.gitmodules 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/.gitmodules 2014-10-07 20:09:51.000000000 +0000 @@ -1,6 +1,6 @@ [submodule "E323AI"] path = AI/Skirmish/E323AI - url = git://github.com/Error323/E323AI.git + url = git://github.com/spring/E323AI.git [submodule "HughAI"] path = AI/Skirmish/HughAI url = git://github.com/spring/HughAI.git diff -Nru spring-96.0~14.04~ppa4/include/SDL/begin_code.h spring-98.0~14.04~ppa6/include/SDL/begin_code.h --- spring-96.0~14.04~ppa4/include/SDL/begin_code.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/begin_code.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,156 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2004 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* This file sets things up for C dynamic library function definitions, - static inlined functions, and structures aligned at 4-byte alignment. - If you don't like ugly C preprocessor code, don't look at this file. :) -*/ - -/* This shouldn't be nested -- included it around code only. */ -#ifdef _begin_code_h -#error Nested inclusion of begin_code.h -#endif -#define _begin_code_h - -/* Some compilers use a special export keyword */ -#ifndef DECLSPEC -# if defined(__BEOS__) -# if defined(__GNUC__) -# define DECLSPEC __declspec(dllexport) -# else -# define DECLSPEC __declspec(export) -# endif -# elif defined(__WIN32__) -# ifdef __BORLANDC__ -# ifdef BUILD_SDL -# define DECLSPEC -# else -# define DECLSPEC __declspec(dllimport) -# endif -# else -# define DECLSPEC __declspec(dllexport) -# endif -# elif defined(__OS2__) -# ifdef __WATCOMC__ -# ifdef BUILD_SDL -# define DECLSPEC __declspec(dllexport) -# else -# define DECLSPEC -# endif -# else -# define DECLSPEC -# endif -# else -# if defined(__GNUC__) && __GNUC__ >= 4 -# define DECLSPEC __attribute__ ((visibility("default"))) -# else -# define DECLSPEC -# endif -# endif -#endif - -/* By default SDL uses the C calling convention */ -#ifndef SDLCALL -#if defined(__WIN32__) && !defined(__GNUC__) -#define SDLCALL __cdecl -#else -#ifdef __OS2__ -/* But on OS/2, we use the _System calling convention */ -/* to be compatible with every compiler */ -#define SDLCALL _System -#else -#define SDLCALL -#endif -#endif -#endif /* SDLCALL */ - -#ifdef __SYMBIAN32__ -#ifndef EKA2 -#undef DECLSPEC -#define DECLSPEC -#elif !defined(__WINS__) -#undef DECLSPEC -#define DECLSPEC __declspec(dllexport) -#endif /* !EKA2 */ -#endif /* __SYMBIAN32__ */ - -/* Force structure packing at 4 byte alignment. - This is necessary if the header is included in code which has structure - packing set to an alternate value, say for loading structures from disk. - The packing is reset to the previous value in close_code.h - */ -#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) -#ifdef _MSC_VER -#pragma warning(disable: 4103) -#endif -#ifdef __BORLANDC__ -#pragma nopackwarning -#endif -#pragma pack(push,4) -#elif (defined(__MWERKS__) && defined(__MACOS__)) -#pragma options align=mac68k4byte -#pragma enumsalwaysint on -#endif /* Compiler needs structure packing set */ - -/* Set up compiler-specific options for inlining functions */ -#ifndef SDL_INLINE_OKAY -#ifdef __GNUC__ -#define SDL_INLINE_OKAY -#else -/* Add any special compiler-specific cases here */ -#if defined(_MSC_VER) || defined(__BORLANDC__) || \ - defined(__DMC__) || defined(__SC__) || \ - defined(__WATCOMC__) || defined(__LCC__) || \ - defined(__DECC) || defined(__EABI__) -#ifndef __inline__ -#define __inline__ __inline -#endif -#define SDL_INLINE_OKAY -#else -#if !defined(__MRC__) && !defined(_SGI_SOURCE) -#ifndef __inline__ -#define __inline__ inline -#endif -#define SDL_INLINE_OKAY -#endif /* Not a funky compiler */ -#endif /* Visual C++ */ -#endif /* GNU C */ -#endif /* SDL_INLINE_OKAY */ - -/* If inlining isn't supported, remove "__inline__", turning static - inlined functions into static functions (resulting in code bloat - in all files which include the offending header files) -*/ -#ifndef SDL_INLINE_OKAY -#define __inline__ -#endif - -/* Apparently this is needed by several Windows compilers */ -#if !defined(__MACH__) -#ifndef NULL -#ifdef __cplusplus -#define NULL 0 -#else -#define NULL ((void *)0) -#endif -#endif /* NULL */ -#endif /* ! Mac OS X - breaks precompiled headers */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/close_code.h spring-98.0~14.04~ppa6/include/SDL/close_code.h --- spring-96.0~14.04~ppa4/include/SDL/close_code.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/close_code.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2004 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* This file reverses the effects of begin_code.h and should be included - after you finish any function and structure declarations in your headers -*/ - -#undef _begin_code_h - -/* Reset structure packing at previous byte alignment */ -#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__) -#ifdef __BORLANDC__ -#pragma nopackwarning -#endif -#if (defined(__MWERKS__) && defined(__MACOS__)) -#pragma options align=reset -#pragma enumsalwaysint reset -#else -#pragma pack(pop) -#endif -#endif /* Compiler needs structure packing set */ - diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_active.h spring-98.0~14.04~ppa6/include/SDL/SDL_active.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_active.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_active.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* Include file for SDL application focus event handling */ - -#ifndef _SDL_active_h -#define _SDL_active_h - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* The available application states */ -#define SDL_APPMOUSEFOCUS 0x01 /* The app has mouse coverage */ -#define SDL_APPINPUTFOCUS 0x02 /* The app has input focus */ -#define SDL_APPACTIVE 0x04 /* The application is active */ - -/* Function prototypes */ -/* - * This function returns the current state of the application, which is a - * bitwise combination of SDL_APPMOUSEFOCUS, SDL_APPINPUTFOCUS, and - * SDL_APPACTIVE. If SDL_APPACTIVE is set, then the user is able to - * see your application, otherwise it has been iconified or disabled. - */ -extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_active_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_audio.h spring-98.0~14.04~ppa6/include/SDL/SDL_audio.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_audio.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_audio.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,253 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* Access to the raw audio mixing buffer for the SDL library */ - -#ifndef _SDL_audio_h -#define _SDL_audio_h - -#include "SDL_stdinc.h" -#include "SDL_error.h" -#include "SDL_endian.h" -#include "SDL_mutex.h" -#include "SDL_thread.h" -#include "SDL_rwops.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* The calculated values in this structure are calculated by SDL_OpenAudio() */ -typedef struct SDL_AudioSpec { - int freq; /* DSP frequency -- samples per second */ - Uint16 format; /* Audio data format */ - Uint8 channels; /* Number of channels: 1 mono, 2 stereo */ - Uint8 silence; /* Audio buffer silence value (calculated) */ - Uint16 samples; /* Audio buffer size in samples (power of 2) */ - Uint16 padding; /* Necessary for some compile environments */ - Uint32 size; /* Audio buffer size in bytes (calculated) */ - /* This function is called when the audio device needs more data. - 'stream' is a pointer to the audio data buffer - 'len' is the length of that buffer in bytes. - Once the callback returns, the buffer will no longer be valid. - Stereo samples are stored in a LRLRLR ordering. - */ - void (SDLCALL *callback)(void *userdata, Uint8 *stream, int len); - void *userdata; -} SDL_AudioSpec; - -/* Audio format flags (defaults to LSB byte order) */ -#define AUDIO_U8 0x0008 /* Unsigned 8-bit samples */ -#define AUDIO_S8 0x8008 /* Signed 8-bit samples */ -#define AUDIO_U16LSB 0x0010 /* Unsigned 16-bit samples */ -#define AUDIO_S16LSB 0x8010 /* Signed 16-bit samples */ -#define AUDIO_U16MSB 0x1010 /* As above, but big-endian byte order */ -#define AUDIO_S16MSB 0x9010 /* As above, but big-endian byte order */ -#define AUDIO_U16 AUDIO_U16LSB -#define AUDIO_S16 AUDIO_S16LSB - -/* Native audio byte ordering */ -#if SDL_BYTEORDER == SDL_LIL_ENDIAN -#define AUDIO_U16SYS AUDIO_U16LSB -#define AUDIO_S16SYS AUDIO_S16LSB -#else -#define AUDIO_U16SYS AUDIO_U16MSB -#define AUDIO_S16SYS AUDIO_S16MSB -#endif - - -/* A structure to hold a set of audio conversion filters and buffers */ -typedef struct SDL_AudioCVT { - int needed; /* Set to 1 if conversion possible */ - Uint16 src_format; /* Source audio format */ - Uint16 dst_format; /* Target audio format */ - double rate_incr; /* Rate conversion increment */ - Uint8 *buf; /* Buffer to hold entire audio data */ - int len; /* Length of original audio buffer */ - int len_cvt; /* Length of converted audio buffer */ - int len_mult; /* buffer must be len*len_mult big */ - double len_ratio; /* Given len, final size is len*len_ratio */ - void (SDLCALL *filters[10])(struct SDL_AudioCVT *cvt, Uint16 format); - int filter_index; /* Current audio conversion function */ -} SDL_AudioCVT; - - -/* Function prototypes */ - -/* These functions are used internally, and should not be used unless you - * have a specific need to specify the audio driver you want to use. - * You should normally use SDL_Init() or SDL_InitSubSystem(). - */ -extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name); -extern DECLSPEC void SDLCALL SDL_AudioQuit(void); - -/* This function fills the given character buffer with the name of the - * current audio driver, and returns a pointer to it if the audio driver has - * been initialized. It returns NULL if no driver has been initialized. - */ -extern DECLSPEC char * SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen); - -/* - * This function opens the audio device with the desired parameters, and - * returns 0 if successful, placing the actual hardware parameters in the - * structure pointed to by 'obtained'. If 'obtained' is NULL, the audio - * data passed to the callback function will be guaranteed to be in the - * requested format, and will be automatically converted to the hardware - * audio format if necessary. This function returns -1 if it failed - * to open the audio device, or couldn't set up the audio thread. - * - * When filling in the desired audio spec structure, - * 'desired->freq' should be the desired audio frequency in samples-per-second. - * 'desired->format' should be the desired audio format. - * 'desired->samples' is the desired size of the audio buffer, in samples. - * This number should be a power of two, and may be adjusted by the audio - * driver to a value more suitable for the hardware. Good values seem to - * range between 512 and 8096 inclusive, depending on the application and - * CPU speed. Smaller values yield faster response time, but can lead - * to underflow if the application is doing heavy processing and cannot - * fill the audio buffer in time. A stereo sample consists of both right - * and left channels in LR ordering. - * Note that the number of samples is directly related to time by the - * following formula: ms = (samples*1000)/freq - * 'desired->size' is the size in bytes of the audio buffer, and is - * calculated by SDL_OpenAudio(). - * 'desired->silence' is the value used to set the buffer to silence, - * and is calculated by SDL_OpenAudio(). - * 'desired->callback' should be set to a function that will be called - * when the audio device is ready for more data. It is passed a pointer - * to the audio buffer, and the length in bytes of the audio buffer. - * This function usually runs in a separate thread, and so you should - * protect data structures that it accesses by calling SDL_LockAudio() - * and SDL_UnlockAudio() in your code. - * 'desired->userdata' is passed as the first parameter to your callback - * function. - * - * The audio device starts out playing silence when it's opened, and should - * be enabled for playing by calling SDL_PauseAudio(0) when you are ready - * for your audio callback function to be called. Since the audio driver - * may modify the requested size of the audio buffer, you should allocate - * any local mixing buffers after you open the audio device. - */ -extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained); - -/* - * Get the current audio state: - */ -typedef enum { - SDL_AUDIO_STOPPED = 0, - SDL_AUDIO_PLAYING, - SDL_AUDIO_PAUSED -} SDL_audiostatus; -extern DECLSPEC SDL_audiostatus SDLCALL SDL_GetAudioStatus(void); - -/* - * This function pauses and unpauses the audio callback processing. - * It should be called with a parameter of 0 after opening the audio - * device to start playing sound. This is so you can safely initialize - * data for your callback function after opening the audio device. - * Silence will be written to the audio device during the pause. - */ -extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on); - -/* - * This function loads a WAVE from the data source, automatically freeing - * that source if 'freesrc' is non-zero. For example, to load a WAVE file, - * you could do: - * SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...); - * - * If this function succeeds, it returns the given SDL_AudioSpec, - * filled with the audio data format of the wave data, and sets - * 'audio_buf' to a malloc()'d buffer containing the audio data, - * and sets 'audio_len' to the length of that audio buffer, in bytes. - * You need to free the audio buffer with SDL_FreeWAV() when you are - * done with it. - * - * This function returns NULL and sets the SDL error message if the - * wave file cannot be opened, uses an unknown data format, or is - * corrupt. Currently raw and MS-ADPCM WAVE files are supported. - */ -extern DECLSPEC SDL_AudioSpec * SDLCALL SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len); - -/* Compatibility convenience function -- loads a WAV from a file */ -#define SDL_LoadWAV(file, spec, audio_buf, audio_len) \ - SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len) - -/* - * This function frees data previously allocated with SDL_LoadWAV_RW() - */ -extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 *audio_buf); - -/* - * This function takes a source format and rate and a destination format - * and rate, and initializes the 'cvt' structure with information needed - * by SDL_ConvertAudio() to convert a buffer of audio data from one format - * to the other. - * This function returns 0, or -1 if there was an error. - */ -extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT *cvt, - Uint16 src_format, Uint8 src_channels, int src_rate, - Uint16 dst_format, Uint8 dst_channels, int dst_rate); - -/* Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(), - * created an audio buffer cvt->buf, and filled it with cvt->len bytes of - * audio data in the source format, this function will convert it in-place - * to the desired format. - * The data conversion may expand the size of the audio data, so the buffer - * cvt->buf should be allocated after the cvt structure is initialized by - * SDL_BuildAudioCVT(), and should be cvt->len*cvt->len_mult bytes long. - */ -extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT *cvt); - -/* - * This takes two audio buffers of the playing audio format and mixes - * them, performing addition, volume adjustment, and overflow clipping. - * The volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME - * for full audio volume. Note this does not change hardware volume. - * This is provided for convenience -- you can mix your own audio data. - */ -#define SDL_MIX_MAXVOLUME 128 -extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 *dst, const Uint8 *src, Uint32 len, int volume); - -/* - * The lock manipulated by these functions protects the callback function. - * During a LockAudio/UnlockAudio pair, you can be guaranteed that the - * callback function is not running. Do not call these from the callback - * function or you will cause deadlock. - */ -extern DECLSPEC void SDLCALL SDL_LockAudio(void); -extern DECLSPEC void SDLCALL SDL_UnlockAudio(void); - -/* - * This function shuts down audio processing and closes the audio device. - */ -extern DECLSPEC void SDLCALL SDL_CloseAudio(void); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_audio_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_byteorder.h spring-98.0~14.04~ppa6/include/SDL/SDL_byteorder.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_byteorder.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_byteorder.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* DEPRECATED */ -#include "SDL_endian.h" diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_cdrom.h spring-98.0~14.04~ppa6/include/SDL/SDL_cdrom.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_cdrom.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_cdrom.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,171 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* This is the CD-audio control API for Simple DirectMedia Layer */ - -#ifndef _SDL_cdrom_h -#define _SDL_cdrom_h - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* In order to use these functions, SDL_Init() must have been called - with the SDL_INIT_CDROM flag. This causes SDL to scan the system - for CD-ROM drives, and load appropriate drivers. -*/ - -/* The maximum number of CD-ROM tracks on a disk */ -#define SDL_MAX_TRACKS 99 - -/* The types of CD-ROM track possible */ -#define SDL_AUDIO_TRACK 0x00 -#define SDL_DATA_TRACK 0x04 - -/* The possible states which a CD-ROM drive can be in. */ -typedef enum { - CD_TRAYEMPTY, - CD_STOPPED, - CD_PLAYING, - CD_PAUSED, - CD_ERROR = -1 -} CDstatus; - -/* Given a status, returns true if there's a disk in the drive */ -#define CD_INDRIVE(status) ((int)(status) > 0) - -typedef struct SDL_CDtrack { - Uint8 id; /* Track number */ - Uint8 type; /* Data or audio track */ - Uint16 unused; - Uint32 length; /* Length, in frames, of this track */ - Uint32 offset; /* Offset, in frames, from start of disk */ -} SDL_CDtrack; - -/* This structure is only current as of the last call to SDL_CDStatus() */ -typedef struct SDL_CD { - int id; /* Private drive identifier */ - CDstatus status; /* Current drive status */ - - /* The rest of this structure is only valid if there's a CD in drive */ - int numtracks; /* Number of tracks on disk */ - int cur_track; /* Current track position */ - int cur_frame; /* Current frame offset within current track */ - SDL_CDtrack track[SDL_MAX_TRACKS+1]; -} SDL_CD; - -/* Conversion functions from frames to Minute/Second/Frames and vice versa */ -#define CD_FPS 75 -#define FRAMES_TO_MSF(f, M,S,F) { \ - int value = f; \ - *(F) = value%CD_FPS; \ - value /= CD_FPS; \ - *(S) = value%60; \ - value /= 60; \ - *(M) = value; \ -} -#define MSF_TO_FRAMES(M, S, F) ((M)*60*CD_FPS+(S)*CD_FPS+(F)) - -/* CD-audio API functions: */ - -/* Returns the number of CD-ROM drives on the system, or -1 if - SDL_Init() has not been called with the SDL_INIT_CDROM flag. - */ -extern DECLSPEC int SDLCALL SDL_CDNumDrives(void); - -/* Returns a human-readable, system-dependent identifier for the CD-ROM. - Example: - "/dev/cdrom" - "E:" - "/dev/disk/ide/1/master" -*/ -extern DECLSPEC const char * SDLCALL SDL_CDName(int drive); - -/* Opens a CD-ROM drive for access. It returns a drive handle on success, - or NULL if the drive was invalid or busy. This newly opened CD-ROM - becomes the default CD used when other CD functions are passed a NULL - CD-ROM handle. - Drives are numbered starting with 0. Drive 0 is the system default CD-ROM. -*/ -extern DECLSPEC SDL_CD * SDLCALL SDL_CDOpen(int drive); - -/* This function returns the current status of the given drive. - If the drive has a CD in it, the table of contents of the CD and current - play position of the CD will be stored in the SDL_CD structure. -*/ -extern DECLSPEC CDstatus SDLCALL SDL_CDStatus(SDL_CD *cdrom); - -/* Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks' - tracks and 'nframes' frames. If both 'ntrack' and 'nframe' are 0, play - until the end of the CD. This function will skip data tracks. - This function should only be called after calling SDL_CDStatus() to - get track information about the CD. - For example: - // Play entire CD: - if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) - SDL_CDPlayTracks(cdrom, 0, 0, 0, 0); - // Play last track: - if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) { - SDL_CDPlayTracks(cdrom, cdrom->numtracks-1, 0, 0, 0); - } - // Play first and second track and 10 seconds of third track: - if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) - SDL_CDPlayTracks(cdrom, 0, 0, 2, 10); - - This function returns 0, or -1 if there was an error. -*/ -extern DECLSPEC int SDLCALL SDL_CDPlayTracks(SDL_CD *cdrom, - int start_track, int start_frame, int ntracks, int nframes); - -/* Play the given CD starting at 'start' frame for 'length' frames. - It returns 0, or -1 if there was an error. -*/ -extern DECLSPEC int SDLCALL SDL_CDPlay(SDL_CD *cdrom, int start, int length); - -/* Pause play -- returns 0, or -1 on error */ -extern DECLSPEC int SDLCALL SDL_CDPause(SDL_CD *cdrom); - -/* Resume play -- returns 0, or -1 on error */ -extern DECLSPEC int SDLCALL SDL_CDResume(SDL_CD *cdrom); - -/* Stop play -- returns 0, or -1 on error */ -extern DECLSPEC int SDLCALL SDL_CDStop(SDL_CD *cdrom); - -/* Eject CD-ROM -- returns 0, or -1 on error */ -extern DECLSPEC int SDLCALL SDL_CDEject(SDL_CD *cdrom); - -/* Closes the handle for the CD-ROM drive */ -extern DECLSPEC void SDLCALL SDL_CDClose(SDL_CD *cdrom); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_video_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_config.h spring-98.0~14.04~ppa6/include/SDL/SDL_config.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_config.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_config.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,308 +0,0 @@ -/* include/SDL_config.h. Generated from SDL_config.h.in by configure. */ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -#ifndef _SDL_config_h -#define _SDL_config_h - -/* This is a set of defines to configure the SDL features */ - -/* General platform specific identifiers */ -#include "SDL_platform.h" - -/* Make sure that this isn't included by Visual C++ */ -#ifdef _MSC_VER -#error You should copy include/SDL_config.h.default to include/SDL_config.h -#endif - -/* C language features */ -/* #undef const */ -/* #undef inline */ -/* #undef volatile */ - -/* C datatypes */ -/* #undef size_t */ -/* #undef int8_t */ -/* #undef uint8_t */ -/* #undef int16_t */ -/* #undef uint16_t */ -/* #undef int32_t */ -/* #undef uint32_t */ -/* #undef int64_t */ -/* #undef uint64_t */ -/* #undef uintptr_t */ -#define SDL_HAS_64BIT_TYPE 1 - -/* Endianness */ -#define SDL_BYTEORDER 1234 - -/* Comment this if you want to build without any C library requirements */ -#define HAVE_LIBC 1 -#if HAVE_LIBC - -/* Useful headers */ -#define HAVE_ALLOCA_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STDLIB_H 1 -#define HAVE_STDARG_H 1 -#define HAVE_MALLOC_H 1 -#define HAVE_MEMORY_H 1 -#define HAVE_STRING_H 1 -#define HAVE_STRINGS_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 -#define HAVE_CTYPE_H 1 -#define HAVE_MATH_H 1 -#define HAVE_ICONV_H 1 -#define HAVE_SIGNAL_H 1 -/* #undef HAVE_ALTIVEC_H */ - -/* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#ifndef _WIN32 /* Don't use C runtime versions of these on Windows */ -#define HAVE_GETENV 1 -#define HAVE_PUTENV 1 -#define HAVE_UNSETENV 1 -#endif -#define HAVE_QSORT 1 -#define HAVE_ABS 1 -#define HAVE_BCOPY 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 -#define HAVE_STRLEN 1 -/* #undef HAVE_STRLCPY */ -/* #undef HAVE_STRLCAT */ -#define HAVE_STRDUP 1 -/* #undef HAVE__STRREV */ -/* #undef HAVE__STRUPR */ -/* #undef HAVE__STRLWR */ -/* #undef HAVE_INDEX */ -/* #undef HAVE_RINDEX */ -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -/* #undef HAVE_ITOA */ -/* #undef HAVE__LTOA */ -/* #undef HAVE__UITOA */ -/* #undef HAVE__ULTOA */ -#define HAVE_STRTOL 1 -#define HAVE_STRTOUL 1 -/* #undef HAVE__I64TOA */ -/* #undef HAVE__UI64TOA */ -#define HAVE_STRTOLL 1 -#define HAVE_STRTOULL 1 -#define HAVE_STRTOD 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -/* #undef HAVE__STRICMP */ -#define HAVE_STRCASECMP 1 -/* #undef HAVE__STRNICMP */ -#define HAVE_STRNCASECMP 1 -#define HAVE_SSCANF 1 -#define HAVE_SNPRINTF 1 -#define HAVE_VSNPRINTF 1 -#define HAVE_ICONV 1 -#define HAVE_SIGACTION 1 -#define HAVE_SETJMP 1 -#define HAVE_NANOSLEEP 1 -/* #undef HAVE_CLOCK_GETTIME */ -#define HAVE_DLVSYM 1 -/* #undef HAVE_GETPAGESIZE */ -#define HAVE_MPROTECT 1 - -#else -/* We may need some replacement for stdarg.h here */ -#include -#endif /* HAVE_LIBC */ - -/* Allow disabling of core subsystems */ -/* #undef SDL_AUDIO_DISABLED */ -/* #undef SDL_CDROM_DISABLED */ -/* #undef SDL_CPUINFO_DISABLED */ -/* #undef SDL_EVENTS_DISABLED */ -/* #undef SDL_FILE_DISABLED */ -/* #undef SDL_JOYSTICK_DISABLED */ -/* #undef SDL_LOADSO_DISABLED */ -/* #undef SDL_THREADS_DISABLED */ -/* #undef SDL_TIMERS_DISABLED */ -/* #undef SDL_VIDEO_DISABLED */ - -/* Enable various audio drivers */ -#define SDL_AUDIO_DRIVER_ALSA 1 -#define SDL_AUDIO_DRIVER_ALSA_DYNAMIC "libasound.so.2" -/* #undef SDL_AUDIO_DRIVER_ARTS */ -/* #undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC */ -/* #undef SDL_AUDIO_DRIVER_BAUDIO */ -/* #undef SDL_AUDIO_DRIVER_BSD */ -/* #undef SDL_AUDIO_DRIVER_COREAUDIO */ -/* #undef SDL_AUDIO_DRIVER_DART */ -/* #undef SDL_AUDIO_DRIVER_DC */ -#define SDL_AUDIO_DRIVER_DISK 1 -#define SDL_AUDIO_DRIVER_DUMMY 1 -/* #undef SDL_AUDIO_DRIVER_DMEDIA */ -/* #undef SDL_AUDIO_DRIVER_DSOUND */ -/* #undef SDL_AUDIO_DRIVER_PULSE */ -/* #undef SDL_AUDIO_DRIVER_PULSE_DYNAMIC */ -/* #undef SDL_AUDIO_DRIVER_ESD */ -/* #undef SDL_AUDIO_DRIVER_ESD_DYNAMIC */ -/* #undef SDL_AUDIO_DRIVER_MINT */ -/* #undef SDL_AUDIO_DRIVER_MMEAUDIO */ -/* #undef SDL_AUDIO_DRIVER_NAS */ -/* #undef SDL_AUDIO_DRIVER_OSS */ -/* #undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H */ -/* #undef SDL_AUDIO_DRIVER_PAUD */ -/* #undef SDL_AUDIO_DRIVER_QNXNTO */ -/* #undef SDL_AUDIO_DRIVER_SNDMGR */ -/* #undef SDL_AUDIO_DRIVER_SUNAUDIO */ -/* #undef SDL_AUDIO_DRIVER_WAVEOUT */ - -/* Enable various cdrom drivers */ -/* #undef SDL_CDROM_AIX */ -/* #undef SDL_CDROM_BEOS */ -/* #undef SDL_CDROM_BSDI */ -/* #undef SDL_CDROM_DC */ -/* #undef SDL_CDROM_DUMMY */ -/* #undef SDL_CDROM_FREEBSD */ -#define SDL_CDROM_LINUX 1 -/* #undef SDL_CDROM_MACOS */ -/* #undef SDL_CDROM_MACOSX */ -/* #undef SDL_CDROM_MINT */ -/* #undef SDL_CDROM_OPENBSD */ -/* #undef SDL_CDROM_OS2 */ -/* #undef SDL_CDROM_OSF */ -/* #undef SDL_CDROM_QNX */ -/* #undef SDL_CDROM_WIN32 */ - -/* Enable various input drivers */ -#define SDL_INPUT_LINUXEV 1 -/* #undef SDL_INPUT_TSLIB */ -/* #undef SDL_JOYSTICK_BEOS */ -/* #undef SDL_JOYSTICK_DC */ -/* #undef SDL_JOYSTICK_DUMMY */ -/* #undef SDL_JOYSTICK_IOKIT */ -#define SDL_JOYSTICK_LINUX 1 -/* #undef SDL_JOYSTICK_MACOS */ -/* #undef SDL_JOYSTICK_MINT */ -/* #undef SDL_JOYSTICK_OS2 */ -/* #undef SDL_JOYSTICK_RISCOS */ -/* #undef SDL_JOYSTICK_WINMM */ -/* #undef SDL_JOYSTICK_USBHID */ -/* #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H */ - -/* Enable various shared object loading systems */ -/* #undef SDL_LOADSO_BEOS */ -/* #undef SDL_LOADSO_DLCOMPAT */ -#define SDL_LOADSO_DLOPEN 1 -/* #undef SDL_LOADSO_DUMMY */ -/* #undef SDL_LOADSO_LDG */ -/* #undef SDL_LOADSO_MACOS */ -/* #undef SDL_LOADSO_OS2 */ -/* #undef SDL_LOADSO_WIN32 */ - -/* Enable various threading systems */ -/* #undef SDL_THREAD_BEOS */ -/* #undef SDL_THREAD_DC */ -/* #undef SDL_THREAD_OS2 */ -/* #undef SDL_THREAD_PTH */ -#define SDL_THREAD_PTHREAD 1 -#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 -/* #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP */ -/* #undef SDL_THREAD_SPROC */ -/* #undef SDL_THREAD_WIN32 */ - -/* Enable various timer systems */ -/* #undef SDL_TIMER_BEOS */ -/* #undef SDL_TIMER_DC */ -/* #undef SDL_TIMER_DUMMY */ -/* #undef SDL_TIMER_MACOS */ -/* #undef SDL_TIMER_MINT */ -/* #undef SDL_TIMER_OS2 */ -/* #undef SDL_TIMER_RISCOS */ -#define SDL_TIMER_UNIX 1 -/* #undef SDL_TIMER_WIN32 */ -/* #undef SDL_TIMER_WINCE */ - -/* Enable various video drivers */ -#define SDL_VIDEO_DRIVER_AALIB 1 -/* #undef SDL_VIDEO_DRIVER_BWINDOW */ -/* #undef SDL_VIDEO_DRIVER_CACA */ -/* #undef SDL_VIDEO_DRIVER_DC */ -/* #undef SDL_VIDEO_DRIVER_DDRAW */ -/* #undef SDL_VIDEO_DRIVER_DGA */ -/* #undef SDL_VIDEO_DRIVER_DIRECTFB */ -/* #undef SDL_VIDEO_DRIVER_DRAWSPROCKET */ -#define SDL_VIDEO_DRIVER_DUMMY 1 -/* #undef SDL_VIDEO_DRIVER_FBCON */ -/* #undef SDL_VIDEO_DRIVER_GAPI */ -/* #undef SDL_VIDEO_DRIVER_GEM */ -/* #undef SDL_VIDEO_DRIVER_GGI */ -/* #undef SDL_VIDEO_DRIVER_IPOD */ -/* #undef SDL_VIDEO_DRIVER_NANOX */ -/* #undef SDL_VIDEO_DRIVER_OS2FS */ -/* #undef SDL_VIDEO_DRIVER_PHOTON */ -/* #undef SDL_VIDEO_DRIVER_PICOGUI */ -/* #undef SDL_VIDEO_DRIVER_PS2GS */ -/* #undef SDL_VIDEO_DRIVER_QTOPIA */ -/* #undef SDL_VIDEO_DRIVER_QUARTZ */ -/* #undef SDL_VIDEO_DRIVER_RISCOS */ -/* #undef SDL_VIDEO_DRIVER_SVGALIB */ -/* #undef SDL_VIDEO_DRIVER_TOOLBOX */ -/* #undef SDL_VIDEO_DRIVER_VGL */ -/* #undef SDL_VIDEO_DRIVER_WINDIB */ -/* #undef SDL_VIDEO_DRIVER_WSCONS */ -#define SDL_VIDEO_DRIVER_X11 1 -/* #undef SDL_VIDEO_DRIVER_X11_DGAMOUSE */ -#define SDL_VIDEO_DRIVER_X11_DPMS 1 -#define SDL_VIDEO_DRIVER_X11_DYNAMIC "libX11.so.6" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "libXext.so.6" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "libXrandr.so.2" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER "libXrender.so.1" -#define SDL_VIDEO_DRIVER_X11_VIDMODE 1 -/* #undef SDL_VIDEO_DRIVER_X11_XINERAMA */ -/* #undef SDL_VIDEO_DRIVER_X11_XME */ -#define SDL_VIDEO_DRIVER_X11_XRANDR 1 -#define SDL_VIDEO_DRIVER_X11_XV 1 -/* #undef SDL_VIDEO_DRIVER_XBIOS */ - -/* Enable OpenGL support */ -#define SDL_VIDEO_OPENGL 1 -#define SDL_VIDEO_OPENGL_GLX 1 -/* #undef SDL_VIDEO_OPENGL_WGL */ -/* #undef SDL_VIDEO_OPENGL_OSMESA */ -/* #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC */ - -/* Enable assembly routines */ -#define SDL_ASSEMBLY_ROUTINES 1 -/* #undef SDL_HERMES_BLITTERS */ -/* #undef SDL_ALTIVEC_BLITTERS */ - -#endif /* _SDL_config_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_cpuinfo.h spring-98.0~14.04~ppa6/include/SDL/SDL_cpuinfo.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_cpuinfo.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_cpuinfo.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* CPU feature detection for SDL */ - -#ifndef _SDL_cpuinfo_h -#define _SDL_cpuinfo_h - -#include "SDL_stdinc.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* This function returns true if the CPU has the RDTSC instruction - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void); - -/* This function returns true if the CPU has MMX features - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void); - -/* This function returns true if the CPU has MMX Ext. features - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasMMXExt(void); - -/* This function returns true if the CPU has 3DNow features - */ -extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void); - -/* This function returns true if the CPU has 3DNow! Ext. features - */ -extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNowExt(void); - -/* This function returns true if the CPU has SSE features - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void); - -/* This function returns true if the CPU has SSE2 features - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void); - -/* This function returns true if the CPU has AltiVec features - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_cpuinfo_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_endian.h spring-98.0~14.04~ppa6/include/SDL/SDL_endian.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_endian.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_endian.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,194 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* Functions for reading and writing endian-specific values */ - -#ifndef _SDL_endian_h -#define _SDL_endian_h - -#include "SDL_stdinc.h" - -/* The two types of endianness */ -#define SDL_LIL_ENDIAN 1234 -#define SDL_BIG_ENDIAN 4321 - -#ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */ -#if defined(__hppa__) || \ - defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ - (defined(__MIPS__) && defined(__MISPEB__)) || \ - defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \ - defined(__sparc__) -#define SDL_BYTEORDER SDL_BIG_ENDIAN -#else -#define SDL_BYTEORDER SDL_LIL_ENDIAN -#endif -#endif /* !SDL_BYTEORDER */ - - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* Use inline functions for compilers that support them, and static - functions for those that do not. Because these functions become - static for compilers that do not support inline functions, this - header should only be included in files that actually use them. -*/ -#if defined(__GNUC__) && defined(__i386__) && \ - !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) -static __inline__ Uint16 SDL_Swap16(Uint16 x) -{ - __asm__("xchgb %b0,%h0" : "=q" (x) : "0" (x)); - return x; -} -#elif defined(__GNUC__) && defined(__x86_64__) -static __inline__ Uint16 SDL_Swap16(Uint16 x) -{ - __asm__("xchgb %b0,%h0" : "=Q" (x) : "0" (x)); - return x; -} -#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) -static __inline__ Uint16 SDL_Swap16(Uint16 x) -{ - Uint16 result; - - __asm__("rlwimi %0,%2,8,16,23" : "=&r" (result) : "0" (x >> 8), "r" (x)); - return result; -} -#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) -static __inline__ Uint16 SDL_Swap16(Uint16 x) -{ - __asm__("rorw #8,%0" : "=d" (x) : "0" (x) : "cc"); - return x; -} -#else -static __inline__ Uint16 SDL_Swap16(Uint16 x) { - return((x<<8)|(x>>8)); -} -#endif - -#if defined(__GNUC__) && defined(__i386__) && \ - !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) -static __inline__ Uint32 SDL_Swap32(Uint32 x) -{ - __asm__("bswap %0" : "=r" (x) : "0" (x)); - return x; -} -#elif defined(__GNUC__) && defined(__x86_64__) -static __inline__ Uint32 SDL_Swap32(Uint32 x) -{ - __asm__("bswapl %0" : "=r" (x) : "0" (x)); - return x; -} -#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) -static __inline__ Uint32 SDL_Swap32(Uint32 x) -{ - Uint32 result; - - __asm__("rlwimi %0,%2,24,16,23" : "=&r" (result) : "0" (x>>24), "r" (x)); - __asm__("rlwimi %0,%2,8,8,15" : "=&r" (result) : "0" (result), "r" (x)); - __asm__("rlwimi %0,%2,24,0,7" : "=&r" (result) : "0" (result), "r" (x)); - return result; -} -#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) -static __inline__ Uint32 SDL_Swap32(Uint32 x) -{ - __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0" : "=d" (x) : "0" (x) : "cc"); - return x; -} -#else -static __inline__ Uint32 SDL_Swap32(Uint32 x) { - return((x<<24)|((x<<8)&0x00FF0000)|((x>>8)&0x0000FF00)|(x>>24)); -} -#endif - -#ifdef SDL_HAS_64BIT_TYPE -#if defined(__GNUC__) && defined(__i386__) && \ - !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) -static __inline__ Uint64 SDL_Swap64(Uint64 x) -{ - union { - struct { Uint32 a,b; } s; - Uint64 u; - } v; - v.u = x; - __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1" - : "=r" (v.s.a), "=r" (v.s.b) - : "0" (v.s.a), "1" (v.s.b)); - return v.u; -} -#elif defined(__GNUC__) && defined(__x86_64__) -static __inline__ Uint64 SDL_Swap64(Uint64 x) -{ - __asm__("bswapq %0" : "=r" (x) : "0" (x)); - return x; -} -#else -static __inline__ Uint64 SDL_Swap64(Uint64 x) -{ - Uint32 hi, lo; - - /* Separate into high and low 32-bit values and swap them */ - lo = (Uint32)(x&0xFFFFFFFF); - x >>= 32; - hi = (Uint32)(x&0xFFFFFFFF); - x = SDL_Swap32(lo); - x <<= 32; - x |= SDL_Swap32(hi); - return(x); -} -#endif -#else -/* This is mainly to keep compilers from complaining in SDL code. - If there is no real 64-bit datatype, then compilers will complain about - the fake 64-bit datatype that SDL provides when it compiles user code. -*/ -#define SDL_Swap64(X) (X) -#endif /* SDL_HAS_64BIT_TYPE */ - - -/* Byteswap item from the specified endianness to the native endianness */ -#if SDL_BYTEORDER == SDL_LIL_ENDIAN -#define SDL_SwapLE16(X) (X) -#define SDL_SwapLE32(X) (X) -#define SDL_SwapLE64(X) (X) -#define SDL_SwapBE16(X) SDL_Swap16(X) -#define SDL_SwapBE32(X) SDL_Swap32(X) -#define SDL_SwapBE64(X) SDL_Swap64(X) -#else -#define SDL_SwapLE16(X) SDL_Swap16(X) -#define SDL_SwapLE32(X) SDL_Swap32(X) -#define SDL_SwapLE64(X) SDL_Swap64(X) -#define SDL_SwapBE16(X) (X) -#define SDL_SwapBE32(X) (X) -#define SDL_SwapBE64(X) (X) -#endif - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_endian_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_error.h spring-98.0~14.04~ppa6/include/SDL/SDL_error.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_error.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_error.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* Simple error message routines for SDL */ - -#ifndef _SDL_error_h -#define _SDL_error_h - -#include "SDL_stdinc.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* Public functions */ -extern DECLSPEC void SDLCALL SDL_SetError(const char *fmt, ...); -extern DECLSPEC char * SDLCALL SDL_GetError(void); -extern DECLSPEC void SDLCALL SDL_ClearError(void); - -/* Private error message function - used internally */ -#define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) -#define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) -typedef enum { - SDL_ENOMEM, - SDL_EFREAD, - SDL_EFWRITE, - SDL_EFSEEK, - SDL_UNSUPPORTED, - SDL_LASTERROR -} SDL_errorcode; -extern DECLSPEC void SDLCALL SDL_Error(SDL_errorcode code); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_error_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_events.h spring-98.0~14.04~ppa6/include/SDL/SDL_events.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_events.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_events.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,337 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* Include file for SDL event handling */ - -#ifndef _SDL_events_h -#define _SDL_events_h - -#include "SDL_stdinc.h" -#include "SDL_error.h" -#include "SDL_active.h" -#include "SDL_keyboard.h" -#include "SDL_mouse.h" -#include "SDL_joystick.h" -#include "SDL_quit.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* General keyboard/mouse state definitions */ -#define SDL_RELEASED 0 -#define SDL_PRESSED 1 - -/* Event enumerations */ -typedef enum { - SDL_NOEVENT = 0, /* Unused (do not remove) */ - SDL_ACTIVEEVENT, /* Application loses/gains visibility */ - SDL_KEYDOWN, /* Keys pressed */ - SDL_KEYUP, /* Keys released */ - SDL_MOUSEMOTION, /* Mouse moved */ - SDL_MOUSEBUTTONDOWN, /* Mouse button pressed */ - SDL_MOUSEBUTTONUP, /* Mouse button released */ - SDL_JOYAXISMOTION, /* Joystick axis motion */ - SDL_JOYBALLMOTION, /* Joystick trackball motion */ - SDL_JOYHATMOTION, /* Joystick hat position change */ - SDL_JOYBUTTONDOWN, /* Joystick button pressed */ - SDL_JOYBUTTONUP, /* Joystick button released */ - SDL_QUIT, /* User-requested quit */ - SDL_SYSWMEVENT, /* System specific event */ - SDL_EVENT_RESERVEDA, /* Reserved for future use.. */ - SDL_EVENT_RESERVEDB, /* Reserved for future use.. */ - SDL_VIDEORESIZE, /* User resized video mode */ - SDL_VIDEOEXPOSE, /* Screen needs to be redrawn */ - SDL_EVENT_RESERVED2, /* Reserved for future use.. */ - SDL_EVENT_RESERVED3, /* Reserved for future use.. */ - SDL_EVENT_RESERVED4, /* Reserved for future use.. */ - SDL_EVENT_RESERVED5, /* Reserved for future use.. */ - SDL_EVENT_RESERVED6, /* Reserved for future use.. */ - SDL_EVENT_RESERVED7, /* Reserved for future use.. */ - /* Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use */ - SDL_USEREVENT = 24, - /* This last event is only for bounding internal arrays - It is the number of bits in the event mask datatype -- Uint32 - */ - SDL_NUMEVENTS = 32 -} SDL_EventType; - -/* Predefined event masks */ -#define SDL_EVENTMASK(X) (1<<(X)) -typedef enum { - SDL_ACTIVEEVENTMASK = SDL_EVENTMASK(SDL_ACTIVEEVENT), - SDL_KEYDOWNMASK = SDL_EVENTMASK(SDL_KEYDOWN), - SDL_KEYUPMASK = SDL_EVENTMASK(SDL_KEYUP), - SDL_KEYEVENTMASK = SDL_EVENTMASK(SDL_KEYDOWN)| - SDL_EVENTMASK(SDL_KEYUP), - SDL_MOUSEMOTIONMASK = SDL_EVENTMASK(SDL_MOUSEMOTION), - SDL_MOUSEBUTTONDOWNMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN), - SDL_MOUSEBUTTONUPMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONUP), - SDL_MOUSEEVENTMASK = SDL_EVENTMASK(SDL_MOUSEMOTION)| - SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN)| - SDL_EVENTMASK(SDL_MOUSEBUTTONUP), - SDL_JOYAXISMOTIONMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION), - SDL_JOYBALLMOTIONMASK = SDL_EVENTMASK(SDL_JOYBALLMOTION), - SDL_JOYHATMOTIONMASK = SDL_EVENTMASK(SDL_JOYHATMOTION), - SDL_JOYBUTTONDOWNMASK = SDL_EVENTMASK(SDL_JOYBUTTONDOWN), - SDL_JOYBUTTONUPMASK = SDL_EVENTMASK(SDL_JOYBUTTONUP), - SDL_JOYEVENTMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION)| - SDL_EVENTMASK(SDL_JOYBALLMOTION)| - SDL_EVENTMASK(SDL_JOYHATMOTION)| - SDL_EVENTMASK(SDL_JOYBUTTONDOWN)| - SDL_EVENTMASK(SDL_JOYBUTTONUP), - SDL_VIDEORESIZEMASK = SDL_EVENTMASK(SDL_VIDEORESIZE), - SDL_VIDEOEXPOSEMASK = SDL_EVENTMASK(SDL_VIDEOEXPOSE), - SDL_QUITMASK = SDL_EVENTMASK(SDL_QUIT), - SDL_SYSWMEVENTMASK = SDL_EVENTMASK(SDL_SYSWMEVENT) -} SDL_EventMask ; -#define SDL_ALLEVENTS 0xFFFFFFFF - -/* Application visibility event structure */ -typedef struct SDL_ActiveEvent { - Uint8 type; /* SDL_ACTIVEEVENT */ - Uint8 gain; /* Whether given states were gained or lost (1/0) */ - Uint8 state; /* A mask of the focus states */ -} SDL_ActiveEvent; - -/* Keyboard event structure */ -typedef struct SDL_KeyboardEvent { - Uint8 type; /* SDL_KEYDOWN or SDL_KEYUP */ - Uint8 which; /* The keyboard device index */ - Uint8 state; /* SDL_PRESSED or SDL_RELEASED */ - SDL_keysym keysym; -} SDL_KeyboardEvent; - -/* Mouse motion event structure */ -typedef struct SDL_MouseMotionEvent { - Uint8 type; /* SDL_MOUSEMOTION */ - Uint8 which; /* The mouse device index */ - Uint8 state; /* The current button state */ - Uint16 x, y; /* The X/Y coordinates of the mouse */ - Sint16 xrel; /* The relative motion in the X direction */ - Sint16 yrel; /* The relative motion in the Y direction */ -} SDL_MouseMotionEvent; - -/* Mouse button event structure */ -typedef struct SDL_MouseButtonEvent { - Uint8 type; /* SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */ - Uint8 which; /* The mouse device index */ - Uint8 button; /* The mouse button index */ - Uint8 state; /* SDL_PRESSED or SDL_RELEASED */ - Uint16 x, y; /* The X/Y coordinates of the mouse at press time */ -} SDL_MouseButtonEvent; - -/* Joystick axis motion event structure */ -typedef struct SDL_JoyAxisEvent { - Uint8 type; /* SDL_JOYAXISMOTION */ - Uint8 which; /* The joystick device index */ - Uint8 axis; /* The joystick axis index */ - Sint16 value; /* The axis value (range: -32768 to 32767) */ -} SDL_JoyAxisEvent; - -/* Joystick trackball motion event structure */ -typedef struct SDL_JoyBallEvent { - Uint8 type; /* SDL_JOYBALLMOTION */ - Uint8 which; /* The joystick device index */ - Uint8 ball; /* The joystick trackball index */ - Sint16 xrel; /* The relative motion in the X direction */ - Sint16 yrel; /* The relative motion in the Y direction */ -} SDL_JoyBallEvent; - -/* Joystick hat position change event structure */ -typedef struct SDL_JoyHatEvent { - Uint8 type; /* SDL_JOYHATMOTION */ - Uint8 which; /* The joystick device index */ - Uint8 hat; /* The joystick hat index */ - Uint8 value; /* The hat position value: - SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP - SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT - SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN - Note that zero means the POV is centered. - */ -} SDL_JoyHatEvent; - -/* Joystick button event structure */ -typedef struct SDL_JoyButtonEvent { - Uint8 type; /* SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP */ - Uint8 which; /* The joystick device index */ - Uint8 button; /* The joystick button index */ - Uint8 state; /* SDL_PRESSED or SDL_RELEASED */ -} SDL_JoyButtonEvent; - -/* The "window resized" event - When you get this event, you are responsible for setting a new video - mode with the new width and height. - */ -typedef struct SDL_ResizeEvent { - Uint8 type; /* SDL_VIDEORESIZE */ - int w; /* New width */ - int h; /* New height */ -} SDL_ResizeEvent; - -/* The "screen redraw" event */ -typedef struct SDL_ExposeEvent { - Uint8 type; /* SDL_VIDEOEXPOSE */ -} SDL_ExposeEvent; - -/* The "quit requested" event */ -typedef struct SDL_QuitEvent { - Uint8 type; /* SDL_QUIT */ -} SDL_QuitEvent; - -/* A user-defined event type */ -typedef struct SDL_UserEvent { - Uint8 type; /* SDL_USEREVENT through SDL_NUMEVENTS-1 */ - int code; /* User defined event code */ - void *data1; /* User defined data pointer */ - void *data2; /* User defined data pointer */ -} SDL_UserEvent; - -/* If you want to use this event, you should include SDL_syswm.h */ -struct SDL_SysWMmsg; -typedef struct SDL_SysWMmsg SDL_SysWMmsg; -typedef struct SDL_SysWMEvent { - Uint8 type; - SDL_SysWMmsg *msg; -} SDL_SysWMEvent; - -/* General event structure */ -typedef union SDL_Event { - Uint8 type; - SDL_ActiveEvent active; - SDL_KeyboardEvent key; - SDL_MouseMotionEvent motion; - SDL_MouseButtonEvent button; - SDL_JoyAxisEvent jaxis; - SDL_JoyBallEvent jball; - SDL_JoyHatEvent jhat; - SDL_JoyButtonEvent jbutton; - SDL_ResizeEvent resize; - SDL_ExposeEvent expose; - SDL_QuitEvent quit; - SDL_UserEvent user; - SDL_SysWMEvent syswm; -} SDL_Event; - - -/* Function prototypes */ - -/* Pumps the event loop, gathering events from the input devices. - This function updates the event queue and internal input device state. - This should only be run in the thread that sets the video mode. -*/ -extern DECLSPEC void SDLCALL SDL_PumpEvents(void); - -/* Checks the event queue for messages and optionally returns them. - If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to - the back of the event queue. - If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front - of the event queue, matching 'mask', will be returned and will not - be removed from the queue. - If 'action' is SDL_GETEVENT, up to 'numevents' events at the front - of the event queue, matching 'mask', will be returned and will be - removed from the queue. - This function returns the number of events actually stored, or -1 - if there was an error. This function is thread-safe. -*/ -typedef enum { - SDL_ADDEVENT, - SDL_PEEKEVENT, - SDL_GETEVENT -} SDL_eventaction; -/* */ -extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event *events, int numevents, - SDL_eventaction action, Uint32 mask); - -/* Polls for currently pending events, and returns 1 if there are any pending - events, or 0 if there are none available. If 'event' is not NULL, the next - event is removed from the queue and stored in that area. - */ -extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event *event); - -/* Waits indefinitely for the next available event, returning 1, or 0 if there - was an error while waiting for events. If 'event' is not NULL, the next - event is removed from the queue and stored in that area. - */ -extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event *event); - -/* Add an event to the event queue. - This function returns 0 on success, or -1 if the event queue was full - or there was some other error. - */ -extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event *event); - -/* - This function sets up a filter to process all events before they - change internal state and are posted to the internal event queue. - - The filter is protypted as: -*/ -typedef int (SDLCALL *SDL_EventFilter)(const SDL_Event *event); -/* - If the filter returns 1, then the event will be added to the internal queue. - If it returns 0, then the event will be dropped from the queue, but the - internal state will still be updated. This allows selective filtering of - dynamically arriving events. - - WARNING: Be very careful of what you do in the event filter function, as - it may run in a different thread! - - There is one caveat when dealing with the SDL_QUITEVENT event type. The - event filter is only called when the window manager desires to close the - application window. If the event filter returns 1, then the window will - be closed, otherwise the window will remain open if possible. - If the quit event is generated by an interrupt signal, it will bypass the - internal queue and be delivered to the application at the next event poll. -*/ -extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter); - -/* - Return the current event filter - can be used to "chain" filters. - If there is no event filter set, this function returns NULL. -*/ -extern DECLSPEC SDL_EventFilter SDLCALL SDL_GetEventFilter(void); - -/* - This function allows you to set the state of processing certain events. - If 'state' is set to SDL_IGNORE, that event will be automatically dropped - from the event queue and will not event be filtered. - If 'state' is set to SDL_ENABLE, that event will be processed normally. - If 'state' is set to SDL_QUERY, SDL_EventState() will return the - current processing state of the specified event. -*/ -#define SDL_QUERY -1 -#define SDL_IGNORE 0 -#define SDL_DISABLE 0 -#define SDL_ENABLE 1 -extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint8 type, int state); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_events_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_getenv.h spring-98.0~14.04~ppa6/include/SDL/SDL_getenv.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_getenv.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_getenv.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* DEPRECATED */ -#include "SDL_stdinc.h" diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL.h spring-98.0~14.04~ppa6/include/SDL/SDL.h --- spring-96.0~14.04~ppa4/include/SDL/SDL.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* Main include header for the SDL library */ - -#ifndef _SDL_H -#define _SDL_H - -#include "SDL_main.h" -#include "SDL_stdinc.h" -#include "SDL_audio.h" -#include "SDL_cdrom.h" -#include "SDL_cpuinfo.h" -#include "SDL_endian.h" -#include "SDL_error.h" -#include "SDL_events.h" -#include "SDL_loadso.h" -#include "SDL_mutex.h" -#include "SDL_rwops.h" -#include "SDL_thread.h" -#include "SDL_timer.h" -#include "SDL_video.h" -#include "SDL_version.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* As of version 0.5, SDL is loaded dynamically into the application */ - -/* These are the flags which may be passed to SDL_Init() -- you should - specify the subsystems which you will be using in your application. -*/ -#define SDL_INIT_TIMER 0x00000001 -#define SDL_INIT_AUDIO 0x00000010 -#define SDL_INIT_VIDEO 0x00000020 -#define SDL_INIT_CDROM 0x00000100 -#define SDL_INIT_JOYSTICK 0x00000200 -#define SDL_INIT_NOPARACHUTE 0x00100000 /* Don't catch fatal signals */ -#define SDL_INIT_EVENTTHREAD 0x01000000 /* Not supported on all OS's */ -#define SDL_INIT_EVERYTHING 0x0000FFFF - -/* This function loads the SDL dynamically linked library and initializes - * the subsystems specified by 'flags' (and those satisfying dependencies) - * Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup - * signal handlers for some commonly ignored fatal signals (like SIGSEGV) - */ -extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags); - -/* This function initializes specific SDL subsystems */ -extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags); - -/* This function cleans up specific SDL subsystems */ -extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags); - -/* This function returns mask of the specified subsystems which have - been initialized. - If 'flags' is 0, it returns a mask of all initialized subsystems. -*/ -extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags); - -/* This function cleans up all initialized subsystems and unloads the - * dynamically linked library. You should call it upon all exit conditions. - */ -extern DECLSPEC void SDLCALL SDL_Quit(void); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_H */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_joystick.h spring-98.0~14.04~ppa6/include/SDL/SDL_joystick.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_joystick.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_joystick.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,167 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* Include file for SDL joystick event handling */ - -#ifndef _SDL_joystick_h -#define _SDL_joystick_h - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* In order to use these functions, SDL_Init() must have been called - with the SDL_INIT_JOYSTICK flag. This causes SDL to scan the system - for joysticks, and load appropriate drivers. -*/ - -/* The joystick structure used to identify an SDL joystick */ -struct _SDL_Joystick; -typedef struct _SDL_Joystick SDL_Joystick; - - -/* Function prototypes */ -/* - * Count the number of joysticks attached to the system - */ -extern DECLSPEC int SDLCALL SDL_NumJoysticks(void); - -/* - * Get the implementation dependent name of a joystick. - * This can be called before any joysticks are opened. - * If no name can be found, this function returns NULL. - */ -extern DECLSPEC const char * SDLCALL SDL_JoystickName(int device_index); - -/* - * Open a joystick for use - the index passed as an argument refers to - * the N'th joystick on the system. This index is the value which will - * identify this joystick in future joystick events. - * - * This function returns a joystick identifier, or NULL if an error occurred. - */ -extern DECLSPEC SDL_Joystick * SDLCALL SDL_JoystickOpen(int device_index); - -/* - * Returns 1 if the joystick has been opened, or 0 if it has not. - */ -extern DECLSPEC int SDLCALL SDL_JoystickOpened(int device_index); - -/* - * Get the device index of an opened joystick. - */ -extern DECLSPEC int SDLCALL SDL_JoystickIndex(SDL_Joystick *joystick); - -/* - * Get the number of general axis controls on a joystick - */ -extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick *joystick); - -/* - * Get the number of trackballs on a joystick - * Joystick trackballs have only relative motion events associated - * with them and their state cannot be polled. - */ -extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick *joystick); - -/* - * Get the number of POV hats on a joystick - */ -extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick *joystick); - -/* - * Get the number of buttons on a joystick - */ -extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick *joystick); - -/* - * Update the current state of the open joysticks. - * This is called automatically by the event loop if any joystick - * events are enabled. - */ -extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void); - -/* - * Enable/disable joystick event polling. - * If joystick events are disabled, you must call SDL_JoystickUpdate() - * yourself and check the state of the joystick when you want joystick - * information. - * The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE. - */ -extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state); - -/* - * Get the current state of an axis control on a joystick - * The state is a value ranging from -32768 to 32767. - * The axis indices start at index 0. - */ -extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis); - -/* - * Get the current state of a POV hat on a joystick - * The return value is one of the following positions: - */ -#define SDL_HAT_CENTERED 0x00 -#define SDL_HAT_UP 0x01 -#define SDL_HAT_RIGHT 0x02 -#define SDL_HAT_DOWN 0x04 -#define SDL_HAT_LEFT 0x08 -#define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP) -#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN) -#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP) -#define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN) -/* - * The hat indices start at index 0. - */ -extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick, int hat); - -/* - * Get the ball axis change since the last poll - * This returns 0, or -1 if you passed it invalid parameters. - * The ball indices start at index 0. - */ -extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy); - -/* - * Get the current state of a button on a joystick - * The button indices start at index 0. - */ -extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick *joystick, int button); - -/* - * Close a joystick previously opened with SDL_JoystickOpen() - */ -extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick *joystick); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_joystick_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_keyboard.h spring-98.0~14.04~ppa6/include/SDL/SDL_keyboard.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_keyboard.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_keyboard.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* Include file for SDL keyboard event handling */ - -#ifndef _SDL_keyboard_h -#define _SDL_keyboard_h - -#include "SDL_stdinc.h" -#include "SDL_error.h" -#include "SDL_keysym.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* Keysym structure - - The scancode is hardware dependent, and should not be used by general - applications. If no hardware scancode is available, it will be 0. - - - The 'unicode' translated character is only available when character - translation is enabled by the SDL_EnableUNICODE() API. If non-zero, - this is a UNICODE character corresponding to the keypress. If the - high 9 bits of the character are 0, then this maps to the equivalent - ASCII character: - char ch; - if ( (keysym.unicode & 0xFF80) == 0 ) { - ch = keysym.unicode & 0x7F; - } else { - An international character.. - } - */ -typedef struct SDL_keysym { - Uint8 scancode; /* hardware specific scancode */ - SDLKey sym; /* SDL virtual keysym */ - SDLMod mod; /* current key modifiers */ - Uint16 unicode; /* translated character */ -} SDL_keysym; - -/* This is the mask which refers to all hotkey bindings */ -#define SDL_ALL_HOTKEYS 0xFFFFFFFF - -/* Function prototypes */ -/* - * Enable/Disable UNICODE translation of keyboard input. - * This translation has some overhead, so translation defaults off. - * If 'enable' is 1, translation is enabled. - * If 'enable' is 0, translation is disabled. - * If 'enable' is -1, the translation state is not changed. - * It returns the previous state of keyboard translation. - */ -extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable); - -/* - * Enable/Disable keyboard repeat. Keyboard repeat defaults to off. - * 'delay' is the initial delay in ms between the time when a key is - * pressed, and keyboard repeat begins. - * 'interval' is the time in ms between keyboard repeat events. - */ -#define SDL_DEFAULT_REPEAT_DELAY 500 -#define SDL_DEFAULT_REPEAT_INTERVAL 30 -/* - * If 'delay' is set to 0, keyboard repeat is disabled. - */ -extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval); -extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval); - -/* - * Get a snapshot of the current state of the keyboard. - * Returns an array of keystates, indexed by the SDLK_* syms. - * Used: - * Uint8 *keystate = SDL_GetKeyState(NULL); - * if ( keystate[SDLK_RETURN] ) ... is pressed. - */ -extern DECLSPEC Uint8 * SDLCALL SDL_GetKeyState(int *numkeys); - -/* - * Get the current key modifier state - */ -extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void); - -/* - * Set the current key modifier state - * This does not change the keyboard state, only the key modifier flags. - */ -extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate); - -/* - * Get the name of an SDL virtual keysym - */ -extern DECLSPEC char * SDLCALL SDL_GetKeyName(SDLKey key); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_keyboard_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_keysym.h spring-98.0~14.04~ppa6/include/SDL/SDL_keysym.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_keysym.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_keysym.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,311 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -#ifndef _SDL_keysym_h -#define _SDL_keysym_h - -/* What we really want is a mapping of every raw key on the keyboard. - To support international keyboards, we use the range 0xA1 - 0xFF - as international virtual keycodes. We'll follow in the footsteps of X11... - The names of the keys - */ - -typedef enum { - /* The keyboard syms have been cleverly chosen to map to ASCII */ - SDLK_UNKNOWN = 0, - SDLK_FIRST = 0, - SDLK_BACKSPACE = 8, - SDLK_TAB = 9, - SDLK_CLEAR = 12, - SDLK_RETURN = 13, - SDLK_PAUSE = 19, - SDLK_ESCAPE = 27, - SDLK_SPACE = 32, - SDLK_EXCLAIM = 33, - SDLK_QUOTEDBL = 34, - SDLK_HASH = 35, - SDLK_DOLLAR = 36, - SDLK_AMPERSAND = 38, - SDLK_QUOTE = 39, - SDLK_LEFTPAREN = 40, - SDLK_RIGHTPAREN = 41, - SDLK_ASTERISK = 42, - SDLK_PLUS = 43, - SDLK_COMMA = 44, - SDLK_MINUS = 45, - SDLK_PERIOD = 46, - SDLK_SLASH = 47, - SDLK_0 = 48, - SDLK_1 = 49, - SDLK_2 = 50, - SDLK_3 = 51, - SDLK_4 = 52, - SDLK_5 = 53, - SDLK_6 = 54, - SDLK_7 = 55, - SDLK_8 = 56, - SDLK_9 = 57, - SDLK_COLON = 58, - SDLK_SEMICOLON = 59, - SDLK_LESS = 60, - SDLK_EQUALS = 61, - SDLK_GREATER = 62, - SDLK_QUESTION = 63, - SDLK_AT = 64, - /* - Skip uppercase letters - */ - SDLK_LEFTBRACKET = 91, - SDLK_BACKSLASH = 92, - SDLK_RIGHTBRACKET = 93, - SDLK_CARET = 94, - SDLK_UNDERSCORE = 95, - SDLK_BACKQUOTE = 96, - SDLK_a = 97, - SDLK_b = 98, - SDLK_c = 99, - SDLK_d = 100, - SDLK_e = 101, - SDLK_f = 102, - SDLK_g = 103, - SDLK_h = 104, - SDLK_i = 105, - SDLK_j = 106, - SDLK_k = 107, - SDLK_l = 108, - SDLK_m = 109, - SDLK_n = 110, - SDLK_o = 111, - SDLK_p = 112, - SDLK_q = 113, - SDLK_r = 114, - SDLK_s = 115, - SDLK_t = 116, - SDLK_u = 117, - SDLK_v = 118, - SDLK_w = 119, - SDLK_x = 120, - SDLK_y = 121, - SDLK_z = 122, - SDLK_DELETE = 127, - /* End of ASCII mapped keysyms */ - - /* International keyboard syms */ - SDLK_WORLD_0 = 160, /* 0xA0 */ - SDLK_WORLD_1 = 161, - SDLK_WORLD_2 = 162, - SDLK_WORLD_3 = 163, - SDLK_WORLD_4 = 164, - SDLK_WORLD_5 = 165, - SDLK_WORLD_6 = 166, - SDLK_WORLD_7 = 167, - SDLK_WORLD_8 = 168, - SDLK_WORLD_9 = 169, - SDLK_WORLD_10 = 170, - SDLK_WORLD_11 = 171, - SDLK_WORLD_12 = 172, - SDLK_WORLD_13 = 173, - SDLK_WORLD_14 = 174, - SDLK_WORLD_15 = 175, - SDLK_WORLD_16 = 176, - SDLK_WORLD_17 = 177, - SDLK_WORLD_18 = 178, - SDLK_WORLD_19 = 179, - SDLK_WORLD_20 = 180, - SDLK_WORLD_21 = 181, - SDLK_WORLD_22 = 182, - SDLK_WORLD_23 = 183, - SDLK_WORLD_24 = 184, - SDLK_WORLD_25 = 185, - SDLK_WORLD_26 = 186, - SDLK_WORLD_27 = 187, - SDLK_WORLD_28 = 188, - SDLK_WORLD_29 = 189, - SDLK_WORLD_30 = 190, - SDLK_WORLD_31 = 191, - SDLK_WORLD_32 = 192, - SDLK_WORLD_33 = 193, - SDLK_WORLD_34 = 194, - SDLK_WORLD_35 = 195, - SDLK_WORLD_36 = 196, - SDLK_WORLD_37 = 197, - SDLK_WORLD_38 = 198, - SDLK_WORLD_39 = 199, - SDLK_WORLD_40 = 200, - SDLK_WORLD_41 = 201, - SDLK_WORLD_42 = 202, - SDLK_WORLD_43 = 203, - SDLK_WORLD_44 = 204, - SDLK_WORLD_45 = 205, - SDLK_WORLD_46 = 206, - SDLK_WORLD_47 = 207, - SDLK_WORLD_48 = 208, - SDLK_WORLD_49 = 209, - SDLK_WORLD_50 = 210, - SDLK_WORLD_51 = 211, - SDLK_WORLD_52 = 212, - SDLK_WORLD_53 = 213, - SDLK_WORLD_54 = 214, - SDLK_WORLD_55 = 215, - SDLK_WORLD_56 = 216, - SDLK_WORLD_57 = 217, - SDLK_WORLD_58 = 218, - SDLK_WORLD_59 = 219, - SDLK_WORLD_60 = 220, - SDLK_WORLD_61 = 221, - SDLK_WORLD_62 = 222, - SDLK_WORLD_63 = 223, - SDLK_WORLD_64 = 224, - SDLK_WORLD_65 = 225, - SDLK_WORLD_66 = 226, - SDLK_WORLD_67 = 227, - SDLK_WORLD_68 = 228, - SDLK_WORLD_69 = 229, - SDLK_WORLD_70 = 230, - SDLK_WORLD_71 = 231, - SDLK_WORLD_72 = 232, - SDLK_WORLD_73 = 233, - SDLK_WORLD_74 = 234, - SDLK_WORLD_75 = 235, - SDLK_WORLD_76 = 236, - SDLK_WORLD_77 = 237, - SDLK_WORLD_78 = 238, - SDLK_WORLD_79 = 239, - SDLK_WORLD_80 = 240, - SDLK_WORLD_81 = 241, - SDLK_WORLD_82 = 242, - SDLK_WORLD_83 = 243, - SDLK_WORLD_84 = 244, - SDLK_WORLD_85 = 245, - SDLK_WORLD_86 = 246, - SDLK_WORLD_87 = 247, - SDLK_WORLD_88 = 248, - SDLK_WORLD_89 = 249, - SDLK_WORLD_90 = 250, - SDLK_WORLD_91 = 251, - SDLK_WORLD_92 = 252, - SDLK_WORLD_93 = 253, - SDLK_WORLD_94 = 254, - SDLK_WORLD_95 = 255, /* 0xFF */ - - /* Numeric keypad */ - SDLK_KP0 = 256, - SDLK_KP1 = 257, - SDLK_KP2 = 258, - SDLK_KP3 = 259, - SDLK_KP4 = 260, - SDLK_KP5 = 261, - SDLK_KP6 = 262, - SDLK_KP7 = 263, - SDLK_KP8 = 264, - SDLK_KP9 = 265, - SDLK_KP_PERIOD = 266, - SDLK_KP_DIVIDE = 267, - SDLK_KP_MULTIPLY = 268, - SDLK_KP_MINUS = 269, - SDLK_KP_PLUS = 270, - SDLK_KP_ENTER = 271, - SDLK_KP_EQUALS = 272, - - /* Arrows + Home/End pad */ - SDLK_UP = 273, - SDLK_DOWN = 274, - SDLK_RIGHT = 275, - SDLK_LEFT = 276, - SDLK_INSERT = 277, - SDLK_HOME = 278, - SDLK_END = 279, - SDLK_PAGEUP = 280, - SDLK_PAGEDOWN = 281, - - /* Function keys */ - SDLK_F1 = 282, - SDLK_F2 = 283, - SDLK_F3 = 284, - SDLK_F4 = 285, - SDLK_F5 = 286, - SDLK_F6 = 287, - SDLK_F7 = 288, - SDLK_F8 = 289, - SDLK_F9 = 290, - SDLK_F10 = 291, - SDLK_F11 = 292, - SDLK_F12 = 293, - SDLK_F13 = 294, - SDLK_F14 = 295, - SDLK_F15 = 296, - - /* Key state modifier keys */ - SDLK_NUMLOCK = 300, - SDLK_CAPSLOCK = 301, - SDLK_SCROLLOCK = 302, - SDLK_RSHIFT = 303, - SDLK_LSHIFT = 304, - SDLK_RCTRL = 305, - SDLK_LCTRL = 306, - SDLK_RALT = 307, - SDLK_LALT = 308, - SDLK_RMETA = 309, - SDLK_LMETA = 310, - SDLK_LSUPER = 311, /* Left "Windows" key */ - SDLK_RSUPER = 312, /* Right "Windows" key */ - SDLK_MODE = 313, /* "Alt Gr" key */ - SDLK_COMPOSE = 314, /* Multi-key compose key */ - - /* Miscellaneous function keys */ - SDLK_HELP = 315, - SDLK_PRINT = 316, - SDLK_SYSREQ = 317, - SDLK_BREAK = 318, - SDLK_MENU = 319, - SDLK_POWER = 320, /* Power Macintosh power key */ - SDLK_EURO = 321, /* Some european keyboards */ - SDLK_UNDO = 322, /* Atari keyboard has Undo */ - - /* Add any other keys here */ - - SDLK_LAST -} SDLKey; - -/* Enumeration of valid key mods (possibly OR'd together) */ -typedef enum { - KMOD_NONE = 0x0000, - KMOD_LSHIFT= 0x0001, - KMOD_RSHIFT= 0x0002, - KMOD_LCTRL = 0x0040, - KMOD_RCTRL = 0x0080, - KMOD_LALT = 0x0100, - KMOD_RALT = 0x0200, - KMOD_LMETA = 0x0400, - KMOD_RMETA = 0x0800, - KMOD_NUM = 0x1000, - KMOD_CAPS = 0x2000, - KMOD_MODE = 0x4000, - KMOD_RESERVED = 0x8000 -} SDLMod; - -#define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL) -#define KMOD_SHIFT (KMOD_LSHIFT|KMOD_RSHIFT) -#define KMOD_ALT (KMOD_LALT|KMOD_RALT) -#define KMOD_META (KMOD_LMETA|KMOD_RMETA) - -#endif /* _SDL_keysym_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_loadso.h spring-98.0~14.04~ppa6/include/SDL/SDL_loadso.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_loadso.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_loadso.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* System dependent library loading routines */ - -/* Some things to keep in mind: - - These functions only work on C function names. Other languages may - have name mangling and intrinsic language support that varies from - compiler to compiler. - - Make sure you declare your function pointers with the same calling - convention as the actual library function. Your code will crash - mysteriously if you do not do this. - - Avoid namespace collisions. If you load a symbol from the library, - it is not defined whether or not it goes into the global symbol - namespace for the application. If it does and it conflicts with - symbols in your code or other shared libraries, you will not get - the results you expect. :) -*/ - - -#ifndef _SDL_loadso_h -#define _SDL_loadso_h - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* This function dynamically loads a shared object and returns a pointer - * to the object handle (or NULL if there was an error). - * The 'sofile' parameter is a system dependent name of the object file. - */ -extern DECLSPEC void * SDLCALL SDL_LoadObject(const char *sofile); - -/* Given an object handle, this function looks up the address of the - * named function in the shared object and returns it. This address - * is no longer valid after calling SDL_UnloadObject(). - */ -extern DECLSPEC void * SDLCALL SDL_LoadFunction(void *handle, const char *name); - -/* Unload a shared object from memory */ -extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_loadso_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_main.h spring-98.0~14.04~ppa6/include/SDL/SDL_main.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_main.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_main.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -#ifndef _SDL_main_h -#define _SDL_main_h - -#include "SDL_stdinc.h" - -/* Redefine main() on Win32 and MacOS so that it is called by winmain.c */ - -#if defined(__WIN32__) || \ - (defined(__MWERKS__) && !defined(__BEOS__)) || \ - defined(__MACOS__) || defined(__MACOSX__) || \ - defined(__SYMBIAN32__) || defined(QWS) - -#ifdef __cplusplus -#define C_LINKAGE "C" -#else -#define C_LINKAGE -#endif /* __cplusplus */ - -/* The application's main() function must be called with C linkage, - and should be declared like this: -#ifdef __cplusplus -extern "C" -#endif - int main(int argc, char *argv[]) - { - } - */ -#define main SDL_main - -/* The prototype for the application's main() function */ -extern C_LINKAGE int SDL_main(int argc, char *argv[]); - - -/* From the SDL library code -- needed for registering the app on Win32 */ -#ifdef __WIN32__ - -#include "begin_code.h" -#ifdef __cplusplus -extern "C" { -#endif - -/* This should be called from your WinMain() function, if any */ -extern DECLSPEC void SDLCALL SDL_SetModuleHandle(void *hInst); -/* This can also be called, but is no longer necessary */ -extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst); -/* This can also be called, but is no longer necessary (SDL_Quit calls it) */ -extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); -#ifdef __cplusplus -} -#endif -#include "close_code.h" -#endif - -/* From the SDL library code -- needed for registering QuickDraw on MacOS */ -#if defined(__MACOS__) - -#include "begin_code.h" -#ifdef __cplusplus -extern "C" { -#endif - -/* Forward declaration so we don't need to include QuickDraw.h */ -struct QDGlobals; - -/* This should be called from your main() function, if any */ -extern DECLSPEC void SDLCALL SDL_InitQuickDraw(struct QDGlobals *the_qd); - -#ifdef __cplusplus -} -#endif -#include "close_code.h" -#endif - -#endif /* Need to redefine main()? */ - -#endif /* _SDL_main_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_mouse.h spring-98.0~14.04~ppa6/include/SDL/SDL_mouse.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_mouse.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_mouse.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,140 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* Include file for SDL mouse event handling */ - -#ifndef _SDL_mouse_h -#define _SDL_mouse_h - -#include "SDL_stdinc.h" -#include "SDL_error.h" -#include "SDL_video.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct WMcursor WMcursor; /* Implementation dependent */ -typedef struct SDL_Cursor { - SDL_Rect area; /* The area of the mouse cursor */ - Sint16 hot_x, hot_y; /* The "tip" of the cursor */ - Uint8 *data; /* B/W cursor data */ - Uint8 *mask; /* B/W cursor mask */ - Uint8 *save[2]; /* Place to save cursor area */ - WMcursor *wm_cursor; /* Window-manager cursor */ -} SDL_Cursor; - -/* Function prototypes */ -/* - * Retrieve the current state of the mouse. - * The current button state is returned as a button bitmask, which can - * be tested using the SDL_BUTTON(X) macros, and x and y are set to the - * current mouse cursor position. You can pass NULL for either x or y. - */ -extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y); - -/* - * Retrieve the current state of the mouse. - * The current button state is returned as a button bitmask, which can - * be tested using the SDL_BUTTON(X) macros, and x and y are set to the - * mouse deltas since the last call to SDL_GetRelativeMouseState(). - */ -extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int *x, int *y); - -/* - * Set the position of the mouse cursor (generates a mouse motion event) - */ -extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y); - -/* - * Create a cursor using the specified data and mask (in MSB format). - * The cursor width must be a multiple of 8 bits. - * - * The cursor is created in black and white according to the following: - * data mask resulting pixel on screen - * 0 1 White - * 1 1 Black - * 0 0 Transparent - * 1 0 Inverted color if possible, black if not. - * - * Cursors created with this function must be freed with SDL_FreeCursor(). - */ -extern DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor - (Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y); - -/* - * Set the currently active cursor to the specified one. - * If the cursor is currently visible, the change will be immediately - * represented on the display. - */ -extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor *cursor); - -/* - * Returns the currently active cursor. - */ -extern DECLSPEC SDL_Cursor * SDLCALL SDL_GetCursor(void); - -/* - * Deallocates a cursor created with SDL_CreateCursor(). - */ -extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor *cursor); - -/* - * Toggle whether or not the cursor is shown on the screen. - * The cursor start off displayed, but can be turned off. - * SDL_ShowCursor() returns 1 if the cursor was being displayed - * before the call, or 0 if it was not. You can query the current - * state by passing a 'toggle' value of -1. - */ -extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle); - -/* Used as a mask when testing buttons in buttonstate - Button 1: Left mouse button - Button 2: Middle mouse button - Button 3: Right mouse button - Button 4: Mouse wheel up (may also be a real button) - Button 5: Mouse wheel down (may also be a real button) - */ -#define SDL_BUTTON(X) (1 << ((X)-1)) -#define SDL_BUTTON_LEFT 1 -#define SDL_BUTTON_MIDDLE 2 -#define SDL_BUTTON_RIGHT 3 -#define SDL_BUTTON_WHEELUP 4 -#define SDL_BUTTON_WHEELDOWN 5 -#define SDL_BUTTON_X1 6 -#define SDL_BUTTON_X2 7 -#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT) -#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE) -#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT) -#define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1) -#define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2) - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_mouse_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_mutex.h spring-98.0~14.04~ppa6/include/SDL/SDL_mutex.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_mutex.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_mutex.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,162 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -#ifndef _SDL_mutex_h -#define _SDL_mutex_h - -/* Functions to provide thread synchronization primitives - - These are independent of the other SDL routines. -*/ - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* Synchronization functions which can time out return this value - if they time out. -*/ -#define SDL_MUTEX_TIMEDOUT 1 - -/* This is the timeout value which corresponds to never time out */ -#define SDL_MUTEX_MAXWAIT (~(Uint32)0) - - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Mutex functions */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* The SDL mutex structure, defined in SDL_mutex.c */ -struct SDL_mutex; -typedef struct SDL_mutex SDL_mutex; - -/* Create a mutex, initialized unlocked */ -extern DECLSPEC SDL_mutex * SDLCALL SDL_CreateMutex(void); - -/* Lock the mutex (Returns 0, or -1 on error) */ -#define SDL_LockMutex(m) SDL_mutexP(m) -extern DECLSPEC int SDLCALL SDL_mutexP(SDL_mutex *mutex); - -/* Unlock the mutex (Returns 0, or -1 on error) - It is an error to unlock a mutex that has not been locked by - the current thread, and doing so results in undefined behavior. - */ -#define SDL_UnlockMutex(m) SDL_mutexV(m) -extern DECLSPEC int SDLCALL SDL_mutexV(SDL_mutex *mutex); - -/* Destroy a mutex */ -extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex *mutex); - - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Semaphore functions */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* The SDL semaphore structure, defined in SDL_sem.c */ -struct SDL_semaphore; -typedef struct SDL_semaphore SDL_sem; - -/* Create a semaphore, initialized with value, returns NULL on failure. */ -extern DECLSPEC SDL_sem * SDLCALL SDL_CreateSemaphore(Uint32 initial_value); - -/* Destroy a semaphore */ -extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem *sem); - -/* This function suspends the calling thread until the semaphore pointed - * to by sem has a positive count. It then atomically decreases the semaphore - * count. - */ -extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem *sem); - -/* Non-blocking variant of SDL_SemWait(), returns 0 if the wait succeeds, - SDL_MUTEX_TIMEDOUT if the wait would block, and -1 on error. -*/ -extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem *sem); - -/* Variant of SDL_SemWait() with a timeout in milliseconds, returns 0 if - the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait does not succeed in - the allotted time, and -1 on error. - On some platforms this function is implemented by looping with a delay - of 1 ms, and so should be avoided if possible. -*/ -extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem *sem, Uint32 ms); - -/* Atomically increases the semaphore's count (not blocking), returns 0, - or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem *sem); - -/* Returns the current count of the semaphore */ -extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem *sem); - - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Condition variable functions */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* The SDL condition variable structure, defined in SDL_cond.c */ -struct SDL_cond; -typedef struct SDL_cond SDL_cond; - -/* Create a condition variable */ -extern DECLSPEC SDL_cond * SDLCALL SDL_CreateCond(void); - -/* Destroy a condition variable */ -extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond *cond); - -/* Restart one of the threads that are waiting on the condition variable, - returns 0 or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond *cond); - -/* Restart all threads that are waiting on the condition variable, - returns 0 or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond *cond); - -/* Wait on the condition variable, unlocking the provided mutex. - The mutex must be locked before entering this function! - The mutex is re-locked once the condition variable is signaled. - Returns 0 when it is signaled, or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond *cond, SDL_mutex *mut); - -/* Waits for at most 'ms' milliseconds, and returns 0 if the condition - variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not - signaled in the allotted time, and -1 on error. - On some platforms this function is implemented by looping with a delay - of 1 ms, and so should be avoided if possible. -*/ -extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_mutex_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_name.h spring-98.0~14.04~ppa6/include/SDL/SDL_name.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_name.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_name.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ - -#ifndef _SDLname_h_ -#define _SDLname_h_ - -#if defined(__STDC__) || defined(__cplusplus) -#define NeedFunctionPrototypes 1 -#endif - -#define SDL_NAME(X) SDL_##X - -#endif /* _SDLname_h_ */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_opengl.h spring-98.0~14.04~ppa6/include/SDL/SDL_opengl.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_opengl.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_opengl.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,6551 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* This is a simple file to encapsulate the OpenGL API headers */ - -#include "SDL_config.h" - -#ifdef __WIN32__ -#define WIN32_LEAN_AND_MEAN -#ifndef NOMINMAX -#define NOMINMAX /* Don't defined min() and max() */ -#endif -#include -#endif -#ifndef NO_SDL_GLEXT -#define __glext_h_ /* Don't let gl.h include glext.h */ -#endif -#if defined(__MACOSX__) -#include /* Header File For The OpenGL Library */ -#include /* Header File For The GLU Library */ -#elif defined(__MACOS__) -#include /* Header File For The OpenGL Library */ -#include /* Header File For The GLU Library */ -#else -#include /* Header File For The OpenGL Library */ -#include /* Header File For The GLU Library */ -#endif -#ifndef NO_SDL_GLEXT -#undef __glext_h_ -#endif - -/* This file taken from "GLext.h" from the Jeff Molofee OpenGL tutorials. - It is included here because glext.h is not available on some systems. - If you don't want this version included, simply define "NO_SDL_GLEXT" - */ -#ifndef NO_SDL_GLEXT -#if !defined(__glext_h_) && !defined(GL_GLEXT_LEGACY) -#define __glext_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: This software was created using the -** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has -** not been independently verified as being compliant with the OpenGL(R) -** version 1.2.1 Specification. -*/ - -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) -#define WIN32_LEAN_AND_MEAN 1 -#include -#endif - -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -/*************************************************************/ - -/* Header file version number, required by OpenGL ABI for Linux */ -/* glext.h last updated 2005/06/20 */ -/* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */ -#define GL_GLEXT_VERSION 29 - -#ifndef GL_VERSION_1_2 -#define GL_UNSIGNED_BYTE_3_3_2 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2 0x8036 -#define GL_RESCALE_NORMAL 0x803A -#define GL_TEXTURE_BINDING_3D 0x806A -#define GL_PACK_SKIP_IMAGES 0x806B -#define GL_PACK_IMAGE_HEIGHT 0x806C -#define GL_UNPACK_SKIP_IMAGES 0x806D -#define GL_UNPACK_IMAGE_HEIGHT 0x806E -#define GL_TEXTURE_3D 0x806F -#define GL_PROXY_TEXTURE_3D 0x8070 -#define GL_TEXTURE_DEPTH 0x8071 -#define GL_TEXTURE_WRAP_R 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE 0x8073 -#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 -#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define GL_BGR 0x80E0 -#define GL_BGRA 0x80E1 -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_TEXTURE_MIN_LOD 0x813A -#define GL_TEXTURE_MAX_LOD 0x813B -#define GL_TEXTURE_BASE_LEVEL 0x813C -#define GL_TEXTURE_MAX_LEVEL 0x813D -#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 -#define GL_SINGLE_COLOR 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR 0x81FA -#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 -#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 -#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#endif - -#ifndef GL_ARB_imaging -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 -#define GL_FUNC_ADD 0x8006 -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_BLEND_EQUATION 0x8009 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#define GL_CONVOLUTION_1D 0x8010 -#define GL_CONVOLUTION_2D 0x8011 -#define GL_SEPARABLE_2D 0x8012 -#define GL_CONVOLUTION_BORDER_MODE 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS 0x8015 -#define GL_REDUCE 0x8016 -#define GL_CONVOLUTION_FORMAT 0x8017 -#define GL_CONVOLUTION_WIDTH 0x8018 -#define GL_CONVOLUTION_HEIGHT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 -#define GL_HISTOGRAM 0x8024 -#define GL_PROXY_HISTOGRAM 0x8025 -#define GL_HISTOGRAM_WIDTH 0x8026 -#define GL_HISTOGRAM_FORMAT 0x8027 -#define GL_HISTOGRAM_RED_SIZE 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C -#define GL_HISTOGRAM_SINK 0x802D -#define GL_MINMAX 0x802E -#define GL_MINMAX_FORMAT 0x802F -#define GL_MINMAX_SINK 0x8030 -#define GL_TABLE_TOO_LARGE 0x8031 -#define GL_COLOR_MATRIX 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB -#define GL_COLOR_TABLE 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 -#define GL_PROXY_COLOR_TABLE 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 -#define GL_COLOR_TABLE_SCALE 0x80D6 -#define GL_COLOR_TABLE_BIAS 0x80D7 -#define GL_COLOR_TABLE_FORMAT 0x80D8 -#define GL_COLOR_TABLE_WIDTH 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF -#define GL_CONSTANT_BORDER 0x8151 -#define GL_REPLICATE_BORDER 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR 0x8154 -#endif - -#ifndef GL_VERSION_1_3 -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 -#define GL_MAX_TEXTURE_UNITS 0x84E2 -#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 -#define GL_MULTISAMPLE 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE 0x809F -#define GL_SAMPLE_COVERAGE 0x80A0 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB -#define GL_MULTISAMPLE_BIT 0x20000000 -#define GL_NORMAL_MAP 0x8511 -#define GL_REFLECTION_MAP 0x8512 -#define GL_TEXTURE_CUBE_MAP 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -#define GL_COMPRESSED_ALPHA 0x84E9 -#define GL_COMPRESSED_LUMINANCE 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB -#define GL_COMPRESSED_INTENSITY 0x84EC -#define GL_COMPRESSED_RGB 0x84ED -#define GL_COMPRESSED_RGBA 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 -#define GL_TEXTURE_COMPRESSED 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 -#define GL_CLAMP_TO_BORDER 0x812D -#define GL_COMBINE 0x8570 -#define GL_COMBINE_RGB 0x8571 -#define GL_COMBINE_ALPHA 0x8572 -#define GL_SOURCE0_RGB 0x8580 -#define GL_SOURCE1_RGB 0x8581 -#define GL_SOURCE2_RGB 0x8582 -#define GL_SOURCE0_ALPHA 0x8588 -#define GL_SOURCE1_ALPHA 0x8589 -#define GL_SOURCE2_ALPHA 0x858A -#define GL_OPERAND0_RGB 0x8590 -#define GL_OPERAND1_RGB 0x8591 -#define GL_OPERAND2_RGB 0x8592 -#define GL_OPERAND0_ALPHA 0x8598 -#define GL_OPERAND1_ALPHA 0x8599 -#define GL_OPERAND2_ALPHA 0x859A -#define GL_RGB_SCALE 0x8573 -#define GL_ADD_SIGNED 0x8574 -#define GL_INTERPOLATE 0x8575 -#define GL_SUBTRACT 0x84E7 -#define GL_CONSTANT 0x8576 -#define GL_PRIMARY_COLOR 0x8577 -#define GL_PREVIOUS 0x8578 -#define GL_DOT3_RGB 0x86AE -#define GL_DOT3_RGBA 0x86AF -#endif - -#ifndef GL_VERSION_1_4 -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_POINT_SIZE_MIN 0x8126 -#define GL_POINT_SIZE_MAX 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION 0x8129 -#define GL_GENERATE_MIPMAP 0x8191 -#define GL_GENERATE_MIPMAP_HINT 0x8192 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_DEPTH_COMPONENT24 0x81A6 -#define GL_DEPTH_COMPONENT32 0x81A7 -#define GL_MIRRORED_REPEAT 0x8370 -#define GL_FOG_COORDINATE_SOURCE 0x8450 -#define GL_FOG_COORDINATE 0x8451 -#define GL_FRAGMENT_DEPTH 0x8452 -#define GL_CURRENT_FOG_COORDINATE 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 -#define GL_FOG_COORDINATE_ARRAY 0x8457 -#define GL_COLOR_SUM 0x8458 -#define GL_CURRENT_SECONDARY_COLOR 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D -#define GL_SECONDARY_COLOR_ARRAY 0x845E -#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD -#define GL_TEXTURE_FILTER_CONTROL 0x8500 -#define GL_TEXTURE_LOD_BIAS 0x8501 -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_TEXTURE_DEPTH_SIZE 0x884A -#define GL_DEPTH_TEXTURE_MODE 0x884B -#define GL_TEXTURE_COMPARE_MODE 0x884C -#define GL_TEXTURE_COMPARE_FUNC 0x884D -#define GL_COMPARE_R_TO_TEXTURE 0x884E -#endif - -#ifndef GL_VERSION_1_5 -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 -#define GL_QUERY_COUNTER_BITS 0x8864 -#define GL_CURRENT_QUERY 0x8865 -#define GL_QUERY_RESULT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE 0x8867 -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F -#define GL_READ_ONLY 0x88B8 -#define GL_WRITE_ONLY 0x88B9 -#define GL_READ_WRITE 0x88BA -#define GL_BUFFER_ACCESS 0x88BB -#define GL_BUFFER_MAPPED 0x88BC -#define GL_BUFFER_MAP_POINTER 0x88BD -#define GL_STREAM_DRAW 0x88E0 -#define GL_STREAM_READ 0x88E1 -#define GL_STREAM_COPY 0x88E2 -#define GL_STATIC_DRAW 0x88E4 -#define GL_STATIC_READ 0x88E5 -#define GL_STATIC_COPY 0x88E6 -#define GL_DYNAMIC_DRAW 0x88E8 -#define GL_DYNAMIC_READ 0x88E9 -#define GL_DYNAMIC_COPY 0x88EA -#define GL_SAMPLES_PASSED 0x8914 -#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE -#define GL_FOG_COORD GL_FOG_COORDINATE -#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE -#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE -#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE -#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER -#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY -#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING -#define GL_SRC0_RGB GL_SOURCE0_RGB -#define GL_SRC1_RGB GL_SOURCE1_RGB -#define GL_SRC2_RGB GL_SOURCE2_RGB -#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA -#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA -#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA -#endif - -#ifndef GL_VERSION_2_0 -#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 -#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_STENCIL_BACK_FUNC 0x8800 -#define GL_STENCIL_BACK_FAIL 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define GL_MAX_DRAW_BUFFERS 0x8824 -#define GL_DRAW_BUFFER0 0x8825 -#define GL_DRAW_BUFFER1 0x8826 -#define GL_DRAW_BUFFER2 0x8827 -#define GL_DRAW_BUFFER3 0x8828 -#define GL_DRAW_BUFFER4 0x8829 -#define GL_DRAW_BUFFER5 0x882A -#define GL_DRAW_BUFFER6 0x882B -#define GL_DRAW_BUFFER7 0x882C -#define GL_DRAW_BUFFER8 0x882D -#define GL_DRAW_BUFFER9 0x882E -#define GL_DRAW_BUFFER10 0x882F -#define GL_DRAW_BUFFER11 0x8830 -#define GL_DRAW_BUFFER12 0x8831 -#define GL_DRAW_BUFFER13 0x8832 -#define GL_DRAW_BUFFER14 0x8833 -#define GL_DRAW_BUFFER15 0x8834 -#define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_POINT_SPRITE 0x8861 -#define GL_COORD_REPLACE 0x8862 -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_MAX_TEXTURE_COORDS 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A -#define GL_MAX_VARYING_FLOATS 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_SHADER_TYPE 0x8B4F -#define GL_FLOAT_VEC2 0x8B50 -#define GL_FLOAT_VEC3 0x8B51 -#define GL_FLOAT_VEC4 0x8B52 -#define GL_INT_VEC2 0x8B53 -#define GL_INT_VEC3 0x8B54 -#define GL_INT_VEC4 0x8B55 -#define GL_BOOL 0x8B56 -#define GL_BOOL_VEC2 0x8B57 -#define GL_BOOL_VEC3 0x8B58 -#define GL_BOOL_VEC4 0x8B59 -#define GL_FLOAT_MAT2 0x8B5A -#define GL_FLOAT_MAT3 0x8B5B -#define GL_FLOAT_MAT4 0x8B5C -#define GL_SAMPLER_1D 0x8B5D -#define GL_SAMPLER_2D 0x8B5E -#define GL_SAMPLER_3D 0x8B5F -#define GL_SAMPLER_CUBE 0x8B60 -#define GL_SAMPLER_1D_SHADOW 0x8B61 -#define GL_SAMPLER_2D_SHADOW 0x8B62 -#define GL_DELETE_STATUS 0x8B80 -#define GL_COMPILE_STATUS 0x8B81 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D -#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 -#define GL_LOWER_LEFT 0x8CA1 -#define GL_UPPER_LEFT 0x8CA2 -#define GL_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#endif - -#ifndef GL_ARB_multitexture -#define GL_TEXTURE0_ARB 0x84C0 -#define GL_TEXTURE1_ARB 0x84C1 -#define GL_TEXTURE2_ARB 0x84C2 -#define GL_TEXTURE3_ARB 0x84C3 -#define GL_TEXTURE4_ARB 0x84C4 -#define GL_TEXTURE5_ARB 0x84C5 -#define GL_TEXTURE6_ARB 0x84C6 -#define GL_TEXTURE7_ARB 0x84C7 -#define GL_TEXTURE8_ARB 0x84C8 -#define GL_TEXTURE9_ARB 0x84C9 -#define GL_TEXTURE10_ARB 0x84CA -#define GL_TEXTURE11_ARB 0x84CB -#define GL_TEXTURE12_ARB 0x84CC -#define GL_TEXTURE13_ARB 0x84CD -#define GL_TEXTURE14_ARB 0x84CE -#define GL_TEXTURE15_ARB 0x84CF -#define GL_TEXTURE16_ARB 0x84D0 -#define GL_TEXTURE17_ARB 0x84D1 -#define GL_TEXTURE18_ARB 0x84D2 -#define GL_TEXTURE19_ARB 0x84D3 -#define GL_TEXTURE20_ARB 0x84D4 -#define GL_TEXTURE21_ARB 0x84D5 -#define GL_TEXTURE22_ARB 0x84D6 -#define GL_TEXTURE23_ARB 0x84D7 -#define GL_TEXTURE24_ARB 0x84D8 -#define GL_TEXTURE25_ARB 0x84D9 -#define GL_TEXTURE26_ARB 0x84DA -#define GL_TEXTURE27_ARB 0x84DB -#define GL_TEXTURE28_ARB 0x84DC -#define GL_TEXTURE29_ARB 0x84DD -#define GL_TEXTURE30_ARB 0x84DE -#define GL_TEXTURE31_ARB 0x84DF -#define GL_ACTIVE_TEXTURE_ARB 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 -#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 -#endif - -#ifndef GL_ARB_transpose_matrix -#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 -#endif - -#ifndef GL_ARB_multisample -#define GL_MULTISAMPLE_ARB 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F -#define GL_SAMPLE_COVERAGE_ARB 0x80A0 -#define GL_SAMPLE_BUFFERS_ARB 0x80A8 -#define GL_SAMPLES_ARB 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB -#define GL_MULTISAMPLE_BIT_ARB 0x20000000 -#endif - -#ifndef GL_ARB_texture_env_add -#endif - -#ifndef GL_ARB_texture_cube_map -#define GL_NORMAL_MAP_ARB 0x8511 -#define GL_REFLECTION_MAP_ARB 0x8512 -#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C -#endif - -#ifndef GL_ARB_texture_compression -#define GL_COMPRESSED_ALPHA_ARB 0x84E9 -#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB -#define GL_COMPRESSED_INTENSITY_ARB 0x84EC -#define GL_COMPRESSED_RGB_ARB 0x84ED -#define GL_COMPRESSED_RGBA_ARB 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 -#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 -#endif - -#ifndef GL_ARB_texture_border_clamp -#define GL_CLAMP_TO_BORDER_ARB 0x812D -#endif - -#ifndef GL_ARB_point_parameters -#define GL_POINT_SIZE_MIN_ARB 0x8126 -#define GL_POINT_SIZE_MAX_ARB 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 -#endif - -#ifndef GL_ARB_vertex_blend -#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 -#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 -#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 -#define GL_VERTEX_BLEND_ARB 0x86A7 -#define GL_CURRENT_WEIGHT_ARB 0x86A8 -#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 -#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA -#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB -#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC -#define GL_WEIGHT_ARRAY_ARB 0x86AD -#define GL_MODELVIEW0_ARB 0x1700 -#define GL_MODELVIEW1_ARB 0x850A -#define GL_MODELVIEW2_ARB 0x8722 -#define GL_MODELVIEW3_ARB 0x8723 -#define GL_MODELVIEW4_ARB 0x8724 -#define GL_MODELVIEW5_ARB 0x8725 -#define GL_MODELVIEW6_ARB 0x8726 -#define GL_MODELVIEW7_ARB 0x8727 -#define GL_MODELVIEW8_ARB 0x8728 -#define GL_MODELVIEW9_ARB 0x8729 -#define GL_MODELVIEW10_ARB 0x872A -#define GL_MODELVIEW11_ARB 0x872B -#define GL_MODELVIEW12_ARB 0x872C -#define GL_MODELVIEW13_ARB 0x872D -#define GL_MODELVIEW14_ARB 0x872E -#define GL_MODELVIEW15_ARB 0x872F -#define GL_MODELVIEW16_ARB 0x8730 -#define GL_MODELVIEW17_ARB 0x8731 -#define GL_MODELVIEW18_ARB 0x8732 -#define GL_MODELVIEW19_ARB 0x8733 -#define GL_MODELVIEW20_ARB 0x8734 -#define GL_MODELVIEW21_ARB 0x8735 -#define GL_MODELVIEW22_ARB 0x8736 -#define GL_MODELVIEW23_ARB 0x8737 -#define GL_MODELVIEW24_ARB 0x8738 -#define GL_MODELVIEW25_ARB 0x8739 -#define GL_MODELVIEW26_ARB 0x873A -#define GL_MODELVIEW27_ARB 0x873B -#define GL_MODELVIEW28_ARB 0x873C -#define GL_MODELVIEW29_ARB 0x873D -#define GL_MODELVIEW30_ARB 0x873E -#define GL_MODELVIEW31_ARB 0x873F -#endif - -#ifndef GL_ARB_matrix_palette -#define GL_MATRIX_PALETTE_ARB 0x8840 -#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 -#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 -#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 -#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 -#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 -#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 -#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 -#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 -#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 -#endif - -#ifndef GL_ARB_texture_env_combine -#define GL_COMBINE_ARB 0x8570 -#define GL_COMBINE_RGB_ARB 0x8571 -#define GL_COMBINE_ALPHA_ARB 0x8572 -#define GL_SOURCE0_RGB_ARB 0x8580 -#define GL_SOURCE1_RGB_ARB 0x8581 -#define GL_SOURCE2_RGB_ARB 0x8582 -#define GL_SOURCE0_ALPHA_ARB 0x8588 -#define GL_SOURCE1_ALPHA_ARB 0x8589 -#define GL_SOURCE2_ALPHA_ARB 0x858A -#define GL_OPERAND0_RGB_ARB 0x8590 -#define GL_OPERAND1_RGB_ARB 0x8591 -#define GL_OPERAND2_RGB_ARB 0x8592 -#define GL_OPERAND0_ALPHA_ARB 0x8598 -#define GL_OPERAND1_ALPHA_ARB 0x8599 -#define GL_OPERAND2_ALPHA_ARB 0x859A -#define GL_RGB_SCALE_ARB 0x8573 -#define GL_ADD_SIGNED_ARB 0x8574 -#define GL_INTERPOLATE_ARB 0x8575 -#define GL_SUBTRACT_ARB 0x84E7 -#define GL_CONSTANT_ARB 0x8576 -#define GL_PRIMARY_COLOR_ARB 0x8577 -#define GL_PREVIOUS_ARB 0x8578 -#endif - -#ifndef GL_ARB_texture_env_crossbar -#endif - -#ifndef GL_ARB_texture_env_dot3 -#define GL_DOT3_RGB_ARB 0x86AE -#define GL_DOT3_RGBA_ARB 0x86AF -#endif - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_ARB 0x8370 -#endif - -#ifndef GL_ARB_depth_texture -#define GL_DEPTH_COMPONENT16_ARB 0x81A5 -#define GL_DEPTH_COMPONENT24_ARB 0x81A6 -#define GL_DEPTH_COMPONENT32_ARB 0x81A7 -#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A -#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B -#endif - -#ifndef GL_ARB_shadow -#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C -#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D -#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E -#endif - -#ifndef GL_ARB_shadow_ambient -#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF -#endif - -#ifndef GL_ARB_window_pos -#endif - -#ifndef GL_ARB_vertex_program -#define GL_COLOR_SUM_ARB 0x8458 -#define GL_VERTEX_PROGRAM_ARB 0x8620 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 -#define GL_PROGRAM_LENGTH_ARB 0x8627 -#define GL_PROGRAM_STRING_ARB 0x8628 -#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E -#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F -#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 -#define GL_CURRENT_MATRIX_ARB 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 -#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B -#define GL_PROGRAM_BINDING_ARB 0x8677 -#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A -#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 -#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 -#define GL_PROGRAM_FORMAT_ARB 0x8876 -#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 -#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 -#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 -#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 -#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 -#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 -#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 -#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 -#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 -#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 -#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA -#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB -#define GL_PROGRAM_ATTRIBS_ARB 0x88AC -#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD -#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE -#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF -#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 -#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 -#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 -#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 -#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 -#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 -#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 -#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 -#define GL_MATRIX0_ARB 0x88C0 -#define GL_MATRIX1_ARB 0x88C1 -#define GL_MATRIX2_ARB 0x88C2 -#define GL_MATRIX3_ARB 0x88C3 -#define GL_MATRIX4_ARB 0x88C4 -#define GL_MATRIX5_ARB 0x88C5 -#define GL_MATRIX6_ARB 0x88C6 -#define GL_MATRIX7_ARB 0x88C7 -#define GL_MATRIX8_ARB 0x88C8 -#define GL_MATRIX9_ARB 0x88C9 -#define GL_MATRIX10_ARB 0x88CA -#define GL_MATRIX11_ARB 0x88CB -#define GL_MATRIX12_ARB 0x88CC -#define GL_MATRIX13_ARB 0x88CD -#define GL_MATRIX14_ARB 0x88CE -#define GL_MATRIX15_ARB 0x88CF -#define GL_MATRIX16_ARB 0x88D0 -#define GL_MATRIX17_ARB 0x88D1 -#define GL_MATRIX18_ARB 0x88D2 -#define GL_MATRIX19_ARB 0x88D3 -#define GL_MATRIX20_ARB 0x88D4 -#define GL_MATRIX21_ARB 0x88D5 -#define GL_MATRIX22_ARB 0x88D6 -#define GL_MATRIX23_ARB 0x88D7 -#define GL_MATRIX24_ARB 0x88D8 -#define GL_MATRIX25_ARB 0x88D9 -#define GL_MATRIX26_ARB 0x88DA -#define GL_MATRIX27_ARB 0x88DB -#define GL_MATRIX28_ARB 0x88DC -#define GL_MATRIX29_ARB 0x88DD -#define GL_MATRIX30_ARB 0x88DE -#define GL_MATRIX31_ARB 0x88DF -#endif - -#ifndef GL_ARB_fragment_program -#define GL_FRAGMENT_PROGRAM_ARB 0x8804 -#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 -#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 -#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 -#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 -#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 -#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A -#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B -#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C -#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D -#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E -#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F -#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 -#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 -#endif - -#ifndef GL_ARB_vertex_buffer_object -#define GL_BUFFER_SIZE_ARB 0x8764 -#define GL_BUFFER_USAGE_ARB 0x8765 -#define GL_ARRAY_BUFFER_ARB 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 -#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F -#define GL_READ_ONLY_ARB 0x88B8 -#define GL_WRITE_ONLY_ARB 0x88B9 -#define GL_READ_WRITE_ARB 0x88BA -#define GL_BUFFER_ACCESS_ARB 0x88BB -#define GL_BUFFER_MAPPED_ARB 0x88BC -#define GL_BUFFER_MAP_POINTER_ARB 0x88BD -#define GL_STREAM_DRAW_ARB 0x88E0 -#define GL_STREAM_READ_ARB 0x88E1 -#define GL_STREAM_COPY_ARB 0x88E2 -#define GL_STATIC_DRAW_ARB 0x88E4 -#define GL_STATIC_READ_ARB 0x88E5 -#define GL_STATIC_COPY_ARB 0x88E6 -#define GL_DYNAMIC_DRAW_ARB 0x88E8 -#define GL_DYNAMIC_READ_ARB 0x88E9 -#define GL_DYNAMIC_COPY_ARB 0x88EA -#endif - -#ifndef GL_ARB_occlusion_query -#define GL_QUERY_COUNTER_BITS_ARB 0x8864 -#define GL_CURRENT_QUERY_ARB 0x8865 -#define GL_QUERY_RESULT_ARB 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 -#define GL_SAMPLES_PASSED_ARB 0x8914 -#endif - -#ifndef GL_ARB_shader_objects -#define GL_PROGRAM_OBJECT_ARB 0x8B40 -#define GL_SHADER_OBJECT_ARB 0x8B48 -#define GL_OBJECT_TYPE_ARB 0x8B4E -#define GL_OBJECT_SUBTYPE_ARB 0x8B4F -#define GL_FLOAT_VEC2_ARB 0x8B50 -#define GL_FLOAT_VEC3_ARB 0x8B51 -#define GL_FLOAT_VEC4_ARB 0x8B52 -#define GL_INT_VEC2_ARB 0x8B53 -#define GL_INT_VEC3_ARB 0x8B54 -#define GL_INT_VEC4_ARB 0x8B55 -#define GL_BOOL_ARB 0x8B56 -#define GL_BOOL_VEC2_ARB 0x8B57 -#define GL_BOOL_VEC3_ARB 0x8B58 -#define GL_BOOL_VEC4_ARB 0x8B59 -#define GL_FLOAT_MAT2_ARB 0x8B5A -#define GL_FLOAT_MAT3_ARB 0x8B5B -#define GL_FLOAT_MAT4_ARB 0x8B5C -#define GL_SAMPLER_1D_ARB 0x8B5D -#define GL_SAMPLER_2D_ARB 0x8B5E -#define GL_SAMPLER_3D_ARB 0x8B5F -#define GL_SAMPLER_CUBE_ARB 0x8B60 -#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 -#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 -#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 -#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 -#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 -#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 -#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 -#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 -#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 -#endif - -#ifndef GL_ARB_vertex_shader -#define GL_VERTEX_SHADER_ARB 0x8B31 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A -#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D -#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 -#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_FRAGMENT_SHADER_ARB 0x8B30 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B -#endif - -#ifndef GL_ARB_shading_language_100 -#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C -#endif - -#ifndef GL_ARB_texture_non_power_of_two -#endif - -#ifndef GL_ARB_point_sprite -#define GL_POINT_SPRITE_ARB 0x8861 -#define GL_COORD_REPLACE_ARB 0x8862 -#endif - -#ifndef GL_ARB_fragment_program_shadow -#endif - -#ifndef GL_ARB_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 -#define GL_DRAW_BUFFER0_ARB 0x8825 -#define GL_DRAW_BUFFER1_ARB 0x8826 -#define GL_DRAW_BUFFER2_ARB 0x8827 -#define GL_DRAW_BUFFER3_ARB 0x8828 -#define GL_DRAW_BUFFER4_ARB 0x8829 -#define GL_DRAW_BUFFER5_ARB 0x882A -#define GL_DRAW_BUFFER6_ARB 0x882B -#define GL_DRAW_BUFFER7_ARB 0x882C -#define GL_DRAW_BUFFER8_ARB 0x882D -#define GL_DRAW_BUFFER9_ARB 0x882E -#define GL_DRAW_BUFFER10_ARB 0x882F -#define GL_DRAW_BUFFER11_ARB 0x8830 -#define GL_DRAW_BUFFER12_ARB 0x8831 -#define GL_DRAW_BUFFER13_ARB 0x8832 -#define GL_DRAW_BUFFER14_ARB 0x8833 -#define GL_DRAW_BUFFER15_ARB 0x8834 -#endif - -#ifndef GL_ARB_texture_rectangle -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -#endif - -#ifndef GL_ARB_color_buffer_float -#define GL_RGBA_FLOAT_MODE_ARB 0x8820 -#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A -#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B -#define GL_CLAMP_READ_COLOR_ARB 0x891C -#define GL_FIXED_ONLY_ARB 0x891D -#endif - -#ifndef GL_ARB_half_float_pixel -#define GL_HALF_FLOAT_ARB 0x140B -#endif - -#ifndef GL_ARB_texture_float -#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 -#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 -#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 -#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 -#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 -#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 -#define GL_RGBA32F_ARB 0x8814 -#define GL_RGB32F_ARB 0x8815 -#define GL_ALPHA32F_ARB 0x8816 -#define GL_INTENSITY32F_ARB 0x8817 -#define GL_LUMINANCE32F_ARB 0x8818 -#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 -#define GL_RGBA16F_ARB 0x881A -#define GL_RGB16F_ARB 0x881B -#define GL_ALPHA16F_ARB 0x881C -#define GL_INTENSITY16F_ARB 0x881D -#define GL_LUMINANCE16F_ARB 0x881E -#define GL_LUMINANCE_ALPHA16F_ARB 0x881F -#endif - -#ifndef GL_ARB_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF -#endif - -#ifndef GL_EXT_abgr -#define GL_ABGR_EXT 0x8000 -#endif - -#ifndef GL_EXT_blend_color -#define GL_CONSTANT_COLOR_EXT 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 -#define GL_CONSTANT_ALPHA_EXT 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 -#define GL_BLEND_COLOR_EXT 0x8005 -#endif - -#ifndef GL_EXT_polygon_offset -#define GL_POLYGON_OFFSET_EXT 0x8037 -#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 -#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 -#endif - -#ifndef GL_EXT_texture -#define GL_ALPHA4_EXT 0x803B -#define GL_ALPHA8_EXT 0x803C -#define GL_ALPHA12_EXT 0x803D -#define GL_ALPHA16_EXT 0x803E -#define GL_LUMINANCE4_EXT 0x803F -#define GL_LUMINANCE8_EXT 0x8040 -#define GL_LUMINANCE12_EXT 0x8041 -#define GL_LUMINANCE16_EXT 0x8042 -#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 -#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 -#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 -#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 -#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 -#define GL_INTENSITY_EXT 0x8049 -#define GL_INTENSITY4_EXT 0x804A -#define GL_INTENSITY8_EXT 0x804B -#define GL_INTENSITY12_EXT 0x804C -#define GL_INTENSITY16_EXT 0x804D -#define GL_RGB2_EXT 0x804E -#define GL_RGB4_EXT 0x804F -#define GL_RGB5_EXT 0x8050 -#define GL_RGB8_EXT 0x8051 -#define GL_RGB10_EXT 0x8052 -#define GL_RGB12_EXT 0x8053 -#define GL_RGB16_EXT 0x8054 -#define GL_RGBA2_EXT 0x8055 -#define GL_RGBA4_EXT 0x8056 -#define GL_RGB5_A1_EXT 0x8057 -#define GL_RGBA8_EXT 0x8058 -#define GL_RGB10_A2_EXT 0x8059 -#define GL_RGBA12_EXT 0x805A -#define GL_RGBA16_EXT 0x805B -#define GL_TEXTURE_RED_SIZE_EXT 0x805C -#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D -#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E -#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 -#define GL_REPLACE_EXT 0x8062 -#define GL_PROXY_TEXTURE_1D_EXT 0x8063 -#define GL_PROXY_TEXTURE_2D_EXT 0x8064 -#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 -#endif - -#ifndef GL_EXT_texture3D -#define GL_PACK_SKIP_IMAGES_EXT 0x806B -#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C -#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D -#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E -#define GL_TEXTURE_3D_EXT 0x806F -#define GL_PROXY_TEXTURE_3D_EXT 0x8070 -#define GL_TEXTURE_DEPTH_EXT 0x8071 -#define GL_TEXTURE_WRAP_R_EXT 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 -#endif - -#ifndef GL_SGIS_texture_filter4 -#define GL_FILTER4_SGIS 0x8146 -#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 -#endif - -#ifndef GL_EXT_subtexture -#endif - -#ifndef GL_EXT_copy_texture -#endif - -#ifndef GL_EXT_histogram -#define GL_HISTOGRAM_EXT 0x8024 -#define GL_PROXY_HISTOGRAM_EXT 0x8025 -#define GL_HISTOGRAM_WIDTH_EXT 0x8026 -#define GL_HISTOGRAM_FORMAT_EXT 0x8027 -#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C -#define GL_HISTOGRAM_SINK_EXT 0x802D -#define GL_MINMAX_EXT 0x802E -#define GL_MINMAX_FORMAT_EXT 0x802F -#define GL_MINMAX_SINK_EXT 0x8030 -#define GL_TABLE_TOO_LARGE_EXT 0x8031 -#endif - -#ifndef GL_EXT_convolution -#define GL_CONVOLUTION_1D_EXT 0x8010 -#define GL_CONVOLUTION_2D_EXT 0x8011 -#define GL_SEPARABLE_2D_EXT 0x8012 -#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 -#define GL_REDUCE_EXT 0x8016 -#define GL_CONVOLUTION_FORMAT_EXT 0x8017 -#define GL_CONVOLUTION_WIDTH_EXT 0x8018 -#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 -#endif - -#ifndef GL_SGI_color_matrix -#define GL_COLOR_MATRIX_SGI 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB -#endif - -#ifndef GL_SGI_color_table -#define GL_COLOR_TABLE_SGI 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 -#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 -#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 -#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 -#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 -#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF -#endif - -#ifndef GL_SGIS_pixel_texture -#define GL_PIXEL_TEXTURE_SGIS 0x8353 -#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 -#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 -#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 -#endif - -#ifndef GL_SGIX_pixel_texture -#define GL_PIXEL_TEX_GEN_SGIX 0x8139 -#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B -#endif - -#ifndef GL_SGIS_texture4D -#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 -#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 -#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 -#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 -#define GL_TEXTURE_4D_SGIS 0x8134 -#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 -#define GL_TEXTURE_4DSIZE_SGIS 0x8136 -#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 -#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 -#define GL_TEXTURE_4D_BINDING_SGIS 0x814F -#endif - -#ifndef GL_SGI_texture_color_table -#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC -#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD -#endif - -#ifndef GL_EXT_cmyka -#define GL_CMYK_EXT 0x800C -#define GL_CMYKA_EXT 0x800D -#define GL_PACK_CMYK_HINT_EXT 0x800E -#define GL_UNPACK_CMYK_HINT_EXT 0x800F -#endif - -#ifndef GL_EXT_texture_object -#define GL_TEXTURE_PRIORITY_EXT 0x8066 -#define GL_TEXTURE_RESIDENT_EXT 0x8067 -#define GL_TEXTURE_1D_BINDING_EXT 0x8068 -#define GL_TEXTURE_2D_BINDING_EXT 0x8069 -#define GL_TEXTURE_3D_BINDING_EXT 0x806A -#endif - -#ifndef GL_SGIS_detail_texture -#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 -#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 -#define GL_LINEAR_DETAIL_SGIS 0x8097 -#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 -#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 -#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A -#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B -#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C -#endif - -#ifndef GL_SGIS_sharpen_texture -#define GL_LINEAR_SHARPEN_SGIS 0x80AD -#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE -#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF -#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 -#endif - -#ifndef GL_EXT_packed_pixels -#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 -#endif - -#ifndef GL_SGIS_texture_lod -#define GL_TEXTURE_MIN_LOD_SGIS 0x813A -#define GL_TEXTURE_MAX_LOD_SGIS 0x813B -#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C -#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D -#endif - -#ifndef GL_SGIS_multisample -#define GL_MULTISAMPLE_SGIS 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F -#define GL_SAMPLE_MASK_SGIS 0x80A0 -#define GL_1PASS_SGIS 0x80A1 -#define GL_2PASS_0_SGIS 0x80A2 -#define GL_2PASS_1_SGIS 0x80A3 -#define GL_4PASS_0_SGIS 0x80A4 -#define GL_4PASS_1_SGIS 0x80A5 -#define GL_4PASS_2_SGIS 0x80A6 -#define GL_4PASS_3_SGIS 0x80A7 -#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 -#define GL_SAMPLES_SGIS 0x80A9 -#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA -#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB -#define GL_SAMPLE_PATTERN_SGIS 0x80AC -#endif - -#ifndef GL_EXT_rescale_normal -#define GL_RESCALE_NORMAL_EXT 0x803A -#endif - -#ifndef GL_EXT_vertex_array -#define GL_VERTEX_ARRAY_EXT 0x8074 -#define GL_NORMAL_ARRAY_EXT 0x8075 -#define GL_COLOR_ARRAY_EXT 0x8076 -#define GL_INDEX_ARRAY_EXT 0x8077 -#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 -#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 -#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A -#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B -#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C -#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D -#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E -#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F -#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 -#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 -#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 -#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 -#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 -#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 -#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 -#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 -#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A -#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B -#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C -#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D -#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E -#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F -#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 -#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 -#endif - -#ifndef GL_EXT_misc_attribute -#endif - -#ifndef GL_SGIS_generate_mipmap -#define GL_GENERATE_MIPMAP_SGIS 0x8191 -#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 -#endif - -#ifndef GL_SGIX_clipmap -#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 -#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 -#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 -#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 -#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 -#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 -#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 -#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 -#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 -#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D -#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E -#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F -#endif - -#ifndef GL_SGIX_shadow -#define GL_TEXTURE_COMPARE_SGIX 0x819A -#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B -#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C -#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D -#endif - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_CLAMP_TO_EDGE_SGIS 0x812F -#endif - -#ifndef GL_SGIS_texture_border_clamp -#define GL_CLAMP_TO_BORDER_SGIS 0x812D -#endif - -#ifndef GL_EXT_blend_minmax -#define GL_FUNC_ADD_EXT 0x8006 -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#define GL_BLEND_EQUATION_EXT 0x8009 -#endif - -#ifndef GL_EXT_blend_subtract -#define GL_FUNC_SUBTRACT_EXT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B -#endif - -#ifndef GL_EXT_blend_logic_op -#endif - -#ifndef GL_SGIX_interlace -#define GL_INTERLACE_SGIX 0x8094 -#endif - -#ifndef GL_SGIX_pixel_tiles -#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E -#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F -#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 -#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 -#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 -#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 -#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 -#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 -#endif - -#ifndef GL_SGIS_texture_select -#define GL_DUAL_ALPHA4_SGIS 0x8110 -#define GL_DUAL_ALPHA8_SGIS 0x8111 -#define GL_DUAL_ALPHA12_SGIS 0x8112 -#define GL_DUAL_ALPHA16_SGIS 0x8113 -#define GL_DUAL_LUMINANCE4_SGIS 0x8114 -#define GL_DUAL_LUMINANCE8_SGIS 0x8115 -#define GL_DUAL_LUMINANCE12_SGIS 0x8116 -#define GL_DUAL_LUMINANCE16_SGIS 0x8117 -#define GL_DUAL_INTENSITY4_SGIS 0x8118 -#define GL_DUAL_INTENSITY8_SGIS 0x8119 -#define GL_DUAL_INTENSITY12_SGIS 0x811A -#define GL_DUAL_INTENSITY16_SGIS 0x811B -#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C -#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D -#define GL_QUAD_ALPHA4_SGIS 0x811E -#define GL_QUAD_ALPHA8_SGIS 0x811F -#define GL_QUAD_LUMINANCE4_SGIS 0x8120 -#define GL_QUAD_LUMINANCE8_SGIS 0x8121 -#define GL_QUAD_INTENSITY4_SGIS 0x8122 -#define GL_QUAD_INTENSITY8_SGIS 0x8123 -#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 -#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 -#endif - -#ifndef GL_SGIX_sprite -#define GL_SPRITE_SGIX 0x8148 -#define GL_SPRITE_MODE_SGIX 0x8149 -#define GL_SPRITE_AXIS_SGIX 0x814A -#define GL_SPRITE_TRANSLATION_SGIX 0x814B -#define GL_SPRITE_AXIAL_SGIX 0x814C -#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D -#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E -#endif - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E -#endif - -#ifndef GL_EXT_point_parameters -#define GL_POINT_SIZE_MIN_EXT 0x8126 -#define GL_POINT_SIZE_MAX_EXT 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 -#define GL_DISTANCE_ATTENUATION_EXT 0x8129 -#endif - -#ifndef GL_SGIS_point_parameters -#define GL_POINT_SIZE_MIN_SGIS 0x8126 -#define GL_POINT_SIZE_MAX_SGIS 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 -#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 -#endif - -#ifndef GL_SGIX_instruments -#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 -#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 -#endif - -#ifndef GL_SGIX_texture_scale_bias -#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 -#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A -#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B -#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C -#endif - -#ifndef GL_SGIX_framezoom -#define GL_FRAMEZOOM_SGIX 0x818B -#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C -#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D -#endif - -#ifndef GL_SGIX_tag_sample_buffer -#endif - -#ifndef GL_FfdMaskSGIX -#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 -#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 -#endif - -#ifndef GL_SGIX_polynomial_ffd -#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 -#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 -#define GL_DEFORMATIONS_MASK_SGIX 0x8196 -#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 -#endif - -#ifndef GL_SGIX_reference_plane -#define GL_REFERENCE_PLANE_SGIX 0x817D -#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E -#endif - -#ifndef GL_SGIX_flush_raster -#endif - -#ifndef GL_SGIX_depth_texture -#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 -#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 -#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 -#endif - -#ifndef GL_SGIS_fog_function -#define GL_FOG_FUNC_SGIS 0x812A -#define GL_FOG_FUNC_POINTS_SGIS 0x812B -#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C -#endif - -#ifndef GL_SGIX_fog_offset -#define GL_FOG_OFFSET_SGIX 0x8198 -#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 -#endif - -#ifndef GL_HP_image_transform -#define GL_IMAGE_SCALE_X_HP 0x8155 -#define GL_IMAGE_SCALE_Y_HP 0x8156 -#define GL_IMAGE_TRANSLATE_X_HP 0x8157 -#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 -#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 -#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A -#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B -#define GL_IMAGE_MAG_FILTER_HP 0x815C -#define GL_IMAGE_MIN_FILTER_HP 0x815D -#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E -#define GL_CUBIC_HP 0x815F -#define GL_AVERAGE_HP 0x8160 -#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 -#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 -#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 -#endif - -#ifndef GL_HP_convolution_border_modes -#define GL_IGNORE_BORDER_HP 0x8150 -#define GL_CONSTANT_BORDER_HP 0x8151 -#define GL_REPLICATE_BORDER_HP 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 -#endif - -#ifndef GL_INGR_palette_buffer -#endif - -#ifndef GL_SGIX_texture_add_env -#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE -#endif - -#ifndef GL_EXT_color_subtable -#endif - -#ifndef GL_PGI_vertex_hints -#define GL_VERTEX_DATA_HINT_PGI 0x1A22A -#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B -#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C -#define GL_MAX_VERTEX_HINT_PGI 0x1A22D -#define GL_COLOR3_BIT_PGI 0x00010000 -#define GL_COLOR4_BIT_PGI 0x00020000 -#define GL_EDGEFLAG_BIT_PGI 0x00040000 -#define GL_INDEX_BIT_PGI 0x00080000 -#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 -#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 -#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 -#define GL_MAT_EMISSION_BIT_PGI 0x00800000 -#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 -#define GL_MAT_SHININESS_BIT_PGI 0x02000000 -#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 -#define GL_NORMAL_BIT_PGI 0x08000000 -#define GL_TEXCOORD1_BIT_PGI 0x10000000 -#define GL_TEXCOORD2_BIT_PGI 0x20000000 -#define GL_TEXCOORD3_BIT_PGI 0x40000000 -#define GL_TEXCOORD4_BIT_PGI 0x80000000 -#define GL_VERTEX23_BIT_PGI 0x00000004 -#define GL_VERTEX4_BIT_PGI 0x00000008 -#endif - -#ifndef GL_PGI_misc_hints -#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 -#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD -#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE -#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 -#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 -#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 -#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C -#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D -#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E -#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F -#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 -#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 -#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 -#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 -#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 -#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 -#define GL_CLIP_NEAR_HINT_PGI 0x1A220 -#define GL_CLIP_FAR_HINT_PGI 0x1A221 -#define GL_WIDE_LINE_HINT_PGI 0x1A222 -#define GL_BACK_NORMALS_HINT_PGI 0x1A223 -#endif - -#ifndef GL_EXT_paletted_texture -#define GL_COLOR_INDEX1_EXT 0x80E2 -#define GL_COLOR_INDEX2_EXT 0x80E3 -#define GL_COLOR_INDEX4_EXT 0x80E4 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_COLOR_INDEX12_EXT 0x80E6 -#define GL_COLOR_INDEX16_EXT 0x80E7 -#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED -#endif - -#ifndef GL_EXT_clip_volume_hint -#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 -#endif - -#ifndef GL_SGIX_list_priority -#define GL_LIST_PRIORITY_SGIX 0x8182 -#endif - -#ifndef GL_SGIX_ir_instrument1 -#define GL_IR_INSTRUMENT1_SGIX 0x817F -#endif - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 -#endif - -#ifndef GL_SGIX_texture_lod_bias -#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E -#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F -#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 -#endif - -#ifndef GL_SGIX_shadow_ambient -#define GL_SHADOW_AMBIENT_SGIX 0x80BF -#endif - -#ifndef GL_EXT_index_texture -#endif - -#ifndef GL_EXT_index_material -#define GL_INDEX_MATERIAL_EXT 0x81B8 -#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 -#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA -#endif - -#ifndef GL_EXT_index_func -#define GL_INDEX_TEST_EXT 0x81B5 -#define GL_INDEX_TEST_FUNC_EXT 0x81B6 -#define GL_INDEX_TEST_REF_EXT 0x81B7 -#endif - -#ifndef GL_EXT_index_array_formats -#define GL_IUI_V2F_EXT 0x81AD -#define GL_IUI_V3F_EXT 0x81AE -#define GL_IUI_N3F_V2F_EXT 0x81AF -#define GL_IUI_N3F_V3F_EXT 0x81B0 -#define GL_T2F_IUI_V2F_EXT 0x81B1 -#define GL_T2F_IUI_V3F_EXT 0x81B2 -#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 -#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 -#endif - -#ifndef GL_EXT_compiled_vertex_array -#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 -#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 -#endif - -#ifndef GL_EXT_cull_vertex -#define GL_CULL_VERTEX_EXT 0x81AA -#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB -#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC -#endif - -#ifndef GL_SGIX_ycrcb -#define GL_YCRCB_422_SGIX 0x81BB -#define GL_YCRCB_444_SGIX 0x81BC -#endif - -#ifndef GL_SGIX_fragment_lighting -#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 -#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 -#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 -#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 -#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 -#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 -#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 -#define GL_LIGHT_ENV_MODE_SGIX 0x8407 -#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 -#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 -#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A -#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B -#define GL_FRAGMENT_LIGHT0_SGIX 0x840C -#define GL_FRAGMENT_LIGHT1_SGIX 0x840D -#define GL_FRAGMENT_LIGHT2_SGIX 0x840E -#define GL_FRAGMENT_LIGHT3_SGIX 0x840F -#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 -#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 -#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 -#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 -#endif - -#ifndef GL_IBM_rasterpos_clip -#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 -#endif - -#ifndef GL_HP_texture_lighting -#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 -#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 -#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 -#endif - -#ifndef GL_EXT_draw_range_elements -#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 -#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 -#endif - -#ifndef GL_WIN_phong_shading -#define GL_PHONG_WIN 0x80EA -#define GL_PHONG_HINT_WIN 0x80EB -#endif - -#ifndef GL_WIN_specular_fog -#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC -#endif - -#ifndef GL_EXT_light_texture -#define GL_FRAGMENT_MATERIAL_EXT 0x8349 -#define GL_FRAGMENT_NORMAL_EXT 0x834A -#define GL_FRAGMENT_COLOR_EXT 0x834C -#define GL_ATTENUATION_EXT 0x834D -#define GL_SHADOW_ATTENUATION_EXT 0x834E -#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F -#define GL_TEXTURE_LIGHT_EXT 0x8350 -#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 -#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 -/* reuse GL_FRAGMENT_DEPTH_EXT */ -#endif - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_ALPHA_MIN_SGIX 0x8320 -#define GL_ALPHA_MAX_SGIX 0x8321 -#endif - -#ifndef GL_SGIX_impact_pixel_texture -#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 -#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 -#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 -#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 -#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 -#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 -#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A -#endif - -#ifndef GL_EXT_bgra -#define GL_BGR_EXT 0x80E0 -#define GL_BGRA_EXT 0x80E1 -#endif - -#ifndef GL_SGIX_async -#define GL_ASYNC_MARKER_SGIX 0x8329 -#endif - -#ifndef GL_SGIX_async_pixel -#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C -#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D -#define GL_ASYNC_READ_PIXELS_SGIX 0x835E -#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F -#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 -#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 -#endif - -#ifndef GL_SGIX_async_histogram -#define GL_ASYNC_HISTOGRAM_SGIX 0x832C -#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D -#endif - -#ifndef GL_INTEL_texture_scissor -#endif - -#ifndef GL_INTEL_parallel_arrays -#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 -#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 -#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 -#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 -#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 -#endif - -#ifndef GL_HP_occlusion_test -#define GL_OCCLUSION_TEST_HP 0x8165 -#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 -#endif - -#ifndef GL_EXT_pixel_transform -#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 -#define GL_PIXEL_MAG_FILTER_EXT 0x8331 -#define GL_PIXEL_MIN_FILTER_EXT 0x8332 -#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 -#define GL_CUBIC_EXT 0x8334 -#define GL_AVERAGE_EXT 0x8335 -#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 -#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 -#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 -#endif - -#ifndef GL_EXT_pixel_transform_color_table -#endif - -#ifndef GL_EXT_shared_texture_palette -#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB -#endif - -#ifndef GL_EXT_separate_specular_color -#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 -#define GL_SINGLE_COLOR_EXT 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA -#endif - -#ifndef GL_EXT_secondary_color -#define GL_COLOR_SUM_EXT 0x8458 -#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D -#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E -#endif - -#ifndef GL_EXT_texture_perturb_normal -#define GL_PERTURB_EXT 0x85AE -#define GL_TEXTURE_NORMAL_EXT 0x85AF -#endif - -#ifndef GL_EXT_multi_draw_arrays -#endif - -#ifndef GL_EXT_fog_coord -#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 -#define GL_FOG_COORDINATE_EXT 0x8451 -#define GL_FRAGMENT_DEPTH_EXT 0x8452 -#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 -#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 -#endif - -#ifndef GL_REND_screen_coordinates -#define GL_SCREEN_COORDINATES_REND 0x8490 -#define GL_INVERTED_SCREEN_W_REND 0x8491 -#endif - -#ifndef GL_EXT_coordinate_frame -#define GL_TANGENT_ARRAY_EXT 0x8439 -#define GL_BINORMAL_ARRAY_EXT 0x843A -#define GL_CURRENT_TANGENT_EXT 0x843B -#define GL_CURRENT_BINORMAL_EXT 0x843C -#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E -#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F -#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 -#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 -#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 -#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 -#define GL_MAP1_TANGENT_EXT 0x8444 -#define GL_MAP2_TANGENT_EXT 0x8445 -#define GL_MAP1_BINORMAL_EXT 0x8446 -#define GL_MAP2_BINORMAL_EXT 0x8447 -#endif - -#ifndef GL_EXT_texture_env_combine -#define GL_COMBINE_EXT 0x8570 -#define GL_COMBINE_RGB_EXT 0x8571 -#define GL_COMBINE_ALPHA_EXT 0x8572 -#define GL_RGB_SCALE_EXT 0x8573 -#define GL_ADD_SIGNED_EXT 0x8574 -#define GL_INTERPOLATE_EXT 0x8575 -#define GL_CONSTANT_EXT 0x8576 -#define GL_PRIMARY_COLOR_EXT 0x8577 -#define GL_PREVIOUS_EXT 0x8578 -#define GL_SOURCE0_RGB_EXT 0x8580 -#define GL_SOURCE1_RGB_EXT 0x8581 -#define GL_SOURCE2_RGB_EXT 0x8582 -#define GL_SOURCE0_ALPHA_EXT 0x8588 -#define GL_SOURCE1_ALPHA_EXT 0x8589 -#define GL_SOURCE2_ALPHA_EXT 0x858A -#define GL_OPERAND0_RGB_EXT 0x8590 -#define GL_OPERAND1_RGB_EXT 0x8591 -#define GL_OPERAND2_RGB_EXT 0x8592 -#define GL_OPERAND0_ALPHA_EXT 0x8598 -#define GL_OPERAND1_ALPHA_EXT 0x8599 -#define GL_OPERAND2_ALPHA_EXT 0x859A -#endif - -#ifndef GL_APPLE_specular_vector -#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 -#endif - -#ifndef GL_APPLE_transform_hint -#define GL_TRANSFORM_HINT_APPLE 0x85B1 -#endif - -#ifndef GL_SGIX_fog_scale -#define GL_FOG_SCALE_SGIX 0x81FC -#define GL_FOG_SCALE_VALUE_SGIX 0x81FD -#endif - -#ifndef GL_SUNX_constant_data -#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 -#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 -#endif - -#ifndef GL_SUN_global_alpha -#define GL_GLOBAL_ALPHA_SUN 0x81D9 -#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA -#endif - -#ifndef GL_SUN_triangle_list -#define GL_RESTART_SUN 0x0001 -#define GL_REPLACE_MIDDLE_SUN 0x0002 -#define GL_REPLACE_OLDEST_SUN 0x0003 -#define GL_TRIANGLE_LIST_SUN 0x81D7 -#define GL_REPLACEMENT_CODE_SUN 0x81D8 -#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 -#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 -#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 -#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 -#define GL_R1UI_V3F_SUN 0x85C4 -#define GL_R1UI_C4UB_V3F_SUN 0x85C5 -#define GL_R1UI_C3F_V3F_SUN 0x85C6 -#define GL_R1UI_N3F_V3F_SUN 0x85C7 -#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 -#define GL_R1UI_T2F_V3F_SUN 0x85C9 -#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA -#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB -#endif - -#ifndef GL_SUN_vertex -#endif - -#ifndef GL_EXT_blend_func_separate -#define GL_BLEND_DST_RGB_EXT 0x80C8 -#define GL_BLEND_SRC_RGB_EXT 0x80C9 -#define GL_BLEND_DST_ALPHA_EXT 0x80CA -#define GL_BLEND_SRC_ALPHA_EXT 0x80CB -#endif - -#ifndef GL_INGR_color_clamp -#define GL_RED_MIN_CLAMP_INGR 0x8560 -#define GL_GREEN_MIN_CLAMP_INGR 0x8561 -#define GL_BLUE_MIN_CLAMP_INGR 0x8562 -#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 -#define GL_RED_MAX_CLAMP_INGR 0x8564 -#define GL_GREEN_MAX_CLAMP_INGR 0x8565 -#define GL_BLUE_MAX_CLAMP_INGR 0x8566 -#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 -#endif - -#ifndef GL_INGR_interlace_read -#define GL_INTERLACE_READ_INGR 0x8568 -#endif - -#ifndef GL_EXT_stencil_wrap -#define GL_INCR_WRAP_EXT 0x8507 -#define GL_DECR_WRAP_EXT 0x8508 -#endif - -#ifndef GL_EXT_422_pixels -#define GL_422_EXT 0x80CC -#define GL_422_REV_EXT 0x80CD -#define GL_422_AVERAGE_EXT 0x80CE -#define GL_422_REV_AVERAGE_EXT 0x80CF -#endif - -#ifndef GL_NV_texgen_reflection -#define GL_NORMAL_MAP_NV 0x8511 -#define GL_REFLECTION_MAP_NV 0x8512 -#endif - -#ifndef GL_EXT_texture_cube_map -#define GL_NORMAL_MAP_EXT 0x8511 -#define GL_REFLECTION_MAP_EXT 0x8512 -#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C -#endif - -#ifndef GL_SUN_convolution_border_modes -#define GL_WRAP_BORDER_SUN 0x81D4 -#endif - -#ifndef GL_EXT_texture_env_add -#endif - -#ifndef GL_EXT_texture_lod_bias -#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD -#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 -#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 -#endif - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif - -#ifndef GL_EXT_vertex_weighting -#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH -#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 -#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX -#define GL_MODELVIEW1_MATRIX_EXT 0x8506 -#define GL_VERTEX_WEIGHTING_EXT 0x8509 -#define GL_MODELVIEW0_EXT GL_MODELVIEW -#define GL_MODELVIEW1_EXT 0x850A -#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B -#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C -#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D -#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E -#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F -#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 -#endif - -#ifndef GL_NV_light_max_exponent -#define GL_MAX_SHININESS_NV 0x8504 -#define GL_MAX_SPOT_EXPONENT_NV 0x8505 -#endif - -#ifndef GL_NV_vertex_array_range -#define GL_VERTEX_ARRAY_RANGE_NV 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E -#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F -#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 -#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 -#endif - -#ifndef GL_NV_register_combiners -#define GL_REGISTER_COMBINERS_NV 0x8522 -#define GL_VARIABLE_A_NV 0x8523 -#define GL_VARIABLE_B_NV 0x8524 -#define GL_VARIABLE_C_NV 0x8525 -#define GL_VARIABLE_D_NV 0x8526 -#define GL_VARIABLE_E_NV 0x8527 -#define GL_VARIABLE_F_NV 0x8528 -#define GL_VARIABLE_G_NV 0x8529 -#define GL_CONSTANT_COLOR0_NV 0x852A -#define GL_CONSTANT_COLOR1_NV 0x852B -#define GL_PRIMARY_COLOR_NV 0x852C -#define GL_SECONDARY_COLOR_NV 0x852D -#define GL_SPARE0_NV 0x852E -#define GL_SPARE1_NV 0x852F -#define GL_DISCARD_NV 0x8530 -#define GL_E_TIMES_F_NV 0x8531 -#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 -#define GL_UNSIGNED_IDENTITY_NV 0x8536 -#define GL_UNSIGNED_INVERT_NV 0x8537 -#define GL_EXPAND_NORMAL_NV 0x8538 -#define GL_EXPAND_NEGATE_NV 0x8539 -#define GL_HALF_BIAS_NORMAL_NV 0x853A -#define GL_HALF_BIAS_NEGATE_NV 0x853B -#define GL_SIGNED_IDENTITY_NV 0x853C -#define GL_SIGNED_NEGATE_NV 0x853D -#define GL_SCALE_BY_TWO_NV 0x853E -#define GL_SCALE_BY_FOUR_NV 0x853F -#define GL_SCALE_BY_ONE_HALF_NV 0x8540 -#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 -#define GL_COMBINER_INPUT_NV 0x8542 -#define GL_COMBINER_MAPPING_NV 0x8543 -#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 -#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 -#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 -#define GL_COMBINER_MUX_SUM_NV 0x8547 -#define GL_COMBINER_SCALE_NV 0x8548 -#define GL_COMBINER_BIAS_NV 0x8549 -#define GL_COMBINER_AB_OUTPUT_NV 0x854A -#define GL_COMBINER_CD_OUTPUT_NV 0x854B -#define GL_COMBINER_SUM_OUTPUT_NV 0x854C -#define GL_MAX_GENERAL_COMBINERS_NV 0x854D -#define GL_NUM_GENERAL_COMBINERS_NV 0x854E -#define GL_COLOR_SUM_CLAMP_NV 0x854F -#define GL_COMBINER0_NV 0x8550 -#define GL_COMBINER1_NV 0x8551 -#define GL_COMBINER2_NV 0x8552 -#define GL_COMBINER3_NV 0x8553 -#define GL_COMBINER4_NV 0x8554 -#define GL_COMBINER5_NV 0x8555 -#define GL_COMBINER6_NV 0x8556 -#define GL_COMBINER7_NV 0x8557 -/* reuse GL_TEXTURE0_ARB */ -/* reuse GL_TEXTURE1_ARB */ -/* reuse GL_ZERO */ -/* reuse GL_NONE */ -/* reuse GL_FOG */ -#endif - -#ifndef GL_NV_fog_distance -#define GL_FOG_DISTANCE_MODE_NV 0x855A -#define GL_EYE_RADIAL_NV 0x855B -#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C -/* reuse GL_EYE_PLANE */ -#endif - -#ifndef GL_NV_texgen_emboss -#define GL_EMBOSS_LIGHT_NV 0x855D -#define GL_EMBOSS_CONSTANT_NV 0x855E -#define GL_EMBOSS_MAP_NV 0x855F -#endif - -#ifndef GL_NV_blend_square -#endif - -#ifndef GL_NV_texture_env_combine4 -#define GL_COMBINE4_NV 0x8503 -#define GL_SOURCE3_RGB_NV 0x8583 -#define GL_SOURCE3_ALPHA_NV 0x858B -#define GL_OPERAND3_RGB_NV 0x8593 -#define GL_OPERAND3_ALPHA_NV 0x859B -#endif - -#ifndef GL_MESA_resize_buffers -#endif - -#ifndef GL_MESA_window_pos -#endif - -#ifndef GL_EXT_texture_compression_s3tc -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 -#endif - -#ifndef GL_IBM_cull_vertex -#define GL_CULL_VERTEX_IBM 103050 -#endif - -#ifndef GL_IBM_multimode_draw_arrays -#endif - -#ifndef GL_IBM_vertex_array_lists -#define GL_VERTEX_ARRAY_LIST_IBM 103070 -#define GL_NORMAL_ARRAY_LIST_IBM 103071 -#define GL_COLOR_ARRAY_LIST_IBM 103072 -#define GL_INDEX_ARRAY_LIST_IBM 103073 -#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 -#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 -#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 -#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 -#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 -#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 -#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 -#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 -#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 -#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 -#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 -#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 -#endif - -#ifndef GL_SGIX_subsample -#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 -#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 -#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 -#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 -#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 -#endif - -#ifndef GL_SGIX_ycrcb_subsample -#endif - -#ifndef GL_SGIX_ycrcba -#define GL_YCRCB_SGIX 0x8318 -#define GL_YCRCBA_SGIX 0x8319 -#endif - -#ifndef GL_SGI_depth_pass_instrument -#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 -#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 -#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 -#endif - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 -#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 -#endif - -#ifndef GL_3DFX_multisample -#define GL_MULTISAMPLE_3DFX 0x86B2 -#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 -#define GL_SAMPLES_3DFX 0x86B4 -#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 -#endif - -#ifndef GL_3DFX_tbuffer -#endif - -#ifndef GL_EXT_multisample -#define GL_MULTISAMPLE_EXT 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F -#define GL_SAMPLE_MASK_EXT 0x80A0 -#define GL_1PASS_EXT 0x80A1 -#define GL_2PASS_0_EXT 0x80A2 -#define GL_2PASS_1_EXT 0x80A3 -#define GL_4PASS_0_EXT 0x80A4 -#define GL_4PASS_1_EXT 0x80A5 -#define GL_4PASS_2_EXT 0x80A6 -#define GL_4PASS_3_EXT 0x80A7 -#define GL_SAMPLE_BUFFERS_EXT 0x80A8 -#define GL_SAMPLES_EXT 0x80A9 -#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA -#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB -#define GL_SAMPLE_PATTERN_EXT 0x80AC -#define GL_MULTISAMPLE_BIT_EXT 0x20000000 -#endif - -#ifndef GL_SGIX_vertex_preclip -#define GL_VERTEX_PRECLIP_SGIX 0x83EE -#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF -#endif - -#ifndef GL_SGIX_convolution_accuracy -#define GL_CONVOLUTION_HINT_SGIX 0x8316 -#endif - -#ifndef GL_SGIX_resample -#define GL_PACK_RESAMPLE_SGIX 0x842C -#define GL_UNPACK_RESAMPLE_SGIX 0x842D -#define GL_RESAMPLE_REPLICATE_SGIX 0x842E -#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F -#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 -#endif - -#ifndef GL_SGIS_point_line_texgen -#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 -#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 -#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 -#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 -#define GL_EYE_POINT_SGIS 0x81F4 -#define GL_OBJECT_POINT_SGIS 0x81F5 -#define GL_EYE_LINE_SGIS 0x81F6 -#define GL_OBJECT_LINE_SGIS 0x81F7 -#endif - -#ifndef GL_SGIS_texture_color_mask -#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF -#endif - -#ifndef GL_EXT_texture_env_dot3 -#define GL_DOT3_RGB_EXT 0x8740 -#define GL_DOT3_RGBA_EXT 0x8741 -#endif - -#ifndef GL_ATI_texture_mirror_once -#define GL_MIRROR_CLAMP_ATI 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 -#endif - -#ifndef GL_NV_fence -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 -#endif - -#ifndef GL_IBM_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_IBM 0x8370 -#endif - -#ifndef GL_NV_evaluators -#define GL_EVAL_2D_NV 0x86C0 -#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 -#define GL_MAP_TESSELLATION_NV 0x86C2 -#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 -#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 -#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 -#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 -#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 -#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 -#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 -#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA -#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB -#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC -#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD -#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE -#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF -#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 -#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 -#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 -#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 -#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 -#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 -#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 -#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 -#endif - -#ifndef GL_NV_packed_depth_stencil -#define GL_DEPTH_STENCIL_NV 0x84F9 -#define GL_UNSIGNED_INT_24_8_NV 0x84FA -#endif - -#ifndef GL_NV_register_combiners2 -#define GL_PER_STAGE_CONSTANTS_NV 0x8535 -#endif - -#ifndef GL_NV_texture_compression_vtc -#endif - -#ifndef GL_NV_texture_rectangle -#define GL_TEXTURE_RECTANGLE_NV 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 -#endif - -#ifndef GL_NV_texture_shader -#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C -#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D -#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E -#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 -#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA -#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB -#define GL_DSDT_MAG_INTENSITY_NV 0x86DC -#define GL_SHADER_CONSISTENT_NV 0x86DD -#define GL_TEXTURE_SHADER_NV 0x86DE -#define GL_SHADER_OPERATION_NV 0x86DF -#define GL_CULL_MODES_NV 0x86E0 -#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 -#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV -#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV -#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV -#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 -#define GL_CONST_EYE_NV 0x86E5 -#define GL_PASS_THROUGH_NV 0x86E6 -#define GL_CULL_FRAGMENT_NV 0x86E7 -#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 -#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 -#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA -#define GL_DOT_PRODUCT_NV 0x86EC -#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED -#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE -#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 -#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 -#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 -#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 -#define GL_HILO_NV 0x86F4 -#define GL_DSDT_NV 0x86F5 -#define GL_DSDT_MAG_NV 0x86F6 -#define GL_DSDT_MAG_VIB_NV 0x86F7 -#define GL_HILO16_NV 0x86F8 -#define GL_SIGNED_HILO_NV 0x86F9 -#define GL_SIGNED_HILO16_NV 0x86FA -#define GL_SIGNED_RGBA_NV 0x86FB -#define GL_SIGNED_RGBA8_NV 0x86FC -#define GL_SIGNED_RGB_NV 0x86FE -#define GL_SIGNED_RGB8_NV 0x86FF -#define GL_SIGNED_LUMINANCE_NV 0x8701 -#define GL_SIGNED_LUMINANCE8_NV 0x8702 -#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 -#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 -#define GL_SIGNED_ALPHA_NV 0x8705 -#define GL_SIGNED_ALPHA8_NV 0x8706 -#define GL_SIGNED_INTENSITY_NV 0x8707 -#define GL_SIGNED_INTENSITY8_NV 0x8708 -#define GL_DSDT8_NV 0x8709 -#define GL_DSDT8_MAG8_NV 0x870A -#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B -#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C -#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D -#define GL_HI_SCALE_NV 0x870E -#define GL_LO_SCALE_NV 0x870F -#define GL_DS_SCALE_NV 0x8710 -#define GL_DT_SCALE_NV 0x8711 -#define GL_MAGNITUDE_SCALE_NV 0x8712 -#define GL_VIBRANCE_SCALE_NV 0x8713 -#define GL_HI_BIAS_NV 0x8714 -#define GL_LO_BIAS_NV 0x8715 -#define GL_DS_BIAS_NV 0x8716 -#define GL_DT_BIAS_NV 0x8717 -#define GL_MAGNITUDE_BIAS_NV 0x8718 -#define GL_VIBRANCE_BIAS_NV 0x8719 -#define GL_TEXTURE_BORDER_VALUES_NV 0x871A -#define GL_TEXTURE_HI_SIZE_NV 0x871B -#define GL_TEXTURE_LO_SIZE_NV 0x871C -#define GL_TEXTURE_DS_SIZE_NV 0x871D -#define GL_TEXTURE_DT_SIZE_NV 0x871E -#define GL_TEXTURE_MAG_SIZE_NV 0x871F -#endif - -#ifndef GL_NV_texture_shader2 -#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF -#endif - -#ifndef GL_NV_vertex_array_range2 -#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 -#endif - -#ifndef GL_NV_vertex_program -#define GL_VERTEX_PROGRAM_NV 0x8620 -#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 -#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 -#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 -#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 -#define GL_CURRENT_ATTRIB_NV 0x8626 -#define GL_PROGRAM_LENGTH_NV 0x8627 -#define GL_PROGRAM_STRING_NV 0x8628 -#define GL_MODELVIEW_PROJECTION_NV 0x8629 -#define GL_IDENTITY_NV 0x862A -#define GL_INVERSE_NV 0x862B -#define GL_TRANSPOSE_NV 0x862C -#define GL_INVERSE_TRANSPOSE_NV 0x862D -#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E -#define GL_MAX_TRACK_MATRICES_NV 0x862F -#define GL_MATRIX0_NV 0x8630 -#define GL_MATRIX1_NV 0x8631 -#define GL_MATRIX2_NV 0x8632 -#define GL_MATRIX3_NV 0x8633 -#define GL_MATRIX4_NV 0x8634 -#define GL_MATRIX5_NV 0x8635 -#define GL_MATRIX6_NV 0x8636 -#define GL_MATRIX7_NV 0x8637 -#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 -#define GL_CURRENT_MATRIX_NV 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 -#define GL_PROGRAM_PARAMETER_NV 0x8644 -#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 -#define GL_PROGRAM_TARGET_NV 0x8646 -#define GL_PROGRAM_RESIDENT_NV 0x8647 -#define GL_TRACK_MATRIX_NV 0x8648 -#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 -#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A -#define GL_PROGRAM_ERROR_POSITION_NV 0x864B -#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 -#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 -#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 -#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 -#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 -#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 -#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 -#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 -#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 -#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 -#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A -#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B -#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C -#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D -#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E -#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F -#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 -#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 -#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 -#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 -#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 -#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 -#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 -#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 -#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 -#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 -#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A -#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B -#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C -#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D -#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E -#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F -#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 -#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 -#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 -#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 -#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 -#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 -#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 -#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 -#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 -#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 -#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A -#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B -#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C -#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D -#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E -#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F -#endif - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 -#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A -#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B -#endif - -#ifndef GL_SGIX_scalebias_hint -#define GL_SCALEBIAS_HINT_SGIX 0x8322 -#endif - -#ifndef GL_OML_interlace -#define GL_INTERLACE_OML 0x8980 -#define GL_INTERLACE_READ_OML 0x8981 -#endif - -#ifndef GL_OML_subsample -#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 -#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 -#endif - -#ifndef GL_OML_resample -#define GL_PACK_RESAMPLE_OML 0x8984 -#define GL_UNPACK_RESAMPLE_OML 0x8985 -#define GL_RESAMPLE_REPLICATE_OML 0x8986 -#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 -#define GL_RESAMPLE_AVERAGE_OML 0x8988 -#define GL_RESAMPLE_DECIMATE_OML 0x8989 -#endif - -#ifndef GL_NV_copy_depth_to_color -#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E -#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F -#endif - -#ifndef GL_ATI_envmap_bumpmap -#define GL_BUMP_ROT_MATRIX_ATI 0x8775 -#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 -#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 -#define GL_BUMP_TEX_UNITS_ATI 0x8778 -#define GL_DUDV_ATI 0x8779 -#define GL_DU8DV8_ATI 0x877A -#define GL_BUMP_ENVMAP_ATI 0x877B -#define GL_BUMP_TARGET_ATI 0x877C -#endif - -#ifndef GL_ATI_fragment_shader -#define GL_FRAGMENT_SHADER_ATI 0x8920 -#define GL_REG_0_ATI 0x8921 -#define GL_REG_1_ATI 0x8922 -#define GL_REG_2_ATI 0x8923 -#define GL_REG_3_ATI 0x8924 -#define GL_REG_4_ATI 0x8925 -#define GL_REG_5_ATI 0x8926 -#define GL_REG_6_ATI 0x8927 -#define GL_REG_7_ATI 0x8928 -#define GL_REG_8_ATI 0x8929 -#define GL_REG_9_ATI 0x892A -#define GL_REG_10_ATI 0x892B -#define GL_REG_11_ATI 0x892C -#define GL_REG_12_ATI 0x892D -#define GL_REG_13_ATI 0x892E -#define GL_REG_14_ATI 0x892F -#define GL_REG_15_ATI 0x8930 -#define GL_REG_16_ATI 0x8931 -#define GL_REG_17_ATI 0x8932 -#define GL_REG_18_ATI 0x8933 -#define GL_REG_19_ATI 0x8934 -#define GL_REG_20_ATI 0x8935 -#define GL_REG_21_ATI 0x8936 -#define GL_REG_22_ATI 0x8937 -#define GL_REG_23_ATI 0x8938 -#define GL_REG_24_ATI 0x8939 -#define GL_REG_25_ATI 0x893A -#define GL_REG_26_ATI 0x893B -#define GL_REG_27_ATI 0x893C -#define GL_REG_28_ATI 0x893D -#define GL_REG_29_ATI 0x893E -#define GL_REG_30_ATI 0x893F -#define GL_REG_31_ATI 0x8940 -#define GL_CON_0_ATI 0x8941 -#define GL_CON_1_ATI 0x8942 -#define GL_CON_2_ATI 0x8943 -#define GL_CON_3_ATI 0x8944 -#define GL_CON_4_ATI 0x8945 -#define GL_CON_5_ATI 0x8946 -#define GL_CON_6_ATI 0x8947 -#define GL_CON_7_ATI 0x8948 -#define GL_CON_8_ATI 0x8949 -#define GL_CON_9_ATI 0x894A -#define GL_CON_10_ATI 0x894B -#define GL_CON_11_ATI 0x894C -#define GL_CON_12_ATI 0x894D -#define GL_CON_13_ATI 0x894E -#define GL_CON_14_ATI 0x894F -#define GL_CON_15_ATI 0x8950 -#define GL_CON_16_ATI 0x8951 -#define GL_CON_17_ATI 0x8952 -#define GL_CON_18_ATI 0x8953 -#define GL_CON_19_ATI 0x8954 -#define GL_CON_20_ATI 0x8955 -#define GL_CON_21_ATI 0x8956 -#define GL_CON_22_ATI 0x8957 -#define GL_CON_23_ATI 0x8958 -#define GL_CON_24_ATI 0x8959 -#define GL_CON_25_ATI 0x895A -#define GL_CON_26_ATI 0x895B -#define GL_CON_27_ATI 0x895C -#define GL_CON_28_ATI 0x895D -#define GL_CON_29_ATI 0x895E -#define GL_CON_30_ATI 0x895F -#define GL_CON_31_ATI 0x8960 -#define GL_MOV_ATI 0x8961 -#define GL_ADD_ATI 0x8963 -#define GL_MUL_ATI 0x8964 -#define GL_SUB_ATI 0x8965 -#define GL_DOT3_ATI 0x8966 -#define GL_DOT4_ATI 0x8967 -#define GL_MAD_ATI 0x8968 -#define GL_LERP_ATI 0x8969 -#define GL_CND_ATI 0x896A -#define GL_CND0_ATI 0x896B -#define GL_DOT2_ADD_ATI 0x896C -#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D -#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E -#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F -#define GL_NUM_PASSES_ATI 0x8970 -#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 -#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 -#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 -#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 -#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 -#define GL_SWIZZLE_STR_ATI 0x8976 -#define GL_SWIZZLE_STQ_ATI 0x8977 -#define GL_SWIZZLE_STR_DR_ATI 0x8978 -#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 -#define GL_SWIZZLE_STRQ_ATI 0x897A -#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B -#define GL_RED_BIT_ATI 0x00000001 -#define GL_GREEN_BIT_ATI 0x00000002 -#define GL_BLUE_BIT_ATI 0x00000004 -#define GL_2X_BIT_ATI 0x00000001 -#define GL_4X_BIT_ATI 0x00000002 -#define GL_8X_BIT_ATI 0x00000004 -#define GL_HALF_BIT_ATI 0x00000008 -#define GL_QUARTER_BIT_ATI 0x00000010 -#define GL_EIGHTH_BIT_ATI 0x00000020 -#define GL_SATURATE_BIT_ATI 0x00000040 -#define GL_COMP_BIT_ATI 0x00000002 -#define GL_NEGATE_BIT_ATI 0x00000004 -#define GL_BIAS_BIT_ATI 0x00000008 -#endif - -#ifndef GL_ATI_pn_triangles -#define GL_PN_TRIANGLES_ATI 0x87F0 -#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 -#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 -#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 -#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 -#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 -#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 -#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 -#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 -#endif - -#ifndef GL_ATI_vertex_array_object -#define GL_STATIC_ATI 0x8760 -#define GL_DYNAMIC_ATI 0x8761 -#define GL_PRESERVE_ATI 0x8762 -#define GL_DISCARD_ATI 0x8763 -#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 -#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 -#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 -#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 -#endif - -#ifndef GL_EXT_vertex_shader -#define GL_VERTEX_SHADER_EXT 0x8780 -#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 -#define GL_OP_INDEX_EXT 0x8782 -#define GL_OP_NEGATE_EXT 0x8783 -#define GL_OP_DOT3_EXT 0x8784 -#define GL_OP_DOT4_EXT 0x8785 -#define GL_OP_MUL_EXT 0x8786 -#define GL_OP_ADD_EXT 0x8787 -#define GL_OP_MADD_EXT 0x8788 -#define GL_OP_FRAC_EXT 0x8789 -#define GL_OP_MAX_EXT 0x878A -#define GL_OP_MIN_EXT 0x878B -#define GL_OP_SET_GE_EXT 0x878C -#define GL_OP_SET_LT_EXT 0x878D -#define GL_OP_CLAMP_EXT 0x878E -#define GL_OP_FLOOR_EXT 0x878F -#define GL_OP_ROUND_EXT 0x8790 -#define GL_OP_EXP_BASE_2_EXT 0x8791 -#define GL_OP_LOG_BASE_2_EXT 0x8792 -#define GL_OP_POWER_EXT 0x8793 -#define GL_OP_RECIP_EXT 0x8794 -#define GL_OP_RECIP_SQRT_EXT 0x8795 -#define GL_OP_SUB_EXT 0x8796 -#define GL_OP_CROSS_PRODUCT_EXT 0x8797 -#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 -#define GL_OP_MOV_EXT 0x8799 -#define GL_OUTPUT_VERTEX_EXT 0x879A -#define GL_OUTPUT_COLOR0_EXT 0x879B -#define GL_OUTPUT_COLOR1_EXT 0x879C -#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D -#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E -#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F -#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 -#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 -#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 -#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 -#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 -#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 -#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 -#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 -#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 -#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 -#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA -#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB -#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC -#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD -#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE -#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF -#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 -#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 -#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 -#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 -#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 -#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 -#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 -#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 -#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 -#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 -#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA -#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB -#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC -#define GL_OUTPUT_FOG_EXT 0x87BD -#define GL_SCALAR_EXT 0x87BE -#define GL_VECTOR_EXT 0x87BF -#define GL_MATRIX_EXT 0x87C0 -#define GL_VARIANT_EXT 0x87C1 -#define GL_INVARIANT_EXT 0x87C2 -#define GL_LOCAL_CONSTANT_EXT 0x87C3 -#define GL_LOCAL_EXT 0x87C4 -#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 -#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 -#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 -#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 -#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE -#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF -#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 -#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 -#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 -#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 -#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 -#define GL_X_EXT 0x87D5 -#define GL_Y_EXT 0x87D6 -#define GL_Z_EXT 0x87D7 -#define GL_W_EXT 0x87D8 -#define GL_NEGATIVE_X_EXT 0x87D9 -#define GL_NEGATIVE_Y_EXT 0x87DA -#define GL_NEGATIVE_Z_EXT 0x87DB -#define GL_NEGATIVE_W_EXT 0x87DC -#define GL_ZERO_EXT 0x87DD -#define GL_ONE_EXT 0x87DE -#define GL_NEGATIVE_ONE_EXT 0x87DF -#define GL_NORMALIZED_RANGE_EXT 0x87E0 -#define GL_FULL_RANGE_EXT 0x87E1 -#define GL_CURRENT_VERTEX_EXT 0x87E2 -#define GL_MVP_MATRIX_EXT 0x87E3 -#define GL_VARIANT_VALUE_EXT 0x87E4 -#define GL_VARIANT_DATATYPE_EXT 0x87E5 -#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 -#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 -#define GL_VARIANT_ARRAY_EXT 0x87E8 -#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 -#define GL_INVARIANT_VALUE_EXT 0x87EA -#define GL_INVARIANT_DATATYPE_EXT 0x87EB -#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC -#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED -#endif - -#ifndef GL_ATI_vertex_streams -#define GL_MAX_VERTEX_STREAMS_ATI 0x876B -#define GL_VERTEX_STREAM0_ATI 0x876C -#define GL_VERTEX_STREAM1_ATI 0x876D -#define GL_VERTEX_STREAM2_ATI 0x876E -#define GL_VERTEX_STREAM3_ATI 0x876F -#define GL_VERTEX_STREAM4_ATI 0x8770 -#define GL_VERTEX_STREAM5_ATI 0x8771 -#define GL_VERTEX_STREAM6_ATI 0x8772 -#define GL_VERTEX_STREAM7_ATI 0x8773 -#define GL_VERTEX_SOURCE_ATI 0x8774 -#endif - -#ifndef GL_ATI_element_array -#define GL_ELEMENT_ARRAY_ATI 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A -#endif - -#ifndef GL_SUN_mesh_array -#define GL_QUAD_MESH_SUN 0x8614 -#define GL_TRIANGLE_MESH_SUN 0x8615 -#endif - -#ifndef GL_SUN_slice_accum -#define GL_SLICE_ACCUM_SUN 0x85CC -#endif - -#ifndef GL_NV_multisample_filter_hint -#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 -#endif - -#ifndef GL_NV_depth_clamp -#define GL_DEPTH_CLAMP_NV 0x864F -#endif - -#ifndef GL_NV_occlusion_query -#define GL_PIXEL_COUNTER_BITS_NV 0x8864 -#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 -#define GL_PIXEL_COUNT_NV 0x8866 -#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 -#endif - -#ifndef GL_NV_point_sprite -#define GL_POINT_SPRITE_NV 0x8861 -#define GL_COORD_REPLACE_NV 0x8862 -#define GL_POINT_SPRITE_R_MODE_NV 0x8863 -#endif - -#ifndef GL_NV_texture_shader3 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 -#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 -#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 -#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 -#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 -#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A -#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B -#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C -#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D -#define GL_HILO8_NV 0x885E -#define GL_SIGNED_HILO8_NV 0x885F -#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 -#endif - -#ifndef GL_NV_vertex_program1_1 -#endif - -#ifndef GL_EXT_shadow_funcs -#endif - -#ifndef GL_EXT_stencil_two_side -#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 -#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 -#endif - -#ifndef GL_ATI_text_fragment_shader -#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 -#endif - -#ifndef GL_APPLE_client_storage -#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 -#endif - -#ifndef GL_APPLE_element_array -#define GL_ELEMENT_ARRAY_APPLE 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A -#endif - -#ifndef GL_APPLE_fence -#define GL_DRAW_PIXELS_APPLE 0x8A0A -#define GL_FENCE_APPLE 0x8A0B -#endif - -#ifndef GL_APPLE_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 -#endif - -#ifndef GL_APPLE_vertex_array_range -#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E -#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F -#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 -#define GL_STORAGE_CACHED_APPLE 0x85BE -#define GL_STORAGE_SHARED_APPLE 0x85BF -#endif - -#ifndef GL_APPLE_ycbcr_422 -#define GL_YCBCR_422_APPLE 0x85B9 -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#endif - -#ifndef GL_S3_s3tc -#define GL_RGB_S3TC 0x83A0 -#define GL_RGB4_S3TC 0x83A1 -#define GL_RGBA_S3TC 0x83A2 -#define GL_RGBA4_S3TC 0x83A3 -#endif - -#ifndef GL_ATI_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 -#define GL_DRAW_BUFFER0_ATI 0x8825 -#define GL_DRAW_BUFFER1_ATI 0x8826 -#define GL_DRAW_BUFFER2_ATI 0x8827 -#define GL_DRAW_BUFFER3_ATI 0x8828 -#define GL_DRAW_BUFFER4_ATI 0x8829 -#define GL_DRAW_BUFFER5_ATI 0x882A -#define GL_DRAW_BUFFER6_ATI 0x882B -#define GL_DRAW_BUFFER7_ATI 0x882C -#define GL_DRAW_BUFFER8_ATI 0x882D -#define GL_DRAW_BUFFER9_ATI 0x882E -#define GL_DRAW_BUFFER10_ATI 0x882F -#define GL_DRAW_BUFFER11_ATI 0x8830 -#define GL_DRAW_BUFFER12_ATI 0x8831 -#define GL_DRAW_BUFFER13_ATI 0x8832 -#define GL_DRAW_BUFFER14_ATI 0x8833 -#define GL_DRAW_BUFFER15_ATI 0x8834 -#endif - -#ifndef GL_ATI_pixel_format_float -#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 -#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 -#endif - -#ifndef GL_ATI_texture_env_combine3 -#define GL_MODULATE_ADD_ATI 0x8744 -#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 -#define GL_MODULATE_SUBTRACT_ATI 0x8746 -#endif - -#ifndef GL_ATI_texture_float -#define GL_RGBA_FLOAT32_ATI 0x8814 -#define GL_RGB_FLOAT32_ATI 0x8815 -#define GL_ALPHA_FLOAT32_ATI 0x8816 -#define GL_INTENSITY_FLOAT32_ATI 0x8817 -#define GL_LUMINANCE_FLOAT32_ATI 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 -#define GL_RGBA_FLOAT16_ATI 0x881A -#define GL_RGB_FLOAT16_ATI 0x881B -#define GL_ALPHA_FLOAT16_ATI 0x881C -#define GL_INTENSITY_FLOAT16_ATI 0x881D -#define GL_LUMINANCE_FLOAT16_ATI 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F -#endif - -#ifndef GL_NV_float_buffer -#define GL_FLOAT_R_NV 0x8880 -#define GL_FLOAT_RG_NV 0x8881 -#define GL_FLOAT_RGB_NV 0x8882 -#define GL_FLOAT_RGBA_NV 0x8883 -#define GL_FLOAT_R16_NV 0x8884 -#define GL_FLOAT_R32_NV 0x8885 -#define GL_FLOAT_RG16_NV 0x8886 -#define GL_FLOAT_RG32_NV 0x8887 -#define GL_FLOAT_RGB16_NV 0x8888 -#define GL_FLOAT_RGB32_NV 0x8889 -#define GL_FLOAT_RGBA16_NV 0x888A -#define GL_FLOAT_RGBA32_NV 0x888B -#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C -#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D -#define GL_FLOAT_RGBA_MODE_NV 0x888E -#endif - -#ifndef GL_NV_fragment_program -#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 -#define GL_FRAGMENT_PROGRAM_NV 0x8870 -#define GL_MAX_TEXTURE_COORDS_NV 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 -#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 -#define GL_PROGRAM_ERROR_STRING_NV 0x8874 -#endif - -#ifndef GL_NV_half_float -#define GL_HALF_FLOAT_NV 0x140B -#endif - -#ifndef GL_NV_pixel_data_range -#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 -#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 -#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A -#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B -#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C -#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D -#endif - -#ifndef GL_NV_primitive_restart -#define GL_PRIMITIVE_RESTART_NV 0x8558 -#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 -#endif - -#ifndef GL_NV_texture_expand_normal -#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F -#endif - -#ifndef GL_NV_vertex_program2 -#endif - -#ifndef GL_ATI_map_object_buffer -#endif - -#ifndef GL_ATI_separate_stencil -#define GL_STENCIL_BACK_FUNC_ATI 0x8800 -#define GL_STENCIL_BACK_FAIL_ATI 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 -#endif - -#ifndef GL_ATI_vertex_attrib_array_object -#endif - -#ifndef GL_OES_read_format -#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B -#endif - -#ifndef GL_EXT_depth_bounds_test -#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 -#define GL_DEPTH_BOUNDS_EXT 0x8891 -#endif - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_MIRROR_CLAMP_EXT 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 -#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 -#endif - -#ifndef GL_EXT_blend_equation_separate -#define GL_BLEND_EQUATION_RGB_EXT GL_BLEND_EQUATION -#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D -#endif - -#ifndef GL_MESA_pack_invert -#define GL_PACK_INVERT_MESA 0x8758 -#endif - -#ifndef GL_MESA_ycbcr_texture -#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB -#define GL_YCBCR_MESA 0x8757 -#endif - -#ifndef GL_EXT_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF -#endif - -#ifndef GL_NV_fragment_program_option -#endif - -#ifndef GL_NV_fragment_program2 -#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 -#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 -#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 -#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 -#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 -#endif - -#ifndef GL_NV_vertex_program2_option -/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ -/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ -#endif - -#ifndef GL_NV_vertex_program3 -/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ -#endif - -#ifndef GL_EXT_framebuffer_object -#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 -#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 -#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT 0x8CD8 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 -#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF -#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 -#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 -#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 -#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 -#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 -#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 -#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 -#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 -#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 -#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA -#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB -#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC -#define GL_COLOR_ATTACHMENT13_EXT 0x8CED -#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE -#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF -#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 -#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 -#define GL_FRAMEBUFFER_EXT 0x8D40 -#define GL_RENDERBUFFER_EXT 0x8D41 -#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 -#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 -#define GL_STENCIL_INDEX1_EXT 0x8D46 -#define GL_STENCIL_INDEX4_EXT 0x8D47 -#define GL_STENCIL_INDEX8_EXT 0x8D48 -#define GL_STENCIL_INDEX16_EXT 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 -#endif - -#ifndef GL_GREMEDY_string_marker -#endif - - -/*************************************************************/ - -#include -#ifndef GL_VERSION_2_0 -/* GL type for program/shader text */ -typedef char GLchar; /* native character */ -#endif - -#ifndef GL_VERSION_1_5 -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptr; -typedef ptrdiff_t GLsizeiptr; -#endif - -#ifndef GL_ARB_vertex_buffer_object -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptrARB; -typedef ptrdiff_t GLsizeiptrARB; -#endif - -#ifndef GL_ARB_shader_objects -/* GL types for handling shader object handles and program/shader text */ -typedef char GLcharARB; /* native character */ -typedef unsigned int GLhandleARB; /* shader object handle */ -#endif - -/* GL types for "half" precision (s10e5) float data in host memory */ -#ifndef GL_ARB_half_float_pixel -typedef unsigned short GLhalfARB; -#endif - -#ifndef GL_NV_half_float -typedef unsigned short GLhalfNV; -#endif - -#ifndef GL_VERSION_1_2 -#define GL_VERSION_1_2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf); -GLAPI void APIENTRY glBlendEquation (GLenum); -GLAPI void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); -GLAPI void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyColorTable (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glGetColorTable (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetColorTableParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetColorTableParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glColorSubTable (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyColorSubTable (GLenum, GLsizei, GLint, GLint, GLsizei); -GLAPI void APIENTRY glConvolutionFilter1D (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionParameterf (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glConvolutionParameterfv (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glConvolutionParameteri (GLenum, GLenum, GLint); -GLAPI void APIENTRY glConvolutionParameteriv (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glGetConvolutionFilter (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetSeparableFilter (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); -GLAPI void APIENTRY glSeparableFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); -GLAPI void APIENTRY glGetHistogram (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetHistogramParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetHistogramParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMinmax (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glHistogram (GLenum, GLsizei, GLenum, GLboolean); -GLAPI void APIENTRY glMinmax (GLenum, GLenum, GLboolean); -GLAPI void APIENTRY glResetHistogram (GLenum); -GLAPI void APIENTRY glResetMinmax (GLenum); -GLAPI void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); -typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_VERSION_1_3 -#define GL_VERSION_1_3 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTexture (GLenum); -GLAPI void APIENTRY glClientActiveTexture (GLenum); -GLAPI void APIENTRY glMultiTexCoord1d (GLenum, GLdouble); -GLAPI void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord1f (GLenum, GLfloat); -GLAPI void APIENTRY glMultiTexCoord1fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord1i (GLenum, GLint); -GLAPI void APIENTRY glMultiTexCoord1iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord1s (GLenum, GLshort); -GLAPI void APIENTRY glMultiTexCoord1sv (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord2d (GLenum, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord2dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord2f (GLenum, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord2fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord2i (GLenum, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord2iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord2s (GLenum, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord2sv (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord3d (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord3dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord3f (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord3fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord3i (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord3iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord3s (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord3sv (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord4d (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord4dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord4f (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord4fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord4i (GLenum, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord4iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord4s (GLenum, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord4sv (GLenum, const GLshort *); -GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *); -GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *); -GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *); -GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *); -GLAPI void APIENTRY glSampleCoverage (GLclampf, GLboolean); -GLAPI void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_VERSION_1_4 -#define GL_VERSION_1_4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparate (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glFogCoordf (GLfloat); -GLAPI void APIENTRY glFogCoordfv (const GLfloat *); -GLAPI void APIENTRY glFogCoordd (GLdouble); -GLAPI void APIENTRY glFogCoorddv (const GLdouble *); -GLAPI void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glMultiDrawArrays (GLenum, GLint *, GLsizei *, GLsizei); -GLAPI void APIENTRY glMultiDrawElements (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); -GLAPI void APIENTRY glPointParameterf (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfv (GLenum, const GLfloat *); -GLAPI void APIENTRY glPointParameteri (GLenum, GLint); -GLAPI void APIENTRY glPointParameteriv (GLenum, const GLint *); -GLAPI void APIENTRY glSecondaryColor3b (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *); -GLAPI void APIENTRY glSecondaryColor3d (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *); -GLAPI void APIENTRY glSecondaryColor3f (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *); -GLAPI void APIENTRY glSecondaryColor3i (GLint, GLint, GLint); -GLAPI void APIENTRY glSecondaryColor3iv (const GLint *); -GLAPI void APIENTRY glSecondaryColor3s (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *); -GLAPI void APIENTRY glSecondaryColor3ub (GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *); -GLAPI void APIENTRY glSecondaryColor3ui (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *); -GLAPI void APIENTRY glSecondaryColor3us (GLushort, GLushort, GLushort); -GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *); -GLAPI void APIENTRY glSecondaryColorPointer (GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glWindowPos2d (GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos2dv (const GLdouble *); -GLAPI void APIENTRY glWindowPos2f (GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos2fv (const GLfloat *); -GLAPI void APIENTRY glWindowPos2i (GLint, GLint); -GLAPI void APIENTRY glWindowPos2iv (const GLint *); -GLAPI void APIENTRY glWindowPos2s (GLshort, GLshort); -GLAPI void APIENTRY glWindowPos2sv (const GLshort *); -GLAPI void APIENTRY glWindowPos3d (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos3dv (const GLdouble *); -GLAPI void APIENTRY glWindowPos3f (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos3fv (const GLfloat *); -GLAPI void APIENTRY glWindowPos3i (GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos3iv (const GLint *); -GLAPI void APIENTRY glWindowPos3s (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos3sv (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); -#endif - -#ifndef GL_VERSION_1_5 -#define GL_VERSION_1_5 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueries (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteQueries (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsQuery (GLuint); -GLAPI void APIENTRY glBeginQuery (GLenum, GLuint); -GLAPI void APIENTRY glEndQuery (GLenum); -GLAPI void APIENTRY glGetQueryiv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectuiv (GLuint, GLenum, GLuint *); -GLAPI void APIENTRY glBindBuffer (GLenum, GLuint); -GLAPI void APIENTRY glDeleteBuffers (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenBuffers (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsBuffer (GLuint); -GLAPI void APIENTRY glBufferData (GLenum, GLsizeiptr, const GLvoid *, GLenum); -GLAPI void APIENTRY glBufferSubData (GLenum, GLintptr, GLsizeiptr, const GLvoid *); -GLAPI void APIENTRY glGetBufferSubData (GLenum, GLintptr, GLsizeiptr, GLvoid *); -GLAPI GLvoid* APIENTRY glMapBuffer (GLenum, GLenum); -GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum); -GLAPI void APIENTRY glGetBufferParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetBufferPointerv (GLenum, GLenum, GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_VERSION_2_0 -#define GL_VERSION_2_0 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparate (GLenum, GLenum); -GLAPI void APIENTRY glDrawBuffers (GLsizei, const GLenum *); -GLAPI void APIENTRY glStencilOpSeparate (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glStencilFuncSeparate (GLenum, GLenum, GLint, GLuint); -GLAPI void APIENTRY glStencilMaskSeparate (GLenum, GLuint); -GLAPI void APIENTRY glAttachShader (GLuint, GLuint); -GLAPI void APIENTRY glBindAttribLocation (GLuint, GLuint, const GLchar *); -GLAPI void APIENTRY glCompileShader (GLuint); -GLAPI GLuint APIENTRY glCreateProgram (void); -GLAPI GLuint APIENTRY glCreateShader (GLenum); -GLAPI void APIENTRY glDeleteProgram (GLuint); -GLAPI void APIENTRY glDeleteShader (GLuint); -GLAPI void APIENTRY glDetachShader (GLuint, GLuint); -GLAPI void APIENTRY glDisableVertexAttribArray (GLuint); -GLAPI void APIENTRY glEnableVertexAttribArray (GLuint); -GLAPI void APIENTRY glGetActiveAttrib (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); -GLAPI void APIENTRY glGetActiveUniform (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); -GLAPI void APIENTRY glGetAttachedShaders (GLuint, GLsizei, GLsizei *, GLuint *); -GLAPI GLint APIENTRY glGetAttribLocation (GLuint, const GLchar *); -GLAPI void APIENTRY glGetProgramiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetProgramInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI void APIENTRY glGetShaderiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetShaderInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI void APIENTRY glGetShaderSource (GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI GLint APIENTRY glGetUniformLocation (GLuint, const GLchar *); -GLAPI void APIENTRY glGetUniformfv (GLuint, GLint, GLfloat *); -GLAPI void APIENTRY glGetUniformiv (GLuint, GLint, GLint *); -GLAPI void APIENTRY glGetVertexAttribdv (GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetVertexAttribfv (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint, GLenum, GLvoid* *); -GLAPI GLboolean APIENTRY glIsProgram (GLuint); -GLAPI GLboolean APIENTRY glIsShader (GLuint); -GLAPI void APIENTRY glLinkProgram (GLuint); -GLAPI void APIENTRY glShaderSource (GLuint, GLsizei, const GLchar* *, const GLint *); -GLAPI void APIENTRY glUseProgram (GLuint); -GLAPI void APIENTRY glUniform1f (GLint, GLfloat); -GLAPI void APIENTRY glUniform2f (GLint, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform3f (GLint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform4f (GLint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform1i (GLint, GLint); -GLAPI void APIENTRY glUniform2i (GLint, GLint, GLint); -GLAPI void APIENTRY glUniform3i (GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform4i (GLint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform1fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform2fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform3fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform4fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform1iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform2iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform3iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform4iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniformMatrix2fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix3fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix4fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glValidateProgram (GLuint); -GLAPI void APIENTRY glVertexAttrib1d (GLuint, GLdouble); -GLAPI void APIENTRY glVertexAttrib1dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib1f (GLuint, GLfloat); -GLAPI void APIENTRY glVertexAttrib1fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib1s (GLuint, GLshort); -GLAPI void APIENTRY glVertexAttrib1sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib2d (GLuint, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib2dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib2f (GLuint, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib2fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib2s (GLuint, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib2sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib3d (GLuint, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib3dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib3f (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib3fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib3s (GLuint, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib3sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4Niv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4Nub (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttrib4bv (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4d (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib4dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib4f (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib4fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib4iv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4s (GLuint, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib4sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4ubv (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4uiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4usv (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttribPointer (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); -typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); -typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); -typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); -typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_ARB_multitexture -#define GL_ARB_multitexture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTextureARB (GLenum); -GLAPI void APIENTRY glClientActiveTextureARB (GLenum); -GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble); -GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat); -GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum, GLint); -GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort); -GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); -#endif - -#ifndef GL_ARB_transpose_matrix -#define GL_ARB_transpose_matrix 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *); -GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *); -GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *); -GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -#endif - -#ifndef GL_ARB_multisample -#define GL_ARB_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleCoverageARB (GLclampf, GLboolean); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); -#endif - -#ifndef GL_ARB_texture_env_add -#define GL_ARB_texture_env_add 1 -#endif - -#ifndef GL_ARB_texture_cube_map -#define GL_ARB_texture_cube_map 1 -#endif - -#ifndef GL_ARB_texture_compression -#define GL_ARB_texture_compression 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum, GLint, GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_ARB_texture_border_clamp -#define GL_ARB_texture_border_clamp 1 -#endif - -#ifndef GL_ARB_point_parameters -#define GL_ARB_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfARB (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfvARB (GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_ARB_vertex_blend -#define GL_ARB_vertex_blend 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWeightbvARB (GLint, const GLbyte *); -GLAPI void APIENTRY glWeightsvARB (GLint, const GLshort *); -GLAPI void APIENTRY glWeightivARB (GLint, const GLint *); -GLAPI void APIENTRY glWeightfvARB (GLint, const GLfloat *); -GLAPI void APIENTRY glWeightdvARB (GLint, const GLdouble *); -GLAPI void APIENTRY glWeightubvARB (GLint, const GLubyte *); -GLAPI void APIENTRY glWeightusvARB (GLint, const GLushort *); -GLAPI void APIENTRY glWeightuivARB (GLint, const GLuint *); -GLAPI void APIENTRY glWeightPointerARB (GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glVertexBlendARB (GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); -typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); -typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); -typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); -typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); -typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); -typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); -#endif - -#ifndef GL_ARB_matrix_palette -#define GL_ARB_matrix_palette 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint); -GLAPI void APIENTRY glMatrixIndexubvARB (GLint, const GLubyte *); -GLAPI void APIENTRY glMatrixIndexusvARB (GLint, const GLushort *); -GLAPI void APIENTRY glMatrixIndexuivARB (GLint, const GLuint *); -GLAPI void APIENTRY glMatrixIndexPointerARB (GLint, GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); -typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_ARB_texture_env_combine -#define GL_ARB_texture_env_combine 1 -#endif - -#ifndef GL_ARB_texture_env_crossbar -#define GL_ARB_texture_env_crossbar 1 -#endif - -#ifndef GL_ARB_texture_env_dot3 -#define GL_ARB_texture_env_dot3 1 -#endif - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_ARB_texture_mirrored_repeat 1 -#endif - -#ifndef GL_ARB_depth_texture -#define GL_ARB_depth_texture 1 -#endif - -#ifndef GL_ARB_shadow -#define GL_ARB_shadow 1 -#endif - -#ifndef GL_ARB_shadow_ambient -#define GL_ARB_shadow_ambient 1 -#endif - -#ifndef GL_ARB_window_pos -#define GL_ARB_window_pos 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dARB (GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *); -GLAPI void APIENTRY glWindowPos2fARB (GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *); -GLAPI void APIENTRY glWindowPos2iARB (GLint, GLint); -GLAPI void APIENTRY glWindowPos2ivARB (const GLint *); -GLAPI void APIENTRY glWindowPos2sARB (GLshort, GLshort); -GLAPI void APIENTRY glWindowPos2svARB (const GLshort *); -GLAPI void APIENTRY glWindowPos3dARB (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *); -GLAPI void APIENTRY glWindowPos3fARB (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *); -GLAPI void APIENTRY glWindowPos3iARB (GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos3ivARB (const GLint *); -GLAPI void APIENTRY glWindowPos3sARB (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos3svARB (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); -#endif - -#ifndef GL_ARB_vertex_program -#define GL_ARB_vertex_program 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttrib1dARB (GLuint, GLdouble); -GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib1fARB (GLuint, GLfloat); -GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib1sARB (GLuint, GLshort); -GLAPI void APIENTRY glVertexAttrib1svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib2dARB (GLuint, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib2fARB (GLuint, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib2sARB (GLuint, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib2svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib3dARB (GLuint, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib3fARB (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib3sARB (GLuint, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib3svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4dARB (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib4fARB (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4sARB (GLuint, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib4svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttribPointerARB (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); -GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint); -GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint); -GLAPI void APIENTRY glProgramStringARB (GLenum, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glBindProgramARB (GLenum, GLuint); -GLAPI void APIENTRY glDeleteProgramsARB (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenProgramsARB (GLsizei, GLuint *); -GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum, GLuint, GLdouble *); -GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum, GLuint, GLfloat *); -GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum, GLuint, GLdouble *); -GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum, GLuint, GLfloat *); -GLAPI void APIENTRY glGetProgramivARB (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetProgramStringARB (GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribivARB (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint, GLenum, GLvoid* *); -GLAPI GLboolean APIENTRY glIsProgramARB (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); -typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); -#endif - -#ifndef GL_ARB_fragment_program -#define GL_ARB_fragment_program 1 -/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ -#endif - -#ifndef GL_ARB_vertex_buffer_object -#define GL_ARB_vertex_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindBufferARB (GLenum, GLuint); -GLAPI void APIENTRY glDeleteBuffersARB (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenBuffersARB (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsBufferARB (GLuint); -GLAPI void APIENTRY glBufferDataARB (GLenum, GLsizeiptrARB, const GLvoid *, GLenum); -GLAPI void APIENTRY glBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *); -GLAPI void APIENTRY glGetBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *); -GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum, GLenum); -GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum); -GLAPI void APIENTRY glGetBufferParameterivARB (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetBufferPointervARB (GLenum, GLenum, GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_ARB_occlusion_query -#define GL_ARB_occlusion_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueriesARB (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteQueriesARB (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsQueryARB (GLuint); -GLAPI void APIENTRY glBeginQueryARB (GLenum, GLuint); -GLAPI void APIENTRY glEndQueryARB (GLenum); -GLAPI void APIENTRY glGetQueryivARB (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectivARB (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint, GLenum, GLuint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); -#endif - -#ifndef GL_ARB_shader_objects -#define GL_ARB_shader_objects 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB); -GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum); -GLAPI void APIENTRY glDetachObjectARB (GLhandleARB, GLhandleARB); -GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum); -GLAPI void APIENTRY glShaderSourceARB (GLhandleARB, GLsizei, const GLcharARB* *, const GLint *); -GLAPI void APIENTRY glCompileShaderARB (GLhandleARB); -GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); -GLAPI void APIENTRY glAttachObjectARB (GLhandleARB, GLhandleARB); -GLAPI void APIENTRY glLinkProgramARB (GLhandleARB); -GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB); -GLAPI void APIENTRY glValidateProgramARB (GLhandleARB); -GLAPI void APIENTRY glUniform1fARB (GLint, GLfloat); -GLAPI void APIENTRY glUniform2fARB (GLint, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform3fARB (GLint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform4fARB (GLint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform1iARB (GLint, GLint); -GLAPI void APIENTRY glUniform2iARB (GLint, GLint, GLint); -GLAPI void APIENTRY glUniform3iARB (GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform4iARB (GLint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform1fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform2fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform3fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform4fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform1ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform2ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform3ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform4ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniformMatrix2fvARB (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix3fvARB (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix4fvARB (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB, GLenum, GLfloat *); -GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB, GLenum, GLint *); -GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); -GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); -GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB, const GLcharARB *); -GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); -GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB, GLint, GLfloat *); -GLAPI void APIENTRY glGetUniformivARB (GLhandleARB, GLint, GLint *); -GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); -typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); -typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); -typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); -typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); -typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); -#endif - -#ifndef GL_ARB_vertex_shader -#define GL_ARB_vertex_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB, GLuint, const GLcharARB *); -GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); -GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB, const GLcharARB *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_ARB_fragment_shader 1 -#endif - -#ifndef GL_ARB_shading_language_100 -#define GL_ARB_shading_language_100 1 -#endif - -#ifndef GL_ARB_texture_non_power_of_two -#define GL_ARB_texture_non_power_of_two 1 -#endif - -#ifndef GL_ARB_point_sprite -#define GL_ARB_point_sprite 1 -#endif - -#ifndef GL_ARB_fragment_program_shadow -#define GL_ARB_fragment_program_shadow 1 -#endif - -#ifndef GL_ARB_draw_buffers -#define GL_ARB_draw_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersARB (GLsizei, const GLenum *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); -#endif - -#ifndef GL_ARB_texture_rectangle -#define GL_ARB_texture_rectangle 1 -#endif - -#ifndef GL_ARB_color_buffer_float -#define GL_ARB_color_buffer_float 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClampColorARB (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); -#endif - -#ifndef GL_ARB_half_float_pixel -#define GL_ARB_half_float_pixel 1 -#endif - -#ifndef GL_ARB_texture_float -#define GL_ARB_texture_float 1 -#endif - -#ifndef GL_ARB_pixel_buffer_object -#define GL_ARB_pixel_buffer_object 1 -#endif - -#ifndef GL_EXT_abgr -#define GL_EXT_abgr 1 -#endif - -#ifndef GL_EXT_blend_color -#define GL_EXT_blend_color 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -#endif - -#ifndef GL_EXT_polygon_offset -#define GL_EXT_polygon_offset 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat, GLfloat); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); -#endif - -#ifndef GL_EXT_texture -#define GL_EXT_texture 1 -#endif - -#ifndef GL_EXT_texture3D -#define GL_EXT_texture3D 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage3DEXT (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_SGIS_texture_filter4 -#define GL_SGIS_texture_filter4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum, GLenum, GLsizei, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); -typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); -#endif - -#ifndef GL_EXT_subtexture -#define GL_EXT_subtexture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexSubImage1DEXT (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_EXT_copy_texture -#define GL_EXT_copy_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); -GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); -GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_EXT_histogram -#define GL_EXT_histogram 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetHistogramEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMinmaxEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glHistogramEXT (GLenum, GLsizei, GLenum, GLboolean); -GLAPI void APIENTRY glMinmaxEXT (GLenum, GLenum, GLboolean); -GLAPI void APIENTRY glResetHistogramEXT (GLenum); -GLAPI void APIENTRY glResetMinmaxEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); -#endif - -#ifndef GL_EXT_convolution -#define GL_EXT_convolution 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum, GLenum, GLint); -GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); -GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -#endif - -#ifndef GL_EXT_color_matrix -#define GL_EXT_color_matrix 1 -#endif - -#ifndef GL_SGI_color_table -#define GL_SGI_color_table 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableSGI (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glColorTableParameterivSGI (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyColorTableSGI (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glGetColorTableSGI (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); -#endif - -#ifndef GL_SGIX_pixel_texture -#define GL_SGIX_pixel_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenSGIX (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); -#endif - -#ifndef GL_SGIS_pixel_texture -#define GL_SGIS_pixel_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum, GLint); -GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum, const GLint *); -GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum, GLfloat); -GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum, const GLfloat *); -GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum, GLint *); -GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); -#endif - -#ifndef GL_SGIS_texture4D -#define GL_SGIS_texture4D 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage4DSGIS (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_SGI_texture_color_table -#define GL_SGI_texture_color_table 1 -#endif - -#ifndef GL_EXT_cmyka -#define GL_EXT_cmyka 1 -#endif - -#ifndef GL_EXT_texture_object -#define GL_EXT_texture_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei, const GLuint *, GLboolean *); -GLAPI void APIENTRY glBindTextureEXT (GLenum, GLuint); -GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenTexturesEXT (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint); -GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei, const GLuint *, const GLclampf *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); -typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); -typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); -#endif - -#ifndef GL_SGIS_detail_texture -#define GL_SGIS_detail_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum, GLsizei, const GLfloat *); -GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#endif - -#ifndef GL_SGIS_sharpen_texture -#define GL_SGIS_sharpen_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum, GLsizei, const GLfloat *); -GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#endif - -#ifndef GL_EXT_packed_pixels -#define GL_EXT_packed_pixels 1 -#endif - -#ifndef GL_SGIS_texture_lod -#define GL_SGIS_texture_lod 1 -#endif - -#ifndef GL_SGIS_multisample -#define GL_SGIS_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskSGIS (GLclampf, GLboolean); -GLAPI void APIENTRY glSamplePatternSGIS (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); -#endif - -#ifndef GL_EXT_rescale_normal -#define GL_EXT_rescale_normal 1 -#endif - -#ifndef GL_EXT_vertex_array -#define GL_EXT_vertex_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glArrayElementEXT (GLint); -GLAPI void APIENTRY glColorPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glDrawArraysEXT (GLenum, GLint, GLsizei); -GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei, GLsizei, const GLboolean *); -GLAPI void APIENTRY glGetPointervEXT (GLenum, GLvoid* *); -GLAPI void APIENTRY glIndexPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glNormalPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glTexCoordPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glVertexPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); -typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); -typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); -typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_misc_attribute -#define GL_EXT_misc_attribute 1 -#endif - -#ifndef GL_SGIS_generate_mipmap -#define GL_SGIS_generate_mipmap 1 -#endif - -#ifndef GL_SGIX_clipmap -#define GL_SGIX_clipmap 1 -#endif - -#ifndef GL_SGIX_shadow -#define GL_SGIX_shadow 1 -#endif - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_SGIS_texture_edge_clamp 1 -#endif - -#ifndef GL_SGIS_texture_border_clamp -#define GL_SGIS_texture_border_clamp 1 -#endif - -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); -#endif - -#ifndef GL_EXT_blend_subtract -#define GL_EXT_blend_subtract 1 -#endif - -#ifndef GL_EXT_blend_logic_op -#define GL_EXT_blend_logic_op 1 -#endif - -#ifndef GL_SGIX_interlace -#define GL_SGIX_interlace 1 -#endif - -#ifndef GL_SGIX_pixel_tiles -#define GL_SGIX_pixel_tiles 1 -#endif - -#ifndef GL_SGIX_texture_select -#define GL_SGIX_texture_select 1 -#endif - -#ifndef GL_SGIX_sprite -#define GL_SGIX_sprite 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum, GLfloat); -GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum, const GLfloat *); -GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum, GLint); -GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_SGIX_texture_multi_buffer 1 -#endif - -#ifndef GL_EXT_point_parameters -#define GL_EXT_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfEXT (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfvEXT (GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_SGIS_point_parameters -#define GL_SGIS_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfSGIS (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfvSGIS (GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_SGIX_instruments -#define GL_SGIX_instruments 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); -GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei, GLint *); -GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *); -GLAPI void APIENTRY glReadInstrumentsSGIX (GLint); -GLAPI void APIENTRY glStartInstrumentsSGIX (void); -GLAPI void APIENTRY glStopInstrumentsSGIX (GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); -typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); -typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); -typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); -#endif - -#ifndef GL_SGIX_texture_scale_bias -#define GL_SGIX_texture_scale_bias 1 -#endif - -#ifndef GL_SGIX_framezoom -#define GL_SGIX_framezoom 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFrameZoomSGIX (GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); -#endif - -#ifndef GL_SGIX_tag_sample_buffer -#define GL_SGIX_tag_sample_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTagSampleBufferSGIX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); -#endif - -#ifndef GL_SGIX_polynomial_ffd -#define GL_SGIX_polynomial_ffd 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); -GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); -GLAPI void APIENTRY glDeformSGIX (GLbitfield); -GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); -typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); -#endif - -#ifndef GL_SGIX_reference_plane -#define GL_SGIX_reference_plane 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); -#endif - -#ifndef GL_SGIX_flush_raster -#define GL_SGIX_flush_raster 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushRasterSGIX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); -#endif - -#ifndef GL_SGIX_depth_texture -#define GL_SGIX_depth_texture 1 -#endif - -#ifndef GL_SGIS_fog_function -#define GL_SGIS_fog_function 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogFuncSGIS (GLsizei, const GLfloat *); -GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); -#endif - -#ifndef GL_SGIX_fog_offset -#define GL_SGIX_fog_offset 1 -#endif - -#ifndef GL_HP_image_transform -#define GL_HP_image_transform 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glImageTransformParameteriHP (GLenum, GLenum, GLint); -GLAPI void APIENTRY glImageTransformParameterfHP (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glImageTransformParameterivHP (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_HP_convolution_border_modes -#define GL_HP_convolution_border_modes 1 -#endif - -#ifndef GL_SGIX_texture_add_env -#define GL_SGIX_texture_add_env 1 -#endif - -#ifndef GL_EXT_color_subtable -#define GL_EXT_color_subtable 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum, GLsizei, GLint, GLint, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -#endif - -#ifndef GL_PGI_vertex_hints -#define GL_PGI_vertex_hints 1 -#endif - -#ifndef GL_PGI_misc_hints -#define GL_PGI_misc_hints 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glHintPGI (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); -#endif - -#ifndef GL_EXT_paletted_texture -#define GL_EXT_paletted_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_EXT_clip_volume_hint -#define GL_EXT_clip_volume_hint 1 -#endif - -#ifndef GL_SGIX_list_priority -#define GL_SGIX_list_priority 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetListParameterivSGIX (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glListParameterfSGIX (GLuint, GLenum, GLfloat); -GLAPI void APIENTRY glListParameterfvSGIX (GLuint, GLenum, const GLfloat *); -GLAPI void APIENTRY glListParameteriSGIX (GLuint, GLenum, GLint); -GLAPI void APIENTRY glListParameterivSGIX (GLuint, GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); -#endif - -#ifndef GL_SGIX_ir_instrument1 -#define GL_SGIX_ir_instrument1 1 -#endif - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_SGIX_calligraphic_fragment 1 -#endif - -#ifndef GL_SGIX_texture_lod_bias -#define GL_SGIX_texture_lod_bias 1 -#endif - -#ifndef GL_SGIX_shadow_ambient -#define GL_SGIX_shadow_ambient 1 -#endif - -#ifndef GL_EXT_index_texture -#define GL_EXT_index_texture 1 -#endif - -#ifndef GL_EXT_index_material -#define GL_EXT_index_material 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexMaterialEXT (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); -#endif - -#ifndef GL_EXT_index_func -#define GL_EXT_index_func 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexFuncEXT (GLenum, GLclampf); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); -#endif - -#ifndef GL_EXT_index_array_formats -#define GL_EXT_index_array_formats 1 -#endif - -#ifndef GL_EXT_compiled_vertex_array -#define GL_EXT_compiled_vertex_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLockArraysEXT (GLint, GLsizei); -GLAPI void APIENTRY glUnlockArraysEXT (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); -#endif - -#ifndef GL_EXT_cull_vertex -#define GL_EXT_cull_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCullParameterdvEXT (GLenum, GLdouble *); -GLAPI void APIENTRY glCullParameterfvEXT (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); -#endif - -#ifndef GL_SGIX_ycrcb -#define GL_SGIX_ycrcb 1 -#endif - -#ifndef GL_SGIX_fragment_lighting -#define GL_SGIX_fragment_lighting 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum, GLenum); -GLAPI void APIENTRY glFragmentLightfSGIX (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glFragmentLightiSGIX (GLenum, GLenum, GLint); -GLAPI void APIENTRY glFragmentLightivSGIX (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum, GLfloat); -GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum, const GLfloat *); -GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum, GLint); -GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum, const GLint *); -GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum, GLenum, GLint); -GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glLightEnviSGIX (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); -#endif - -#ifndef GL_IBM_rasterpos_clip -#define GL_IBM_rasterpos_clip 1 -#endif - -#ifndef GL_HP_texture_lighting -#define GL_HP_texture_lighting 1 -#endif - -#ifndef GL_EXT_draw_range_elements -#define GL_EXT_draw_range_elements 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -#endif - -#ifndef GL_WIN_phong_shading -#define GL_WIN_phong_shading 1 -#endif - -#ifndef GL_WIN_specular_fog -#define GL_WIN_specular_fog 1 -#endif - -#ifndef GL_EXT_light_texture -#define GL_EXT_light_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glApplyTextureEXT (GLenum); -GLAPI void APIENTRY glTextureLightEXT (GLenum); -GLAPI void APIENTRY glTextureMaterialEXT (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); -#endif - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_SGIX_blend_alpha_minmax 1 -#endif - -#ifndef GL_EXT_bgra -#define GL_EXT_bgra 1 -#endif - -#ifndef GL_SGIX_async -#define GL_SGIX_async 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint); -GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *); -GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *); -GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei); -GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint, GLsizei); -GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); -typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); -typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); -typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); -typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); -typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); -#endif - -#ifndef GL_SGIX_async_pixel -#define GL_SGIX_async_pixel 1 -#endif - -#ifndef GL_SGIX_async_histogram -#define GL_SGIX_async_histogram 1 -#endif - -#ifndef GL_INTEL_parallel_arrays -#define GL_INTEL_parallel_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexPointervINTEL (GLint, GLenum, const GLvoid* *); -GLAPI void APIENTRY glNormalPointervINTEL (GLenum, const GLvoid* *); -GLAPI void APIENTRY glColorPointervINTEL (GLint, GLenum, const GLvoid* *); -GLAPI void APIENTRY glTexCoordPointervINTEL (GLint, GLenum, const GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -#endif - -#ifndef GL_HP_occlusion_test -#define GL_HP_occlusion_test 1 -#endif - -#ifndef GL_EXT_pixel_transform -#define GL_EXT_pixel_transform 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum, GLenum, GLint); -GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum, GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_EXT_pixel_transform_color_table -#define GL_EXT_pixel_transform_color_table 1 -#endif - -#ifndef GL_EXT_shared_texture_palette -#define GL_EXT_shared_texture_palette 1 -#endif - -#ifndef GL_EXT_separate_specular_color -#define GL_EXT_separate_specular_color 1 -#endif - -#ifndef GL_EXT_secondary_color -#define GL_EXT_secondary_color 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *); -GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *); -GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *); -GLAPI void APIENTRY glSecondaryColor3iEXT (GLint, GLint, GLint); -GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *); -GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *); -GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *); -GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *); -GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort, GLushort, GLushort); -GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *); -GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint, GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_texture_perturb_normal -#define GL_EXT_texture_perturb_normal 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureNormalEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); -#endif - -#ifndef GL_EXT_multi_draw_arrays -#define GL_EXT_multi_draw_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); -GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -#endif - -#ifndef GL_EXT_fog_coord -#define GL_EXT_fog_coord 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogCoordfEXT (GLfloat); -GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *); -GLAPI void APIENTRY glFogCoorddEXT (GLdouble); -GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *); -GLAPI void APIENTRY glFogCoordPointerEXT (GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_REND_screen_coordinates -#define GL_REND_screen_coordinates 1 -#endif - -#ifndef GL_EXT_coordinate_frame -#define GL_EXT_coordinate_frame 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTangent3bEXT (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *); -GLAPI void APIENTRY glTangent3dEXT (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *); -GLAPI void APIENTRY glTangent3fEXT (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *); -GLAPI void APIENTRY glTangent3iEXT (GLint, GLint, GLint); -GLAPI void APIENTRY glTangent3ivEXT (const GLint *); -GLAPI void APIENTRY glTangent3sEXT (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glTangent3svEXT (const GLshort *); -GLAPI void APIENTRY glBinormal3bEXT (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *); -GLAPI void APIENTRY glBinormal3dEXT (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *); -GLAPI void APIENTRY glBinormal3fEXT (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *); -GLAPI void APIENTRY glBinormal3iEXT (GLint, GLint, GLint); -GLAPI void APIENTRY glBinormal3ivEXT (const GLint *); -GLAPI void APIENTRY glBinormal3sEXT (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glBinormal3svEXT (const GLshort *); -GLAPI void APIENTRY glTangentPointerEXT (GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glBinormalPointerEXT (GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); -typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); -typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); -typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); -typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); -typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); -typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); -typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); -typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); -typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); -typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_texture_env_combine -#define GL_EXT_texture_env_combine 1 -#endif - -#ifndef GL_APPLE_specular_vector -#define GL_APPLE_specular_vector 1 -#endif - -#ifndef GL_APPLE_transform_hint -#define GL_APPLE_transform_hint 1 -#endif - -#ifndef GL_SGIX_fog_scale -#define GL_SGIX_fog_scale 1 -#endif - -#ifndef GL_SUNX_constant_data -#define GL_SUNX_constant_data 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFinishTextureSUNX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); -#endif - -#ifndef GL_SUN_global_alpha -#define GL_SUN_global_alpha 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte); -GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort); -GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint); -GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat); -GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble); -GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte); -GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort); -GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); -#endif - -#ifndef GL_SUN_triangle_list -#define GL_SUN_triangle_list 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint); -GLAPI void APIENTRY glReplacementCodeusSUN (GLushort); -GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte); -GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *); -GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *); -GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *); -GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum, GLsizei, const GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); -#endif - -#ifndef GL_SUN_vertex -#define GL_SUN_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat); -GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat, GLfloat, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *, const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *, const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -#endif - -#ifndef GL_EXT_blend_func_separate -#define GL_EXT_blend_func_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum, GLenum, GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif - -#ifndef GL_INGR_blend_func_separate -#define GL_INGR_blend_func_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum, GLenum, GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif - -#ifndef GL_INGR_color_clamp -#define GL_INGR_color_clamp 1 -#endif - -#ifndef GL_INGR_interlace_read -#define GL_INGR_interlace_read 1 -#endif - -#ifndef GL_EXT_stencil_wrap -#define GL_EXT_stencil_wrap 1 -#endif - -#ifndef GL_EXT_422_pixels -#define GL_EXT_422_pixels 1 -#endif - -#ifndef GL_NV_texgen_reflection -#define GL_NV_texgen_reflection 1 -#endif - -#ifndef GL_SUN_convolution_border_modes -#define GL_SUN_convolution_border_modes 1 -#endif - -#ifndef GL_EXT_texture_env_add -#define GL_EXT_texture_env_add 1 -#endif - -#ifndef GL_EXT_texture_lod_bias -#define GL_EXT_texture_lod_bias 1 -#endif - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 -#endif - -#ifndef GL_EXT_vertex_weighting -#define GL_EXT_vertex_weighting 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexWeightfEXT (GLfloat); -GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *); -GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei, GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_NV_light_max_exponent -#define GL_NV_light_max_exponent 1 -#endif - -#ifndef GL_NV_vertex_array_range -#define GL_NV_vertex_array_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); -GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); -#endif - -#ifndef GL_NV_register_combiners -#define GL_NV_register_combiners 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *); -GLAPI void APIENTRY glCombinerParameterfNV (GLenum, GLfloat); -GLAPI void APIENTRY glCombinerParameterivNV (GLenum, const GLint *); -GLAPI void APIENTRY glCombinerParameteriNV (GLenum, GLint); -GLAPI void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean); -GLAPI void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); -#endif - -#ifndef GL_NV_fog_distance -#define GL_NV_fog_distance 1 -#endif - -#ifndef GL_NV_texgen_emboss -#define GL_NV_texgen_emboss 1 -#endif - -#ifndef GL_NV_blend_square -#define GL_NV_blend_square 1 -#endif - -#ifndef GL_NV_texture_env_combine4 -#define GL_NV_texture_env_combine4 1 -#endif - -#ifndef GL_MESA_resize_buffers -#define GL_MESA_resize_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glResizeBuffersMESA (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); -#endif - -#ifndef GL_MESA_window_pos -#define GL_MESA_window_pos 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dMESA (GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *); -GLAPI void APIENTRY glWindowPos2fMESA (GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *); -GLAPI void APIENTRY glWindowPos2iMESA (GLint, GLint); -GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *); -GLAPI void APIENTRY glWindowPos2sMESA (GLshort, GLshort); -GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *); -GLAPI void APIENTRY glWindowPos3dMESA (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *); -GLAPI void APIENTRY glWindowPos3fMESA (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *); -GLAPI void APIENTRY glWindowPos3iMESA (GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *); -GLAPI void APIENTRY glWindowPos3sMESA (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *); -GLAPI void APIENTRY glWindowPos4dMESA (GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *); -GLAPI void APIENTRY glWindowPos4fMESA (GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *); -GLAPI void APIENTRY glWindowPos4iMESA (GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *); -GLAPI void APIENTRY glWindowPos4sMESA (GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); -#endif - -#ifndef GL_IBM_cull_vertex -#define GL_IBM_cull_vertex 1 -#endif - -#ifndef GL_IBM_multimode_draw_arrays -#define GL_IBM_multimode_draw_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint); -GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *, const GLsizei *, GLenum, const GLvoid* const *, GLsizei, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); -#endif - -#ifndef GL_IBM_vertex_array_lists -#define GL_IBM_vertex_array_lists 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint, const GLboolean* *, GLint); -GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glIndexPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glNormalPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glTexCoordPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glVertexPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -#endif - -#ifndef GL_SGIX_subsample -#define GL_SGIX_subsample 1 -#endif - -#ifndef GL_SGIX_ycrcba -#define GL_SGIX_ycrcba 1 -#endif - -#ifndef GL_SGIX_ycrcb_subsample -#define GL_SGIX_ycrcb_subsample 1 -#endif - -#ifndef GL_SGIX_depth_pass_instrument -#define GL_SGIX_depth_pass_instrument 1 -#endif - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_3DFX_texture_compression_FXT1 1 -#endif - -#ifndef GL_3DFX_multisample -#define GL_3DFX_multisample 1 -#endif - -#ifndef GL_3DFX_tbuffer -#define GL_3DFX_tbuffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTbufferMask3DFX (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); -#endif - -#ifndef GL_EXT_multisample -#define GL_EXT_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskEXT (GLclampf, GLboolean); -GLAPI void APIENTRY glSamplePatternEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); -#endif - -#ifndef GL_SGIX_vertex_preclip -#define GL_SGIX_vertex_preclip 1 -#endif - -#ifndef GL_SGIX_convolution_accuracy -#define GL_SGIX_convolution_accuracy 1 -#endif - -#ifndef GL_SGIX_resample -#define GL_SGIX_resample 1 -#endif - -#ifndef GL_SGIS_point_line_texgen -#define GL_SGIS_point_line_texgen 1 -#endif - -#ifndef GL_SGIS_texture_color_mask -#define GL_SGIS_texture_color_mask 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean, GLboolean, GLboolean, GLboolean); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -#endif - -#ifndef GL_SGIX_igloo_interface -#define GL_SGIX_igloo_interface 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); -#endif - -#ifndef GL_EXT_texture_env_dot3 -#define GL_EXT_texture_env_dot3 1 -#endif - -#ifndef GL_ATI_texture_mirror_once -#define GL_ATI_texture_mirror_once 1 -#endif - -#ifndef GL_NV_fence -#define GL_NV_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenFencesNV (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsFenceNV (GLuint); -GLAPI GLboolean APIENTRY glTestFenceNV (GLuint); -GLAPI void APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glFinishFenceNV (GLuint); -GLAPI void APIENTRY glSetFenceNV (GLuint, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); -typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); -#endif - -#ifndef GL_NV_evaluators -#define GL_NV_evaluators 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLint, GLint, GLboolean, const GLvoid *); -GLAPI void APIENTRY glMapParameterivNV (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glMapParameterfvNV (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glGetMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLboolean, GLvoid *); -GLAPI void APIENTRY glGetMapParameterivNV (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMapParameterfvNV (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum, GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glEvalMapsNV (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); -typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); -#endif - -#ifndef GL_NV_packed_depth_stencil -#define GL_NV_packed_depth_stencil 1 -#endif - -#ifndef GL_NV_register_combiners2 -#define GL_NV_register_combiners2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_NV_texture_compression_vtc -#define GL_NV_texture_compression_vtc 1 -#endif - -#ifndef GL_NV_texture_rectangle -#define GL_NV_texture_rectangle 1 -#endif - -#ifndef GL_NV_texture_shader -#define GL_NV_texture_shader 1 -#endif - -#ifndef GL_NV_texture_shader2 -#define GL_NV_texture_shader2 1 -#endif - -#ifndef GL_NV_vertex_array_range2 -#define GL_NV_vertex_array_range2 1 -#endif - -#ifndef GL_NV_vertex_program -#define GL_NV_vertex_program 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei, const GLuint *, GLboolean *); -GLAPI void APIENTRY glBindProgramNV (GLenum, GLuint); -GLAPI void APIENTRY glDeleteProgramsNV (GLsizei, const GLuint *); -GLAPI void APIENTRY glExecuteProgramNV (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glGenProgramsNV (GLsizei, GLuint *); -GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum, GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetProgramivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetProgramStringNV (GLuint, GLenum, GLubyte *); -GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum, GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint, GLenum, GLvoid* *); -GLAPI GLboolean APIENTRY glIsProgramNV (GLuint); -GLAPI void APIENTRY glLoadProgramNV (GLenum, GLuint, GLsizei, const GLubyte *); -GLAPI void APIENTRY glProgramParameter4dNV (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramParameter4dvNV (GLenum, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramParameter4fNV (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramParameter4fvNV (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glProgramParameters4dvNV (GLenum, GLuint, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramParameters4fvNV (GLenum, GLuint, GLuint, const GLfloat *); -GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei, const GLuint *); -GLAPI void APIENTRY glTrackMatrixNV (GLenum, GLuint, GLenum, GLenum); -GLAPI void APIENTRY glVertexAttribPointerNV (GLuint, GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glVertexAttrib1dNV (GLuint, GLdouble); -GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib1fNV (GLuint, GLfloat); -GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib1sNV (GLuint, GLshort); -GLAPI void APIENTRY glVertexAttrib1svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib2dNV (GLuint, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib2fNV (GLuint, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib2sNV (GLuint, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib2svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib3dNV (GLuint, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib3fNV (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib3sNV (GLuint, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib3svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4dNV (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib4fNV (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib4sNV (GLuint, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib4svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs1svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs2svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs3svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs4svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint, GLsizei, const GLubyte *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); -typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); -typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint count, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint count, const GLfloat *v); -typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); -#endif - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_SGIX_texture_coordinate_clamp 1 -#endif - -#ifndef GL_SGIX_scalebias_hint -#define GL_SGIX_scalebias_hint 1 -#endif - -#ifndef GL_OML_interlace -#define GL_OML_interlace 1 -#endif - -#ifndef GL_OML_subsample -#define GL_OML_subsample 1 -#endif - -#ifndef GL_OML_resample -#define GL_OML_resample 1 -#endif - -#ifndef GL_NV_copy_depth_to_color -#define GL_NV_copy_depth_to_color 1 -#endif - -#ifndef GL_ATI_envmap_bumpmap -#define GL_ATI_envmap_bumpmap 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBumpParameterivATI (GLenum, const GLint *); -GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum, GLint *); -GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); -#endif - -#ifndef GL_ATI_fragment_shader -#define GL_ATI_fragment_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint); -GLAPI void APIENTRY glBindFragmentShaderATI (GLuint); -GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint); -GLAPI void APIENTRY glBeginFragmentShaderATI (void); -GLAPI void APIENTRY glEndFragmentShaderATI (void); -GLAPI void APIENTRY glPassTexCoordATI (GLuint, GLuint, GLenum); -GLAPI void APIENTRY glSampleMapATI (GLuint, GLuint, GLenum); -GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); -typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); -typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); -#endif - -#ifndef GL_ATI_pn_triangles -#define GL_ATI_pn_triangles 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPNTrianglesiATI (GLenum, GLint); -GLAPI void APIENTRY glPNTrianglesfATI (GLenum, GLfloat); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); -#endif - -#ifndef GL_ATI_vertex_array_object -#define GL_ATI_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei, const GLvoid *, GLenum); -GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint); -GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint, GLuint, GLsizei, const GLvoid *, GLenum); -GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetObjectBufferivATI (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glFreeObjectBufferATI (GLuint); -GLAPI void APIENTRY glArrayObjectATI (GLenum, GLint, GLenum, GLsizei, GLuint, GLuint); -GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetArrayObjectivATI (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glVariantArrayObjectATI (GLuint, GLenum, GLsizei, GLuint, GLuint); -GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); -typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); -#endif - -#ifndef GL_EXT_vertex_shader -#define GL_EXT_vertex_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginVertexShaderEXT (void); -GLAPI void APIENTRY glEndVertexShaderEXT (void); -GLAPI void APIENTRY glBindVertexShaderEXT (GLuint); -GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint); -GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint); -GLAPI void APIENTRY glShaderOp1EXT (GLenum, GLuint, GLuint); -GLAPI void APIENTRY glShaderOp2EXT (GLenum, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glShaderOp3EXT (GLenum, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSwizzleEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glWriteMaskEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glInsertComponentEXT (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glExtractComponentEXT (GLuint, GLuint, GLuint); -GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum, GLenum, GLenum, GLuint); -GLAPI void APIENTRY glSetInvariantEXT (GLuint, GLenum, const GLvoid *); -GLAPI void APIENTRY glSetLocalConstantEXT (GLuint, GLenum, const GLvoid *); -GLAPI void APIENTRY glVariantbvEXT (GLuint, const GLbyte *); -GLAPI void APIENTRY glVariantsvEXT (GLuint, const GLshort *); -GLAPI void APIENTRY glVariantivEXT (GLuint, const GLint *); -GLAPI void APIENTRY glVariantfvEXT (GLuint, const GLfloat *); -GLAPI void APIENTRY glVariantdvEXT (GLuint, const GLdouble *); -GLAPI void APIENTRY glVariantubvEXT (GLuint, const GLubyte *); -GLAPI void APIENTRY glVariantusvEXT (GLuint, const GLushort *); -GLAPI void APIENTRY glVariantuivEXT (GLuint, const GLuint *); -GLAPI void APIENTRY glVariantPointerEXT (GLuint, GLenum, GLuint, const GLvoid *); -GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint); -GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint); -GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum, GLenum); -GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum, GLenum); -GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum, GLenum, GLenum); -GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum, GLenum); -GLAPI GLuint APIENTRY glBindParameterEXT (GLenum); -GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint, GLenum); -GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint, GLenum, GLboolean *); -GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVariantPointervEXT (GLuint, GLenum, GLvoid* *); -GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint, GLenum, GLboolean *); -GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint, GLenum, GLboolean *); -GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); -typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); -typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); -typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); -typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); -typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); -typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); -typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); -typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); -typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); -typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); -typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); -typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); -typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); -typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); -typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); -typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); -typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -#endif - -#ifndef GL_ATI_vertex_streams -#define GL_ATI_vertex_streams 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexStream1sATI (GLenum, GLshort); -GLAPI void APIENTRY glVertexStream1svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream1iATI (GLenum, GLint); -GLAPI void APIENTRY glVertexStream1ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream1fATI (GLenum, GLfloat); -GLAPI void APIENTRY glVertexStream1fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream1dATI (GLenum, GLdouble); -GLAPI void APIENTRY glVertexStream1dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glVertexStream2sATI (GLenum, GLshort, GLshort); -GLAPI void APIENTRY glVertexStream2svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream2iATI (GLenum, GLint, GLint); -GLAPI void APIENTRY glVertexStream2ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream2fATI (GLenum, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexStream2fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream2dATI (GLenum, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexStream2dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glVertexStream3sATI (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexStream3svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream3iATI (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glVertexStream3ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexStream3fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexStream3dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glVertexStream4sATI (GLenum, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexStream4svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream4iATI (GLenum, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glVertexStream4ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream4fATI (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexStream4fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream4dATI (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexStream4dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glNormalStream3bATI (GLenum, GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glNormalStream3bvATI (GLenum, const GLbyte *); -GLAPI void APIENTRY glNormalStream3sATI (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glNormalStream3svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glNormalStream3iATI (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glNormalStream3ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glNormalStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glNormalStream3fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glNormalStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glNormalStream3dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum); -GLAPI void APIENTRY glVertexBlendEnviATI (GLenum, GLint); -GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum, GLfloat); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); -#endif - -#ifndef GL_ATI_element_array -#define GL_ATI_element_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerATI (GLenum, const GLvoid *); -GLAPI void APIENTRY glDrawElementArrayATI (GLenum, GLsizei); -GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum, GLuint, GLuint, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); -#endif - -#ifndef GL_SUN_mesh_array -#define GL_SUN_mesh_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); -#endif - -#ifndef GL_SUN_slice_accum -#define GL_SUN_slice_accum 1 -#endif - -#ifndef GL_NV_multisample_filter_hint -#define GL_NV_multisample_filter_hint 1 -#endif - -#ifndef GL_NV_depth_clamp -#define GL_NV_depth_clamp 1 -#endif - -#ifndef GL_NV_occlusion_query -#define GL_NV_occlusion_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint); -GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint); -GLAPI void APIENTRY glEndOcclusionQueryNV (void); -GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint, GLenum, GLuint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); -#endif - -#ifndef GL_NV_point_sprite -#define GL_NV_point_sprite 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameteriNV (GLenum, GLint); -GLAPI void APIENTRY glPointParameterivNV (GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_NV_texture_shader3 -#define GL_NV_texture_shader3 1 -#endif - -#ifndef GL_NV_vertex_program1_1 -#define GL_NV_vertex_program1_1 1 -#endif - -#ifndef GL_EXT_shadow_funcs -#define GL_EXT_shadow_funcs 1 -#endif - -#ifndef GL_EXT_stencil_two_side -#define GL_EXT_stencil_two_side 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); -#endif - -#ifndef GL_ATI_text_fragment_shader -#define GL_ATI_text_fragment_shader 1 -#endif - -#ifndef GL_APPLE_client_storage -#define GL_APPLE_client_storage 1 -#endif - -#ifndef GL_APPLE_element_array -#define GL_APPLE_element_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerAPPLE (GLenum, const GLvoid *); -GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum, GLint, GLsizei); -GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, GLint, GLsizei); -GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum, const GLint *, const GLsizei *, GLsizei); -GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, const GLint *, const GLsizei *, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); -#endif - -#ifndef GL_APPLE_fence -#define GL_APPLE_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenFencesAPPLE (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei, const GLuint *); -GLAPI void APIENTRY glSetFenceAPPLE (GLuint); -GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint); -GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint); -GLAPI void APIENTRY glFinishFenceAPPLE (GLuint); -GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum, GLuint); -GLAPI void APIENTRY glFinishObjectAPPLE (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); -typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); -typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); -#endif - -#ifndef GL_APPLE_vertex_array_object -#define GL_APPLE_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint); -GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); -#endif - -#ifndef GL_APPLE_vertex_array_range -#define GL_APPLE_vertex_array_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei, GLvoid *); -GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei, GLvoid *); -GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); -#endif - -#ifndef GL_APPLE_ycbcr_422 -#define GL_APPLE_ycbcr_422 1 -#endif - -#ifndef GL_S3_s3tc -#define GL_S3_s3tc 1 -#endif - -#ifndef GL_ATI_draw_buffers -#define GL_ATI_draw_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersATI (GLsizei, const GLenum *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); -#endif - -#ifndef GL_ATI_pixel_format_float -#define GL_ATI_pixel_format_float 1 -/* This is really a WGL extension, but defines some associated GL enums. - * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. - */ -#endif - -#ifndef GL_ATI_texture_env_combine3 -#define GL_ATI_texture_env_combine3 1 -#endif - -#ifndef GL_ATI_texture_float -#define GL_ATI_texture_float 1 -#endif - -#ifndef GL_NV_float_buffer -#define GL_NV_float_buffer 1 -#endif - -#ifndef GL_NV_fragment_program -#define GL_NV_fragment_program 1 -/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint, GLsizei, const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint, GLsizei, const GLubyte *, const GLdouble *); -GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint, GLsizei, const GLubyte *, GLfloat *); -GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint, GLsizei, const GLubyte *, GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); -#endif - -#ifndef GL_NV_half_float -#define GL_NV_half_float 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertex2hNV (GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertex3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertex4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *); -GLAPI void APIENTRY glNormal3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glColor4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV); -GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glFogCoordhNV (GLhalfNV); -GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *); -GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV); -GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib1hNV (GLuint, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib2hNV (GLuint, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib3hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib4hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint, GLsizei, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint, GLsizei, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint, GLsizei, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint, GLsizei, const GLhalfNV *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); -typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); -typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); -typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); -typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -#endif - -#ifndef GL_NV_pixel_data_range -#define GL_NV_pixel_data_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelDataRangeNV (GLenum, GLsizei, GLvoid *); -GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); -#endif - -#ifndef GL_NV_primitive_restart -#define GL_NV_primitive_restart 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPrimitiveRestartNV (void); -GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); -#endif - -#ifndef GL_NV_texture_expand_normal -#define GL_NV_texture_expand_normal 1 -#endif - -#ifndef GL_NV_vertex_program2 -#define GL_NV_vertex_program2 1 -#endif - -#ifndef GL_ATI_map_object_buffer -#define GL_ATI_map_object_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint); -GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); -#endif - -#ifndef GL_ATI_separate_stencil -#define GL_ATI_separate_stencil 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilOpSeparateATI (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum, GLenum, GLint, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -#endif - -#ifndef GL_ATI_vertex_attrib_array_object -#define GL_ATI_vertex_attrib_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint, GLint, GLenum, GLboolean, GLsizei, GLuint, GLuint); -GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); -#endif - -#ifndef GL_OES_read_format -#define GL_OES_read_format 1 -#endif - -#ifndef GL_EXT_depth_bounds_test -#define GL_EXT_depth_bounds_test 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDepthBoundsEXT (GLclampd, GLclampd); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); -#endif - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_EXT_texture_mirror_clamp 1 -#endif - -#ifndef GL_EXT_blend_equation_separate -#define GL_EXT_blend_equation_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); -#endif - -#ifndef GL_MESA_pack_invert -#define GL_MESA_pack_invert 1 -#endif - -#ifndef GL_MESA_ycbcr_texture -#define GL_MESA_ycbcr_texture 1 -#endif - -#ifndef GL_EXT_pixel_buffer_object -#define GL_EXT_pixel_buffer_object 1 -#endif - -#ifndef GL_NV_fragment_program_option -#define GL_NV_fragment_program_option 1 -#endif - -#ifndef GL_NV_fragment_program2 -#define GL_NV_fragment_program2 1 -#endif - -#ifndef GL_NV_vertex_program2_option -#define GL_NV_vertex_program2_option 1 -#endif - -#ifndef GL_NV_vertex_program3 -#define GL_NV_vertex_program3 1 -#endif - -#ifndef GL_EXT_framebuffer_object -#define GL_EXT_framebuffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint); -GLAPI void APIENTRY glBindRenderbufferEXT (GLenum, GLuint); -GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei, GLuint *); -GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum, GLenum, GLsizei, GLsizei); -GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum, GLenum, GLint *); -GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint); -GLAPI void APIENTRY glBindFramebufferEXT (GLenum, GLuint); -GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei, GLuint *); -GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum); -GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum, GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum, GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLint); -GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum, GLenum, GLenum, GLuint); -GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGenerateMipmapEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); -#endif - -#ifndef GL_GREMEDY_string_marker -#define GL_GREMEDY_string_marker 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); -#endif - - -#ifdef __cplusplus -} -#endif - -#endif -#endif /* NO_SDL_GLEXT */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_platform.h spring-98.0~14.04~ppa6/include/SDL/SDL_platform.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_platform.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_platform.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* Try to get a standard set of platform defines */ - -#ifndef _SDL_platform_h -#define _SDL_platform_h - -#if defined(_AIX) -#undef __AIX__ -#define __AIX__ 1 -#endif -#if defined(__BEOS__) -#undef __BEOS__ -#define __BEOS__ 1 -#endif -#if defined(bsdi) || defined(__bsdi) || defined(__bsdi__) -#undef __BSDI__ -#define __BSDI__ 1 -#endif -#if defined(_arch_dreamcast) -#undef __DREAMCAST__ -#define __DREAMCAST__ 1 -#endif -#if defined(__FreeBSD__) || defined(__DragonFly__) -#undef __FREEBSD__ -#define __FREEBSD__ 1 -#endif -#if defined(hpux) || defined(__hpux) || defined(__hpux__) -#undef __HPUX__ -#define __HPUX__ 1 -#endif -#if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE) -#undef __IRIX__ -#define __IRIX__ 1 -#endif -#if defined(linux) || defined(__linux) || defined(__linux__) -#undef __LINUX__ -#define __LINUX__ 1 -#endif -#if defined(__APPLE__) -#undef __MACOSX__ -#define __MACOSX__ 1 -#elif defined(macintosh) -#undef __MACOS__ -#define __MACOS__ 1 -#endif -#if defined(__NetBSD__) -#undef __NETBSD__ -#define __NETBSD__ 1 -#endif -#if defined(__OpenBSD__) -#undef __OPENBSD__ -#define __OPENBSD__ 1 -#endif -#if defined(__OS2__) -#undef __OS2__ -#define __OS2__ 1 -#endif -#if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) -#undef __OSF__ -#define __OSF__ 1 -#endif -#if defined(__QNXNTO__) -#undef __QNXNTO__ -#define __QNXNTO__ 1 -#endif -#if defined(riscos) || defined(__riscos) || defined(__riscos__) -#undef __RISCOS__ -#define __RISCOS__ 1 -#endif -#if defined(__SVR4) -#undef __SOLARIS__ -#define __SOLARIS__ 1 -#endif -#if defined(WIN32) || defined(_WIN32) -#undef __WIN32__ -#define __WIN32__ 1 -#endif - -#endif /* _SDL_platform_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_quit.h spring-98.0~14.04~ppa6/include/SDL/SDL_quit.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_quit.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_quit.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* Include file for SDL quit event handling */ - -#ifndef _SDL_quit_h -#define _SDL_quit_h - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -/* - An SDL_QUITEVENT is generated when the user tries to close the application - window. If it is ignored or filtered out, the window will remain open. - If it is not ignored or filtered, it is queued normally and the window - is allowed to close. When the window is closed, screen updates will - complete, but have no effect. - - SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) - and SIGTERM (system termination request), if handlers do not already - exist, that generate SDL_QUITEVENT events as well. There is no way - to determine the cause of an SDL_QUITEVENT, but setting a signal - handler in your application will override the default generation of - quit events for that signal. -*/ - -/* There are no functions directly affecting the quit event */ -#define SDL_QuitRequested() \ - (SDL_PumpEvents(), SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUITMASK)) - -#endif /* _SDL_quit_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_rwops.h spring-98.0~14.04~ppa6/include/SDL/SDL_rwops.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_rwops.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_rwops.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,144 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* This file provides a general interface for SDL to read and write - data sources. It can easily be extended to files, memory, etc. -*/ - -#ifndef _SDL_rwops_h -#define _SDL_rwops_h - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* This is the read/write operation structure -- very basic */ - -typedef struct SDL_RWops { - /* Seek to 'offset' relative to whence, one of stdio's whence values: - SEEK_SET, SEEK_CUR, SEEK_END - Returns the final offset in the data source. - */ - int (SDLCALL *seek)(struct SDL_RWops *context, int offset, int whence); - - /* Read up to 'num' objects each of size 'objsize' from the data - source to the area pointed at by 'ptr'. - Returns the number of objects read, or -1 if the read failed. - */ - int (SDLCALL *read)(struct SDL_RWops *context, void *ptr, int size, int maxnum); - - /* Write exactly 'num' objects each of size 'objsize' from the area - pointed at by 'ptr' to data source. - Returns 'num', or -1 if the write failed. - */ - int (SDLCALL *write)(struct SDL_RWops *context, const void *ptr, int size, int num); - - /* Close and free an allocated SDL_FSops structure */ - int (SDLCALL *close)(struct SDL_RWops *context); - - Uint32 type; - union { -#if defined(__WIN32__) && !defined(__SYMBIAN32__) - struct { - int append; - void *h; - struct { - void *data; - int size; - int left; - } buffer; - } win32io; -#endif -#ifdef HAVE_STDIO_H - struct { - int autoclose; - FILE *fp; - } stdio; -#endif - struct { - Uint8 *base; - Uint8 *here; - Uint8 *stop; - } mem; - struct { - void *data1; - } unknown; - } hidden; - -} SDL_RWops; - - -/* Functions to create SDL_RWops structures from various data sources */ - -extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFile(const char *file, const char *mode); - -#ifdef HAVE_STDIO_H -extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFP(FILE *fp, int autoclose); -#endif - -extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromMem(void *mem, int size); -extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromConstMem(const void *mem, int size); - -extern DECLSPEC SDL_RWops * SDLCALL SDL_AllocRW(void); -extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops *area); - -#define RW_SEEK_SET 0 /* Seek from the beginning of data */ -#define RW_SEEK_CUR 1 /* Seek relative to current read point */ -#define RW_SEEK_END 2 /* Seek relative to the end of data */ - -/* Macros to easily read and write from an SDL_RWops structure */ -#define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence) -#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR) -#define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n) -#define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n) -#define SDL_RWclose(ctx) (ctx)->close(ctx) - - -/* Read an item of the specified endianness and return in native format */ -extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops *src); -extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops *src); -extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops *src); -extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops *src); -extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops *src); -extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops *src); - -/* Write an item of native format to the specified endianness */ -extern DECLSPEC int SDLCALL SDL_WriteLE16(SDL_RWops *dst, Uint16 value); -extern DECLSPEC int SDLCALL SDL_WriteBE16(SDL_RWops *dst, Uint16 value); -extern DECLSPEC int SDLCALL SDL_WriteLE32(SDL_RWops *dst, Uint32 value); -extern DECLSPEC int SDLCALL SDL_WriteBE32(SDL_RWops *dst, Uint32 value); -extern DECLSPEC int SDLCALL SDL_WriteLE64(SDL_RWops *dst, Uint64 value); -extern DECLSPEC int SDLCALL SDL_WriteBE64(SDL_RWops *dst, Uint64 value); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_rwops_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_stdinc.h spring-98.0~14.04~ppa6/include/SDL/SDL_stdinc.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_stdinc.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_stdinc.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,597 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* This is a general header that includes C language support */ - -#ifndef _SDL_stdinc_h -#define _SDL_stdinc_h - -#include "SDL_config.h" - - -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_STDIO_H -#include -#endif -#if defined(STDC_HEADERS) -# include -# include -# include -#else -# if defined(HAVE_STDLIB_H) -# include -# elif defined(HAVE_MALLOC_H) -# include -# endif -# if defined(HAVE_STDDEF_H) -# include -# endif -# if defined(HAVE_STDARG_H) -# include -# endif -#endif -#ifdef HAVE_STRING_H -# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H) -# include -# endif -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif -#if defined(HAVE_INTTYPES_H) -# include -#elif defined(HAVE_STDINT_H) -# include -#endif -#ifdef HAVE_CTYPE_H -# include -#endif -#ifdef HAVE_ICONV_H -# include -#endif - -/* The number of elements in an array */ -#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0])) -#define SDL_TABLESIZE(table) SDL_arraysize(table) - -/* Basic data types */ -typedef enum SDL_bool { - SDL_FALSE = 0, - SDL_TRUE = 1 -} SDL_bool; - -typedef int8_t Sint8; -typedef uint8_t Uint8; -typedef int16_t Sint16; -typedef uint16_t Uint16; -typedef int32_t Sint32; -typedef uint32_t Uint32; - -#ifdef SDL_HAS_64BIT_TYPE -typedef int64_t Sint64; -#ifndef SYMBIAN32_GCCE -typedef uint64_t Uint64; -#endif -#else -/* This is really just a hack to prevent the compiler from complaining */ -typedef struct { - Uint32 hi; - Uint32 lo; -} Uint64, Sint64; -#endif - -/* Make sure the types really have the right sizes */ -#define SDL_COMPILE_TIME_ASSERT(name, x) \ - typedef int SDL_dummy_ ## name[(x) * 2 - 1] - -SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1); -SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1); -SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2); -SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2); -SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4); -SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4); -SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8); -SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8); - -/* Check to make sure enums are the size of ints, for structure packing. - For both Watcom C/C++ and Borland C/C++ the compiler option that makes - enums having the size of an int must be enabled. - This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11). -*/ -/* Enable enums always int in CodeWarrior (for MPW use "-enum int") */ -#ifdef __MWERKS__ -#pragma enumsalwaysint on -#endif - -typedef enum { - DUMMY_ENUM_VALUE -} SDL_DUMMY_ENUM; - -#ifndef __NDS__ -SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int)); -#endif - - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef HAVE_MALLOC -#define SDL_malloc malloc -#else -extern DECLSPEC void * SDLCALL SDL_malloc(size_t size); -#endif - -#ifdef HAVE_CALLOC -#define SDL_calloc calloc -#else -extern DECLSPEC void * SDLCALL SDL_calloc(size_t nmemb, size_t size); -#endif - -#ifdef HAVE_REALLOC -#define SDL_realloc realloc -#else -extern DECLSPEC void * SDLCALL SDL_realloc(void *mem, size_t size); -#endif - -#ifdef HAVE_FREE -#define SDL_free free -#else -extern DECLSPEC void SDLCALL SDL_free(void *mem); -#endif - -#if defined(HAVE_ALLOCA) && !defined(alloca) -# if defined(HAVE_ALLOCA_H) -# include -# elif defined(__GNUC__) -# define alloca __builtin_alloca -# elif defined(_MSC_VER) -# include -# define alloca _alloca -# elif defined(__WATCOMC__) -# include -# elif defined(__BORLANDC__) -# include -# elif defined(__DMC__) -# include -# elif defined(__AIX__) - #pragma alloca -# elif defined(__MRC__) - void *alloca (unsigned); -# else - char *alloca (); -# endif -#endif -#ifdef HAVE_ALLOCA -#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count)) -#define SDL_stack_free(data) -#else -#define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*(count)) -#define SDL_stack_free(data) SDL_free(data) -#endif - -#ifdef HAVE_GETENV -#define SDL_getenv getenv -#else -extern DECLSPEC char * SDLCALL SDL_getenv(const char *name); -#endif - -#ifdef HAVE_PUTENV -#define SDL_putenv putenv -#else -extern DECLSPEC int SDLCALL SDL_putenv(const char *variable); -#endif - -#ifdef HAVE_QSORT -#define SDL_qsort qsort -#else -extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, - int (*compare)(const void *, const void *)); -#endif - -#ifdef HAVE_ABS -#define SDL_abs abs -#else -#define SDL_abs(X) ((X) < 0 ? -(X) : (X)) -#endif - -#define SDL_min(x, y) (((x) < (y)) ? (x) : (y)) -#define SDL_max(x, y) (((x) > (y)) ? (x) : (y)) - -#ifdef HAVE_CTYPE_H -#define SDL_isdigit(X) isdigit(X) -#define SDL_isspace(X) isspace(X) -#define SDL_toupper(X) toupper(X) -#define SDL_tolower(X) tolower(X) -#else -#define SDL_isdigit(X) (((X) >= '0') && ((X) <= '9')) -#define SDL_isspace(X) (((X) == ' ') || ((X) == '\t') || ((X) == '\r') || ((X) == '\n')) -#define SDL_toupper(X) (((X) >= 'a') && ((X) <= 'z') ? ('A'+((X)-'a')) : (X)) -#define SDL_tolower(X) (((X) >= 'A') && ((X) <= 'Z') ? ('a'+((X)-'A')) : (X)) -#endif - -#ifdef HAVE_MEMSET -#define SDL_memset memset -#else -extern DECLSPEC void * SDLCALL SDL_memset(void *dst, int c, size_t len); -#endif - -#if defined(__GNUC__) && defined(i386) -#define SDL_memset4(dst, val, len) \ -do { \ - int u0, u1, u2; \ - __asm__ __volatile__ ( \ - "cld\n\t" \ - "rep ; stosl\n\t" \ - : "=&D" (u0), "=&a" (u1), "=&c" (u2) \ - : "0" (dst), "1" (val), "2" ((Uint32)(len)) \ - : "memory" ); \ -} while(0) -#endif -#ifndef SDL_memset4 -#define SDL_memset4(dst, val, len) \ -do { \ - unsigned _count = (len); \ - unsigned _n = (_count + 3) / 4; \ - Uint32 *_p = (Uint32 *)(dst); \ - Uint32 _val = (val); \ - switch (_count % 4) { \ - case 0: do { *_p++ = _val; \ - case 3: *_p++ = _val; \ - case 2: *_p++ = _val; \ - case 1: *_p++ = _val; \ - } while ( --_n ); \ - } \ -} while(0) -#endif - -/* We can count on memcpy existing on Mac OS X and being well-tuned. */ -#if defined(__MACH__) && defined(__APPLE__) -#define SDL_memcpy(dst, src, len) memcpy(dst, src, len) -#elif defined(__GNUC__) && defined(i386) -#define SDL_memcpy(dst, src, len) \ -do { \ - int u0, u1, u2; \ - __asm__ __volatile__ ( \ - "cld\n\t" \ - "rep ; movsl\n\t" \ - "testb $2,%b4\n\t" \ - "je 1f\n\t" \ - "movsw\n" \ - "1:\ttestb $1,%b4\n\t" \ - "je 2f\n\t" \ - "movsb\n" \ - "2:" \ - : "=&c" (u0), "=&D" (u1), "=&S" (u2) \ - : "0" ((unsigned)(len)/4), "q" (len), "1" (dst),"2" (src) \ - : "memory" ); \ -} while(0) -#endif -#ifndef SDL_memcpy -#ifdef HAVE_MEMCPY -#define SDL_memcpy memcpy -#elif defined(HAVE_BCOPY) -#define SDL_memcpy(d, s, n) bcopy((s), (d), (n)) -#else -extern DECLSPEC void * SDLCALL SDL_memcpy(void *dst, const void *src, size_t len); -#endif -#endif - -/* We can count on memcpy existing on Mac OS X and being well-tuned. */ -#if defined(__MACH__) && defined(__APPLE__) -#define SDL_memcpy4(dst, src, len) memcpy(dst, src, (len)*4) -#elif defined(__GNUC__) && defined(i386) -#define SDL_memcpy4(dst, src, len) \ -do { \ - int ecx, edi, esi; \ - __asm__ __volatile__ ( \ - "cld\n\t" \ - "rep ; movsl" \ - : "=&c" (ecx), "=&D" (edi), "=&S" (esi) \ - : "0" ((unsigned)(len)), "1" (dst), "2" (src) \ - : "memory" ); \ -} while(0) -#endif -#ifndef SDL_memcpy4 -#define SDL_memcpy4(dst, src, len) SDL_memcpy(dst, src, (len) << 2) -#endif - -#if defined(__GNUC__) && defined(i386) -#define SDL_revcpy(dst, src, len) \ -do { \ - int u0, u1, u2; \ - char *dstp = (char *)(dst); \ - char *srcp = (char *)(src); \ - int n = (len); \ - if ( n >= 4 ) { \ - __asm__ __volatile__ ( \ - "std\n\t" \ - "rep ; movsl\n\t" \ - "cld\n\t" \ - : "=&c" (u0), "=&D" (u1), "=&S" (u2) \ - : "0" (n >> 2), \ - "1" (dstp+(n-4)), "2" (srcp+(n-4)) \ - : "memory" ); \ - } \ - switch (n & 3) { \ - case 3: dstp[2] = srcp[2]; \ - case 2: dstp[1] = srcp[1]; \ - case 1: dstp[0] = srcp[0]; \ - break; \ - default: \ - break; \ - } \ -} while(0) -#endif -#ifndef SDL_revcpy -extern DECLSPEC void * SDLCALL SDL_revcpy(void *dst, const void *src, size_t len); -#endif - -#ifdef HAVE_MEMMOVE -#define SDL_memmove memmove -#elif defined(HAVE_BCOPY) -#define SDL_memmove(d, s, n) bcopy((s), (d), (n)) -#else -#define SDL_memmove(dst, src, len) \ -do { \ - if ( dst < src ) { \ - SDL_memcpy(dst, src, len); \ - } else { \ - SDL_revcpy(dst, src, len); \ - } \ -} while(0) -#endif - -#ifdef HAVE_MEMCMP -#define SDL_memcmp memcmp -#else -extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len); -#endif - -#ifdef HAVE_STRLEN -#define SDL_strlen strlen -#else -extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string); -#endif - -#ifdef HAVE_STRLCPY -#define SDL_strlcpy strlcpy -#else -extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src, size_t maxlen); -#endif - -#ifdef HAVE_STRLCAT -#define SDL_strlcat strlcat -#else -extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src, size_t maxlen); -#endif - -#ifdef HAVE_STRDUP -#define SDL_strdup strdup -#else -extern DECLSPEC char * SDLCALL SDL_strdup(const char *string); -#endif - -#ifdef HAVE__STRREV -#define SDL_strrev _strrev -#else -extern DECLSPEC char * SDLCALL SDL_strrev(char *string); -#endif - -#ifdef HAVE__STRUPR -#define SDL_strupr _strupr -#else -extern DECLSPEC char * SDLCALL SDL_strupr(char *string); -#endif - -#ifdef HAVE__STRLWR -#define SDL_strlwr _strlwr -#else -extern DECLSPEC char * SDLCALL SDL_strlwr(char *string); -#endif - -#ifdef HAVE_STRCHR -#define SDL_strchr strchr -#elif defined(HAVE_INDEX) -#define SDL_strchr index -#else -extern DECLSPEC char * SDLCALL SDL_strchr(const char *string, int c); -#endif - -#ifdef HAVE_STRRCHR -#define SDL_strrchr strrchr -#elif defined(HAVE_RINDEX) -#define SDL_strrchr rindex -#else -extern DECLSPEC char * SDLCALL SDL_strrchr(const char *string, int c); -#endif - -#ifdef HAVE_STRSTR -#define SDL_strstr strstr -#else -extern DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *needle); -#endif - -#ifdef HAVE_ITOA -#define SDL_itoa itoa -#else -#define SDL_itoa(value, string, radix) SDL_ltoa((long)value, string, radix) -#endif - -#ifdef HAVE__LTOA -#define SDL_ltoa _ltoa -#else -extern DECLSPEC char * SDLCALL SDL_ltoa(long value, char *string, int radix); -#endif - -#ifdef HAVE__UITOA -#define SDL_uitoa _uitoa -#else -#define SDL_uitoa(value, string, radix) SDL_ultoa((long)value, string, radix) -#endif - -#ifdef HAVE__ULTOA -#define SDL_ultoa _ultoa -#else -extern DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *string, int radix); -#endif - -#ifdef HAVE_STRTOL -#define SDL_strtol strtol -#else -extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, int base); -#endif - -#ifdef HAVE_STRTOUL -#define SDL_strtoul strtoul -#else -extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string, char **endp, int base); -#endif - -#ifdef SDL_HAS_64BIT_TYPE - -#ifdef HAVE__I64TOA -#define SDL_lltoa _i64toa -#else -extern DECLSPEC char* SDLCALL SDL_lltoa(Sint64 value, char *string, int radix); -#endif - -#ifdef HAVE__UI64TOA -#define SDL_ulltoa _ui64toa -#else -extern DECLSPEC char* SDLCALL SDL_ulltoa(Uint64 value, char *string, int radix); -#endif - -#ifdef HAVE_STRTOLL -#define SDL_strtoll strtoll -#else -extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, int base); -#endif - -#ifdef HAVE_STRTOULL -#define SDL_strtoull strtoull -#else -extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp, int base); -#endif - -#endif /* SDL_HAS_64BIT_TYPE */ - -#ifdef HAVE_STRTOD -#define SDL_strtod strtod -#else -extern DECLSPEC double SDLCALL SDL_strtod(const char *string, char **endp); -#endif - -#ifdef HAVE_ATOI -#define SDL_atoi atoi -#else -#define SDL_atoi(X) SDL_strtol(X, NULL, 0) -#endif - -#ifdef HAVE_ATOF -#define SDL_atof atof -#else -#define SDL_atof(X) SDL_strtod(X, NULL) -#endif - -#ifdef HAVE_STRCMP -#define SDL_strcmp strcmp -#else -extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2); -#endif - -#ifdef HAVE_STRNCMP -#define SDL_strncmp strncmp -#else -extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen); -#endif - -#ifdef HAVE_STRCASECMP -#define SDL_strcasecmp strcasecmp -#elif defined(HAVE__STRICMP) -#define SDL_strcasecmp _stricmp -#else -extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2); -#endif - -#ifdef HAVE_STRNCASECMP -#define SDL_strncasecmp strncasecmp -#elif defined(HAVE__STRNICMP) -#define SDL_strncasecmp _strnicmp -#else -extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen); -#endif - -#ifdef HAVE_SSCANF -#define SDL_sscanf sscanf -#else -extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...); -#endif - -#ifdef HAVE_SNPRINTF -#define SDL_snprintf snprintf -#else -extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...); -#endif - -#ifdef HAVE_VSNPRINTF -#define SDL_vsnprintf vsnprintf -#else -extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap); -#endif - -/* The SDL implementation of iconv() returns these error codes */ -#define SDL_ICONV_ERROR (size_t)-1 -#define SDL_ICONV_E2BIG (size_t)-2 -#define SDL_ICONV_EILSEQ (size_t)-3 -#define SDL_ICONV_EINVAL (size_t)-4 - -#ifdef HAVE_ICONV -#define SDL_iconv_t iconv_t -#define SDL_iconv_open iconv_open -#define SDL_iconv_close iconv_close -#else -typedef struct _SDL_iconv_t *SDL_iconv_t; -extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode, const char *fromcode); -extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd); -#endif -extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft); -/* This function converts a string between encodings in one pass, returning a - string that must be freed with SDL_free() or NULL on error. -*/ -extern DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft); -#define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1) -#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1) -#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1) - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_stdinc_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_syswm.h spring-98.0~14.04~ppa6/include/SDL/SDL_syswm.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_syswm.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_syswm.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,214 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* Include file for SDL custom system window manager hooks */ - -#ifndef _SDL_syswm_h -#define _SDL_syswm_h - -#include "SDL_stdinc.h" -#include "SDL_error.h" -#include "SDL_version.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* Your application has access to a special type of event 'SDL_SYSWMEVENT', - which contains window-manager specific information and arrives whenever - an unhandled window event occurs. This event is ignored by default, but - you can enable it with SDL_EventState() -*/ -#ifdef SDL_PROTOTYPES_ONLY -struct SDL_SysWMinfo; -typedef struct SDL_SysWMinfo SDL_SysWMinfo; -#else - -/* This is the structure for custom window manager events */ -#if defined(SDL_VIDEO_DRIVER_X11) -#if defined(__APPLE__) && defined(__MACH__) -/* conflicts with Quickdraw.h */ -#define Cursor X11Cursor -#endif - -#include -#include - -#if defined(__APPLE__) && defined(__MACH__) -/* matches the re-define above */ -#undef Cursor -#endif - -/* These are the various supported subsystems under UNIX */ -typedef enum { - SDL_SYSWM_X11 -} SDL_SYSWM_TYPE; - -/* The UNIX custom event structure */ -struct SDL_SysWMmsg { - SDL_version version; - SDL_SYSWM_TYPE subsystem; - union { - XEvent xevent; - } event; -}; - -/* The UNIX custom window manager information structure. - When this structure is returned, it holds information about which - low level system it is using, and will be one of SDL_SYSWM_TYPE. - */ -typedef struct SDL_SysWMinfo { - SDL_version version; - SDL_SYSWM_TYPE subsystem; - union { - struct { - Display *display; /* The X11 display */ - Window window; /* The X11 display window */ - /* These locking functions should be called around - any X11 functions using the display variable, - but not the gfxdisplay variable. - They lock the event thread, so should not be - called around event functions or from event filters. - */ - void (*lock_func)(void); - void (*unlock_func)(void); - - /* Introduced in SDL 1.0.2 */ - Window fswindow; /* The X11 fullscreen window */ - Window wmwindow; /* The X11 managed input window */ - - /* Introduced in SDL 1.2.12 */ - Display *gfxdisplay; /* The X11 display to which rendering is done */ - } x11; - } info; -} SDL_SysWMinfo; - -#elif defined(SDL_VIDEO_DRIVER_NANOX) -#include - -/* The generic custom event structure */ -struct SDL_SysWMmsg { - SDL_version version; - int data; -}; - -/* The windows custom window manager information structure */ -typedef struct SDL_SysWMinfo { - SDL_version version ; - GR_WINDOW_ID window ; /* The display window */ -} SDL_SysWMinfo; - -#elif defined(SDL_VIDEO_DRIVER_WINDIB) || defined(SDL_VIDEO_DRIVER_DDRAW) || defined(SDL_VIDEO_DRIVER_GAPI) -#define WIN32_LEAN_AND_MEAN -#include - -/* The windows custom event structure */ -struct SDL_SysWMmsg { - SDL_version version; - HWND hwnd; /* The window for the message */ - UINT msg; /* The type of message */ - WPARAM wParam; /* WORD message parameter */ - LPARAM lParam; /* LONG message parameter */ -}; - -/* The windows custom window manager information structure */ -typedef struct SDL_SysWMinfo { - SDL_version version; - HWND window; /* The Win32 display window */ - HGLRC hglrc; /* The OpenGL context, if any */ -} SDL_SysWMinfo; - -#elif defined(SDL_VIDEO_DRIVER_RISCOS) - -/* RISC OS custom event structure */ -struct SDL_SysWMmsg { - SDL_version version; - int eventCode; /* The window for the message */ - int pollBlock[64]; -}; - -/* The RISC OS custom window manager information structure */ -typedef struct SDL_SysWMinfo { - SDL_version version; - int wimpVersion; /* Wimp version running under */ - int taskHandle; /* The RISC OS task handle */ - int window; /* The RISC OS display window */ -} SDL_SysWMinfo; - -#elif defined(SDL_VIDEO_DRIVER_PHOTON) -#include -#include - -/* The QNX custom event structure */ -struct SDL_SysWMmsg { - SDL_version version; - int data; -}; - -/* The QNX custom window manager information structure */ -typedef struct SDL_SysWMinfo { - SDL_version version; - int data; -} SDL_SysWMinfo; - -#else - -/* The generic custom event structure */ -struct SDL_SysWMmsg { - SDL_version version; - int data; -}; - -/* The generic custom window manager information structure */ -typedef struct SDL_SysWMinfo { - SDL_version version; - int data; -} SDL_SysWMinfo; - -#endif /* video driver type */ - -#endif /* SDL_PROTOTYPES_ONLY */ - -/* Function prototypes */ -/* - * This function gives you custom hooks into the window manager information. - * It fills the structure pointed to by 'info' with custom information and - * returns 1 if the function is implemented. If it's not implemented, or - * the version member of the 'info' structure is invalid, it returns 0. - * - * You typically use this function like this: - * SDL_SysWMInfo info; - * SDL_VERSION(&info.version); - * if ( SDL_GetWMInfo(&info) ) { ... } - */ -extern DECLSPEC int SDLCALL SDL_GetWMInfo(SDL_SysWMinfo *info); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_syswm_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_thread.h spring-98.0~14.04~ppa6/include/SDL/SDL_thread.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_thread.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_thread.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,119 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -#ifndef _SDL_thread_h -#define _SDL_thread_h - -/* Header for the SDL thread management routines - - These are independent of the other SDL routines. -*/ - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -/* Thread synchronization primitives */ -#include "SDL_mutex.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* The SDL thread structure, defined in SDL_thread.c */ -struct SDL_Thread; -typedef struct SDL_Thread SDL_Thread; - -/* Create a thread */ -#if ((defined(__WIN32__) && !defined(HAVE_LIBC)) || defined(__OS2__)) && !defined(__SYMBIAN32__) -/* - We compile SDL into a DLL on OS/2. This means, that it's the DLL which - creates a new thread for the calling process with the SDL_CreateThread() - API. There is a problem with this, that only the RTL of the SDL.DLL will - be initialized for those threads, and not the RTL of the calling application! - To solve this, we make a little hack here. - We'll always use the caller's _beginthread() and _endthread() APIs to - start a new thread. This way, if it's the SDL.DLL which uses this API, - then the RTL of SDL.DLL will be used to create the new thread, and if it's - the application, then the RTL of the application will be used. - So, in short: - Always use the _beginthread() and _endthread() of the calling runtime library! -*/ -#define SDL_PASSED_BEGINTHREAD_ENDTHREAD -#ifndef _WIN32_WCE -#include /* This has _beginthread() and _endthread() defined! */ -#endif - -#ifdef __OS2__ -typedef int (*pfnSDL_CurrentBeginThread)(void (*func)(void *), void *, unsigned, void *arg); -typedef void (*pfnSDL_CurrentEndThread)(void); -#elif __GNUC__ -typedef unsigned long (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned, - unsigned (__stdcall *func)(void *), void *arg, - unsigned, unsigned *threadID); -typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code); -#else -typedef uintptr_t (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned, - unsigned (__stdcall *func)(void *), void *arg, - unsigned, unsigned *threadID); -typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code); -#endif - -extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread); - -#ifdef __OS2__ -#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthread, _endthread) -#elif defined(_WIN32_WCE) -#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, NULL, NULL) -#else -#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthreadex, _endthreadex) -#endif -#else -extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data); -#endif - -/* Get the 32-bit thread identifier for the current thread */ -extern DECLSPEC Uint32 SDLCALL SDL_ThreadID(void); - -/* Get the 32-bit thread identifier for the specified thread, - equivalent to SDL_ThreadID() if the specified thread is NULL. - */ -extern DECLSPEC Uint32 SDLCALL SDL_GetThreadID(SDL_Thread *thread); - -/* Wait for a thread to finish. - The return code for the thread function is placed in the area - pointed to by 'status', if 'status' is not NULL. - */ -extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread *thread, int *status); - -/* Forcefully kill a thread without worrying about its state */ -extern DECLSPEC void SDLCALL SDL_KillThread(SDL_Thread *thread); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_thread_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_timer.h spring-98.0~14.04~ppa6/include/SDL/SDL_timer.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_timer.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_timer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,115 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -#ifndef _SDL_timer_h -#define _SDL_timer_h - -/* Header for the SDL time management routines */ - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* This is the OS scheduler timeslice, in milliseconds */ -#define SDL_TIMESLICE 10 - -/* This is the maximum resolution of the SDL timer on all platforms */ -#define TIMER_RESOLUTION 10 /* Experimentally determined */ - -/* Get the number of milliseconds since the SDL library initialization. - * Note that this value wraps if the program runs for more than ~49 days. - */ -extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); - -/* Wait a specified number of milliseconds before returning */ -extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); - -/* Function prototype for the timer callback function */ -typedef Uint32 (SDLCALL *SDL_TimerCallback)(Uint32 interval); - -/* Set a callback to run after the specified number of milliseconds has - * elapsed. The callback function is passed the current timer interval - * and returns the next timer interval. If the returned value is the - * same as the one passed in, the periodic alarm continues, otherwise a - * new alarm is scheduled. If the callback returns 0, the periodic alarm - * is cancelled. - * - * To cancel a currently running timer, call SDL_SetTimer(0, NULL); - * - * The timer callback function may run in a different thread than your - * main code, and so shouldn't call any functions from within itself. - * - * The maximum resolution of this timer is 10 ms, which means that if - * you request a 16 ms timer, your callback will run approximately 20 ms - * later on an unloaded system. If you wanted to set a flag signaling - * a frame update at 30 frames per second (every 33 ms), you might set a - * timer for 30 ms: - * SDL_SetTimer((33/10)*10, flag_update); - * - * If you use this function, you need to pass SDL_INIT_TIMER to SDL_Init(). - * - * Under UNIX, you should not use raise or use SIGALRM and this function - * in the same program, as it is implemented using setitimer(). You also - * should not use this function in multi-threaded applications as signals - * to multi-threaded apps have undefined behavior in some implementations. - * - * This function returns 0 if successful, or -1 if there was an error. - */ -extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval, SDL_TimerCallback callback); - -/* New timer API, supports multiple timers - * Written by Stephane Peter - */ - -/* Function prototype for the new timer callback function. - * The callback function is passed the current timer interval and returns - * the next timer interval. If the returned value is the same as the one - * passed in, the periodic alarm continues, otherwise a new alarm is - * scheduled. If the callback returns 0, the periodic alarm is cancelled. - */ -typedef Uint32 (SDLCALL *SDL_NewTimerCallback)(Uint32 interval, void *param); - -/* Definition of the timer ID type */ -typedef struct _SDL_TimerID *SDL_TimerID; - -/* Add a new timer to the pool of timers already running. - Returns a timer ID, or NULL when an error occurs. - */ -extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param); - -/* Remove one of the multiple timers knowing its ID. - * Returns a boolean value indicating success. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID t); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_timer_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_types.h spring-98.0~14.04~ppa6/include/SDL/SDL_types.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_types.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_types.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* DEPRECATED */ -#include "SDL_stdinc.h" diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_version.h spring-98.0~14.04~ppa6/include/SDL/SDL_version.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_version.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_version.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* This header defines the current SDL version */ - -#ifndef _SDL_version_h -#define _SDL_version_h - -#include "SDL_stdinc.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL -*/ -#define SDL_MAJOR_VERSION 1 -#define SDL_MINOR_VERSION 2 -#define SDL_PATCHLEVEL 13 - -typedef struct SDL_version { - Uint8 major; - Uint8 minor; - Uint8 patch; -} SDL_version; - -/* This macro can be used to fill a version structure with the compile-time - * version of the SDL library. - */ -#define SDL_VERSION(X) \ -{ \ - (X)->major = SDL_MAJOR_VERSION; \ - (X)->minor = SDL_MINOR_VERSION; \ - (X)->patch = SDL_PATCHLEVEL; \ -} - -/* This macro turns the version numbers into a numeric value: - (1,2,3) -> (1203) - This assumes that there will never be more than 100 patchlevels -*/ -#define SDL_VERSIONNUM(X, Y, Z) \ - ((X)*1000 + (Y)*100 + (Z)) - -/* This is the version number macro for the current SDL version */ -#define SDL_COMPILEDVERSION \ - SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) - -/* This macro will evaluate to true if compiled with SDL at least X.Y.Z */ -#define SDL_VERSION_ATLEAST(X, Y, Z) \ - (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) - -/* This function gets the version of the dynamically linked SDL library. - it should NOT be used to fill a version structure, instead you should - use the SDL_Version() macro. - */ -extern DECLSPEC const SDL_version * SDLCALL SDL_Linked_Version(void); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_version_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL/SDL_video.h spring-98.0~14.04~ppa6/include/SDL/SDL_video.h --- spring-96.0~14.04~ppa4/include/SDL/SDL_video.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL/SDL_video.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,891 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* Header file for access to the SDL raw framebuffer window */ - -#ifndef _SDL_video_h -#define _SDL_video_h - -#include "SDL_stdinc.h" -#include "SDL_error.h" -#include "SDL_rwops.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/* Transparency definitions: These define alpha as the opacity of a surface */ -#define SDL_ALPHA_OPAQUE 255 -#define SDL_ALPHA_TRANSPARENT 0 - -/* Useful data types */ -typedef struct SDL_Rect { - Sint16 x, y; - Uint16 w, h; -} SDL_Rect; - -typedef struct SDL_Color { - Uint8 r; - Uint8 g; - Uint8 b; - Uint8 unused; -} SDL_Color; -#define SDL_Colour SDL_Color - -typedef struct SDL_Palette { - int ncolors; - SDL_Color *colors; -} SDL_Palette; - -/* Everything in the pixel format structure is read-only */ -typedef struct SDL_PixelFormat { - SDL_Palette *palette; - Uint8 BitsPerPixel; - Uint8 BytesPerPixel; - Uint8 Rloss; - Uint8 Gloss; - Uint8 Bloss; - Uint8 Aloss; - Uint8 Rshift; - Uint8 Gshift; - Uint8 Bshift; - Uint8 Ashift; - Uint32 Rmask; - Uint32 Gmask; - Uint32 Bmask; - Uint32 Amask; - - /* RGB color key information */ - Uint32 colorkey; - /* Alpha value information (per-surface alpha) */ - Uint8 alpha; -} SDL_PixelFormat; - -/* This structure should be treated as read-only, except for 'pixels', - which, if not NULL, contains the raw pixel data for the surface. -*/ -typedef struct SDL_Surface { - Uint32 flags; /* Read-only */ - SDL_PixelFormat *format; /* Read-only */ - int w, h; /* Read-only */ - Uint16 pitch; /* Read-only */ - void *pixels; /* Read-write */ - int offset; /* Private */ - - /* Hardware-specific surface info */ - struct private_hwdata *hwdata; - - /* clipping information */ - SDL_Rect clip_rect; /* Read-only */ - Uint32 unused1; /* for binary compatibility */ - - /* Allow recursive locks */ - Uint32 locked; /* Private */ - - /* info for fast blit mapping to other surfaces */ - struct SDL_BlitMap *map; /* Private */ - - /* format version, bumped at every change to invalidate blit maps */ - unsigned int format_version; /* Private */ - - /* Reference count -- used when freeing surface */ - int refcount; /* Read-mostly */ -} SDL_Surface; - -/* These are the currently supported flags for the SDL_surface */ -/* Available for SDL_CreateRGBSurface() or SDL_SetVideoMode() */ -#define SDL_SWSURFACE 0x00000000 /* Surface is in system memory */ -#define SDL_HWSURFACE 0x00000001 /* Surface is in video memory */ -#define SDL_ASYNCBLIT 0x00000004 /* Use asynchronous blits if possible */ -/* Available for SDL_SetVideoMode() */ -#define SDL_ANYFORMAT 0x10000000 /* Allow any video depth/pixel-format */ -#define SDL_HWPALETTE 0x20000000 /* Surface has exclusive palette */ -#define SDL_DOUBLEBUF 0x40000000 /* Set up double-buffered video mode */ -#define SDL_FULLSCREEN 0x80000000 /* Surface is a full screen display */ -#define SDL_OPENGL 0x00000002 /* Create an OpenGL rendering context */ -#define SDL_OPENGLBLIT 0x0000000A /* Create an OpenGL rendering context and use it for blitting */ -#define SDL_RESIZABLE 0x00000010 /* This video mode may be resized */ -#define SDL_NOFRAME 0x00000020 /* No window caption or edge frame */ -/* Used internally (read-only) */ -#define SDL_HWACCEL 0x00000100 /* Blit uses hardware acceleration */ -#define SDL_SRCCOLORKEY 0x00001000 /* Blit uses a source color key */ -#define SDL_RLEACCELOK 0x00002000 /* Private flag */ -#define SDL_RLEACCEL 0x00004000 /* Surface is RLE encoded */ -#define SDL_SRCALPHA 0x00010000 /* Blit uses source alpha blending */ -#define SDL_PREALLOC 0x01000000 /* Surface uses preallocated memory */ - -/* Evaluates to true if the surface needs to be locked before access */ -#define SDL_MUSTLOCK(surface) \ - (surface->offset || \ - ((surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_RLEACCEL)) != 0)) - -/* typedef for private surface blitting functions */ -typedef int (*SDL_blit)(struct SDL_Surface *src, SDL_Rect *srcrect, - struct SDL_Surface *dst, SDL_Rect *dstrect); - - -/* Useful for determining the video hardware capabilities */ -typedef struct SDL_VideoInfo { - Uint32 hw_available :1; /* Flag: Can you create hardware surfaces? */ - Uint32 wm_available :1; /* Flag: Can you talk to a window manager? */ - Uint32 UnusedBits1 :6; - Uint32 UnusedBits2 :1; - Uint32 blit_hw :1; /* Flag: Accelerated blits HW --> HW */ - Uint32 blit_hw_CC :1; /* Flag: Accelerated blits with Colorkey */ - Uint32 blit_hw_A :1; /* Flag: Accelerated blits with Alpha */ - Uint32 blit_sw :1; /* Flag: Accelerated blits SW --> HW */ - Uint32 blit_sw_CC :1; /* Flag: Accelerated blits with Colorkey */ - Uint32 blit_sw_A :1; /* Flag: Accelerated blits with Alpha */ - Uint32 blit_fill :1; /* Flag: Accelerated color fill */ - Uint32 UnusedBits3 :16; - Uint32 video_mem; /* The total amount of video memory (in K) */ - SDL_PixelFormat *vfmt; /* Value: The format of the video surface */ - int current_w; /* Value: The current video mode width */ - int current_h; /* Value: The current video mode height */ -} SDL_VideoInfo; - - -/* The most common video overlay formats. - For an explanation of these pixel formats, see: - http://www.webartz.com/fourcc/indexyuv.htm - - For information on the relationship between color spaces, see: - http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html - */ -#define SDL_YV12_OVERLAY 0x32315659 /* Planar mode: Y + V + U (3 planes) */ -#define SDL_IYUV_OVERLAY 0x56555949 /* Planar mode: Y + U + V (3 planes) */ -#define SDL_YUY2_OVERLAY 0x32595559 /* Packed mode: Y0+U0+Y1+V0 (1 plane) */ -#define SDL_UYVY_OVERLAY 0x59565955 /* Packed mode: U0+Y0+V0+Y1 (1 plane) */ -#define SDL_YVYU_OVERLAY 0x55595659 /* Packed mode: Y0+V0+Y1+U0 (1 plane) */ - -/* The YUV hardware video overlay */ -typedef struct SDL_Overlay { - Uint32 format; /* Read-only */ - int w, h; /* Read-only */ - int planes; /* Read-only */ - Uint16 *pitches; /* Read-only */ - Uint8 **pixels; /* Read-write */ - - /* Hardware-specific surface info */ - struct private_yuvhwfuncs *hwfuncs; - struct private_yuvhwdata *hwdata; - - /* Special flags */ - Uint32 hw_overlay :1; /* Flag: This overlay hardware accelerated? */ - Uint32 UnusedBits :31; -} SDL_Overlay; - - -/* Public enumeration for setting the OpenGL window attributes. */ -typedef enum { - SDL_GL_RED_SIZE, - SDL_GL_GREEN_SIZE, - SDL_GL_BLUE_SIZE, - SDL_GL_ALPHA_SIZE, - SDL_GL_BUFFER_SIZE, - SDL_GL_DOUBLEBUFFER, - SDL_GL_DEPTH_SIZE, - SDL_GL_STENCIL_SIZE, - SDL_GL_ACCUM_RED_SIZE, - SDL_GL_ACCUM_GREEN_SIZE, - SDL_GL_ACCUM_BLUE_SIZE, - SDL_GL_ACCUM_ALPHA_SIZE, - SDL_GL_STEREO, - SDL_GL_MULTISAMPLEBUFFERS, - SDL_GL_MULTISAMPLESAMPLES, - SDL_GL_ACCELERATED_VISUAL, - SDL_GL_SWAP_CONTROL -} SDL_GLattr; - -/* flags for SDL_SetPalette() */ -#define SDL_LOGPAL 0x01 -#define SDL_PHYSPAL 0x02 - -/* Function prototypes */ - -/* These functions are used internally, and should not be used unless you - * have a specific need to specify the video driver you want to use. - * You should normally use SDL_Init() or SDL_InitSubSystem(). - * - * SDL_VideoInit() initializes the video subsystem -- sets up a connection - * to the window manager, etc, and determines the current video mode and - * pixel format, but does not initialize a window or graphics mode. - * Note that event handling is activated by this routine. - * - * If you use both sound and video in your application, you need to call - * SDL_Init() before opening the sound device, otherwise under Win32 DirectX, - * you won't be able to set full-screen display modes. - */ -extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name, Uint32 flags); -extern DECLSPEC void SDLCALL SDL_VideoQuit(void); - -/* This function fills the given character buffer with the name of the - * video driver, and returns a pointer to it if the video driver has - * been initialized. It returns NULL if no driver has been initialized. - */ -extern DECLSPEC char * SDLCALL SDL_VideoDriverName(char *namebuf, int maxlen); - -/* - * This function returns a pointer to the current display surface. - * If SDL is doing format conversion on the display surface, this - * function returns the publicly visible surface, not the real video - * surface. - */ -extern DECLSPEC SDL_Surface * SDLCALL SDL_GetVideoSurface(void); - -/* - * This function returns a read-only pointer to information about the - * video hardware. If this is called before SDL_SetVideoMode(), the 'vfmt' - * member of the returned structure will contain the pixel format of the - * "best" video mode. - */ -extern DECLSPEC const SDL_VideoInfo * SDLCALL SDL_GetVideoInfo(void); - -/* - * Check to see if a particular video mode is supported. - * It returns 0 if the requested mode is not supported under any bit depth, - * or returns the bits-per-pixel of the closest available mode with the - * given width and height. If this bits-per-pixel is different from the - * one used when setting the video mode, SDL_SetVideoMode() will succeed, - * but will emulate the requested bits-per-pixel with a shadow surface. - * - * The arguments to SDL_VideoModeOK() are the same ones you would pass to - * SDL_SetVideoMode() - */ -extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags); - -/* - * Return a pointer to an array of available screen dimensions for the - * given format and video flags, sorted largest to smallest. Returns - * NULL if there are no dimensions available for a particular format, - * or (SDL_Rect **)-1 if any dimension is okay for the given format. - * - * If 'format' is NULL, the mode list will be for the format given - * by SDL_GetVideoInfo()->vfmt - */ -extern DECLSPEC SDL_Rect ** SDLCALL SDL_ListModes(SDL_PixelFormat *format, Uint32 flags); - -/* - * Set up a video mode with the specified width, height and bits-per-pixel. - * - * If 'bpp' is 0, it is treated as the current display bits per pixel. - * - * If SDL_ANYFORMAT is set in 'flags', the SDL library will try to set the - * requested bits-per-pixel, but will return whatever video pixel format is - * available. The default is to emulate the requested pixel format if it - * is not natively available. - * - * If SDL_HWSURFACE is set in 'flags', the video surface will be placed in - * video memory, if possible, and you may have to call SDL_LockSurface() - * in order to access the raw framebuffer. Otherwise, the video surface - * will be created in system memory. - * - * If SDL_ASYNCBLIT is set in 'flags', SDL will try to perform rectangle - * updates asynchronously, but you must always lock before accessing pixels. - * SDL will wait for updates to complete before returning from the lock. - * - * If SDL_HWPALETTE is set in 'flags', the SDL library will guarantee - * that the colors set by SDL_SetColors() will be the colors you get. - * Otherwise, in 8-bit mode, SDL_SetColors() may not be able to set all - * of the colors exactly the way they are requested, and you should look - * at the video surface structure to determine the actual palette. - * If SDL cannot guarantee that the colors you request can be set, - * i.e. if the colormap is shared, then the video surface may be created - * under emulation in system memory, overriding the SDL_HWSURFACE flag. - * - * If SDL_FULLSCREEN is set in 'flags', the SDL library will try to set - * a fullscreen video mode. The default is to create a windowed mode - * if the current graphics system has a window manager. - * If the SDL library is able to set a fullscreen video mode, this flag - * will be set in the surface that is returned. - * - * If SDL_DOUBLEBUF is set in 'flags', the SDL library will try to set up - * two surfaces in video memory and swap between them when you call - * SDL_Flip(). This is usually slower than the normal single-buffering - * scheme, but prevents "tearing" artifacts caused by modifying video - * memory while the monitor is refreshing. It should only be used by - * applications that redraw the entire screen on every update. - * - * If SDL_RESIZABLE is set in 'flags', the SDL library will allow the - * window manager, if any, to resize the window at runtime. When this - * occurs, SDL will send a SDL_VIDEORESIZE event to you application, - * and you must respond to the event by re-calling SDL_SetVideoMode() - * with the requested size (or another size that suits the application). - * - * If SDL_NOFRAME is set in 'flags', the SDL library will create a window - * without any title bar or frame decoration. Fullscreen video modes have - * this flag set automatically. - * - * This function returns the video framebuffer surface, or NULL if it fails. - * - * If you rely on functionality provided by certain video flags, check the - * flags of the returned surface to make sure that functionality is available. - * SDL will fall back to reduced functionality if the exact flags you wanted - * are not available. - */ -extern DECLSPEC SDL_Surface * SDLCALL SDL_SetVideoMode - (int width, int height, int bpp, Uint32 flags); - -/* - * Makes sure the given list of rectangles is updated on the given screen. - * If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire - * screen. - * These functions should not be called while 'screen' is locked. - */ -extern DECLSPEC void SDLCALL SDL_UpdateRects - (SDL_Surface *screen, int numrects, SDL_Rect *rects); -extern DECLSPEC void SDLCALL SDL_UpdateRect - (SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h); - -/* - * On hardware that supports double-buffering, this function sets up a flip - * and returns. The hardware will wait for vertical retrace, and then swap - * video buffers before the next video surface blit or lock will return. - * On hardware that doesn not support double-buffering, this is equivalent - * to calling SDL_UpdateRect(screen, 0, 0, 0, 0); - * The SDL_DOUBLEBUF flag must have been passed to SDL_SetVideoMode() when - * setting the video mode for this function to perform hardware flipping. - * This function returns 0 if successful, or -1 if there was an error. - */ -extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface *screen); - -/* - * Set the gamma correction for each of the color channels. - * The gamma values range (approximately) between 0.1 and 10.0 - * - * If this function isn't supported directly by the hardware, it will - * be emulated using gamma ramps, if available. If successful, this - * function returns 0, otherwise it returns -1. - */ -extern DECLSPEC int SDLCALL SDL_SetGamma(float red, float green, float blue); - -/* - * Set the gamma translation table for the red, green, and blue channels - * of the video hardware. Each table is an array of 256 16-bit quantities, - * representing a mapping between the input and output for that channel. - * The input is the index into the array, and the output is the 16-bit - * gamma value at that index, scaled to the output color precision. - * - * You may pass NULL for any of the channels to leave it unchanged. - * If the call succeeds, it will return 0. If the display driver or - * hardware does not support gamma translation, or otherwise fails, - * this function will return -1. - */ -extern DECLSPEC int SDLCALL SDL_SetGammaRamp(const Uint16 *red, const Uint16 *green, const Uint16 *blue); - -/* - * Retrieve the current values of the gamma translation tables. - * - * You must pass in valid pointers to arrays of 256 16-bit quantities. - * Any of the pointers may be NULL to ignore that channel. - * If the call succeeds, it will return 0. If the display driver or - * hardware does not support gamma translation, or otherwise fails, - * this function will return -1. - */ -extern DECLSPEC int SDLCALL SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue); - -/* - * Sets a portion of the colormap for the given 8-bit surface. If 'surface' - * is not a palettized surface, this function does nothing, returning 0. - * If all of the colors were set as passed to SDL_SetColors(), it will - * return 1. If not all the color entries were set exactly as given, - * it will return 0, and you should look at the surface palette to - * determine the actual color palette. - * - * When 'surface' is the surface associated with the current display, the - * display colormap will be updated with the requested colors. If - * SDL_HWPALETTE was set in SDL_SetVideoMode() flags, SDL_SetColors() - * will always return 1, and the palette is guaranteed to be set the way - * you desire, even if the window colormap has to be warped or run under - * emulation. - */ -extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface *surface, - SDL_Color *colors, int firstcolor, int ncolors); - -/* - * Sets a portion of the colormap for a given 8-bit surface. - * 'flags' is one or both of: - * SDL_LOGPAL -- set logical palette, which controls how blits are mapped - * to/from the surface, - * SDL_PHYSPAL -- set physical palette, which controls how pixels look on - * the screen - * Only screens have physical palettes. Separate change of physical/logical - * palettes is only possible if the screen has SDL_HWPALETTE set. - * - * The return value is 1 if all colours could be set as requested, and 0 - * otherwise. - * - * SDL_SetColors() is equivalent to calling this function with - * flags = (SDL_LOGPAL|SDL_PHYSPAL). - */ -extern DECLSPEC int SDLCALL SDL_SetPalette(SDL_Surface *surface, int flags, - SDL_Color *colors, int firstcolor, - int ncolors); - -/* - * Maps an RGB triple to an opaque pixel value for a given pixel format - */ -extern DECLSPEC Uint32 SDLCALL SDL_MapRGB -(const SDL_PixelFormat * const format, - const Uint8 r, const Uint8 g, const Uint8 b); - -/* - * Maps an RGBA quadruple to a pixel value for a given pixel format - */ -extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA -(const SDL_PixelFormat * const format, - const Uint8 r, const Uint8 g, const Uint8 b, const Uint8 a); - -/* - * Maps a pixel value into the RGB components for a given pixel format - */ -extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, SDL_PixelFormat *fmt, - Uint8 *r, Uint8 *g, Uint8 *b); - -/* - * Maps a pixel value into the RGBA components for a given pixel format - */ -extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, SDL_PixelFormat *fmt, - Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a); - -/* - * Allocate and free an RGB surface (must be called after SDL_SetVideoMode) - * If the depth is 4 or 8 bits, an empty palette is allocated for the surface. - * If the depth is greater than 8 bits, the pixel format is set using the - * flags '[RGB]mask'. - * If the function runs out of memory, it will return NULL. - * - * The 'flags' tell what kind of surface to create. - * SDL_SWSURFACE means that the surface should be created in system memory. - * SDL_HWSURFACE means that the surface should be created in video memory, - * with the same format as the display surface. This is useful for surfaces - * that will not change much, to take advantage of hardware acceleration - * when being blitted to the display surface. - * SDL_ASYNCBLIT means that SDL will try to perform asynchronous blits with - * this surface, but you must always lock it before accessing the pixels. - * SDL will wait for current blits to finish before returning from the lock. - * SDL_SRCCOLORKEY indicates that the surface will be used for colorkey blits. - * If the hardware supports acceleration of colorkey blits between - * two surfaces in video memory, SDL will try to place the surface in - * video memory. If this isn't possible or if there is no hardware - * acceleration available, the surface will be placed in system memory. - * SDL_SRCALPHA means that the surface will be used for alpha blits and - * if the hardware supports hardware acceleration of alpha blits between - * two surfaces in video memory, to place the surface in video memory - * if possible, otherwise it will be placed in system memory. - * If the surface is created in video memory, blits will be _much_ faster, - * but the surface format must be identical to the video surface format, - * and the only way to access the pixels member of the surface is to use - * the SDL_LockSurface() and SDL_UnlockSurface() calls. - * If the requested surface actually resides in video memory, SDL_HWSURFACE - * will be set in the flags member of the returned surface. If for some - * reason the surface could not be placed in video memory, it will not have - * the SDL_HWSURFACE flag set, and will be created in system memory instead. - */ -#define SDL_AllocSurface SDL_CreateRGBSurface -extern DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurface - (Uint32 flags, int width, int height, int depth, - Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); -extern DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, - int width, int height, int depth, int pitch, - Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); -extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface *surface); - -/* - * SDL_LockSurface() sets up a surface for directly accessing the pixels. - * Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write - * to and read from 'surface->pixels', using the pixel format stored in - * 'surface->format'. Once you are done accessing the surface, you should - * use SDL_UnlockSurface() to release it. - * - * Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates - * to 0, then you can read and write to the surface at any time, and the - * pixel format of the surface will not change. In particular, if the - * SDL_HWSURFACE flag is not given when calling SDL_SetVideoMode(), you - * will not need to lock the display surface before accessing it. - * - * No operating system or library calls should be made between lock/unlock - * pairs, as critical system locks may be held during this time. - * - * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked. - */ -extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface *surface); -extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface); - -/* - * Load a surface from a seekable SDL data source (memory or file.) - * If 'freesrc' is non-zero, the source will be closed after being read. - * Returns the new surface, or NULL if there was an error. - * The new surface should be freed with SDL_FreeSurface(). - */ -extern DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP_RW(SDL_RWops *src, int freesrc); - -/* Convenience macro -- load a surface from a file */ -#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1) - -/* - * Save a surface to a seekable SDL data source (memory or file.) - * If 'freedst' is non-zero, the source will be closed after being written. - * Returns 0 if successful or -1 if there was an error. - */ -extern DECLSPEC int SDLCALL SDL_SaveBMP_RW - (SDL_Surface *surface, SDL_RWops *dst, int freedst); - -/* Convenience macro -- save a surface to a file */ -#define SDL_SaveBMP(surface, file) \ - SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1) - -/* - * Sets the color key (transparent pixel) in a blittable surface. - * If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL), - * 'key' will be the transparent pixel in the source image of a blit. - * SDL_RLEACCEL requests RLE acceleration for the surface if present, - * and removes RLE acceleration if absent. - * If 'flag' is 0, this function clears any current color key. - * This function returns 0, or -1 if there was an error. - */ -extern DECLSPEC int SDLCALL SDL_SetColorKey - (SDL_Surface *surface, Uint32 flag, Uint32 key); - -/* - * This function sets the alpha value for the entire surface, as opposed to - * using the alpha component of each pixel. This value measures the range - * of transparency of the surface, 0 being completely transparent to 255 - * being completely opaque. An 'alpha' value of 255 causes blits to be - * opaque, the source pixels copied to the destination (the default). Note - * that per-surface alpha can be combined with colorkey transparency. - * - * If 'flag' is 0, alpha blending is disabled for the surface. - * If 'flag' is SDL_SRCALPHA, alpha blending is enabled for the surface. - * OR:ing the flag with SDL_RLEACCEL requests RLE acceleration for the - * surface; if SDL_RLEACCEL is not specified, the RLE accel will be removed. - * - * The 'alpha' parameter is ignored for surfaces that have an alpha channel. - */ -extern DECLSPEC int SDLCALL SDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha); - -/* - * Sets the clipping rectangle for the destination surface in a blit. - * - * If the clip rectangle is NULL, clipping will be disabled. - * If the clip rectangle doesn't intersect the surface, the function will - * return SDL_FALSE and blits will be completely clipped. Otherwise the - * function returns SDL_TRUE and blits to the surface will be clipped to - * the intersection of the surface area and the clipping rectangle. - * - * Note that blits are automatically clipped to the edges of the source - * and destination surfaces. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect); - -/* - * Gets the clipping rectangle for the destination surface in a blit. - * 'rect' must be a pointer to a valid rectangle which will be filled - * with the correct values. - */ -extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect); - -/* - * Creates a new surface of the specified format, and then copies and maps - * the given surface to it so the blit of the converted surface will be as - * fast as possible. If this function fails, it returns NULL. - * - * The 'flags' parameter is passed to SDL_CreateRGBSurface() and has those - * semantics. You can also pass SDL_RLEACCEL in the flags parameter and - * SDL will try to RLE accelerate colorkey and alpha blits in the resulting - * surface. - * - * This function is used internally by SDL_DisplayFormat(). - */ -extern DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface - (SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags); - -/* - * This performs a fast blit from the source surface to the destination - * surface. It assumes that the source and destination rectangles are - * the same size. If either 'srcrect' or 'dstrect' are NULL, the entire - * surface (src or dst) is copied. The final blit rectangles are saved - * in 'srcrect' and 'dstrect' after all clipping is performed. - * If the blit is successful, it returns 0, otherwise it returns -1. - * - * The blit function should not be called on a locked surface. - * - * The blit semantics for surfaces with and without alpha and colorkey - * are defined as follows: - * - * RGBA->RGB: - * SDL_SRCALPHA set: - * alpha-blend (using alpha-channel). - * SDL_SRCCOLORKEY ignored. - * SDL_SRCALPHA not set: - * copy RGB. - * if SDL_SRCCOLORKEY set, only copy the pixels matching the - * RGB values of the source colour key, ignoring alpha in the - * comparison. - * - * RGB->RGBA: - * SDL_SRCALPHA set: - * alpha-blend (using the source per-surface alpha value); - * set destination alpha to opaque. - * SDL_SRCALPHA not set: - * copy RGB, set destination alpha to source per-surface alpha value. - * both: - * if SDL_SRCCOLORKEY set, only copy the pixels matching the - * source colour key. - * - * RGBA->RGBA: - * SDL_SRCALPHA set: - * alpha-blend (using the source alpha channel) the RGB values; - * leave destination alpha untouched. [Note: is this correct?] - * SDL_SRCCOLORKEY ignored. - * SDL_SRCALPHA not set: - * copy all of RGBA to the destination. - * if SDL_SRCCOLORKEY set, only copy the pixels matching the - * RGB values of the source colour key, ignoring alpha in the - * comparison. - * - * RGB->RGB: - * SDL_SRCALPHA set: - * alpha-blend (using the source per-surface alpha value). - * SDL_SRCALPHA not set: - * copy RGB. - * both: - * if SDL_SRCCOLORKEY set, only copy the pixels matching the - * source colour key. - * - * If either of the surfaces were in video memory, and the blit returns -2, - * the video memory was lost, so it should be reloaded with artwork and - * re-blitted: - while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) { - while ( SDL_LockSurface(image) < 0 ) - Sleep(10); - -- Write image pixels to image->pixels -- - SDL_UnlockSurface(image); - } - * This happens under DirectX 5.0 when the system switches away from your - * fullscreen application. The lock will also fail until you have access - * to the video memory again. - */ -/* You should call SDL_BlitSurface() unless you know exactly how SDL - blitting works internally and how to use the other blit functions. -*/ -#define SDL_BlitSurface SDL_UpperBlit - -/* This is the public blit function, SDL_BlitSurface(), and it performs - rectangle validation and clipping before passing it to SDL_LowerBlit() -*/ -extern DECLSPEC int SDLCALL SDL_UpperBlit - (SDL_Surface *src, SDL_Rect *srcrect, - SDL_Surface *dst, SDL_Rect *dstrect); -/* This is a semi-private blit function and it performs low-level surface - blitting only. -*/ -extern DECLSPEC int SDLCALL SDL_LowerBlit - (SDL_Surface *src, SDL_Rect *srcrect, - SDL_Surface *dst, SDL_Rect *dstrect); - -/* - * This function performs a fast fill of the given rectangle with 'color' - * The given rectangle is clipped to the destination surface clip area - * and the final fill rectangle is saved in the passed in pointer. - * If 'dstrect' is NULL, the whole surface will be filled with 'color' - * The color should be a pixel of the format used by the surface, and - * can be generated by the SDL_MapRGB() function. - * This function returns 0 on success, or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_FillRect - (SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color); - -/* - * This function takes a surface and copies it to a new surface of the - * pixel format and colors of the video framebuffer, suitable for fast - * blitting onto the display surface. It calls SDL_ConvertSurface() - * - * If you want to take advantage of hardware colorkey or alpha blit - * acceleration, you should set the colorkey and alpha value before - * calling this function. - * - * If the conversion fails or runs out of memory, it returns NULL - */ -extern DECLSPEC SDL_Surface * SDLCALL SDL_DisplayFormat(SDL_Surface *surface); - -/* - * This function takes a surface and copies it to a new surface of the - * pixel format and colors of the video framebuffer (if possible), - * suitable for fast alpha blitting onto the display surface. - * The new surface will always have an alpha channel. - * - * If you want to take advantage of hardware colorkey or alpha blit - * acceleration, you should set the colorkey and alpha value before - * calling this function. - * - * If the conversion fails or runs out of memory, it returns NULL - */ -extern DECLSPEC SDL_Surface * SDLCALL SDL_DisplayFormatAlpha(SDL_Surface *surface); - - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* YUV video surface overlay functions */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* This function creates a video output overlay - Calling the returned surface an overlay is something of a misnomer because - the contents of the display surface underneath the area where the overlay - is shown is undefined - it may be overwritten with the converted YUV data. -*/ -extern DECLSPEC SDL_Overlay * SDLCALL SDL_CreateYUVOverlay(int width, int height, - Uint32 format, SDL_Surface *display); - -/* Lock an overlay for direct access, and unlock it when you are done */ -extern DECLSPEC int SDLCALL SDL_LockYUVOverlay(SDL_Overlay *overlay); -extern DECLSPEC void SDLCALL SDL_UnlockYUVOverlay(SDL_Overlay *overlay); - -/* Blit a video overlay to the display surface. - The contents of the video surface underneath the blit destination are - not defined. - The width and height of the destination rectangle may be different from - that of the overlay, but currently only 2x scaling is supported. -*/ -extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect); - -/* Free a video overlay */ -extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay *overlay); - - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* OpenGL support functions. */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Dynamically load an OpenGL library, or the default one if path is NULL - * - * If you do this, you need to retrieve all of the GL functions used in - * your program from the dynamic library using SDL_GL_GetProcAddress(). - */ -extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path); - -/* - * Get the address of a GL function - */ -extern DECLSPEC void * SDLCALL SDL_GL_GetProcAddress(const char* proc); - -/* - * Set an attribute of the OpenGL subsystem before intialization. - */ -extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value); - -/* - * Get an attribute of the OpenGL subsystem from the windowing - * interface, such as glX. This is of course different from getting - * the values from SDL's internal OpenGL subsystem, which only - * stores the values you request before initialization. - * - * Developers should track the values they pass into SDL_GL_SetAttribute - * themselves if they want to retrieve these values. - */ -extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int* value); - -/* - * Swap the OpenGL buffers, if double-buffering is supported. - */ -extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void); - -/* - * Internal functions that should not be called unless you have read - * and understood the source code for these functions. - */ -extern DECLSPEC void SDLCALL SDL_GL_UpdateRects(int numrects, SDL_Rect* rects); -extern DECLSPEC void SDLCALL SDL_GL_Lock(void); -extern DECLSPEC void SDLCALL SDL_GL_Unlock(void); - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* These functions allow interaction with the window manager, if any. */ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Sets/Gets the title and icon text of the display window (UTF-8 encoded) - */ -extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title, const char *icon); -extern DECLSPEC void SDLCALL SDL_WM_GetCaption(char **title, char **icon); - -/* - * Sets the icon for the display window. - * This function must be called before the first call to SDL_SetVideoMode(). - * It takes an icon surface, and a mask in MSB format. - * If 'mask' is NULL, the entire icon surface will be used as the icon. - */ -extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask); - -/* - * This function iconifies the window, and returns 1 if it succeeded. - * If the function succeeds, it generates an SDL_APPACTIVE loss event. - * This function is a noop and returns 0 in non-windowed environments. - */ -extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void); - -/* - * Toggle fullscreen mode without changing the contents of the screen. - * If the display surface does not require locking before accessing - * the pixel information, then the memory pointers will not change. - * - * If this function was able to toggle fullscreen mode (change from - * running in a window to fullscreen, or vice-versa), it will return 1. - * If it is not implemented, or fails, it returns 0. - * - * The next call to SDL_SetVideoMode() will set the mode fullscreen - * attribute based on the flags parameter - if SDL_FULLSCREEN is not - * set, then the display will be windowed by default where supported. - * - * This is currently only implemented in the X11 video driver. - */ -extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen(SDL_Surface *surface); - -/* - * This function allows you to set and query the input grab state of - * the application. It returns the new input grab state. - */ -typedef enum { - SDL_GRAB_QUERY = -1, - SDL_GRAB_OFF = 0, - SDL_GRAB_ON = 1, - SDL_GRAB_FULLSCREEN /* Used internally */ -} SDL_GrabMode; -/* - * Grabbing means that the mouse is confined to the application window, - * and nearly all keyboard input is passed directly to the application, - * and not interpreted by a window manager, if any. - */ -extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode); - -/* Not in public API at the moment - do not use! */ -extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface *src, SDL_Rect *srcrect, - SDL_Surface *dst, SDL_Rect *dstrect); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_video_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/begin_code.h spring-98.0~14.04~ppa6/include/SDL2/begin_code.h --- spring-96.0~14.04~ppa4/include/SDL2/begin_code.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/begin_code.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,140 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file begin_code.h + * + * This file sets things up for C dynamic library function definitions, + * static inlined functions, and structures aligned at 4-byte alignment. + * If you don't like ugly C preprocessor code, don't look at this file. :) + */ + +/* This shouldn't be nested -- included it around code only. */ +#ifdef _begin_code_h +#error Nested inclusion of begin_code.h +#endif +#define _begin_code_h + +#ifndef SDL_DEPRECATED +# if (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */ +# define SDL_DEPRECATED __attribute__((deprecated)) +# else +# define SDL_DEPRECATED +# endif +#endif + +/* Some compilers use a special export keyword */ +#ifndef DECLSPEC +# if defined(__WIN32__) +# ifdef __BORLANDC__ +# ifdef BUILD_SDL +# define DECLSPEC +# else +# define DECLSPEC __declspec(dllimport) +# endif +# else +# define DECLSPEC __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && __GNUC__ >= 4 +# define DECLSPEC __attribute__ ((visibility("default"))) +# elif defined(__GNUC__) && __GNUC__ >= 2 +# define DECLSPEC __declspec(dllexport) +# else +# define DECLSPEC +# endif +# endif +#endif + +/* By default SDL uses the C calling convention */ +#ifndef SDLCALL +#if defined(__WIN32__) && !defined(__GNUC__) +#define SDLCALL __cdecl +#else +#define SDLCALL +#endif +#endif /* SDLCALL */ + +/* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */ +#ifdef __SYMBIAN32__ +#undef DECLSPEC +#define DECLSPEC +#endif /* __SYMBIAN32__ */ + +/* Force structure packing at 4 byte alignment. + This is necessary if the header is included in code which has structure + packing set to an alternate value, say for loading structures from disk. + The packing is reset to the previous value in close_code.h + */ +#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) +#ifdef _MSC_VER +#pragma warning(disable: 4103) +#endif +#ifdef __BORLANDC__ +#pragma nopackwarning +#endif +#ifdef _M_X64 +/* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */ +#pragma pack(push,8) +#else +#pragma pack(push,4) +#endif +#endif /* Compiler needs structure packing set */ + +#ifndef SDL_INLINE +#if defined(__GNUC__) +#define SDL_INLINE __inline__ +#elif defined(_MSC_VER) || defined(__BORLANDC__) || \ + defined(__DMC__) || defined(__SC__) || \ + defined(__WATCOMC__) || defined(__LCC__) || \ + defined(__DECC) +#define SDL_INLINE __inline +#ifndef __inline__ +#define __inline__ __inline +#endif +#else +#define SDL_INLINE inline +#ifndef __inline__ +#define __inline__ inline +#endif +#endif +#endif /* SDL_INLINE not defined */ + +#ifndef SDL_FORCE_INLINE +#if defined(_MSC_VER) +#define SDL_FORCE_INLINE __forceinline +#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) +#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__ +#else +#define SDL_FORCE_INLINE static SDL_INLINE +#endif +#endif /* SDL_FORCE_INLINE not defined */ + +/* Apparently this is needed by several Windows compilers */ +#if !defined(__MACH__) +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else +#define NULL ((void *)0) +#endif +#endif /* NULL */ +#endif /* ! Mac OS X - breaks precompiled headers */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/close_code.h spring-98.0~14.04~ppa6/include/SDL2/close_code.h --- spring-96.0~14.04~ppa4/include/SDL2/close_code.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/close_code.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,37 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file close_code.h + * + * This file reverses the effects of begin_code.h and should be included + * after you finish any function and structure declarations in your headers + */ + +#undef _begin_code_h + +/* Reset structure packing at previous byte alignment */ +#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__) +#ifdef __BORLANDC__ +#pragma nopackwarning +#endif +#pragma pack(pop) +#endif /* Compiler needs structure packing set */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_assert.h spring-98.0~14.04~ppa6/include/SDL2/SDL_assert.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_assert.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_assert.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,246 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_assert_h +#define _SDL_assert_h + +#include "SDL_config.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef SDL_ASSERT_LEVEL +#ifdef SDL_DEFAULT_ASSERT_LEVEL +#define SDL_ASSERT_LEVEL SDL_DEFAULT_ASSERT_LEVEL +#elif defined(_DEBUG) || defined(DEBUG) || \ + (defined(__GNUC__) && !defined(__OPTIMIZE__)) +#define SDL_ASSERT_LEVEL 2 +#else +#define SDL_ASSERT_LEVEL 1 +#endif +#endif /* SDL_ASSERT_LEVEL */ + +/* +These are macros and not first class functions so that the debugger breaks +on the assertion line and not in some random guts of SDL, and so each +assert can have unique static variables associated with it. +*/ + +#if defined(_MSC_VER) +/* Don't include intrin.h here because it contains C++ code */ + extern void __cdecl __debugbreak(void); + #define SDL_TriggerBreakpoint() __debugbreak() +#elif (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) + #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" ) +#elif defined(HAVE_SIGNAL_H) + #include + #define SDL_TriggerBreakpoint() raise(SIGTRAP) +#else + /* How do we trigger breakpoints on this platform? */ + #define SDL_TriggerBreakpoint() +#endif + +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */ +# define SDL_FUNCTION __func__ +#elif ((__GNUC__ >= 2) || defined(_MSC_VER)) +# define SDL_FUNCTION __FUNCTION__ +#else +# define SDL_FUNCTION "???" +#endif +#define SDL_FILE __FILE__ +#define SDL_LINE __LINE__ + +/* +sizeof (x) makes the compiler still parse the expression even without +assertions enabled, so the code is always checked at compile time, but +doesn't actually generate code for it, so there are no side effects or +expensive checks at run time, just the constant size of what x WOULD be, +which presumably gets optimized out as unused. +This also solves the problem of... + + int somevalue = blah(); + SDL_assert(somevalue == 1); + +...which would cause compiles to complain that somevalue is unused if we +disable assertions. +*/ + +#ifdef _MSC_VER /* stupid /W4 warnings. */ +#define SDL_NULL_WHILE_LOOP_CONDITION (-1 == __LINE__) +#else +#define SDL_NULL_WHILE_LOOP_CONDITION (0) +#endif + +#define SDL_disabled_assert(condition) \ + do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION) + +typedef enum +{ + SDL_ASSERTION_RETRY, /**< Retry the assert immediately. */ + SDL_ASSERTION_BREAK, /**< Make the debugger trigger a breakpoint. */ + SDL_ASSERTION_ABORT, /**< Terminate the program. */ + SDL_ASSERTION_IGNORE, /**< Ignore the assert. */ + SDL_ASSERTION_ALWAYS_IGNORE /**< Ignore the assert from now on. */ +} SDL_assert_state; + +typedef struct SDL_assert_data +{ + int always_ignore; + unsigned int trigger_count; + const char *condition; + const char *filename; + int linenum; + const char *function; + const struct SDL_assert_data *next; +} SDL_assert_data; + +#if (SDL_ASSERT_LEVEL > 0) + +/* Never call this directly. Use the SDL_assert* macros. */ +extern DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *, + const char *, + const char *, int); + +/* the do {} while(0) avoids dangling else problems: + if (x) SDL_assert(y); else blah(); + ... without the do/while, the "else" could attach to this macro's "if". + We try to handle just the minimum we need here in a macro...the loop, + the static vars, and break points. The heavy lifting is handled in + SDL_ReportAssertion(), in SDL_assert.c. +*/ +#define SDL_enabled_assert(condition) \ + do { \ + while ( !(condition) ) { \ + static struct SDL_assert_data assert_data = { \ + 0, 0, #condition, 0, 0, 0, 0 \ + }; \ + const SDL_assert_state state = SDL_ReportAssertion(&assert_data, \ + SDL_FUNCTION, \ + SDL_FILE, \ + SDL_LINE); \ + if (state == SDL_ASSERTION_RETRY) { \ + continue; /* go again. */ \ + } else if (state == SDL_ASSERTION_BREAK) { \ + SDL_TriggerBreakpoint(); \ + } \ + break; /* not retrying. */ \ + } \ + } while (SDL_NULL_WHILE_LOOP_CONDITION) + +#endif /* enabled assertions support code */ + +/* Enable various levels of assertions. */ +#if SDL_ASSERT_LEVEL == 0 /* assertions disabled */ +# define SDL_assert(condition) SDL_disabled_assert(condition) +# define SDL_assert_release(condition) SDL_disabled_assert(condition) +# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) +#elif SDL_ASSERT_LEVEL == 1 /* release settings. */ +# define SDL_assert(condition) SDL_disabled_assert(condition) +# define SDL_assert_release(condition) SDL_enabled_assert(condition) +# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) +#elif SDL_ASSERT_LEVEL == 2 /* normal settings. */ +# define SDL_assert(condition) SDL_enabled_assert(condition) +# define SDL_assert_release(condition) SDL_enabled_assert(condition) +# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) +#elif SDL_ASSERT_LEVEL == 3 /* paranoid settings. */ +# define SDL_assert(condition) SDL_enabled_assert(condition) +# define SDL_assert_release(condition) SDL_enabled_assert(condition) +# define SDL_assert_paranoid(condition) SDL_enabled_assert(condition) +#else +# error Unknown assertion level. +#endif + +/* this assertion is never disabled at any level. */ +#define SDL_assert_always(condition) SDL_enabled_assert(condition) + + +typedef SDL_assert_state (SDLCALL *SDL_AssertionHandler)( + const SDL_assert_data* data, void* userdata); + +/** + * \brief Set an application-defined assertion handler. + * + * This allows an app to show its own assertion UI and/or force the + * response to an assertion failure. If the app doesn't provide this, SDL + * will try to do the right thing, popping up a system-specific GUI dialog, + * and probably minimizing any fullscreen windows. + * + * This callback may fire from any thread, but it runs wrapped in a mutex, so + * it will only fire from one thread at a time. + * + * Setting the callback to NULL restores SDL's original internal handler. + * + * This callback is NOT reset to SDL's internal handler upon SDL_Quit()! + * + * \return SDL_assert_state value of how to handle the assertion failure. + * + * \param handler Callback function, called when an assertion fails. + * \param userdata A pointer passed to the callback as-is. + */ +extern DECLSPEC void SDLCALL SDL_SetAssertionHandler( + SDL_AssertionHandler handler, + void *userdata); + +/** + * \brief Get a list of all assertion failures. + * + * Get all assertions triggered since last call to SDL_ResetAssertionReport(), + * or the start of the program. + * + * The proper way to examine this data looks something like this: + * + * + * const SDL_assert_data *item = SDL_GetAssertionReport(); + * while (item) { + * printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n", + * item->condition, item->function, item->filename, + * item->linenum, item->trigger_count, + * item->always_ignore ? "yes" : "no"); + * item = item->next; + * } + * + * + * \return List of all assertions. + * \sa SDL_ResetAssertionReport + */ +extern DECLSPEC const SDL_assert_data * SDLCALL SDL_GetAssertionReport(void); + +/** + * \brief Reset the list of all assertion failures. + * + * Reset list of all assertions triggered. + * + * \sa SDL_GetAssertionReport + */ +extern DECLSPEC void SDLCALL SDL_ResetAssertionReport(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_assert_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_atomic.h spring-98.0~14.04~ppa6/include/SDL2/SDL_atomic.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_atomic.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_atomic.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,359 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_atomic.h + * + * Atomic operations. + * + * IMPORTANT: + * If you are not an expert in concurrent lockless programming, you should + * only be using the atomic lock and reference counting functions in this + * file. In all other cases you should be protecting your data structures + * with full mutexes. + * + * The list of "safe" functions to use are: + * SDL_AtomicLock() + * SDL_AtomicUnlock() + * SDL_AtomicIncRef() + * SDL_AtomicDecRef() + * + * Seriously, here be dragons! + * ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + * + * You can find out a little more about lockless programming and the + * subtle issues that can arise here: + * http://msdn.microsoft.com/en-us/library/ee418650%28v=vs.85%29.aspx + * + * There's also lots of good information here: + * http://www.1024cores.net/home/lock-free-algorithms + * http://preshing.com/ + * + * These operations may or may not actually be implemented using + * processor specific atomic operations. When possible they are + * implemented as true processor specific atomic operations. When that + * is not possible the are implemented using locks that *do* use the + * available atomic operations. + * + * All of the atomic operations that modify memory are full memory barriers. + */ + +#ifndef _SDL_atomic_h_ +#define _SDL_atomic_h_ + +#include "SDL_stdinc.h" +#include "SDL_platform.h" + +#include "begin_code.h" + +/* Need to do this here because intrin.h has C++ code in it */ +/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */ +#if defined(_MSC_VER) && (_MSC_VER >= 1500) +#include +#define HAVE_MSC_ATOMICS 1 +#endif + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \name SDL AtomicLock + * + * The atomic locks are efficient spinlocks using CPU instructions, + * but are vulnerable to starvation and can spin forever if a thread + * holding a lock has been terminated. For this reason you should + * minimize the code executed inside an atomic lock and never do + * expensive things like API or system calls while holding them. + * + * The atomic locks are not safe to lock recursively. + * + * Porting Note: + * The spin lock functions and type are required and can not be + * emulated because they are used in the atomic emulation code. + */ +/* @{ */ + +typedef int SDL_SpinLock; + +/** + * \brief Try to lock a spin lock by setting it to a non-zero value. + * + * \param lock Points to the lock. + * + * \return SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already held. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTryLock(SDL_SpinLock *lock); + +/** + * \brief Lock a spin lock by setting it to a non-zero value. + * + * \param lock Points to the lock. + */ +extern DECLSPEC void SDLCALL SDL_AtomicLock(SDL_SpinLock *lock); + +/** + * \brief Unlock a spin lock by setting it to 0. Always returns immediately + * + * \param lock Points to the lock. + */ +extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock); + +/* @} *//* SDL AtomicLock */ + + +/** + * The compiler barrier prevents the compiler from reordering + * reads and writes to globally visible variables across the call. + */ +#if defined(_MSC_VER) && (_MSC_VER > 1200) +void _ReadWriteBarrier(void); +#pragma intrinsic(_ReadWriteBarrier) +#define SDL_CompilerBarrier() _ReadWriteBarrier() +#elif defined(__GNUC__) +#define SDL_CompilerBarrier() __asm__ __volatile__ ("" : : : "memory") +#else +#define SDL_CompilerBarrier() \ +{ SDL_SpinLock _tmp = 0; SDL_AtomicLock(&_tmp); SDL_AtomicUnlock(&_tmp); } +#endif + +/** + * Memory barriers are designed to prevent reads and writes from being + * reordered by the compiler and being seen out of order on multi-core CPUs. + * + * A typical pattern would be for thread A to write some data and a flag, + * and for thread B to read the flag and get the data. In this case you + * would insert a release barrier between writing the data and the flag, + * guaranteeing that the data write completes no later than the flag is + * written, and you would insert an acquire barrier between reading the + * flag and reading the data, to ensure that all the reads associated + * with the flag have completed. + * + * In this pattern you should always see a release barrier paired with + * an acquire barrier and you should gate the data reads/writes with a + * single flag variable. + * + * For more information on these semantics, take a look at the blog post: + * http://preshing.com/20120913/acquire-and-release-semantics + */ +#if defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) +#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("lwsync" : : : "memory") +#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("lwsync" : : : "memory") +#elif defined(__GNUC__) && defined(__arm__) +#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) +#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory") +#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory") +#elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) +#ifdef __thumb__ +/* The mcr instruction isn't available in thumb mode, use real functions */ +extern DECLSPEC void SDLCALL SDL_MemoryBarrierRelease(); +extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquire(); +#else +#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory") +#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory") +#endif /* __thumb__ */ +#else +#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("" : : : "memory") +#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("" : : : "memory") +#endif /* __GNUC__ && __arm__ */ +#else +/* This is correct for the x86 and x64 CPUs, and we'll expand this over time. */ +#define SDL_MemoryBarrierRelease() SDL_CompilerBarrier() +#define SDL_MemoryBarrierAcquire() SDL_CompilerBarrier() +#endif + + +/* Platform specific optimized versions of the atomic functions, + * you can disable these by defining SDL_DISABLE_ATOMIC_INLINE + */ +#if defined(SDL_ATOMIC_DISABLED) && SDL_ATOMIC_DISABLED +#define SDL_DISABLE_ATOMIC_INLINE +#endif +#ifndef SDL_DISABLE_ATOMIC_INLINE + +#ifdef HAVE_MSC_ATOMICS + +#define SDL_AtomicSet(a, v) _InterlockedExchange((long*)&(a)->value, (v)) +#define SDL_AtomicAdd(a, v) _InterlockedExchangeAdd((long*)&(a)->value, (v)) +#define SDL_AtomicCAS(a, oldval, newval) (_InterlockedCompareExchange((long*)&(a)->value, (newval), (oldval)) == (oldval)) +#define SDL_AtomicSetPtr(a, v) _InterlockedExchangePointer((a), (v)) +#if _M_IX86 +#define SDL_AtomicCASPtr(a, oldval, newval) (_InterlockedCompareExchange((long*)(a), (long)(newval), (long)(oldval)) == (long)(oldval)) +#else +#define SDL_AtomicCASPtr(a, oldval, newval) (_InterlockedCompareExchangePointer((a), (newval), (oldval)) == (oldval)) +#endif + +#elif defined(__MACOSX__) +#include + +#define SDL_AtomicCAS(a, oldval, newval) OSAtomicCompareAndSwap32Barrier((oldval), (newval), &(a)->value) +#ifdef __LP64__ +#define SDL_AtomicCASPtr(a, oldval, newval) OSAtomicCompareAndSwap64Barrier((int64_t)(oldval), (int64_t)(newval), (int64_t*)(a)) +#else +#define SDL_AtomicCASPtr(a, oldval, newval) OSAtomicCompareAndSwap32Barrier((int32_t)(oldval), (int32_t)(newval), (int32_t*)(a)) +#endif + +#elif defined(HAVE_GCC_ATOMICS) + +#define SDL_AtomicSet(a, v) __sync_lock_test_and_set(&(a)->value, v) +#define SDL_AtomicAdd(a, v) __sync_fetch_and_add(&(a)->value, v) +#define SDL_AtomicSetPtr(a, v) __sync_lock_test_and_set(a, v) +#define SDL_AtomicCAS(a, oldval, newval) __sync_bool_compare_and_swap(&(a)->value, oldval, newval) +#define SDL_AtomicCASPtr(a, oldval, newval) __sync_bool_compare_and_swap(a, oldval, newval) + +#endif + +#endif /* !SDL_DISABLE_ATOMIC_INLINE */ + + +/** + * \brief A type representing an atomic integer value. It is a struct + * so people don't accidentally use numeric operations on it. + */ +#ifndef SDL_atomic_t_defined +typedef struct { int value; } SDL_atomic_t; +#endif + +/** + * \brief Set an atomic variable to a new value if it is currently an old value. + * + * \return SDL_TRUE if the atomic variable was set, SDL_FALSE otherwise. + * + * \note If you don't know what this function is for, you shouldn't use it! +*/ +#ifndef SDL_AtomicCAS +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval); +#endif + +/** + * \brief Set an atomic variable to a value. + * + * \return The previous value of the atomic variable. + */ +#ifndef SDL_AtomicSet +SDL_FORCE_INLINE int SDL_AtomicSet(SDL_atomic_t *a, int v) +{ + int value; + do { + value = a->value; + } while (!SDL_AtomicCAS(a, value, v)); + return value; +} +#endif + +/** + * \brief Get the value of an atomic variable + */ +#ifndef SDL_AtomicGet +SDL_FORCE_INLINE int SDL_AtomicGet(SDL_atomic_t *a) +{ + int value = a->value; + SDL_CompilerBarrier(); + return value; +} +#endif + +/** + * \brief Add to an atomic variable. + * + * \return The previous value of the atomic variable. + * + * \note This same style can be used for any number operation + */ +#ifndef SDL_AtomicAdd +SDL_FORCE_INLINE int SDL_AtomicAdd(SDL_atomic_t *a, int v) +{ + int value; + do { + value = a->value; + } while (!SDL_AtomicCAS(a, value, (value + v))); + return value; +} +#endif + +/** + * \brief Increment an atomic variable used as a reference count. + */ +#ifndef SDL_AtomicIncRef +#define SDL_AtomicIncRef(a) SDL_AtomicAdd(a, 1) +#endif + +/** + * \brief Decrement an atomic variable used as a reference count. + * + * \return SDL_TRUE if the variable reached zero after decrementing, + * SDL_FALSE otherwise + */ +#ifndef SDL_AtomicDecRef +#define SDL_AtomicDecRef(a) (SDL_AtomicAdd(a, -1) == 1) +#endif + +/** + * \brief Set a pointer to a new value if it is currently an old value. + * + * \return SDL_TRUE if the pointer was set, SDL_FALSE otherwise. + * + * \note If you don't know what this function is for, you shouldn't use it! +*/ +#ifndef SDL_AtomicCASPtr +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCASPtr(void* *a, void *oldval, void *newval); +#endif + +/** + * \brief Set a pointer to a value atomically. + * + * \return The previous value of the pointer. + */ +#ifndef SDL_AtomicSetPtr +SDL_FORCE_INLINE void* SDL_AtomicSetPtr(void* *a, void* v) +{ + void* value; + do { + value = *a; + } while (!SDL_AtomicCASPtr(a, value, v)); + return value; +} +#endif + +/** + * \brief Get the value of a pointer atomically. + */ +#ifndef SDL_AtomicGetPtr +SDL_FORCE_INLINE void* SDL_AtomicGetPtr(void* *a) +{ + void* value = *a; + SDL_CompilerBarrier(); + return value; +} +#endif + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif + +#include "close_code.h" + +#endif /* _SDL_atomic_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_audio.h spring-98.0~14.04~ppa6/include/SDL2/SDL_audio.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_audio.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_audio.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,506 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_audio.h + * + * Access to the raw audio mixing buffer for the SDL library. + */ + +#ifndef _SDL_audio_h +#define _SDL_audio_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_endian.h" +#include "SDL_mutex.h" +#include "SDL_thread.h" +#include "SDL_rwops.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Audio format flags. + * + * These are what the 16 bits in SDL_AudioFormat currently mean... + * (Unspecified bits are always zero). + * + * \verbatim + ++-----------------------sample is signed if set + || + || ++-----------sample is bigendian if set + || || + || || ++---sample is float if set + || || || + || || || +---sample bit size---+ + || || || | | + 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 + \endverbatim + * + * There are macros in SDL 2.0 and later to query these bits. + */ +typedef Uint16 SDL_AudioFormat; + +/** + * \name Audio flags + */ +/* @{ */ + +#define SDL_AUDIO_MASK_BITSIZE (0xFF) +#define SDL_AUDIO_MASK_DATATYPE (1<<8) +#define SDL_AUDIO_MASK_ENDIAN (1<<12) +#define SDL_AUDIO_MASK_SIGNED (1<<15) +#define SDL_AUDIO_BITSIZE(x) (x & SDL_AUDIO_MASK_BITSIZE) +#define SDL_AUDIO_ISFLOAT(x) (x & SDL_AUDIO_MASK_DATATYPE) +#define SDL_AUDIO_ISBIGENDIAN(x) (x & SDL_AUDIO_MASK_ENDIAN) +#define SDL_AUDIO_ISSIGNED(x) (x & SDL_AUDIO_MASK_SIGNED) +#define SDL_AUDIO_ISINT(x) (!SDL_AUDIO_ISFLOAT(x)) +#define SDL_AUDIO_ISLITTLEENDIAN(x) (!SDL_AUDIO_ISBIGENDIAN(x)) +#define SDL_AUDIO_ISUNSIGNED(x) (!SDL_AUDIO_ISSIGNED(x)) + +/** + * \name Audio format flags + * + * Defaults to LSB byte order. + */ +/* @{ */ +#define AUDIO_U8 0x0008 /**< Unsigned 8-bit samples */ +#define AUDIO_S8 0x8008 /**< Signed 8-bit samples */ +#define AUDIO_U16LSB 0x0010 /**< Unsigned 16-bit samples */ +#define AUDIO_S16LSB 0x8010 /**< Signed 16-bit samples */ +#define AUDIO_U16MSB 0x1010 /**< As above, but big-endian byte order */ +#define AUDIO_S16MSB 0x9010 /**< As above, but big-endian byte order */ +#define AUDIO_U16 AUDIO_U16LSB +#define AUDIO_S16 AUDIO_S16LSB +/* @} */ + +/** + * \name int32 support + */ +/* @{ */ +#define AUDIO_S32LSB 0x8020 /**< 32-bit integer samples */ +#define AUDIO_S32MSB 0x9020 /**< As above, but big-endian byte order */ +#define AUDIO_S32 AUDIO_S32LSB +/* @} */ + +/** + * \name float32 support + */ +/* @{ */ +#define AUDIO_F32LSB 0x8120 /**< 32-bit floating point samples */ +#define AUDIO_F32MSB 0x9120 /**< As above, but big-endian byte order */ +#define AUDIO_F32 AUDIO_F32LSB +/* @} */ + +/** + * \name Native audio byte ordering + */ +/* @{ */ +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define AUDIO_U16SYS AUDIO_U16LSB +#define AUDIO_S16SYS AUDIO_S16LSB +#define AUDIO_S32SYS AUDIO_S32LSB +#define AUDIO_F32SYS AUDIO_F32LSB +#else +#define AUDIO_U16SYS AUDIO_U16MSB +#define AUDIO_S16SYS AUDIO_S16MSB +#define AUDIO_S32SYS AUDIO_S32MSB +#define AUDIO_F32SYS AUDIO_F32MSB +#endif +/* @} */ + +/** + * \name Allow change flags + * + * Which audio format changes are allowed when opening a device. + */ +/* @{ */ +#define SDL_AUDIO_ALLOW_FREQUENCY_CHANGE 0x00000001 +#define SDL_AUDIO_ALLOW_FORMAT_CHANGE 0x00000002 +#define SDL_AUDIO_ALLOW_CHANNELS_CHANGE 0x00000004 +#define SDL_AUDIO_ALLOW_ANY_CHANGE (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE|SDL_AUDIO_ALLOW_FORMAT_CHANGE|SDL_AUDIO_ALLOW_CHANNELS_CHANGE) +/* @} */ + +/* @} *//* Audio flags */ + +/** + * This function is called when the audio device needs more data. + * + * \param userdata An application-specific parameter saved in + * the SDL_AudioSpec structure + * \param stream A pointer to the audio data buffer. + * \param len The length of that buffer in bytes. + * + * Once the callback returns, the buffer will no longer be valid. + * Stereo samples are stored in a LRLRLR ordering. + */ +typedef void (SDLCALL * SDL_AudioCallback) (void *userdata, Uint8 * stream, + int len); + +/** + * The calculated values in this structure are calculated by SDL_OpenAudio(). + */ +typedef struct SDL_AudioSpec +{ + int freq; /**< DSP frequency -- samples per second */ + SDL_AudioFormat format; /**< Audio data format */ + Uint8 channels; /**< Number of channels: 1 mono, 2 stereo */ + Uint8 silence; /**< Audio buffer silence value (calculated) */ + Uint16 samples; /**< Audio buffer size in samples (power of 2) */ + Uint16 padding; /**< Necessary for some compile environments */ + Uint32 size; /**< Audio buffer size in bytes (calculated) */ + SDL_AudioCallback callback; + void *userdata; +} SDL_AudioSpec; + + +struct SDL_AudioCVT; +typedef void (SDLCALL * SDL_AudioFilter) (struct SDL_AudioCVT * cvt, + SDL_AudioFormat format); + +/** + * A structure to hold a set of audio conversion filters and buffers. + */ +#ifdef __GNUC__ +/* This structure is 84 bytes on 32-bit architectures, make sure GCC doesn't + pad it out to 88 bytes to guarantee ABI compatibility between compilers. + vvv + The next time we rev the ABI, make sure to size the ints and add padding. +*/ +#define SDL_AUDIOCVT_PACKED __attribute__((packed)) +#else +#define SDL_AUDIOCVT_PACKED +#endif +/* */ +typedef struct SDL_AudioCVT +{ + int needed; /**< Set to 1 if conversion possible */ + SDL_AudioFormat src_format; /**< Source audio format */ + SDL_AudioFormat dst_format; /**< Target audio format */ + double rate_incr; /**< Rate conversion increment */ + Uint8 *buf; /**< Buffer to hold entire audio data */ + int len; /**< Length of original audio buffer */ + int len_cvt; /**< Length of converted audio buffer */ + int len_mult; /**< buffer must be len*len_mult big */ + double len_ratio; /**< Given len, final size is len*len_ratio */ + SDL_AudioFilter filters[10]; /**< Filter list */ + int filter_index; /**< Current audio conversion function */ +} SDL_AUDIOCVT_PACKED SDL_AudioCVT; + + +/* Function prototypes */ + +/** + * \name Driver discovery functions + * + * These functions return the list of built in audio drivers, in the + * order that they are normally initialized by default. + */ +/* @{ */ +extern DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void); +extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index); +/* @} */ + +/** + * \name Initialization and cleanup + * + * \internal These functions are used internally, and should not be used unless + * you have a specific need to specify the audio driver you want to + * use. You should normally use SDL_Init() or SDL_InitSubSystem(). + */ +/* @{ */ +extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name); +extern DECLSPEC void SDLCALL SDL_AudioQuit(void); +/* @} */ + +/** + * This function returns the name of the current audio driver, or NULL + * if no driver has been initialized. + */ +extern DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver(void); + +/** + * This function opens the audio device with the desired parameters, and + * returns 0 if successful, placing the actual hardware parameters in the + * structure pointed to by \c obtained. If \c obtained is NULL, the audio + * data passed to the callback function will be guaranteed to be in the + * requested format, and will be automatically converted to the hardware + * audio format if necessary. This function returns -1 if it failed + * to open the audio device, or couldn't set up the audio thread. + * + * When filling in the desired audio spec structure, + * - \c desired->freq should be the desired audio frequency in samples-per- + * second. + * - \c desired->format should be the desired audio format. + * - \c desired->samples is the desired size of the audio buffer, in + * samples. This number should be a power of two, and may be adjusted by + * the audio driver to a value more suitable for the hardware. Good values + * seem to range between 512 and 8096 inclusive, depending on the + * application and CPU speed. Smaller values yield faster response time, + * but can lead to underflow if the application is doing heavy processing + * and cannot fill the audio buffer in time. A stereo sample consists of + * both right and left channels in LR ordering. + * Note that the number of samples is directly related to time by the + * following formula: \code ms = (samples*1000)/freq \endcode + * - \c desired->size is the size in bytes of the audio buffer, and is + * calculated by SDL_OpenAudio(). + * - \c desired->silence is the value used to set the buffer to silence, + * and is calculated by SDL_OpenAudio(). + * - \c desired->callback should be set to a function that will be called + * when the audio device is ready for more data. It is passed a pointer + * to the audio buffer, and the length in bytes of the audio buffer. + * This function usually runs in a separate thread, and so you should + * protect data structures that it accesses by calling SDL_LockAudio() + * and SDL_UnlockAudio() in your code. + * - \c desired->userdata is passed as the first parameter to your callback + * function. + * + * The audio device starts out playing silence when it's opened, and should + * be enabled for playing by calling \c SDL_PauseAudio(0) when you are ready + * for your audio callback function to be called. Since the audio driver + * may modify the requested size of the audio buffer, you should allocate + * any local mixing buffers after you open the audio device. + */ +extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec * desired, + SDL_AudioSpec * obtained); + +/** + * SDL Audio Device IDs. + * + * A successful call to SDL_OpenAudio() is always device id 1, and legacy + * SDL audio APIs assume you want this device ID. SDL_OpenAudioDevice() calls + * always returns devices >= 2 on success. The legacy calls are good both + * for backwards compatibility and when you don't care about multiple, + * specific, or capture devices. + */ +typedef Uint32 SDL_AudioDeviceID; + +/** + * Get the number of available devices exposed by the current driver. + * Only valid after a successfully initializing the audio subsystem. + * Returns -1 if an explicit list of devices can't be determined; this is + * not an error. For example, if SDL is set up to talk to a remote audio + * server, it can't list every one available on the Internet, but it will + * still allow a specific host to be specified to SDL_OpenAudioDevice(). + * + * In many common cases, when this function returns a value <= 0, it can still + * successfully open the default device (NULL for first argument of + * SDL_OpenAudioDevice()). + */ +extern DECLSPEC int SDLCALL SDL_GetNumAudioDevices(int iscapture); + +/** + * Get the human-readable name of a specific audio device. + * Must be a value between 0 and (number of audio devices-1). + * Only valid after a successfully initializing the audio subsystem. + * The values returned by this function reflect the latest call to + * SDL_GetNumAudioDevices(); recall that function to redetect available + * hardware. + * + * The string returned by this function is UTF-8 encoded, read-only, and + * managed internally. You are not to free it. If you need to keep the + * string for any length of time, you should make your own copy of it, as it + * will be invalid next time any of several other SDL functions is called. + */ +extern DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index, + int iscapture); + + +/** + * Open a specific audio device. Passing in a device name of NULL requests + * the most reasonable default (and is equivalent to calling SDL_OpenAudio()). + * + * The device name is a UTF-8 string reported by SDL_GetAudioDeviceName(), but + * some drivers allow arbitrary and driver-specific strings, such as a + * hostname/IP address for a remote audio server, or a filename in the + * diskaudio driver. + * + * \return 0 on error, a valid device ID that is >= 2 on success. + * + * SDL_OpenAudio(), unlike this function, always acts on device ID 1. + */ +extern DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice(const char + *device, + int iscapture, + const + SDL_AudioSpec * + desired, + SDL_AudioSpec * + obtained, + int + allowed_changes); + + + +/** + * \name Audio state + * + * Get the current audio state. + */ +/* @{ */ +typedef enum +{ + SDL_AUDIO_STOPPED = 0, + SDL_AUDIO_PLAYING, + SDL_AUDIO_PAUSED +} SDL_AudioStatus; +extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioStatus(void); + +extern DECLSPEC SDL_AudioStatus SDLCALL +SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev); +/* @} *//* Audio State */ + +/** + * \name Pause audio functions + * + * These functions pause and unpause the audio callback processing. + * They should be called with a parameter of 0 after opening the audio + * device to start playing sound. This is so you can safely initialize + * data for your callback function after opening the audio device. + * Silence will be written to the audio device during the pause. + */ +/* @{ */ +extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on); +extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev, + int pause_on); +/* @} *//* Pause audio functions */ + +/** + * This function loads a WAVE from the data source, automatically freeing + * that source if \c freesrc is non-zero. For example, to load a WAVE file, + * you could do: + * \code + * SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...); + * \endcode + * + * If this function succeeds, it returns the given SDL_AudioSpec, + * filled with the audio data format of the wave data, and sets + * \c *audio_buf to a malloc()'d buffer containing the audio data, + * and sets \c *audio_len to the length of that audio buffer, in bytes. + * You need to free the audio buffer with SDL_FreeWAV() when you are + * done with it. + * + * This function returns NULL and sets the SDL error message if the + * wave file cannot be opened, uses an unknown data format, or is + * corrupt. Currently raw and MS-ADPCM WAVE files are supported. + */ +extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src, + int freesrc, + SDL_AudioSpec * spec, + Uint8 ** audio_buf, + Uint32 * audio_len); + +/** + * Loads a WAV from a file. + * Compatibility convenience function. + */ +#define SDL_LoadWAV(file, spec, audio_buf, audio_len) \ + SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len) + +/** + * This function frees data previously allocated with SDL_LoadWAV_RW() + */ +extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 * audio_buf); + +/** + * This function takes a source format and rate and a destination format + * and rate, and initializes the \c cvt structure with information needed + * by SDL_ConvertAudio() to convert a buffer of audio data from one format + * to the other. + * + * \return -1 if the format conversion is not supported, 0 if there's + * no conversion needed, or 1 if the audio filter is set up. + */ +extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT * cvt, + SDL_AudioFormat src_format, + Uint8 src_channels, + int src_rate, + SDL_AudioFormat dst_format, + Uint8 dst_channels, + int dst_rate); + +/** + * Once you have initialized the \c cvt structure using SDL_BuildAudioCVT(), + * created an audio buffer \c cvt->buf, and filled it with \c cvt->len bytes of + * audio data in the source format, this function will convert it in-place + * to the desired format. + * + * The data conversion may expand the size of the audio data, so the buffer + * \c cvt->buf should be allocated after the \c cvt structure is initialized by + * SDL_BuildAudioCVT(), and should be \c cvt->len*cvt->len_mult bytes long. + */ +extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT * cvt); + +#define SDL_MIX_MAXVOLUME 128 +/** + * This takes two audio buffers of the playing audio format and mixes + * them, performing addition, volume adjustment, and overflow clipping. + * The volume ranges from 0 - 128, and should be set to ::SDL_MIX_MAXVOLUME + * for full audio volume. Note this does not change hardware volume. + * This is provided for convenience -- you can mix your own audio data. + */ +extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 * dst, const Uint8 * src, + Uint32 len, int volume); + +/** + * This works like SDL_MixAudio(), but you specify the audio format instead of + * using the format of audio device 1. Thus it can be used when no audio + * device is open at all. + */ +extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst, + const Uint8 * src, + SDL_AudioFormat format, + Uint32 len, int volume); + +/** + * \name Audio lock functions + * + * The lock manipulated by these functions protects the callback function. + * During a SDL_LockAudio()/SDL_UnlockAudio() pair, you can be guaranteed that + * the callback function is not running. Do not call these from the callback + * function or you will cause deadlock. + */ +/* @{ */ +extern DECLSPEC void SDLCALL SDL_LockAudio(void); +extern DECLSPEC void SDLCALL SDL_LockAudioDevice(SDL_AudioDeviceID dev); +extern DECLSPEC void SDLCALL SDL_UnlockAudio(void); +extern DECLSPEC void SDLCALL SDL_UnlockAudioDevice(SDL_AudioDeviceID dev); +/* @} *//* Audio lock functions */ + +/** + * This function shuts down audio processing and closes the audio device. + */ +extern DECLSPEC void SDLCALL SDL_CloseAudio(void); +extern DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID dev); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_audio_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_bits.h spring-98.0~14.04~ppa6/include/SDL2/SDL_bits.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_bits.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_bits.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,97 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_bits.h + * + * Functions for fiddling with bits and bitmasks. + */ + +#ifndef _SDL_bits_h +#define _SDL_bits_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \file SDL_bits.h + */ + +/** + * Get the index of the most significant bit. Result is undefined when called + * with 0. This operation can also be stated as "count leading zeroes" and + * "log base 2". + * + * \return Index of the most significant bit, or -1 if the value is 0. + */ +SDL_FORCE_INLINE int +SDL_MostSignificantBitIndex32(Uint32 x) +{ +#if defined(__GNUC__) && __GNUC__ >= 4 + /* Count Leading Zeroes builtin in GCC. + * http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html + */ + if (x == 0) { + return -1; + } + return 31 - __builtin_clz(x); +#else + /* Based off of Bit Twiddling Hacks by Sean Eron Anderson + * , released in the public domain. + * http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog + */ + const Uint32 b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000}; + const int S[] = {1, 2, 4, 8, 16}; + + int msbIndex = 0; + int i; + + if (x == 0) { + return -1; + } + + for (i = 4; i >= 0; i--) + { + if (x & b[i]) + { + x >>= S[i]; + msbIndex |= S[i]; + } + } + + return msbIndex; +#endif +} + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_bits_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_blendmode.h spring-98.0~14.04~ppa6/include/SDL2/SDL_blendmode.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_blendmode.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_blendmode.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,63 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_blendmode.h + * + * Header file declaring the SDL_BlendMode enumeration + */ + +#ifndef _SDL_blendmode_h +#define _SDL_blendmode_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief The blend mode used in SDL_RenderCopy() and drawing operations. + */ +typedef enum +{ + SDL_BLENDMODE_NONE = 0x00000000, /**< no blending + dstRGBA = srcRGBA */ + SDL_BLENDMODE_BLEND = 0x00000001, /**< alpha blending + dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)) + dstA = srcA + (dstA * (1-srcA)) */ + SDL_BLENDMODE_ADD = 0x00000002, /**< additive blending + dstRGB = (srcRGB * srcA) + dstRGB + dstA = dstA */ + SDL_BLENDMODE_MOD = 0x00000004 /**< color modulate + dstRGB = srcRGB * dstRGB + dstA = dstA */ +} SDL_BlendMode; + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_video_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_clipboard.h spring-98.0~14.04~ppa6/include/SDL2/SDL_clipboard.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_clipboard.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_clipboard.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,71 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_clipboard.h + * + * Include file for SDL clipboard handling + */ + +#ifndef _SDL_clipboard_h +#define _SDL_clipboard_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Function prototypes */ + +/** + * \brief Put UTF-8 text into the clipboard + * + * \sa SDL_GetClipboardText() + */ +extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text); + +/** + * \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free() + * + * \sa SDL_SetClipboardText() + */ +extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void); + +/** + * \brief Returns a flag indicating whether the clipboard exists and contains a text string that is non-empty + * + * \sa SDL_GetClipboardText() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_clipboard_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_config.h spring-98.0~14.04~ppa6/include/SDL2/SDL_config.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_config.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_config.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,322 @@ +/* include/SDL_config.h. Generated from SDL_config.h.in by configure. */ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_config_h +#define _SDL_config_h + +/** + * \file SDL_config.h.in + * + * This is a set of defines to configure the SDL features + */ + +/* General platform specific identifiers */ +#include "SDL_platform.h" + +/* Make sure that this isn't included by Visual C++ */ +#ifdef _MSC_VER +#error You should run hg revert SDL_config.h +#endif + +/* C language features */ +/* #undef const */ +/* #undef inline */ +/* #undef volatile */ + +/* C datatypes */ +#ifdef __LP64__ +#define SIZEOF_VOIDP 8 +#else +#define SIZEOF_VOIDP 4 +#endif +#define HAVE_GCC_ATOMICS 1 +/* #undef HAVE_GCC_SYNC_LOCK_TEST_AND_SET */ +#define HAVE_PTHREAD_SPINLOCK 1 + +/* Comment this if you want to build without any C library requirements */ +#define HAVE_LIBC 1 +#if HAVE_LIBC + +/* Useful headers */ +#define HAVE_ALLOCA_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STDARG_H 1 +#define HAVE_MALLOC_H 1 +#define HAVE_MEMORY_H 1 +#define HAVE_STRING_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_ICONV_H 1 +#define HAVE_SIGNAL_H 1 +/* #undef HAVE_ALTIVEC_H */ +/* #undef HAVE_PTHREAD_NP_H */ +#define HAVE_LIBUDEV_H 1 +#define HAVE_DBUS_DBUS_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */ +#define HAVE_GETENV 1 +#define HAVE_SETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_UNSETENV 1 +#endif +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +/* #undef HAVE_STRLCPY */ +/* #undef HAVE_STRLCAT */ +#define HAVE_STRDUP 1 +/* #undef HAVE__STRREV */ +/* #undef HAVE__STRUPR */ +/* #undef HAVE__STRLWR */ +/* #undef HAVE_INDEX */ +/* #undef HAVE_RINDEX */ +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +/* #undef HAVE_ITOA */ +/* #undef HAVE__LTOA */ +/* #undef HAVE__UITOA */ +/* #undef HAVE__ULTOA */ +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +/* #undef HAVE__I64TOA */ +/* #undef HAVE__UI64TOA */ +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +/* #undef HAVE__STRICMP */ +#define HAVE_STRCASECMP 1 +/* #undef HAVE__STRNICMP */ +#define HAVE_STRNCASECMP 1 +#define HAVE_SSCANF 1 +#define HAVE_SNPRINTF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_M_PI /**/ +#define HAVE_ATAN 1 +#define HAVE_ATAN2 1 +#define HAVE_CEIL 1 +#define HAVE_COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_POW 1 +#define HAVE_SCALBN 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_FSEEKO 1 +#define HAVE_FSEEKO64 1 +#define HAVE_SIGACTION 1 +#define HAVE_SA_SIGACTION 1 +#define HAVE_SETJMP 1 +#define HAVE_NANOSLEEP 1 +#define HAVE_SYSCONF 1 +/* #undef HAVE_SYSCTLBYNAME */ +#define HAVE_CLOCK_GETTIME 1 +/* #undef HAVE_GETPAGESIZE */ +#define HAVE_MPROTECT 1 +#define HAVE_ICONV 1 +#define HAVE_PTHREAD_SETNAME_NP 1 +/* #undef HAVE_PTHREAD_SET_NAME_NP */ +#define HAVE_SEM_TIMEDWAIT 1 + +#else +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 +#define HAVE_STDINT_H 1 +#endif /* HAVE_LIBC */ + +/* SDL internal assertion support */ +/* #undef SDL_DEFAULT_ASSERT_LEVEL */ + +/* Allow disabling of core subsystems */ +/* #undef SDL_ATOMIC_DISABLED */ +/* #undef SDL_AUDIO_DISABLED */ +/* #undef SDL_CPUINFO_DISABLED */ +/* #undef SDL_EVENTS_DISABLED */ +/* #undef SDL_FILE_DISABLED */ +/* #undef SDL_JOYSTICK_DISABLED */ +#define SDL_HAPTIC_DISABLED 1 +#define SDL_LOADSO_DISABLED 1 +/* #undef SDL_RENDER_DISABLED */ +/* #undef SDL_THREADS_DISABLED */ +/* #undef SDL_TIMERS_DISABLED */ +/* #undef SDL_VIDEO_DISABLED */ +/* #undef SDL_POWER_DISABLED */ +/* #undef SDL_FILESYSTEM_DISABLED */ + +/* Enable various audio drivers */ +#define SDL_AUDIO_DRIVER_ALSA 1 +/* #undef SDL_AUDIO_DRIVER_ALSA_DYNAMIC */ +/* #undef SDL_AUDIO_DRIVER_ARTS */ +/* #undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC */ +/* #undef SDL_AUDIO_DRIVER_PULSEAUDIO */ +/* #undef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC */ +/* #undef SDL_AUDIO_DRIVER_BEOSAUDIO */ +/* #undef SDL_AUDIO_DRIVER_BSD */ +/* #undef SDL_AUDIO_DRIVER_COREAUDIO */ +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 +/* #undef SDL_AUDIO_DRIVER_XAUDIO2 */ +/* #undef SDL_AUDIO_DRIVER_DSOUND */ +/* #undef SDL_AUDIO_DRIVER_ESD */ +/* #undef SDL_AUDIO_DRIVER_ESD_DYNAMIC */ +/* #undef SDL_AUDIO_DRIVER_NAS */ +/* #undef SDL_AUDIO_DRIVER_NAS_DYNAMIC */ +/* #undef SDL_AUDIO_DRIVER_SNDIO */ +/* #undef SDL_AUDIO_DRIVER_SNDIO_DYNAMIC */ +/* #undef SDL_AUDIO_DRIVER_OSS */ +/* #undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H */ +/* #undef SDL_AUDIO_DRIVER_PAUDIO */ +/* #undef SDL_AUDIO_DRIVER_QSA */ +/* #undef SDL_AUDIO_DRIVER_SUNAUDIO */ +/* #undef SDL_AUDIO_DRIVER_WINMM */ +/* #undef SDL_AUDIO_DRIVER_FUSIONSOUND */ +/* #undef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC */ + +/* Enable various input drivers */ +#define SDL_INPUT_LINUXEV 1 +#define SDL_INPUT_LINUXKD 1 +/* #undef SDL_INPUT_TSLIB */ +/* #undef SDL_JOYSTICK_BEOS */ +/* #undef SDL_JOYSTICK_DINPUT */ +/* #undef SDL_JOYSTICK_DUMMY */ +/* #undef SDL_JOYSTICK_IOKIT */ +#define SDL_JOYSTICK_LINUX 1 +/* #undef SDL_JOYSTICK_WINMM */ +/* #undef SDL_JOYSTICK_USBHID */ +/* #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H */ +/* #undef SDL_HAPTIC_DUMMY */ +/* #undef SDL_HAPTIC_LINUX */ +/* #undef SDL_HAPTIC_IOKIT */ +/* #undef SDL_HAPTIC_DINPUT */ + +/* Enable various shared object loading systems */ +/* #undef SDL_LOADSO_BEOS */ +#define SDL_LOADSO_DLOPEN 1 +/* #undef SDL_LOADSO_DUMMY */ +/* #undef SDL_LOADSO_LDG */ +/* #undef SDL_LOADSO_WINDOWS */ + +/* Enable various threading systems */ +/* #undef SDL_THREAD_BEOS */ +#define SDL_THREAD_PTHREAD 1 +#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 +/* #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP */ +/* #undef SDL_THREAD_WINDOWS */ + +/* Enable various timer systems */ +/* #undef SDL_TIMER_BEOS */ +/* #undef SDL_TIMER_DUMMY */ +#define SDL_TIMER_UNIX 1 +/* #undef SDL_TIMER_WINDOWS */ + +/* Enable various video drivers */ +/* #undef SDL_VIDEO_DRIVER_BWINDOW */ +/* #undef SDL_VIDEO_DRIVER_COCOA */ +/* #undef SDL_VIDEO_DRIVER_DIRECTFB */ +/* #undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC */ +#define SDL_VIDEO_DRIVER_DUMMY 1 +/* #undef SDL_VIDEO_DRIVER_WINDOWS */ +#define SDL_VIDEO_DRIVER_X11 1 +/* #undef SDL_VIDEO_DRIVER_RPI */ +/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC */ +/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT */ +/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR */ +/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA */ +/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 */ +/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR */ +/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS */ +/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE */ +#define SDL_VIDEO_DRIVER_X11_XCURSOR 1 +/* #undef SDL_VIDEO_DRIVER_X11_XINERAMA */ +#define SDL_VIDEO_DRIVER_X11_XINPUT2 1 +#define SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH 1 +#define SDL_VIDEO_DRIVER_X11_XRANDR 1 +#define SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1 +#define SDL_VIDEO_DRIVER_X11_XSHAPE 1 +#define SDL_VIDEO_DRIVER_X11_XVIDMODE 1 +#define SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1 +#define SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32 1 +#define SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY 1 +#define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1 + +/* #undef SDL_VIDEO_RENDER_D3D */ +#define SDL_VIDEO_RENDER_OGL 1 +/* #undef SDL_VIDEO_RENDER_OGL_ES */ +/* #undef SDL_VIDEO_RENDER_OGL_ES2 */ +/* #undef SDL_VIDEO_RENDER_DIRECTFB */ + +/* Enable OpenGL support */ +#define SDL_VIDEO_OPENGL 1 +/* #undef SDL_VIDEO_OPENGL_ES */ +/* #undef SDL_VIDEO_OPENGL_ES2 */ +/* #undef SDL_VIDEO_OPENGL_BGL */ +/* #undef SDL_VIDEO_OPENGL_CGL */ +/* #undef SDL_VIDEO_OPENGL_EGL */ +#define SDL_VIDEO_OPENGL_GLX 1 +/* #undef SDL_VIDEO_OPENGL_WGL */ +/* #undef SDL_VIDEO_OPENGL_OSMESA */ +/* #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC */ + +/* Enable system power support */ +#define SDL_POWER_LINUX 1 +/* #undef SDL_POWER_WINDOWS */ +/* #undef SDL_POWER_MACOSX */ +/* #undef SDL_POWER_BEOS */ +/* #undef SDL_POWER_HARDWIRED */ + +/* Enable system filesystem support */ +/* #undef SDL_FILESYSTEM_BEOS */ +/* #undef SDL_FILESYSTEM_COCOA */ +/* #undef SDL_FILESYSTEM_DUMMY */ +#define SDL_FILESYSTEM_UNIX 1 +/* #undef SDL_FILESYSTEM_WINDOWS */ + +/* Enable assembly routines */ +#define SDL_ASSEMBLY_ROUTINES 1 +/* #undef SDL_ALTIVEC_BLITTERS */ + +#endif /* _SDL_config_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_cpuinfo.h spring-98.0~14.04~ppa6/include/SDL2/SDL_cpuinfo.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_cpuinfo.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_cpuinfo.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,151 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_cpuinfo.h + * + * CPU feature detection for SDL. + */ + +#ifndef _SDL_cpuinfo_h +#define _SDL_cpuinfo_h + +#include "SDL_stdinc.h" + +/* Need to do this here because intrin.h has C++ code in it */ +/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */ +#if defined(_MSC_VER) && (_MSC_VER >= 1500) +#include +#ifndef _WIN64 +#define __MMX__ +#define __3dNOW__ +#endif +#define __SSE__ +#define __SSE2__ +#elif defined(__MINGW64_VERSION_MAJOR) +#include +#else +#ifdef __ALTIVEC__ +#if HAVE_ALTIVEC_H && !defined(__APPLE_ALTIVEC__) +#include +#undef pixel +#endif +#endif +#ifdef __MMX__ +#include +#endif +#ifdef __3dNOW__ +#include +#endif +#ifdef __SSE__ +#include +#endif +#ifdef __SSE2__ +#include +#endif +#endif + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* This is a guess for the cacheline size used for padding. + * Most x86 processors have a 64 byte cache line. + * The 64-bit PowerPC processors have a 128 byte cache line. + * We'll use the larger value to be generally safe. + */ +#define SDL_CACHELINE_SIZE 128 + +/** + * This function returns the number of CPU cores available. + */ +extern DECLSPEC int SDLCALL SDL_GetCPUCount(void); + +/** + * This function returns the L1 cache line size of the CPU + * + * This is useful for determining multi-threaded structure padding + * or SIMD prefetch sizes. + */ +extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void); + +/** + * This function returns true if the CPU has the RDTSC instruction. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void); + +/** + * This function returns true if the CPU has AltiVec features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); + +/** + * This function returns true if the CPU has MMX features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void); + +/** + * This function returns true if the CPU has 3DNow! features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void); + +/** + * This function returns true if the CPU has SSE features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void); + +/** + * This function returns true if the CPU has SSE2 features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void); + +/** + * This function returns true if the CPU has SSE3 features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void); + +/** + * This function returns true if the CPU has SSE4.1 features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void); + +/** + * This function returns true if the CPU has SSE4.2 features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void); + +/** + * This function returns the amount of RAM configured in the system, in MB. + */ +extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_cpuinfo_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_endian.h spring-98.0~14.04~ppa6/include/SDL2/SDL_endian.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_endian.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_endian.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,239 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_endian.h + * + * Functions for reading and writing endian-specific values + */ + +#ifndef _SDL_endian_h +#define _SDL_endian_h + +#include "SDL_stdinc.h" + +/** + * \name The two types of endianness + */ +/* @{ */ +#define SDL_LIL_ENDIAN 1234 +#define SDL_BIG_ENDIAN 4321 +/* @} */ + +#ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */ +#ifdef __linux__ +#include +#define SDL_BYTEORDER __BYTE_ORDER +#else /* __linux __ */ +#if defined(__hppa__) || \ + defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ + (defined(__MIPS__) && defined(__MISPEB__)) || \ + defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \ + defined(__sparc__) +#define SDL_BYTEORDER SDL_BIG_ENDIAN +#else +#define SDL_BYTEORDER SDL_LIL_ENDIAN +#endif +#endif /* __linux __ */ +#endif /* !SDL_BYTEORDER */ + + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \file SDL_endian.h + */ +#if defined(__GNUC__) && defined(__i386__) && \ + !(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */) +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + __asm__("xchgb %b0,%h0": "=q"(x):"0"(x)); + return x; +} +#elif defined(__GNUC__) && defined(__x86_64__) +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + __asm__("xchgb %b0,%h0": "=Q"(x):"0"(x)); + return x; +} +#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + int result; + + __asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x)); + return (Uint16)result; +} +#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + __asm__("rorw #8,%0": "=d"(x): "0"(x):"cc"); + return x; +} +#else +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + return SDL_static_cast(Uint16, ((x << 8) | (x >> 8))); +} +#endif + +#if defined(__GNUC__) && defined(__i386__) +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + __asm__("bswap %0": "=r"(x):"0"(x)); + return x; +} +#elif defined(__GNUC__) && defined(__x86_64__) +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + __asm__("bswapl %0": "=r"(x):"0"(x)); + return x; +} +#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + Uint32 result; + + __asm__("rlwimi %0,%2,24,16,23": "=&r"(result):"0"(x >> 24), "r"(x)); + __asm__("rlwimi %0,%2,8,8,15": "=&r"(result):"0"(result), "r"(x)); + __asm__("rlwimi %0,%2,24,0,7": "=&r"(result):"0"(result), "r"(x)); + return result; +} +#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0": "=d"(x): "0"(x):"cc"); + return x; +} +#else +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + return SDL_static_cast(Uint32, ((x << 24) | ((x << 8) & 0x00FF0000) | + ((x >> 8) & 0x0000FF00) | (x >> 24))); +} +#endif + +#if defined(__GNUC__) && defined(__i386__) +SDL_FORCE_INLINE Uint64 +SDL_Swap64(Uint64 x) +{ + union + { + struct + { + Uint32 a, b; + } s; + Uint64 u; + } v; + v.u = x; + __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1": "=r"(v.s.a), "=r"(v.s.b):"0"(v.s.a), + "1"(v.s. + b)); + return v.u; +} +#elif defined(__GNUC__) && defined(__x86_64__) +SDL_FORCE_INLINE Uint64 +SDL_Swap64(Uint64 x) +{ + __asm__("bswapq %0": "=r"(x):"0"(x)); + return x; +} +#else +SDL_FORCE_INLINE Uint64 +SDL_Swap64(Uint64 x) +{ + Uint32 hi, lo; + + /* Separate into high and low 32-bit values and swap them */ + lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF); + x >>= 32; + hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF); + x = SDL_Swap32(lo); + x <<= 32; + x |= SDL_Swap32(hi); + return (x); +} +#endif + + +SDL_FORCE_INLINE float +SDL_SwapFloat(float x) +{ + union + { + float f; + Uint32 ui32; + } swapper; + swapper.f = x; + swapper.ui32 = SDL_Swap32(swapper.ui32); + return swapper.f; +} + + +/** + * \name Swap to native + * Byteswap item from the specified endianness to the native endianness. + */ +/* @{ */ +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define SDL_SwapLE16(X) (X) +#define SDL_SwapLE32(X) (X) +#define SDL_SwapLE64(X) (X) +#define SDL_SwapFloatLE(X) (X) +#define SDL_SwapBE16(X) SDL_Swap16(X) +#define SDL_SwapBE32(X) SDL_Swap32(X) +#define SDL_SwapBE64(X) SDL_Swap64(X) +#define SDL_SwapFloatBE(X) SDL_SwapFloat(X) +#else +#define SDL_SwapLE16(X) SDL_Swap16(X) +#define SDL_SwapLE32(X) SDL_Swap32(X) +#define SDL_SwapLE64(X) SDL_Swap64(X) +#define SDL_SwapFloatLE(X) SDL_SwapFloat(X) +#define SDL_SwapBE16(X) (X) +#define SDL_SwapBE32(X) (X) +#define SDL_SwapBE64(X) (X) +#define SDL_SwapFloatBE(X) (X) +#endif +/* @} *//* Swap to native */ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_endian_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_error.h spring-98.0~14.04~ppa6/include/SDL2/SDL_error.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_error.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_error.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,76 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_error.h + * + * Simple error message routines for SDL. + */ + +#ifndef _SDL_error_h +#define _SDL_error_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Public functions */ +/* SDL_SetError() unconditionally returns -1. */ +extern DECLSPEC int SDLCALL SDL_SetError(const char *fmt, ...); +extern DECLSPEC const char *SDLCALL SDL_GetError(void); +extern DECLSPEC void SDLCALL SDL_ClearError(void); + +/** + * \name Internal error functions + * + * \internal + * Private error reporting function - used internally. + */ +/* @{ */ +#define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) +#define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) +#define SDL_InvalidParamError(param) SDL_SetError("Parameter '%s' is invalid", (param)) +typedef enum +{ + SDL_ENOMEM, + SDL_EFREAD, + SDL_EFWRITE, + SDL_EFSEEK, + SDL_UNSUPPORTED, + SDL_LASTERROR +} SDL_errorcode; +/* SDL_Error() unconditionally returns -1. */ +extern DECLSPEC int SDLCALL SDL_Error(SDL_errorcode code); +/* @} *//* Internal error functions */ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_error_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_events.h spring-98.0~14.04~ppa6/include/SDL2/SDL_events.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_events.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_events.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,720 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_events.h + * + * Include file for SDL event handling. + */ + +#ifndef _SDL_events_h +#define _SDL_events_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_video.h" +#include "SDL_keyboard.h" +#include "SDL_mouse.h" +#include "SDL_joystick.h" +#include "SDL_gamecontroller.h" +#include "SDL_quit.h" +#include "SDL_gesture.h" +#include "SDL_touch.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* General keyboard/mouse state definitions */ +#define SDL_RELEASED 0 +#define SDL_PRESSED 1 + +/** + * \brief The types of events that can be delivered. + */ +typedef enum +{ + SDL_FIRSTEVENT = 0, /**< Unused (do not remove) */ + + /* Application events */ + SDL_QUIT = 0x100, /**< User-requested quit */ + + /* These application events have special meaning on iOS, see README-ios.txt for details */ + SDL_APP_TERMINATING, /**< The application is being terminated by the OS + Called on iOS in applicationWillTerminate() + Called on Android in onDestroy() + */ + SDL_APP_LOWMEMORY, /**< The application is low on memory, free memory if possible. + Called on iOS in applicationDidReceiveMemoryWarning() + Called on Android in onLowMemory() + */ + SDL_APP_WILLENTERBACKGROUND, /**< The application is about to enter the background + Called on iOS in applicationWillResignActive() + Called on Android in onPause() + */ + SDL_APP_DIDENTERBACKGROUND, /**< The application did enter the background and may not get CPU for some time + Called on iOS in applicationDidEnterBackground() + Called on Android in onPause() + */ + SDL_APP_WILLENTERFOREGROUND, /**< The application is about to enter the foreground + Called on iOS in applicationWillEnterForeground() + Called on Android in onResume() + */ + SDL_APP_DIDENTERFOREGROUND, /**< The application is now interactive + Called on iOS in applicationDidBecomeActive() + Called on Android in onResume() + */ + + /* Window events */ + SDL_WINDOWEVENT = 0x200, /**< Window state change */ + SDL_SYSWMEVENT, /**< System specific event */ + + /* Keyboard events */ + SDL_KEYDOWN = 0x300, /**< Key pressed */ + SDL_KEYUP, /**< Key released */ + SDL_TEXTEDITING, /**< Keyboard text editing (composition) */ + SDL_TEXTINPUT, /**< Keyboard text input */ + + /* Mouse events */ + SDL_MOUSEMOTION = 0x400, /**< Mouse moved */ + SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */ + SDL_MOUSEBUTTONUP, /**< Mouse button released */ + SDL_MOUSEWHEEL, /**< Mouse wheel motion */ + + /* Joystick events */ + SDL_JOYAXISMOTION = 0x600, /**< Joystick axis motion */ + SDL_JOYBALLMOTION, /**< Joystick trackball motion */ + SDL_JOYHATMOTION, /**< Joystick hat position change */ + SDL_JOYBUTTONDOWN, /**< Joystick button pressed */ + SDL_JOYBUTTONUP, /**< Joystick button released */ + SDL_JOYDEVICEADDED, /**< A new joystick has been inserted into the system */ + SDL_JOYDEVICEREMOVED, /**< An opened joystick has been removed */ + + /* Game controller events */ + SDL_CONTROLLERAXISMOTION = 0x650, /**< Game controller axis motion */ + SDL_CONTROLLERBUTTONDOWN, /**< Game controller button pressed */ + SDL_CONTROLLERBUTTONUP, /**< Game controller button released */ + SDL_CONTROLLERDEVICEADDED, /**< A new Game controller has been inserted into the system */ + SDL_CONTROLLERDEVICEREMOVED, /**< An opened Game controller has been removed */ + SDL_CONTROLLERDEVICEREMAPPED, /**< The controller mapping was updated */ + + /* Touch events */ + SDL_FINGERDOWN = 0x700, + SDL_FINGERUP, + SDL_FINGERMOTION, + + /* Gesture events */ + SDL_DOLLARGESTURE = 0x800, + SDL_DOLLARRECORD, + SDL_MULTIGESTURE, + + /* Clipboard events */ + SDL_CLIPBOARDUPDATE = 0x900, /**< The clipboard changed */ + + /* Drag and drop events */ + SDL_DROPFILE = 0x1000, /**< The system requests a file open */ + + /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use, + * and should be allocated with SDL_RegisterEvents() + */ + SDL_USEREVENT = 0x8000, + + /** + * This last event is only for bounding internal arrays + */ + SDL_LASTEVENT = 0xFFFF +} SDL_EventType; + +/** + * \brief Fields shared by every event + */ +typedef struct SDL_CommonEvent +{ + Uint32 type; + Uint32 timestamp; +} SDL_CommonEvent; + +/** + * \brief Window state change event data (event.window.*) + */ +typedef struct SDL_WindowEvent +{ + Uint32 type; /**< ::SDL_WINDOWEVENT */ + Uint32 timestamp; + Uint32 windowID; /**< The associated window */ + Uint8 event; /**< ::SDL_WindowEventID */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; + Sint32 data1; /**< event dependent data */ + Sint32 data2; /**< event dependent data */ +} SDL_WindowEvent; + +/** + * \brief Keyboard button event structure (event.key.*) + */ +typedef struct SDL_KeyboardEvent +{ + Uint32 type; /**< ::SDL_KEYDOWN or ::SDL_KEYUP */ + Uint32 timestamp; + Uint32 windowID; /**< The window with keyboard focus, if any */ + Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ + Uint8 repeat; /**< Non-zero if this is a key repeat */ + Uint8 padding2; + Uint8 padding3; + SDL_Keysym keysym; /**< The key that was pressed or released */ +} SDL_KeyboardEvent; + +#define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32) +/** + * \brief Keyboard text editing event structure (event.edit.*) + */ +typedef struct SDL_TextEditingEvent +{ + Uint32 type; /**< ::SDL_TEXTEDITING */ + Uint32 timestamp; + Uint32 windowID; /**< The window with keyboard focus, if any */ + char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */ + Sint32 start; /**< The start cursor of selected editing text */ + Sint32 length; /**< The length of selected editing text */ +} SDL_TextEditingEvent; + + +#define SDL_TEXTINPUTEVENT_TEXT_SIZE (32) +/** + * \brief Keyboard text input event structure (event.text.*) + */ +typedef struct SDL_TextInputEvent +{ + Uint32 type; /**< ::SDL_TEXTINPUT */ + Uint32 timestamp; + Uint32 windowID; /**< The window with keyboard focus, if any */ + char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */ +} SDL_TextInputEvent; + +/** + * \brief Mouse motion event structure (event.motion.*) + */ +typedef struct SDL_MouseMotionEvent +{ + Uint32 type; /**< ::SDL_MOUSEMOTION */ + Uint32 timestamp; + Uint32 windowID; /**< The window with mouse focus, if any */ + Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ + Uint32 state; /**< The current button state */ + Sint32 x; /**< X coordinate, relative to window */ + Sint32 y; /**< Y coordinate, relative to window */ + Sint32 xrel; /**< The relative motion in the X direction */ + Sint32 yrel; /**< The relative motion in the Y direction */ +} SDL_MouseMotionEvent; + +/** + * \brief Mouse button event structure (event.button.*) + */ +typedef struct SDL_MouseButtonEvent +{ + Uint32 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */ + Uint32 timestamp; + Uint32 windowID; /**< The window with mouse focus, if any */ + Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ + Uint8 button; /**< The mouse button index */ + Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ + Uint8 padding1; + Uint8 padding2; + Sint32 x; /**< X coordinate, relative to window */ + Sint32 y; /**< Y coordinate, relative to window */ +} SDL_MouseButtonEvent; + +/** + * \brief Mouse wheel event structure (event.wheel.*) + */ +typedef struct SDL_MouseWheelEvent +{ + Uint32 type; /**< ::SDL_MOUSEWHEEL */ + Uint32 timestamp; + Uint32 windowID; /**< The window with mouse focus, if any */ + Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ + Sint32 x; /**< The amount scrolled horizontally */ + Sint32 y; /**< The amount scrolled vertically */ +} SDL_MouseWheelEvent; + +/** + * \brief Joystick axis motion event structure (event.jaxis.*) + */ +typedef struct SDL_JoyAxisEvent +{ + Uint32 type; /**< ::SDL_JOYAXISMOTION */ + Uint32 timestamp; + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 axis; /**< The joystick axis index */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; + Sint16 value; /**< The axis value (range: -32768 to 32767) */ + Uint16 padding4; +} SDL_JoyAxisEvent; + +/** + * \brief Joystick trackball motion event structure (event.jball.*) + */ +typedef struct SDL_JoyBallEvent +{ + Uint32 type; /**< ::SDL_JOYBALLMOTION */ + Uint32 timestamp; + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 ball; /**< The joystick trackball index */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; + Sint16 xrel; /**< The relative motion in the X direction */ + Sint16 yrel; /**< The relative motion in the Y direction */ +} SDL_JoyBallEvent; + +/** + * \brief Joystick hat position change event structure (event.jhat.*) + */ +typedef struct SDL_JoyHatEvent +{ + Uint32 type; /**< ::SDL_JOYHATMOTION */ + Uint32 timestamp; + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 hat; /**< The joystick hat index */ + Uint8 value; /**< The hat position value. + * \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP + * \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT + * \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN + * + * Note that zero means the POV is centered. + */ + Uint8 padding1; + Uint8 padding2; +} SDL_JoyHatEvent; + +/** + * \brief Joystick button event structure (event.jbutton.*) + */ +typedef struct SDL_JoyButtonEvent +{ + Uint32 type; /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */ + Uint32 timestamp; + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 button; /**< The joystick button index */ + Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ + Uint8 padding1; + Uint8 padding2; +} SDL_JoyButtonEvent; + +/** + * \brief Joystick device event structure (event.jdevice.*) + */ +typedef struct SDL_JoyDeviceEvent +{ + Uint32 type; /**< ::SDL_JOYDEVICEADDED or ::SDL_JOYDEVICEREMOVED */ + Uint32 timestamp; + Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED event */ +} SDL_JoyDeviceEvent; + + +/** + * \brief Game controller axis motion event structure (event.caxis.*) + */ +typedef struct SDL_ControllerAxisEvent +{ + Uint32 type; /**< ::SDL_CONTROLLERAXISMOTION */ + Uint32 timestamp; + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 axis; /**< The controller axis (SDL_GameControllerAxis) */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; + Sint16 value; /**< The axis value (range: -32768 to 32767) */ + Uint16 padding4; +} SDL_ControllerAxisEvent; + + +/** + * \brief Game controller button event structure (event.cbutton.*) + */ +typedef struct SDL_ControllerButtonEvent +{ + Uint32 type; /**< ::SDL_CONTROLLERBUTTONDOWN or ::SDL_CONTROLLERBUTTONUP */ + Uint32 timestamp; + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 button; /**< The controller button (SDL_GameControllerButton) */ + Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ + Uint8 padding1; + Uint8 padding2; +} SDL_ControllerButtonEvent; + + +/** + * \brief Controller device event structure (event.cdevice.*) + */ +typedef struct SDL_ControllerDeviceEvent +{ + Uint32 type; /**< ::SDL_CONTROLLERDEVICEADDED, ::SDL_CONTROLLERDEVICEREMOVED, or ::SDL_CONTROLLERDEVICEREMAPPED */ + Uint32 timestamp; + Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */ +} SDL_ControllerDeviceEvent; + + +/** + * \brief Touch finger event structure (event.tfinger.*) + */ +typedef struct SDL_TouchFingerEvent +{ + Uint32 type; /**< ::SDL_FINGERMOTION or ::SDL_FINGERDOWN or ::SDL_FINGERUP */ + Uint32 timestamp; + SDL_TouchID touchId; /**< The touch device id */ + SDL_FingerID fingerId; + float x; /**< Normalized in the range 0...1 */ + float y; /**< Normalized in the range 0...1 */ + float dx; /**< Normalized in the range 0...1 */ + float dy; /**< Normalized in the range 0...1 */ + float pressure; /**< Normalized in the range 0...1 */ +} SDL_TouchFingerEvent; + + +/** + * \brief Multiple Finger Gesture Event (event.mgesture.*) + */ +typedef struct SDL_MultiGestureEvent +{ + Uint32 type; /**< ::SDL_MULTIGESTURE */ + Uint32 timestamp; + SDL_TouchID touchId; /**< The touch device index */ + float dTheta; + float dDist; + float x; + float y; + Uint16 numFingers; + Uint16 padding; +} SDL_MultiGestureEvent; + + +/** + * \brief Dollar Gesture Event (event.dgesture.*) + */ +typedef struct SDL_DollarGestureEvent +{ + Uint32 type; /**< ::SDL_DOLLARGESTURE */ + Uint32 timestamp; + SDL_TouchID touchId; /**< The touch device id */ + SDL_GestureID gestureId; + Uint32 numFingers; + float error; + float x; /**< Normalized center of gesture */ + float y; /**< Normalized center of gesture */ +} SDL_DollarGestureEvent; + + +/** + * \brief An event used to request a file open by the system (event.drop.*) + * This event is disabled by default, you can enable it with SDL_EventState() + * \note If you enable this event, you must free the filename in the event. + */ +typedef struct SDL_DropEvent +{ + Uint32 type; /**< ::SDL_DROPFILE */ + Uint32 timestamp; + char *file; /**< The file name, which should be freed with SDL_free() */ +} SDL_DropEvent; + + +/** + * \brief The "quit requested" event + */ +typedef struct SDL_QuitEvent +{ + Uint32 type; /**< ::SDL_QUIT */ + Uint32 timestamp; +} SDL_QuitEvent; + +/** + * \brief OS Specific event + */ +typedef struct SDL_OSEvent +{ + Uint32 type; /**< ::SDL_QUIT */ + Uint32 timestamp; +} SDL_OSEvent; + +/** + * \brief A user-defined event type (event.user.*) + */ +typedef struct SDL_UserEvent +{ + Uint32 type; /**< ::SDL_USEREVENT through ::SDL_LASTEVENT-1 */ + Uint32 timestamp; + Uint32 windowID; /**< The associated window if any */ + Sint32 code; /**< User defined event code */ + void *data1; /**< User defined data pointer */ + void *data2; /**< User defined data pointer */ +} SDL_UserEvent; + + +struct SDL_SysWMmsg; +typedef struct SDL_SysWMmsg SDL_SysWMmsg; + +/** + * \brief A video driver dependent system event (event.syswm.*) + * This event is disabled by default, you can enable it with SDL_EventState() + * + * \note If you want to use this event, you should include SDL_syswm.h. + */ +typedef struct SDL_SysWMEvent +{ + Uint32 type; /**< ::SDL_SYSWMEVENT */ + Uint32 timestamp; + SDL_SysWMmsg *msg; /**< driver dependent data, defined in SDL_syswm.h */ +} SDL_SysWMEvent; + +/** + * \brief General event structure + */ +typedef union SDL_Event +{ + Uint32 type; /**< Event type, shared with all events */ + SDL_CommonEvent common; /**< Common event data */ + SDL_WindowEvent window; /**< Window event data */ + SDL_KeyboardEvent key; /**< Keyboard event data */ + SDL_TextEditingEvent edit; /**< Text editing event data */ + SDL_TextInputEvent text; /**< Text input event data */ + SDL_MouseMotionEvent motion; /**< Mouse motion event data */ + SDL_MouseButtonEvent button; /**< Mouse button event data */ + SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */ + SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */ + SDL_JoyBallEvent jball; /**< Joystick ball event data */ + SDL_JoyHatEvent jhat; /**< Joystick hat event data */ + SDL_JoyButtonEvent jbutton; /**< Joystick button event data */ + SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */ + SDL_ControllerAxisEvent caxis; /**< Game Controller axis event data */ + SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */ + SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */ + SDL_QuitEvent quit; /**< Quit request event data */ + SDL_UserEvent user; /**< Custom event data */ + SDL_SysWMEvent syswm; /**< System dependent window event data */ + SDL_TouchFingerEvent tfinger; /**< Touch finger event data */ + SDL_MultiGestureEvent mgesture; /**< Gesture event data */ + SDL_DollarGestureEvent dgesture; /**< Gesture event data */ + SDL_DropEvent drop; /**< Drag and drop event data */ + + /* This is necessary for ABI compatibility between Visual C++ and GCC + Visual C++ will respect the push pack pragma and use 52 bytes for + this structure, and GCC will use the alignment of the largest datatype + within the union, which is 8 bytes. + + So... we'll add padding to force the size to be 56 bytes for both. + */ + Uint8 padding[56]; +} SDL_Event; + + +/* Function prototypes */ + +/** + * Pumps the event loop, gathering events from the input devices. + * + * This function updates the event queue and internal input device state. + * + * This should only be run in the thread that sets the video mode. + */ +extern DECLSPEC void SDLCALL SDL_PumpEvents(void); + +/* @{ */ +typedef enum +{ + SDL_ADDEVENT, + SDL_PEEKEVENT, + SDL_GETEVENT +} SDL_eventaction; + +/** + * Checks the event queue for messages and optionally returns them. + * + * If \c action is ::SDL_ADDEVENT, up to \c numevents events will be added to + * the back of the event queue. + * + * If \c action is ::SDL_PEEKEVENT, up to \c numevents events at the front + * of the event queue, within the specified minimum and maximum type, + * will be returned and will not be removed from the queue. + * + * If \c action is ::SDL_GETEVENT, up to \c numevents events at the front + * of the event queue, within the specified minimum and maximum type, + * will be returned and will be removed from the queue. + * + * \return The number of events actually stored, or -1 if there was an error. + * + * This function is thread-safe. + */ +extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents, + SDL_eventaction action, + Uint32 minType, Uint32 maxType); +/* @} */ + +/** + * Checks to see if certain event types are in the event queue. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type); +extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType); + +/** + * This function clears events from the event queue + */ +extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type); +extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType); + +/** + * \brief Polls for currently pending events. + * + * \return 1 if there are any pending events, or 0 if there are none available. + * + * \param event If not NULL, the next event is removed from the queue and + * stored in that area. + */ +extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event); + +/** + * \brief Waits indefinitely for the next available event. + * + * \return 1, or 0 if there was an error while waiting for events. + * + * \param event If not NULL, the next event is removed from the queue and + * stored in that area. + */ +extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event); + +/** + * \brief Waits until the specified timeout (in milliseconds) for the next + * available event. + * + * \return 1, or 0 if there was an error while waiting for events. + * + * \param event If not NULL, the next event is removed from the queue and + * stored in that area. + * \param timeout The timeout (in milliseconds) to wait for next event. + */ +extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event, + int timeout); + +/** + * \brief Add an event to the event queue. + * + * \return 1 on success, 0 if the event was filtered, or -1 if the event queue + * was full or there was some other error. + */ +extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event); + +typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event); + +/** + * Sets up a filter to process all events before they change internal state and + * are posted to the internal event queue. + * + * The filter is prototyped as: + * \code + * int SDL_EventFilter(void *userdata, SDL_Event * event); + * \endcode + * + * If the filter returns 1, then the event will be added to the internal queue. + * If it returns 0, then the event will be dropped from the queue, but the + * internal state will still be updated. This allows selective filtering of + * dynamically arriving events. + * + * \warning Be very careful of what you do in the event filter function, as + * it may run in a different thread! + * + * There is one caveat when dealing with the ::SDL_QuitEvent event type. The + * event filter is only called when the window manager desires to close the + * application window. If the event filter returns 1, then the window will + * be closed, otherwise the window will remain open if possible. + * + * If the quit event is generated by an interrupt signal, it will bypass the + * internal queue and be delivered to the application at the next event poll. + */ +extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter, + void *userdata); + +/** + * Return the current event filter - can be used to "chain" filters. + * If there is no event filter set, this function returns SDL_FALSE. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter, + void **userdata); + +/** + * Add a function which is called when an event is added to the queue. + */ +extern DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter, + void *userdata); + +/** + * Remove an event watch function added with SDL_AddEventWatch() + */ +extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter, + void *userdata); + +/** + * Run the filter function on the current event queue, removing any + * events for which the filter returns 0. + */ +extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter, + void *userdata); + +/* @{ */ +#define SDL_QUERY -1 +#define SDL_IGNORE 0 +#define SDL_DISABLE 0 +#define SDL_ENABLE 1 + +/** + * This function allows you to set the state of processing certain events. + * - If \c state is set to ::SDL_IGNORE, that event will be automatically + * dropped from the event queue and will not event be filtered. + * - If \c state is set to ::SDL_ENABLE, that event will be processed + * normally. + * - If \c state is set to ::SDL_QUERY, SDL_EventState() will return the + * current processing state of the specified event. + */ +extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state); +/* @} */ +#define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY) + +/** + * This function allocates a set of user-defined events, and returns + * the beginning event number for that set of events. + * + * If there aren't enough user-defined events left, this function + * returns (Uint32)-1 + */ +extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_events_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_filesystem.h spring-98.0~14.04~ppa6/include/SDL2/SDL_filesystem.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_filesystem.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_filesystem.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,136 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_filesystem.h + * + * \brief Include file for filesystem SDL API functions + */ + +#ifndef _SDL_filesystem_h +#define _SDL_filesystem_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Get the path where the application resides. + * + * Get the "base path". This is the directory where the application was run + * from, which is probably the installation directory, and may or may not + * be the process's current working directory. + * + * This returns an absolute path in UTF-8 encoding, and is guaranteed to + * end with a path separator ('\\' on Windows, '/' most other places). + * + * The pointer returned by this function is owned by you. Please call + * SDL_free() on the pointer when you are done with it, or it will be a + * memory leak. This is not necessarily a fast call, though, so you should + * call this once near startup and save the string if you need it. + * + * Some platforms can't determine the application's path, and on other + * platforms, this might be meaningless. In such cases, this function will + * return NULL. + * + * \return String of base dir in UTF-8 encoding, or NULL on error. + * + * \sa SDL_GetPrefPath + */ +extern DECLSPEC char *SDLCALL SDL_GetBasePath(void); + +/** + * \brief Get the user-and-app-specific path where files can be written. + * + * Get the "pref dir". This is meant to be where users can write personal + * files (preferences and save games, etc) that are specific to your + * application. This directory is unique per user, per application. + * + * This function will decide the appropriate location in the native filesystem, + * create the directory if necessary, and return a string of the absolute + * path to the directory in UTF-8 encoding. + * + * On Windows, the string might look like: + * "C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\" + * + * On Linux, the string might look like: + * "/home/bob/.local/share/My Program Name/" + * + * On Mac OS X, the string might look like: + * "/Users/bob/Library/Application Support/My Program Name/" + * + * (etc.) + * + * You specify the name of your organization (if it's not a real organization, + * your name or an Internet domain you own might do) and the name of your + * application. These should be untranslated proper names. + * + * Both the org and app strings may become part of a directory name, so + * please follow these rules: + * + * - Try to use the same org string (including case-sensitivity) for + * all your applications that use this function. + * - Always use a unique app string for each one, and make sure it never + * changes for an app once you've decided on it. + * - Unicode characters are legal, as long as it's UTF-8 encoded, but... + * - ...only use letters, numbers, and spaces. Avoid punctuation like + * "Game Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient. + * + * This returns an absolute path in UTF-8 encoding, and is guaranteed to + * end with a path separator ('\\' on Windows, '/' most other places). + * + * The pointer returned by this function is owned by you. Please call + * SDL_free() on the pointer when you are done with it, or it will be a + * memory leak. This is not necessarily a fast call, though, so you should + * call this once near startup and save the string if you need it. + * + * You should assume the path returned by this function is the only safe + * place to write files (and that SDL_GetBasePath(), while it might be + * writable, or even the parent of the returned path, aren't where you + * should be writing things). + * + * Some platforms can't determine the pref path, and on other + * platforms, this might be meaningless. In such cases, this function will + * return NULL. + * + * \param org The name of your organization. + * \param app The name of your application. + * \return UTF-8 string of user dir in platform-dependent notation. NULL + * if there's a problem (creating directory failed, etc). + * + * \sa SDL_GetBasePath + */ +extern DECLSPEC char *SDLCALL SDL_GetPrefPath(const char *org, const char *app); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_system_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_gamecontroller.h spring-98.0~14.04~ppa6/include/SDL2/SDL_gamecontroller.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_gamecontroller.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_gamecontroller.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,298 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_gamecontroller.h + * + * Include file for SDL game controller event handling + */ + +#ifndef _SDL_gamecontroller_h +#define _SDL_gamecontroller_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_joystick.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \file SDL_gamecontroller.h + * + * In order to use these functions, SDL_Init() must have been called + * with the ::SDL_INIT_JOYSTICK flag. This causes SDL to scan the system + * for game controllers, and load appropriate drivers. + * + * If you would like to receive controller updates while the application + * is in the background, you should set the following hint before calling + * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS + */ + +/* The gamecontroller structure used to identify an SDL game controller */ +struct _SDL_GameController; +typedef struct _SDL_GameController SDL_GameController; + + +typedef enum +{ + SDL_CONTROLLER_BINDTYPE_NONE = 0, + SDL_CONTROLLER_BINDTYPE_BUTTON, + SDL_CONTROLLER_BINDTYPE_AXIS, + SDL_CONTROLLER_BINDTYPE_HAT +} SDL_GameControllerBindType; + +/** + * Get the SDL joystick layer binding for this controller button/axis mapping + */ +typedef struct SDL_GameControllerButtonBind +{ + SDL_GameControllerBindType bindType; + union + { + int button; + int axis; + struct { + int hat; + int hat_mask; + } hat; + } value; + +} SDL_GameControllerButtonBind; + + +/** + * To count the number of game controllers in the system for the following: + * int nJoysticks = SDL_NumJoysticks(); + * int nGameControllers = 0; + * for ( int i = 0; i < nJoysticks; i++ ) { + * if ( SDL_IsGameController(i) ) { + * nGameControllers++; + * } + * } + * + * Using the SDL_HINT_GAMECONTROLLERCONFIG hint or the SDL_GameControllerAddMapping you can add support for controllers SDL is unaware of or cause an existing controller to have a different binding. The format is: + * guid,name,mappings + * + * Where GUID is the string value from SDL_JoystickGetGUIDString(), name is the human readable string for the device and mappings are controller mappings to joystick ones. + * Under Windows there is a reserved GUID of "xinput" that covers any XInput devices. + * The mapping format for joystick is: + * bX - a joystick button, index X + * hX.Y - hat X with value Y + * aX - axis X of the joystick + * Buttons can be used as a controller axis and vice versa. + * + * This string shows an example of a valid mapping for a controller + * "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7", + * + */ + +/** + * Add or update an existing mapping configuration + * + * \return 1 if mapping is added, 0 if updated, -1 on error + */ +extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping( const char* mappingString ); + +/** + * Get a mapping string for a GUID + * + * \return the mapping string. Must be freed with SDL_free. Returns NULL if no mapping is available + */ +extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID( SDL_JoystickGUID guid ); + +/** + * Get a mapping string for an open GameController + * + * \return the mapping string. Must be freed with SDL_free. Returns NULL if no mapping is available + */ +extern DECLSPEC char * SDLCALL SDL_GameControllerMapping( SDL_GameController * gamecontroller ); + +/** + * Is the joystick on this index supported by the game controller interface? + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index); + + +/** + * Get the implementation dependent name of a game controller. + * This can be called before any controllers are opened. + * If no name can be found, this function returns NULL. + */ +extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index); + +/** + * Open a game controller for use. + * The index passed as an argument refers to the N'th game controller on the system. + * This index is the value which will identify this controller in future controller + * events. + * + * \return A controller identifier, or NULL if an error occurred. + */ +extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_index); + +/** + * Return the name for this currently opened controller + */ +extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller); + +/** + * Returns SDL_TRUE if the controller has been opened and currently connected, + * or SDL_FALSE if it has not. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerGetAttached(SDL_GameController *gamecontroller); + +/** + * Get the underlying joystick object used by a controller + */ +extern DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameController *gamecontroller); + +/** + * Enable/disable controller event polling. + * + * If controller events are disabled, you must call SDL_GameControllerUpdate() + * yourself and check the state of the controller when you want controller + * information. + * + * The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE. + */ +extern DECLSPEC int SDLCALL SDL_GameControllerEventState(int state); + +/** + * Update the current state of the open game controllers. + * + * This is called automatically by the event loop if any game controller + * events are enabled. + */ +extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void); + + +/** + * The list of axes available from a controller + */ +typedef enum +{ + SDL_CONTROLLER_AXIS_INVALID = -1, + SDL_CONTROLLER_AXIS_LEFTX, + SDL_CONTROLLER_AXIS_LEFTY, + SDL_CONTROLLER_AXIS_RIGHTX, + SDL_CONTROLLER_AXIS_RIGHTY, + SDL_CONTROLLER_AXIS_TRIGGERLEFT, + SDL_CONTROLLER_AXIS_TRIGGERRIGHT, + SDL_CONTROLLER_AXIS_MAX +} SDL_GameControllerAxis; + +/** + * turn this string into a axis mapping + */ +extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromString(const char *pchString); + +/** + * turn this axis enum into a string mapping + */ +extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis); + +/** + * Get the SDL joystick layer binding for this controller button mapping + */ +extern DECLSPEC SDL_GameControllerButtonBind SDLCALL +SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller, + SDL_GameControllerAxis axis); + +/** + * Get the current state of an axis control on a game controller. + * + * The state is a value ranging from -32768 to 32767. + * + * The axis indices start at index 0. + */ +extern DECLSPEC Sint16 SDLCALL +SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, + SDL_GameControllerAxis axis); + +/** + * The list of buttons available from a controller + */ +typedef enum +{ + SDL_CONTROLLER_BUTTON_INVALID = -1, + SDL_CONTROLLER_BUTTON_A, + SDL_CONTROLLER_BUTTON_B, + SDL_CONTROLLER_BUTTON_X, + SDL_CONTROLLER_BUTTON_Y, + SDL_CONTROLLER_BUTTON_BACK, + SDL_CONTROLLER_BUTTON_GUIDE, + SDL_CONTROLLER_BUTTON_START, + SDL_CONTROLLER_BUTTON_LEFTSTICK, + SDL_CONTROLLER_BUTTON_RIGHTSTICK, + SDL_CONTROLLER_BUTTON_LEFTSHOULDER, + SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, + SDL_CONTROLLER_BUTTON_DPAD_UP, + SDL_CONTROLLER_BUTTON_DPAD_DOWN, + SDL_CONTROLLER_BUTTON_DPAD_LEFT, + SDL_CONTROLLER_BUTTON_DPAD_RIGHT, + SDL_CONTROLLER_BUTTON_MAX +} SDL_GameControllerButton; + +/** + * turn this string into a button mapping + */ +extern DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFromString(const char *pchString); + +/** + * turn this button enum into a string mapping + */ +extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForButton(SDL_GameControllerButton button); + +/** + * Get the SDL joystick layer binding for this controller button mapping + */ +extern DECLSPEC SDL_GameControllerButtonBind SDLCALL +SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller, + SDL_GameControllerButton button); + + +/** + * Get the current state of a button on a game controller. + * + * The button indices start at index 0. + */ +extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller, + SDL_GameControllerButton button); + +/** + * Close a controller previously opened with SDL_GameControllerOpen(). + */ +extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecontroller); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_gamecontroller_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_gesture.h spring-98.0~14.04~ppa6/include/SDL2/SDL_gesture.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_gesture.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_gesture.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,87 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_gesture.h + * + * Include file for SDL gesture event handling. + */ + +#ifndef _SDL_gesture_h +#define _SDL_gesture_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_video.h" + +#include "SDL_touch.h" + + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +typedef Sint64 SDL_GestureID; + +/* Function prototypes */ + +/** + * \brief Begin Recording a gesture on the specified touch, or all touches (-1) + * + * + */ +extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId); + + +/** + * \brief Save all currently loaded Dollar Gesture templates + * + * + */ +extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *src); + +/** + * \brief Save a currently loaded Dollar Gesture template + * + * + */ +extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *src); + + +/** + * \brief Load Dollar Gesture templates from a file + * + * + */ +extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_gesture_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL.h spring-98.0~14.04~ppa6/include/SDL2/SDL.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,163 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL.h + * + * Main include header for the SDL library + */ + +/** + * \mainpage Simple DirectMedia Layer (SDL) + * + * http://www.libsdl.org/ + * + * \section intro_sec Introduction + * + * Simple DirectMedia Layer is a cross-platform development library designed + * to provide low level access to audio, keyboard, mouse, joystick, and + * graphics hardware via OpenGL and Direct3D. It is used by video playback + * software, emulators, and popular games including Valve's award winning + * catalog and many Humble Bundle games. + * + * SDL officially supports Windows, Mac OS X, Linux, iOS, and Android. + * Support for other platforms may be found in the source code. + * + * SDL is written in C, works natively with C++, and there are bindings + * available for several other languages, including C# and Python. + * + * This library is distributed under the zlib license, which can be found + * in the file "COPYING.txt". + * + * The best way to learn how to use SDL is to check out the header files in + * the "include" subdirectory and the programs in the "test" subdirectory. + * The header files and test programs are well commented and always up to date. + * More documentation and FAQs are available online at: + * http://wiki.libsdl.org/ + * + * If you need help with the library, or just want to discuss SDL related + * issues, you can join the developers mailing list: + * http://www.libsdl.org/mailing-list.php + * + * Enjoy! + * Sam Lantinga (slouken@libsdl.org) + */ + +#ifndef _SDL_H +#define _SDL_H + +#include "SDL_main.h" +#include "SDL_stdinc.h" +#include "SDL_assert.h" +#include "SDL_atomic.h" +#include "SDL_audio.h" +#include "SDL_clipboard.h" +#include "SDL_cpuinfo.h" +#include "SDL_endian.h" +#include "SDL_error.h" +#include "SDL_events.h" +#include "SDL_filesystem.h" +#include "SDL_joystick.h" +#include "SDL_gamecontroller.h" +#include "SDL_haptic.h" +#include "SDL_hints.h" +#include "SDL_loadso.h" +#include "SDL_log.h" +#include "SDL_messagebox.h" +#include "SDL_mutex.h" +#include "SDL_power.h" +#include "SDL_render.h" +#include "SDL_rwops.h" +#include "SDL_system.h" +#include "SDL_thread.h" +#include "SDL_timer.h" +#include "SDL_version.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* As of version 0.5, SDL is loaded dynamically into the application */ + +/** + * \name SDL_INIT_* + * + * These are the flags which may be passed to SDL_Init(). You should + * specify the subsystems which you will be using in your application. + */ +/* @{ */ +#define SDL_INIT_TIMER 0x00000001 +#define SDL_INIT_AUDIO 0x00000010 +#define SDL_INIT_VIDEO 0x00000020 /**< SDL_INIT_VIDEO implies SDL_INIT_EVENTS */ +#define SDL_INIT_JOYSTICK 0x00000200 /**< SDL_INIT_JOYSTICK implies SDL_INIT_EVENTS */ +#define SDL_INIT_HAPTIC 0x00001000 +#define SDL_INIT_GAMECONTROLLER 0x00002000 /**< SDL_INIT_GAMECONTROLLER implies SDL_INIT_JOYSTICK */ +#define SDL_INIT_EVENTS 0x00004000 +#define SDL_INIT_NOPARACHUTE 0x00100000 /**< Don't catch fatal signals */ +#define SDL_INIT_EVERYTHING ( \ + SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \ + SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER \ + ) +/* @} */ + +/** + * This function initializes the subsystems specified by \c flags + * Unless the ::SDL_INIT_NOPARACHUTE flag is set, it will install cleanup + * signal handlers for some commonly ignored fatal signals (like SIGSEGV). + */ +extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags); + +/** + * This function initializes specific SDL subsystems + */ +extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags); + +/** + * This function cleans up specific SDL subsystems + */ +extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags); + +/** + * This function returns a mask of the specified subsystems which have + * previously been initialized. + * + * If \c flags is 0, it returns a mask of all initialized subsystems. + */ +extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags); + +/** + * This function cleans up all initialized subsystems. You should + * call it upon all exit conditions. + */ +extern DECLSPEC void SDLCALL SDL_Quit(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_H */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_haptic.h spring-98.0~14.04~ppa6/include/SDL2/SDL_haptic.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_haptic.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_haptic.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,1225 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_haptic.h + * + * \brief The SDL Haptic subsystem allows you to control haptic (force feedback) + * devices. + * + * The basic usage is as follows: + * - Initialize the Subsystem (::SDL_INIT_HAPTIC). + * - Open a Haptic Device. + * - SDL_HapticOpen() to open from index. + * - SDL_HapticOpenFromJoystick() to open from an existing joystick. + * - Create an effect (::SDL_HapticEffect). + * - Upload the effect with SDL_HapticNewEffect(). + * - Run the effect with SDL_HapticRunEffect(). + * - (optional) Free the effect with SDL_HapticDestroyEffect(). + * - Close the haptic device with SDL_HapticClose(). + * + * \par Simple rumble example: + * \code + * SDL_Haptic *haptic; + * + * // Open the device + * haptic = SDL_HapticOpen( 0 ); + * if (haptic == NULL) + * return -1; + * + * // Initialize simple rumble + * if (SDL_HapticRumbleInit( haptic ) != 0) + * return -1; + * + * // Play effect at 50% strength for 2 seconds + * if (SDL_HapticRumblePlay( haptic, 0.5, 2000 ) != 0) + * return -1; + * SDL_Delay( 2000 ); + * + * // Clean up + * SDL_HapticClose( haptic ); + * \endcode + * + * \par Complete example: + * \code + * int test_haptic( SDL_Joystick * joystick ) { + * SDL_Haptic *haptic; + * SDL_HapticEffect effect; + * int effect_id; + * + * // Open the device + * haptic = SDL_HapticOpenFromJoystick( joystick ); + * if (haptic == NULL) return -1; // Most likely joystick isn't haptic + * + * // See if it can do sine waves + * if ((SDL_HapticQuery(haptic) & SDL_HAPTIC_SINE)==0) { + * SDL_HapticClose(haptic); // No sine effect + * return -1; + * } + * + * // Create the effect + * memset( &effect, 0, sizeof(SDL_HapticEffect) ); // 0 is safe default + * effect.type = SDL_HAPTIC_SINE; + * effect.periodic.direction.type = SDL_HAPTIC_POLAR; // Polar coordinates + * effect.periodic.direction.dir[0] = 18000; // Force comes from south + * effect.periodic.period = 1000; // 1000 ms + * effect.periodic.magnitude = 20000; // 20000/32767 strength + * effect.periodic.length = 5000; // 5 seconds long + * effect.periodic.attack_length = 1000; // Takes 1 second to get max strength + * effect.periodic.fade_length = 1000; // Takes 1 second to fade away + * + * // Upload the effect + * effect_id = SDL_HapticNewEffect( haptic, &effect ); + * + * // Test the effect + * SDL_HapticRunEffect( haptic, effect_id, 1 ); + * SDL_Delay( 5000); // Wait for the effect to finish + * + * // We destroy the effect, although closing the device also does this + * SDL_HapticDestroyEffect( haptic, effect_id ); + * + * // Close the device + * SDL_HapticClose(haptic); + * + * return 0; // Success + * } + * \endcode + * + * You can also find out more information on my blog: + * http://bobbens.dyndns.org/journal/2010/sdl_haptic/ + * + * \author Edgar Simo Serra + */ + +#ifndef _SDL_haptic_h +#define _SDL_haptic_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_joystick.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * \typedef SDL_Haptic + * + * \brief The haptic structure used to identify an SDL haptic. + * + * \sa SDL_HapticOpen + * \sa SDL_HapticOpenFromJoystick + * \sa SDL_HapticClose + */ +struct _SDL_Haptic; +typedef struct _SDL_Haptic SDL_Haptic; + + +/** + * \name Haptic features + * + * Different haptic features a device can have. + */ +/* @{ */ + +/** + * \name Haptic effects + */ +/* @{ */ + +/** + * \brief Constant effect supported. + * + * Constant haptic effect. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_CONSTANT (1<<0) + +/** + * \brief Sine wave effect supported. + * + * Periodic haptic effect that simulates sine waves. + * + * \sa SDL_HapticPeriodic + */ +#define SDL_HAPTIC_SINE (1<<1) + +/** + * \brief Left/Right effect supported. + * + * Haptic effect for direct control over high/low frequency motors. + * + * \sa SDL_HapticLeftRight + * \warning this value was SDL_HAPTIC_SQUARE right before 2.0.0 shipped. Sorry, + * we ran out of bits, and this is important for XInput devices. + */ +#define SDL_HAPTIC_LEFTRIGHT (1<<2) + +/* !!! FIXME: put this back when we have more bits in 2.1 */ +/* #define SDL_HAPTIC_SQUARE (1<<2) */ + +/** + * \brief Triangle wave effect supported. + * + * Periodic haptic effect that simulates triangular waves. + * + * \sa SDL_HapticPeriodic + */ +#define SDL_HAPTIC_TRIANGLE (1<<3) + +/** + * \brief Sawtoothup wave effect supported. + * + * Periodic haptic effect that simulates saw tooth up waves. + * + * \sa SDL_HapticPeriodic + */ +#define SDL_HAPTIC_SAWTOOTHUP (1<<4) + +/** + * \brief Sawtoothdown wave effect supported. + * + * Periodic haptic effect that simulates saw tooth down waves. + * + * \sa SDL_HapticPeriodic + */ +#define SDL_HAPTIC_SAWTOOTHDOWN (1<<5) + +/** + * \brief Ramp effect supported. + * + * Ramp haptic effect. + * + * \sa SDL_HapticRamp + */ +#define SDL_HAPTIC_RAMP (1<<6) + +/** + * \brief Spring effect supported - uses axes position. + * + * Condition haptic effect that simulates a spring. Effect is based on the + * axes position. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_SPRING (1<<7) + +/** + * \brief Damper effect supported - uses axes velocity. + * + * Condition haptic effect that simulates dampening. Effect is based on the + * axes velocity. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_DAMPER (1<<8) + +/** + * \brief Inertia effect supported - uses axes acceleration. + * + * Condition haptic effect that simulates inertia. Effect is based on the axes + * acceleration. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_INERTIA (1<<9) + +/** + * \brief Friction effect supported - uses axes movement. + * + * Condition haptic effect that simulates friction. Effect is based on the + * axes movement. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_FRICTION (1<<10) + +/** + * \brief Custom effect is supported. + * + * User defined custom haptic effect. + */ +#define SDL_HAPTIC_CUSTOM (1<<11) + +/* @} *//* Haptic effects */ + +/* These last few are features the device has, not effects */ + +/** + * \brief Device can set global gain. + * + * Device supports setting the global gain. + * + * \sa SDL_HapticSetGain + */ +#define SDL_HAPTIC_GAIN (1<<12) + +/** + * \brief Device can set autocenter. + * + * Device supports setting autocenter. + * + * \sa SDL_HapticSetAutocenter + */ +#define SDL_HAPTIC_AUTOCENTER (1<<13) + +/** + * \brief Device can be queried for effect status. + * + * Device can be queried for effect status. + * + * \sa SDL_HapticGetEffectStatus + */ +#define SDL_HAPTIC_STATUS (1<<14) + +/** + * \brief Device can be paused. + * + * \sa SDL_HapticPause + * \sa SDL_HapticUnpause + */ +#define SDL_HAPTIC_PAUSE (1<<15) + + +/** + * \name Direction encodings + */ +/* @{ */ + +/** + * \brief Uses polar coordinates for the direction. + * + * \sa SDL_HapticDirection + */ +#define SDL_HAPTIC_POLAR 0 + +/** + * \brief Uses cartesian coordinates for the direction. + * + * \sa SDL_HapticDirection + */ +#define SDL_HAPTIC_CARTESIAN 1 + +/** + * \brief Uses spherical coordinates for the direction. + * + * \sa SDL_HapticDirection + */ +#define SDL_HAPTIC_SPHERICAL 2 + +/* @} *//* Direction encodings */ + +/* @} *//* Haptic features */ + +/* + * Misc defines. + */ + +/** + * \brief Used to play a device an infinite number of times. + * + * \sa SDL_HapticRunEffect + */ +#define SDL_HAPTIC_INFINITY 4294967295U + + +/** + * \brief Structure that represents a haptic direction. + * + * Directions can be specified by: + * - ::SDL_HAPTIC_POLAR : Specified by polar coordinates. + * - ::SDL_HAPTIC_CARTESIAN : Specified by cartesian coordinates. + * - ::SDL_HAPTIC_SPHERICAL : Specified by spherical coordinates. + * + * Cardinal directions of the haptic device are relative to the positioning + * of the device. North is considered to be away from the user. + * + * The following diagram represents the cardinal directions: + * \verbatim + .--. + |__| .-------. + |=.| |.-----.| + |--| || || + | | |'-----'| + |__|~')_____(' + [ COMPUTER ] + + + North (0,-1) + ^ + | + | + (1,0) West <----[ HAPTIC ]----> East (-1,0) + | + | + v + South (0,1) + + + [ USER ] + \|||/ + (o o) + ---ooO-(_)-Ooo--- + \endverbatim + * + * If type is ::SDL_HAPTIC_POLAR, direction is encoded by hundredths of a + * degree starting north and turning clockwise. ::SDL_HAPTIC_POLAR only uses + * the first \c dir parameter. The cardinal directions would be: + * - North: 0 (0 degrees) + * - East: 9000 (90 degrees) + * - South: 18000 (180 degrees) + * - West: 27000 (270 degrees) + * + * If type is ::SDL_HAPTIC_CARTESIAN, direction is encoded by three positions + * (X axis, Y axis and Z axis (with 3 axes)). ::SDL_HAPTIC_CARTESIAN uses + * the first three \c dir parameters. The cardinal directions would be: + * - North: 0,-1, 0 + * - East: -1, 0, 0 + * - South: 0, 1, 0 + * - West: 1, 0, 0 + * + * The Z axis represents the height of the effect if supported, otherwise + * it's unused. In cartesian encoding (1, 2) would be the same as (2, 4), you + * can use any multiple you want, only the direction matters. + * + * If type is ::SDL_HAPTIC_SPHERICAL, direction is encoded by two rotations. + * The first two \c dir parameters are used. The \c dir parameters are as + * follows (all values are in hundredths of degrees): + * - Degrees from (1, 0) rotated towards (0, 1). + * - Degrees towards (0, 0, 1) (device needs at least 3 axes). + * + * + * Example of force coming from the south with all encodings (force coming + * from the south means the user will have to pull the stick to counteract): + * \code + * SDL_HapticDirection direction; + * + * // Cartesian directions + * direction.type = SDL_HAPTIC_CARTESIAN; // Using cartesian direction encoding. + * direction.dir[0] = 0; // X position + * direction.dir[1] = 1; // Y position + * // Assuming the device has 2 axes, we don't need to specify third parameter. + * + * // Polar directions + * direction.type = SDL_HAPTIC_POLAR; // We'll be using polar direction encoding. + * direction.dir[0] = 18000; // Polar only uses first parameter + * + * // Spherical coordinates + * direction.type = SDL_HAPTIC_SPHERICAL; // Spherical encoding + * direction.dir[0] = 9000; // Since we only have two axes we don't need more parameters. + * \endcode + * + * \sa SDL_HAPTIC_POLAR + * \sa SDL_HAPTIC_CARTESIAN + * \sa SDL_HAPTIC_SPHERICAL + * \sa SDL_HapticEffect + * \sa SDL_HapticNumAxes + */ +typedef struct SDL_HapticDirection +{ + Uint8 type; /**< The type of encoding. */ + Sint32 dir[3]; /**< The encoded direction. */ +} SDL_HapticDirection; + + +/** + * \brief A structure containing a template for a Constant effect. + * + * The struct is exclusive to the ::SDL_HAPTIC_CONSTANT effect. + * + * A constant effect applies a constant force in the specified direction + * to the joystick. + * + * \sa SDL_HAPTIC_CONSTANT + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticConstant +{ + /* Header */ + Uint16 type; /**< ::SDL_HAPTIC_CONSTANT */ + SDL_HapticDirection direction; /**< Direction of the effect. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Constant */ + Sint16 level; /**< Strength of the constant effect. */ + + /* Envelope */ + Uint16 attack_length; /**< Duration of the attack. */ + Uint16 attack_level; /**< Level at the start of the attack. */ + Uint16 fade_length; /**< Duration of the fade. */ + Uint16 fade_level; /**< Level at the end of the fade. */ +} SDL_HapticConstant; + +/** + * \brief A structure containing a template for a Periodic effect. + * + * The struct handles the following effects: + * - ::SDL_HAPTIC_SINE + * - ::SDL_HAPTIC_LEFTRIGHT + * - ::SDL_HAPTIC_TRIANGLE + * - ::SDL_HAPTIC_SAWTOOTHUP + * - ::SDL_HAPTIC_SAWTOOTHDOWN + * + * A periodic effect consists in a wave-shaped effect that repeats itself + * over time. The type determines the shape of the wave and the parameters + * determine the dimensions of the wave. + * + * Phase is given by hundredth of a cycle meaning that giving the phase a value + * of 9000 will displace it 25% of its period. Here are sample values: + * - 0: No phase displacement. + * - 9000: Displaced 25% of its period. + * - 18000: Displaced 50% of its period. + * - 27000: Displaced 75% of its period. + * - 36000: Displaced 100% of its period, same as 0, but 0 is preferred. + * + * Examples: + * \verbatim + SDL_HAPTIC_SINE + __ __ __ __ + / \ / \ / \ / + / \__/ \__/ \__/ + + SDL_HAPTIC_SQUARE + __ __ __ __ __ + | | | | | | | | | | + | |__| |__| |__| |__| | + + SDL_HAPTIC_TRIANGLE + /\ /\ /\ /\ /\ + / \ / \ / \ / \ / + / \/ \/ \/ \/ + + SDL_HAPTIC_SAWTOOTHUP + /| /| /| /| /| /| /| + / | / | / | / | / | / | / | + / |/ |/ |/ |/ |/ |/ | + + SDL_HAPTIC_SAWTOOTHDOWN + \ |\ |\ |\ |\ |\ |\ | + \ | \ | \ | \ | \ | \ | \ | + \| \| \| \| \| \| \| + \endverbatim + * + * \sa SDL_HAPTIC_SINE + * \sa SDL_HAPTIC_LEFTRIGHT + * \sa SDL_HAPTIC_TRIANGLE + * \sa SDL_HAPTIC_SAWTOOTHUP + * \sa SDL_HAPTIC_SAWTOOTHDOWN + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticPeriodic +{ + /* Header */ + Uint16 type; /**< ::SDL_HAPTIC_SINE, ::SDL_HAPTIC_LEFTRIGHT, + ::SDL_HAPTIC_TRIANGLE, ::SDL_HAPTIC_SAWTOOTHUP or + ::SDL_HAPTIC_SAWTOOTHDOWN */ + SDL_HapticDirection direction; /**< Direction of the effect. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Periodic */ + Uint16 period; /**< Period of the wave. */ + Sint16 magnitude; /**< Peak value. */ + Sint16 offset; /**< Mean value of the wave. */ + Uint16 phase; /**< Horizontal shift given by hundredth of a cycle. */ + + /* Envelope */ + Uint16 attack_length; /**< Duration of the attack. */ + Uint16 attack_level; /**< Level at the start of the attack. */ + Uint16 fade_length; /**< Duration of the fade. */ + Uint16 fade_level; /**< Level at the end of the fade. */ +} SDL_HapticPeriodic; + +/** + * \brief A structure containing a template for a Condition effect. + * + * The struct handles the following effects: + * - ::SDL_HAPTIC_SPRING: Effect based on axes position. + * - ::SDL_HAPTIC_DAMPER: Effect based on axes velocity. + * - ::SDL_HAPTIC_INERTIA: Effect based on axes acceleration. + * - ::SDL_HAPTIC_FRICTION: Effect based on axes movement. + * + * Direction is handled by condition internals instead of a direction member. + * The condition effect specific members have three parameters. The first + * refers to the X axis, the second refers to the Y axis and the third + * refers to the Z axis. The right terms refer to the positive side of the + * axis and the left terms refer to the negative side of the axis. Please + * refer to the ::SDL_HapticDirection diagram for which side is positive and + * which is negative. + * + * \sa SDL_HapticDirection + * \sa SDL_HAPTIC_SPRING + * \sa SDL_HAPTIC_DAMPER + * \sa SDL_HAPTIC_INERTIA + * \sa SDL_HAPTIC_FRICTION + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticCondition +{ + /* Header */ + Uint16 type; /**< ::SDL_HAPTIC_SPRING, ::SDL_HAPTIC_DAMPER, + ::SDL_HAPTIC_INERTIA or ::SDL_HAPTIC_FRICTION */ + SDL_HapticDirection direction; /**< Direction of the effect - Not used ATM. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Condition */ + Uint16 right_sat[3]; /**< Level when joystick is to the positive side. */ + Uint16 left_sat[3]; /**< Level when joystick is to the negative side. */ + Sint16 right_coeff[3]; /**< How fast to increase the force towards the positive side. */ + Sint16 left_coeff[3]; /**< How fast to increase the force towards the negative side. */ + Uint16 deadband[3]; /**< Size of the dead zone. */ + Sint16 center[3]; /**< Position of the dead zone. */ +} SDL_HapticCondition; + +/** + * \brief A structure containing a template for a Ramp effect. + * + * This struct is exclusively for the ::SDL_HAPTIC_RAMP effect. + * + * The ramp effect starts at start strength and ends at end strength. + * It augments in linear fashion. If you use attack and fade with a ramp + * the effects get added to the ramp effect making the effect become + * quadratic instead of linear. + * + * \sa SDL_HAPTIC_RAMP + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticRamp +{ + /* Header */ + Uint16 type; /**< ::SDL_HAPTIC_RAMP */ + SDL_HapticDirection direction; /**< Direction of the effect. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Ramp */ + Sint16 start; /**< Beginning strength level. */ + Sint16 end; /**< Ending strength level. */ + + /* Envelope */ + Uint16 attack_length; /**< Duration of the attack. */ + Uint16 attack_level; /**< Level at the start of the attack. */ + Uint16 fade_length; /**< Duration of the fade. */ + Uint16 fade_level; /**< Level at the end of the fade. */ +} SDL_HapticRamp; + +/** + * \brief A structure containing a template for a Left/Right effect. + * + * This struct is exclusively for the ::SDL_HAPTIC_LEFTRIGHT effect. + * + * The Left/Right effect is used to explicitly control the large and small + * motors, commonly found in modern game controllers. One motor is high + * frequency, the other is low frequency. + * + * \sa SDL_HAPTIC_LEFTRIGHT + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticLeftRight +{ + /* Header */ + Uint16 type; /**< ::SDL_HAPTIC_LEFTRIGHT */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + + /* Rumble */ + Uint16 large_magnitude; /**< Control of the large controller motor. */ + Uint16 small_magnitude; /**< Control of the small controller motor. */ +} SDL_HapticLeftRight; + +/** + * \brief A structure containing a template for the ::SDL_HAPTIC_CUSTOM effect. + * + * A custom force feedback effect is much like a periodic effect, where the + * application can define its exact shape. You will have to allocate the + * data yourself. Data should consist of channels * samples Uint16 samples. + * + * If channels is one, the effect is rotated using the defined direction. + * Otherwise it uses the samples in data for the different axes. + * + * \sa SDL_HAPTIC_CUSTOM + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticCustom +{ + /* Header */ + Uint16 type; /**< ::SDL_HAPTIC_CUSTOM */ + SDL_HapticDirection direction; /**< Direction of the effect. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Custom */ + Uint8 channels; /**< Axes to use, minimum of one. */ + Uint16 period; /**< Sample periods. */ + Uint16 samples; /**< Amount of samples. */ + Uint16 *data; /**< Should contain channels*samples items. */ + + /* Envelope */ + Uint16 attack_length; /**< Duration of the attack. */ + Uint16 attack_level; /**< Level at the start of the attack. */ + Uint16 fade_length; /**< Duration of the fade. */ + Uint16 fade_level; /**< Level at the end of the fade. */ +} SDL_HapticCustom; + +/** + * \brief The generic template for any haptic effect. + * + * All values max at 32767 (0x7FFF). Signed values also can be negative. + * Time values unless specified otherwise are in milliseconds. + * + * You can also pass ::SDL_HAPTIC_INFINITY to length instead of a 0-32767 + * value. Neither delay, interval, attack_length nor fade_length support + * ::SDL_HAPTIC_INFINITY. Fade will also not be used since effect never ends. + * + * Additionally, the ::SDL_HAPTIC_RAMP effect does not support a duration of + * ::SDL_HAPTIC_INFINITY. + * + * Button triggers may not be supported on all devices, it is advised to not + * use them if possible. Buttons start at index 1 instead of index 0 like + * the joystick. + * + * If both attack_length and fade_level are 0, the envelope is not used, + * otherwise both values are used. + * + * Common parts: + * \code + * // Replay - All effects have this + * Uint32 length; // Duration of effect (ms). + * Uint16 delay; // Delay before starting effect. + * + * // Trigger - All effects have this + * Uint16 button; // Button that triggers effect. + * Uint16 interval; // How soon before effect can be triggered again. + * + * // Envelope - All effects except condition effects have this + * Uint16 attack_length; // Duration of the attack (ms). + * Uint16 attack_level; // Level at the start of the attack. + * Uint16 fade_length; // Duration of the fade out (ms). + * Uint16 fade_level; // Level at the end of the fade. + * \endcode + * + * + * Here we have an example of a constant effect evolution in time: + * \verbatim + Strength + ^ + | + | effect level --> _________________ + | / \ + | / \ + | / \ + | / \ + | attack_level --> | \ + | | | <--- fade_level + | + +--------------------------------------------------> Time + [--] [---] + attack_length fade_length + + [------------------][-----------------------] + delay length + \endverbatim + * + * Note either the attack_level or the fade_level may be above the actual + * effect level. + * + * \sa SDL_HapticConstant + * \sa SDL_HapticPeriodic + * \sa SDL_HapticCondition + * \sa SDL_HapticRamp + * \sa SDL_HapticLeftRight + * \sa SDL_HapticCustom + */ +typedef union SDL_HapticEffect +{ + /* Common for all force feedback effects */ + Uint16 type; /**< Effect type. */ + SDL_HapticConstant constant; /**< Constant effect. */ + SDL_HapticPeriodic periodic; /**< Periodic effect. */ + SDL_HapticCondition condition; /**< Condition effect. */ + SDL_HapticRamp ramp; /**< Ramp effect. */ + SDL_HapticLeftRight leftright; /**< Left/Right effect. */ + SDL_HapticCustom custom; /**< Custom effect. */ +} SDL_HapticEffect; + + +/* Function prototypes */ +/** + * \brief Count the number of haptic devices attached to the system. + * + * \return Number of haptic devices detected on the system. + */ +extern DECLSPEC int SDLCALL SDL_NumHaptics(void); + +/** + * \brief Get the implementation dependent name of a Haptic device. + * + * This can be called before any joysticks are opened. + * If no name can be found, this function returns NULL. + * + * \param device_index Index of the device to get its name. + * \return Name of the device or NULL on error. + * + * \sa SDL_NumHaptics + */ +extern DECLSPEC const char *SDLCALL SDL_HapticName(int device_index); + +/** + * \brief Opens a Haptic device for usage. + * + * The index passed as an argument refers to the N'th Haptic device on this + * system. + * + * When opening a haptic device, its gain will be set to maximum and + * autocenter will be disabled. To modify these values use + * SDL_HapticSetGain() and SDL_HapticSetAutocenter(). + * + * \param device_index Index of the device to open. + * \return Device identifier or NULL on error. + * + * \sa SDL_HapticIndex + * \sa SDL_HapticOpenFromMouse + * \sa SDL_HapticOpenFromJoystick + * \sa SDL_HapticClose + * \sa SDL_HapticSetGain + * \sa SDL_HapticSetAutocenter + * \sa SDL_HapticPause + * \sa SDL_HapticStopAll + */ +extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpen(int device_index); + +/** + * \brief Checks if the haptic device at index has been opened. + * + * \param device_index Index to check to see if it has been opened. + * \return 1 if it has been opened or 0 if it hasn't. + * + * \sa SDL_HapticOpen + * \sa SDL_HapticIndex + */ +extern DECLSPEC int SDLCALL SDL_HapticOpened(int device_index); + +/** + * \brief Gets the index of a haptic device. + * + * \param haptic Haptic device to get the index of. + * \return The index of the haptic device or -1 on error. + * + * \sa SDL_HapticOpen + * \sa SDL_HapticOpened + */ +extern DECLSPEC int SDLCALL SDL_HapticIndex(SDL_Haptic * haptic); + +/** + * \brief Gets whether or not the current mouse has haptic capabilities. + * + * \return SDL_TRUE if the mouse is haptic, SDL_FALSE if it isn't. + * + * \sa SDL_HapticOpenFromMouse + */ +extern DECLSPEC int SDLCALL SDL_MouseIsHaptic(void); + +/** + * \brief Tries to open a haptic device from the current mouse. + * + * \return The haptic device identifier or NULL on error. + * + * \sa SDL_MouseIsHaptic + * \sa SDL_HapticOpen + */ +extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromMouse(void); + +/** + * \brief Checks to see if a joystick has haptic features. + * + * \param joystick Joystick to test for haptic capabilities. + * \return 1 if the joystick is haptic, 0 if it isn't + * or -1 if an error ocurred. + * + * \sa SDL_HapticOpenFromJoystick + */ +extern DECLSPEC int SDLCALL SDL_JoystickIsHaptic(SDL_Joystick * joystick); + +/** + * \brief Opens a Haptic device for usage from a Joystick device. + * + * You must still close the haptic device seperately. It will not be closed + * with the joystick. + * + * When opening from a joystick you should first close the haptic device before + * closing the joystick device. If not, on some implementations the haptic + * device will also get unallocated and you'll be unable to use force feedback + * on that device. + * + * \param joystick Joystick to create a haptic device from. + * \return A valid haptic device identifier on success or NULL on error. + * + * \sa SDL_HapticOpen + * \sa SDL_HapticClose + */ +extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromJoystick(SDL_Joystick * + joystick); + +/** + * \brief Closes a Haptic device previously opened with SDL_HapticOpen(). + * + * \param haptic Haptic device to close. + */ +extern DECLSPEC void SDLCALL SDL_HapticClose(SDL_Haptic * haptic); + +/** + * \brief Returns the number of effects a haptic device can store. + * + * On some platforms this isn't fully supported, and therefore is an + * approximation. Always check to see if your created effect was actually + * created and do not rely solely on SDL_HapticNumEffects(). + * + * \param haptic The haptic device to query effect max. + * \return The number of effects the haptic device can store or + * -1 on error. + * + * \sa SDL_HapticNumEffectsPlaying + * \sa SDL_HapticQuery + */ +extern DECLSPEC int SDLCALL SDL_HapticNumEffects(SDL_Haptic * haptic); + +/** + * \brief Returns the number of effects a haptic device can play at the same + * time. + * + * This is not supported on all platforms, but will always return a value. + * Added here for the sake of completeness. + * + * \param haptic The haptic device to query maximum playing effects. + * \return The number of effects the haptic device can play at the same time + * or -1 on error. + * + * \sa SDL_HapticNumEffects + * \sa SDL_HapticQuery + */ +extern DECLSPEC int SDLCALL SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic); + +/** + * \brief Gets the haptic devices supported features in bitwise matter. + * + * Example: + * \code + * if (SDL_HapticQuery(haptic) & SDL_HAPTIC_CONSTANT) { + * printf("We have constant haptic effect!"); + * } + * \endcode + * + * \param haptic The haptic device to query. + * \return Haptic features in bitwise manner (OR'd). + * + * \sa SDL_HapticNumEffects + * \sa SDL_HapticEffectSupported + */ +extern DECLSPEC unsigned int SDLCALL SDL_HapticQuery(SDL_Haptic * haptic); + + +/** + * \brief Gets the number of haptic axes the device has. + * + * \sa SDL_HapticDirection + */ +extern DECLSPEC int SDLCALL SDL_HapticNumAxes(SDL_Haptic * haptic); + +/** + * \brief Checks to see if effect is supported by haptic. + * + * \param haptic Haptic device to check on. + * \param effect Effect to check to see if it is supported. + * \return SDL_TRUE if effect is supported, SDL_FALSE if it isn't or -1 on error. + * + * \sa SDL_HapticQuery + * \sa SDL_HapticNewEffect + */ +extern DECLSPEC int SDLCALL SDL_HapticEffectSupported(SDL_Haptic * haptic, + SDL_HapticEffect * + effect); + +/** + * \brief Creates a new haptic effect on the device. + * + * \param haptic Haptic device to create the effect on. + * \param effect Properties of the effect to create. + * \return The id of the effect on success or -1 on error. + * + * \sa SDL_HapticUpdateEffect + * \sa SDL_HapticRunEffect + * \sa SDL_HapticDestroyEffect + */ +extern DECLSPEC int SDLCALL SDL_HapticNewEffect(SDL_Haptic * haptic, + SDL_HapticEffect * effect); + +/** + * \brief Updates the properties of an effect. + * + * Can be used dynamically, although behaviour when dynamically changing + * direction may be strange. Specifically the effect may reupload itself + * and start playing from the start. You cannot change the type either when + * running SDL_HapticUpdateEffect(). + * + * \param haptic Haptic device that has the effect. + * \param effect Effect to update. + * \param data New effect properties to use. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticNewEffect + * \sa SDL_HapticRunEffect + * \sa SDL_HapticDestroyEffect + */ +extern DECLSPEC int SDLCALL SDL_HapticUpdateEffect(SDL_Haptic * haptic, + int effect, + SDL_HapticEffect * data); + +/** + * \brief Runs the haptic effect on its associated haptic device. + * + * If iterations are ::SDL_HAPTIC_INFINITY, it'll run the effect over and over + * repeating the envelope (attack and fade) every time. If you only want the + * effect to last forever, set ::SDL_HAPTIC_INFINITY in the effect's length + * parameter. + * + * \param haptic Haptic device to run the effect on. + * \param effect Identifier of the haptic effect to run. + * \param iterations Number of iterations to run the effect. Use + * ::SDL_HAPTIC_INFINITY for infinity. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticStopEffect + * \sa SDL_HapticDestroyEffect + * \sa SDL_HapticGetEffectStatus + */ +extern DECLSPEC int SDLCALL SDL_HapticRunEffect(SDL_Haptic * haptic, + int effect, + Uint32 iterations); + +/** + * \brief Stops the haptic effect on its associated haptic device. + * + * \param haptic Haptic device to stop the effect on. + * \param effect Identifier of the effect to stop. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticRunEffect + * \sa SDL_HapticDestroyEffect + */ +extern DECLSPEC int SDLCALL SDL_HapticStopEffect(SDL_Haptic * haptic, + int effect); + +/** + * \brief Destroys a haptic effect on the device. + * + * This will stop the effect if it's running. Effects are automatically + * destroyed when the device is closed. + * + * \param haptic Device to destroy the effect on. + * \param effect Identifier of the effect to destroy. + * + * \sa SDL_HapticNewEffect + */ +extern DECLSPEC void SDLCALL SDL_HapticDestroyEffect(SDL_Haptic * haptic, + int effect); + +/** + * \brief Gets the status of the current effect on the haptic device. + * + * Device must support the ::SDL_HAPTIC_STATUS feature. + * + * \param haptic Haptic device to query the effect status on. + * \param effect Identifier of the effect to query its status. + * \return 0 if it isn't playing, 1 if it is playing or -1 on error. + * + * \sa SDL_HapticRunEffect + * \sa SDL_HapticStopEffect + */ +extern DECLSPEC int SDLCALL SDL_HapticGetEffectStatus(SDL_Haptic * haptic, + int effect); + +/** + * \brief Sets the global gain of the device. + * + * Device must support the ::SDL_HAPTIC_GAIN feature. + * + * The user may specify the maximum gain by setting the environment variable + * SDL_HAPTIC_GAIN_MAX which should be between 0 and 100. All calls to + * SDL_HapticSetGain() will scale linearly using SDL_HAPTIC_GAIN_MAX as the + * maximum. + * + * \param haptic Haptic device to set the gain on. + * \param gain Value to set the gain to, should be between 0 and 100. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticQuery + */ +extern DECLSPEC int SDLCALL SDL_HapticSetGain(SDL_Haptic * haptic, int gain); + +/** + * \brief Sets the global autocenter of the device. + * + * Autocenter should be between 0 and 100. Setting it to 0 will disable + * autocentering. + * + * Device must support the ::SDL_HAPTIC_AUTOCENTER feature. + * + * \param haptic Haptic device to set autocentering on. + * \param autocenter Value to set autocenter to, 0 disables autocentering. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticQuery + */ +extern DECLSPEC int SDLCALL SDL_HapticSetAutocenter(SDL_Haptic * haptic, + int autocenter); + +/** + * \brief Pauses a haptic device. + * + * Device must support the ::SDL_HAPTIC_PAUSE feature. Call + * SDL_HapticUnpause() to resume playback. + * + * Do not modify the effects nor add new ones while the device is paused. + * That can cause all sorts of weird errors. + * + * \param haptic Haptic device to pause. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticUnpause + */ +extern DECLSPEC int SDLCALL SDL_HapticPause(SDL_Haptic * haptic); + +/** + * \brief Unpauses a haptic device. + * + * Call to unpause after SDL_HapticPause(). + * + * \param haptic Haptic device to pause. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticPause + */ +extern DECLSPEC int SDLCALL SDL_HapticUnpause(SDL_Haptic * haptic); + +/** + * \brief Stops all the currently playing effects on a haptic device. + * + * \param haptic Haptic device to stop. + * \return 0 on success or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_HapticStopAll(SDL_Haptic * haptic); + +/** + * \brief Checks to see if rumble is supported on a haptic device. + * + * \param haptic Haptic device to check to see if it supports rumble. + * \return SDL_TRUE if effect is supported, SDL_FALSE if it isn't or -1 on error. + * + * \sa SDL_HapticRumbleInit + * \sa SDL_HapticRumblePlay + * \sa SDL_HapticRumbleStop + */ +extern DECLSPEC int SDLCALL SDL_HapticRumbleSupported(SDL_Haptic * haptic); + +/** + * \brief Initializes the haptic device for simple rumble playback. + * + * \param haptic Haptic device to initialize for simple rumble playback. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticOpen + * \sa SDL_HapticRumbleSupported + * \sa SDL_HapticRumblePlay + * \sa SDL_HapticRumbleStop + */ +extern DECLSPEC int SDLCALL SDL_HapticRumbleInit(SDL_Haptic * haptic); + +/** + * \brief Runs simple rumble on a haptic device + * + * \param haptic Haptic device to play rumble effect on. + * \param strength Strength of the rumble to play as a 0-1 float value. + * \param length Length of the rumble to play in milliseconds. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticRumbleSupported + * \sa SDL_HapticRumbleInit + * \sa SDL_HapticRumbleStop + */ +extern DECLSPEC int SDLCALL SDL_HapticRumblePlay(SDL_Haptic * haptic, float strength, Uint32 length ); + +/** + * \brief Stops the simple rumble on a haptic device. + * + * \param haptic Haptic to stop the rumble on. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticRumbleSupported + * \sa SDL_HapticRumbleInit + * \sa SDL_HapticRumblePlay + */ +extern DECLSPEC int SDLCALL SDL_HapticRumbleStop(SDL_Haptic * haptic); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_haptic_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_hints.h spring-98.0~14.04~ppa6/include/SDL2/SDL_hints.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_hints.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_hints.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,355 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_hints.h + * + * Official documentation for SDL configuration variables + * + * This file contains functions to set and get configuration hints, + * as well as listing each of them alphabetically. + * + * The convention for naming hints is SDL_HINT_X, where "SDL_X" is + * the environment variable that can be used to override the default. + * + * In general these hints are just that - they may or may not be + * supported or applicable on any given platform, but they provide + * a way for an application or user to give the library a hint as + * to how they would like the library to work. + */ + +#ifndef _SDL_hints_h +#define _SDL_hints_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief A variable controlling how 3D acceleration is used to accelerate the SDL screen surface. + * + * SDL can try to accelerate the SDL screen surface by using streaming + * textures with a 3D rendering engine. This variable controls whether and + * how this is done. + * + * This variable can be set to the following values: + * "0" - Disable 3D acceleration + * "1" - Enable 3D acceleration, using the default renderer. + * "X" - Enable 3D acceleration, using X where X is one of the valid rendering drivers. (e.g. "direct3d", "opengl", etc.) + * + * By default SDL tries to make a best guess for each platform whether + * to use acceleration or not. + */ +#define SDL_HINT_FRAMEBUFFER_ACCELERATION "SDL_FRAMEBUFFER_ACCELERATION" + +/** + * \brief A variable specifying which render driver to use. + * + * If the application doesn't pick a specific renderer to use, this variable + * specifies the name of the preferred renderer. If the preferred renderer + * can't be initialized, the normal default renderer is used. + * + * This variable is case insensitive and can be set to the following values: + * "direct3d" + * "opengl" + * "opengles2" + * "opengles" + * "software" + * + * The default varies by platform, but it's the first one in the list that + * is available on the current platform. + */ +#define SDL_HINT_RENDER_DRIVER "SDL_RENDER_DRIVER" + +/** + * \brief A variable controlling whether the OpenGL render driver uses shaders if they are available. + * + * This variable can be set to the following values: + * "0" - Disable shaders + * "1" - Enable shaders + * + * By default shaders are used if OpenGL supports them. + */ +#define SDL_HINT_RENDER_OPENGL_SHADERS "SDL_RENDER_OPENGL_SHADERS" + +/** + * \brief A variable controlling whether the Direct3D device is initialized for thread-safe operations. + * + * This variable can be set to the following values: + * "0" - Thread-safety is not enabled (faster) + * "1" - Thread-safety is enabled + * + * By default the Direct3D device is created with thread-safety disabled. + */ +#define SDL_HINT_RENDER_DIRECT3D_THREADSAFE "SDL_RENDER_DIRECT3D_THREADSAFE" + +/** + * \brief A variable controlling the scaling quality + * + * This variable can be set to the following values: + * "0" or "nearest" - Nearest pixel sampling + * "1" or "linear" - Linear filtering (supported by OpenGL and Direct3D) + * "2" or "best" - Currently this is the same as "linear" + * + * By default nearest pixel sampling is used + */ +#define SDL_HINT_RENDER_SCALE_QUALITY "SDL_RENDER_SCALE_QUALITY" + +/** + * \brief A variable controlling whether updates to the SDL screen surface should be synchronized with the vertical refresh, to avoid tearing. + * + * This variable can be set to the following values: + * "0" - Disable vsync + * "1" - Enable vsync + * + * By default SDL does not sync screen surface updates with vertical refresh. + */ +#define SDL_HINT_RENDER_VSYNC "SDL_RENDER_VSYNC" + +/** + * \brief A variable controlling whether the X11 VidMode extension should be used. + * + * This variable can be set to the following values: + * "0" - Disable XVidMode + * "1" - Enable XVidMode + * + * By default SDL will use XVidMode if it is available. + */ +#define SDL_HINT_VIDEO_X11_XVIDMODE "SDL_VIDEO_X11_XVIDMODE" + +/** + * \brief A variable controlling whether the X11 Xinerama extension should be used. + * + * This variable can be set to the following values: + * "0" - Disable Xinerama + * "1" - Enable Xinerama + * + * By default SDL will use Xinerama if it is available. + */ +#define SDL_HINT_VIDEO_X11_XINERAMA "SDL_VIDEO_X11_XINERAMA" + +/** + * \brief A variable controlling whether the X11 XRandR extension should be used. + * + * This variable can be set to the following values: + * "0" - Disable XRandR + * "1" - Enable XRandR + * + * By default SDL will not use XRandR because of window manager issues. + */ +#define SDL_HINT_VIDEO_X11_XRANDR "SDL_VIDEO_X11_XRANDR" + +/** + * \brief A variable controlling whether grabbing input grabs the keyboard + * + * This variable can be set to the following values: + * "0" - Grab will affect only the mouse + * "1" - Grab will affect mouse and keyboard + * + * By default SDL will not grab the keyboard so system shortcuts still work. + */ +#define SDL_HINT_GRAB_KEYBOARD "SDL_GRAB_KEYBOARD" + +/** + * \brief Minimize your SDL_Window if it loses key focus when in Fullscreen mode. Defaults to true. + * + */ +#define SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS "SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS" + + +/** + * \brief A variable controlling whether the idle timer is disabled on iOS. + * + * When an iOS app does not receive touches for some time, the screen is + * dimmed automatically. For games where the accelerometer is the only input + * this is problematic. This functionality can be disabled by setting this + * hint. + * + * This variable can be set to the following values: + * "0" - Enable idle timer + * "1" - Disable idle timer + */ +#define SDL_HINT_IDLE_TIMER_DISABLED "SDL_IOS_IDLE_TIMER_DISABLED" + +/** + * \brief A variable controlling which orientations are allowed on iOS. + * + * In some circumstances it is necessary to be able to explicitly control + * which UI orientations are allowed. + * + * This variable is a space delimited list of the following values: + * "LandscapeLeft", "LandscapeRight", "Portrait" "PortraitUpsideDown" + */ +#define SDL_HINT_ORIENTATIONS "SDL_IOS_ORIENTATIONS" + + +/** + * \brief A variable that lets you disable the detection and use of Xinput gamepad devices + * + * The variable can be set to the following values: + * "0" - Disable XInput timer (only uses direct input) + * "1" - Enable XInput timer (the default) + */ +#define SDL_HINT_XINPUT_ENABLED "SDL_XINPUT_ENABLED" + + +/** + * \brief A variable that lets you manually hint extra gamecontroller db entries + * + * The variable should be newline delimited rows of gamecontroller config data, see SDL_gamecontroller.h + * + * This hint must be set before calling SDL_Init(SDL_INIT_GAMECONTROLLER) + * You can update mappings after the system is initialized with SDL_GameControllerMappingForGUID() and SDL_GameControllerAddMapping() + */ +#define SDL_HINT_GAMECONTROLLERCONFIG "SDL_GAMECONTROLLERCONFIG" + + +/** + * \brief A variable that lets you enable joystick (and gamecontroller) events even when your app is in the background. + * + * The variable can be set to the following values: + * "0" - Disable joystick & gamecontroller input events when the + * application is in the background. + * "1" - Enable joystick & gamecontroller input events when the + * application is in the backgroumd. + * + * The default value is "0". This hint may be set at any time. + */ +#define SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS "SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS" + + +/** + * \brief If set to 0 then never set the top most bit on a SDL Window, even if the video mode expects it. + * This is a debugging aid for developers and not expected to be used by end users. The default is "1" + * + * This variable can be set to the following values: + * "0" - don't allow topmost + * "1" - allow topmost + */ +#define SDL_HINT_ALLOW_TOPMOST "SDL_ALLOW_TOPMOST" + + +/** + * \brief A variable that controls the timer resolution, in milliseconds. + * + * The higher resolution the timer, the more frequently the CPU services + * timer interrupts, and the more precise delays are, but this takes up + * power and CPU time. This hint is only used on Windows 7 and earlier. + * + * See this blog post for more information: + * http://randomascii.wordpress.com/2013/07/08/windows-timer-resolution-megawatts-wasted/ + * + * If this variable is set to "0", the system timer resolution is not set. + * + * The default value is "1". This hint may be set at any time. + */ +#define SDL_HINT_TIMER_RESOLUTION "SDL_TIMER_RESOLUTION" + + +/** + * \brief If set to 1, then do not allow high-DPI windows. ("Retina" on Mac) + */ +#define SDL_HINT_VIDEO_HIGHDPI_DISABLED "SDL_VIDEO_HIGHDPI_DISABLED" + + +/** + * \brief An enumeration of hint priorities + */ +typedef enum +{ + SDL_HINT_DEFAULT, + SDL_HINT_NORMAL, + SDL_HINT_OVERRIDE +} SDL_HintPriority; + + +/** + * \brief Set a hint with a specific priority + * + * The priority controls the behavior when setting a hint that already + * has a value. Hints will replace existing hints of their priority and + * lower. Environment variables are considered to have override priority. + * + * \return SDL_TRUE if the hint was set, SDL_FALSE otherwise + */ +extern DECLSPEC SDL_bool SDLCALL SDL_SetHintWithPriority(const char *name, + const char *value, + SDL_HintPriority priority); + +/** + * \brief Set a hint with normal priority + * + * \return SDL_TRUE if the hint was set, SDL_FALSE otherwise + */ +extern DECLSPEC SDL_bool SDLCALL SDL_SetHint(const char *name, + const char *value); + +/** + * \brief Get a hint + * + * \return The string value of a hint variable. + */ +extern DECLSPEC const char * SDLCALL SDL_GetHint(const char *name); + +/** + * \brief Add a function to watch a particular hint + * + * \param name The hint to watch + * \param callback The function to call when the hint value changes + * \param userdata A pointer to pass to the callback function + */ +typedef void (*SDL_HintCallback)(void *userdata, const char *name, const char *oldValue, const char *newValue); +extern DECLSPEC void SDLCALL SDL_AddHintCallback(const char *name, + SDL_HintCallback callback, + void *userdata); + +/** + * \brief Remove a function watching a particular hint + * + * \param name The hint being watched + * \param callback The function being called when the hint value changes + * \param userdata A pointer being passed to the callback function + */ +extern DECLSPEC void SDLCALL SDL_DelHintCallback(const char *name, + SDL_HintCallback callback, + void *userdata); + +/** + * \brief Clear all hints + * + * This function is called during SDL_Quit() to free stored hints. + */ +extern DECLSPEC void SDLCALL SDL_ClearHints(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_hints_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_joystick.h spring-98.0~14.04~ppa6/include/SDL2/SDL_joystick.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_joystick.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_joystick.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,253 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_joystick.h + * + * Include file for SDL joystick event handling + * + * The term "device_index" identifies currently plugged in joystick devices between 0 and SDL_NumJoysticks, with the exact joystick + * behind a device_index changing as joysticks are plugged and unplugged. + * + * The term "instance_id" is the current instantiation of a joystick device in the system, if the joystick is removed and then re-inserted + * then it will get a new instance_id, instance_id's are monotonically increasing identifiers of a joystick plugged in. + * + * The term JoystickGUID is a stable 128-bit identifier for a joystick device that does not change over time, it identifies class of + * the device (a X360 wired controller for example). This identifier is platform dependent. + * + * + */ + +#ifndef _SDL_joystick_h +#define _SDL_joystick_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \file SDL_joystick.h + * + * In order to use these functions, SDL_Init() must have been called + * with the ::SDL_INIT_JOYSTICK flag. This causes SDL to scan the system + * for joysticks, and load appropriate drivers. + * + * If you would like to receive joystick updates while the application + * is in the background, you should set the following hint before calling + * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS + */ + +/* The joystick structure used to identify an SDL joystick */ +struct _SDL_Joystick; +typedef struct _SDL_Joystick SDL_Joystick; + +/* A structure that encodes the stable unique id for a joystick device */ +typedef struct { + Uint8 data[16]; +} SDL_JoystickGUID; + +typedef Sint32 SDL_JoystickID; + + +/* Function prototypes */ +/** + * Count the number of joysticks attached to the system right now + */ +extern DECLSPEC int SDLCALL SDL_NumJoysticks(void); + +/** + * Get the implementation dependent name of a joystick. + * This can be called before any joysticks are opened. + * If no name can be found, this function returns NULL. + */ +extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index); + +/** + * Open a joystick for use. + * The index passed as an argument refers tothe N'th joystick on the system. + * This index is the value which will identify this joystick in future joystick + * events. + * + * \return A joystick identifier, or NULL if an error occurred. + */ +extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index); + +/** + * Return the name for this currently opened joystick. + * If no name can be found, this function returns NULL. + */ +extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick * joystick); + +/** + * Return the GUID for the joystick at this index + */ +extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_index); + +/** + * Return the GUID for this opened joystick + */ +extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick * joystick); + +/** + * Return a string representation for this guid. pszGUID must point to at least 33 bytes + * (32 for the string plus a NULL terminator). + */ +extern DECLSPEC void SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID); + +/** + * convert a string into a joystick formatted guid + */ +extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const char *pchGUID); + +/** + * Returns SDL_TRUE if the joystick has been opened and currently connected, or SDL_FALSE if it has not. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAttached(SDL_Joystick * joystick); + +/** + * Get the instance ID of an opened joystick or -1 if the joystick is invalid. + */ +extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick * joystick); + +/** + * Get the number of general axis controls on a joystick. + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick * joystick); + +/** + * Get the number of trackballs on a joystick. + * + * Joystick trackballs have only relative motion events associated + * with them and their state cannot be polled. + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick * joystick); + +/** + * Get the number of POV hats on a joystick. + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick * joystick); + +/** + * Get the number of buttons on a joystick. + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick * joystick); + +/** + * Update the current state of the open joysticks. + * + * This is called automatically by the event loop if any joystick + * events are enabled. + */ +extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void); + +/** + * Enable/disable joystick event polling. + * + * If joystick events are disabled, you must call SDL_JoystickUpdate() + * yourself and check the state of the joystick when you want joystick + * information. + * + * The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE. + */ +extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state); + +/** + * Get the current state of an axis control on a joystick. + * + * The state is a value ranging from -32768 to 32767. + * + * The axis indices start at index 0. + */ +extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick, + int axis); + +/** + * \name Hat positions + */ +/* @{ */ +#define SDL_HAT_CENTERED 0x00 +#define SDL_HAT_UP 0x01 +#define SDL_HAT_RIGHT 0x02 +#define SDL_HAT_DOWN 0x04 +#define SDL_HAT_LEFT 0x08 +#define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP) +#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN) +#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP) +#define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN) +/* @} */ + +/** + * Get the current state of a POV hat on a joystick. + * + * The hat indices start at index 0. + * + * \return The return value is one of the following positions: + * - ::SDL_HAT_CENTERED + * - ::SDL_HAT_UP + * - ::SDL_HAT_RIGHT + * - ::SDL_HAT_DOWN + * - ::SDL_HAT_LEFT + * - ::SDL_HAT_RIGHTUP + * - ::SDL_HAT_RIGHTDOWN + * - ::SDL_HAT_LEFTUP + * - ::SDL_HAT_LEFTDOWN + */ +extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick * joystick, + int hat); + +/** + * Get the ball axis change since the last poll. + * + * \return 0, or -1 if you passed it invalid parameters. + * + * The ball indices start at index 0. + */ +extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick * joystick, + int ball, int *dx, int *dy); + +/** + * Get the current state of a button on a joystick. + * + * The button indices start at index 0. + */ +extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick, + int button); + +/** + * Close a joystick previously opened with SDL_JoystickOpen(). + */ +extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick * joystick); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_joystick_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_keyboard.h spring-98.0~14.04~ppa6/include/SDL2/SDL_keyboard.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_keyboard.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_keyboard.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,217 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_keyboard.h + * + * Include file for SDL keyboard event handling + */ + +#ifndef _SDL_keyboard_h +#define _SDL_keyboard_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_keycode.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief The SDL keysym structure, used in key events. + * + * \note If you are looking for translated character input, see the ::SDL_TEXTINPUT event. + */ +typedef struct SDL_Keysym +{ + SDL_Scancode scancode; /**< SDL physical key code - see ::SDL_Scancode for details */ + SDL_Keycode sym; /**< SDL virtual key code - see ::SDL_Keycode for details */ + Uint16 mod; /**< current key modifiers */ + Uint32 unused; +} SDL_Keysym; + +/* Function prototypes */ + +/** + * \brief Get the window which currently has keyboard focus. + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void); + +/** + * \brief Get a snapshot of the current state of the keyboard. + * + * \param numkeys if non-NULL, receives the length of the returned array. + * + * \return An array of key states. Indexes into this array are obtained by using ::SDL_Scancode values. + * + * \b Example: + * \code + * const Uint8 *state = SDL_GetKeyboardState(NULL); + * if ( state[SDL_SCANCODE_RETURN] ) { + * printf(" is pressed.\n"); + * } + * \endcode + */ +extern DECLSPEC const Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys); + +/** + * \brief Get the current key modifier state for the keyboard. + */ +extern DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void); + +/** + * \brief Set the current key modifier state for the keyboard. + * + * \note This does not change the keyboard state, only the key modifier flags. + */ +extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate); + +/** + * \brief Get the key code corresponding to the given scancode according + * to the current keyboard layout. + * + * See ::SDL_Keycode for details. + * + * \sa SDL_GetKeyName() + */ +extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode); + +/** + * \brief Get the scancode corresponding to the given key code according to the + * current keyboard layout. + * + * See ::SDL_Scancode for details. + * + * \sa SDL_GetScancodeName() + */ +extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key); + +/** + * \brief Get a human-readable name for a scancode. + * + * \return A pointer to the name for the scancode. + * If the scancode doesn't have a name, this function returns + * an empty string (""). + * + * \sa SDL_Scancode + */ +extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode scancode); + +/** + * \brief Get a scancode from a human-readable name + * + * \return scancode, or SDL_SCANCODE_UNKNOWN if the name wasn't recognized + * + * \sa SDL_Scancode + */ +extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *name); + +/** + * \brief Get a human-readable name for a key. + * + * \return A pointer to a UTF-8 string that stays valid at least until the next + * call to this function. If you need it around any longer, you must + * copy it. If the key doesn't have a name, this function returns an + * empty string (""). + * + * \sa SDL_Key + */ +extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDL_Keycode key); + +/** + * \brief Get a key code from a human-readable name + * + * \return key code, or SDLK_UNKNOWN if the name wasn't recognized + * + * \sa SDL_Keycode + */ +extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name); + +/** + * \brief Start accepting Unicode text input events. + * This function will show the on-screen keyboard if supported. + * + * \sa SDL_StopTextInput() + * \sa SDL_SetTextInputRect() + * \sa SDL_HasScreenKeyboardSupport() + */ +extern DECLSPEC void SDLCALL SDL_StartTextInput(void); + +/** + * \brief Return whether or not Unicode text input events are enabled. + * + * \sa SDL_StartTextInput() + * \sa SDL_StopTextInput() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputActive(void); + +/** + * \brief Stop receiving any text input events. + * This function will hide the on-screen keyboard if supported. + * + * \sa SDL_StartTextInput() + * \sa SDL_HasScreenKeyboardSupport() + */ +extern DECLSPEC void SDLCALL SDL_StopTextInput(void); + +/** + * \brief Set the rectangle used to type Unicode text inputs. + * This is used as a hint for IME and on-screen keyboard placement. + * + * \sa SDL_StartTextInput() + */ +extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect); + +/** + * \brief Returns whether the platform has some screen keyboard support. + * + * \return SDL_TRUE if some keyboard support is available else SDL_FALSE. + * + * \note Not all screen keyboard functions are supported on all platforms. + * + * \sa SDL_IsScreenKeyboardShown() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasScreenKeyboardSupport(void); + +/** + * \brief Returns whether the screen keyboard is shown for given window. + * + * \param window The window for which screen keyboard should be queried. + * + * \return SDL_TRUE if screen keyboard is shown else SDL_FALSE. + * + * \sa SDL_HasScreenKeyboardSupport() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenKeyboardShown(SDL_Window *window); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_keyboard_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_keycode.h spring-98.0~14.04~ppa6/include/SDL2/SDL_keycode.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_keycode.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_keycode.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,341 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_keycode.h + * + * Defines constants which identify keyboard keys and modifiers. + */ + +#ifndef _SDL_keycode_h +#define _SDL_keycode_h + +#include "SDL_stdinc.h" +#include "SDL_scancode.h" + +/** + * \brief The SDL virtual key representation. + * + * Values of this type are used to represent keyboard keys using the current + * layout of the keyboard. These values include Unicode values representing + * the unmodified character that would be generated by pressing the key, or + * an SDLK_* constant for those keys that do not generate characters. + */ +typedef Sint32 SDL_Keycode; + +#define SDLK_SCANCODE_MASK (1<<30) +#define SDL_SCANCODE_TO_KEYCODE(X) (X | SDLK_SCANCODE_MASK) + +enum +{ + SDLK_UNKNOWN = 0, + + SDLK_RETURN = '\r', + SDLK_ESCAPE = '\033', + SDLK_BACKSPACE = '\b', + SDLK_TAB = '\t', + SDLK_SPACE = ' ', + SDLK_EXCLAIM = '!', + SDLK_QUOTEDBL = '"', + SDLK_HASH = '#', + SDLK_PERCENT = '%', + SDLK_DOLLAR = '$', + SDLK_AMPERSAND = '&', + SDLK_QUOTE = '\'', + SDLK_LEFTPAREN = '(', + SDLK_RIGHTPAREN = ')', + SDLK_ASTERISK = '*', + SDLK_PLUS = '+', + SDLK_COMMA = ',', + SDLK_MINUS = '-', + SDLK_PERIOD = '.', + SDLK_SLASH = '/', + SDLK_0 = '0', + SDLK_1 = '1', + SDLK_2 = '2', + SDLK_3 = '3', + SDLK_4 = '4', + SDLK_5 = '5', + SDLK_6 = '6', + SDLK_7 = '7', + SDLK_8 = '8', + SDLK_9 = '9', + SDLK_COLON = ':', + SDLK_SEMICOLON = ';', + SDLK_LESS = '<', + SDLK_EQUALS = '=', + SDLK_GREATER = '>', + SDLK_QUESTION = '?', + SDLK_AT = '@', + /* + Skip uppercase letters + */ + SDLK_LEFTBRACKET = '[', + SDLK_BACKSLASH = '\\', + SDLK_RIGHTBRACKET = ']', + SDLK_CARET = '^', + SDLK_UNDERSCORE = '_', + SDLK_BACKQUOTE = '`', + SDLK_a = 'a', + SDLK_b = 'b', + SDLK_c = 'c', + SDLK_d = 'd', + SDLK_e = 'e', + SDLK_f = 'f', + SDLK_g = 'g', + SDLK_h = 'h', + SDLK_i = 'i', + SDLK_j = 'j', + SDLK_k = 'k', + SDLK_l = 'l', + SDLK_m = 'm', + SDLK_n = 'n', + SDLK_o = 'o', + SDLK_p = 'p', + SDLK_q = 'q', + SDLK_r = 'r', + SDLK_s = 's', + SDLK_t = 't', + SDLK_u = 'u', + SDLK_v = 'v', + SDLK_w = 'w', + SDLK_x = 'x', + SDLK_y = 'y', + SDLK_z = 'z', + + SDLK_CAPSLOCK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CAPSLOCK), + + SDLK_F1 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F1), + SDLK_F2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F2), + SDLK_F3 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F3), + SDLK_F4 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F4), + SDLK_F5 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F5), + SDLK_F6 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F6), + SDLK_F7 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F7), + SDLK_F8 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F8), + SDLK_F9 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F9), + SDLK_F10 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F10), + SDLK_F11 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F11), + SDLK_F12 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F12), + + SDLK_PRINTSCREEN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PRINTSCREEN), + SDLK_SCROLLLOCK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SCROLLLOCK), + SDLK_PAUSE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAUSE), + SDLK_INSERT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_INSERT), + SDLK_HOME = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HOME), + SDLK_PAGEUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEUP), + SDLK_DELETE = '\177', + SDLK_END = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_END), + SDLK_PAGEDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEDOWN), + SDLK_RIGHT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RIGHT), + SDLK_LEFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LEFT), + SDLK_DOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DOWN), + SDLK_UP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_UP), + + SDLK_NUMLOCKCLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_NUMLOCKCLEAR), + SDLK_KP_DIVIDE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DIVIDE), + SDLK_KP_MULTIPLY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MULTIPLY), + SDLK_KP_MINUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MINUS), + SDLK_KP_PLUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PLUS), + SDLK_KP_ENTER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_ENTER), + SDLK_KP_1 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_1), + SDLK_KP_2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_2), + SDLK_KP_3 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_3), + SDLK_KP_4 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_4), + SDLK_KP_5 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_5), + SDLK_KP_6 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_6), + SDLK_KP_7 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_7), + SDLK_KP_8 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_8), + SDLK_KP_9 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_9), + SDLK_KP_0 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_0), + SDLK_KP_PERIOD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PERIOD), + + SDLK_APPLICATION = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_APPLICATION), + SDLK_POWER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_POWER), + SDLK_KP_EQUALS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EQUALS), + SDLK_F13 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F13), + SDLK_F14 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F14), + SDLK_F15 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F15), + SDLK_F16 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F16), + SDLK_F17 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F17), + SDLK_F18 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F18), + SDLK_F19 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F19), + SDLK_F20 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F20), + SDLK_F21 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F21), + SDLK_F22 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F22), + SDLK_F23 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F23), + SDLK_F24 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F24), + SDLK_EXECUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXECUTE), + SDLK_HELP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HELP), + SDLK_MENU = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MENU), + SDLK_SELECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SELECT), + SDLK_STOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_STOP), + SDLK_AGAIN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AGAIN), + SDLK_UNDO = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_UNDO), + SDLK_CUT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CUT), + SDLK_COPY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_COPY), + SDLK_PASTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PASTE), + SDLK_FIND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_FIND), + SDLK_MUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MUTE), + SDLK_VOLUMEUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_VOLUMEUP), + SDLK_VOLUMEDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_VOLUMEDOWN), + SDLK_KP_COMMA = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_COMMA), + SDLK_KP_EQUALSAS400 = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EQUALSAS400), + + SDLK_ALTERASE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_ALTERASE), + SDLK_SYSREQ = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SYSREQ), + SDLK_CANCEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CANCEL), + SDLK_CLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEAR), + SDLK_PRIOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PRIOR), + SDLK_RETURN2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RETURN2), + SDLK_SEPARATOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SEPARATOR), + SDLK_OUT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_OUT), + SDLK_OPER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_OPER), + SDLK_CLEARAGAIN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEARAGAIN), + SDLK_CRSEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CRSEL), + SDLK_EXSEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXSEL), + + SDLK_KP_00 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_00), + SDLK_KP_000 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_000), + SDLK_THOUSANDSSEPARATOR = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_THOUSANDSSEPARATOR), + SDLK_DECIMALSEPARATOR = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DECIMALSEPARATOR), + SDLK_CURRENCYUNIT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CURRENCYUNIT), + SDLK_CURRENCYSUBUNIT = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CURRENCYSUBUNIT), + SDLK_KP_LEFTPAREN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LEFTPAREN), + SDLK_KP_RIGHTPAREN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_RIGHTPAREN), + SDLK_KP_LEFTBRACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LEFTBRACE), + SDLK_KP_RIGHTBRACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_RIGHTBRACE), + SDLK_KP_TAB = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_TAB), + SDLK_KP_BACKSPACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_BACKSPACE), + SDLK_KP_A = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_A), + SDLK_KP_B = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_B), + SDLK_KP_C = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_C), + SDLK_KP_D = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_D), + SDLK_KP_E = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_E), + SDLK_KP_F = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_F), + SDLK_KP_XOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_XOR), + SDLK_KP_POWER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_POWER), + SDLK_KP_PERCENT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PERCENT), + SDLK_KP_LESS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LESS), + SDLK_KP_GREATER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_GREATER), + SDLK_KP_AMPERSAND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_AMPERSAND), + SDLK_KP_DBLAMPERSAND = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DBLAMPERSAND), + SDLK_KP_VERTICALBAR = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_VERTICALBAR), + SDLK_KP_DBLVERTICALBAR = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DBLVERTICALBAR), + SDLK_KP_COLON = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_COLON), + SDLK_KP_HASH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_HASH), + SDLK_KP_SPACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_SPACE), + SDLK_KP_AT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_AT), + SDLK_KP_EXCLAM = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EXCLAM), + SDLK_KP_MEMSTORE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMSTORE), + SDLK_KP_MEMRECALL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMRECALL), + SDLK_KP_MEMCLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMCLEAR), + SDLK_KP_MEMADD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMADD), + SDLK_KP_MEMSUBTRACT = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMSUBTRACT), + SDLK_KP_MEMMULTIPLY = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMMULTIPLY), + SDLK_KP_MEMDIVIDE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMDIVIDE), + SDLK_KP_PLUSMINUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PLUSMINUS), + SDLK_KP_CLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_CLEAR), + SDLK_KP_CLEARENTRY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_CLEARENTRY), + SDLK_KP_BINARY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_BINARY), + SDLK_KP_OCTAL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_OCTAL), + SDLK_KP_DECIMAL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DECIMAL), + SDLK_KP_HEXADECIMAL = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_HEXADECIMAL), + + SDLK_LCTRL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LCTRL), + SDLK_LSHIFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LSHIFT), + SDLK_LALT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LALT), + SDLK_LGUI = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LGUI), + SDLK_RCTRL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RCTRL), + SDLK_RSHIFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RSHIFT), + SDLK_RALT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RALT), + SDLK_RGUI = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RGUI), + + SDLK_MODE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MODE), + + SDLK_AUDIONEXT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIONEXT), + SDLK_AUDIOPREV = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOPREV), + SDLK_AUDIOSTOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOSTOP), + SDLK_AUDIOPLAY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOPLAY), + SDLK_AUDIOMUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOMUTE), + SDLK_MEDIASELECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIASELECT), + SDLK_WWW = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_WWW), + SDLK_MAIL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MAIL), + SDLK_CALCULATOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CALCULATOR), + SDLK_COMPUTER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_COMPUTER), + SDLK_AC_SEARCH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_SEARCH), + SDLK_AC_HOME = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_HOME), + SDLK_AC_BACK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_BACK), + SDLK_AC_FORWARD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_FORWARD), + SDLK_AC_STOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_STOP), + SDLK_AC_REFRESH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_REFRESH), + SDLK_AC_BOOKMARKS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_BOOKMARKS), + + SDLK_BRIGHTNESSDOWN = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_BRIGHTNESSDOWN), + SDLK_BRIGHTNESSUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_BRIGHTNESSUP), + SDLK_DISPLAYSWITCH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DISPLAYSWITCH), + SDLK_KBDILLUMTOGGLE = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMTOGGLE), + SDLK_KBDILLUMDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMDOWN), + SDLK_KBDILLUMUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMUP), + SDLK_EJECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EJECT), + SDLK_SLEEP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SLEEP) +}; + +/** + * \brief Enumeration of valid key mods (possibly OR'd together). + */ +typedef enum +{ + KMOD_NONE = 0x0000, + KMOD_LSHIFT = 0x0001, + KMOD_RSHIFT = 0x0002, + KMOD_LCTRL = 0x0040, + KMOD_RCTRL = 0x0080, + KMOD_LALT = 0x0100, + KMOD_RALT = 0x0200, + KMOD_LGUI = 0x0400, + KMOD_RGUI = 0x0800, + KMOD_NUM = 0x1000, + KMOD_CAPS = 0x2000, + KMOD_MODE = 0x4000, + KMOD_RESERVED = 0x8000 +} SDL_Keymod; + +#define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL) +#define KMOD_SHIFT (KMOD_LSHIFT|KMOD_RSHIFT) +#define KMOD_ALT (KMOD_LALT|KMOD_RALT) +#define KMOD_GUI (KMOD_LGUI|KMOD_RGUI) + +#endif /* _SDL_keycode_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_loadso.h spring-98.0~14.04~ppa6/include/SDL2/SDL_loadso.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_loadso.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_loadso.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,81 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_loadso.h + * + * System dependent library loading routines + * + * Some things to keep in mind: + * \li These functions only work on C function names. Other languages may + * have name mangling and intrinsic language support that varies from + * compiler to compiler. + * \li Make sure you declare your function pointers with the same calling + * convention as the actual library function. Your code will crash + * mysteriously if you do not do this. + * \li Avoid namespace collisions. If you load a symbol from the library, + * it is not defined whether or not it goes into the global symbol + * namespace for the application. If it does and it conflicts with + * symbols in your code or other shared libraries, you will not get + * the results you expect. :) + */ + +#ifndef _SDL_loadso_h +#define _SDL_loadso_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This function dynamically loads a shared object and returns a pointer + * to the object handle (or NULL if there was an error). + * The 'sofile' parameter is a system dependent name of the object file. + */ +extern DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile); + +/** + * Given an object handle, this function looks up the address of the + * named function in the shared object and returns it. This address + * is no longer valid after calling SDL_UnloadObject(). + */ +extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle, + const char *name); + +/** + * Unload a shared object from memory. + */ +extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_loadso_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_log.h spring-98.0~14.04~ppa6/include/SDL2/SDL_log.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_log.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_log.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,211 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_log.h + * + * Simple log messages with categories and priorities. + * + * By default logs are quiet, but if you're debugging SDL you might want: + * + * SDL_LogSetAllPriority(SDL_LOG_PRIORITY_WARN); + * + * Here's where the messages go on different platforms: + * Windows: debug output stream + * Android: log output + * Others: standard error output (stderr) + */ + +#ifndef _SDL_log_h +#define _SDL_log_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * \brief The maximum size of a log message + * + * Messages longer than the maximum size will be truncated + */ +#define SDL_MAX_LOG_MESSAGE 4096 + +/** + * \brief The predefined log categories + * + * By default the application category is enabled at the INFO level, + * the assert category is enabled at the WARN level, test is enabled + * at the VERBOSE level and all other categories are enabled at the + * CRITICAL level. + */ +enum +{ + SDL_LOG_CATEGORY_APPLICATION, + SDL_LOG_CATEGORY_ERROR, + SDL_LOG_CATEGORY_ASSERT, + SDL_LOG_CATEGORY_SYSTEM, + SDL_LOG_CATEGORY_AUDIO, + SDL_LOG_CATEGORY_VIDEO, + SDL_LOG_CATEGORY_RENDER, + SDL_LOG_CATEGORY_INPUT, + SDL_LOG_CATEGORY_TEST, + + /* Reserved for future SDL library use */ + SDL_LOG_CATEGORY_RESERVED1, + SDL_LOG_CATEGORY_RESERVED2, + SDL_LOG_CATEGORY_RESERVED3, + SDL_LOG_CATEGORY_RESERVED4, + SDL_LOG_CATEGORY_RESERVED5, + SDL_LOG_CATEGORY_RESERVED6, + SDL_LOG_CATEGORY_RESERVED7, + SDL_LOG_CATEGORY_RESERVED8, + SDL_LOG_CATEGORY_RESERVED9, + SDL_LOG_CATEGORY_RESERVED10, + + /* Beyond this point is reserved for application use, e.g. + enum { + MYAPP_CATEGORY_AWESOME1 = SDL_LOG_CATEGORY_CUSTOM, + MYAPP_CATEGORY_AWESOME2, + MYAPP_CATEGORY_AWESOME3, + ... + }; + */ + SDL_LOG_CATEGORY_CUSTOM +}; + +/** + * \brief The predefined log priorities + */ +typedef enum +{ + SDL_LOG_PRIORITY_VERBOSE = 1, + SDL_LOG_PRIORITY_DEBUG, + SDL_LOG_PRIORITY_INFO, + SDL_LOG_PRIORITY_WARN, + SDL_LOG_PRIORITY_ERROR, + SDL_LOG_PRIORITY_CRITICAL, + SDL_NUM_LOG_PRIORITIES +} SDL_LogPriority; + + +/** + * \brief Set the priority of all log categories + */ +extern DECLSPEC void SDLCALL SDL_LogSetAllPriority(SDL_LogPriority priority); + +/** + * \brief Set the priority of a particular log category + */ +extern DECLSPEC void SDLCALL SDL_LogSetPriority(int category, + SDL_LogPriority priority); + +/** + * \brief Get the priority of a particular log category + */ +extern DECLSPEC SDL_LogPriority SDLCALL SDL_LogGetPriority(int category); + +/** + * \brief Reset all priorities to default. + * + * \note This is called in SDL_Quit(). + */ +extern DECLSPEC void SDLCALL SDL_LogResetPriorities(void); + +/** + * \brief Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO + */ +extern DECLSPEC void SDLCALL SDL_Log(const char *fmt, ...); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_VERBOSE + */ +extern DECLSPEC void SDLCALL SDL_LogVerbose(int category, const char *fmt, ...); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_DEBUG + */ +extern DECLSPEC void SDLCALL SDL_LogDebug(int category, const char *fmt, ...); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_INFO + */ +extern DECLSPEC void SDLCALL SDL_LogInfo(int category, const char *fmt, ...); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_WARN + */ +extern DECLSPEC void SDLCALL SDL_LogWarn(int category, const char *fmt, ...); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_ERROR + */ +extern DECLSPEC void SDLCALL SDL_LogError(int category, const char *fmt, ...); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_CRITICAL + */ +extern DECLSPEC void SDLCALL SDL_LogCritical(int category, const char *fmt, ...); + +/** + * \brief Log a message with the specified category and priority. + */ +extern DECLSPEC void SDLCALL SDL_LogMessage(int category, + SDL_LogPriority priority, + const char *fmt, ...); + +/** + * \brief Log a message with the specified category and priority. + */ +extern DECLSPEC void SDLCALL SDL_LogMessageV(int category, + SDL_LogPriority priority, + const char *fmt, va_list ap); + +/** + * \brief The prototype for the log output function + */ +typedef void (*SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message); + +/** + * \brief Get the current log output function. + */ +extern DECLSPEC void SDLCALL SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata); + +/** + * \brief This function allows you to replace the default log output + * function with one of your own. + */ +extern DECLSPEC void SDLCALL SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_log_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_main.h spring-98.0~14.04~ppa6/include/SDL2/SDL_main.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_main.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_main.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,125 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_main_h +#define _SDL_main_h + +#include "SDL_stdinc.h" + +/** + * \file SDL_main.h + * + * Redefine main() on some platforms so that it is called by SDL. + */ + +#ifndef SDL_MAIN_HANDLED +#if defined(__WIN32__) +/* On Windows SDL provides WinMain(), which parses the command line and passes + the arguments to your main function. + + If you provide your own WinMain(), you may define SDL_MAIN_HANDLED + */ +#define SDL_MAIN_AVAILABLE + +#elif defined(__IPHONEOS__) +/* On iOS SDL provides a main function that creates an application delegate + and starts the iOS application run loop. + + See src/video/uikit/SDL_uikitappdelegate.m for more details. + */ +#define SDL_MAIN_NEEDED + +#elif defined(__ANDROID__) +/* On Android SDL provides a Java class in SDLActivity.java that is the + main activity entry point. + + See README-android.txt for more details on extending that class. + */ +#define SDL_MAIN_NEEDED + +#endif +#endif /* SDL_MAIN_HANDLED */ + +#ifdef __cplusplus +#define C_LINKAGE "C" +#else +#define C_LINKAGE +#endif /* __cplusplus */ + +/** + * \file SDL_main.h + * + * The application's main() function must be called with C linkage, + * and should be declared like this: + * \code + * #ifdef __cplusplus + * extern "C" + * #endif + * int main(int argc, char *argv[]) + * { + * } + * \endcode + */ + +#if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE) +#define main SDL_main +#endif + +/** + * The prototype for the application's main() function + */ +extern C_LINKAGE int SDL_main(int argc, char *argv[]); + + +#include "begin_code.h" +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This is called by the real SDL main function to let the rest of the + * library know that initialization was done properly. + * + * Calling this yourself without knowing what you're doing can cause + * crashes and hard to diagnose problems with your application. + */ +extern DECLSPEC void SDL_SetMainReady(void); + +#ifdef __WIN32__ + +/** + * This can be called to set the application class at startup + */ +extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, + void *hInst); +extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); + +#endif /* __WIN32__ */ + + +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_main_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_messagebox.h spring-98.0~14.04~ppa6/include/SDL2/SDL_messagebox.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_messagebox.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_messagebox.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,144 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_messagebox_h +#define _SDL_messagebox_h + +#include "SDL_stdinc.h" +#include "SDL_video.h" /* For SDL_Window */ + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief SDL_MessageBox flags. If supported will display warning icon, etc. + */ +typedef enum +{ + SDL_MESSAGEBOX_ERROR = 0x00000010, /**< error dialog */ + SDL_MESSAGEBOX_WARNING = 0x00000020, /**< warning dialog */ + SDL_MESSAGEBOX_INFORMATION = 0x00000040 /**< informational dialog */ +} SDL_MessageBoxFlags; + +/** + * \brief Flags for SDL_MessageBoxButtonData. + */ +typedef enum +{ + SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001, /**< Marks the default button when return is hit */ + SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002 /**< Marks the default button when escape is hit */ +} SDL_MessageBoxButtonFlags; + +/** + * \brief Individual button data. + */ +typedef struct +{ + Uint32 flags; /**< ::SDL_MessageBoxButtonFlags */ + int buttonid; /**< User defined button id (value returned via SDL_ShowMessageBox) */ + const char * text; /**< The UTF-8 button text */ +} SDL_MessageBoxButtonData; + +/** + * \brief RGB value used in a message box color scheme + */ +typedef struct +{ + Uint8 r, g, b; +} SDL_MessageBoxColor; + +typedef enum +{ + SDL_MESSAGEBOX_COLOR_BACKGROUND, + SDL_MESSAGEBOX_COLOR_TEXT, + SDL_MESSAGEBOX_COLOR_BUTTON_BORDER, + SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND, + SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, + SDL_MESSAGEBOX_COLOR_MAX +} SDL_MessageBoxColorType; + +/** + * \brief A set of colors to use for message box dialogs + */ +typedef struct +{ + SDL_MessageBoxColor colors[SDL_MESSAGEBOX_COLOR_MAX]; +} SDL_MessageBoxColorScheme; + +/** + * \brief MessageBox structure containing title, text, window, etc. + */ +typedef struct +{ + Uint32 flags; /**< ::SDL_MessageBoxFlags */ + SDL_Window *window; /**< Parent window, can be NULL */ + const char *title; /**< UTF-8 title */ + const char *message; /**< UTF-8 message text */ + + int numbuttons; + const SDL_MessageBoxButtonData *buttons; + + const SDL_MessageBoxColorScheme *colorScheme; /**< ::SDL_MessageBoxColorScheme, can be NULL to use system settings */ +} SDL_MessageBoxData; + +/** + * \brief Create a modal message box. + * + * \param messageboxdata The SDL_MessageBoxData structure with title, text, etc. + * \param buttonid The pointer to which user id of hit button should be copied. + * + * \return -1 on error, otherwise 0 and buttonid contains user id of button + * hit or -1 if dialog was closed. + * + * \note This function should be called on the thread that created the parent + * window, or on the main thread if the messagebox has no parent. It will + * block execution of that thread until the user clicks a button or + * closes the messagebox. + */ +extern DECLSPEC int SDLCALL SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); + +/** + * \brief Create a simple modal message box + * + * \param flags ::SDL_MessageBoxFlags + * \param title UTF-8 title text + * \param message UTF-8 message text + * \param window The parent window, or NULL for no parent + * + * \return 0 on success, -1 on error + * + * \sa SDL_ShowMessageBox + */ +extern DECLSPEC int SDLCALL SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_messagebox_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_mouse.h spring-98.0~14.04~ppa6/include/SDL2/SDL_mouse.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_mouse.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_mouse.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,224 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_mouse.h + * + * Include file for SDL mouse event handling. + */ + +#ifndef _SDL_mouse_h +#define _SDL_mouse_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct SDL_Cursor SDL_Cursor; /* Implementation dependent */ + +/** + * \brief Cursor types for SDL_CreateSystemCursor. + */ +typedef enum +{ + SDL_SYSTEM_CURSOR_ARROW, /**< Arrow */ + SDL_SYSTEM_CURSOR_IBEAM, /**< I-beam */ + SDL_SYSTEM_CURSOR_WAIT, /**< Wait */ + SDL_SYSTEM_CURSOR_CROSSHAIR, /**< Crosshair */ + SDL_SYSTEM_CURSOR_WAITARROW, /**< Small wait cursor (or Wait if not available) */ + SDL_SYSTEM_CURSOR_SIZENWSE, /**< Double arrow pointing northwest and southeast */ + SDL_SYSTEM_CURSOR_SIZENESW, /**< Double arrow pointing northeast and southwest */ + SDL_SYSTEM_CURSOR_SIZEWE, /**< Double arrow pointing west and east */ + SDL_SYSTEM_CURSOR_SIZENS, /**< Double arrow pointing north and south */ + SDL_SYSTEM_CURSOR_SIZEALL, /**< Four pointed arrow pointing north, south, east, and west */ + SDL_SYSTEM_CURSOR_NO, /**< Slashed circle or crossbones */ + SDL_SYSTEM_CURSOR_HAND, /**< Hand */ + SDL_NUM_SYSTEM_CURSORS +} SDL_SystemCursor; + +/* Function prototypes */ + +/** + * \brief Get the window which currently has mouse focus. + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void); + +/** + * \brief Retrieve the current state of the mouse. + * + * The current button state is returned as a button bitmask, which can + * be tested using the SDL_BUTTON(X) macros, and x and y are set to the + * mouse cursor position relative to the focus window for the currently + * selected mouse. You can pass NULL for either x or y. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetMouseState(int *x, int *y); + +/** + * \brief Retrieve the relative state of the mouse. + * + * The current button state is returned as a button bitmask, which can + * be tested using the SDL_BUTTON(X) macros, and x and y are set to the + * mouse deltas since the last call to SDL_GetRelativeMouseState(). + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y); + +/** + * \brief Moves the mouse to the given position within the window. + * + * \param window The window to move the mouse into, or NULL for the current mouse focus + * \param x The x coordinate within the window + * \param y The y coordinate within the window + * + * \note This function generates a mouse motion event + */ +extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window, + int x, int y); + +/** + * \brief Set relative mouse mode. + * + * \param enabled Whether or not to enable relative mode + * + * \return 0 on success, or -1 if relative mode is not supported. + * + * While the mouse is in relative mode, the cursor is hidden, and the + * driver will try to report continuous motion in the current window. + * Only relative motion events will be delivered, the mouse position + * will not change. + * + * \note This function will flush any pending mouse motion. + * + * \sa SDL_GetRelativeMouseMode() + */ +extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled); + +/** + * \brief Query whether relative mouse mode is enabled. + * + * \sa SDL_SetRelativeMouseMode() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void); + +/** + * \brief Create a cursor, using the specified bitmap data and + * mask (in MSB format). + * + * The cursor width must be a multiple of 8 bits. + * + * The cursor is created in black and white according to the following: + * + * + * + * + * + * + *
data mask resulting pixel on screen
0 1 White
1 1 Black
0 0 Transparent
1 0 Inverted color if possible, black + * if not.
+ * + * \sa SDL_FreeCursor() + */ +extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data, + const Uint8 * mask, + int w, int h, int hot_x, + int hot_y); + +/** + * \brief Create a color cursor. + * + * \sa SDL_FreeCursor() + */ +extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface, + int hot_x, + int hot_y); + +/** + * \brief Create a system cursor. + * + * \sa SDL_FreeCursor() + */ +extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id); + +/** + * \brief Set the active cursor. + */ +extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor); + +/** + * \brief Return the active cursor. + */ +extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void); + +/** + * \brief Return the default cursor. + */ +extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetDefaultCursor(void); + +/** + * \brief Frees a cursor created with SDL_CreateCursor(). + * + * \sa SDL_CreateCursor() + */ +extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor); + +/** + * \brief Toggle whether or not the cursor is shown. + * + * \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current + * state. + * + * \return 1 if the cursor is shown, or 0 if the cursor is hidden. + */ +extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle); + +/** + * Used as a mask when testing buttons in buttonstate. + * - Button 1: Left mouse button + * - Button 2: Middle mouse button + * - Button 3: Right mouse button + */ +#define SDL_BUTTON(X) (1 << ((X)-1)) +#define SDL_BUTTON_LEFT 1 +#define SDL_BUTTON_MIDDLE 2 +#define SDL_BUTTON_RIGHT 3 +#define SDL_BUTTON_X1 4 +#define SDL_BUTTON_X2 5 +#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT) +#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE) +#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT) +#define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1) +#define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2) + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_mouse_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_mutex.h spring-98.0~14.04~ppa6/include/SDL2/SDL_mutex.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_mutex.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_mutex.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,251 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_mutex_h +#define _SDL_mutex_h + +/** + * \file SDL_mutex.h + * + * Functions to provide thread synchronization primitives. + */ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Synchronization functions which can time out return this value + * if they time out. + */ +#define SDL_MUTEX_TIMEDOUT 1 + +/** + * This is the timeout value which corresponds to never time out. + */ +#define SDL_MUTEX_MAXWAIT (~(Uint32)0) + + +/** + * \name Mutex functions + */ +/* @{ */ + +/* The SDL mutex structure, defined in SDL_sysmutex.c */ +struct SDL_mutex; +typedef struct SDL_mutex SDL_mutex; + +/** + * Create a mutex, initialized unlocked. + */ +extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void); + +/** + * Lock the mutex. + * + * \return 0, or -1 on error. + */ +#define SDL_mutexP(m) SDL_LockMutex(m) +extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex); + +/** + * Try to lock the mutex + * + * \return 0, SDL_MUTEX_TIMEDOUT, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex); + +/** + * Unlock the mutex. + * + * \return 0, or -1 on error. + * + * \warning It is an error to unlock a mutex that has not been locked by + * the current thread, and doing so results in undefined behavior. + */ +#define SDL_mutexV(m) SDL_UnlockMutex(m) +extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex); + +/** + * Destroy a mutex. + */ +extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex * mutex); + +/* @} *//* Mutex functions */ + + +/** + * \name Semaphore functions + */ +/* @{ */ + +/* The SDL semaphore structure, defined in SDL_syssem.c */ +struct SDL_semaphore; +typedef struct SDL_semaphore SDL_sem; + +/** + * Create a semaphore, initialized with value, returns NULL on failure. + */ +extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value); + +/** + * Destroy a semaphore. + */ +extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem * sem); + +/** + * This function suspends the calling thread until the semaphore pointed + * to by \c sem has a positive count. It then atomically decreases the + * semaphore count. + */ +extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem * sem); + +/** + * Non-blocking variant of SDL_SemWait(). + * + * \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait would + * block, and -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem); + +/** + * Variant of SDL_SemWait() with a timeout in milliseconds. + * + * \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait does not + * succeed in the allotted time, and -1 on error. + * + * \warning On some platforms this function is implemented by looping with a + * delay of 1 ms, and so should be avoided if possible. + */ +extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem * sem, Uint32 ms); + +/** + * Atomically increases the semaphore's count (not blocking). + * + * \return 0, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem * sem); + +/** + * Returns the current count of the semaphore. + */ +extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem * sem); + +/* @} *//* Semaphore functions */ + + +/** + * \name Condition variable functions + */ +/* @{ */ + +/* The SDL condition variable structure, defined in SDL_syscond.c */ +struct SDL_cond; +typedef struct SDL_cond SDL_cond; + +/** + * Create a condition variable. + * + * Typical use of condition variables: + * + * Thread A: + * SDL_LockMutex(lock); + * while ( ! condition ) { + * SDL_CondWait(cond, lock); + * } + * SDL_UnlockMutex(lock); + * + * Thread B: + * SDL_LockMutex(lock); + * ... + * condition = true; + * ... + * SDL_CondSignal(cond); + * SDL_UnlockMutex(lock); + * + * There is some discussion whether to signal the condition variable + * with the mutex locked or not. There is some potential performance + * benefit to unlocking first on some platforms, but there are some + * potential race conditions depending on how your code is structured. + * + * In general it's safer to signal the condition variable while the + * mutex is locked. + */ +extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void); + +/** + * Destroy a condition variable. + */ +extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond * cond); + +/** + * Restart one of the threads that are waiting on the condition variable. + * + * \return 0 or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond * cond); + +/** + * Restart all threads that are waiting on the condition variable. + * + * \return 0 or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond * cond); + +/** + * Wait on the condition variable, unlocking the provided mutex. + * + * \warning The mutex must be locked before entering this function! + * + * The mutex is re-locked once the condition variable is signaled. + * + * \return 0 when it is signaled, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex); + +/** + * Waits for at most \c ms milliseconds, and returns 0 if the condition + * variable is signaled, ::SDL_MUTEX_TIMEDOUT if the condition is not + * signaled in the allotted time, and -1 on error. + * + * \warning On some platforms this function is implemented by looping with a + * delay of 1 ms, and so should be avoided if possible. + */ +extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond * cond, + SDL_mutex * mutex, Uint32 ms); + +/* @} *//* Condition variable functions */ + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_mutex_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_name.h spring-98.0~14.04~ppa6/include/SDL2/SDL_name.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_name.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_name.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,11 @@ + +#ifndef _SDLname_h_ +#define _SDLname_h_ + +#if defined(__STDC__) || defined(__cplusplus) +#define NeedFunctionPrototypes 1 +#endif + +#define SDL_NAME(X) SDL_##X + +#endif /* _SDLname_h_ */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_opengles2.h spring-98.0~14.04~ppa6/include/SDL2/SDL_opengles2.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_opengles2.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_opengles2.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,38 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_opengles.h + * + * This is a simple file to encapsulate the OpenGL ES 2.0 API headers. + */ + +#ifdef __IPHONEOS__ +#include +#include +#else +#include +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_opengles.h spring-98.0~14.04~ppa6/include/SDL2/SDL_opengles.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_opengles.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_opengles.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,38 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_opengles.h + * + * This is a simple file to encapsulate the OpenGL ES 1.X API headers. + */ + +#ifdef __IPHONEOS__ +#include +#include +#else +#include +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_opengl.h spring-98.0~14.04~ppa6/include/SDL2/SDL_opengl.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_opengl.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_opengl.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,11126 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_opengl.h + * + * This is a simple file to encapsulate the OpenGL API headers. + */ + +#ifndef _SDL_opengl_h +#define _SDL_opengl_h + +#include "SDL_config.h" + +#ifndef __IPHONEOS__ + +#ifdef __WIN32__ +#define WIN32_LEAN_AND_MEAN +#ifndef NOMINMAX +#define NOMINMAX /* Don't defined min() and max() */ +#endif +#include +#endif + +#ifdef __glext_h_ +/* Someone has already included glext.h */ +#define NO_SDL_GLEXT +#endif +#ifndef NO_SDL_GLEXT +#define __glext_h_ /* Don't let gl.h include glext.h */ +#endif +#if defined(__MACOSX__) +#include /* Header File For The OpenGL Library */ +#define __X_GL_H +#else +#include /* Header File For The OpenGL Library */ +#endif +#ifndef NO_SDL_GLEXT +#undef __glext_h_ +#endif + +/** + * \file SDL_opengl.h + * + * This file is included because glext.h is not available on some systems. + * If you don't want this version included, simply define ::NO_SDL_GLEXT. + * + * The latest version is available from: + * http://www.opengl.org/registry/ + */ + +/** + * \def NO_SDL_GLEXT + * + * Define this if you have your own version of glext.h and want to disable the + * version included in SDL_opengl.h. + */ + +#if !defined(NO_SDL_GLEXT) && !defined(GL_GLEXT_LEGACY) +#ifndef __glext_h_ +#define __glext_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2007-2010 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Header file version number, required by OpenGL ABI for Linux */ +/* glext.h last updated $Date: 2010-08-03 01:30:25 -0700 (Tue, 03 Aug 2010) $ */ +/* Current version at http://www.opengl.org/registry/ */ +#define GL_GLEXT_VERSION 64 +/* Function declaration macros - to move into glplatform.h */ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +/*************************************************************/ + +#ifndef GL_VERSION_1_2 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#endif + +#ifndef GL_VERSION_1_2_DEPRECATED +#define GL_RESCALE_NORMAL 0x803A +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#endif + +#ifndef GL_ARB_imaging +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_FUNC_ADD 0x8006 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_BLEND_EQUATION 0x8009 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#endif + +#ifndef GL_ARB_imaging_DEPRECATED +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#endif + +#ifndef GL_VERSION_1_3 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#endif + +#ifndef GL_VERSION_1_3_DEPRECATED +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +#endif + +#ifndef GL_VERSION_1_4 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#endif + +#ifndef GL_VERSION_1_4_DEPRECATED +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#endif + +#ifndef GL_VERSION_1_5 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#endif + +#ifndef GL_VERSION_1_5_DEPRECATED +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_FOG_COORD_SRC 0x8450 +#define GL_FOG_COORD 0x8451 +#define GL_CURRENT_FOG_COORD 0x8453 +#define GL_FOG_COORD_ARRAY_TYPE 0x8454 +#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORD_ARRAY_POINTER 0x8456 +#define GL_FOG_COORD_ARRAY 0x8457 +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D +#define GL_SRC0_RGB 0x8580 +#define GL_SRC1_RGB 0x8581 +#define GL_SRC2_RGB 0x8582 +#define GL_SRC0_ALPHA 0x8588 +#define GL_SRC1_ALPHA 0x8589 +#define GL_SRC2_ALPHA 0x858A +#endif + +#ifndef GL_VERSION_2_0 +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#endif + +#ifndef GL_VERSION_2_0_DEPRECATED +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_TEXTURE_COORDS 0x8871 +#endif + +#ifndef GL_VERSION_2_1 +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#endif + +#ifndef GL_VERSION_2_1_DEPRECATED +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F +#define GL_SLUMINANCE_ALPHA 0x8C44 +#define GL_SLUMINANCE8_ALPHA8 0x8C45 +#define GL_SLUMINANCE 0x8C46 +#define GL_SLUMINANCE8 0x8C47 +#define GL_COMPRESSED_SLUMINANCE 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B +#endif + +#ifndef GL_VERSION_3_0 +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_CLIP_DISTANCE0 0x3000 +#define GL_CLIP_DISTANCE1 0x3001 +#define GL_CLIP_DISTANCE2 0x3002 +#define GL_CLIP_DISTANCE3 0x3003 +#define GL_CLIP_DISTANCE4 0x3004 +#define GL_CLIP_DISTANCE5 0x3005 +#define GL_CLIP_DISTANCE6 0x3006 +#define GL_CLIP_DISTANCE7 0x3007 +#define GL_MAX_CLIP_DISTANCES 0x0D32 +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_CONTEXT_FLAGS 0x821E +#define GL_DEPTH_BUFFER 0x8223 +#define GL_STENCIL_BUFFER 0x8224 +#define GL_COMPRESSED_RED 0x8225 +#define GL_COMPRESSED_RG 0x8226 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_FIXED_ONLY 0x891D +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_1D_ARRAY 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_GREEN_INTEGER 0x8D95 +#define GL_BLUE_INTEGER 0x8D96 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_BGR_INTEGER 0x8D9A +#define GL_BGRA_INTEGER 0x8D9B +#define GL_SAMPLER_1D_ARRAY 0x8DC0 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_1D 0x8DC9 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_QUERY_WAIT 0x8E13 +#define GL_QUERY_NO_WAIT 0x8E14 +#define GL_QUERY_BY_REGION_WAIT 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +/* Reuse tokens from ARB_depth_buffer_float */ +/* reuse GL_DEPTH_COMPONENT32F */ +/* reuse GL_DEPTH32F_STENCIL8 */ +/* reuse GL_FLOAT_32_UNSIGNED_INT_24_8_REV */ +/* Reuse tokens from ARB_framebuffer_object */ +/* reuse GL_INVALID_FRAMEBUFFER_OPERATION */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ +/* reuse GL_FRAMEBUFFER_DEFAULT */ +/* reuse GL_FRAMEBUFFER_UNDEFINED */ +/* reuse GL_DEPTH_STENCIL_ATTACHMENT */ +/* reuse GL_INDEX */ +/* reuse GL_MAX_RENDERBUFFER_SIZE */ +/* reuse GL_DEPTH_STENCIL */ +/* reuse GL_UNSIGNED_INT_24_8 */ +/* reuse GL_DEPTH24_STENCIL8 */ +/* reuse GL_TEXTURE_STENCIL_SIZE */ +/* reuse GL_TEXTURE_RED_TYPE */ +/* reuse GL_TEXTURE_GREEN_TYPE */ +/* reuse GL_TEXTURE_BLUE_TYPE */ +/* reuse GL_TEXTURE_ALPHA_TYPE */ +/* reuse GL_TEXTURE_DEPTH_TYPE */ +/* reuse GL_UNSIGNED_NORMALIZED */ +/* reuse GL_FRAMEBUFFER_BINDING */ +/* reuse GL_DRAW_FRAMEBUFFER_BINDING */ +/* reuse GL_RENDERBUFFER_BINDING */ +/* reuse GL_READ_FRAMEBUFFER */ +/* reuse GL_DRAW_FRAMEBUFFER */ +/* reuse GL_READ_FRAMEBUFFER_BINDING */ +/* reuse GL_RENDERBUFFER_SAMPLES */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ +/* reuse GL_FRAMEBUFFER_COMPLETE */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ +/* reuse GL_FRAMEBUFFER_UNSUPPORTED */ +/* reuse GL_MAX_COLOR_ATTACHMENTS */ +/* reuse GL_COLOR_ATTACHMENT0 */ +/* reuse GL_COLOR_ATTACHMENT1 */ +/* reuse GL_COLOR_ATTACHMENT2 */ +/* reuse GL_COLOR_ATTACHMENT3 */ +/* reuse GL_COLOR_ATTACHMENT4 */ +/* reuse GL_COLOR_ATTACHMENT5 */ +/* reuse GL_COLOR_ATTACHMENT6 */ +/* reuse GL_COLOR_ATTACHMENT7 */ +/* reuse GL_COLOR_ATTACHMENT8 */ +/* reuse GL_COLOR_ATTACHMENT9 */ +/* reuse GL_COLOR_ATTACHMENT10 */ +/* reuse GL_COLOR_ATTACHMENT11 */ +/* reuse GL_COLOR_ATTACHMENT12 */ +/* reuse GL_COLOR_ATTACHMENT13 */ +/* reuse GL_COLOR_ATTACHMENT14 */ +/* reuse GL_COLOR_ATTACHMENT15 */ +/* reuse GL_DEPTH_ATTACHMENT */ +/* reuse GL_STENCIL_ATTACHMENT */ +/* reuse GL_FRAMEBUFFER */ +/* reuse GL_RENDERBUFFER */ +/* reuse GL_RENDERBUFFER_WIDTH */ +/* reuse GL_RENDERBUFFER_HEIGHT */ +/* reuse GL_RENDERBUFFER_INTERNAL_FORMAT */ +/* reuse GL_STENCIL_INDEX1 */ +/* reuse GL_STENCIL_INDEX4 */ +/* reuse GL_STENCIL_INDEX8 */ +/* reuse GL_STENCIL_INDEX16 */ +/* reuse GL_RENDERBUFFER_RED_SIZE */ +/* reuse GL_RENDERBUFFER_GREEN_SIZE */ +/* reuse GL_RENDERBUFFER_BLUE_SIZE */ +/* reuse GL_RENDERBUFFER_ALPHA_SIZE */ +/* reuse GL_RENDERBUFFER_DEPTH_SIZE */ +/* reuse GL_RENDERBUFFER_STENCIL_SIZE */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ +/* reuse GL_MAX_SAMPLES */ +/* Reuse tokens from ARB_framebuffer_sRGB */ +/* reuse GL_FRAMEBUFFER_SRGB */ +/* Reuse tokens from ARB_half_float_vertex */ +/* reuse GL_HALF_FLOAT */ +/* Reuse tokens from ARB_map_buffer_range */ +/* reuse GL_MAP_READ_BIT */ +/* reuse GL_MAP_WRITE_BIT */ +/* reuse GL_MAP_INVALIDATE_RANGE_BIT */ +/* reuse GL_MAP_INVALIDATE_BUFFER_BIT */ +/* reuse GL_MAP_FLUSH_EXPLICIT_BIT */ +/* reuse GL_MAP_UNSYNCHRONIZED_BIT */ +/* Reuse tokens from ARB_texture_compression_rgtc */ +/* reuse GL_COMPRESSED_RED_RGTC1 */ +/* reuse GL_COMPRESSED_SIGNED_RED_RGTC1 */ +/* reuse GL_COMPRESSED_RG_RGTC2 */ +/* reuse GL_COMPRESSED_SIGNED_RG_RGTC2 */ +/* Reuse tokens from ARB_texture_rg */ +/* reuse GL_RG */ +/* reuse GL_RG_INTEGER */ +/* reuse GL_R8 */ +/* reuse GL_R16 */ +/* reuse GL_RG8 */ +/* reuse GL_RG16 */ +/* reuse GL_R16F */ +/* reuse GL_R32F */ +/* reuse GL_RG16F */ +/* reuse GL_RG32F */ +/* reuse GL_R8I */ +/* reuse GL_R8UI */ +/* reuse GL_R16I */ +/* reuse GL_R16UI */ +/* reuse GL_R32I */ +/* reuse GL_R32UI */ +/* reuse GL_RG8I */ +/* reuse GL_RG8UI */ +/* reuse GL_RG16I */ +/* reuse GL_RG16UI */ +/* reuse GL_RG32I */ +/* reuse GL_RG32UI */ +/* Reuse tokens from ARB_vertex_array_object */ +/* reuse GL_VERTEX_ARRAY_BINDING */ +#endif + +#ifndef GL_VERSION_3_0_DEPRECATED +#define GL_CLAMP_VERTEX_COLOR 0x891A +#define GL_CLAMP_FRAGMENT_COLOR 0x891B +#define GL_ALPHA_INTEGER 0x8D97 +/* Reuse tokens from ARB_framebuffer_object */ +/* reuse GL_TEXTURE_LUMINANCE_TYPE */ +/* reuse GL_TEXTURE_INTENSITY_TYPE */ +#endif + +#ifndef GL_VERSION_3_1 +#define GL_SAMPLER_2D_RECT 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_INT_SAMPLER_2D_RECT 0x8DCD +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT 0x8C2E +#define GL_TEXTURE_RECTANGLE 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 +#define GL_RED_SNORM 0x8F90 +#define GL_RG_SNORM 0x8F91 +#define GL_RGB_SNORM 0x8F92 +#define GL_RGBA_SNORM 0x8F93 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM 0x8F98 +#define GL_RG16_SNORM 0x8F99 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGBA16_SNORM 0x8F9B +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART 0x8F9D +#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +/* Reuse tokens from ARB_copy_buffer */ +/* reuse GL_COPY_READ_BUFFER */ +/* reuse GL_COPY_WRITE_BUFFER */ +/* Reuse tokens from ARB_draw_instanced (none) */ +/* Reuse tokens from ARB_uniform_buffer_object */ +/* reuse GL_UNIFORM_BUFFER */ +/* reuse GL_UNIFORM_BUFFER_BINDING */ +/* reuse GL_UNIFORM_BUFFER_START */ +/* reuse GL_UNIFORM_BUFFER_SIZE */ +/* reuse GL_MAX_VERTEX_UNIFORM_BLOCKS */ +/* reuse GL_MAX_FRAGMENT_UNIFORM_BLOCKS */ +/* reuse GL_MAX_COMBINED_UNIFORM_BLOCKS */ +/* reuse GL_MAX_UNIFORM_BUFFER_BINDINGS */ +/* reuse GL_MAX_UNIFORM_BLOCK_SIZE */ +/* reuse GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS */ +/* reuse GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT */ +/* reuse GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH */ +/* reuse GL_ACTIVE_UNIFORM_BLOCKS */ +/* reuse GL_UNIFORM_TYPE */ +/* reuse GL_UNIFORM_SIZE */ +/* reuse GL_UNIFORM_NAME_LENGTH */ +/* reuse GL_UNIFORM_BLOCK_INDEX */ +/* reuse GL_UNIFORM_OFFSET */ +/* reuse GL_UNIFORM_ARRAY_STRIDE */ +/* reuse GL_UNIFORM_MATRIX_STRIDE */ +/* reuse GL_UNIFORM_IS_ROW_MAJOR */ +/* reuse GL_UNIFORM_BLOCK_BINDING */ +/* reuse GL_UNIFORM_BLOCK_DATA_SIZE */ +/* reuse GL_UNIFORM_BLOCK_NAME_LENGTH */ +/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS */ +/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER */ +/* reuse GL_INVALID_INDEX */ +#endif + +#ifndef GL_VERSION_3_2 +#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 +#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_PROGRAM_POINT_SIZE 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_CONTEXT_PROFILE_MASK 0x9126 +/* reuse GL_MAX_VARYING_COMPONENTS */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ +/* Reuse tokens from ARB_depth_clamp */ +/* reuse GL_DEPTH_CLAMP */ +/* Reuse tokens from ARB_draw_elements_base_vertex (none) */ +/* Reuse tokens from ARB_fragment_coord_conventions (none) */ +/* Reuse tokens from ARB_provoking_vertex */ +/* reuse GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ +/* reuse GL_FIRST_VERTEX_CONVENTION */ +/* reuse GL_LAST_VERTEX_CONVENTION */ +/* reuse GL_PROVOKING_VERTEX */ +/* Reuse tokens from ARB_seamless_cube_map */ +/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */ +/* Reuse tokens from ARB_sync */ +/* reuse GL_MAX_SERVER_WAIT_TIMEOUT */ +/* reuse GL_OBJECT_TYPE */ +/* reuse GL_SYNC_CONDITION */ +/* reuse GL_SYNC_STATUS */ +/* reuse GL_SYNC_FLAGS */ +/* reuse GL_SYNC_FENCE */ +/* reuse GL_SYNC_GPU_COMMANDS_COMPLETE */ +/* reuse GL_UNSIGNALED */ +/* reuse GL_SIGNALED */ +/* reuse GL_ALREADY_SIGNALED */ +/* reuse GL_TIMEOUT_EXPIRED */ +/* reuse GL_CONDITION_SATISFIED */ +/* reuse GL_WAIT_FAILED */ +/* reuse GL_TIMEOUT_IGNORED */ +/* reuse GL_SYNC_FLUSH_COMMANDS_BIT */ +/* reuse GL_TIMEOUT_IGNORED */ +/* Reuse tokens from ARB_texture_multisample */ +/* reuse GL_SAMPLE_POSITION */ +/* reuse GL_SAMPLE_MASK */ +/* reuse GL_SAMPLE_MASK_VALUE */ +/* reuse GL_MAX_SAMPLE_MASK_WORDS */ +/* reuse GL_TEXTURE_2D_MULTISAMPLE */ +/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE */ +/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE */ +/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_TEXTURE_SAMPLES */ +/* reuse GL_TEXTURE_FIXED_SAMPLE_LOCATIONS */ +/* reuse GL_SAMPLER_2D_MULTISAMPLE */ +/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE */ +/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE */ +/* reuse GL_SAMPLER_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_MAX_COLOR_TEXTURE_SAMPLES */ +/* reuse GL_MAX_DEPTH_TEXTURE_SAMPLES */ +/* reuse GL_MAX_INTEGER_SAMPLES */ +/* Don't need to reuse tokens from ARB_vertex_array_bgra since they're already in 1.2 core */ +#endif + +#ifndef GL_VERSION_3_3 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +/* Reuse tokens from ARB_blend_func_extended */ +/* reuse GL_SRC1_COLOR */ +/* reuse GL_ONE_MINUS_SRC1_COLOR */ +/* reuse GL_ONE_MINUS_SRC1_ALPHA */ +/* reuse GL_MAX_DUAL_SOURCE_DRAW_BUFFERS */ +/* Reuse tokens from ARB_explicit_attrib_location (none) */ +/* Reuse tokens from ARB_occlusion_query2 */ +/* reuse GL_ANY_SAMPLES_PASSED */ +/* Reuse tokens from ARB_sampler_objects */ +/* reuse GL_SAMPLER_BINDING */ +/* Reuse tokens from ARB_shader_bit_encoding (none) */ +/* Reuse tokens from ARB_texture_rgb10_a2ui */ +/* reuse GL_RGB10_A2UI */ +/* Reuse tokens from ARB_texture_swizzle */ +/* reuse GL_TEXTURE_SWIZZLE_R */ +/* reuse GL_TEXTURE_SWIZZLE_G */ +/* reuse GL_TEXTURE_SWIZZLE_B */ +/* reuse GL_TEXTURE_SWIZZLE_A */ +/* reuse GL_TEXTURE_SWIZZLE_RGBA */ +/* Reuse tokens from ARB_timer_query */ +/* reuse GL_TIME_ELAPSED */ +/* reuse GL_TIMESTAMP */ +/* Reuse tokens from ARB_vertex_type_2_10_10_10_rev */ +/* reuse GL_INT_2_10_10_10_REV */ +#endif + +#ifndef GL_VERSION_4_0 +#define GL_SAMPLE_SHADING 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F +/* Reuse tokens from ARB_texture_query_lod (none) */ +/* Reuse tokens from ARB_draw_buffers_blend (none) */ +/* Reuse tokens from ARB_draw_indirect */ +/* reuse GL_DRAW_INDIRECT_BUFFER */ +/* reuse GL_DRAW_INDIRECT_BUFFER_BINDING */ +/* Reuse tokens from ARB_gpu_shader5 */ +/* reuse GL_GEOMETRY_SHADER_INVOCATIONS */ +/* reuse GL_MAX_GEOMETRY_SHADER_INVOCATIONS */ +/* reuse GL_MIN_FRAGMENT_INTERPOLATION_OFFSET */ +/* reuse GL_MAX_FRAGMENT_INTERPOLATION_OFFSET */ +/* reuse GL_FRAGMENT_INTERPOLATION_OFFSET_BITS */ +/* reuse GL_MAX_VERTEX_STREAMS */ +/* Reuse tokens from ARB_gpu_shader_fp64 */ +/* reuse GL_DOUBLE_VEC2 */ +/* reuse GL_DOUBLE_VEC3 */ +/* reuse GL_DOUBLE_VEC4 */ +/* reuse GL_DOUBLE_MAT2 */ +/* reuse GL_DOUBLE_MAT3 */ +/* reuse GL_DOUBLE_MAT4 */ +/* reuse GL_DOUBLE_MAT2x3 */ +/* reuse GL_DOUBLE_MAT2x4 */ +/* reuse GL_DOUBLE_MAT3x2 */ +/* reuse GL_DOUBLE_MAT3x4 */ +/* reuse GL_DOUBLE_MAT4x2 */ +/* reuse GL_DOUBLE_MAT4x3 */ +/* Reuse tokens from ARB_shader_subroutine */ +/* reuse GL_ACTIVE_SUBROUTINES */ +/* reuse GL_ACTIVE_SUBROUTINE_UNIFORMS */ +/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS */ +/* reuse GL_ACTIVE_SUBROUTINE_MAX_LENGTH */ +/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH */ +/* reuse GL_MAX_SUBROUTINES */ +/* reuse GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS */ +/* reuse GL_NUM_COMPATIBLE_SUBROUTINES */ +/* reuse GL_COMPATIBLE_SUBROUTINES */ +/* Reuse tokens from ARB_tessellation_shader */ +/* reuse GL_PATCHES */ +/* reuse GL_PATCH_VERTICES */ +/* reuse GL_PATCH_DEFAULT_INNER_LEVEL */ +/* reuse GL_PATCH_DEFAULT_OUTER_LEVEL */ +/* reuse GL_TESS_CONTROL_OUTPUT_VERTICES */ +/* reuse GL_TESS_GEN_MODE */ +/* reuse GL_TESS_GEN_SPACING */ +/* reuse GL_TESS_GEN_VERTEX_ORDER */ +/* reuse GL_TESS_GEN_POINT_MODE */ +/* reuse GL_ISOLINES */ +/* reuse GL_FRACTIONAL_ODD */ +/* reuse GL_FRACTIONAL_EVEN */ +/* reuse GL_MAX_PATCH_VERTICES */ +/* reuse GL_MAX_TESS_GEN_LEVEL */ +/* reuse GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS */ +/* reuse GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS */ +/* reuse GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS */ +/* reuse GL_MAX_TESS_PATCH_COMPONENTS */ +/* reuse GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS */ +/* reuse GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS */ +/* reuse GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS */ +/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS */ +/* reuse GL_MAX_TESS_CONTROL_INPUT_COMPONENTS */ +/* reuse GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS */ +/* reuse GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER */ +/* reuse GL_TESS_EVALUATION_SHADER */ +/* reuse GL_TESS_CONTROL_SHADER */ +/* Reuse tokens from ARB_texture_buffer_object_rgb32 (none) */ +/* Reuse tokens from ARB_transform_feedback2 */ +/* reuse GL_TRANSFORM_FEEDBACK */ +/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */ +/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */ +/* reuse GL_TRANSFORM_FEEDBACK_BINDING */ +/* Reuse tokens from ARB_transform_feedback3 */ +/* reuse GL_MAX_TRANSFORM_FEEDBACK_BUFFERS */ +/* reuse GL_MAX_VERTEX_STREAMS */ +#endif + +#ifndef GL_VERSION_4_1 +/* Reuse tokens from ARB_ES2_compatibility */ +/* reuse GL_FIXED */ +/* reuse GL_IMPLEMENTATION_COLOR_READ_TYPE */ +/* reuse GL_IMPLEMENTATION_COLOR_READ_FORMAT */ +/* reuse GL_LOW_FLOAT */ +/* reuse GL_MEDIUM_FLOAT */ +/* reuse GL_HIGH_FLOAT */ +/* reuse GL_LOW_INT */ +/* reuse GL_MEDIUM_INT */ +/* reuse GL_HIGH_INT */ +/* reuse GL_SHADER_COMPILER */ +/* reuse GL_NUM_SHADER_BINARY_FORMATS */ +/* reuse GL_MAX_VERTEX_UNIFORM_VECTORS */ +/* reuse GL_MAX_VARYING_VECTORS */ +/* reuse GL_MAX_FRAGMENT_UNIFORM_VECTORS */ +/* Reuse tokens from ARB_get_program_binary */ +/* reuse GL_PROGRAM_BINARY_RETRIEVABLE_HINT */ +/* reuse GL_PROGRAM_BINARY_LENGTH */ +/* reuse GL_NUM_PROGRAM_BINARY_FORMATS */ +/* reuse GL_PROGRAM_BINARY_FORMATS */ +/* Reuse tokens from ARB_separate_shader_objects */ +/* reuse GL_VERTEX_SHADER_BIT */ +/* reuse GL_FRAGMENT_SHADER_BIT */ +/* reuse GL_GEOMETRY_SHADER_BIT */ +/* reuse GL_TESS_CONTROL_SHADER_BIT */ +/* reuse GL_TESS_EVALUATION_SHADER_BIT */ +/* reuse GL_ALL_SHADER_BITS */ +/* reuse GL_PROGRAM_SEPARABLE */ +/* reuse GL_ACTIVE_PROGRAM */ +/* reuse GL_PROGRAM_PIPELINE_BINDING */ +/* Reuse tokens from ARB_shader_precision (none) */ +/* Reuse tokens from ARB_vertex_attrib_64bit - all are in GL 3.0 and 4.0 already */ +/* Reuse tokens from ARB_viewport_array - some are in GL 1.1 and ARB_provoking_vertex already */ +/* reuse GL_MAX_VIEWPORTS */ +/* reuse GL_VIEWPORT_SUBPIXEL_BITS */ +/* reuse GL_VIEWPORT_BOUNDS_RANGE */ +/* reuse GL_LAYER_PROVOKING_VERTEX */ +/* reuse GL_VIEWPORT_INDEX_PROVOKING_VERTEX */ +/* reuse GL_UNDEFINED_VERTEX */ +#endif + +#ifndef GL_ARB_multitexture +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +#endif + +#ifndef GL_ARB_multisample +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +#endif + +#ifndef GL_ARB_texture_env_add +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif + +#ifndef GL_ARB_texture_compression +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif + +#ifndef GL_ARB_point_parameters +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif + +#ifndef GL_ARB_shadow +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif + +#ifndef GL_ARB_window_pos +#endif + +#ifndef GL_ARB_vertex_program +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +#endif + +#ifndef GL_ARB_fragment_program +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +#endif + +#ifndef GL_ARB_shader_objects +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#endif + +#ifndef GL_ARB_point_sprite +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_HALF_FLOAT_ARB 0x140B +#endif + +#ifndef GL_ARB_texture_float +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif + +#ifndef GL_ARB_depth_buffer_float +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#endif + +#ifndef GL_ARB_draw_instanced +#endif + +#ifndef GL_ARB_framebuffer_object +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#endif + +#ifndef GL_ARB_framebuffer_object_DEPRECATED +#define GL_INDEX 0x8222 +#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 +#endif + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#endif + +#ifndef GL_ARB_geometry_shader4 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 +/* reuse GL_MAX_VARYING_COMPONENTS */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ +#endif + +#ifndef GL_ARB_half_float_vertex +#define GL_HALF_FLOAT 0x140B +#endif + +#ifndef GL_ARB_instanced_arrays +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE +#endif + +#ifndef GL_ARB_map_buffer_range +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#endif + +#ifndef GL_ARB_texture_buffer_object +#define GL_TEXTURE_BUFFER_ARB 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E +#endif + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#endif + +#ifndef GL_ARB_texture_rg +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#endif + +#ifndef GL_ARB_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#endif + +#ifndef GL_ARB_uniform_buffer_object +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +#endif + +#ifndef GL_ARB_compatibility +/* ARB_compatibility just defines tokens from core 3.0 */ +#endif + +#ifndef GL_ARB_copy_buffer +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#endif + +#ifndef GL_ARB_shader_texture_lod +#endif + +#ifndef GL_ARB_depth_clamp +#define GL_DEPTH_CLAMP 0x864F +#endif + +#ifndef GL_ARB_draw_elements_base_vertex +#endif + +#ifndef GL_ARB_fragment_coord_conventions +#endif + +#ifndef GL_ARB_provoking_vertex +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_PROVOKING_VERTEX 0x8E4F +#endif + +#ifndef GL_ARB_seamless_cube_map +#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F +#endif + +#ifndef GL_ARB_sync +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#endif + +#ifndef GL_ARB_texture_multisample +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 +#endif + +#ifndef GL_ARB_vertex_array_bgra +/* reuse GL_BGRA */ +#endif + +#ifndef GL_ARB_draw_buffers_blend +#endif + +#ifndef GL_ARB_sample_shading +#define GL_SAMPLE_SHADING_ARB 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 +#endif + +#ifndef GL_ARB_texture_cube_map_array +#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F +#endif + +#ifndef GL_ARB_texture_gather +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F +#endif + +#ifndef GL_ARB_texture_query_lod +#endif + +#ifndef GL_ARB_shading_language_include +#define GL_SHADER_INCLUDE_ARB 0x8DAE +#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 +#define GL_NAMED_STRING_TYPE_ARB 0x8DEA +#endif + +#ifndef GL_ARB_texture_compression_bptc +#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F +#endif + +#ifndef GL_ARB_blend_func_extended +#define GL_SRC1_COLOR 0x88F9 +/* reuse GL_SRC1_ALPHA */ +#define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC +#endif + +#ifndef GL_ARB_explicit_attrib_location +#endif + +#ifndef GL_ARB_occlusion_query2 +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#endif + +#ifndef GL_ARB_sampler_objects +#define GL_SAMPLER_BINDING 0x8919 +#endif + +#ifndef GL_ARB_shader_bit_encoding +#endif + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_RGB10_A2UI 0x906F +#endif + +#ifndef GL_ARB_texture_swizzle +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 +#endif + +#ifndef GL_ARB_timer_query +#define GL_TIME_ELAPSED 0x88BF +#define GL_TIMESTAMP 0x8E28 +#endif + +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +/* reuse GL_UNSIGNED_INT_2_10_10_10_REV */ +#define GL_INT_2_10_10_10_REV 0x8D9F +#endif + +#ifndef GL_ARB_draw_indirect +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 +#endif + +#ifndef GL_ARB_gpu_shader5 +#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D +/* reuse GL_MAX_VERTEX_STREAMS */ +#endif + +#ifndef GL_ARB_gpu_shader_fp64 +/* reuse GL_DOUBLE */ +#define GL_DOUBLE_VEC2 0x8FFC +#define GL_DOUBLE_VEC3 0x8FFD +#define GL_DOUBLE_VEC4 0x8FFE +#define GL_DOUBLE_MAT2 0x8F46 +#define GL_DOUBLE_MAT3 0x8F47 +#define GL_DOUBLE_MAT4 0x8F48 +#define GL_DOUBLE_MAT2x3 0x8F49 +#define GL_DOUBLE_MAT2x4 0x8F4A +#define GL_DOUBLE_MAT3x2 0x8F4B +#define GL_DOUBLE_MAT3x4 0x8F4C +#define GL_DOUBLE_MAT4x2 0x8F4D +#define GL_DOUBLE_MAT4x3 0x8F4E +#endif + +#ifndef GL_ARB_shader_subroutine +#define GL_ACTIVE_SUBROUTINES 0x8DE5 +#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 +#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 +#define GL_MAX_SUBROUTINES 0x8DE7 +#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 +#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A +#define GL_COMPATIBLE_SUBROUTINES 0x8E4B +/* reuse GL_UNIFORM_SIZE */ +/* reuse GL_UNIFORM_NAME_LENGTH */ +#endif + +#ifndef GL_ARB_tessellation_shader +#define GL_PATCHES 0x000E +#define GL_PATCH_VERTICES 0x8E72 +#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 +#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 +#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 +#define GL_TESS_GEN_MODE 0x8E76 +#define GL_TESS_GEN_SPACING 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 +#define GL_TESS_GEN_POINT_MODE 0x8E79 +/* reuse GL_TRIANGLES */ +/* reuse GL_QUADS */ +#define GL_ISOLINES 0x8E7A +/* reuse GL_EQUAL */ +#define GL_FRACTIONAL_ODD 0x8E7B +#define GL_FRACTIONAL_EVEN 0x8E7C +/* reuse GL_CCW */ +/* reuse GL_CW */ +#define GL_MAX_PATCH_VERTICES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 +#define GL_TESS_EVALUATION_SHADER 0x8E87 +#define GL_TESS_CONTROL_SHADER 0x8E88 +#endif + +#ifndef GL_ARB_texture_buffer_object_rgb32 +/* reuse GL_RGB32F */ +/* reuse GL_RGB32UI */ +/* reuse GL_RGB32I */ +#endif + +#ifndef GL_ARB_transform_feedback2 +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#endif + +#ifndef GL_ARB_transform_feedback3 +#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 +#define GL_MAX_VERTEX_STREAMS 0x8E71 +#endif + +#ifndef GL_ARB_ES2_compatibility +#define GL_FIXED 0x140C +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#endif + +#ifndef GL_ARB_get_program_binary +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#endif + +#ifndef GL_ARB_separate_shader_objects +#define GL_VERTEX_SHADER_BIT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT 0x00000002 +#define GL_GEOMETRY_SHADER_BIT 0x00000004 +#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 +#define GL_ALL_SHADER_BITS 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE 0x8258 +#define GL_ACTIVE_PROGRAM 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING 0x825A +#endif + +#ifndef GL_ARB_shader_precision +#endif + +#ifndef GL_ARB_vertex_attrib_64bit +/* reuse GL_RGB32I */ +/* reuse GL_DOUBLE_VEC2 */ +/* reuse GL_DOUBLE_VEC3 */ +/* reuse GL_DOUBLE_VEC4 */ +/* reuse GL_DOUBLE_MAT2 */ +/* reuse GL_DOUBLE_MAT3 */ +/* reuse GL_DOUBLE_MAT4 */ +/* reuse GL_DOUBLE_MAT2x3 */ +/* reuse GL_DOUBLE_MAT2x4 */ +/* reuse GL_DOUBLE_MAT3x2 */ +/* reuse GL_DOUBLE_MAT3x4 */ +/* reuse GL_DOUBLE_MAT4x2 */ +/* reuse GL_DOUBLE_MAT4x3 */ +#endif + +#ifndef GL_ARB_viewport_array +/* reuse GL_SCISSOR_BOX */ +/* reuse GL_VIEWPORT */ +/* reuse GL_DEPTH_RANGE */ +/* reuse GL_SCISSOR_TEST */ +#define GL_MAX_VIEWPORTS 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE 0x825D +#define GL_LAYER_PROVOKING_VERTEX 0x825E +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F +#define GL_UNDEFINED_VERTEX 0x8260 +/* reuse GL_FIRST_VERTEX_CONVENTION */ +/* reuse GL_LAST_VERTEX_CONVENTION */ +/* reuse GL_PROVOKING_VERTEX */ +#endif + +#ifndef GL_ARB_cl_event +#define GL_SYNC_CL_EVENT_ARB 0x8240 +#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 +#endif + +#ifndef GL_ARB_debug_output +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 +#define GL_DEBUG_SOURCE_API_ARB 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A +#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B +#define GL_DEBUG_TYPE_ERROR_ARB 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 +#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 +#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 +#endif + +#ifndef GL_ARB_robustness +/* reuse GL_NO_ERROR */ +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 +#endif + +#ifndef GL_ARB_shader_stencil_export +#endif + +#ifndef GL_EXT_abgr +#define GL_ABGR_EXT 0x8000 +#endif + +#ifndef GL_EXT_blend_color +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +#endif + +#ifndef GL_EXT_texture +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif + +#ifndef GL_EXT_texture3D +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +#endif + +#ifndef GL_EXT_subtexture +#endif + +#ifndef GL_EXT_copy_texture +#endif + +#ifndef GL_EXT_histogram +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +#endif + +#ifndef GL_EXT_convolution +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +#endif + +#ifndef GL_SGI_color_matrix +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif + +#ifndef GL_SGI_color_table +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +#endif + +#ifndef GL_SGIS_texture4D +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif + +#ifndef GL_EXT_cmyka +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif + +#ifndef GL_EXT_texture_object +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif + +#ifndef GL_SGIS_multisample +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif + +#ifndef GL_EXT_vertex_array +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +#endif + +#ifndef GL_EXT_misc_attribute +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif + +#ifndef GL_SGIX_shadow +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_BLEND_EQUATION_EXT 0x8009 +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif + +#ifndef GL_EXT_blend_logic_op +#endif + +#ifndef GL_SGIX_interlace +#define GL_INTERLACE_SGIX 0x8094 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif + +#ifndef GL_SGIS_texture_select +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif + +#ifndef GL_EXT_point_parameters +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +#endif + +#ifndef GL_SGIX_instruments +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif + +#ifndef GL_SGIX_framezoom +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#endif + +#ifndef GL_FfdMaskSGIX +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +#endif + +#ifndef GL_SGIX_flush_raster +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif + +#ifndef GL_HP_image_transform +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif + +#ifndef GL_INGR_palette_buffer +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif + +#ifndef GL_EXT_color_subtable +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_LIST_PRIORITY_SGIX 0x8182 +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif + +#ifndef GL_EXT_index_texture +#endif + +#ifndef GL_EXT_index_material +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +#endif + +#ifndef GL_EXT_index_func +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +#endif + +#ifndef GL_WIN_phong_shading +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif + +#ifndef GL_WIN_specular_fog +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif + +#ifndef GL_EXT_light_texture +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +/* reuse GL_FRAGMENT_DEPTH_EXT */ +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif + +#ifndef GL_SGIX_impact_pixel_texture +#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 +#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 +#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 +#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 +#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 +#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 +#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A +#endif + +#ifndef GL_EXT_bgra +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif + +#ifndef GL_SGIX_async +#define GL_ASYNC_MARKER_SGIX 0x8329 +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif + +#ifndef GL_INTEL_texture_scissor +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +#endif + +#ifndef GL_HP_occlusion_test +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif + +#ifndef GL_EXT_secondary_color +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +#endif + +#ifndef GL_EXT_multi_draw_arrays +#endif + +#ifndef GL_EXT_fog_coord +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_FOG_SCALE_SGIX 0x81FC +#define GL_FOG_SCALE_VALUE_SGIX 0x81FD +#endif + +#ifndef GL_SUNX_constant_data +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +#endif + +#ifndef GL_SUN_global_alpha +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +#endif + +#ifndef GL_SUN_triangle_list +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +#endif + +#ifndef GL_SUN_vertex +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +#endif + +#ifndef GL_INGR_color_clamp +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INTERLACE_READ_INGR 0x8568 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif + +#ifndef GL_EXT_texture_cube_map +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif + +#ifndef GL_EXT_texture_env_add +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT GL_MODELVIEW +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +#endif + +#ifndef GL_NV_register_combiners +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +/* reuse GL_TEXTURE0_ARB */ +/* reuse GL_TEXTURE1_ARB */ +/* reuse GL_ZERO */ +/* reuse GL_NONE */ +/* reuse GL_FOG */ +#endif + +#ifndef GL_NV_fog_distance +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +/* reuse GL_EYE_PLANE */ +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif + +#ifndef GL_NV_blend_square +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif + +#ifndef GL_MESA_resize_buffers +#endif + +#ifndef GL_MESA_window_pos +#endif + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_CULL_VERTEX_IBM 103050 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +#endif + +#ifndef GL_SGIX_subsample +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif + +#ifndef GL_SGI_depth_pass_instrument +#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 +#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 +#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif + +#ifndef GL_3DFX_tbuffer +#endif + +#ifndef GL_EXT_multisample +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif + +#ifndef GL_SGIX_resample +#define GL_PACK_RESAMPLE_SGIX 0x842C +#define GL_UNPACK_RESAMPLE_SGIX 0x842D +#define GL_RESAMPLE_REPLICATE_SGIX 0x842E +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif + +#ifndef GL_NV_fence +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +#endif + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif + +#ifndef GL_NV_evaluators +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +#endif + +#ifndef GL_NV_texture_compression_vtc +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif + +#ifndef GL_NV_texture_shader +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV +#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV +#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif + +#ifndef GL_NV_vertex_program +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif + +#ifndef GL_OML_interlace +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif + +#ifndef GL_OML_subsample +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif + +#ifndef GL_OML_resample +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +#endif + +#ifndef GL_ATI_element_array +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +#endif + +#ifndef GL_SUN_mesh_array +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_DEPTH_CLAMP_NV 0x864F +#endif + +#ifndef GL_NV_occlusion_query +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +#endif + +#ifndef GL_NV_point_sprite +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif + +#ifndef GL_NV_vertex_program1_1 +#endif + +#ifndef GL_EXT_shadow_funcs +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif + +#ifndef GL_APPLE_element_array +#define GL_ELEMENT_ARRAY_APPLE 0x8A0C +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E +#endif + +#ifndef GL_APPLE_fence +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CLIENT_APPLE 0x85B4 +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_YCBCR_422_APPLE 0x85B9 +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#endif + +#ifndef GL_S3_s3tc +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif + +#ifndef GL_ATI_texture_float +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif + +#ifndef GL_NV_float_buffer +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif + +#ifndef GL_NV_fragment_program +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +#endif + +#ifndef GL_NV_half_float +#define GL_HALF_FLOAT_NV 0x140B +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +#endif + +#ifndef GL_NV_primitive_restart +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif + +#ifndef GL_NV_vertex_program2 +#endif + +#ifndef GL_ATI_map_object_buffer +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#endif + +#ifndef GL_OES_read_format +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_BLEND_EQUATION_RGB_EXT 0x8009 +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +#endif + +#ifndef GL_MESA_pack_invert +#define GL_PACK_INVERT_MESA 0x8758 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif + +#ifndef GL_NV_fragment_program_option +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif + +#ifndef GL_NV_vertex_program2_option +/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ +/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ +#endif + +#ifndef GL_NV_vertex_program3 +/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +#endif + +#ifndef GL_GREMEDY_string_marker +#endif + +#ifndef GL_EXT_packed_depth_stencil +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 +#endif + +#ifndef GL_EXT_stencil_clear_tag +#define GL_STENCIL_TAG_BITS_EXT 0x88F2 +#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 +#endif + +#ifndef GL_EXT_texture_sRGB +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif + +#ifndef GL_EXT_framebuffer_blit +#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING_EXT +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA +#endif + +#ifndef GL_EXT_framebuffer_multisample +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +#endif + +#ifndef GL_MESAX_texture_stack +#define GL_TEXTURE_1D_STACK_MESAX 0x8759 +#define GL_TEXTURE_2D_STACK_MESAX 0x875A +#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B +#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C +#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D +#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E +#endif + +#ifndef GL_EXT_timer_query +#define GL_TIME_ELAPSED_EXT 0x88BF +#endif + +#ifndef GL_EXT_gpu_program_parameters +#endif + +#ifndef GL_APPLE_flush_buffer_range +#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 +#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 +#endif + +#ifndef GL_NV_gpu_program4 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 +#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 +#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 +#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 +#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 +#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 +#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 +#endif + +#ifndef GL_NV_geometry_program4 +#define GL_LINES_ADJACENCY_EXT 0x000A +#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B +#define GL_TRIANGLES_ADJACENCY_EXT 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D +#define GL_GEOMETRY_PROGRAM_NV 0x8C26 +#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 +#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 +#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 +#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 +#endif + +#ifndef GL_EXT_geometry_shader4 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +/* reuse GL_GEOMETRY_VERTICES_OUT_EXT */ +/* reuse GL_GEOMETRY_INPUT_TYPE_EXT */ +/* reuse GL_GEOMETRY_OUTPUT_TYPE_EXT */ +/* reuse GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT */ +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE +#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 +/* reuse GL_LINES_ADJACENCY_EXT */ +/* reuse GL_LINE_STRIP_ADJACENCY_EXT */ +/* reuse GL_TRIANGLES_ADJACENCY_EXT */ +/* reuse GL_TRIANGLE_STRIP_ADJACENCY_EXT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ +/* reuse GL_PROGRAM_POINT_SIZE_EXT */ +#endif + +#ifndef GL_NV_vertex_program4 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD +#endif + +#ifndef GL_EXT_gpu_shader4 +#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 +#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 +#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 +#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 +#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 +#define GL_INT_SAMPLER_1D_EXT 0x8DC9 +#define GL_INT_SAMPLER_2D_EXT 0x8DCA +#define GL_INT_SAMPLER_3D_EXT 0x8DCB +#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC +#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD +#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 +#endif + +#ifndef GL_EXT_draw_instanced +#endif + +#ifndef GL_EXT_packed_float +#define GL_R11F_G11F_B10F_EXT 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B +#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C +#endif + +#ifndef GL_EXT_texture_array +#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 +#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D +#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF +#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ +#endif + +#ifndef GL_EXT_texture_buffer_object +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E +#endif + +#ifndef GL_EXT_texture_compression_latc +#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 +#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 +#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 +#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 +#endif + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#endif + +#ifndef GL_EXT_texture_shared_exponent +#define GL_RGB9_E5_EXT 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E +#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F +#endif + +#ifndef GL_NV_depth_buffer_float +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD +#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF +#endif + +#ifndef GL_NV_fragment_program4 +#endif + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB +#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 +#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 +#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 +#endif + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA +#endif + +#ifndef GL_NV_geometry_shader4 +#endif + +#ifndef GL_NV_parameter_buffer_object +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 +#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 +#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 +#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 +#endif + +#ifndef GL_EXT_draw_buffers2 +#endif + +#ifndef GL_NV_transform_feedback +#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 +#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 +#define GL_TEXTURE_COORD_NV 0x8C79 +#define GL_CLIP_DISTANCE_NV 0x8C7A +#define GL_VERTEX_ID_NV 0x8C7B +#define GL_PRIMITIVE_ID_NV 0x8C7C +#define GL_GENERIC_ATTRIB_NV 0x8C7D +#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 +#define GL_ACTIVE_VARYINGS_NV 0x8C81 +#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 +#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 +#define GL_PRIMITIVES_GENERATED_NV 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 +#define GL_RASTERIZER_DISCARD_NV 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_ATTRIBS_NV 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B +#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C +#define GL_SEPARATE_ATTRIBS_NV 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F +#define GL_LAYER_NV 0x8DAA +#define GL_NEXT_BUFFER_NV -2 +#define GL_SKIP_COMPONENTS4_NV -3 +#define GL_SKIP_COMPONENTS3_NV -4 +#define GL_SKIP_COMPONENTS2_NV -5 +#define GL_SKIP_COMPONENTS1_NV -6 +#endif + +#ifndef GL_EXT_bindable_uniform +#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 +#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 +#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 +#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED +#define GL_UNIFORM_BUFFER_EXT 0x8DEE +#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF +#endif + +#ifndef GL_EXT_texture_integer +#define GL_RGBA32UI_EXT 0x8D70 +#define GL_RGB32UI_EXT 0x8D71 +#define GL_ALPHA32UI_EXT 0x8D72 +#define GL_INTENSITY32UI_EXT 0x8D73 +#define GL_LUMINANCE32UI_EXT 0x8D74 +#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 +#define GL_RGBA16UI_EXT 0x8D76 +#define GL_RGB16UI_EXT 0x8D77 +#define GL_ALPHA16UI_EXT 0x8D78 +#define GL_INTENSITY16UI_EXT 0x8D79 +#define GL_LUMINANCE16UI_EXT 0x8D7A +#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B +#define GL_RGBA8UI_EXT 0x8D7C +#define GL_RGB8UI_EXT 0x8D7D +#define GL_ALPHA8UI_EXT 0x8D7E +#define GL_INTENSITY8UI_EXT 0x8D7F +#define GL_LUMINANCE8UI_EXT 0x8D80 +#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 +#define GL_RGBA32I_EXT 0x8D82 +#define GL_RGB32I_EXT 0x8D83 +#define GL_ALPHA32I_EXT 0x8D84 +#define GL_INTENSITY32I_EXT 0x8D85 +#define GL_LUMINANCE32I_EXT 0x8D86 +#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 +#define GL_RGBA16I_EXT 0x8D88 +#define GL_RGB16I_EXT 0x8D89 +#define GL_ALPHA16I_EXT 0x8D8A +#define GL_INTENSITY16I_EXT 0x8D8B +#define GL_LUMINANCE16I_EXT 0x8D8C +#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D +#define GL_RGBA8I_EXT 0x8D8E +#define GL_RGB8I_EXT 0x8D8F +#define GL_ALPHA8I_EXT 0x8D90 +#define GL_INTENSITY8I_EXT 0x8D91 +#define GL_LUMINANCE8I_EXT 0x8D92 +#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 +#define GL_RED_INTEGER_EXT 0x8D94 +#define GL_GREEN_INTEGER_EXT 0x8D95 +#define GL_BLUE_INTEGER_EXT 0x8D96 +#define GL_ALPHA_INTEGER_EXT 0x8D97 +#define GL_RGB_INTEGER_EXT 0x8D98 +#define GL_RGBA_INTEGER_EXT 0x8D99 +#define GL_BGR_INTEGER_EXT 0x8D9A +#define GL_BGRA_INTEGER_EXT 0x8D9B +#define GL_LUMINANCE_INTEGER_EXT 0x8D9C +#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D +#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E +#endif + +#ifndef GL_GREMEDY_frame_terminator +#endif + +#ifndef GL_NV_conditional_render +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 +#endif + +#ifndef GL_NV_present_video +#define GL_FRAME_NV 0x8E26 +#define GL_FIELDS_NV 0x8E27 +#define GL_CURRENT_TIME_NV 0x8E28 +#define GL_NUM_FILL_STREAMS_NV 0x8E29 +#define GL_PRESENT_TIME_NV 0x8E2A +#define GL_PRESENT_DURATION_NV 0x8E2B +#endif + +#ifndef GL_EXT_transform_feedback +#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F +#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C +#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D +#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 +#define GL_RASTERIZER_DISCARD_EXT 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 +#endif + +#ifndef GL_EXT_direct_state_access +#define GL_PROGRAM_MATRIX_EXT 0x8E2D +#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E +#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F +#endif + +#ifndef GL_EXT_vertex_array_bgra +/* reuse GL_BGRA */ +#endif + +#ifndef GL_EXT_texture_swizzle +#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 +#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 +#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 +#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 +#endif + +#ifndef GL_NV_explicit_multisample +#define GL_SAMPLE_POSITION_NV 0x8E50 +#define GL_SAMPLE_MASK_NV 0x8E51 +#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 +#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 +#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 +#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 +#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 +#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 +#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 +#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 +#endif + +#ifndef GL_NV_transform_feedback2 +#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 +#endif + +#ifndef GL_ATI_meminfo +#define GL_VBO_FREE_MEMORY_ATI 0x87FB +#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC +#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD +#endif + +#ifndef GL_AMD_performance_monitor +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 +#endif + +#ifndef GL_AMD_texture_texture4 +#endif + +#ifndef GL_AMD_vertex_shader_tesselator +#define GL_SAMPLER_BUFFER_AMD 0x9001 +#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 +#define GL_TESSELLATION_MODE_AMD 0x9004 +#define GL_TESSELLATION_FACTOR_AMD 0x9005 +#define GL_DISCRETE_AMD 0x9006 +#define GL_CONTINUOUS_AMD 0x9007 +#endif + +#ifndef GL_EXT_provoking_vertex +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D +#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E +#define GL_PROVOKING_VERTEX_EXT 0x8E4F +#endif + +#ifndef GL_EXT_texture_snorm +#define GL_ALPHA_SNORM 0x9010 +#define GL_LUMINANCE_SNORM 0x9011 +#define GL_LUMINANCE_ALPHA_SNORM 0x9012 +#define GL_INTENSITY_SNORM 0x9013 +#define GL_ALPHA8_SNORM 0x9014 +#define GL_LUMINANCE8_SNORM 0x9015 +#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 +#define GL_INTENSITY8_SNORM 0x9017 +#define GL_ALPHA16_SNORM 0x9018 +#define GL_LUMINANCE16_SNORM 0x9019 +#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A +#define GL_INTENSITY16_SNORM 0x901B +/* reuse GL_RED_SNORM */ +/* reuse GL_RG_SNORM */ +/* reuse GL_RGB_SNORM */ +/* reuse GL_RGBA_SNORM */ +/* reuse GL_R8_SNORM */ +/* reuse GL_RG8_SNORM */ +/* reuse GL_RGB8_SNORM */ +/* reuse GL_RGBA8_SNORM */ +/* reuse GL_R16_SNORM */ +/* reuse GL_RG16_SNORM */ +/* reuse GL_RGB16_SNORM */ +/* reuse GL_RGBA16_SNORM */ +/* reuse GL_SIGNED_NORMALIZED */ +#endif + +#ifndef GL_AMD_draw_buffers_blend +#endif + +#ifndef GL_APPLE_texture_range +#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 +#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 +#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC +#define GL_STORAGE_PRIVATE_APPLE 0x85BD +/* reuse GL_STORAGE_CACHED_APPLE */ +/* reuse GL_STORAGE_SHARED_APPLE */ +#endif + +#ifndef GL_APPLE_float_pixels +#define GL_HALF_APPLE 0x140B +#define GL_RGBA_FLOAT32_APPLE 0x8814 +#define GL_RGB_FLOAT32_APPLE 0x8815 +#define GL_ALPHA_FLOAT32_APPLE 0x8816 +#define GL_INTENSITY_FLOAT32_APPLE 0x8817 +#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 +#define GL_RGBA_FLOAT16_APPLE 0x881A +#define GL_RGB_FLOAT16_APPLE 0x881B +#define GL_ALPHA_FLOAT16_APPLE 0x881C +#define GL_INTENSITY_FLOAT16_APPLE 0x881D +#define GL_LUMINANCE_FLOAT16_APPLE 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F +#define GL_COLOR_FLOAT_APPLE 0x8A0F +#endif + +#ifndef GL_APPLE_vertex_program_evaluators +#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 +#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 +#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 +#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 +#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 +#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 +#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 +#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 +#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 +#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 +#endif + +#ifndef GL_APPLE_aux_depth_stencil +#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 +#endif + +#ifndef GL_APPLE_object_purgeable +#define GL_BUFFER_OBJECT_APPLE 0x85B3 +#define GL_RELEASED_APPLE 0x8A19 +#define GL_VOLATILE_APPLE 0x8A1A +#define GL_RETAINED_APPLE 0x8A1B +#define GL_UNDEFINED_APPLE 0x8A1C +#define GL_PURGEABLE_APPLE 0x8A1D +#endif + +#ifndef GL_APPLE_row_bytes +#define GL_PACK_ROW_BYTES_APPLE 0x8A15 +#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 +#endif + +#ifndef GL_APPLE_rgb_422 +#define GL_RGB_422_APPLE 0x8A1F +/* reuse GL_UNSIGNED_SHORT_8_8_APPLE */ +/* reuse GL_UNSIGNED_SHORT_8_8_REV_APPLE */ +#endif + +#ifndef GL_NV_video_capture +#define GL_VIDEO_BUFFER_NV 0x9020 +#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 +#define GL_FIELD_UPPER_NV 0x9022 +#define GL_FIELD_LOWER_NV 0x9023 +#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 +#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 +#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 +#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 +#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 +#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 +#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A +#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B +#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C +#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D +#define GL_PARTIAL_SUCCESS_NV 0x902E +#define GL_SUCCESS_NV 0x902F +#define GL_FAILURE_NV 0x9030 +#define GL_YCBYCR8_422_NV 0x9031 +#define GL_YCBAYCR8A_4224_NV 0x9032 +#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 +#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 +#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 +#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 +#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 +#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 +#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 +#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A +#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B +#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C +#endif + +#ifndef GL_NV_copy_image +#endif + +#ifndef GL_EXT_separate_shader_objects +#define GL_ACTIVE_PROGRAM_EXT 0x8B8D +#endif + +#ifndef GL_NV_parameter_buffer_object2 +#endif + +#ifndef GL_NV_shader_buffer_load +#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D +#define GL_GPU_ADDRESS_NV 0x8F34 +#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 +#endif + +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E +#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F +#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 +#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 +#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 +#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 +#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 +#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 +#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 +#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 +#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 +#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 +#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A +#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B +#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C +#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D +#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E +#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F +#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 +#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 +#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 +#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 +#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 +#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 +#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 +#endif + +#ifndef GL_NV_texture_barrier +#endif + +#ifndef GL_AMD_shader_stencil_export +#endif + +#ifndef GL_AMD_seamless_cubemap_per_texture +/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS_ARB */ +#endif + +#ifndef GL_AMD_conservative_depth +#endif + +#ifndef GL_EXT_shader_image_load_store +#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 +#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A +#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B +#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C +#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D +#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E +#define GL_IMAGE_1D_EXT 0x904C +#define GL_IMAGE_2D_EXT 0x904D +#define GL_IMAGE_3D_EXT 0x904E +#define GL_IMAGE_2D_RECT_EXT 0x904F +#define GL_IMAGE_CUBE_EXT 0x9050 +#define GL_IMAGE_BUFFER_EXT 0x9051 +#define GL_IMAGE_1D_ARRAY_EXT 0x9052 +#define GL_IMAGE_2D_ARRAY_EXT 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 +#define GL_INT_IMAGE_1D_EXT 0x9057 +#define GL_INT_IMAGE_2D_EXT 0x9058 +#define GL_INT_IMAGE_3D_EXT 0x9059 +#define GL_INT_IMAGE_2D_RECT_EXT 0x905A +#define GL_INT_IMAGE_CUBE_EXT 0x905B +#define GL_INT_IMAGE_BUFFER_EXT 0x905C +#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D +#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C +#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D +#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 +#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 +#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF +#endif + +#ifndef GL_EXT_vertex_attrib_64bit +/* reuse GL_DOUBLE */ +#define GL_DOUBLE_VEC2_EXT 0x8FFC +#define GL_DOUBLE_VEC3_EXT 0x8FFD +#define GL_DOUBLE_VEC4_EXT 0x8FFE +#define GL_DOUBLE_MAT2_EXT 0x8F46 +#define GL_DOUBLE_MAT3_EXT 0x8F47 +#define GL_DOUBLE_MAT4_EXT 0x8F48 +#define GL_DOUBLE_MAT2x3_EXT 0x8F49 +#define GL_DOUBLE_MAT2x4_EXT 0x8F4A +#define GL_DOUBLE_MAT3x2_EXT 0x8F4B +#define GL_DOUBLE_MAT3x4_EXT 0x8F4C +#define GL_DOUBLE_MAT4x2_EXT 0x8F4D +#define GL_DOUBLE_MAT4x3_EXT 0x8F4E +#endif + +#ifndef GL_NV_gpu_program5 +#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C +#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D +#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 +#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 +#endif + +#ifndef GL_NV_gpu_shader5 +#define GL_INT64_NV 0x140E +#define GL_UNSIGNED_INT64_NV 0x140F +#define GL_INT8_NV 0x8FE0 +#define GL_INT8_VEC2_NV 0x8FE1 +#define GL_INT8_VEC3_NV 0x8FE2 +#define GL_INT8_VEC4_NV 0x8FE3 +#define GL_INT16_NV 0x8FE4 +#define GL_INT16_VEC2_NV 0x8FE5 +#define GL_INT16_VEC3_NV 0x8FE6 +#define GL_INT16_VEC4_NV 0x8FE7 +#define GL_INT64_VEC2_NV 0x8FE9 +#define GL_INT64_VEC3_NV 0x8FEA +#define GL_INT64_VEC4_NV 0x8FEB +#define GL_UNSIGNED_INT8_NV 0x8FEC +#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED +#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE +#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF +#define GL_UNSIGNED_INT16_NV 0x8FF0 +#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 +#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 +#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 +#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB +/* reuse GL_PATCHES */ +#endif + +#ifndef GL_NV_shader_buffer_store +#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 +/* reuse GL_READ_WRITE */ +/* reuse GL_WRITE_ONLY */ +#endif + +#ifndef GL_NV_tessellation_program5 +#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 +#define GL_TESS_CONTROL_PROGRAM_NV 0x891E +#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F +#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 +#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 +#endif + +#ifndef GL_NV_vertex_attrib_integer_64bit +/* reuse GL_INT64_NV */ +/* reuse GL_UNSIGNED_INT64_NV */ +#endif + +#ifndef GL_NV_multisample_coverage +#define GL_COVERAGE_SAMPLES_NV 0x80A9 +#define GL_COLOR_SAMPLES_NV 0x8E20 +#endif + +#ifndef GL_AMD_name_gen_delete +#define GL_DATA_BUFFER_AMD 0x9151 +#define GL_PERFORMANCE_MONITOR_AMD 0x9152 +#define GL_QUERY_OBJECT_AMD 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 +#define GL_SAMPLER_OBJECT_AMD 0x9155 +#endif + +#ifndef GL_AMD_debug_output +#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 +#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 +#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 +#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A +#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B +#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C +#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D +#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E +#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F +#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 +#endif + +#ifndef GL_NV_vdpau_interop +#define GL_SURFACE_STATE_NV 0x86EB +#define GL_SURFACE_REGISTERED_NV 0x86FD +#define GL_SURFACE_MAPPED_NV 0x8700 +#define GL_WRITE_DISCARD_NV 0x88BE +#endif + +#ifndef GL_AMD_transform_feedback3_lines_triangles +#endif + + +/*************************************************************/ + +#include +#ifndef GL_VERSION_2_0 +/* GL type for program/shader text */ +typedef char GLchar; +#endif + +#ifndef GL_VERSION_1_5 +/* GL types for handling large vertex buffer objects */ +#if defined(__APPLE__) +typedef long GLintptr; +typedef long GLsizeiptr; +#else +typedef ptrdiff_t GLintptr; +typedef ptrdiff_t GLsizeiptr; +#endif +#endif + +#ifndef GL_ARB_vertex_buffer_object +/* GL types for handling large vertex buffer objects */ +#if defined(__APPLE__) +typedef long GLintptrARB; +typedef long GLsizeiptrARB; +#else +typedef ptrdiff_t GLintptrARB; +typedef ptrdiff_t GLsizeiptrARB; +#endif +#endif + +#ifndef GL_ARB_shader_objects +/* GL types for program/shader text and shader object handles */ +typedef char GLcharARB; +#if defined(__APPLE__) +typedef void *GLhandleARB; +#else +typedef unsigned int GLhandleARB; +#endif +#endif + +/* GL type for "half" precision (s10e5) float data in host memory */ +#ifndef GL_ARB_half_float_pixel +typedef unsigned short GLhalfARB; +#endif + +#ifndef GL_NV_half_float +typedef unsigned short GLhalfNV; +#endif + +#ifndef GLEXT_64_TYPES_DEFINED +/* This code block is duplicated in glxext.h, so must be protected */ +#define GLEXT_64_TYPES_DEFINED +/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ +/* (as used in the GL_EXT_timer_query extension). */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include +#elif defined(__sun__) || defined(__digital__) +#include +#if defined(__STDC__) +#if defined(__arch64__) || defined(_LP64) +typedef long int int64_t; +typedef unsigned long int uint64_t; +#else +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#endif /* __arch64__ */ +#endif /* __STDC__ */ +#elif defined( __VMS ) || defined(__sgi) +#include +#elif defined(__SCO__) || defined(__USLC__) +#include +#elif defined(__UNIXOS2__) || defined(__SOL64__) +typedef long int int32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#elif defined(_WIN32) && defined(__GNUC__) +#include +#elif defined(_WIN32) +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +/* Fallback if nothing above works */ +#include +#endif +#endif + +#ifndef GL_EXT_timer_query +typedef int64_t GLint64EXT; +typedef uint64_t GLuint64EXT; +#endif + +#ifndef GL_ARB_sync +typedef int64_t GLint64; +typedef uint64_t GLuint64; +typedef struct __GLsync *GLsync; +#endif + +#ifndef GL_ARB_cl_event +/* These incomplete types let us declare types compatible with OpenCL's cl_context and cl_event */ +struct _cl_context; +struct _cl_event; +#endif + +#ifndef GL_ARB_debug_output +typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#endif + +#ifndef GL_AMD_debug_output +typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#endif + +#ifndef GL_NV_vdpau_interop +typedef GLintptr GLvdpauSurfaceNV; +#endif + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +GLAPI void APIENTRY glBlendEquation (GLenum mode); +GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_VERSION_1_2_DEPRECATED +#define GL_VERSION_1_2_DEPRECATED 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, GLvoid *table); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, GLvoid *image); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogram (GLenum target); +GLAPI void APIENTRY glResetMinmax (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +#endif + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum texture); +GLAPI void APIENTRY glSampleCoverage (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, GLvoid *img); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_VERSION_1_3_DEPRECATED +#define GL_VERSION_1_3_DEPRECATED 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClientActiveTexture (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +#endif + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_VERSION_1_4_DEPRECATED +#define GL_VERSION_1_4_DEPRECATED 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordf (GLfloat coord); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); +GLAPI void APIENTRY glFogCoordd (GLdouble coord); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2iv (const GLint *v); +GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); +GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3iv (const GLint *v); +GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +#endif + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQuery (GLuint id); +GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQuery (GLenum target); +GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); +GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +GLAPI GLvoid* APIENTRY glMapBuffer (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid* *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GLAPI void APIENTRY glCompileShader (GLuint shader); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum type); +GLAPI void APIENTRY glDeleteProgram (GLuint program); +GLAPI void APIENTRY glDeleteShader (GLuint shader); +GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid* *pointer); +GLAPI GLboolean APIENTRY glIsProgram (GLuint program); +GLAPI GLboolean APIENTRY glIsShader (GLuint shader); +GLAPI void APIENTRY glLinkProgram (GLuint program); +GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); +GLAPI void APIENTRY glUseProgram (GLuint program); +GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glValidateProgram (GLuint program); +GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif + +#ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 +/* OpenGL 3.0 also reuses entry points from these extensions: */ +/* ARB_framebuffer_object */ +/* ARB_map_buffer_range */ +/* ARB_vertex_array_object */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); +GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); +GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedback (void); +GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); +GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRender (void); +GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); +GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI const GLubyte * APIENTRY glGetStringi (GLenum name, GLuint index); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +#endif + +#ifndef GL_VERSION_3_1 +#define GL_VERSION_3_1 1 +/* OpenGL 3.1 also reuses entry points from these extensions: */ +/* ARB_copy_buffer */ +/* ARB_uniform_buffer_object */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); +#endif + +#ifndef GL_VERSION_3_2 +#define GL_VERSION_3_2 1 +/* OpenGL 3.2 also reuses entry points from these extensions: */ +/* ARB_draw_elements_base_vertex */ +/* ARB_provoking_vertex */ +/* ARB_sync */ +/* ARB_texture_multisample */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); +GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +#endif + +#ifndef GL_VERSION_3_3 +#define GL_VERSION_3_3 1 +/* OpenGL 3.3 also reuses entry points from these extensions: */ +/* ARB_blend_func_extended */ +/* ARB_sampler_objects */ +/* ARB_explicit_attrib_location, but it has none */ +/* ARB_occlusion_query2 (no entry points) */ +/* ARB_shader_bit_encoding (no entry points) */ +/* ARB_texture_rgb10_a2ui (no entry points) */ +/* ARB_texture_swizzle (no entry points) */ +/* ARB_timer_query */ +/* ARB_vertex_type_2_10_10_10_rev */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +#endif + +#ifndef GL_VERSION_4_0 +#define GL_VERSION_4_0 1 +/* OpenGL 4.0 also reuses entry points from these extensions: */ +/* ARB_texture_query_lod (no entry points) */ +/* ARB_draw_indirect */ +/* ARB_gpu_shader5 (no entry points) */ +/* ARB_gpu_shader_fp64 */ +/* ARB_shader_subroutine */ +/* ARB_tessellation_shader */ +/* ARB_texture_buffer_object_rgb32 (no entry points) */ +/* ARB_texture_cube_map_array (no entry points) */ +/* ARB_texture_gather (no entry points) */ +/* ARB_transform_feedback2 */ +/* ARB_transform_feedback3 */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShading (GLclampf value); +GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLclampf value); +typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif + +#ifndef GL_VERSION_4_1 +#define GL_VERSION_4_1 1 +/* OpenGL 4.1 also reuses entry points from these extensions: */ +/* ARB_ES2_compatibility */ +/* ARB_get_program_binary */ +/* ARB_separate_shader_objects */ +/* ARB_shader_precision (no entry points) */ +/* ARB_vertex_attrib_64bit */ +/* ARB_viewport_array */ +#endif + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +#endif + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLclampf value, GLboolean invert); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); +#endif + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#endif + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, GLvoid *img); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#endif + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); +GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); +GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); +GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); +GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); +GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); +GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); +GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); +GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glVertexBlendARB (GLint count); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#endif + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#endif + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); +#endif + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, GLvoid *string); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, GLvoid* *pointer); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); +#endif + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); +GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, GLvoid* *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); +GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQueryARB (GLenum target); +GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); +GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); +GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); +GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); +GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); +GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); +GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); +GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); +GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); +GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +#endif + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#endif + +#ifndef GL_ARB_depth_buffer_float +#define GL_ARB_depth_buffer_float 1 +#endif + +#ifndef GL_ARB_draw_instanced +#define GL_ARB_draw_instanced 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif + +#ifndef GL_ARB_framebuffer_object +#define GL_ARB_framebuffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmap (GLenum target); +GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#endif + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_ARB_framebuffer_sRGB 1 +#endif + +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif + +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +#endif + +#ifndef GL_ARB_instanced_arrays +#define GL_ARB_instanced_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); +#endif + +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvoid* APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +#endif + +#ifndef GL_ARB_texture_buffer_object +#define GL_ARB_texture_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#endif + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_ARB_texture_compression_rgtc 1 +#endif + +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#endif + +#ifndef GL_ARB_vertex_array_object +#define GL_ARB_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArray (GLuint array); +GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); +#endif + +#ifndef GL_ARB_uniform_buffer_object +#define GL_ARB_uniform_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* *uniformNames, GLuint *uniformIndices); +GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); +GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar* *uniformNames, GLuint *uniformIndices); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#endif + +#ifndef GL_ARB_compatibility +#define GL_ARB_compatibility 1 +#endif + +#ifndef GL_ARB_copy_buffer +#define GL_ARB_copy_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +#endif + +#ifndef GL_ARB_shader_texture_lod +#define GL_ARB_shader_texture_lod 1 +#endif + +#ifndef GL_ARB_depth_clamp +#define GL_ARB_depth_clamp 1 +#endif + +#ifndef GL_ARB_draw_elements_base_vertex +#define GL_ARB_draw_elements_base_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); +GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount, const GLint *basevertex); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount, const GLint *basevertex); +#endif + +#ifndef GL_ARB_fragment_coord_conventions +#define GL_ARB_fragment_coord_conventions 1 +#endif + +#ifndef GL_ARB_provoking_vertex +#define GL_ARB_provoking_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProvokingVertex (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); +#endif + +#ifndef GL_ARB_seamless_cube_map +#define GL_ARB_seamless_cube_map 1 +#endif + +#ifndef GL_ARB_sync +#define GL_ARB_sync 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GLAPI GLboolean APIENTRY glIsSync (GLsync sync); +GLAPI void APIENTRY glDeleteSync (GLsync sync); +GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); +typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); +typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif + +#ifndef GL_ARB_texture_multisample +#define GL_ARB_texture_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaski (GLuint index, GLbitfield mask); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask); +#endif + +#ifndef GL_ARB_vertex_array_bgra +#define GL_ARB_vertex_array_bgra 1 +#endif + +#ifndef GL_ARB_draw_buffers_blend +#define GL_ARB_draw_buffers_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif + +#ifndef GL_ARB_sample_shading +#define GL_ARB_sample_shading 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShadingARB (GLclampf value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLclampf value); +#endif + +#ifndef GL_ARB_texture_cube_map_array +#define GL_ARB_texture_cube_map_array 1 +#endif + +#ifndef GL_ARB_texture_gather +#define GL_ARB_texture_gather 1 +#endif + +#ifndef GL_ARB_texture_query_lod +#define GL_ARB_texture_query_lod 1 +#endif + +#ifndef GL_ARB_shading_language_include +#define GL_ARB_shading_language_include 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); +GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); +typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#endif + +#ifndef GL_ARB_texture_compression_bptc +#define GL_ARB_texture_compression_bptc 1 +#endif + +#ifndef GL_ARB_blend_func_extended +#define GL_ARB_blend_func_extended 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); +#endif + +#ifndef GL_ARB_explicit_attrib_location +#define GL_ARB_explicit_attrib_location 1 +#endif + +#ifndef GL_ARB_occlusion_query2 +#define GL_ARB_occlusion_query2 1 +#endif + +#ifndef GL_ARB_sampler_objects +#define GL_ARB_sampler_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); +GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); +GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); +#endif + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_ARB_texture_rgb10_a2ui 1 +#endif + +#ifndef GL_ARB_texture_swizzle +#define GL_ARB_texture_swizzle 1 +#endif + +#ifndef GL_ARB_timer_query +#define GL_ARB_timer_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); +GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); +#endif + +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +#define GL_ARB_vertex_type_2_10_10_10_rev 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +#endif + +#ifndef GL_ARB_draw_indirect +#define GL_ARB_draw_indirect 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const GLvoid *indirect); +GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const GLvoid *indirect); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const GLvoid *indirect); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const GLvoid *indirect); +#endif + +#ifndef GL_ARB_gpu_shader5 +#define GL_ARB_gpu_shader5 1 +#endif + +#ifndef GL_ARB_gpu_shader_fp64 +#define GL_ARB_gpu_shader_fp64 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); +GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); +#endif + +#ifndef GL_ARB_shader_subroutine +#define GL_ARB_shader_subroutine 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); +GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); +GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); +typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +#endif + +#ifndef GL_ARB_tessellation_shader +#define GL_ARB_tessellation_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); +GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); +#endif + +#ifndef GL_ARB_texture_buffer_object_rgb32 +#define GL_ARB_texture_buffer_object_rgb32 1 +#endif + +#ifndef GL_ARB_transform_feedback2 +#define GL_ARB_transform_feedback2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedback (void); +GLAPI void APIENTRY glResumeTransformFeedback (void); +GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); +#endif + +#ifndef GL_ARB_transform_feedback3 +#define GL_ARB_transform_feedback3 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); +GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); +GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); +GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); +typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +#endif + +#ifndef GL_ARB_ES2_compatibility +#define GL_ARB_ES2_compatibility 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReleaseShaderCompiler (void); +GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GLAPI void APIENTRY glDepthRangef (GLclampf n, GLclampf f); +GLAPI void APIENTRY glClearDepthf (GLclampf d); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLclampf n, GLclampf f); +typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLclampf d); +#endif + +#ifndef GL_ARB_get_program_binary +#define GL_ARB_get_program_binary 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); +GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); +#endif + +#ifndef GL_ARB_separate_shader_objects +#define GL_ARB_separate_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); +GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar* *strings); +GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); +GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); +GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); +GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar* *strings); +typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); +typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +#endif + +#ifndef GL_ARB_vertex_attrib_64bit +#define GL_ARB_vertex_attrib_64bit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); +#endif + +#ifndef GL_ARB_viewport_array +#define GL_ARB_viewport_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); +GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); +GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLclampd *v); +GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLclampd n, GLclampd f); +GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLclampd *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLclampd n, GLclampd f); +typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); +#endif + +#ifndef GL_ARB_cl_event +#define GL_ARB_cl_event 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); +#endif + +#ifndef GL_ARB_debug_output +#define GL_ARB_debug_output 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const GLvoid *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#endif + +#ifndef GL_ARB_robustness +#define GL_ARB_robustness 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); +GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); +GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); +GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); +GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); +GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); +GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); +GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); +GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); +GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); +GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); +typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); +typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); +typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); +typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); +typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); +typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +#endif + +#ifndef GL_ARB_shader_stencil_export +#define GL_ARB_shader_stencil_export 1 +#endif + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#endif + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColorEXT (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#endif + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#endif + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogramEXT (GLenum target); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +#endif + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *image); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +#endif + +#ifndef GL_SGI_color_matrix +#define GL_SGI_color_matrix 1 +#endif + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, GLvoid *table); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#endif + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#endif + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); +GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#endif + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#endif + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint i); +GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); +GLAPI void APIENTRY glGetPointervEXT (GLenum pname, GLvoid* *params); +GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#endif + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#endif + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#endif + +#ifndef GL_SGIX_texture_select +#define GL_SGIX_texture_select 1 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#endif + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#endif + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTagSampleBufferSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +#endif + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushRasterSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#endif + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#endif + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, GLvoid *data); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); +GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); +GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#endif + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); +GLAPI void APIENTRY glUnlockArraysEXT (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); +GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#endif + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#endif + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#endif + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); +GLAPI void APIENTRY glTextureLightEXT (GLenum pname); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#endif + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#endif + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const GLvoid* *pointer); +GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +#endif + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#endif + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +#endif + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); +GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); +GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); +GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_SGIX_fog_scale 1 +#endif + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#endif + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +#endif + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const GLvoid* *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); +#endif + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#endif + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); +#endif + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#endif + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#endif + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#endif + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +#endif + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean* *pointer, GLint ptrstride); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +#endif + +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif + +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#endif + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +#endif + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#endif + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif + +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const GLvoid *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#endif + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); +GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); +GLAPI void APIENTRY glFinishFenceNV (GLuint fence); +GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#endif + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#endif + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#endif + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); +GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); +GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, GLvoid* *pointer); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); +GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLuint count, const GLdouble *v); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLuint count, const GLfloat *v); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint count, const GLfloat *v); +typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#endif + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#endif + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#endif + +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); +GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const GLvoid *pointer, GLenum usage); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); +GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); +GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const GLvoid *addr); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const GLvoid *addr); +GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); +GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); +GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); +GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); +GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); +GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); +GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); +GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); +GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, GLvoid* *data); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); +GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); +GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerATI (GLenum type, const GLvoid *pointer); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#endif + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#endif + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#endif + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const GLvoid *pointer); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#endif + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +/* This is really a WGL extension, but defines some associated GL enums. + * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. + */ +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#endif + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#endif + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#endif + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, GLvoid *pointer); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#endif + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#endif + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#endif + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); +#endif + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#endif + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#endif + +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#endif + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const GLvoid *string); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); +#endif + +#ifndef GL_EXT_packed_depth_stencil +#define GL_EXT_packed_depth_stencil 1 +#endif + +#ifndef GL_EXT_stencil_clear_tag +#define GL_EXT_stencil_clear_tag 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif + +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 +#endif + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif + +#ifndef GL_EXT_framebuffer_multisample +#define GL_EXT_framebuffer_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +#ifndef GL_MESAX_texture_stack +#define GL_MESAX_texture_stack 1 +#endif + +#ifndef GL_EXT_timer_query +#define GL_EXT_timer_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64EXT *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); +#endif + +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif + +#ifndef GL_APPLE_flush_buffer_range +#define GL_APPLE_flush_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); +#endif + +#ifndef GL_NV_gpu_program4 +#define GL_NV_gpu_program4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +#endif + +#ifndef GL_NV_geometry_program4 +#define GL_NV_geometry_program4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); +GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif + +#ifndef GL_EXT_geometry_shader4 +#define GL_EXT_geometry_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +#endif + +#ifndef GL_NV_vertex_program4 +#define GL_NV_vertex_program4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); +#endif + +#ifndef GL_EXT_gpu_shader4 +#define GL_EXT_gpu_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +#endif + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif + +#ifndef GL_EXT_packed_float +#define GL_EXT_packed_float 1 +#endif + +#ifndef GL_EXT_texture_array +#define GL_EXT_texture_array 1 +#endif + +#ifndef GL_EXT_texture_buffer_object +#define GL_EXT_texture_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#endif + +#ifndef GL_EXT_texture_compression_latc +#define GL_EXT_texture_compression_latc 1 +#endif + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#endif + +#ifndef GL_EXT_texture_shared_exponent +#define GL_EXT_texture_shared_exponent 1 +#endif + +#ifndef GL_NV_depth_buffer_float +#define GL_NV_depth_buffer_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); +GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); +typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); +#endif + +#ifndef GL_NV_fragment_program4 +#define GL_NV_fragment_program4 1 +#endif + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_NV_framebuffer_multisample_coverage 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_EXT_framebuffer_sRGB 1 +#endif + +#ifndef GL_NV_geometry_shader4 +#define GL_NV_geometry_shader4 1 +#endif + +#ifndef GL_NV_parameter_buffer_object +#define GL_NV_parameter_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); +#endif + +#ifndef GL_EXT_draw_buffers2 +#define GL_EXT_draw_buffers2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); +#endif + +#ifndef GL_NV_transform_feedback +#define GL_NV_transform_feedback 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackNV (void); +GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint count, const GLint *attribs, GLenum bufferMode); +GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); +GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); +GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#endif + +#ifndef GL_EXT_bindable_uniform +#define GL_EXT_bindable_uniform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); +GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); +GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); +typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); +typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); +#endif + +#ifndef GL_EXT_texture_integer +#define GL_EXT_texture_integer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); +GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); +typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#endif + +#ifndef GL_GREMEDY_frame_terminator +#define GL_GREMEDY_frame_terminator 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); +#endif + +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRenderNV (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +#endif + +#ifndef GL_NV_present_video +#define GL_NV_present_video 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); +GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#endif + +#ifndef GL_EXT_transform_feedback +#define GL_EXT_transform_feedback 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackEXT (void); +GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#endif + +#ifndef GL_EXT_direct_state_access +#define GL_EXT_direct_state_access 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); +GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); +GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); +GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); +GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); +GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, GLvoid* *data); +GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, GLvoid *img); +GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, GLvoid *img); +GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); +GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, GLvoid *string); +GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); +GLAPI GLvoid* APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); +GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); +GLAPI GLvoid* APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, GLvoid* *params); +GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); +GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); +GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); +GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); +GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); +GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); +typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLvoid* *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, GLvoid *img); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, GLvoid *img); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); +typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, GLvoid* *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); +typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +#endif + +#ifndef GL_EXT_vertex_array_bgra +#define GL_EXT_vertex_array_bgra 1 +#endif + +#ifndef GL_EXT_texture_swizzle +#define GL_EXT_texture_swizzle 1 +#endif + +#ifndef GL_NV_explicit_multisample +#define GL_NV_explicit_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); +GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); +#endif + +#ifndef GL_NV_transform_feedback2 +#define GL_NV_transform_feedback2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedbackNV (void); +GLAPI void APIENTRY glResumeTransformFeedbackNV (void); +GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); +#endif + +#ifndef GL_ATI_meminfo +#define GL_ATI_meminfo 1 +#endif + +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data); +GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data); +typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif + +#ifndef GL_AMD_texture_texture4 +#define GL_AMD_texture_texture4 1 +#endif + +#ifndef GL_AMD_vertex_shader_tesselator +#define GL_AMD_vertex_shader_tesselator 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); +GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_provoking_vertex +#define GL_EXT_provoking_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_texture_snorm +#define GL_EXT_texture_snorm 1 +#endif + +#ifndef GL_AMD_draw_buffers_blend +#define GL_AMD_draw_buffers_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#endif + +#ifndef GL_APPLE_texture_range +#define GL_APPLE_texture_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const GLvoid *pointer); +GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, GLvoid* *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_APPLE_float_pixels +#define GL_APPLE_float_pixels 1 +#endif + +#ifndef GL_APPLE_vertex_program_evaluators +#define GL_APPLE_vertex_program_evaluators 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#endif + +#ifndef GL_APPLE_aux_depth_stencil +#define GL_APPLE_aux_depth_stencil 1 +#endif + +#ifndef GL_APPLE_object_purgeable +#define GL_APPLE_object_purgeable 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#endif + +#ifndef GL_APPLE_row_bytes +#define GL_APPLE_row_bytes 1 +#endif + +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#endif + +#ifndef GL_NV_video_capture +#define GL_NV_video_capture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#endif + +#ifndef GL_NV_copy_image +#define GL_NV_copy_image 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif + +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); +GLAPI void APIENTRY glActiveProgramEXT (GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); +typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); +#endif + +#ifndef GL_NV_parameter_buffer_object2 +#define GL_NV_parameter_buffer_object2 1 +#endif + +#ifndef GL_NV_shader_buffer_load +#define GL_NV_shader_buffer_load 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); +GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); +GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); +GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); +GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); +GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); +GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); +GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); +GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); +GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); +GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); +typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); +typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); +typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); +typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif + +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_NV_vertex_buffer_unified_memory 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); +GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); +#endif + +#ifndef GL_NV_texture_barrier +#define GL_NV_texture_barrier 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureBarrierNV (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); +#endif + +#ifndef GL_AMD_shader_stencil_export +#define GL_AMD_shader_stencil_export 1 +#endif + +#ifndef GL_AMD_seamless_cubemap_per_texture +#define GL_AMD_seamless_cubemap_per_texture 1 +#endif + +#ifndef GL_AMD_conservative_depth +#define GL_AMD_conservative_depth 1 +#endif + +#ifndef GL_EXT_shader_image_load_store +#define GL_EXT_shader_image_load_store 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); +#endif + +#ifndef GL_EXT_vertex_attrib_64bit +#define GL_EXT_vertex_attrib_64bit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +#endif + +#ifndef GL_NV_gpu_program5 +#define GL_NV_gpu_program5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); +#endif + +#ifndef GL_NV_gpu_shader5 +#define GL_NV_gpu_shader5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); +GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); +GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); +GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); +GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); +GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif + +#ifndef GL_NV_shader_buffer_store +#define GL_NV_shader_buffer_store 1 +#endif + +#ifndef GL_NV_tessellation_program5 +#define GL_NV_tessellation_program5 1 +#endif + +#ifndef GL_NV_vertex_attrib_integer_64bit +#define GL_NV_vertex_attrib_integer_64bit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); +GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +#endif + +#ifndef GL_NV_multisample_coverage +#define GL_NV_multisample_coverage 1 +#endif + +#ifndef GL_AMD_name_gen_delete +#define GL_AMD_name_gen_delete 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); +GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); +GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); +typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); +typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); +#endif + +#ifndef GL_AMD_debug_output +#define GL_AMD_debug_output 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, GLvoid *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, GLvoid *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif + +#ifndef GL_NV_vdpau_interop +#define GL_NV_vdpau_interop 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVDPAUInitNV (const GLvoid *vdpDevice, const GLvoid *getProcAddress); +GLAPI void APIENTRY glVDPAUFiniNV (void); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI void APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); +GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const GLvoid *vdpDevice, const GLvoid *getProcAddress); +typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef void (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); +typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#endif + +#ifndef GL_AMD_transform_feedback3_lines_triangles +#define GL_AMD_transform_feedback3_lines_triangles 1 +#endif + + +#ifdef __cplusplus +} +#endif + +#endif +#endif /* NO_SDL_GLEXT */ + +#endif /* !__IPHONEOS__ */ + +#endif /* _SDL_opengl_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_pixels.h spring-98.0~14.04~ppa6/include/SDL2/SDL_pixels.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_pixels.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_pixels.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,427 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_pixels.h + * + * Header for the enumerated pixel format definitions. + */ + +#ifndef _SDL_pixels_h +#define _SDL_pixels_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \name Transparency definitions + * + * These define alpha as the opacity of a surface. + */ +/* @{ */ +#define SDL_ALPHA_OPAQUE 255 +#define SDL_ALPHA_TRANSPARENT 0 +/* @} */ + +/** Pixel type. */ +enum +{ + SDL_PIXELTYPE_UNKNOWN, + SDL_PIXELTYPE_INDEX1, + SDL_PIXELTYPE_INDEX4, + SDL_PIXELTYPE_INDEX8, + SDL_PIXELTYPE_PACKED8, + SDL_PIXELTYPE_PACKED16, + SDL_PIXELTYPE_PACKED32, + SDL_PIXELTYPE_ARRAYU8, + SDL_PIXELTYPE_ARRAYU16, + SDL_PIXELTYPE_ARRAYU32, + SDL_PIXELTYPE_ARRAYF16, + SDL_PIXELTYPE_ARRAYF32 +}; + +/** Bitmap pixel order, high bit -> low bit. */ +enum +{ + SDL_BITMAPORDER_NONE, + SDL_BITMAPORDER_4321, + SDL_BITMAPORDER_1234 +}; + +/** Packed component order, high bit -> low bit. */ +enum +{ + SDL_PACKEDORDER_NONE, + SDL_PACKEDORDER_XRGB, + SDL_PACKEDORDER_RGBX, + SDL_PACKEDORDER_ARGB, + SDL_PACKEDORDER_RGBA, + SDL_PACKEDORDER_XBGR, + SDL_PACKEDORDER_BGRX, + SDL_PACKEDORDER_ABGR, + SDL_PACKEDORDER_BGRA +}; + +/** Array component order, low byte -> high byte. */ +enum +{ + SDL_ARRAYORDER_NONE, + SDL_ARRAYORDER_RGB, + SDL_ARRAYORDER_RGBA, + SDL_ARRAYORDER_ARGB, + SDL_ARRAYORDER_BGR, + SDL_ARRAYORDER_BGRA, + SDL_ARRAYORDER_ABGR +}; + +/** Packed component layout. */ +enum +{ + SDL_PACKEDLAYOUT_NONE, + SDL_PACKEDLAYOUT_332, + SDL_PACKEDLAYOUT_4444, + SDL_PACKEDLAYOUT_1555, + SDL_PACKEDLAYOUT_5551, + SDL_PACKEDLAYOUT_565, + SDL_PACKEDLAYOUT_8888, + SDL_PACKEDLAYOUT_2101010, + SDL_PACKEDLAYOUT_1010102 +}; + +#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) SDL_FOURCC(A, B, C, D) + +#define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \ + ((1 << 28) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \ + ((bits) << 8) | ((bytes) << 0)) + +#define SDL_PIXELFLAG(X) (((X) >> 28) & 0x0F) +#define SDL_PIXELTYPE(X) (((X) >> 24) & 0x0F) +#define SDL_PIXELORDER(X) (((X) >> 20) & 0x0F) +#define SDL_PIXELLAYOUT(X) (((X) >> 16) & 0x0F) +#define SDL_BITSPERPIXEL(X) (((X) >> 8) & 0xFF) +#define SDL_BYTESPERPIXEL(X) \ + (SDL_ISPIXELFORMAT_FOURCC(X) ? \ + ((((X) == SDL_PIXELFORMAT_YUY2) || \ + ((X) == SDL_PIXELFORMAT_UYVY) || \ + ((X) == SDL_PIXELFORMAT_YVYU)) ? 2 : 1) : (((X) >> 0) & 0xFF)) + +#define SDL_ISPIXELFORMAT_INDEXED(format) \ + (!SDL_ISPIXELFORMAT_FOURCC(format) && \ + ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8))) + +#define SDL_ISPIXELFORMAT_ALPHA(format) \ + (!SDL_ISPIXELFORMAT_FOURCC(format) && \ + ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \ + (SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \ + (SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \ + (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA))) + +/* The flag is set to 1 because 0x1? is not in the printable ASCII range */ +#define SDL_ISPIXELFORMAT_FOURCC(format) \ + ((format) && (SDL_PIXELFLAG(format) != 1)) + +/* Note: If you modify this list, update SDL_GetPixelFormatName() */ +enum +{ + SDL_PIXELFORMAT_UNKNOWN, + SDL_PIXELFORMAT_INDEX1LSB = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_4321, 0, + 1, 0), + SDL_PIXELFORMAT_INDEX1MSB = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0, + 1, 0), + SDL_PIXELFORMAT_INDEX4LSB = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0, + 4, 0), + SDL_PIXELFORMAT_INDEX4MSB = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_1234, 0, + 4, 0), + SDL_PIXELFORMAT_INDEX8 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1), + SDL_PIXELFORMAT_RGB332 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED8, SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_332, 8, 1), + SDL_PIXELFORMAT_RGB444 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_4444, 12, 2), + SDL_PIXELFORMAT_RGB555 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_1555, 15, 2), + SDL_PIXELFORMAT_BGR555 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, + SDL_PACKEDLAYOUT_1555, 15, 2), + SDL_PIXELFORMAT_ARGB4444 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB, + SDL_PACKEDLAYOUT_4444, 16, 2), + SDL_PIXELFORMAT_RGBA4444 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA, + SDL_PACKEDLAYOUT_4444, 16, 2), + SDL_PIXELFORMAT_ABGR4444 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR, + SDL_PACKEDLAYOUT_4444, 16, 2), + SDL_PIXELFORMAT_BGRA4444 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA, + SDL_PACKEDLAYOUT_4444, 16, 2), + SDL_PIXELFORMAT_ARGB1555 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB, + SDL_PACKEDLAYOUT_1555, 16, 2), + SDL_PIXELFORMAT_RGBA5551 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA, + SDL_PACKEDLAYOUT_5551, 16, 2), + SDL_PIXELFORMAT_ABGR1555 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR, + SDL_PACKEDLAYOUT_1555, 16, 2), + SDL_PIXELFORMAT_BGRA5551 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA, + SDL_PACKEDLAYOUT_5551, 16, 2), + SDL_PIXELFORMAT_RGB565 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_565, 16, 2), + SDL_PIXELFORMAT_BGR565 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, + SDL_PACKEDLAYOUT_565, 16, 2), + SDL_PIXELFORMAT_RGB24 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0, + 24, 3), + SDL_PIXELFORMAT_BGR24 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_BGR, 0, + 24, 3), + SDL_PIXELFORMAT_RGB888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_8888, 24, 4), + SDL_PIXELFORMAT_RGBX8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX, + SDL_PACKEDLAYOUT_8888, 24, 4), + SDL_PIXELFORMAT_BGR888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR, + SDL_PACKEDLAYOUT_8888, 24, 4), + SDL_PIXELFORMAT_BGRX8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRX, + SDL_PACKEDLAYOUT_8888, 24, 4), + SDL_PIXELFORMAT_ARGB8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, + SDL_PACKEDLAYOUT_8888, 32, 4), + SDL_PIXELFORMAT_RGBA8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA, + SDL_PACKEDLAYOUT_8888, 32, 4), + SDL_PIXELFORMAT_ABGR8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR, + SDL_PACKEDLAYOUT_8888, 32, 4), + SDL_PIXELFORMAT_BGRA8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRA, + SDL_PACKEDLAYOUT_8888, 32, 4), + SDL_PIXELFORMAT_ARGB2101010 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, + SDL_PACKEDLAYOUT_2101010, 32, 4), + + SDL_PIXELFORMAT_YV12 = /**< Planar mode: Y + V + U (3 planes) */ + SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'), + SDL_PIXELFORMAT_IYUV = /**< Planar mode: Y + U + V (3 planes) */ + SDL_DEFINE_PIXELFOURCC('I', 'Y', 'U', 'V'), + SDL_PIXELFORMAT_YUY2 = /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */ + SDL_DEFINE_PIXELFOURCC('Y', 'U', 'Y', '2'), + SDL_PIXELFORMAT_UYVY = /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */ + SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'), + SDL_PIXELFORMAT_YVYU = /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */ + SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U') +}; + +typedef struct SDL_Color +{ + Uint8 r; + Uint8 g; + Uint8 b; + Uint8 a; +} SDL_Color; +#define SDL_Colour SDL_Color + +typedef struct SDL_Palette +{ + int ncolors; + SDL_Color *colors; + Uint32 version; + int refcount; +} SDL_Palette; + +/** + * \note Everything in the pixel format structure is read-only. + */ +typedef struct SDL_PixelFormat +{ + Uint32 format; + SDL_Palette *palette; + Uint8 BitsPerPixel; + Uint8 BytesPerPixel; + Uint8 padding[2]; + Uint32 Rmask; + Uint32 Gmask; + Uint32 Bmask; + Uint32 Amask; + Uint8 Rloss; + Uint8 Gloss; + Uint8 Bloss; + Uint8 Aloss; + Uint8 Rshift; + Uint8 Gshift; + Uint8 Bshift; + Uint8 Ashift; + int refcount; + struct SDL_PixelFormat *next; +} SDL_PixelFormat; + +/** + * \brief Get the human readable name of a pixel format + */ +extern DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(Uint32 format); + +/** + * \brief Convert one of the enumerated pixel formats to a bpp and RGBA masks. + * + * \return SDL_TRUE, or SDL_FALSE if the conversion wasn't possible. + * + * \sa SDL_MasksToPixelFormatEnum() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format, + int *bpp, + Uint32 * Rmask, + Uint32 * Gmask, + Uint32 * Bmask, + Uint32 * Amask); + +/** + * \brief Convert a bpp and RGBA masks to an enumerated pixel format. + * + * \return The pixel format, or ::SDL_PIXELFORMAT_UNKNOWN if the conversion + * wasn't possible. + * + * \sa SDL_PixelFormatEnumToMasks() + */ +extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp, + Uint32 Rmask, + Uint32 Gmask, + Uint32 Bmask, + Uint32 Amask); + +/** + * \brief Create an SDL_PixelFormat structure from a pixel format enum. + */ +extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_AllocFormat(Uint32 pixel_format); + +/** + * \brief Free an SDL_PixelFormat structure. + */ +extern DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format); + +/** + * \brief Create a palette structure with the specified number of color + * entries. + * + * \return A new palette, or NULL if there wasn't enough memory. + * + * \note The palette entries are initialized to white. + * + * \sa SDL_FreePalette() + */ +extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors); + +/** + * \brief Set the palette for a pixel format structure. + */ +extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format, + SDL_Palette *palette); + +/** + * \brief Set a range of colors in a palette. + * + * \param palette The palette to modify. + * \param colors An array of colors to copy into the palette. + * \param firstcolor The index of the first palette entry to modify. + * \param ncolors The number of entries to modify. + * + * \return 0 on success, or -1 if not all of the colors could be set. + */ +extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette, + const SDL_Color * colors, + int firstcolor, int ncolors); + +/** + * \brief Free a palette created with SDL_AllocPalette(). + * + * \sa SDL_AllocPalette() + */ +extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette); + +/** + * \brief Maps an RGB triple to an opaque pixel value for a given pixel format. + * + * \sa SDL_MapRGBA + */ +extern DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormat * format, + Uint8 r, Uint8 g, Uint8 b); + +/** + * \brief Maps an RGBA quadruple to a pixel value for a given pixel format. + * + * \sa SDL_MapRGB + */ +extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat * format, + Uint8 r, Uint8 g, Uint8 b, + Uint8 a); + +/** + * \brief Get the RGB components from a pixel of the specified format. + * + * \sa SDL_GetRGBA + */ +extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, + const SDL_PixelFormat * format, + Uint8 * r, Uint8 * g, Uint8 * b); + +/** + * \brief Get the RGBA components from a pixel of the specified format. + * + * \sa SDL_GetRGB + */ +extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, + const SDL_PixelFormat * format, + Uint8 * r, Uint8 * g, Uint8 * b, + Uint8 * a); + +/** + * \brief Calculate a 256 entry gamma ramp for a gamma value. + */ +extern DECLSPEC void SDLCALL SDL_CalculateGammaRamp(float gamma, Uint16 * ramp); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_pixels_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_platform.h spring-98.0~14.04~ppa6/include/SDL2/SDL_platform.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_platform.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_platform.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,155 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_platform.h + * + * Try to get a standard set of platform defines. + */ + +#ifndef _SDL_platform_h +#define _SDL_platform_h + +#if defined(_AIX) +#undef __AIX__ +#define __AIX__ 1 +#endif +#if defined(__BEOS__) +#undef __BEOS__ +#define __BEOS__ 1 +#endif +#if defined(__HAIKU__) +#undef __HAIKU__ +#define __HAIKU__ 1 +#endif +#if defined(bsdi) || defined(__bsdi) || defined(__bsdi__) +#undef __BSDI__ +#define __BSDI__ 1 +#endif +#if defined(_arch_dreamcast) +#undef __DREAMCAST__ +#define __DREAMCAST__ 1 +#endif +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) +#undef __FREEBSD__ +#define __FREEBSD__ 1 +#endif +#if defined(hpux) || defined(__hpux) || defined(__hpux__) +#undef __HPUX__ +#define __HPUX__ 1 +#endif +#if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE) +#undef __IRIX__ +#define __IRIX__ 1 +#endif +#if defined(linux) || defined(__linux) || defined(__linux__) +#undef __LINUX__ +#define __LINUX__ 1 +#endif +#if defined(ANDROID) +#undef __ANDROID__ +#undef __LINUX__ /* do we need to do this? */ +#define __ANDROID__ 1 +#endif + +#if defined(__APPLE__) +/* lets us know what version of Mac OS X we're compiling on */ +#include "AvailabilityMacros.h" +#include "TargetConditionals.h" +#if TARGET_OS_IPHONE +/* if compiling for iPhone */ +#undef __IPHONEOS__ +#define __IPHONEOS__ 1 +#undef __MACOSX__ +#else +/* if not compiling for iPhone */ +#undef __MACOSX__ +#define __MACOSX__ 1 +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050 +# error SDL for Mac OS X only supports deploying on 10.5 and above. +#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1050 */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060 +# error SDL for Mac OS X must be built with a 10.6 SDK or above. +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED < 1060 */ +#endif /* TARGET_OS_IPHONE */ +#endif /* defined(__APPLE__) */ + +#if defined(__NetBSD__) +#undef __NETBSD__ +#define __NETBSD__ 1 +#endif +#if defined(__OpenBSD__) +#undef __OPENBSD__ +#define __OPENBSD__ 1 +#endif +#if defined(__OS2__) +#undef __OS2__ +#define __OS2__ 1 +#endif +#if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) +#undef __OSF__ +#define __OSF__ 1 +#endif +#if defined(__QNXNTO__) +#undef __QNXNTO__ +#define __QNXNTO__ 1 +#endif +#if defined(riscos) || defined(__riscos) || defined(__riscos__) +#undef __RISCOS__ +#define __RISCOS__ 1 +#endif +#if defined(__SVR4) +#undef __SOLARIS__ +#define __SOLARIS__ 1 +#endif +#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) +#undef __WINDOWS__ +#define __WINDOWS__ 1 +#endif +#if defined(__WINDOWS__) +#undef __WIN32__ +#define __WIN32__ 1 +#endif +#if defined(__PSP__) +#undef __PSP__ +#define __PSP__ 1 +#endif + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Gets the name of the platform. + */ +extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_platform_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_power.h spring-98.0~14.04~ppa6/include/SDL2/SDL_power.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_power.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_power.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,75 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_power_h +#define _SDL_power_h + +/** + * \file SDL_power.h + * + * Header for the SDL power management routines. + */ + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief The basic state for the system's power supply. + */ +typedef enum +{ + SDL_POWERSTATE_UNKNOWN, /**< cannot determine power status */ + SDL_POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */ + SDL_POWERSTATE_NO_BATTERY, /**< Plugged in, no battery available */ + SDL_POWERSTATE_CHARGING, /**< Plugged in, charging battery */ + SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */ +} SDL_PowerState; + + +/** + * \brief Get the current power supply details. + * + * \param secs Seconds of battery life left. You can pass a NULL here if + * you don't care. Will return -1 if we can't determine a + * value, or we're not running on a battery. + * + * \param pct Percentage of battery life left, between 0 and 100. You can + * pass a NULL here if you don't care. Will return -1 if we + * can't determine a value, or we're not running on a battery. + * + * \return The state of the battery (if any). + */ +extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *secs, int *pct); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_power_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_quit.h spring-98.0~14.04~ppa6/include/SDL2/SDL_quit.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_quit.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_quit.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,58 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_quit.h + * + * Include file for SDL quit event handling. + */ + +#ifndef _SDL_quit_h +#define _SDL_quit_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +/** + * \file SDL_quit.h + * + * An ::SDL_QUIT event is generated when the user tries to close the application + * window. If it is ignored or filtered out, the window will remain open. + * If it is not ignored or filtered, it is queued normally and the window + * is allowed to close. When the window is closed, screen updates will + * complete, but have no effect. + * + * SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) + * and SIGTERM (system termination request), if handlers do not already + * exist, that generate ::SDL_QUIT events as well. There is no way + * to determine the cause of an ::SDL_QUIT event, but setting a signal + * handler in your application will override the default generation of + * quit events for that signal. + * + * \sa SDL_Quit() + */ + +/* There are no functions directly affecting the quit event */ + +#define SDL_QuitRequested() \ + (SDL_PumpEvents(), (SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUIT,SDL_QUIT) > 0)) + +#endif /* _SDL_quit_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_rect.h spring-98.0~14.04~ppa6/include/SDL2/SDL_rect.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_rect.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_rect.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,138 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_rect.h + * + * Header file for SDL_rect definition and management functions. + */ + +#ifndef _SDL_rect_h +#define _SDL_rect_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_pixels.h" +#include "SDL_rwops.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief The structure that defines a point + * + * \sa SDL_EnclosePoints + */ +typedef struct SDL_Point +{ + int x; + int y; +} SDL_Point; + +/** + * \brief A rectangle, with the origin at the upper left. + * + * \sa SDL_RectEmpty + * \sa SDL_RectEquals + * \sa SDL_HasIntersection + * \sa SDL_IntersectRect + * \sa SDL_UnionRect + * \sa SDL_EnclosePoints + */ +typedef struct SDL_Rect +{ + int x, y; + int w, h; +} SDL_Rect; + +/** + * \brief Returns true if the rectangle has no area. + */ +SDL_FORCE_INLINE SDL_bool SDL_RectEmpty(const SDL_Rect *r) +{ + return ((!r) || (r->w <= 0) || (r->h <= 0)) ? SDL_TRUE : SDL_FALSE; +} + +/** + * \brief Returns true if the two rectangles are equal. + */ +SDL_FORCE_INLINE SDL_bool SDL_RectEquals(const SDL_Rect *a, const SDL_Rect *b) +{ + return (a && b && (a->x == b->x) && (a->y == b->y) && + (a->w == b->w) && (a->h == b->h)) ? SDL_TRUE : SDL_FALSE; +} + +/** + * \brief Determine whether two rectangles intersect. + * + * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A, + const SDL_Rect * B); + +/** + * \brief Calculate the intersection of two rectangles. + * + * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A, + const SDL_Rect * B, + SDL_Rect * result); + +/** + * \brief Calculate the union of two rectangles. + */ +extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A, + const SDL_Rect * B, + SDL_Rect * result); + +/** + * \brief Calculate a minimal rectangle enclosing a set of points + * + * \return SDL_TRUE if any points were within the clipping rect + */ +extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points, + int count, + const SDL_Rect * clip, + SDL_Rect * result); + +/** + * \brief Calculate the intersection of a rectangle and line segment. + * + * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect * + rect, int *X1, + int *Y1, int *X2, + int *Y2); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_rect_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_render.h spring-98.0~14.04~ppa6/include/SDL2/SDL_render.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_render.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_render.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,870 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_render.h + * + * Header file for SDL 2D rendering functions. + * + * This API supports the following features: + * * single pixel points + * * single pixel lines + * * filled rectangles + * * texture images + * + * The primitives may be drawn in opaque, blended, or additive modes. + * + * The texture images may be drawn in opaque, blended, or additive modes. + * They can have an additional color tint or alpha modulation applied to + * them, and may also be stretched with linear interpolation. + * + * This API is designed to accelerate simple 2D operations. You may + * want more functionality such as polygons and particle effects and + * in that case you should use SDL's OpenGL/Direct3D support or one + * of the many good 3D engines. + * + * These functions must be called from the main thread. + * See this bug for details: http://bugzilla.libsdl.org/show_bug.cgi?id=1995 + */ + +#ifndef _SDL_render_h +#define _SDL_render_h + +#include "SDL_stdinc.h" +#include "SDL_rect.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Flags used when creating a rendering context + */ +typedef enum +{ + SDL_RENDERER_SOFTWARE = 0x00000001, /**< The renderer is a software fallback */ + SDL_RENDERER_ACCELERATED = 0x00000002, /**< The renderer uses hardware + acceleration */ + SDL_RENDERER_PRESENTVSYNC = 0x00000004, /**< Present is synchronized + with the refresh rate */ + SDL_RENDERER_TARGETTEXTURE = 0x00000008 /**< The renderer supports + rendering to texture */ +} SDL_RendererFlags; + +/** + * \brief Information on the capabilities of a render driver or context. + */ +typedef struct SDL_RendererInfo +{ + const char *name; /**< The name of the renderer */ + Uint32 flags; /**< Supported ::SDL_RendererFlags */ + Uint32 num_texture_formats; /**< The number of available texture formats */ + Uint32 texture_formats[16]; /**< The available texture formats */ + int max_texture_width; /**< The maximimum texture width */ + int max_texture_height; /**< The maximimum texture height */ +} SDL_RendererInfo; + +/** + * \brief The access pattern allowed for a texture. + */ +typedef enum +{ + SDL_TEXTUREACCESS_STATIC, /**< Changes rarely, not lockable */ + SDL_TEXTUREACCESS_STREAMING, /**< Changes frequently, lockable */ + SDL_TEXTUREACCESS_TARGET /**< Texture can be used as a render target */ +} SDL_TextureAccess; + +/** + * \brief The texture channel modulation used in SDL_RenderCopy(). + */ +typedef enum +{ + SDL_TEXTUREMODULATE_NONE = 0x00000000, /**< No modulation */ + SDL_TEXTUREMODULATE_COLOR = 0x00000001, /**< srcC = srcC * color */ + SDL_TEXTUREMODULATE_ALPHA = 0x00000002 /**< srcA = srcA * alpha */ +} SDL_TextureModulate; + +/** + * \brief Flip constants for SDL_RenderCopyEx + */ +typedef enum +{ + SDL_FLIP_NONE = 0x00000000, /**< Do not flip */ + SDL_FLIP_HORIZONTAL = 0x00000001, /**< flip horizontally */ + SDL_FLIP_VERTICAL = 0x00000002 /**< flip vertically */ +} SDL_RendererFlip; + +/** + * \brief A structure representing rendering state + */ +struct SDL_Renderer; +typedef struct SDL_Renderer SDL_Renderer; + +/** + * \brief An efficient driver-specific representation of pixel data + */ +struct SDL_Texture; +typedef struct SDL_Texture SDL_Texture; + + +/* Function prototypes */ + +/** + * \brief Get the number of 2D rendering drivers available for the current + * display. + * + * A render driver is a set of code that handles rendering and texture + * management on a particular display. Normally there is only one, but + * some drivers may have several available with different capabilities. + * + * \sa SDL_GetRenderDriverInfo() + * \sa SDL_CreateRenderer() + */ +extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void); + +/** + * \brief Get information about a specific 2D rendering driver for the current + * display. + * + * \param index The index of the driver to query information about. + * \param info A pointer to an SDL_RendererInfo struct to be filled with + * information on the rendering driver. + * + * \return 0 on success, -1 if the index was out of range. + * + * \sa SDL_CreateRenderer() + */ +extern DECLSPEC int SDLCALL SDL_GetRenderDriverInfo(int index, + SDL_RendererInfo * info); + +/** + * \brief Create a window and default renderer + * + * \param width The width of the window + * \param height The height of the window + * \param window_flags The flags used to create the window + * \param window A pointer filled with the window, or NULL on error + * \param renderer A pointer filled with the renderer, or NULL on error + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer( + int width, int height, Uint32 window_flags, + SDL_Window **window, SDL_Renderer **renderer); + + +/** + * \brief Create a 2D rendering context for a window. + * + * \param window The window where rendering is displayed. + * \param index The index of the rendering driver to initialize, or -1 to + * initialize the first one supporting the requested flags. + * \param flags ::SDL_RendererFlags. + * + * \return A valid rendering context or NULL if there was an error. + * + * \sa SDL_CreateSoftwareRenderer() + * \sa SDL_GetRendererInfo() + * \sa SDL_DestroyRenderer() + */ +extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window * window, + int index, Uint32 flags); + +/** + * \brief Create a 2D software rendering context for a surface. + * + * \param surface The surface where rendering is done. + * + * \return A valid rendering context or NULL if there was an error. + * + * \sa SDL_CreateRenderer() + * \sa SDL_DestroyRenderer() + */ +extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface * surface); + +/** + * \brief Get the renderer associated with a window. + */ +extern DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window * window); + +/** + * \brief Get information about a rendering context. + */ +extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer * renderer, + SDL_RendererInfo * info); + +/** + * \brief Get the output size of a rendering context. + */ +extern DECLSPEC int SDLCALL SDL_GetRendererOutputSize(SDL_Renderer * renderer, + int *w, int *h); + +/** + * \brief Create a texture for a rendering context. + * + * \param renderer The renderer. + * \param format The format of the texture. + * \param access One of the enumerated values in ::SDL_TextureAccess. + * \param w The width of the texture in pixels. + * \param h The height of the texture in pixels. + * + * \return The created texture is returned, or 0 if no rendering context was + * active, the format was unsupported, or the width or height were out + * of range. + * + * \sa SDL_QueryTexture() + * \sa SDL_UpdateTexture() + * \sa SDL_DestroyTexture() + */ +extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer * renderer, + Uint32 format, + int access, int w, + int h); + +/** + * \brief Create a texture from an existing surface. + * + * \param renderer The renderer. + * \param surface The surface containing pixel data used to fill the texture. + * + * \return The created texture is returned, or 0 on error. + * + * \note The surface is not modified or freed by this function. + * + * \sa SDL_QueryTexture() + * \sa SDL_DestroyTexture() + */ +extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface); + +/** + * \brief Query the attributes of a texture + * + * \param texture A texture to be queried. + * \param format A pointer filled in with the raw format of the texture. The + * actual format may differ, but pixel transfers will use this + * format. + * \param access A pointer filled in with the actual access to the texture. + * \param w A pointer filled in with the width of the texture in pixels. + * \param h A pointer filled in with the height of the texture in pixels. + * + * \return 0 on success, or -1 if the texture is not valid. + */ +extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture, + Uint32 * format, int *access, + int *w, int *h); + +/** + * \brief Set an additional color value used in render copy operations. + * + * \param texture The texture to update. + * \param r The red color value multiplied into copy operations. + * \param g The green color value multiplied into copy operations. + * \param b The blue color value multiplied into copy operations. + * + * \return 0 on success, or -1 if the texture is not valid or color modulation + * is not supported. + * + * \sa SDL_GetTextureColorMod() + */ +extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture, + Uint8 r, Uint8 g, Uint8 b); + + +/** + * \brief Get the additional color value used in render copy operations. + * + * \param texture The texture to query. + * \param r A pointer filled in with the current red color value. + * \param g A pointer filled in with the current green color value. + * \param b A pointer filled in with the current blue color value. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \sa SDL_SetTextureColorMod() + */ +extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture, + Uint8 * r, Uint8 * g, + Uint8 * b); + +/** + * \brief Set an additional alpha value used in render copy operations. + * + * \param texture The texture to update. + * \param alpha The alpha value multiplied into copy operations. + * + * \return 0 on success, or -1 if the texture is not valid or alpha modulation + * is not supported. + * + * \sa SDL_GetTextureAlphaMod() + */ +extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture, + Uint8 alpha); + +/** + * \brief Get the additional alpha value used in render copy operations. + * + * \param texture The texture to query. + * \param alpha A pointer filled in with the current alpha value. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \sa SDL_SetTextureAlphaMod() + */ +extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture, + Uint8 * alpha); + +/** + * \brief Set the blend mode used for texture copy operations. + * + * \param texture The texture to update. + * \param blendMode ::SDL_BlendMode to use for texture blending. + * + * \return 0 on success, or -1 if the texture is not valid or the blend mode is + * not supported. + * + * \note If the blend mode is not supported, the closest supported mode is + * chosen. + * + * \sa SDL_GetTextureBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture, + SDL_BlendMode blendMode); + +/** + * \brief Get the blend mode used for texture copy operations. + * + * \param texture The texture to query. + * \param blendMode A pointer filled in with the current blend mode. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \sa SDL_SetTextureBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture, + SDL_BlendMode *blendMode); + +/** + * \brief Update the given texture rectangle with new pixel data. + * + * \param texture The texture to update + * \param rect A pointer to the rectangle of pixels to update, or NULL to + * update the entire texture. + * \param pixels The raw pixel data. + * \param pitch The number of bytes between rows of pixel data. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \note This is a fairly slow function. + */ +extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture, + const SDL_Rect * rect, + const void *pixels, int pitch); + +/** + * \brief Update a rectangle within a planar YV12 or IYUV texture with new pixel data. + * + * \param texture The texture to update + * \param rect A pointer to the rectangle of pixels to update, or NULL to + * update the entire texture. + * \param Yplane The raw pixel data for the Y plane. + * \param Ypitch The number of bytes between rows of pixel data for the Y plane. + * \param Uplane The raw pixel data for the U plane. + * \param Upitch The number of bytes between rows of pixel data for the U plane. + * \param Vplane The raw pixel data for the V plane. + * \param Vpitch The number of bytes between rows of pixel data for the V plane. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \note You can use SDL_UpdateTexture() as long as your pixel data is + * a contiguous block of Y and U/V planes in the proper order, but + * this function is available if your pixel data is not contiguous. + */ +extern DECLSPEC int SDLCALL SDL_UpdateYUVTexture(SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); + +/** + * \brief Lock a portion of the texture for write-only pixel access. + * + * \param texture The texture to lock for access, which was created with + * ::SDL_TEXTUREACCESS_STREAMING. + * \param rect A pointer to the rectangle to lock for access. If the rect + * is NULL, the entire texture will be locked. + * \param pixels This is filled in with a pointer to the locked pixels, + * appropriately offset by the locked area. + * \param pitch This is filled in with the pitch of the locked pixels. + * + * \return 0 on success, or -1 if the texture is not valid or was not created with ::SDL_TEXTUREACCESS_STREAMING. + * + * \sa SDL_UnlockTexture() + */ +extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture, + const SDL_Rect * rect, + void **pixels, int *pitch); + +/** + * \brief Unlock a texture, uploading the changes to video memory, if needed. + * + * \sa SDL_LockTexture() + */ +extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture); + +/** + * \brief Determines whether a window supports the use of render targets + * + * \param renderer The renderer that will be checked + * + * \return SDL_TRUE if supported, SDL_FALSE if not. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_RenderTargetSupported(SDL_Renderer *renderer); + +/** + * \brief Set a texture as the current rendering target. + * + * \param renderer The renderer. + * \param texture The targeted texture, which must be created with the SDL_TEXTUREACCESS_TARGET flag, or NULL for the default render target + * + * \return 0 on success, or -1 on error + * + * \sa SDL_GetRenderTarget() + */ +extern DECLSPEC int SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer, + SDL_Texture *texture); + +/** + * \brief Get the current render target or NULL for the default render target. + * + * \return The current render target + * + * \sa SDL_SetRenderTarget() + */ +extern DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer); + +/** + * \brief Set device independent resolution for rendering + * + * \param renderer The renderer for which resolution should be set. + * \param w The width of the logical resolution + * \param h The height of the logical resolution + * + * This function uses the viewport and scaling functionality to allow a fixed logical + * resolution for rendering, regardless of the actual output resolution. If the actual + * output resolution doesn't have the same aspect ratio the output rendering will be + * centered within the output display. + * + * If the output display is a window, mouse events in the window will be filtered + * and scaled so they seem to arrive within the logical resolution. + * + * \note If this function results in scaling or subpixel drawing by the + * rendering backend, it will be handled using the appropriate + * quality hints. + * + * \sa SDL_RenderGetLogicalSize() + * \sa SDL_RenderSetScale() + * \sa SDL_RenderSetViewport() + */ +extern DECLSPEC int SDLCALL SDL_RenderSetLogicalSize(SDL_Renderer * renderer, int w, int h); + +/** + * \brief Get device independent resolution for rendering + * + * \param renderer The renderer from which resolution should be queried. + * \param w A pointer filled with the width of the logical resolution + * \param h A pointer filled with the height of the logical resolution + * + * \sa SDL_RenderSetLogicalSize() + */ +extern DECLSPEC void SDLCALL SDL_RenderGetLogicalSize(SDL_Renderer * renderer, int *w, int *h); + +/** + * \brief Set the drawing area for rendering on the current target. + * + * \param renderer The renderer for which the drawing area should be set. + * \param rect The rectangle representing the drawing area, or NULL to set the viewport to the entire target. + * + * The x,y of the viewport rect represents the origin for rendering. + * + * \return 0 on success, or -1 on error + * + * \note If the window associated with the renderer is resized, the viewport is automatically reset. + * + * \sa SDL_RenderGetViewport() + * \sa SDL_RenderSetLogicalSize() + */ +extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer, + const SDL_Rect * rect); + +/** + * \brief Get the drawing area for the current target. + * + * \sa SDL_RenderSetViewport() + */ +extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer, + SDL_Rect * rect); + +/** + * \brief Set the clip rectangle for the current target. + * + * \param renderer The renderer for which clip rectangle should be set. + * \param rect A pointer to the rectangle to set as the clip rectangle, or + * NULL to disable clipping. + * + * \return 0 on success, or -1 on error + * + * \sa SDL_RenderGetClipRect() + */ +extern DECLSPEC int SDLCALL SDL_RenderSetClipRect(SDL_Renderer * renderer, + const SDL_Rect * rect); + +/** + * \brief Get the clip rectangle for the current target. + * + * \param renderer The renderer from which clip rectangle should be queried. + * \param rect A pointer filled in with the current clip rectangle, or + * an empty rectangle if clipping is disabled. + * + * \sa SDL_RenderSetClipRect() + */ +extern DECLSPEC void SDLCALL SDL_RenderGetClipRect(SDL_Renderer * renderer, + SDL_Rect * rect); + +/** + * \brief Set the drawing scale for rendering on the current target. + * + * \param renderer The renderer for which the drawing scale should be set. + * \param scaleX The horizontal scaling factor + * \param scaleY The vertical scaling factor + * + * The drawing coordinates are scaled by the x/y scaling factors + * before they are used by the renderer. This allows resolution + * independent drawing with a single coordinate system. + * + * \note If this results in scaling or subpixel drawing by the + * rendering backend, it will be handled using the appropriate + * quality hints. For best results use integer scaling factors. + * + * \sa SDL_RenderGetScale() + * \sa SDL_RenderSetLogicalSize() + */ +extern DECLSPEC int SDLCALL SDL_RenderSetScale(SDL_Renderer * renderer, + float scaleX, float scaleY); + +/** + * \brief Get the drawing scale for the current target. + * + * \param renderer The renderer from which drawing scale should be queried. + * \param scaleX A pointer filled in with the horizontal scaling factor + * \param scaleY A pointer filled in with the vertical scaling factor + * + * \sa SDL_RenderSetScale() + */ +extern DECLSPEC void SDLCALL SDL_RenderGetScale(SDL_Renderer * renderer, + float *scaleX, float *scaleY); + +/** + * \brief Set the color used for drawing operations (Rect, Line and Clear). + * + * \param renderer The renderer for which drawing color should be set. + * \param r The red value used to draw on the rendering target. + * \param g The green value used to draw on the rendering target. + * \param b The blue value used to draw on the rendering target. + * \param a The alpha value used to draw on the rendering target, usually + * ::SDL_ALPHA_OPAQUE (255). + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDL_SetRenderDrawColor(SDL_Renderer * renderer, + Uint8 r, Uint8 g, Uint8 b, + Uint8 a); + +/** + * \brief Get the color used for drawing operations (Rect, Line and Clear). + * + * \param renderer The renderer from which drawing color should be queried. + * \param r A pointer to the red value used to draw on the rendering target. + * \param g A pointer to the green value used to draw on the rendering target. + * \param b A pointer to the blue value used to draw on the rendering target. + * \param a A pointer to the alpha value used to draw on the rendering target, + * usually ::SDL_ALPHA_OPAQUE (255). + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDL_GetRenderDrawColor(SDL_Renderer * renderer, + Uint8 * r, Uint8 * g, Uint8 * b, + Uint8 * a); + +/** + * \brief Set the blend mode used for drawing operations (Fill and Line). + * + * \param renderer The renderer for which blend mode should be set. + * \param blendMode ::SDL_BlendMode to use for blending. + * + * \return 0 on success, or -1 on error + * + * \note If the blend mode is not supported, the closest supported mode is + * chosen. + * + * \sa SDL_GetRenderDrawBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer, + SDL_BlendMode blendMode); + +/** + * \brief Get the blend mode used for drawing operations. + * + * \param renderer The renderer from which blend mode should be queried. + * \param blendMode A pointer filled in with the current blend mode. + * + * \return 0 on success, or -1 on error + * + * \sa SDL_SetRenderDrawBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer, + SDL_BlendMode *blendMode); + +/** + * \brief Clear the current rendering target with the drawing color + * + * This function clears the entire rendering target, ignoring the viewport. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer); + +/** + * \brief Draw a point on the current rendering target. + * + * \param renderer The renderer which should draw a point. + * \param x The x coordinate of the point. + * \param y The y coordinate of the point. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer, + int x, int y); + +/** + * \brief Draw multiple points on the current rendering target. + * + * \param renderer The renderer which should draw multiple points. + * \param points The points to draw + * \param count The number of points to draw + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer, + const SDL_Point * points, + int count); + +/** + * \brief Draw a line on the current rendering target. + * + * \param renderer The renderer which should draw a line. + * \param x1 The x coordinate of the start point. + * \param y1 The y coordinate of the start point. + * \param x2 The x coordinate of the end point. + * \param y2 The y coordinate of the end point. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer, + int x1, int y1, int x2, int y2); + +/** + * \brief Draw a series of connected lines on the current rendering target. + * + * \param renderer The renderer which should draw multiple lines. + * \param points The points along the lines + * \param count The number of points, drawing count-1 lines + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer, + const SDL_Point * points, + int count); + +/** + * \brief Draw a rectangle on the current rendering target. + * + * \param renderer The renderer which should draw a rectangle. + * \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer, + const SDL_Rect * rect); + +/** + * \brief Draw some number of rectangles on the current rendering target. + * + * \param renderer The renderer which should draw multiple rectangles. + * \param rects A pointer to an array of destination rectangles. + * \param count The number of rectangles. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer, + const SDL_Rect * rects, + int count); + +/** + * \brief Fill a rectangle on the current rendering target with the drawing color. + * + * \param renderer The renderer which should fill a rectangle. + * \param rect A pointer to the destination rectangle, or NULL for the entire + * rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer, + const SDL_Rect * rect); + +/** + * \brief Fill some number of rectangles on the current rendering target with the drawing color. + * + * \param renderer The renderer which should fill multiple rectangles. + * \param rects A pointer to an array of destination rectangles. + * \param count The number of rectangles. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer, + const SDL_Rect * rects, + int count); + +/** + * \brief Copy a portion of the texture to the current rendering target. + * + * \param renderer The renderer which should copy parts of a texture. + * \param texture The source texture. + * \param srcrect A pointer to the source rectangle, or NULL for the entire + * texture. + * \param dstrect A pointer to the destination rectangle, or NULL for the + * entire rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer, + SDL_Texture * texture, + const SDL_Rect * srcrect, + const SDL_Rect * dstrect); + +/** + * \brief Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center + * + * \param renderer The renderer which should copy parts of a texture. + * \param texture The source texture. + * \param srcrect A pointer to the source rectangle, or NULL for the entire + * texture. + * \param dstrect A pointer to the destination rectangle, or NULL for the + * entire rendering target. + * \param angle An angle in degrees that indicates the rotation that will be applied to dstrect + * \param center A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done aroud dstrect.w/2, dstrect.h/2) + * \param flip An SDL_RendererFlip value stating which flipping actions should be performed on the texture + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer, + SDL_Texture * texture, + const SDL_Rect * srcrect, + const SDL_Rect * dstrect, + const double angle, + const SDL_Point *center, + const SDL_RendererFlip flip); + +/** + * \brief Read pixels from the current rendering target. + * + * \param renderer The renderer from which pixels should be read. + * \param rect A pointer to the rectangle to read, or NULL for the entire + * render target. + * \param format The desired format of the pixel data, or 0 to use the format + * of the rendering target + * \param pixels A pointer to be filled in with the pixel data + * \param pitch The pitch of the pixels parameter. + * + * \return 0 on success, or -1 if pixel reading is not supported. + * + * \warning This is a very slow operation, and should not be used frequently. + */ +extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer, + const SDL_Rect * rect, + Uint32 format, + void *pixels, int pitch); + +/** + * \brief Update the screen with rendering performed. + */ +extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer); + +/** + * \brief Destroy the specified texture. + * + * \sa SDL_CreateTexture() + * \sa SDL_CreateTextureFromSurface() + */ +extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture); + +/** + * \brief Destroy the rendering context for a window and free associated + * textures. + * + * \sa SDL_CreateRenderer() + */ +extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer); + + +/** + * \brief Bind the texture to the current OpenGL/ES/ES2 context for use with + * OpenGL instructions. + * + * \param texture The SDL texture to bind + * \param texw A pointer to a float that will be filled with the texture width + * \param texh A pointer to a float that will be filled with the texture height + * + * \return 0 on success, or -1 if the operation is not supported + */ +extern DECLSPEC int SDLCALL SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh); + +/** + * \brief Unbind a texture from the current OpenGL/ES/ES2 context. + * + * \param texture The SDL texture to unbind + * + * \return 0 on success, or -1 if the operation is not supported + */ +extern DECLSPEC int SDLCALL SDL_GL_UnbindTexture(SDL_Texture *texture); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_render_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_revision.h spring-98.0~14.04~ppa6/include/SDL2/SDL_revision.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_revision.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_revision.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,2 @@ +#define SDL_REVISION "hg-7890:c031abe0b287" +#define SDL_REVISION_NUMBER 7890 diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_rwops.h spring-98.0~14.04~ppa6/include/SDL2/SDL_rwops.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_rwops.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_rwops.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,232 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_rwops.h + * + * This file provides a general interface for SDL to read and write + * data streams. It can easily be extended to files, memory, etc. + */ + +#ifndef _SDL_rwops_h +#define _SDL_rwops_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* RWops Types */ +#define SDL_RWOPS_UNKNOWN 0 /* Unknown stream type */ +#define SDL_RWOPS_WINFILE 1 /* Win32 file */ +#define SDL_RWOPS_STDFILE 2 /* Stdio file */ +#define SDL_RWOPS_JNIFILE 3 /* Android asset */ +#define SDL_RWOPS_MEMORY 4 /* Memory stream */ +#define SDL_RWOPS_MEMORY_RO 5 /* Read-Only memory stream */ + +/** + * This is the read/write operation structure -- very basic. + */ +typedef struct SDL_RWops +{ + /** + * Return the size of the file in this rwops, or -1 if unknown + */ + Sint64 (SDLCALL * size) (struct SDL_RWops * context); + + /** + * Seek to \c offset relative to \c whence, one of stdio's whence values: + * RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END + * + * \return the final offset in the data stream, or -1 on error. + */ + Sint64 (SDLCALL * seek) (struct SDL_RWops * context, Sint64 offset, + int whence); + + /** + * Read up to \c maxnum objects each of size \c size from the data + * stream to the area pointed at by \c ptr. + * + * \return the number of objects read, or 0 at error or end of file. + */ + size_t (SDLCALL * read) (struct SDL_RWops * context, void *ptr, + size_t size, size_t maxnum); + + /** + * Write exactly \c num objects each of size \c size from the area + * pointed at by \c ptr to data stream. + * + * \return the number of objects written, or 0 at error or end of file. + */ + size_t (SDLCALL * write) (struct SDL_RWops * context, const void *ptr, + size_t size, size_t num); + + /** + * Close and free an allocated SDL_RWops structure. + * + * \return 0 if successful or -1 on write error when flushing data. + */ + int (SDLCALL * close) (struct SDL_RWops * context); + + Uint32 type; + union + { +#if defined(ANDROID) + struct + { + void *fileNameRef; + void *inputStreamRef; + void *readableByteChannelRef; + void *readMethod; + void *assetFileDescriptorRef; + long position; + long size; + long offset; + int fd; + } androidio; +#elif defined(__WIN32__) + struct + { + SDL_bool append; + void *h; + struct + { + void *data; + size_t size; + size_t left; + } buffer; + } windowsio; +#endif + +#ifdef HAVE_STDIO_H + struct + { + SDL_bool autoclose; + FILE *fp; + } stdio; +#endif + struct + { + Uint8 *base; + Uint8 *here; + Uint8 *stop; + } mem; + struct + { + void *data1; + void *data2; + } unknown; + } hidden; + +} SDL_RWops; + + +/** + * \name RWFrom functions + * + * Functions to create SDL_RWops structures from various data streams. + */ +/* @{ */ + +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file, + const char *mode); + +#ifdef HAVE_STDIO_H +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(FILE * fp, + SDL_bool autoclose); +#else +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(void * fp, + SDL_bool autoclose); +#endif + +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, int size); +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem(const void *mem, + int size); + +/* @} *//* RWFrom functions */ + + +extern DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW(void); +extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area); + +#define RW_SEEK_SET 0 /**< Seek from the beginning of data */ +#define RW_SEEK_CUR 1 /**< Seek relative to current read point */ +#define RW_SEEK_END 2 /**< Seek relative to the end of data */ + +/** + * \name Read/write macros + * + * Macros to easily read and write from an SDL_RWops structure. + */ +/* @{ */ +#define SDL_RWsize(ctx) (ctx)->size(ctx) +#define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence) +#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR) +#define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n) +#define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n) +#define SDL_RWclose(ctx) (ctx)->close(ctx) +/* @} *//* Read/write macros */ + + +/** + * \name Read endian functions + * + * Read an item of the specified endianness and return in native format. + */ +/* @{ */ +extern DECLSPEC Uint8 SDLCALL SDL_ReadU8(SDL_RWops * src); +extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops * src); +extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops * src); +extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops * src); +extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops * src); +extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops * src); +extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops * src); +/* @} *//* Read endian functions */ + +/** + * \name Write endian functions + * + * Write an item of native format to the specified endianness. + */ +/* @{ */ +extern DECLSPEC size_t SDLCALL SDL_WriteU8(SDL_RWops * dst, Uint8 value); +extern DECLSPEC size_t SDLCALL SDL_WriteLE16(SDL_RWops * dst, Uint16 value); +extern DECLSPEC size_t SDLCALL SDL_WriteBE16(SDL_RWops * dst, Uint16 value); +extern DECLSPEC size_t SDLCALL SDL_WriteLE32(SDL_RWops * dst, Uint32 value); +extern DECLSPEC size_t SDLCALL SDL_WriteBE32(SDL_RWops * dst, Uint32 value); +extern DECLSPEC size_t SDLCALL SDL_WriteLE64(SDL_RWops * dst, Uint64 value); +extern DECLSPEC size_t SDLCALL SDL_WriteBE64(SDL_RWops * dst, Uint64 value); +/* @} *//* Write endian functions */ + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_rwops_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_scancode.h spring-98.0~14.04~ppa6/include/SDL2/SDL_scancode.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_scancode.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_scancode.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,401 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_scancode.h + * + * Defines keyboard scancodes. + */ + +#ifndef _SDL_scancode_h +#define _SDL_scancode_h + +#include "SDL_stdinc.h" + +/** + * \brief The SDL keyboard scancode representation. + * + * Values of this type are used to represent keyboard keys, among other places + * in the \link SDL_Keysym::scancode key.keysym.scancode \endlink field of the + * SDL_Event structure. + * + * The values in this enumeration are based on the USB usage page standard: + * http://www.usb.org/developers/devclass_docs/Hut1_12v2.pdf + */ +typedef enum +{ + SDL_SCANCODE_UNKNOWN = 0, + + /** + * \name Usage page 0x07 + * + * These values are from usage page 0x07 (USB keyboard page). + */ + /* @{ */ + + SDL_SCANCODE_A = 4, + SDL_SCANCODE_B = 5, + SDL_SCANCODE_C = 6, + SDL_SCANCODE_D = 7, + SDL_SCANCODE_E = 8, + SDL_SCANCODE_F = 9, + SDL_SCANCODE_G = 10, + SDL_SCANCODE_H = 11, + SDL_SCANCODE_I = 12, + SDL_SCANCODE_J = 13, + SDL_SCANCODE_K = 14, + SDL_SCANCODE_L = 15, + SDL_SCANCODE_M = 16, + SDL_SCANCODE_N = 17, + SDL_SCANCODE_O = 18, + SDL_SCANCODE_P = 19, + SDL_SCANCODE_Q = 20, + SDL_SCANCODE_R = 21, + SDL_SCANCODE_S = 22, + SDL_SCANCODE_T = 23, + SDL_SCANCODE_U = 24, + SDL_SCANCODE_V = 25, + SDL_SCANCODE_W = 26, + SDL_SCANCODE_X = 27, + SDL_SCANCODE_Y = 28, + SDL_SCANCODE_Z = 29, + + SDL_SCANCODE_1 = 30, + SDL_SCANCODE_2 = 31, + SDL_SCANCODE_3 = 32, + SDL_SCANCODE_4 = 33, + SDL_SCANCODE_5 = 34, + SDL_SCANCODE_6 = 35, + SDL_SCANCODE_7 = 36, + SDL_SCANCODE_8 = 37, + SDL_SCANCODE_9 = 38, + SDL_SCANCODE_0 = 39, + + SDL_SCANCODE_RETURN = 40, + SDL_SCANCODE_ESCAPE = 41, + SDL_SCANCODE_BACKSPACE = 42, + SDL_SCANCODE_TAB = 43, + SDL_SCANCODE_SPACE = 44, + + SDL_SCANCODE_MINUS = 45, + SDL_SCANCODE_EQUALS = 46, + SDL_SCANCODE_LEFTBRACKET = 47, + SDL_SCANCODE_RIGHTBRACKET = 48, + SDL_SCANCODE_BACKSLASH = 49, /**< Located at the lower left of the return + * key on ISO keyboards and at the right end + * of the QWERTY row on ANSI keyboards. + * Produces REVERSE SOLIDUS (backslash) and + * VERTICAL LINE in a US layout, REVERSE + * SOLIDUS and VERTICAL LINE in a UK Mac + * layout, NUMBER SIGN and TILDE in a UK + * Windows layout, DOLLAR SIGN and POUND SIGN + * in a Swiss German layout, NUMBER SIGN and + * APOSTROPHE in a German layout, GRAVE + * ACCENT and POUND SIGN in a French Mac + * layout, and ASTERISK and MICRO SIGN in a + * French Windows layout. + */ + SDL_SCANCODE_NONUSHASH = 50, /**< ISO USB keyboards actually use this code + * instead of 49 for the same key, but all + * OSes I've seen treat the two codes + * identically. So, as an implementor, unless + * your keyboard generates both of those + * codes and your OS treats them differently, + * you should generate SDL_SCANCODE_BACKSLASH + * instead of this code. As a user, you + * should not rely on this code because SDL + * will never generate it with most (all?) + * keyboards. + */ + SDL_SCANCODE_SEMICOLON = 51, + SDL_SCANCODE_APOSTROPHE = 52, + SDL_SCANCODE_GRAVE = 53, /**< Located in the top left corner (on both ANSI + * and ISO keyboards). Produces GRAVE ACCENT and + * TILDE in a US Windows layout and in US and UK + * Mac layouts on ANSI keyboards, GRAVE ACCENT + * and NOT SIGN in a UK Windows layout, SECTION + * SIGN and PLUS-MINUS SIGN in US and UK Mac + * layouts on ISO keyboards, SECTION SIGN and + * DEGREE SIGN in a Swiss German layout (Mac: + * only on ISO keyboards), CIRCUMFLEX ACCENT and + * DEGREE SIGN in a German layout (Mac: only on + * ISO keyboards), SUPERSCRIPT TWO and TILDE in a + * French Windows layout, COMMERCIAL AT and + * NUMBER SIGN in a French Mac layout on ISO + * keyboards, and LESS-THAN SIGN and GREATER-THAN + * SIGN in a Swiss German, German, or French Mac + * layout on ANSI keyboards. + */ + SDL_SCANCODE_COMMA = 54, + SDL_SCANCODE_PERIOD = 55, + SDL_SCANCODE_SLASH = 56, + + SDL_SCANCODE_CAPSLOCK = 57, + + SDL_SCANCODE_F1 = 58, + SDL_SCANCODE_F2 = 59, + SDL_SCANCODE_F3 = 60, + SDL_SCANCODE_F4 = 61, + SDL_SCANCODE_F5 = 62, + SDL_SCANCODE_F6 = 63, + SDL_SCANCODE_F7 = 64, + SDL_SCANCODE_F8 = 65, + SDL_SCANCODE_F9 = 66, + SDL_SCANCODE_F10 = 67, + SDL_SCANCODE_F11 = 68, + SDL_SCANCODE_F12 = 69, + + SDL_SCANCODE_PRINTSCREEN = 70, + SDL_SCANCODE_SCROLLLOCK = 71, + SDL_SCANCODE_PAUSE = 72, + SDL_SCANCODE_INSERT = 73, /**< insert on PC, help on some Mac keyboards (but + does send code 73, not 117) */ + SDL_SCANCODE_HOME = 74, + SDL_SCANCODE_PAGEUP = 75, + SDL_SCANCODE_DELETE = 76, + SDL_SCANCODE_END = 77, + SDL_SCANCODE_PAGEDOWN = 78, + SDL_SCANCODE_RIGHT = 79, + SDL_SCANCODE_LEFT = 80, + SDL_SCANCODE_DOWN = 81, + SDL_SCANCODE_UP = 82, + + SDL_SCANCODE_NUMLOCKCLEAR = 83, /**< num lock on PC, clear on Mac keyboards + */ + SDL_SCANCODE_KP_DIVIDE = 84, + SDL_SCANCODE_KP_MULTIPLY = 85, + SDL_SCANCODE_KP_MINUS = 86, + SDL_SCANCODE_KP_PLUS = 87, + SDL_SCANCODE_KP_ENTER = 88, + SDL_SCANCODE_KP_1 = 89, + SDL_SCANCODE_KP_2 = 90, + SDL_SCANCODE_KP_3 = 91, + SDL_SCANCODE_KP_4 = 92, + SDL_SCANCODE_KP_5 = 93, + SDL_SCANCODE_KP_6 = 94, + SDL_SCANCODE_KP_7 = 95, + SDL_SCANCODE_KP_8 = 96, + SDL_SCANCODE_KP_9 = 97, + SDL_SCANCODE_KP_0 = 98, + SDL_SCANCODE_KP_PERIOD = 99, + + SDL_SCANCODE_NONUSBACKSLASH = 100, /**< This is the additional key that ISO + * keyboards have over ANSI ones, + * located between left shift and Y. + * Produces GRAVE ACCENT and TILDE in a + * US or UK Mac layout, REVERSE SOLIDUS + * (backslash) and VERTICAL LINE in a + * US or UK Windows layout, and + * LESS-THAN SIGN and GREATER-THAN SIGN + * in a Swiss German, German, or French + * layout. */ + SDL_SCANCODE_APPLICATION = 101, /**< windows contextual menu, compose */ + SDL_SCANCODE_POWER = 102, /**< The USB document says this is a status flag, + * not a physical key - but some Mac keyboards + * do have a power key. */ + SDL_SCANCODE_KP_EQUALS = 103, + SDL_SCANCODE_F13 = 104, + SDL_SCANCODE_F14 = 105, + SDL_SCANCODE_F15 = 106, + SDL_SCANCODE_F16 = 107, + SDL_SCANCODE_F17 = 108, + SDL_SCANCODE_F18 = 109, + SDL_SCANCODE_F19 = 110, + SDL_SCANCODE_F20 = 111, + SDL_SCANCODE_F21 = 112, + SDL_SCANCODE_F22 = 113, + SDL_SCANCODE_F23 = 114, + SDL_SCANCODE_F24 = 115, + SDL_SCANCODE_EXECUTE = 116, + SDL_SCANCODE_HELP = 117, + SDL_SCANCODE_MENU = 118, + SDL_SCANCODE_SELECT = 119, + SDL_SCANCODE_STOP = 120, + SDL_SCANCODE_AGAIN = 121, /**< redo */ + SDL_SCANCODE_UNDO = 122, + SDL_SCANCODE_CUT = 123, + SDL_SCANCODE_COPY = 124, + SDL_SCANCODE_PASTE = 125, + SDL_SCANCODE_FIND = 126, + SDL_SCANCODE_MUTE = 127, + SDL_SCANCODE_VOLUMEUP = 128, + SDL_SCANCODE_VOLUMEDOWN = 129, +/* not sure whether there's a reason to enable these */ +/* SDL_SCANCODE_LOCKINGCAPSLOCK = 130, */ +/* SDL_SCANCODE_LOCKINGNUMLOCK = 131, */ +/* SDL_SCANCODE_LOCKINGSCROLLLOCK = 132, */ + SDL_SCANCODE_KP_COMMA = 133, + SDL_SCANCODE_KP_EQUALSAS400 = 134, + + SDL_SCANCODE_INTERNATIONAL1 = 135, /**< used on Asian keyboards, see + footnotes in USB doc */ + SDL_SCANCODE_INTERNATIONAL2 = 136, + SDL_SCANCODE_INTERNATIONAL3 = 137, /**< Yen */ + SDL_SCANCODE_INTERNATIONAL4 = 138, + SDL_SCANCODE_INTERNATIONAL5 = 139, + SDL_SCANCODE_INTERNATIONAL6 = 140, + SDL_SCANCODE_INTERNATIONAL7 = 141, + SDL_SCANCODE_INTERNATIONAL8 = 142, + SDL_SCANCODE_INTERNATIONAL9 = 143, + SDL_SCANCODE_LANG1 = 144, /**< Hangul/English toggle */ + SDL_SCANCODE_LANG2 = 145, /**< Hanja conversion */ + SDL_SCANCODE_LANG3 = 146, /**< Katakana */ + SDL_SCANCODE_LANG4 = 147, /**< Hiragana */ + SDL_SCANCODE_LANG5 = 148, /**< Zenkaku/Hankaku */ + SDL_SCANCODE_LANG6 = 149, /**< reserved */ + SDL_SCANCODE_LANG7 = 150, /**< reserved */ + SDL_SCANCODE_LANG8 = 151, /**< reserved */ + SDL_SCANCODE_LANG9 = 152, /**< reserved */ + + SDL_SCANCODE_ALTERASE = 153, /**< Erase-Eaze */ + SDL_SCANCODE_SYSREQ = 154, + SDL_SCANCODE_CANCEL = 155, + SDL_SCANCODE_CLEAR = 156, + SDL_SCANCODE_PRIOR = 157, + SDL_SCANCODE_RETURN2 = 158, + SDL_SCANCODE_SEPARATOR = 159, + SDL_SCANCODE_OUT = 160, + SDL_SCANCODE_OPER = 161, + SDL_SCANCODE_CLEARAGAIN = 162, + SDL_SCANCODE_CRSEL = 163, + SDL_SCANCODE_EXSEL = 164, + + SDL_SCANCODE_KP_00 = 176, + SDL_SCANCODE_KP_000 = 177, + SDL_SCANCODE_THOUSANDSSEPARATOR = 178, + SDL_SCANCODE_DECIMALSEPARATOR = 179, + SDL_SCANCODE_CURRENCYUNIT = 180, + SDL_SCANCODE_CURRENCYSUBUNIT = 181, + SDL_SCANCODE_KP_LEFTPAREN = 182, + SDL_SCANCODE_KP_RIGHTPAREN = 183, + SDL_SCANCODE_KP_LEFTBRACE = 184, + SDL_SCANCODE_KP_RIGHTBRACE = 185, + SDL_SCANCODE_KP_TAB = 186, + SDL_SCANCODE_KP_BACKSPACE = 187, + SDL_SCANCODE_KP_A = 188, + SDL_SCANCODE_KP_B = 189, + SDL_SCANCODE_KP_C = 190, + SDL_SCANCODE_KP_D = 191, + SDL_SCANCODE_KP_E = 192, + SDL_SCANCODE_KP_F = 193, + SDL_SCANCODE_KP_XOR = 194, + SDL_SCANCODE_KP_POWER = 195, + SDL_SCANCODE_KP_PERCENT = 196, + SDL_SCANCODE_KP_LESS = 197, + SDL_SCANCODE_KP_GREATER = 198, + SDL_SCANCODE_KP_AMPERSAND = 199, + SDL_SCANCODE_KP_DBLAMPERSAND = 200, + SDL_SCANCODE_KP_VERTICALBAR = 201, + SDL_SCANCODE_KP_DBLVERTICALBAR = 202, + SDL_SCANCODE_KP_COLON = 203, + SDL_SCANCODE_KP_HASH = 204, + SDL_SCANCODE_KP_SPACE = 205, + SDL_SCANCODE_KP_AT = 206, + SDL_SCANCODE_KP_EXCLAM = 207, + SDL_SCANCODE_KP_MEMSTORE = 208, + SDL_SCANCODE_KP_MEMRECALL = 209, + SDL_SCANCODE_KP_MEMCLEAR = 210, + SDL_SCANCODE_KP_MEMADD = 211, + SDL_SCANCODE_KP_MEMSUBTRACT = 212, + SDL_SCANCODE_KP_MEMMULTIPLY = 213, + SDL_SCANCODE_KP_MEMDIVIDE = 214, + SDL_SCANCODE_KP_PLUSMINUS = 215, + SDL_SCANCODE_KP_CLEAR = 216, + SDL_SCANCODE_KP_CLEARENTRY = 217, + SDL_SCANCODE_KP_BINARY = 218, + SDL_SCANCODE_KP_OCTAL = 219, + SDL_SCANCODE_KP_DECIMAL = 220, + SDL_SCANCODE_KP_HEXADECIMAL = 221, + + SDL_SCANCODE_LCTRL = 224, + SDL_SCANCODE_LSHIFT = 225, + SDL_SCANCODE_LALT = 226, /**< alt, option */ + SDL_SCANCODE_LGUI = 227, /**< windows, command (apple), meta */ + SDL_SCANCODE_RCTRL = 228, + SDL_SCANCODE_RSHIFT = 229, + SDL_SCANCODE_RALT = 230, /**< alt gr, option */ + SDL_SCANCODE_RGUI = 231, /**< windows, command (apple), meta */ + + SDL_SCANCODE_MODE = 257, /**< I'm not sure if this is really not covered + * by any of the above, but since there's a + * special KMOD_MODE for it I'm adding it here + */ + + /* @} *//* Usage page 0x07 */ + + /** + * \name Usage page 0x0C + * + * These values are mapped from usage page 0x0C (USB consumer page). + */ + /* @{ */ + + SDL_SCANCODE_AUDIONEXT = 258, + SDL_SCANCODE_AUDIOPREV = 259, + SDL_SCANCODE_AUDIOSTOP = 260, + SDL_SCANCODE_AUDIOPLAY = 261, + SDL_SCANCODE_AUDIOMUTE = 262, + SDL_SCANCODE_MEDIASELECT = 263, + SDL_SCANCODE_WWW = 264, + SDL_SCANCODE_MAIL = 265, + SDL_SCANCODE_CALCULATOR = 266, + SDL_SCANCODE_COMPUTER = 267, + SDL_SCANCODE_AC_SEARCH = 268, + SDL_SCANCODE_AC_HOME = 269, + SDL_SCANCODE_AC_BACK = 270, + SDL_SCANCODE_AC_FORWARD = 271, + SDL_SCANCODE_AC_STOP = 272, + SDL_SCANCODE_AC_REFRESH = 273, + SDL_SCANCODE_AC_BOOKMARKS = 274, + + /* @} *//* Usage page 0x0C */ + + /** + * \name Walther keys + * + * These are values that Christian Walther added (for mac keyboard?). + */ + /* @{ */ + + SDL_SCANCODE_BRIGHTNESSDOWN = 275, + SDL_SCANCODE_BRIGHTNESSUP = 276, + SDL_SCANCODE_DISPLAYSWITCH = 277, /**< display mirroring/dual display + switch, video mode switch */ + SDL_SCANCODE_KBDILLUMTOGGLE = 278, + SDL_SCANCODE_KBDILLUMDOWN = 279, + SDL_SCANCODE_KBDILLUMUP = 280, + SDL_SCANCODE_EJECT = 281, + SDL_SCANCODE_SLEEP = 282, + + SDL_SCANCODE_APP1 = 283, + SDL_SCANCODE_APP2 = 284, + + /* @} *//* Walther keys */ + + /* Add any other keys here. */ + + SDL_NUM_SCANCODES = 512 /**< not a key, just marks the number of scancodes + for array bounds */ +} SDL_Scancode; + +#endif /* _SDL_scancode_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_shape.h spring-98.0~14.04~ppa6/include/SDL2/SDL_shape.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_shape.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_shape.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,143 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_shape_h +#define _SDL_shape_h + +#include "SDL_stdinc.h" +#include "SDL_pixels.h" +#include "SDL_rect.h" +#include "SDL_surface.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** \file SDL_shape.h + * + * Header file for the shaped window API. + */ + +#define SDL_NONSHAPEABLE_WINDOW -1 +#define SDL_INVALID_SHAPE_ARGUMENT -2 +#define SDL_WINDOW_LACKS_SHAPE -3 + +/** + * \brief Create a window that can be shaped with the specified position, dimensions, and flags. + * + * \param title The title of the window, in UTF-8 encoding. + * \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or + * ::SDL_WINDOWPOS_UNDEFINED. + * \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or + * ::SDL_WINDOWPOS_UNDEFINED. + * \param w The width of the window. + * \param h The height of the window. + * \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with any of the following: + * ::SDL_WINDOW_OPENGL, ::SDL_WINDOW_INPUT_GRABBED, + * ::SDL_WINDOW_HIDDEN, ::SDL_WINDOW_RESIZABLE, + * ::SDL_WINDOW_MAXIMIZED, ::SDL_WINDOW_MINIMIZED, + * ::SDL_WINDOW_BORDERLESS is always set, and ::SDL_WINDOW_FULLSCREEN is always unset. + * + * \return The window created, or NULL if window creation failed. + * + * \sa SDL_DestroyWindow() + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags); + +/** + * \brief Return whether the given window is a shaped window. + * + * \param window The window to query for being shaped. + * + * \return SDL_TRUE if the window is a window that can be shaped, SDL_FALSE if the window is unshaped or NULL. + * \sa SDL_CreateShapedWindow + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IsShapedWindow(const SDL_Window *window); + +/** \brief An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. */ +typedef enum { + /** \brief The default mode, a binarized alpha cutoff of 1. */ + ShapeModeDefault, + /** \brief A binarized alpha cutoff with a given integer value. */ + ShapeModeBinarizeAlpha, + /** \brief A binarized alpha cutoff with a given integer value, but with the opposite comparison. */ + ShapeModeReverseBinarizeAlpha, + /** \brief A color key is applied. */ + ShapeModeColorKey +} WindowShapeMode; + +#define SDL_SHAPEMODEALPHA(mode) (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha) + +/** \brief A union containing parameters for shaped windows. */ +typedef union { + /** \brief a cutoff alpha value for binarization of the window shape's alpha channel. */ + Uint8 binarizationCutoff; + SDL_Color colorKey; +} SDL_WindowShapeParams; + +/** \brief A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents. */ +typedef struct SDL_WindowShapeMode { + /** \brief The mode of these window-shape parameters. */ + WindowShapeMode mode; + /** \brief Window-shape parameters. */ + SDL_WindowShapeParams parameters; +} SDL_WindowShapeMode; + +/** + * \brief Set the shape and parameters of a shaped window. + * + * \param window The shaped window whose parameters should be set. + * \param shape A surface encoding the desired shape for the window. + * \param shape_mode The parameters to set for the shaped window. + * + * \return 0 on success, SDL_INVALID_SHAPE_ARGUMENT on invalid an invalid shape argument, or SDL_NONSHAPEABLE_WINDOW + * if the SDL_Window* given does not reference a valid shaped window. + * + * \sa SDL_WindowShapeMode + * \sa SDL_GetShapedWindowMode. + */ +extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode); + +/** + * \brief Get the shape parameters of a shaped window. + * + * \param window The shaped window whose parameters should be retrieved. + * \param shape_mode An empty shape-mode structure to fill, or NULL to check whether the window has a shape. + * + * \return 0 if the window has a shape and, provided shape_mode was not NULL, shape_mode has been filled with the mode + * data, SDL_NONSHAPEABLE_WINDOW if the SDL_Window given is not a shaped window, or SDL_WINDOW_LACKS_SHAPE if + * the SDL_Window* given is a shapeable window currently lacking a shape. + * + * \sa SDL_WindowShapeMode + * \sa SDL_SetWindowShape + */ +extern DECLSPEC int SDLCALL SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_shape_h */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_stdinc.h spring-98.0~14.04~ppa6/include/SDL2/SDL_stdinc.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_stdinc.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_stdinc.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,392 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_stdinc.h + * + * This is a general header that includes C language support. + */ + +#ifndef _SDL_stdinc_h +#define _SDL_stdinc_h + +#include "SDL_config.h" + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_STDIO_H +#include +#endif +#if defined(STDC_HEADERS) +# include +# include +# include +#else +# if defined(HAVE_STDLIB_H) +# include +# elif defined(HAVE_MALLOC_H) +# include +# endif +# if defined(HAVE_STDDEF_H) +# include +# endif +# if defined(HAVE_STDARG_H) +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H) +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#if defined(HAVE_INTTYPES_H) +# include +#elif defined(HAVE_STDINT_H) +# include +#endif +#ifdef HAVE_CTYPE_H +# include +#endif +#ifdef HAVE_MATH_H +# include +#endif +#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H) +# include +#endif + +/** + * The number of elements in an array. + */ +#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0])) +#define SDL_TABLESIZE(table) SDL_arraysize(table) + +/** + * \name Cast operators + * + * Use proper C++ casts when compiled as C++ to be compatible with the option + * -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above). + */ +/* @{ */ +#ifdef __cplusplus +#define SDL_reinterpret_cast(type, expression) reinterpret_cast(expression) +#define SDL_static_cast(type, expression) static_cast(expression) +#define SDL_const_cast(type, expression) const_cast(expression) +#else +#define SDL_reinterpret_cast(type, expression) ((type)(expression)) +#define SDL_static_cast(type, expression) ((type)(expression)) +#define SDL_const_cast(type, expression) ((type)(expression)) +#endif +/* @} *//* Cast operators */ + +/* Define a four character code as a Uint32 */ +#define SDL_FOURCC(A, B, C, D) \ + ((SDL_static_cast(Uint32, SDL_static_cast(Uint8, (A))) << 0) | \ + (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (B))) << 8) | \ + (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (C))) << 16) | \ + (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (D))) << 24)) + +/** + * \name Basic data types + */ +/* @{ */ + +typedef enum +{ + SDL_FALSE = 0, + SDL_TRUE = 1 +} SDL_bool; + +/** + * \brief A signed 8-bit integer type. + */ +typedef int8_t Sint8; +/** + * \brief An unsigned 8-bit integer type. + */ +typedef uint8_t Uint8; +/** + * \brief A signed 16-bit integer type. + */ +typedef int16_t Sint16; +/** + * \brief An unsigned 16-bit integer type. + */ +typedef uint16_t Uint16; +/** + * \brief A signed 32-bit integer type. + */ +typedef int32_t Sint32; +/** + * \brief An unsigned 32-bit integer type. + */ +typedef uint32_t Uint32; + +/** + * \brief A signed 64-bit integer type. + */ +typedef int64_t Sint64; +/** + * \brief An unsigned 64-bit integer type. + */ +typedef uint64_t Uint64; + +/* @} *//* Basic data types */ + + +#define SDL_COMPILE_TIME_ASSERT(name, x) \ + typedef int SDL_dummy_ ## name[(x) * 2 - 1] +/** \cond */ +#ifndef DOXYGEN_SHOULD_IGNORE_THIS +SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1); +SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1); +SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2); +SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2); +SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4); +SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4); +SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8); +SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8); +#endif /* DOXYGEN_SHOULD_IGNORE_THIS */ +/** \endcond */ + +/* Check to make sure enums are the size of ints, for structure packing. + For both Watcom C/C++ and Borland C/C++ the compiler option that makes + enums having the size of an int must be enabled. + This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11). +*/ + +/** \cond */ +#ifndef DOXYGEN_SHOULD_IGNORE_THIS +#if !defined(__ANDROID__) + /* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */ +typedef enum +{ + DUMMY_ENUM_VALUE +} SDL_DUMMY_ENUM; + +SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int)); +#endif +#endif /* DOXYGEN_SHOULD_IGNORE_THIS */ +/** \endcond */ + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(HAVE_ALLOCA) && !defined(alloca) +# if defined(HAVE_ALLOCA_H) +# include +# elif defined(__GNUC__) +# define alloca __builtin_alloca +# elif defined(_MSC_VER) +# include +# define alloca _alloca +# elif defined(__WATCOMC__) +# include +# elif defined(__BORLANDC__) +# include +# elif defined(__DMC__) +# include +# elif defined(__AIX__) +#pragma alloca +# elif defined(__MRC__) +void *alloca(unsigned); +# else +char *alloca(); +# endif +#endif +#ifdef HAVE_ALLOCA +#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count)) +#define SDL_stack_free(data) +#else +#define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*(count)) +#define SDL_stack_free(data) SDL_free(data) +#endif + +extern DECLSPEC void *SDLCALL SDL_malloc(size_t size); +extern DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size); +extern DECLSPEC void *SDLCALL SDL_realloc(void *mem, size_t size); +extern DECLSPEC void SDLCALL SDL_free(void *mem); + +extern DECLSPEC char *SDLCALL SDL_getenv(const char *name); +extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value, int overwrite); + +extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *)); + +extern DECLSPEC int SDLCALL SDL_abs(int x); + +/* !!! FIXME: these have side effects. You probably shouldn't use them. */ +/* !!! FIXME: Maybe we do forceinline functions of SDL_mini, SDL_minf, etc? */ +#define SDL_min(x, y) (((x) < (y)) ? (x) : (y)) +#define SDL_max(x, y) (((x) > (y)) ? (x) : (y)) + +extern DECLSPEC int SDLCALL SDL_isdigit(int x); +extern DECLSPEC int SDLCALL SDL_isspace(int x); +extern DECLSPEC int SDLCALL SDL_toupper(int x); +extern DECLSPEC int SDLCALL SDL_tolower(int x); + +extern DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len); + +#define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x))) +#define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x))) + +/* Note that memset() is a byte assignment and this is a 32-bit assignment, so they're not directly equivalent. */ +SDL_FORCE_INLINE void SDL_memset4(void *dst, int val, size_t dwords) +{ +#if defined(__GNUC__) && defined(i386) + int u0, u1, u2; + __asm__ __volatile__ ( + "cld \n\t" + "rep ; stosl \n\t" + : "=&D" (u0), "=&a" (u1), "=&c" (u2) + : "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, dwords)) + : "memory" + ); +#else + size_t _n = (dwords + 3) / 4; + Uint32 *_p = SDL_static_cast(Uint32 *, dst); + Uint32 _val = (val); + if (dwords == 0) + return; + switch (dwords % 4) + { + case 0: do { *_p++ = _val; + case 3: *_p++ = _val; + case 2: *_p++ = _val; + case 1: *_p++ = _val; + } while ( --_n ); + } +#endif +} + + +extern DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src, size_t len); + +SDL_FORCE_INLINE void *SDL_memcpy4(void *dst, const void *src, size_t dwords) +{ + return SDL_memcpy(dst, src, dwords * 4); +} + +extern DECLSPEC void *SDLCALL SDL_memmove(void *dst, const void *src, size_t len); +extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len); + +extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t *wstr); +extern DECLSPEC size_t SDLCALL SDL_wcslcpy(wchar_t *dst, const wchar_t *src, size_t maxlen); +extern DECLSPEC size_t SDLCALL SDL_wcslcat(wchar_t *dst, const wchar_t *src, size_t maxlen); + +extern DECLSPEC size_t SDLCALL SDL_strlen(const char *str); +extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src, size_t maxlen); +extern DECLSPEC size_t SDLCALL SDL_utf8strlcpy(char *dst, const char *src, size_t dst_bytes); +extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src, size_t maxlen); +extern DECLSPEC char *SDLCALL SDL_strdup(const char *str); +extern DECLSPEC char *SDLCALL SDL_strrev(char *str); +extern DECLSPEC char *SDLCALL SDL_strupr(char *str); +extern DECLSPEC char *SDLCALL SDL_strlwr(char *str); +extern DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c); +extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c); +extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle); + +extern DECLSPEC char *SDLCALL SDL_itoa(int value, char *str, int radix); +extern DECLSPEC char *SDLCALL SDL_uitoa(unsigned int value, char *str, int radix); +extern DECLSPEC char *SDLCALL SDL_ltoa(long value, char *str, int radix); +extern DECLSPEC char *SDLCALL SDL_ultoa(unsigned long value, char *str, int radix); +extern DECLSPEC char *SDLCALL SDL_lltoa(Sint64 value, char *str, int radix); +extern DECLSPEC char *SDLCALL SDL_ulltoa(Uint64 value, char *str, int radix); + +extern DECLSPEC int SDLCALL SDL_atoi(const char *str); +extern DECLSPEC double SDLCALL SDL_atof(const char *str); +extern DECLSPEC long SDLCALL SDL_strtol(const char *str, char **endp, int base); +extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *str, char **endp, int base); +extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *str, char **endp, int base); +extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *str, char **endp, int base); +extern DECLSPEC double SDLCALL SDL_strtod(const char *str, char **endp); + +extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2); +extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen); +extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2); +extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t len); + +extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...); +extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...); +extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap); + +#ifndef HAVE_M_PI +#ifndef M_PI +#define M_PI 3.14159265358979323846264338327950288 /* pi */ +#endif +#endif + +extern DECLSPEC double SDLCALL SDL_atan(double x); +extern DECLSPEC double SDLCALL SDL_atan2(double x, double y); +extern DECLSPEC double SDLCALL SDL_ceil(double x); +extern DECLSPEC double SDLCALL SDL_copysign(double x, double y); +extern DECLSPEC double SDLCALL SDL_cos(double x); +extern DECLSPEC float SDLCALL SDL_cosf(float x); +extern DECLSPEC double SDLCALL SDL_fabs(double x); +extern DECLSPEC double SDLCALL SDL_floor(double x); +extern DECLSPEC double SDLCALL SDL_log(double x); +extern DECLSPEC double SDLCALL SDL_pow(double x, double y); +extern DECLSPEC double SDLCALL SDL_scalbn(double x, int n); +extern DECLSPEC double SDLCALL SDL_sin(double x); +extern DECLSPEC float SDLCALL SDL_sinf(float x); +extern DECLSPEC double SDLCALL SDL_sqrt(double x); + +/* The SDL implementation of iconv() returns these error codes */ +#define SDL_ICONV_ERROR (size_t)-1 +#define SDL_ICONV_E2BIG (size_t)-2 +#define SDL_ICONV_EILSEQ (size_t)-3 +#define SDL_ICONV_EINVAL (size_t)-4 + +/* SDL_iconv_* are now always real symbols/types, not macros or inlined. */ +typedef struct _SDL_iconv_t *SDL_iconv_t; +extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode, + const char *fromcode); +extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd); +extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf, + size_t * inbytesleft, char **outbuf, + size_t * outbytesleft); +/** + * This function converts a string between encodings in one pass, returning a + * string that must be freed with SDL_free() or NULL on error. + */ +extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode, + const char *fromcode, + const char *inbuf, + size_t inbytesleft); +#define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1) +#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", S, SDL_strlen(S)+1) +#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4-INTERNAL", "UTF-8", S, SDL_strlen(S)+1) + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_stdinc_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_surface.h spring-98.0~14.04~ppa6/include/SDL2/SDL_surface.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_surface.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_surface.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,503 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_surface.h + * + * Header file for ::SDL_Surface definition and management functions. + */ + +#ifndef _SDL_surface_h +#define _SDL_surface_h + +#include "SDL_stdinc.h" +#include "SDL_pixels.h" +#include "SDL_rect.h" +#include "SDL_blendmode.h" +#include "SDL_rwops.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \name Surface flags + * + * These are the currently supported flags for the ::SDL_Surface. + * + * \internal + * Used internally (read-only). + */ +/* @{ */ +#define SDL_SWSURFACE 0 /**< Just here for compatibility */ +#define SDL_PREALLOC 0x00000001 /**< Surface uses preallocated memory */ +#define SDL_RLEACCEL 0x00000002 /**< Surface is RLE encoded */ +#define SDL_DONTFREE 0x00000004 /**< Surface is referenced internally */ +/* @} *//* Surface flags */ + +/** + * Evaluates to true if the surface needs to be locked before access. + */ +#define SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0) + +/** + * \brief A collection of pixels used in software blitting. + * + * \note This structure should be treated as read-only, except for \c pixels, + * which, if not NULL, contains the raw pixel data for the surface. + */ +typedef struct SDL_Surface +{ + Uint32 flags; /**< Read-only */ + SDL_PixelFormat *format; /**< Read-only */ + int w, h; /**< Read-only */ + int pitch; /**< Read-only */ + void *pixels; /**< Read-write */ + + /** Application data associated with the surface */ + void *userdata; /**< Read-write */ + + /** information needed for surfaces requiring locks */ + int locked; /**< Read-only */ + void *lock_data; /**< Read-only */ + + /** clipping information */ + SDL_Rect clip_rect; /**< Read-only */ + + /** info for fast blit mapping to other surfaces */ + struct SDL_BlitMap *map; /**< Private */ + + /** Reference count -- used when freeing surface */ + int refcount; /**< Read-mostly */ +} SDL_Surface; + +/** + * \brief The type of function used for surface blitting functions. + */ +typedef int (*SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect, + struct SDL_Surface * dst, SDL_Rect * dstrect); + +/** + * Allocate and free an RGB surface. + * + * If the depth is 4 or 8 bits, an empty palette is allocated for the surface. + * If the depth is greater than 8 bits, the pixel format is set using the + * flags '[RGB]mask'. + * + * If the function runs out of memory, it will return NULL. + * + * \param flags The \c flags are obsolete and should be set to 0. + * \param width The width in pixels of the surface to create. + * \param height The height in pixels of the surface to create. + * \param depth The depth in bits of the surface to create. + * \param Rmask The red mask of the surface to create. + * \param Gmask The green mask of the surface to create. + * \param Bmask The blue mask of the surface to create. + * \param Amask The alpha mask of the surface to create. + */ +extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface + (Uint32 flags, int width, int height, int depth, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); +extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, + int width, + int height, + int depth, + int pitch, + Uint32 Rmask, + Uint32 Gmask, + Uint32 Bmask, + Uint32 Amask); +extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface); + +/** + * \brief Set the palette used by a surface. + * + * \return 0, or -1 if the surface format doesn't use a palette. + * + * \note A single palette can be shared with many surfaces. + */ +extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface * surface, + SDL_Palette * palette); + +/** + * \brief Sets up a surface for directly accessing the pixels. + * + * Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write + * to and read from \c surface->pixels, using the pixel format stored in + * \c surface->format. Once you are done accessing the surface, you should + * use SDL_UnlockSurface() to release it. + * + * Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates + * to 0, then you can read and write to the surface at any time, and the + * pixel format of the surface will not change. + * + * No operating system or library calls should be made between lock/unlock + * pairs, as critical system locks may be held during this time. + * + * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked. + * + * \sa SDL_UnlockSurface() + */ +extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface * surface); +/** \sa SDL_LockSurface() */ +extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface); + +/** + * Load a surface from a seekable SDL data stream (memory or file). + * + * If \c freesrc is non-zero, the stream will be closed after being read. + * + * The new surface should be freed with SDL_FreeSurface(). + * + * \return the new surface, or NULL if there was an error. + */ +extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src, + int freesrc); + +/** + * Load a surface from a file. + * + * Convenience macro. + */ +#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1) + +/** + * Save a surface to a seekable SDL data stream (memory or file). + * + * If \c freedst is non-zero, the stream will be closed after being written. + * + * \return 0 if successful or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_SaveBMP_RW + (SDL_Surface * surface, SDL_RWops * dst, int freedst); + +/** + * Save a surface to a file. + * + * Convenience macro. + */ +#define SDL_SaveBMP(surface, file) \ + SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1) + +/** + * \brief Sets the RLE acceleration hint for a surface. + * + * \return 0 on success, or -1 if the surface is not valid + * + * \note If RLE is enabled, colorkey and alpha blending blits are much faster, + * but the surface must be locked before directly accessing the pixels. + */ +extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface, + int flag); + +/** + * \brief Sets the color key (transparent pixel) in a blittable surface. + * + * \param surface The surface to update + * \param flag Non-zero to enable colorkey and 0 to disable colorkey + * \param key The transparent pixel in the native surface format + * + * \return 0 on success, or -1 if the surface is not valid + * + * You can pass SDL_RLEACCEL to enable RLE accelerated blits. + */ +extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface, + int flag, Uint32 key); + +/** + * \brief Gets the color key (transparent pixel) in a blittable surface. + * + * \param surface The surface to update + * \param key A pointer filled in with the transparent pixel in the native + * surface format + * + * \return 0 on success, or -1 if the surface is not valid or colorkey is not + * enabled. + */ +extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface, + Uint32 * key); + +/** + * \brief Set an additional color value used in blit operations. + * + * \param surface The surface to update. + * \param r The red color value multiplied into blit operations. + * \param g The green color value multiplied into blit operations. + * \param b The blue color value multiplied into blit operations. + * + * \return 0 on success, or -1 if the surface is not valid. + * + * \sa SDL_GetSurfaceColorMod() + */ +extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface, + Uint8 r, Uint8 g, Uint8 b); + + +/** + * \brief Get the additional color value used in blit operations. + * + * \param surface The surface to query. + * \param r A pointer filled in with the current red color value. + * \param g A pointer filled in with the current green color value. + * \param b A pointer filled in with the current blue color value. + * + * \return 0 on success, or -1 if the surface is not valid. + * + * \sa SDL_SetSurfaceColorMod() + */ +extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface, + Uint8 * r, Uint8 * g, + Uint8 * b); + +/** + * \brief Set an additional alpha value used in blit operations. + * + * \param surface The surface to update. + * \param alpha The alpha value multiplied into blit operations. + * + * \return 0 on success, or -1 if the surface is not valid. + * + * \sa SDL_GetSurfaceAlphaMod() + */ +extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface, + Uint8 alpha); + +/** + * \brief Get the additional alpha value used in blit operations. + * + * \param surface The surface to query. + * \param alpha A pointer filled in with the current alpha value. + * + * \return 0 on success, or -1 if the surface is not valid. + * + * \sa SDL_SetSurfaceAlphaMod() + */ +extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface, + Uint8 * alpha); + +/** + * \brief Set the blend mode used for blit operations. + * + * \param surface The surface to update. + * \param blendMode ::SDL_BlendMode to use for blit blending. + * + * \return 0 on success, or -1 if the parameters are not valid. + * + * \sa SDL_GetSurfaceBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface, + SDL_BlendMode blendMode); + +/** + * \brief Get the blend mode used for blit operations. + * + * \param surface The surface to query. + * \param blendMode A pointer filled in with the current blend mode. + * + * \return 0 on success, or -1 if the surface is not valid. + * + * \sa SDL_SetSurfaceBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface, + SDL_BlendMode *blendMode); + +/** + * Sets the clipping rectangle for the destination surface in a blit. + * + * If the clip rectangle is NULL, clipping will be disabled. + * + * If the clip rectangle doesn't intersect the surface, the function will + * return SDL_FALSE and blits will be completely clipped. Otherwise the + * function returns SDL_TRUE and blits to the surface will be clipped to + * the intersection of the surface area and the clipping rectangle. + * + * Note that blits are automatically clipped to the edges of the source + * and destination surfaces. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface, + const SDL_Rect * rect); + +/** + * Gets the clipping rectangle for the destination surface in a blit. + * + * \c rect must be a pointer to a valid rectangle which will be filled + * with the correct values. + */ +extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface, + SDL_Rect * rect); + +/** + * Creates a new surface of the specified format, and then copies and maps + * the given surface to it so the blit of the converted surface will be as + * fast as possible. If this function fails, it returns NULL. + * + * The \c flags parameter is passed to SDL_CreateRGBSurface() and has those + * semantics. You can also pass ::SDL_RLEACCEL in the flags parameter and + * SDL will try to RLE accelerate colorkey and alpha blits in the resulting + * surface. + */ +extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface + (SDL_Surface * src, const SDL_PixelFormat * fmt, Uint32 flags); +extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat + (SDL_Surface * src, Uint32 pixel_format, Uint32 flags); + +/** + * \brief Copy a block of pixels of one format to another format + * + * \return 0 on success, or -1 if there was an error + */ +extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height, + Uint32 src_format, + const void * src, int src_pitch, + Uint32 dst_format, + void * dst, int dst_pitch); + +/** + * Performs a fast fill of the given rectangle with \c color. + * + * If \c rect is NULL, the whole surface will be filled with \c color. + * + * The color should be a pixel of the format used by the surface, and + * can be generated by the SDL_MapRGB() function. + * + * \return 0 on success, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_FillRect + (SDL_Surface * dst, const SDL_Rect * rect, Uint32 color); +extern DECLSPEC int SDLCALL SDL_FillRects + (SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color); + +/** + * Performs a fast blit from the source surface to the destination surface. + * + * This assumes that the source and destination rectangles are + * the same size. If either \c srcrect or \c dstrect are NULL, the entire + * surface (\c src or \c dst) is copied. The final blit rectangles are saved + * in \c srcrect and \c dstrect after all clipping is performed. + * + * \return If the blit is successful, it returns 0, otherwise it returns -1. + * + * The blit function should not be called on a locked surface. + * + * The blit semantics for surfaces with and without blending and colorkey + * are defined as follows: + * \verbatim + RGBA->RGB: + Source surface blend mode set to SDL_BLENDMODE_BLEND: + alpha-blend (using the source alpha-channel and per-surface alpha) + SDL_SRCCOLORKEY ignored. + Source surface blend mode set to SDL_BLENDMODE_NONE: + copy RGB. + if SDL_SRCCOLORKEY set, only copy the pixels matching the + RGB values of the source color key, ignoring alpha in the + comparison. + + RGB->RGBA: + Source surface blend mode set to SDL_BLENDMODE_BLEND: + alpha-blend (using the source per-surface alpha) + Source surface blend mode set to SDL_BLENDMODE_NONE: + copy RGB, set destination alpha to source per-surface alpha value. + both: + if SDL_SRCCOLORKEY set, only copy the pixels matching the + source color key. + + RGBA->RGBA: + Source surface blend mode set to SDL_BLENDMODE_BLEND: + alpha-blend (using the source alpha-channel and per-surface alpha) + SDL_SRCCOLORKEY ignored. + Source surface blend mode set to SDL_BLENDMODE_NONE: + copy all of RGBA to the destination. + if SDL_SRCCOLORKEY set, only copy the pixels matching the + RGB values of the source color key, ignoring alpha in the + comparison. + + RGB->RGB: + Source surface blend mode set to SDL_BLENDMODE_BLEND: + alpha-blend (using the source per-surface alpha) + Source surface blend mode set to SDL_BLENDMODE_NONE: + copy RGB. + both: + if SDL_SRCCOLORKEY set, only copy the pixels matching the + source color key. + \endverbatim + * + * You should call SDL_BlitSurface() unless you know exactly how SDL + * blitting works internally and how to use the other blit functions. + */ +#define SDL_BlitSurface SDL_UpperBlit + +/** + * This is the public blit function, SDL_BlitSurface(), and it performs + * rectangle validation and clipping before passing it to SDL_LowerBlit() + */ +extern DECLSPEC int SDLCALL SDL_UpperBlit + (SDL_Surface * src, const SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); + +/** + * This is a semi-private blit function and it performs low-level surface + * blitting only. + */ +extern DECLSPEC int SDLCALL SDL_LowerBlit + (SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); + +/** + * \brief Perform a fast, low quality, stretch blit between two surfaces of the + * same pixel format. + * + * \note This function uses a static buffer, and is not thread-safe. + */ +extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src, + const SDL_Rect * srcrect, + SDL_Surface * dst, + const SDL_Rect * dstrect); + +#define SDL_BlitScaled SDL_UpperBlitScaled + +/** + * This is the public scaled blit function, SDL_BlitScaled(), and it performs + * rectangle validation and clipping before passing it to SDL_LowerBlitScaled() + */ +extern DECLSPEC int SDLCALL SDL_UpperBlitScaled + (SDL_Surface * src, const SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); + +/** + * This is a semi-private blit function and it performs low-level surface + * scaled blitting only. + */ +extern DECLSPEC int SDLCALL SDL_LowerBlitScaled + (SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_surface_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_system.h spring-98.0~14.04~ppa6/include/SDL2/SDL_system.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_system.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_system.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,121 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_system.h + * + * Include file for platform specific SDL API functions + */ + +#ifndef _SDL_system_h +#define _SDL_system_h + +#include "SDL_stdinc.h" +#include "SDL_keyboard.h" +#include "SDL_render.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + + +/* Platform specific functions for Windows */ +#ifdef __WIN32__ + +/* Returns the D3D9 adapter index that matches the specified display index. + This adapter index can be passed to IDirect3D9::CreateDevice and controls + on which monitor a full screen application will appear. +*/ +extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex( int displayIndex ); + +/* Returns the D3D device associated with a renderer, or NULL if it's not a D3D renderer. + Once you are done using the device, you should release it to avoid a resource leak. + */ +typedef struct IDirect3DDevice9 IDirect3DDevice9; +extern DECLSPEC IDirect3DDevice9* SDLCALL SDL_RenderGetD3D9Device(SDL_Renderer * renderer); + +#endif /* __WIN32__ */ + + +/* Platform specific functions for iOS */ +#if defined(__IPHONEOS__) && __IPHONEOS__ + +extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam); +extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled); + +#endif /* __IPHONEOS__ */ + + +/* Platform specific functions for Android */ +#if defined(__ANDROID__) && __ANDROID__ + +/* Get the JNI environment for the current thread + This returns JNIEnv*, but the prototype is void* so we don't need jni.h + */ +extern DECLSPEC void * SDLCALL SDL_AndroidGetJNIEnv(); + +/* Get the SDL Activity object for the application + This returns jobject, but the prototype is void* so we don't need jni.h + The jobject returned by SDL_AndroidGetActivity is a local reference. + It is the caller's responsibility to properly release it + (using env->Push/PopLocalFrame or manually with env->DeleteLocalRef) + */ +extern DECLSPEC void * SDLCALL SDL_AndroidGetActivity(); + +/* See the official Android developer guide for more information: + http://developer.android.com/guide/topics/data/data-storage.html +*/ +#define SDL_ANDROID_EXTERNAL_STORAGE_READ 0x01 +#define SDL_ANDROID_EXTERNAL_STORAGE_WRITE 0x02 + +/* Get the path used for internal storage for this application. + This path is unique to your application and cannot be written to + by other applications. + */ +extern DECLSPEC const char * SDLCALL SDL_AndroidGetInternalStoragePath(); + +/* Get the current state of external storage, a bitmask of these values: + SDL_ANDROID_EXTERNAL_STORAGE_READ + SDL_ANDROID_EXTERNAL_STORAGE_WRITE + If external storage is currently unavailable, this will return 0. +*/ +extern DECLSPEC int SDLCALL SDL_AndroidGetExternalStorageState(); + +/* Get the path used for external storage for this application. + This path is unique to your application, but is public and can be + written to by other applications. + */ +extern DECLSPEC const char * SDLCALL SDL_AndroidGetExternalStoragePath(); + +#endif /* __ANDROID__ */ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_system_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_syswm.h spring-98.0~14.04~ppa6/include/SDL2/SDL_syswm.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_syswm.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_syswm.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,237 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_syswm.h + * + * Include file for SDL custom system window manager hooks. + */ + +#ifndef _SDL_syswm_h +#define _SDL_syswm_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_video.h" +#include "SDL_version.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \file SDL_syswm.h + * + * Your application has access to a special type of event ::SDL_SYSWMEVENT, + * which contains window-manager specific information and arrives whenever + * an unhandled window event occurs. This event is ignored by default, but + * you can enable it with SDL_EventState(). + */ +#ifdef SDL_PROTOTYPES_ONLY +struct SDL_SysWMinfo; +#else + +#if defined(SDL_VIDEO_DRIVER_WINDOWS) +#define WIN32_LEAN_AND_MEAN +#include +#endif + +/* This is the structure for custom window manager events */ +#if defined(SDL_VIDEO_DRIVER_X11) +#if defined(__APPLE__) && defined(__MACH__) +/* conflicts with Quickdraw.h */ +#define Cursor X11Cursor +#endif + +#include +#include + +#if defined(__APPLE__) && defined(__MACH__) +/* matches the re-define above */ +#undef Cursor +#endif + +#endif /* defined(SDL_VIDEO_DRIVER_X11) */ + +#if defined(SDL_VIDEO_DRIVER_DIRECTFB) +#include +#endif + +#if defined(SDL_VIDEO_DRIVER_COCOA) +#ifdef __OBJC__ +#include +#else +typedef struct _NSWindow NSWindow; +#endif +#endif + +#if defined(SDL_VIDEO_DRIVER_UIKIT) +#ifdef __OBJC__ +#include +#else +typedef struct _UIWindow UIWindow; +#endif +#endif + +/** + * These are the various supported windowing subsystems + */ +typedef enum +{ + SDL_SYSWM_UNKNOWN, + SDL_SYSWM_WINDOWS, + SDL_SYSWM_X11, + SDL_SYSWM_DIRECTFB, + SDL_SYSWM_COCOA, + SDL_SYSWM_UIKIT, +} SDL_SYSWM_TYPE; + +/** + * The custom event structure. + */ +struct SDL_SysWMmsg +{ + SDL_version version; + SDL_SYSWM_TYPE subsystem; + union + { +#if defined(SDL_VIDEO_DRIVER_WINDOWS) + struct { + HWND hwnd; /**< The window for the message */ + UINT msg; /**< The type of message */ + WPARAM wParam; /**< WORD message parameter */ + LPARAM lParam; /**< LONG message parameter */ + } win; +#endif +#if defined(SDL_VIDEO_DRIVER_X11) + struct { + XEvent event; + } x11; +#endif +#if defined(SDL_VIDEO_DRIVER_DIRECTFB) + struct { + DFBEvent event; + } dfb; +#endif +#if defined(SDL_VIDEO_DRIVER_COCOA) + struct + { + /* No Cocoa window events yet */ + } cocoa; +#endif +#if defined(SDL_VIDEO_DRIVER_UIKIT) + struct + { + /* No UIKit window events yet */ + } uikit; +#endif + /* Can't have an empty union */ + int dummy; + } msg; +}; + +/** + * The custom window manager information structure. + * + * When this structure is returned, it holds information about which + * low level system it is using, and will be one of SDL_SYSWM_TYPE. + */ +struct SDL_SysWMinfo +{ + SDL_version version; + SDL_SYSWM_TYPE subsystem; + union + { +#if defined(SDL_VIDEO_DRIVER_WINDOWS) + struct + { + HWND window; /**< The window handle */ + } win; +#endif +#if defined(SDL_VIDEO_DRIVER_X11) + struct + { + Display *display; /**< The X11 display */ + Window window; /**< The X11 window */ + } x11; +#endif +#if defined(SDL_VIDEO_DRIVER_DIRECTFB) + struct + { + IDirectFB *dfb; /**< The directfb main interface */ + IDirectFBWindow *window; /**< The directfb window handle */ + IDirectFBSurface *surface; /**< The directfb client surface */ + } dfb; +#endif +#if defined(SDL_VIDEO_DRIVER_COCOA) + struct + { + NSWindow *window; /* The Cocoa window */ + } cocoa; +#endif +#if defined(SDL_VIDEO_DRIVER_UIKIT) + struct + { + UIWindow *window; /* The UIKit window */ + } uikit; +#endif + /* Can't have an empty union */ + int dummy; + } info; +}; + +#endif /* SDL_PROTOTYPES_ONLY */ + +typedef struct SDL_SysWMinfo SDL_SysWMinfo; + +/* Function prototypes */ +/** + * \brief This function allows access to driver-dependent window information. + * + * \param window The window about which information is being requested + * \param info This structure must be initialized with the SDL version, and is + * then filled in with information about the given window. + * + * \return SDL_TRUE if the function is implemented and the version member of + * the \c info struct is valid, SDL_FALSE otherwise. + * + * You typically use this function like this: + * \code + * SDL_SysWMinfo info; + * SDL_VERSION(&info.version); + * if ( SDL_GetWindowWMInfo(window, &info) ) { ... } + * \endcode + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window, + SDL_SysWMinfo * info); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_syswm_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_test_assert.h spring-98.0~14.04~ppa6/include/SDL2/SDL_test_assert.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_test_assert.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_test_assert.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,105 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_test_assert.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + * + * Assert API for test code and test cases + * + */ + +#ifndef _SDL_test_assert_h +#define _SDL_test_assert_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Fails the assert. + */ +#define ASSERT_FAIL 0 + +/** + * \brief Passes the assert. + */ +#define ASSERT_PASS 1 + +/** + * \brief Assert that logs and break execution flow on failures. + * + * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0). + * \param assertDescription Message to log with the assert describing it. + */ +void SDLTest_Assert(int assertCondition, const char *assertDescription, ...); + +/** + * \brief Assert for test cases that logs but does not break execution flow on failures. Updates assertion counters. + * + * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0). + * \param assertDescription Message to log with the assert describing it. + * + * \returns Returns the assertCondition so it can be used to externally to break execution flow if desired. + */ +int SDLTest_AssertCheck(int assertCondition, const char *assertDescription, ...); + +/** + * \brief Explicitely pass without checking an assertion condition. Updates assertion counter. + * + * \param assertDescription Message to log with the assert describing it. + */ +void SDLTest_AssertPass(const char *assertDescription, ...); + +/** + * \brief Resets the assert summary counters to zero. + */ +void SDLTest_ResetAssertSummary(); + +/** + * \brief Logs summary of all assertions (total, pass, fail) since last reset as INFO or ERROR. + */ +void SDLTest_LogAssertSummary(); + + +/** + * \brief Converts the current assert summary state to a test result. + * + * \returns TEST_RESULT_PASSED, TEST_RESULT_FAILED, or TEST_RESULT_NO_ASSERT + */ +int SDLTest_AssertSummaryToTestResult(); + +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_assert_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_test_common.h spring-98.0~14.04~ppa6/include/SDL2/SDL_test_common.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_test_common.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_test_common.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,187 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_test_common.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* Ported from original test\common.h file. */ + +#ifndef _SDL_test_common_h +#define _SDL_test_common_h + +#include "SDL.h" + +#if defined(__PSP__) +#define DEFAULT_WINDOW_WIDTH 480 +#define DEFAULT_WINDOW_HEIGHT 272 +#else +#define DEFAULT_WINDOW_WIDTH 640 +#define DEFAULT_WINDOW_HEIGHT 480 +#endif + +#define VERBOSE_VIDEO 0x00000001 +#define VERBOSE_MODES 0x00000002 +#define VERBOSE_RENDER 0x00000004 +#define VERBOSE_EVENT 0x00000008 +#define VERBOSE_AUDIO 0x00000010 + +typedef struct +{ + /* SDL init flags */ + char **argv; + Uint32 flags; + Uint32 verbose; + + /* Video info */ + const char *videodriver; + int display; + const char *window_title; + const char *window_icon; + Uint32 window_flags; + int window_x; + int window_y; + int window_w; + int window_h; + int window_minW; + int window_minH; + int window_maxW; + int window_maxH; + int logical_w; + int logical_h; + float scale; + int depth; + int refresh_rate; + int num_windows; + SDL_Window **windows; + + /* Renderer info */ + const char *renderdriver; + Uint32 render_flags; + SDL_bool skip_renderer; + SDL_Renderer **renderers; + + /* Audio info */ + const char *audiodriver; + SDL_AudioSpec audiospec; + + /* GL settings */ + int gl_red_size; + int gl_green_size; + int gl_blue_size; + int gl_alpha_size; + int gl_buffer_size; + int gl_depth_size; + int gl_stencil_size; + int gl_double_buffer; + int gl_accum_red_size; + int gl_accum_green_size; + int gl_accum_blue_size; + int gl_accum_alpha_size; + int gl_stereo; + int gl_multisamplebuffers; + int gl_multisamplesamples; + int gl_retained_backing; + int gl_accelerated; + int gl_major_version; + int gl_minor_version; + int gl_debug; + int gl_profile_mask; +} SDLTest_CommonState; + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Function prototypes */ + +/** + * \brief Parse command line parameters and create common state. + * + * \param argv Array of command line parameters + * \param flags Flags indicating which subsystem to initialize (i.e. SDL_INIT_VIDEO | SDL_INIT_AUDIO) + * + * \returns Returns a newly allocated common state object. + */ +SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags); + +/** + * \brief Process one common argument. + * + * \param state The common state describing the test window to create. + * \param index The index of the argument to process in argv[]. + * + * \returns The number of arguments processed (i.e. 1 for --fullscreen, 2 for --video [videodriver], or -1 on error. + */ +int SDLTest_CommonArg(SDLTest_CommonState * state, int index); + +/** + * \brief Returns common usage information + * + * \param state The common state describing the test window to create. + * + * \returns String with usage information + */ +const char *SDLTest_CommonUsage(SDLTest_CommonState * state); + +/** + * \brief Open test window. + * + * \param state The common state describing the test window to create. + * + * \returns True if initialization succeeded, false otherwise + */ +SDL_bool SDLTest_CommonInit(SDLTest_CommonState * state); + +/** + * \brief Common event handler for test windows. + * + * \param state The common state used to create test window. + * \param event The event to handle. + * \param done Flag indicating we are done. + * + */ +void SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done); + +/** + * \brief Close test window. + * + * \param state The common state used to create test window. + * + */ +void SDLTest_CommonQuit(SDLTest_CommonState * state); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_common_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_test_compare.h spring-98.0~14.04~ppa6/include/SDL2/SDL_test_compare.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_test_compare.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_test_compare.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,69 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_test_compare.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + + Defines comparison functions (i.e. for surfaces). + +*/ + +#ifndef _SDL_test_compare_h +#define _SDL_test_compare_h + +#include "SDL.h" + +#include "SDL_test_images.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Compares a surface and with reference image data for equality + * + * \param surface Surface used in comparison + * \param referenceSurface Test Surface used in comparison + * \param allowable_error Allowable difference (squared) in blending accuracy. + * + * \returns 0 if comparison succeeded, >0 (=number of pixels where comparison failed) if comparison failed, -1 if any of the surfaces were NULL, -2 if the surface sizes differ. + */ +int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_compare_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_test_crc32.h spring-98.0~14.04~ppa6/include/SDL2/SDL_test_crc32.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_test_crc32.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_test_crc32.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,124 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_test_crc32.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + + Implements CRC32 calculations (default output is Perl String::CRC32 compatible). + +*/ + +#ifndef _SDL_test_crc32_h +#define _SDL_test_crc32_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + + +/* ------------ Definitions --------- */ + +/* Definition shared by all CRC routines */ + +#ifndef CrcUint32 + #define CrcUint32 unsigned int +#endif +#ifndef CrcUint8 + #define CrcUint8 unsigned char +#endif + +#ifdef ORIGINAL_METHOD + #define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */ +#else + #define CRC32_POLY 0xEDB88320 /* Perl String::CRC32 compatible */ +#endif + +/** + * Data structure for CRC32 (checksum) computation + */ + typedef struct { + CrcUint32 crc32_table[256]; /* CRC table */ + } SDLTest_Crc32Context; + +/* ---------- Function Prototypes ------------- */ + +/** + * /brief Initialize the CRC context + * + * Note: The function initializes the crc table required for all crc calculations. + * + * /param crcContext pointer to context variable + * + * /returns 0 for OK, -1 on error + * + */ + int SDLTest_Crc32Init(SDLTest_Crc32Context * crcContext); + + +/** + * /brief calculate a crc32 from a data block + * + * /param crcContext pointer to context variable + * /param inBuf input buffer to checksum + * /param inLen length of input buffer + * /param crc32 pointer to Uint32 to store the final CRC into + * + * /returns 0 for OK, -1 on error + * + */ +int SDLTest_crc32Calc(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32); + +/* Same routine broken down into three steps */ +int SDLTest_Crc32CalcStart(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32); +int SDLTest_Crc32CalcEnd(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32); +int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32); + + +/** + * /brief clean up CRC context + * + * /param crcContext pointer to context variable + * + * /returns 0 for OK, -1 on error + * +*/ + +int SDLTest_Crc32Done(SDLTest_Crc32Context * crcContext); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_crc32_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_test_font.h spring-98.0~14.04~ppa6/include/SDL2/SDL_test_font.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_test_font.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_test_font.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,62 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_test_font.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +#ifndef _SDL_test_font_h +#define _SDL_test_font_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Function prototypes */ + +/** + * \brief Draw a string in the currently set font. + * + * \param renderer The renderer to draw on. + * \param x The X coordinate of the upper left corner of the string. + * \param y The Y coordinate of the upper left corner of the string. + * \param s The string to draw. + * + * \returns Returns 0 on success, -1 on failure. + */ +int SDLTest_DrawString(SDL_Renderer * renderer, int x, int y, const char *s); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_font_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_test_fuzzer.h spring-98.0~14.04~ppa6/include/SDL2/SDL_test_fuzzer.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_test_fuzzer.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_test_fuzzer.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,384 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_test_fuzzer.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + + Data generators for fuzzing test data in a reproducible way. + +*/ + +#ifndef _SDL_test_fuzzer_h +#define _SDL_test_fuzzer_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + + +/* + Based on GSOC code by Markus Kauppila +*/ + + +/** + * \file + * Note: The fuzzer implementation uses a static instance of random context + * internally which makes it thread-UNsafe. + */ + +/** + * Initializes the fuzzer for a test + * + * /param execKey Execution "Key" that initializes the random number generator uniquely for the test. + * + */ +void SDLTest_FuzzerInit(Uint64 execKey); + + +/** + * Returns a random Uint8 + * + * \returns Generated integer + */ +Uint8 SDLTest_RandomUint8(); + +/** + * Returns a random Sint8 + * + * \returns Generated signed integer + */ +Sint8 SDLTest_RandomSint8(); + + +/** + * Returns a random Uint16 + * + * \returns Generated integer + */ +Uint16 SDLTest_RandomUint16(); + +/** + * Returns a random Sint16 + * + * \returns Generated signed integer + */ +Sint16 SDLTest_RandomSint16(); + + +/** + * Returns a random integer + * + * \returns Generated integer + */ +Sint32 SDLTest_RandomSint32(); + + +/** + * Returns a random positive integer + * + * \returns Generated integer + */ +Uint32 SDLTest_RandomUint32(); + +/** + * Returns random Uint64. + * + * \returns Generated integer + */ +Uint64 SDLTest_RandomUint64(); + + +/** + * Returns random Sint64. + * + * \returns Generated signed integer + */ +Sint64 SDLTest_RandomSint64(); + +/** + * \returns random float in range [0.0 - 1.0[ + */ +float SDLTest_RandomUnitFloat(); + +/** + * \returns random double in range [0.0 - 1.0[ + */ +double SDLTest_RandomUnitDouble(); + +/** + * \returns random float. + * + */ +float SDLTest_RandomFloat(); + +/** + * \returns random double. + * + */ +double SDLTest_RandomDouble(); + +/** + * Returns a random boundary value for Uint8 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomUint8BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 + * RandomUint8BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21 + * RandomUint8BoundaryValue(0, 99, SDL_FALSE) returns 100 + * RandomUint8BoundaryValue(0, 255, SDL_FALSE) returns 0 (error set) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or 0 with error set + */ +Uint8 SDLTest_RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain); + +/** + * Returns a random boundary value for Uint16 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomUint16BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 + * RandomUint16BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21 + * RandomUint16BoundaryValue(0, 99, SDL_FALSE) returns 100 + * RandomUint16BoundaryValue(0, 0xFFFF, SDL_FALSE) returns 0 (error set) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or 0 with error set + */ +Uint16 SDLTest_RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL_bool validDomain); + +/** + * Returns a random boundary value for Uint32 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomUint32BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 + * RandomUint32BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21 + * RandomUint32BoundaryValue(0, 99, SDL_FALSE) returns 100 + * RandomUint32BoundaryValue(0, 0xFFFFFFFF, SDL_FALSE) returns 0 (with error set) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or 0 with error set + */ +Uint32 SDLTest_RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL_bool validDomain); + +/** + * Returns a random boundary value for Uint64 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomUint64BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 + * RandomUint64BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21 + * RandomUint64BoundaryValue(0, 99, SDL_FALSE) returns 100 + * RandomUint64BoundaryValue(0, 0xFFFFFFFFFFFFFFFF, SDL_FALSE) returns 0 (with error set) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or 0 with error set + */ +Uint64 SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDomain); + +/** + * Returns a random boundary value for Sint8 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomSint8BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20 + * RandomSint8BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9 + * RandomSint8BoundaryValue(SINT8_MIN, 99, SDL_FALSE) returns 100 + * RandomSint8BoundaryValue(SINT8_MIN, SINT8_MAX, SDL_FALSE) returns SINT8_MIN (== error value) with error set + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or SINT8_MIN with error set + */ +Sint8 SDLTest_RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, SDL_bool validDomain); + + +/** + * Returns a random boundary value for Sint16 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomSint16BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20 + * RandomSint16BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9 + * RandomSint16BoundaryValue(SINT16_MIN, 99, SDL_FALSE) returns 100 + * RandomSint16BoundaryValue(SINT16_MIN, SINT16_MAX, SDL_FALSE) returns SINT16_MIN (== error value) with error set + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or SINT16_MIN with error set + */ +Sint16 SDLTest_RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL_bool validDomain); + +/** + * Returns a random boundary value for Sint32 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomSint32BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20 + * RandomSint32BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9 + * RandomSint32BoundaryValue(SINT32_MIN, 99, SDL_FALSE) returns 100 + * RandomSint32BoundaryValue(SINT32_MIN, SINT32_MAX, SDL_FALSE) returns SINT32_MIN (== error value) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or SINT32_MIN with error set + */ +Sint32 SDLTest_RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL_bool validDomain); + +/** + * Returns a random boundary value for Sint64 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomSint64BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20 + * RandomSint64BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9 + * RandomSint64BoundaryValue(SINT64_MIN, 99, SDL_FALSE) returns 100 + * RandomSint64BoundaryValue(SINT64_MIN, SINT64_MAX, SDL_FALSE) returns SINT64_MIN (== error value) and error set + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or SINT64_MIN with error set + */ +Sint64 SDLTest_RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDomain); + + +/** + * Returns integer in range [min, max] (inclusive). + * Min and max values can be negative values. + * If Max in smaller tham min, then the values are swapped. + * Min and max are the same value, that value will be returned. + * + * \param min Minimum inclusive value of returned random number + * \param max Maximum inclusive value of returned random number + * + * \returns Generated random integer in range + */ +Sint32 SDLTest_RandomIntegerInRange(Sint32 min, Sint32 max); + + +/** + * Generates random null-terminated string. The minimum length for + * the string is 1 character, maximum length for the string is 255 + * characters and it can contain ASCII characters from 32 to 126. + * + * Note: Returned string needs to be deallocated. + * + * \returns Newly allocated random string; or NULL if length was invalid or string could not be allocated. + */ +char * SDLTest_RandomAsciiString(); + + +/** + * Generates random null-terminated string. The maximum length for + * the string is defined by the maxLength parameter. + * String can contain ASCII characters from 32 to 126. + * + * Note: Returned string needs to be deallocated. + * + * \param maxLength The maximum length of the generated string. + * + * \returns Newly allocated random string; or NULL if maxLength was invalid or string could not be allocated. + */ +char * SDLTest_RandomAsciiStringWithMaximumLength(int maxLength); + + +/** + * Generates random null-terminated string. The length for + * the string is defined by the size parameter. + * String can contain ASCII characters from 32 to 126. + * + * Note: Returned string needs to be deallocated. + * + * \param size The length of the generated string + * + * \returns Newly allocated random string; or NULL if size was invalid or string could not be allocated. + */ +char * SDLTest_RandomAsciiStringOfSize(int size); + +/** + * Returns the invocation count for the fuzzer since last ...FuzzerInit. + */ +int SDLTest_GetFuzzerInvocationCount(); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_fuzzer_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_test.h spring-98.0~14.04~ppa6/include/SDL2/SDL_test.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_test.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_test.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,68 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_test.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +#ifndef _SDL_test_h +#define _SDL_test_h + +#include "SDL.h" +#include "SDL_test_common.h" +#include "SDL_test_font.h" +#include "SDL_test_random.h" +#include "SDL_test_fuzzer.h" +#include "SDL_test_crc32.h" +#include "SDL_test_md5.h" +#include "SDL_test_log.h" +#include "SDL_test_assert.h" +#include "SDL_test_harness.h" +#include "SDL_test_images.h" +#include "SDL_test_compare.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Global definitions */ + +/* + * Note: Maximum size of SDLTest log message is less than SDLs limit + * to ensure we can fit additional information such as the timestamp. + */ +#define SDLTEST_MAX_LOGMESSAGE_LENGTH 3584 + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_test_harness.h spring-98.0~14.04~ppa6/include/SDL2/SDL_test_harness.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_test_harness.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_test_harness.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,123 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_test_harness.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + Defines types for test case definitions and the test execution harness API. + + Based on original GSOC code by Markus Kauppila +*/ + +#ifndef _SDL_test_harness_h +#define _SDL_test_harness_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + + +/* ! Definitions for test case structures */ +#define TEST_ENABLED 1 +#define TEST_DISABLED 0 + +/* ! Definition of all the possible test return values of the test case method */ +#define TEST_ABORTED -1 +#define TEST_STARTED 0 +#define TEST_COMPLETED 1 +#define TEST_SKIPPED 2 + +/* ! Definition of all the possible test results for the harness */ +#define TEST_RESULT_PASSED 0 +#define TEST_RESULT_FAILED 1 +#define TEST_RESULT_NO_ASSERT 2 +#define TEST_RESULT_SKIPPED 3 +#define TEST_RESULT_SETUP_FAILURE 4 + +/* !< Function pointer to a test case setup function (run before every test) */ +typedef void (*SDLTest_TestCaseSetUpFp)(void *arg); + +/* !< Function pointer to a test case function */ +typedef int (*SDLTest_TestCaseFp)(void *arg); + +/* !< Function pointer to a test case teardown function (run after every test) */ +typedef void (*SDLTest_TestCaseTearDownFp)(void *arg); + +/** + * Holds information about a single test case. + */ +typedef struct SDLTest_TestCaseReference { + /* !< Func2Stress */ + SDLTest_TestCaseFp testCase; + /* !< Short name (or function name) "Func2Stress" */ + char *name; + /* !< Long name or full description "This test pushes func2() to the limit." */ + char *description; + /* !< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */ + int enabled; +} SDLTest_TestCaseReference; + +/** + * Holds information about a test suite (multiple test cases). + */ +typedef struct SDLTest_TestSuiteReference { + /* !< "PlatformSuite" */ + char *name; + /* !< The function that is run before each test. NULL skips. */ + SDLTest_TestCaseSetUpFp testSetUp; + /* !< The test cases that are run as part of the suite. Last item should be NULL. */ + const SDLTest_TestCaseReference **testCases; + /* !< The function that is run after each test. NULL skips. */ + SDLTest_TestCaseTearDownFp testTearDown; +} SDLTest_TestSuiteReference; + + +/** + * \brief Execute a test suite using the given run seed and execution key. + * + * \param testSuites Suites containing the test case. + * \param userRunSeed Custom run seed provided by user, or NULL to autogenerate one. + * \param userExecKey Custom execution key provided by user, or 0 to autogenerate one. + * \param filter Filter specification. NULL disables. Case sensitive. + * \param testIterations Number of iterations to run each test case. + * + * \returns Test run result; 0 when all tests passed, 1 if any tests failed. + */ +int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *userRunSeed, Uint64 userExecKey, const char *filter, int testIterations); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_harness_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_test_images.h spring-98.0~14.04~ppa6/include/SDL2/SDL_test_images.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_test_images.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_test_images.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,78 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_test_images.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + + Defines some images for tests. + +*/ + +#ifndef _SDL_test_images_h +#define _SDL_test_images_h + +#include "SDL.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + *Type for test images. + */ +typedef struct SDLTest_SurfaceImage_s { + int width; + int height; + unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ + const char *pixel_data; +} SDLTest_SurfaceImage_t; + +/* Test images */ +SDL_Surface *SDLTest_ImageBlit(); +SDL_Surface *SDLTest_ImageBlitColor(); +SDL_Surface *SDLTest_ImageBlitAlpha(); +SDL_Surface *SDLTest_ImageBlitBlendAdd(); +SDL_Surface *SDLTest_ImageBlitBlend(); +SDL_Surface *SDLTest_ImageBlitBlendMod(); +SDL_Surface *SDLTest_ImageBlitBlendNone(); +SDL_Surface *SDLTest_ImageBlitBlendAll(); +SDL_Surface *SDLTest_ImageFace(); +SDL_Surface *SDLTest_ImagePrimitives(); +SDL_Surface *SDLTest_ImagePrimitivesBlend(); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_images_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_test_log.h spring-98.0~14.04~ppa6/include/SDL2/SDL_test_log.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_test_log.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_test_log.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,67 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_test_log.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + * + * Wrapper to log in the TEST category + * + */ + +#ifndef _SDL_test_log_h +#define _SDL_test_log_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Prints given message with a timestamp in the TEST category and INFO priority. + * + * \param fmt Message to be logged + */ +void SDLTest_Log(const char *fmt, ...); + +/** + * \brief Prints given message with a timestamp in the TEST category and the ERROR priority. + * + * \param fmt Message to be logged + */ +void SDLTest_LogError(const char *fmt, ...); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_log_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_test_md5.h spring-98.0~14.04~ppa6/include/SDL2/SDL_test_md5.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_test_md5.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_test_md5.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,129 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_test_md5.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + *********************************************************************** + ** Header file for implementation of MD5 ** + ** RSA Data Security, Inc. MD5 Message-Digest Algorithm ** + ** Created: 2/17/90 RLR ** + ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version ** + ** Revised (for MD5): RLR 4/27/91 ** + ** -- G modified to have y&~z instead of y&z ** + ** -- FF, GG, HH modified to add in last register done ** + ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 ** + ** -- distinct additive constant for each step ** + ** -- round 4 added, working mod 7 ** + *********************************************************************** +*/ + +/* + *********************************************************************** + ** Message-digest routines: ** + ** To form the message digest for a message M ** + ** (1) Initialize a context buffer mdContext using MD5Init ** + ** (2) Call MD5Update on mdContext and M ** + ** (3) Call MD5Final on mdContext ** + ** The message digest is now in mdContext->digest[0...15] ** + *********************************************************************** +*/ + +#ifndef _SDL_test_md5_h +#define _SDL_test_md5_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* ------------ Definitions --------- */ + +/* typedef a 32-bit type */ + typedef unsigned long int MD5UINT4; + +/* Data structure for MD5 (Message-Digest) computation */ + typedef struct { + MD5UINT4 i[2]; /* number of _bits_ handled mod 2^64 */ + MD5UINT4 buf[4]; /* scratch buffer */ + unsigned char in[64]; /* input buffer */ + unsigned char digest[16]; /* actual digest after Md5Final call */ + } SDLTest_Md5Context; + +/* ---------- Function Prototypes ------------- */ + +/** + * /brief initialize the context + * + * /param mdContext pointer to context variable + * + * Note: The function initializes the message-digest context + * mdContext. Call before each new use of the context - + * all fields are set to zero. + */ + void SDLTest_Md5Init(SDLTest_Md5Context * mdContext); + + +/** + * /brief update digest from variable length data + * + * /param mdContext pointer to context variable + * /param inBuf pointer to data array/string + * /param inLen length of data array/string + * + * Note: The function updates the message-digest context to account + * for the presence of each of the characters inBuf[0..inLen-1] + * in the message whose digest is being computed. +*/ + + void SDLTest_Md5Update(SDLTest_Md5Context * mdContext, unsigned char *inBuf, + unsigned int inLen); + + +/* + * /brief complete digest computation + * + * /param mdContext pointer to context variable + * + * Note: The function terminates the message-digest computation and + * ends with the desired message digest in mdContext.digest[0..15]. + * Always call before using the digest[] variable. +*/ + + void SDLTest_Md5Final(SDLTest_Md5Context * mdContext); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_md5_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_test_random.h spring-98.0~14.04~ppa6/include/SDL2/SDL_test_random.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_test_random.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_test_random.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,115 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_test_random.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + + A "32-bit Multiply with carry random number generator. Very fast. + Includes a list of recommended multipliers. + + multiply-with-carry generator: x(n) = a*x(n-1) + carry mod 2^32. + period: (a*2^31)-1 + +*/ + +#ifndef _SDL_test_random_h +#define _SDL_test_random_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* --- Definitions */ + +/* + * Macros that return a random number in a specific format. + */ +#define SDLTest_RandomInt(c) ((int)SDLTest_Random(c)) + +/* + * Context structure for the random number generator state. + */ + typedef struct { + unsigned int a; + unsigned int x; + unsigned int c; + unsigned int ah; + unsigned int al; + } SDLTest_RandomContext; + + +/* --- Function prototypes */ + +/** + * \brief Initialize random number generator with two integers. + * + * Note: The random sequence of numbers returned by ...Random() is the + * same for the same two integers and has a period of 2^31. + * + * \param rndContext pointer to context structure + * \param xi integer that defines the random sequence + * \param ci integer that defines the random sequence + * + */ + void SDLTest_RandomInit(SDLTest_RandomContext * rndContext, unsigned int xi, + unsigned int ci); + +/** + * \brief Initialize random number generator based on current system time. + * + * \param rndContext pointer to context structure + * + */ + void SDLTest_RandomInitTime(SDLTest_RandomContext *rndContext); + + +/** + * \brief Initialize random number generator based on current system time. + * + * Note: ...RandomInit() or ...RandomInitTime() must have been called + * before using this function. + * + * \param rndContext pointer to context structure + * + * \returns A random number (32bit unsigned integer) + * + */ + unsigned int SDLTest_Random(SDLTest_RandomContext *rndContext); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_test_random_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_thread.h spring-98.0~14.04~ppa6/include/SDL2/SDL_thread.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_thread.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_thread.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,242 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_thread_h +#define _SDL_thread_h + +/** + * \file SDL_thread.h + * + * Header for the SDL thread management routines. + */ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +/* Thread synchronization primitives */ +#include "SDL_atomic.h" +#include "SDL_mutex.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* The SDL thread structure, defined in SDL_thread.c */ +struct SDL_Thread; +typedef struct SDL_Thread SDL_Thread; + +/* The SDL thread ID */ +typedef unsigned long SDL_threadID; + +/* Thread local storage ID, 0 is the invalid ID */ +typedef unsigned int SDL_TLSID; + +/** + * The SDL thread priority. + * + * \note On many systems you require special privileges to set high priority. + */ +typedef enum { + SDL_THREAD_PRIORITY_LOW, + SDL_THREAD_PRIORITY_NORMAL, + SDL_THREAD_PRIORITY_HIGH +} SDL_ThreadPriority; + +/** + * The function passed to SDL_CreateThread(). + * It is passed a void* user context parameter and returns an int. + */ +typedef int (SDLCALL * SDL_ThreadFunction) (void *data); + +#if defined(__WIN32__) && !defined(HAVE_LIBC) +/** + * \file SDL_thread.h + * + * We compile SDL into a DLL. This means, that it's the DLL which + * creates a new thread for the calling process with the SDL_CreateThread() + * API. There is a problem with this, that only the RTL of the SDL.DLL will + * be initialized for those threads, and not the RTL of the calling + * application! + * + * To solve this, we make a little hack here. + * + * We'll always use the caller's _beginthread() and _endthread() APIs to + * start a new thread. This way, if it's the SDL.DLL which uses this API, + * then the RTL of SDL.DLL will be used to create the new thread, and if it's + * the application, then the RTL of the application will be used. + * + * So, in short: + * Always use the _beginthread() and _endthread() of the calling runtime + * library! + */ +#define SDL_PASSED_BEGINTHREAD_ENDTHREAD +#include /* This has _beginthread() and _endthread() defined! */ + +typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned, + unsigned (__stdcall * + func) (void + *), + void *arg, unsigned, + unsigned *threadID); +typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code); + +/** + * Create a thread. + */ +extern DECLSPEC SDL_Thread *SDLCALL +SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data, + pfnSDL_CurrentBeginThread pfnBeginThread, + pfnSDL_CurrentEndThread pfnEndThread); + +/** + * Create a thread. + */ +#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex) + +#else + +/** + * Create a thread. + * + * Thread naming is a little complicated: Most systems have very small + * limits for the string length (BeOS has 32 bytes, Linux currently has 16, + * Visual C++ 6.0 has nine!), and possibly other arbitrary rules. You'll + * have to see what happens with your system's debugger. The name should be + * UTF-8 (but using the naming limits of C identifiers is a better bet). + * There are no requirements for thread naming conventions, so long as the + * string is null-terminated UTF-8, but these guidelines are helpful in + * choosing a name: + * + * http://stackoverflow.com/questions/149932/naming-conventions-for-threads + * + * If a system imposes requirements, SDL will try to munge the string for + * it (truncate, etc), but the original string contents will be available + * from SDL_GetThreadName(). + */ +extern DECLSPEC SDL_Thread *SDLCALL +SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data); + +#endif + +/** + * Get the thread name, as it was specified in SDL_CreateThread(). + * This function returns a pointer to a UTF-8 string that names the + * specified thread, or NULL if it doesn't have a name. This is internal + * memory, not to be free()'d by the caller, and remains valid until the + * specified thread is cleaned up by SDL_WaitThread(). + */ +extern DECLSPEC const char *SDLCALL SDL_GetThreadName(SDL_Thread *thread); + +/** + * Get the thread identifier for the current thread. + */ +extern DECLSPEC SDL_threadID SDLCALL SDL_ThreadID(void); + +/** + * Get the thread identifier for the specified thread. + * + * Equivalent to SDL_ThreadID() if the specified thread is NULL. + */ +extern DECLSPEC SDL_threadID SDLCALL SDL_GetThreadID(SDL_Thread * thread); + +/** + * Set the priority for the current thread + */ +extern DECLSPEC int SDLCALL SDL_SetThreadPriority(SDL_ThreadPriority priority); + +/** + * Wait for a thread to finish. + * + * The return code for the thread function is placed in the area + * pointed to by \c status, if \c status is not NULL. + */ +extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread * thread, int *status); + +/** + * \brief Create an identifier that is globally visible to all threads but refers to data that is thread-specific. + * + * \return The newly created thread local storage identifier, or 0 on error + * + * \code + * static SDL_SpinLock tls_lock; + * static SDL_TLSID thread_local_storage; + * + * void SetMyThreadData(void *value) + * { + * if (!thread_local_storage) { + * SDL_AtomicLock(&tls_lock); + * if (!thread_local_storage) { + * thread_local_storage = SDL_TLSCreate(); + * } + * SDL_AtomicUnLock(&tls_lock); + * } + * SDL_TLSSet(thread_local_storage, value); + * } + * + * void *GetMyThreadData(void) + * { + * return SDL_TLSGet(thread_local_storage); + * } + * \endcode + * + * \sa SDL_TLSGet() + * \sa SDL_TLSSet() + */ +extern DECLSPEC SDL_TLSID SDLCALL SDL_TLSCreate(void); + +/** + * \brief Get the value associated with a thread local storage ID for the current thread. + * + * \param id The thread local storage ID + * + * \return The value associated with the ID for the current thread, or NULL if no value has been set. + * + * \sa SDL_TLSCreate() + * \sa SDL_TLSSet() + */ +extern DECLSPEC void * SDLCALL SDL_TLSGet(SDL_TLSID id); + +/** + * \brief Set the value associated with a thread local storage ID for the current thread. + * + * \param id The thread local storage ID + * \param value The value to associate with the ID for the current thread + * \param destructor A function called when the thread exits, to free the value. + * + * \return 0 on success, -1 on error + * + * \sa SDL_TLSCreate() + * \sa SDL_TLSGet() + */ +extern DECLSPEC int SDLCALL SDL_TLSSet(SDL_TLSID id, const void *value, void (*destructor)(void*)); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_thread_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_timer.h spring-98.0~14.04~ppa6/include/SDL2/SDL_timer.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_timer.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_timer.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,115 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +#ifndef _SDL_timer_h +#define _SDL_timer_h + +/** + * \file SDL_timer.h + * + * Header for the SDL time management routines. + */ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Get the number of milliseconds since the SDL library initialization. + * + * \note This value wraps if the program runs for more than ~49 days. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); + +/** + * \brief Compare SDL ticks values, and return true if A has passed B + * + * e.g. if you want to wait 100 ms, you could do this: + * Uint32 timeout = SDL_GetTicks() + 100; + * while (!SDL_TICKS_PASSED(SDL_GetTicks(), timeout)) { + * ... do work until timeout has elapsed + * } + */ +#define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0) + +/** + * \brief Get the current value of the high resolution counter + */ +extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceCounter(void); + +/** + * \brief Get the count per second of the high resolution counter + */ +extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceFrequency(void); + +/** + * \brief Wait a specified number of milliseconds before returning. + */ +extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); + +/** + * Function prototype for the timer callback function. + * + * The callback function is passed the current timer interval and returns + * the next timer interval. If the returned value is the same as the one + * passed in, the periodic alarm continues, otherwise a new alarm is + * scheduled. If the callback returns 0, the periodic alarm is cancelled. + */ +typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval, void *param); + +/** + * Definition of the timer ID type. + */ +typedef int SDL_TimerID; + +/** + * \brief Add a new timer to the pool of timers already running. + * + * \return A timer ID, or NULL when an error occurs. + */ +extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, + SDL_TimerCallback callback, + void *param); + +/** + * \brief Remove a timer knowing its ID. + * + * \return A boolean value indicating success or failure. + * + * \warning It is not safe to remove a timer multiple times. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID id); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_timer_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_touch.h spring-98.0~14.04~ppa6/include/SDL2/SDL_touch.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_touch.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_touch.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,86 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_touch.h + * + * Include file for SDL touch event handling. + */ + +#ifndef _SDL_touch_h +#define _SDL_touch_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +typedef Sint64 SDL_TouchID; +typedef Sint64 SDL_FingerID; + +typedef struct SDL_Finger +{ + SDL_FingerID id; + float x; + float y; + float pressure; +} SDL_Finger; + +/* Used as the device ID for mouse events simulated with touch input */ +#define SDL_TOUCH_MOUSEID ((Uint32)-1) + + +/* Function prototypes */ + +/** + * \brief Get the number of registered touch devices. + */ +extern DECLSPEC int SDLCALL SDL_GetNumTouchDevices(void); + +/** + * \brief Get the touch ID with the given index, or 0 if the index is invalid. + */ +extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index); + +/** + * \brief Get the number of active fingers for a given touch device. + */ +extern DECLSPEC int SDLCALL SDL_GetNumTouchFingers(SDL_TouchID touchID); + +/** + * \brief Get the finger object of the given touch, with the given index. + */ +extern DECLSPEC SDL_Finger * SDLCALL SDL_GetTouchFinger(SDL_TouchID touchID, int index); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_touch_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_types.h spring-98.0~14.04~ppa6/include/SDL2/SDL_types.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_types.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_types.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,29 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_types.h + * + * \deprecated + */ + +/* DEPRECATED */ +#include "SDL_stdinc.h" diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_version.h spring-98.0~14.04~ppa6/include/SDL2/SDL_version.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_version.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_version.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,162 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_version.h + * + * This header defines the current SDL version. + */ + +#ifndef _SDL_version_h +#define _SDL_version_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Information the version of SDL in use. + * + * Represents the library's version as three levels: major revision + * (increments with massive changes, additions, and enhancements), + * minor revision (increments with backwards-compatible changes to the + * major revision), and patchlevel (increments with fixes to the minor + * revision). + * + * \sa SDL_VERSION + * \sa SDL_GetVersion + */ +typedef struct SDL_version +{ + Uint8 major; /**< major version */ + Uint8 minor; /**< minor version */ + Uint8 patch; /**< update version */ +} SDL_version; + +/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL +*/ +#define SDL_MAJOR_VERSION 2 +#define SDL_MINOR_VERSION 0 +#define SDL_PATCHLEVEL 1 + +/** + * \brief Macro to determine SDL version program was compiled against. + * + * This macro fills in a SDL_version structure with the version of the + * library you compiled against. This is determined by what header the + * compiler uses. Note that if you dynamically linked the library, you might + * have a slightly newer or older version at runtime. That version can be + * determined with SDL_GetVersion(), which, unlike SDL_VERSION(), + * is not a macro. + * + * \param x A pointer to a SDL_version struct to initialize. + * + * \sa SDL_version + * \sa SDL_GetVersion + */ +#define SDL_VERSION(x) \ +{ \ + (x)->major = SDL_MAJOR_VERSION; \ + (x)->minor = SDL_MINOR_VERSION; \ + (x)->patch = SDL_PATCHLEVEL; \ +} + +/** + * This macro turns the version numbers into a numeric value: + * \verbatim + (1,2,3) -> (1203) + \endverbatim + * + * This assumes that there will never be more than 100 patchlevels. + */ +#define SDL_VERSIONNUM(X, Y, Z) \ + ((X)*1000 + (Y)*100 + (Z)) + +/** + * This is the version number macro for the current SDL version. + */ +#define SDL_COMPILEDVERSION \ + SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) + +/** + * This macro will evaluate to true if compiled with SDL at least X.Y.Z. + */ +#define SDL_VERSION_ATLEAST(X, Y, Z) \ + (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) + +/** + * \brief Get the version of SDL that is linked against your program. + * + * If you are linking to SDL dynamically, then it is possible that the + * current version will be different than the version you compiled against. + * This function returns the current version, while SDL_VERSION() is a + * macro that tells you what version you compiled with. + * + * \code + * SDL_version compiled; + * SDL_version linked; + * + * SDL_VERSION(&compiled); + * SDL_GetVersion(&linked); + * printf("We compiled against SDL version %d.%d.%d ...\n", + * compiled.major, compiled.minor, compiled.patch); + * printf("But we linked against SDL version %d.%d.%d.\n", + * linked.major, linked.minor, linked.patch); + * \endcode + * + * This function may be called safely at any time, even before SDL_Init(). + * + * \sa SDL_VERSION + */ +extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver); + +/** + * \brief Get the code revision of SDL that is linked against your program. + * + * Returns an arbitrary string (a hash value) uniquely identifying the + * exact revision of the SDL library in use, and is only useful in comparing + * against other revisions. It is NOT an incrementing number. + */ +extern DECLSPEC const char *SDLCALL SDL_GetRevision(void); + +/** + * \brief Get the revision number of SDL that is linked against your program. + * + * Returns a number uniquely identifying the exact revision of the SDL + * library in use. It is an incrementing number based on commits to + * hg.libsdl.org. + */ +extern DECLSPEC int SDLCALL SDL_GetRevisionNumber(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_version_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/include/SDL2/SDL_video.h spring-98.0~14.04~ppa6/include/SDL2/SDL_video.h --- spring-96.0~14.04~ppa4/include/SDL2/SDL_video.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/include/SDL2/SDL_video.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,974 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2013 Sam Lantinga + + 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. +*/ + +/** + * \file SDL_video.h + * + * Header file for SDL video functions. + */ + +#ifndef _SDL_video_h +#define _SDL_video_h + +#include "SDL_stdinc.h" +#include "SDL_pixels.h" +#include "SDL_rect.h" +#include "SDL_surface.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief The structure that defines a display mode + * + * \sa SDL_GetNumDisplayModes() + * \sa SDL_GetDisplayMode() + * \sa SDL_GetDesktopDisplayMode() + * \sa SDL_GetCurrentDisplayMode() + * \sa SDL_GetClosestDisplayMode() + * \sa SDL_SetWindowDisplayMode() + * \sa SDL_GetWindowDisplayMode() + */ +typedef struct +{ + Uint32 format; /**< pixel format */ + int w; /**< width */ + int h; /**< height */ + int refresh_rate; /**< refresh rate (or zero for unspecified) */ + void *driverdata; /**< driver-specific data, initialize to 0 */ +} SDL_DisplayMode; + +/** + * \brief The type used to identify a window + * + * \sa SDL_CreateWindow() + * \sa SDL_CreateWindowFrom() + * \sa SDL_DestroyWindow() + * \sa SDL_GetWindowData() + * \sa SDL_GetWindowFlags() + * \sa SDL_GetWindowGrab() + * \sa SDL_GetWindowPosition() + * \sa SDL_GetWindowSize() + * \sa SDL_GetWindowTitle() + * \sa SDL_HideWindow() + * \sa SDL_MaximizeWindow() + * \sa SDL_MinimizeWindow() + * \sa SDL_RaiseWindow() + * \sa SDL_RestoreWindow() + * \sa SDL_SetWindowData() + * \sa SDL_SetWindowFullscreen() + * \sa SDL_SetWindowGrab() + * \sa SDL_SetWindowIcon() + * \sa SDL_SetWindowPosition() + * \sa SDL_SetWindowSize() + * \sa SDL_SetWindowBordered() + * \sa SDL_SetWindowTitle() + * \sa SDL_ShowWindow() + */ +typedef struct SDL_Window SDL_Window; + +/** + * \brief The flags on a window + * + * \sa SDL_GetWindowFlags() + */ +typedef enum +{ + SDL_WINDOW_FULLSCREEN = 0x00000001, /**< fullscreen window */ + SDL_WINDOW_OPENGL = 0x00000002, /**< window usable with OpenGL context */ + SDL_WINDOW_SHOWN = 0x00000004, /**< window is visible */ + SDL_WINDOW_HIDDEN = 0x00000008, /**< window is not visible */ + SDL_WINDOW_BORDERLESS = 0x00000010, /**< no window decoration */ + SDL_WINDOW_RESIZABLE = 0x00000020, /**< window can be resized */ + SDL_WINDOW_MINIMIZED = 0x00000040, /**< window is minimized */ + SDL_WINDOW_MAXIMIZED = 0x00000080, /**< window is maximized */ + SDL_WINDOW_INPUT_GRABBED = 0x00000100, /**< window has grabbed input focus */ + SDL_WINDOW_INPUT_FOCUS = 0x00000200, /**< window has input focus */ + SDL_WINDOW_MOUSE_FOCUS = 0x00000400, /**< window has mouse focus */ + SDL_WINDOW_FULLSCREEN_DESKTOP = ( SDL_WINDOW_FULLSCREEN | 0x00001000 ), + SDL_WINDOW_FOREIGN = 0x00000800, /**< window not created by SDL */ + SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000 /**< window should be created in high-DPI mode if supported */ +} SDL_WindowFlags; + +/** + * \brief Used to indicate that you don't care what the window position is. + */ +#define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000 +#define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X)) +#define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0) +#define SDL_WINDOWPOS_ISUNDEFINED(X) \ + (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK) + +/** + * \brief Used to indicate that the window position should be centered. + */ +#define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000 +#define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X)) +#define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0) +#define SDL_WINDOWPOS_ISCENTERED(X) \ + (((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK) + +/** + * \brief Event subtype for window events + */ +typedef enum +{ + SDL_WINDOWEVENT_NONE, /**< Never used */ + SDL_WINDOWEVENT_SHOWN, /**< Window has been shown */ + SDL_WINDOWEVENT_HIDDEN, /**< Window has been hidden */ + SDL_WINDOWEVENT_EXPOSED, /**< Window has been exposed and should be + redrawn */ + SDL_WINDOWEVENT_MOVED, /**< Window has been moved to data1, data2 + */ + SDL_WINDOWEVENT_RESIZED, /**< Window has been resized to data1xdata2 */ + SDL_WINDOWEVENT_SIZE_CHANGED, /**< The window size has changed, either as a result of an API call or through the system or user changing the window size. */ + SDL_WINDOWEVENT_MINIMIZED, /**< Window has been minimized */ + SDL_WINDOWEVENT_MAXIMIZED, /**< Window has been maximized */ + SDL_WINDOWEVENT_RESTORED, /**< Window has been restored to normal size + and position */ + SDL_WINDOWEVENT_ENTER, /**< Window has gained mouse focus */ + SDL_WINDOWEVENT_LEAVE, /**< Window has lost mouse focus */ + SDL_WINDOWEVENT_FOCUS_GAINED, /**< Window has gained keyboard focus */ + SDL_WINDOWEVENT_FOCUS_LOST, /**< Window has lost keyboard focus */ + SDL_WINDOWEVENT_CLOSE /**< The window manager requests that the + window be closed */ +} SDL_WindowEventID; + +/** + * \brief An opaque handle to an OpenGL context. + */ +typedef void *SDL_GLContext; + +/** + * \brief OpenGL configuration attributes + */ +typedef enum +{ + SDL_GL_RED_SIZE, + SDL_GL_GREEN_SIZE, + SDL_GL_BLUE_SIZE, + SDL_GL_ALPHA_SIZE, + SDL_GL_BUFFER_SIZE, + SDL_GL_DOUBLEBUFFER, + SDL_GL_DEPTH_SIZE, + SDL_GL_STENCIL_SIZE, + SDL_GL_ACCUM_RED_SIZE, + SDL_GL_ACCUM_GREEN_SIZE, + SDL_GL_ACCUM_BLUE_SIZE, + SDL_GL_ACCUM_ALPHA_SIZE, + SDL_GL_STEREO, + SDL_GL_MULTISAMPLEBUFFERS, + SDL_GL_MULTISAMPLESAMPLES, + SDL_GL_ACCELERATED_VISUAL, + SDL_GL_RETAINED_BACKING, + SDL_GL_CONTEXT_MAJOR_VERSION, + SDL_GL_CONTEXT_MINOR_VERSION, + SDL_GL_CONTEXT_EGL, + SDL_GL_CONTEXT_FLAGS, + SDL_GL_CONTEXT_PROFILE_MASK, + SDL_GL_SHARE_WITH_CURRENT_CONTEXT, + SDL_GL_FRAMEBUFFER_SRGB_CAPABLE +} SDL_GLattr; + +typedef enum +{ + SDL_GL_CONTEXT_PROFILE_CORE = 0x0001, + SDL_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002, + SDL_GL_CONTEXT_PROFILE_ES = 0x0004 /* GLX_CONTEXT_ES2_PROFILE_BIT_EXT */ +} SDL_GLprofile; + +typedef enum +{ + SDL_GL_CONTEXT_DEBUG_FLAG = 0x0001, + SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = 0x0002, + SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG = 0x0004, + SDL_GL_CONTEXT_RESET_ISOLATION_FLAG = 0x0008 +} SDL_GLcontextFlag; + + +/* Function prototypes */ + +/** + * \brief Get the number of video drivers compiled into SDL + * + * \sa SDL_GetVideoDriver() + */ +extern DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void); + +/** + * \brief Get the name of a built in video driver. + * + * \note The video drivers are presented in the order in which they are + * normally checked during initialization. + * + * \sa SDL_GetNumVideoDrivers() + */ +extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver(int index); + +/** + * \brief Initialize the video subsystem, optionally specifying a video driver. + * + * \param driver_name Initialize a specific driver by name, or NULL for the + * default video driver. + * + * \return 0 on success, -1 on error + * + * This function initializes the video subsystem; setting up a connection + * to the window manager, etc, and determines the available display modes + * and pixel formats, but does not initialize a window or graphics mode. + * + * \sa SDL_VideoQuit() + */ +extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name); + +/** + * \brief Shuts down the video subsystem. + * + * This function closes all windows, and restores the original video mode. + * + * \sa SDL_VideoInit() + */ +extern DECLSPEC void SDLCALL SDL_VideoQuit(void); + +/** + * \brief Returns the name of the currently initialized video driver. + * + * \return The name of the current video driver or NULL if no driver + * has been initialized + * + * \sa SDL_GetNumVideoDrivers() + * \sa SDL_GetVideoDriver() + */ +extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver(void); + +/** + * \brief Returns the number of available video displays. + * + * \sa SDL_GetDisplayBounds() + */ +extern DECLSPEC int SDLCALL SDL_GetNumVideoDisplays(void); + +/** + * \brief Get the name of a display in UTF-8 encoding + * + * \return The name of a display, or NULL for an invalid display index. + * + * \sa SDL_GetNumVideoDisplays() + */ +extern DECLSPEC const char * SDLCALL SDL_GetDisplayName(int displayIndex); + +/** + * \brief Get the desktop area represented by a display, with the primary + * display located at 0,0 + * + * \return 0 on success, or -1 if the index is out of range. + * + * \sa SDL_GetNumVideoDisplays() + */ +extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect); + +/** + * \brief Returns the number of available display modes. + * + * \sa SDL_GetDisplayMode() + */ +extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(int displayIndex); + +/** + * \brief Fill in information about a specific display mode. + * + * \note The display modes are sorted in this priority: + * \li bits per pixel -> more colors to fewer colors + * \li width -> largest to smallest + * \li height -> largest to smallest + * \li refresh rate -> highest to lowest + * + * \sa SDL_GetNumDisplayModes() + */ +extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex, + SDL_DisplayMode * mode); + +/** + * \brief Fill in information about the desktop display mode. + */ +extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode * mode); + +/** + * \brief Fill in information about the current display mode. + */ +extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(int displayIndex, SDL_DisplayMode * mode); + + +/** + * \brief Get the closest match to the requested display mode. + * + * \param displayIndex The index of display from which mode should be queried. + * \param mode The desired display mode + * \param closest A pointer to a display mode to be filled in with the closest + * match of the available display modes. + * + * \return The passed in value \c closest, or NULL if no matching video mode + * was available. + * + * The available display modes are scanned, and \c closest is filled in with the + * closest mode matching the requested mode and returned. The mode format and + * refresh_rate default to the desktop mode if they are 0. The modes are + * scanned with size being first priority, format being second priority, and + * finally checking the refresh_rate. If all the available modes are too + * small, then NULL is returned. + * + * \sa SDL_GetNumDisplayModes() + * \sa SDL_GetDisplayMode() + */ +extern DECLSPEC SDL_DisplayMode * SDLCALL SDL_GetClosestDisplayMode(int displayIndex, const SDL_DisplayMode * mode, SDL_DisplayMode * closest); + +/** + * \brief Get the display index associated with a window. + * + * \return the display index of the display containing the center of the + * window, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_GetWindowDisplayIndex(SDL_Window * window); + +/** + * \brief Set the display mode used when a fullscreen window is visible. + * + * By default the window's dimensions and the desktop format and refresh rate + * are used. + * + * \param window The window for which the display mode should be set. + * \param mode The mode to use, or NULL for the default mode. + * + * \return 0 on success, or -1 if setting the display mode failed. + * + * \sa SDL_GetWindowDisplayMode() + * \sa SDL_SetWindowFullscreen() + */ +extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_Window * window, + const SDL_DisplayMode + * mode); + +/** + * \brief Fill in information about the display mode used when a fullscreen + * window is visible. + * + * \sa SDL_SetWindowDisplayMode() + * \sa SDL_SetWindowFullscreen() + */ +extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window * window, + SDL_DisplayMode * mode); + +/** + * \brief Get the pixel format associated with the window. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window); + +/** + * \brief Create a window with the specified position, dimensions, and flags. + * + * \param title The title of the window, in UTF-8 encoding. + * \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or + * ::SDL_WINDOWPOS_UNDEFINED. + * \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or + * ::SDL_WINDOWPOS_UNDEFINED. + * \param w The width of the window. + * \param h The height of the window. + * \param flags The flags for the window, a mask of any of the following: + * ::SDL_WINDOW_FULLSCREEN, ::SDL_WINDOW_OPENGL, + * ::SDL_WINDOW_HIDDEN, ::SDL_WINDOW_BORDERLESS, + * ::SDL_WINDOW_RESIZABLE, ::SDL_WINDOW_MAXIMIZED, + * ::SDL_WINDOW_MINIMIZED, ::SDL_WINDOW_INPUT_GRABBED, + * ::SDL_WINDOW_ALLOW_HIGHDPI. + * + * \return The id of the window created, or zero if window creation failed. + * + * \sa SDL_DestroyWindow() + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title, + int x, int y, int w, + int h, Uint32 flags); + +/** + * \brief Create an SDL window from an existing native window. + * + * \param data A pointer to driver-dependent window creation data + * + * \return The id of the window created, or zero if window creation failed. + * + * \sa SDL_DestroyWindow() + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindowFrom(const void *data); + +/** + * \brief Get the numeric ID of a window, for logging purposes. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetWindowID(SDL_Window * window); + +/** + * \brief Get a window from a stored ID, or NULL if it doesn't exist. + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromID(Uint32 id); + +/** + * \brief Get the window flags. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetWindowFlags(SDL_Window * window); + +/** + * \brief Set the title of a window, in UTF-8 format. + * + * \sa SDL_GetWindowTitle() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window * window, + const char *title); + +/** + * \brief Get the title of a window, in UTF-8 format. + * + * \sa SDL_SetWindowTitle() + */ +extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_Window * window); + +/** + * \brief Set the icon for a window. + * + * \param window The window for which the icon should be set. + * \param icon The icon for the window. + */ +extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window * window, + SDL_Surface * icon); + +/** + * \brief Associate an arbitrary named pointer with a window. + * + * \param window The window to associate with the pointer. + * \param name The name of the pointer. + * \param userdata The associated pointer. + * + * \return The previous value associated with 'name' + * + * \note The name is case-sensitive. + * + * \sa SDL_GetWindowData() + */ +extern DECLSPEC void* SDLCALL SDL_SetWindowData(SDL_Window * window, + const char *name, + void *userdata); + +/** + * \brief Retrieve the data pointer associated with a window. + * + * \param window The window to query. + * \param name The name of the pointer. + * + * \return The value associated with 'name' + * + * \sa SDL_SetWindowData() + */ +extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window * window, + const char *name); + +/** + * \brief Set the position of a window. + * + * \param window The window to reposition. + * \param x The x coordinate of the window, ::SDL_WINDOWPOS_CENTERED, or + ::SDL_WINDOWPOS_UNDEFINED. + * \param y The y coordinate of the window, ::SDL_WINDOWPOS_CENTERED, or + ::SDL_WINDOWPOS_UNDEFINED. + * + * \note The window coordinate origin is the upper left of the display. + * + * \sa SDL_GetWindowPosition() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window * window, + int x, int y); + +/** + * \brief Get the position of a window. + * + * \param window The window to query. + * \param x Pointer to variable for storing the x position, may be NULL + * \param y Pointer to variable for storing the y position, may be NULL + * + * \sa SDL_SetWindowPosition() + */ +extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window, + int *x, int *y); + +/** + * \brief Set the size of a window's client area. + * + * \param window The window to resize. + * \param w The width of the window, must be >0 + * \param h The height of the window, must be >0 + * + * \note You can't change the size of a fullscreen window, it automatically + * matches the size of the display mode. + * + * \sa SDL_GetWindowSize() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window * window, int w, + int h); + +/** + * \brief Get the size of a window's client area. + * + * \param window The window to query. + * \param w Pointer to variable for storing the width, may be NULL + * \param h Pointer to variable for storing the height, may be NULL + * + * \sa SDL_SetWindowSize() + */ +extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w, + int *h); + +/** + * \brief Set the minimum size of a window's client area. + * + * \param window The window to set a new minimum size. + * \param min_w The minimum width of the window, must be >0 + * \param min_h The minimum height of the window, must be >0 + * + * \note You can't change the minimum size of a fullscreen window, it + * automatically matches the size of the display mode. + * + * \sa SDL_GetWindowMinimumSize() + * \sa SDL_SetWindowMaximumSize() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowMinimumSize(SDL_Window * window, + int min_w, int min_h); + +/** + * \brief Get the minimum size of a window's client area. + * + * \param window The window to query. + * \param w Pointer to variable for storing the minimum width, may be NULL + * \param h Pointer to variable for storing the minimum height, may be NULL + * + * \sa SDL_GetWindowMaximumSize() + * \sa SDL_SetWindowMinimumSize() + */ +extern DECLSPEC void SDLCALL SDL_GetWindowMinimumSize(SDL_Window * window, + int *w, int *h); + +/** + * \brief Set the maximum size of a window's client area. + * + * \param window The window to set a new maximum size. + * \param max_w The maximum width of the window, must be >0 + * \param max_h The maximum height of the window, must be >0 + * + * \note You can't change the maximum size of a fullscreen window, it + * automatically matches the size of the display mode. + * + * \sa SDL_GetWindowMaximumSize() + * \sa SDL_SetWindowMinimumSize() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowMaximumSize(SDL_Window * window, + int max_w, int max_h); + +/** + * \brief Get the maximum size of a window's client area. + * + * \param window The window to query. + * \param w Pointer to variable for storing the maximum width, may be NULL + * \param h Pointer to variable for storing the maximum height, may be NULL + * + * \sa SDL_GetWindowMinimumSize() + * \sa SDL_SetWindowMaximumSize() + */ +extern DECLSPEC void SDLCALL SDL_GetWindowMaximumSize(SDL_Window * window, + int *w, int *h); + +/** + * \brief Set the border state of a window. + * + * This will add or remove the window's SDL_WINDOW_BORDERLESS flag and + * add or remove the border from the actual window. This is a no-op if the + * window's border already matches the requested state. + * + * \param window The window of which to change the border state. + * \param bordered SDL_FALSE to remove border, SDL_TRUE to add border. + * + * \note You can't change the border state of a fullscreen window. + * + * \sa SDL_GetWindowFlags() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window * window, + SDL_bool bordered); + +/** + * \brief Show a window. + * + * \sa SDL_HideWindow() + */ +extern DECLSPEC void SDLCALL SDL_ShowWindow(SDL_Window * window); + +/** + * \brief Hide a window. + * + * \sa SDL_ShowWindow() + */ +extern DECLSPEC void SDLCALL SDL_HideWindow(SDL_Window * window); + +/** + * \brief Raise a window above other windows and set the input focus. + */ +extern DECLSPEC void SDLCALL SDL_RaiseWindow(SDL_Window * window); + +/** + * \brief Make a window as large as possible. + * + * \sa SDL_RestoreWindow() + */ +extern DECLSPEC void SDLCALL SDL_MaximizeWindow(SDL_Window * window); + +/** + * \brief Minimize a window to an iconic representation. + * + * \sa SDL_RestoreWindow() + */ +extern DECLSPEC void SDLCALL SDL_MinimizeWindow(SDL_Window * window); + +/** + * \brief Restore the size and position of a minimized or maximized window. + * + * \sa SDL_MaximizeWindow() + * \sa SDL_MinimizeWindow() + */ +extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_Window * window); + +/** + * \brief Set a window's fullscreen state. + * + * \return 0 on success, or -1 if setting the display mode failed. + * + * \sa SDL_SetWindowDisplayMode() + * \sa SDL_GetWindowDisplayMode() + */ +extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window, + Uint32 flags); + +/** + * \brief Get the SDL surface associated with the window. + * + * \return The window's framebuffer surface, or NULL on error. + * + * A new surface will be created with the optimal format for the window, + * if necessary. This surface will be freed when the window is destroyed. + * + * \note You may not combine this with 3D or the rendering API on this window. + * + * \sa SDL_UpdateWindowSurface() + * \sa SDL_UpdateWindowSurfaceRects() + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_GetWindowSurface(SDL_Window * window); + +/** + * \brief Copy the window surface to the screen. + * + * \return 0 on success, or -1 on error. + * + * \sa SDL_GetWindowSurface() + * \sa SDL_UpdateWindowSurfaceRects() + */ +extern DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window * window); + +/** + * \brief Copy a number of rectangles on the window surface to the screen. + * + * \return 0 on success, or -1 on error. + * + * \sa SDL_GetWindowSurface() + * \sa SDL_UpdateWindowSurfaceRect() + */ +extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window, + const SDL_Rect * rects, + int numrects); + +/** + * \brief Set a window's input grab mode. + * + * \param window The window for which the input grab mode should be set. + * \param grabbed This is SDL_TRUE to grab input, and SDL_FALSE to release input. + * + * \sa SDL_GetWindowGrab() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window * window, + SDL_bool grabbed); + +/** + * \brief Get a window's input grab mode. + * + * \return This returns SDL_TRUE if input is grabbed, and SDL_FALSE otherwise. + * + * \sa SDL_SetWindowGrab() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowGrab(SDL_Window * window); + +/** + * \brief Set the brightness (gamma correction) for a window. + * + * \return 0 on success, or -1 if setting the brightness isn't supported. + * + * \sa SDL_GetWindowBrightness() + * \sa SDL_SetWindowGammaRamp() + */ +extern DECLSPEC int SDLCALL SDL_SetWindowBrightness(SDL_Window * window, float brightness); + +/** + * \brief Get the brightness (gamma correction) for a window. + * + * \return The last brightness value passed to SDL_SetWindowBrightness() + * + * \sa SDL_SetWindowBrightness() + */ +extern DECLSPEC float SDLCALL SDL_GetWindowBrightness(SDL_Window * window); + +/** + * \brief Set the gamma ramp for a window. + * + * \param window The window for which the gamma ramp should be set. + * \param red The translation table for the red channel, or NULL. + * \param green The translation table for the green channel, or NULL. + * \param blue The translation table for the blue channel, or NULL. + * + * \return 0 on success, or -1 if gamma ramps are unsupported. + * + * Set the gamma translation table for the red, green, and blue channels + * of the video hardware. Each table is an array of 256 16-bit quantities, + * representing a mapping between the input and output for that channel. + * The input is the index into the array, and the output is the 16-bit + * gamma value at that index, scaled to the output color precision. + * + * \sa SDL_GetWindowGammaRamp() + */ +extern DECLSPEC int SDLCALL SDL_SetWindowGammaRamp(SDL_Window * window, + const Uint16 * red, + const Uint16 * green, + const Uint16 * blue); + +/** + * \brief Get the gamma ramp for a window. + * + * \param window The window from which the gamma ramp should be queried. + * \param red A pointer to a 256 element array of 16-bit quantities to hold + * the translation table for the red channel, or NULL. + * \param green A pointer to a 256 element array of 16-bit quantities to hold + * the translation table for the green channel, or NULL. + * \param blue A pointer to a 256 element array of 16-bit quantities to hold + * the translation table for the blue channel, or NULL. + * + * \return 0 on success, or -1 if gamma ramps are unsupported. + * + * \sa SDL_SetWindowGammaRamp() + */ +extern DECLSPEC int SDLCALL SDL_GetWindowGammaRamp(SDL_Window * window, + Uint16 * red, + Uint16 * green, + Uint16 * blue); + +/** + * \brief Destroy a window. + */ +extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_Window * window); + + +/** + * \brief Returns whether the screensaver is currently enabled (default on). + * + * \sa SDL_EnableScreenSaver() + * \sa SDL_DisableScreenSaver() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenSaverEnabled(void); + +/** + * \brief Allow the screen to be blanked by a screensaver + * + * \sa SDL_IsScreenSaverEnabled() + * \sa SDL_DisableScreenSaver() + */ +extern DECLSPEC void SDLCALL SDL_EnableScreenSaver(void); + +/** + * \brief Prevent the screen from being blanked by a screensaver + * + * \sa SDL_IsScreenSaverEnabled() + * \sa SDL_EnableScreenSaver() + */ +extern DECLSPEC void SDLCALL SDL_DisableScreenSaver(void); + + +/** + * \name OpenGL support functions + */ +/* @{ */ + +/** + * \brief Dynamically load an OpenGL library. + * + * \param path The platform dependent OpenGL library name, or NULL to open the + * default OpenGL library. + * + * \return 0 on success, or -1 if the library couldn't be loaded. + * + * This should be done after initializing the video driver, but before + * creating any OpenGL windows. If no OpenGL library is loaded, the default + * library will be loaded upon creation of the first OpenGL window. + * + * \note If you do this, you need to retrieve all of the GL functions used in + * your program from the dynamic library using SDL_GL_GetProcAddress(). + * + * \sa SDL_GL_GetProcAddress() + * \sa SDL_GL_UnloadLibrary() + */ +extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path); + +/** + * \brief Get the address of an OpenGL function. + */ +extern DECLSPEC void *SDLCALL SDL_GL_GetProcAddress(const char *proc); + +/** + * \brief Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary(). + * + * \sa SDL_GL_LoadLibrary() + */ +extern DECLSPEC void SDLCALL SDL_GL_UnloadLibrary(void); + +/** + * \brief Return true if an OpenGL extension is supported for the current + * context. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GL_ExtensionSupported(const char + *extension); + +/** + * \brief Set an OpenGL window attribute before window creation. + */ +extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value); + +/** + * \brief Get the actual value for an attribute from the current context. + */ +extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value); + +/** + * \brief Create an OpenGL context for use with an OpenGL window, and make it + * current. + * + * \sa SDL_GL_DeleteContext() + */ +extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window * + window); + +/** + * \brief Set up an OpenGL context for rendering into an OpenGL window. + * + * \note The context must have been created with a compatible window. + */ +extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window * window, + SDL_GLContext context); + +/** + * \brief Get the currently active OpenGL window. + */ +extern DECLSPEC SDL_Window* SDLCALL SDL_GL_GetCurrentWindow(void); + +/** + * \brief Get the currently active OpenGL context. + */ +extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_GetCurrentContext(void); + +/** + * \brief Get the size of a window's underlying drawable (for use with glViewport). + * + * \param window Window from which the drawable size should be queried + * \param w Pointer to variable for storing the width, may be NULL + * \param h Pointer to variable for storing the height, may be NULL + * + * This may differ from SDL_GetWindowSize if we're rendering to a high-DPI + * drawable, i.e. the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a + * platform with high-DPI support (Apple calls this "Retina"), and not disabled + * by the SDL_HINT_VIDEO_HIGHDPI_DISABLED hint. + * + * \sa SDL_GetWindowSize() + * \sa SDL_CreateWindow() + */ +extern DECLSPEC void SDLCALL SDL_GL_GetDrawableSize(SDL_Window * window, int *w, + int *h); + +/** + * \brief Set the swap interval for the current OpenGL context. + * + * \param interval 0 for immediate updates, 1 for updates synchronized with the + * vertical retrace. If the system supports it, you may + * specify -1 to allow late swaps to happen immediately + * instead of waiting for the next retrace. + * + * \return 0 on success, or -1 if setting the swap interval is not supported. + * + * \sa SDL_GL_GetSwapInterval() + */ +extern DECLSPEC int SDLCALL SDL_GL_SetSwapInterval(int interval); + +/** + * \brief Get the swap interval for the current OpenGL context. + * + * \return 0 if there is no vertical retrace synchronization, 1 if the buffer + * swap is synchronized with the vertical retrace, and -1 if late + * swaps happen immediately instead of waiting for the next retrace. + * If the system can't determine the swap interval, or there isn't a + * valid current context, this will return 0 as a safe default. + * + * \sa SDL_GL_SetSwapInterval() + */ +extern DECLSPEC int SDLCALL SDL_GL_GetSwapInterval(void); + +/** + * \brief Swap the OpenGL buffers for a window, if double-buffering is + * supported. + */ +extern DECLSPEC void SDLCALL SDL_GL_SwapWindow(SDL_Window * window); + +/** + * \brief Delete an OpenGL context. + * + * \sa SDL_GL_CreateContext() + */ +extern DECLSPEC void SDLCALL SDL_GL_DeleteContext(SDL_GLContext context); + +/* @} *//* OpenGL support functions */ + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_video_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -Nru spring-96.0~14.04~ppa4/installer/sections/deprecated.nsh spring-98.0~14.04~ppa6/installer/sections/deprecated.nsh --- spring-96.0~14.04~ppa4/installer/sections/deprecated.nsh 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/installer/sections/deprecated.nsh 2014-10-07 20:09:51.000000000 +0000 @@ -2,6 +2,7 @@ ; 95.0 Delete "$SMPROGRAMS\${PRODUCT_NAME}\Test Spring MT.lnk" Delete "$SMPROGRAMS\${PRODUCT_NAME}\Test Spring MT (safemode).lnk" + Delete "$INSTDIR\spring-multithreaded.exe" ; Old DLLs, not needed anymore ; (python upgraded to 25) @@ -34,6 +35,9 @@ RmDir "$INSTDIR\mods" + ; Demofile file association (with multiengine support this doesn't work as current spring can't run old demos) + !insertmacro APP_UNASSOCIATE "sdf" "spring.demofile" + ; deprecated Shortcuts Delete "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall.lnk" Delete "$SMPROGRAMS\${PRODUCT_NAME}\Website.lnk" diff -Nru spring-96.0~14.04~ppa4/installer/sections/main.nsh spring-98.0~14.04~ppa6/installer/sections/main.nsh --- spring-96.0~14.04~ppa4/installer/sections/main.nsh 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/installer/sections/main.nsh 2014-10-07 20:09:51.000000000 +0000 @@ -3,6 +3,15 @@ SetOutPath "$INSTDIR" SetOverWrite on + ${If} ${FileExists} "$INSTDIR\uninst.exe" + MessageBox MB_ICONINFORMATION|MB_YESNO "Spring is already installed in this directory, do you want to uninstall it before continueing?" /SD IDYES IDNO fail + ExecWait '"$INSTDIR\uninst.exe" /S _?=$INSTDIR' $0 + ${If} $0 != 0 + fail: + Abort "Uninstallation failed, please choose a different installation Directory or cleanup the destination directory." + ${EndIf} + ${EndIf} + ${!echonow} "Processing: engine" !insertmacro extractFile "${MIN_PORTABLE_ARCHIVE}" "spring_engine.7z" "" @@ -12,16 +21,16 @@ ${!echonow} "Processing: main: demo file association" ${If} $REGISTRY = 1 - ${If} ${FileExists} "$INSTDIR\spring.exe" - ; Demofile file association - !insertmacro APP_ASSOCIATE "sdf" "spring.demofile" "Spring demo file" \ - "$INSTDIR\spring.exe,0" "Open with Spring" "$\"$INSTDIR\spring.exe$\" $\"%1$\"" - !insertmacro UPDATEFILEASSOC - ; we don't add here $INSTDIR directly to registry, because file-structure will change in future - ; please use this values directly without modifying them - WriteRegStr ${PRODUCT_ROOT_KEY} ${PRODUCT_KEY} "SpringEngineHelper" "$INSTDIR\unitsync.dll" - WriteRegStr ${PRODUCT_ROOT_KEY} ${PRODUCT_KEY} "SpringEngine" "$INSTDIR\spring.exe" - ${EndIf} + ; we don't add here $INSTDIR directly to registry, because file-structure will change in future + ; please use this values directly without modifying them + WriteRegStr ${PRODUCT_ROOT_KEY} ${PRODUCT_KEY} "SpringEngineHelper" "$INSTDIR\unitsync.dll" + WriteRegStr ${PRODUCT_ROOT_KEY} ${PRODUCT_KEY} "SpringEngine" "$INSTDIR\spring.exe" + + ; link custom spring:// scheme, so we can start spring from browser + WriteRegStr HKCR "spring" "" "URL:Spring Protocol" + WriteRegStr HKCR "spring" "URL Protocol" "" + WriteRegStr HKCR "spring\DefaultIcon" "" "spring.exe,1" + WriteRegStr HKCR "spring\shell\open\command" "" "$INSTDIR\spring.exe %1" ${EndIf} !else @@ -41,11 +50,8 @@ RmDir "$INSTDIR\games" ; Registry Keys - DeleteRegValue ${PRODUCT_ROOT_KEY} ${PRODUCT_KEY} "SpringEngineHelper" - DeleteRegValue ${PRODUCT_ROOT_KEY} ${PRODUCT_KEY} "SpringEngine" - - ; Demofile file association - !insertmacro APP_UNASSOCIATE "sdf" "spring.demofile" + DeleteRegKey ${PRODUCT_ROOT_KEY} ${PRODUCT_KEY} + DeleteRegKey HKCR "spring" MessageBox MB_YESNO|MB_ICONQUESTION "Do you want me to completely remove all spring related files?$\n\ All maps, games, screenshots and your settings will be removed. $\n\ diff -Nru spring-96.0~14.04~ppa4/README.markdown spring-98.0~14.04~ppa6/README.markdown --- spring-96.0~14.04~ppa4/README.markdown 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/README.markdown 2014-10-07 20:09:51.000000000 +0000 @@ -1,4 +1,5 @@ # Spring RTS game engine +[![Build Status](https://travis-ci.org/spring/spring.svg?branch=develop)](https://travis-ci.org/spring/spring) ## README diff -Nru spring-96.0~14.04~ppa4/rts/aGui/Button.cpp spring-98.0~14.04~ppa6/rts/aGui/Button.cpp --- spring-96.0~14.04~ppa4/rts/aGui/Button.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/aGui/Button.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -3,7 +3,7 @@ #include "Button.h" #include "Gui.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Rendering/GL/myGL.h" #include "System/Log/ILog.h" @@ -64,7 +64,7 @@ case SDL_MOUSEBUTTONDOWN: { if ((ev.button.button == SDL_BUTTON_LEFT) && MouseOver(ev.button.x, ev.button.y) - && gui->MouseOverElement(GetRoot(), ev.motion.x, ev.motion.y)) + && gui->MouseOverElement(GetRoot(), ev.button.x, ev.button.y)) { clicked = true; } diff -Nru spring-96.0~14.04~ppa4/rts/aGui/CMakeLists.txt spring-98.0~14.04~ppa6/rts/aGui/CMakeLists.txt --- spring-96.0~14.04~ppa4/rts/aGui/CMakeLists.txt 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/aGui/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -1,5 +1,5 @@ -include_directories(${SDL_INCLUDE_DIR}) +include_directories(${SDL2_INCLUDE_DIR}) include_directories(${GLEW_INCLUDE_DIR}) # This list was created using this *nix shell command: # > find . -name "*.cpp"" | sort diff -Nru spring-96.0~14.04~ppa4/rts/aGui/LineEdit.cpp spring-98.0~14.04~ppa6/rts/aGui/LineEdit.cpp --- spring-96.0~14.04~ppa4/rts/aGui/LineEdit.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/aGui/LineEdit.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -3,7 +3,7 @@ #include "LineEdit.h" #include "Rendering/GL/myGL.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "System/Misc/SpringTime.h" @@ -62,15 +62,15 @@ if (hasFocus) { // draw the caret const std::string caretStr = tempText.substr(0, cursorPos); - const float caretWidth = font->GetSize() * font->GetTextWidth(caretStr) / float(screensize[0]); + float caretWidth = font->GetSize() * font->GetTextWidth(caretStr) / float(screensize[0]); char c = tempText[cursorPos]; if (c == 0) { c = ' '; } - const float cursorHeight = font->GetSize() * font->GetLineHeight() / float(screensize[1]); - const float cw = font->GetSize() * font->GetCharacterWidth(c) /float(screensize[0]); - const float csx = pos[0] + 0.01 + caretWidth; - const float f = 0.5f * (1.0f + fastmath::sin(spring_now().toMilliSecsf() * 0.015f)); + float cursorHeight = font->GetSize() * font->GetLineHeight() / float(screensize[1]); + float cw = font->GetSize() * font->GetCharacterWidth(c) /float(screensize[0]); + float csx = pos[0] + 0.01 + caretWidth; + float f = 0.5f * (1.0f + fastmath::sin(spring_now().toMilliSecsf() * 0.015f)); glColor4f(f, f, f, opacity); glRectf(csx, textCenter + cursorHeight/2, csx + cw, textCenter - cursorHeight/2); glColor4f(0.0f, 0.0f, 0.0f, 1.0f); // black @@ -139,7 +139,7 @@ } default: { - uint16_t currentUnicode = ev.key.keysym.unicode; + auto currentUnicode = ev.key.keysym.sym; // only ASCII supported ATM if ((currentUnicode >= 32) && (currentUnicode <= 126)) { char buf[2] = { (const char)currentUnicode, 0 }; diff -Nru spring-96.0~14.04~ppa4/rts/aGui/List.cpp spring-98.0~14.04~ppa6/rts/aGui/List.cpp --- spring-96.0~14.04~ppa4/rts/aGui/List.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/aGui/List.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,10 +2,9 @@ #include "List.h" -#include #include -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Rendering/GlobalRendering.h" #include "Rendering/GL/myGL.h" #include "Game/GlobalUnsynced.h" @@ -70,7 +69,7 @@ items.push_back(name); // calculate width of text and resize box if necessary - const float w = itemFontScale * font->GetSize() * font->GetTextWidth(name) * screensize[0] + 2 * itemSpacing; + float w = itemFontScale * font->GetSize() * font->GetTextWidth(name) * screensize[0] + 2 * itemSpacing; if (w > (size[0])) { //box.x1 = 0.5f - 0.5f * w; @@ -88,13 +87,6 @@ MouseUpdate(x, y); // make sure place is up to date break; } - case SDL_BUTTON_WHEELDOWN: - ScrollDownOne(); - break; - - case SDL_BUTTON_WHEELUP: - ScrollUpOne(); - break; } return false; } @@ -309,16 +301,7 @@ { switch (ev.type) { case SDL_MOUSEBUTTONDOWN: { - if (gui->MouseOverElement(GetRoot(), ev.motion.x, ev.motion.y)) - { - if(!hasFocus) { - hasFocus = true; - MouseMove(ev.motion.x, ev.motion.y, ev.motion.xrel, ev.motion.yrel, ev.motion.state); - } - } - else { - hasFocus = false; - } + hasFocus = gui->MouseOverElement(GetRoot(), ev.button.x, ev.button.y); if(MouseOver(ev.button.x, ev.button.y)) { if(hasFocus) { MousePress(ev.button.x, ev.button.y, ev.button.button); @@ -337,10 +320,22 @@ } break; } + case SDL_MOUSEWHEEL: { + int mousex, mousey; + SDL_GetMouseState(&mousex, &mousey); + if(hasFocus && MouseOver(mousex, mousey)) { + if (ev.wheel.y > 0) { + ScrollUpOne(); + } else { + ScrollDownOne(); + } + return true; + } + } break; case SDL_MOUSEMOTION: { if (!hasFocus) break; - if (MouseOver(ev.button.x, ev.button.y) || activeScrollbar) + if (MouseOver(ev.motion.x, ev.motion.y) || activeScrollbar) { MouseMove(ev.motion.x, ev.motion.y, ev.motion.xrel, ev.motion.yrel, ev.motion.state); return true; @@ -412,7 +407,7 @@ topIndex = std::max(0, place - NumDisplay()/2); } -bool List::KeyPressed(unsigned short k, bool isRepeat) +bool List::KeyPressed(int k, bool isRepeat) { if (k == SDLK_ESCAPE) { if (cancelPlace >= 0) { diff -Nru spring-96.0~14.04~ppa4/rts/aGui/List.h spring-98.0~14.04~ppa6/rts/aGui/List.h --- spring-96.0~14.04~ppa4/rts/aGui/List.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/aGui/List.h 2014-10-07 20:09:51.000000000 +0000 @@ -21,7 +21,7 @@ virtual ~List(); // CInputReceiver implementation - bool KeyPressed(unsigned short k, bool isRepeat); + bool KeyPressed(int k, bool isRepeat); bool MousePress(int x, int y, int button); void MouseMove(int x, int y, int dx,int dy, int button); void MouseRelease(int x, int y, int button); diff -Nru spring-96.0~14.04~ppa4/rts/aGui/TextElement.cpp spring-98.0~14.04~ppa6/rts/aGui/TextElement.cpp --- spring-96.0~14.04~ppa4/rts/aGui/TextElement.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/aGui/TextElement.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,7 +2,7 @@ #include "TextElement.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" namespace agui { @@ -23,7 +23,8 @@ font->SetTextColor(1.0f, 1.0f, 1.0f, opacity); font->SetOutlineColor(0.0f, 0.0f, 0.0f, opacity); std::string mytext = text; - font->WrapInPlace(mytext, font->GetSize(), GlToPixelX(size[0]), GlToPixelY(size[1])); + CglFont* f=font; + f->WrapInPlace(mytext, font->GetSize(), GlToPixelX(size[0]), GlToPixelY(size[1])); font->glPrint(pos[0]+size[0]/2, pos[1]+size[1]/2, 1.f, FONT_CENTER | FONT_VCENTER | FONT_SHADOW | FONT_SCALE | FONT_NORM, mytext); font->End(); } diff -Nru spring-96.0~14.04~ppa4/rts/aGui/Window.cpp spring-98.0~14.04~ppa6/rts/aGui/Window.cpp --- spring-96.0~14.04~ppa4/rts/aGui/Window.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/aGui/Window.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -3,7 +3,7 @@ #include "Window.h" #include "Rendering/GL/myGL.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" namespace agui { diff -Nru spring-96.0~14.04~ppa4/rts/build/cmake/FindAsciiDoc.cmake spring-98.0~14.04~ppa6/rts/build/cmake/FindAsciiDoc.cmake --- spring-96.0~14.04~ppa4/rts/build/cmake/FindAsciiDoc.cmake 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/build/cmake/FindAsciiDoc.cmake 2014-10-07 20:09:51.000000000 +0000 @@ -41,6 +41,7 @@ PATH_SUFFIXES xml/docbook/stylesheet/nwalsh/manpages sgml/docbook/xsl-stylesheets/manpages + xsl/docbook/manpages DOC "DocBook XSL Style-Sheet" ) diff -Nru spring-96.0~14.04~ppa4/rts/build/cmake/FindFontConfig.cmake spring-98.0~14.04~ppa6/rts/build/cmake/FindFontConfig.cmake --- spring-96.0~14.04~ppa4/rts/build/cmake/FindFontConfig.cmake 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/build/cmake/FindFontConfig.cmake 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,32 @@ +# This file is part of the Spring engine (GPL v2 or later), see LICENSE.html + +# - Find the FontConfig library +# Find the FontConfig includes and library +# +# FONTCONFIG_INCLUDE_DIR - where to find fontconfig.h etc. +# FONTCONFIG_LIBRARIES - List of libraries when using fontconfig. +# FONTCONFIG_FOUND - True if fontconfig was found. + +Include(FindPackageHandleStandardArgs) + +If (FONTCONFIG_INCLUDE_DIR) + # Already in cache, be silent + Set(FONTCONFIG_FIND_QUIETLY TRUE) +EndIf (FONTCONFIG_INCLUDE_DIR) + +Find_Path(FONTCONFIG_INCLUDE_DIR fontconfig/fontconfig.h) + +Set(FONTCONFIG_NAMES fontconfig fontconfig-1) +Find_Library(FONTCONFIG_LIBRARY NAMES ${FONTCONFIG_NAMES}) + +# handle the QUIETLY and REQUIRED arguments and set FONTCONFIG_FOUND to TRUE if +# all listed variables are TRUE +Find_Package_Handle_Standard_Args(FONTCONFIG DEFAULT_MSG FONTCONFIG_LIBRARY FONTCONFIG_INCLUDE_DIR) + +If (FONTCONFIG_FOUND) + Set(FONTCONFIG_LIBRARIES ${FONTCONFIG_LIBRARY}) +Else (FONTCONFIG_FOUND) + Set(FONTCONFIG_LIBRARIES) +EndIf (FONTCONFIG_FOUND) + +Mark_As_Advanced(FONTCONFIG_LIBRARY FONTCONFIG_INCLUDE_DIR) diff -Nru spring-96.0~14.04~ppa4/rts/build/cmake/FindGLEW.cmake spring-98.0~14.04~ppa6/rts/build/cmake/FindGLEW.cmake --- spring-96.0~14.04~ppa4/rts/build/cmake/FindGLEW.cmake 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/build/cmake/FindGLEW.cmake 2014-10-07 20:09:51.000000000 +0000 @@ -19,11 +19,11 @@ NAMES GL/glew.h PATHS - ${PROJECT_BINARY_DIR}/include - ${PROJECT_SOURCE_DIR}/include $ENV{CPATH} /usr/include /usr/local/include + ${PROJECT_BINARY_DIR}/include + ${PROJECT_SOURCE_DIR}/include NO_DEFAULT_PATH ) FIND_PATH(GLEW_INCLUDE_DIR NAMES GL/glew.h) @@ -32,16 +32,16 @@ NAMES GLEW PATHS - ${PROJECT_BINARY_DIR}/lib64 - ${PROJECT_BINARY_DIR}/lib - ${PROJECT_SOURCE_DIR}/lib64 - ${PROJECT_SOURCE_DIR}/lib $ENV{LD_LIBRARY_PATH} $ENV{LIBRARY_PATH} /usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib + ${PROJECT_BINARY_DIR}/lib64 + ${PROJECT_BINARY_DIR}/lib + ${PROJECT_SOURCE_DIR}/lib64 + ${PROJECT_SOURCE_DIR}/lib NO_DEFAULT_PATH ) IF (WIN32) diff -Nru spring-96.0~14.04~ppa4/rts/build/cmake/FindSDL2.cmake spring-98.0~14.04~ppa6/rts/build/cmake/FindSDL2.cmake --- spring-96.0~14.04~ppa4/rts/build/cmake/FindSDL2.cmake 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/build/cmake/FindSDL2.cmake 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,204 @@ +# Locate SDL2 library +# This module defines +# SDL2_LIBRARY, the name of the library to link against +# SDL2_FOUND, if false, do not try to link to SDL2 +# SDL2_INCLUDE_DIR, where to find SDL.h +# SDL2_VERSION_STRING the version found +# +# This module responds to the the flag: +# SDL2_BUILDING_LIBRARY +# If this is defined, then no SDL2_main will be linked in because +# only applications need main(). +# Otherwise, it is assumed you are building an application and this +# module will attempt to locate and set the the proper link flags +# as part of the returned SDL2_LIBRARY variable. +# +# Don't forget to include SDL2main.h and SDL2main.m your project for the +# OS X framework based version. (Other versions link to -lSDL2main which +# this module will try to find on your behalf.) Also for OS X, this +# module will automatically add the -framework Cocoa on your behalf. +# +# +# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your configuration +# and no SDL2_LIBRARY, it means CMake did not find your SDL2 library +# (SDL2.dll, libsdl2.so, SDL2.framework, etc). +# Set SDL2_LIBRARY_TEMP to point to your SDL2 library, and configure again. +# Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value +# as appropriate. These values are used to generate the final SDL2_LIBRARY +# variable, but when these values are unset, SDL2_LIBRARY does not get created. +# +# +# $SDL2DIR is an environment variable that would +# correspond to the ./configure --prefix=$SDL2DIR +# used in building SDL2. +# l.e.galup 9-20-02 +# +# Modified by Eric Wing. +# Added code to assist with automated building by using environmental variables +# and providing a more controlled/consistent search behavior. +# Added new modifications to recognize OS X frameworks and +# additional Unix paths (FreeBSD, etc). +# Also corrected the header search path to follow "proper" SDL2 guidelines. +# Added a search for SDL2main which is needed by some platforms. +# Added a search for threads which is needed by some platforms. +# Added needed compile switches for MinGW. +# +# On OSX, this will prefer the Framework version (if found) over others. +# People will have to manually change the cache values of +# SDL2_LIBRARY to override this selection or set the CMake environment +# CMAKE_INCLUDE_PATH to modify the search paths. +# +# Note that the header path has changed from SDL2/SDL.h to just SDL.h +# This needed to change because "proper" SDL2 convention +# is #include "SDL.h", not . This is done for portability +# reasons because not all systems place things in SDL2/ (see FreeBSD). +# +# Ported by Johnny Patterson. This is a literal port for SDL2 of the FindSDL.cmake +# module with the minor edit of changing "SDL" to "SDL2" where necessary. This +# was not created for redistribution, and exists temporarily pending official +# SDL2 CMake modules. + + +#============================================================================= +# Copyright 2003-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + + +FIND_PATH(SDL2_INCLUDE_DIR SDL.h + HINTS + $ENV{SDL2DIR} + PATH_SUFFIXES include/SDL2 include + PATHS + ~/Library/Frameworks + /Library/Frameworks + /usr/local/include/SDL2 + /usr/include/SDL2 + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt +) + +if(SDL2_INCLUDE_DIR AND EXISTS "${SDL2_INCLUDE_DIR}/SDL_version.h") + file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+[0-9]+$") + file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MINOR_VERSION[ \t]+[0-9]+$") + file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_PATCHLEVEL[ \t]+[0-9]+$") + string(REGEX REPLACE "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_VERSION_MAJOR "${SDL2_VERSION_MAJOR_LINE}") + string(REGEX REPLACE "^#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_VERSION_MINOR "${SDL2_VERSION_MINOR_LINE}") + string(REGEX REPLACE "^#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_VERSION_PATCH "${SDL2_VERSION_PATCH_LINE}") + set(SDL2_VERSION_STRING ${SDL_VERSION_MAJOR}.${SDL_VERSION_MINOR}.${SDL_VERSION_PATCH}) + unset(SDL2_VERSION_MAJOR_LINE) + unset(SDL2_VERSION_MINOR_LINE) + unset(SDL2_VERSION_PATCH_LINE) + unset(SDL2_VERSION_MAJOR) + unset(SDL2_VERSION_MINOR) + unset(SDL2_VERSION_PATCH) +endif() + + + +FIND_LIBRARY(SDL2_LIBRARY_TEMP + NAMES SDL2 + HINTS + $ENV{SDL2DIR} + PATH_SUFFIXES lib64 lib + PATHS + /sw + /opt/local + /opt/csw + /opt +) + +IF(NOT SDL2_BUILDING_LIBRARY) + IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework") + # Non-OS X framework versions expect you to also dynamically link to + # SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms + # seem to provide SDL2main for compatibility even though they don't + # necessarily need it. + FIND_LIBRARY(SDL2MAIN_LIBRARY + NAMES SDL2main + HINTS + $ENV{SDL2DIR} + PATH_SUFFIXES lib64 lib + PATHS + /sw + /opt/local + /opt/csw + /opt + ) + ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework") +ENDIF(NOT SDL2_BUILDING_LIBRARY) + + +# SDL2 may require threads on your system. +# The Apple build may not need an explicit flag because one of the +# frameworks may already provide it. +# But for non-OSX systems, I will use the CMake Threads package. +IF(NOT APPLE) + FIND_PACKAGE(Threads) +ENDIF(NOT APPLE) + + +# MinGW needs an additional library, mwindows +# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -lmwindows +# (Actually on second look, I think it only needs one of the m* libraries.) +IF(MINGW) + SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW") +ENDIF(MINGW) + + +SET(SDL2_FOUND "NO") +IF(SDL2_LIBRARY_TEMP) + SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found") + SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} CACHE INTERNAL "") + + # For SDL2main + IF(NOT SDL2_BUILDING_LIBRARY) + IF(SDL2MAIN_LIBRARY) + SET(SDL2_LIBRARY ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY}) + ENDIF(SDL2MAIN_LIBRARY) + ENDIF(NOT SDL2_BUILDING_LIBRARY) + + + # For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa. + # CMake doesn't display the -framework Cocoa string in the UI even + # though it actually is there if I modify a pre-used variable. + # I think it has something to do with the CACHE STRING. + # So I use a temporary variable until the end so I can set the + # "real" variable in one-shot. + IF(APPLE) + SET(SDL2_LIBRARY ${SDL2_LIBRARY} "-framework Cocoa") + ENDIF(APPLE) + + + # For threads, as mentioned Apple doesn't need this. + # In fact, there seems to be a problem if I used the Threads package + # and try using this line, so I'm just skipping it entirely for OS X. + IF(NOT APPLE) + SET(SDL2_LIBRARY ${SDL2_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) + ENDIF(NOT APPLE) + + + # For MinGW library + IF(MINGW) + SET(SDL2_LIBRARY ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP}) + ENDIF(MINGW) + + SET(SDL2_FOUND "YES") +ENDIF(SDL2_LIBRARY_TEMP) + + +INCLUDE(FindPackageHandleStandardArgs) + + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 + REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR SDL2_VERSION_STRING) diff -Nru spring-96.0~14.04~ppa4/rts/build/cmake/FindSevenZip.cmake spring-98.0~14.04~ppa6/rts/build/cmake/FindSevenZip.cmake --- spring-96.0~14.04~ppa4/rts/build/cmake/FindSevenZip.cmake 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/build/cmake/FindSevenZip.cmake 2014-10-07 20:09:51.000000000 +0000 @@ -18,12 +18,17 @@ # 7zr(.exe) only supports 7z archives, while 7z(.exe) and 7za(.exe) # additionally support many other formats (eg zip) + +# cmake 3 doesn't allow () in var names, workarround it: +set(progfilesx86 "ProgramFiles(x86)") + find_program(SEVENZIP_BIN NAMES 7z 7za - HINTS "${MINGWDIR}" "${MINGWLIBS}/bin" "$ENV{ProgramFiles(x86)}/7-zip" "$ENV{ProgramFiles}/7-zip" "$ENV{ProgramW6432}/7-zip" + HINTS "${MINGWDIR}" "${MINGWLIBS}/bin" "$ENV{${progfilesx86}}/7-zip" "$ENV{ProgramFiles}/7-zip" "$ENV{ProgramW6432}/7-zip" PATH_SUFFIXES bin DOC "7zip executable" ) +unset(progfilesx86) # handle the QUIETLY and REQUIRED arguments and set SEVENZIP_FOUND to TRUE if # all listed variables are TRUE FIND_PACKAGE_HANDLE_STANDARD_ARGS(SevenZip DEFAULT_MSG SEVENZIP_BIN) diff -Nru spring-96.0~14.04~ppa4/rts/build/cmake/Util.cmake spring-98.0~14.04~ppa6/rts/build/cmake/Util.cmake --- spring-96.0~14.04~ppa4/rts/build/cmake/Util.cmake 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/build/cmake/Util.cmake 2014-10-07 20:09:51.000000000 +0000 @@ -27,7 +27,7 @@ # * GetVersionPlusDepFile # * GetNativeSourcesRecursive # * CheckMinCMakeVersion -# +# * MakeGlobalVar If (CMAKE_HOST_WIN32) @@ -59,6 +59,7 @@ if (CMAKE_SIZEOF_VOID_P EQUAL 8) # add fpic flag on 64 bit platforms Set(PIC_FLAG "-fpic") else () #no fpic needed on 32bit + set(CMAKE_POSITION_INDEPENDENT_CODE FALSE) Set(PIC_FLAG "") endif() EndIf () @@ -272,3 +273,34 @@ String(REGEX REPLACE "${pattern}" "\\${group}" ${var} "${str}") EndIf () EndMacro (CatchRegexGroup) + + +# macro that adds "freetype-6 freetype6" to find_library on win32 +Macro(FindFreetypeHack) + if(WIN32) + +PREFER_STATIC_LIBS() +find_library(FREETYPE_LIBRARY + NAMES freetype libfreetype freetype219 freetype-6 freetype6 + HINTS + ENV FREETYPE_DIR + PATH_SUFFIXES lib + PATHS + /usr/X11R6 + /usr/local/X11R6 + /usr/local/X11 + /usr/freeware +) +UNPREFER_STATIC_LIBS() + endif() +EndMacro() + + +# make a var global (not cached in CMakeCache.txt!) +# both calls are required, else the variable is empty +# http://www.cmake.org/Bug/view.php?id=15093 +macro(MakeGlobalVar varname) + set(${varname} ${ARGN} PARENT_SCOPE) + set(${varname} ${ARGN}) +endmacro() + diff -Nru spring-96.0~14.04~ppa4/rts/build/cmake/UtilGit.cmake spring-98.0~14.04~ppa6/rts/build/cmake/UtilGit.cmake --- spring-96.0~14.04~ppa4/rts/build/cmake/UtilGit.cmake 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/build/cmake/UtilGit.cmake 2014-10-07 20:09:51.000000000 +0000 @@ -70,7 +70,7 @@ # may be used. # Example tag patterns: all tags:"*", spring-version-tags:"*.*.*" Macro (Git_Util_Describe var dir tagPattern) - Git_Util_Command(${var} "${dir}" describe --tags --candidates 999 --match "${tagPattern}" ${ARGN}) + Git_Util_Command(${var} "${dir}" describe --tags --always --candidates 999 --match "${tagPattern}" ${ARGN}) EndMacro (Git_Util_Describe) diff -Nru spring-96.0~14.04~ppa4/rts/build/cmake/UtilVersion.cmake spring-98.0~14.04~ppa6/rts/build/cmake/UtilVersion.cmake --- spring-96.0~14.04~ppa4/rts/build/cmake/UtilVersion.cmake 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/build/cmake/UtilVersion.cmake 2014-10-07 20:09:51.000000000 +0000 @@ -149,7 +149,7 @@ EndIf (NOT GIT_FOUND) # Fetch git version info - Git_Util_Describe(${prefix}_Describe ${dir} "*.*") + Git_Util_Describe(${prefix}_Describe ${dir} "*") If (NOT ${prefix}_Describe) Message(FATAL_ERROR "Failed to fetch git-describe for ${prefix}.") EndIf (NOT ${prefix}_Describe) @@ -161,7 +161,7 @@ If (NOT ${prefix}_IsRelease) # We always want the long git-describe output on non-releases # for example: 83.0.1-0-g1234567 - Git_Util_Describe(${prefix}_Describe ${dir} "*.*" --long) + Git_Util_Describe(${prefix}_Describe ${dir} "*" --long) EndIf (NOT ${prefix}_IsRelease) Git_Util_Branch(${prefix}_Branch ${dir}) @@ -188,6 +188,13 @@ Message(STATUS "${prefix} version fetched from VERSION file: ${${prefix}_VERSION}") EndIf (${${prefix}_VERSION-NOTFOUND}) EndIf (EXISTS "${dir}/.git") -EndMacro (FetchSpringVersion) + if(DEFINED ENV{CI}) + Message(STATUS "Build on travis-ci detected, not checking version (git clone --depth=...)") + else() + if(NOT "${${prefix}_VERSION}" MATCHES "^${VERSION_REGEX_ANY}$") + Message(FATAL_ERROR "Invalid version format: ${${prefix}_VERSION}") + endif() + endif() +EndMacro (FetchSpringVersion) diff -Nru spring-96.0~14.04~ppa4/rts/builds/CMakeLists.txt spring-98.0~14.04~ppa6/rts/builds/CMakeLists.txt --- spring-96.0~14.04~ppa4/rts/builds/CMakeLists.txt 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/builds/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -1,6 +1,6 @@ ### builds # -# Macros and fucntions defined in this file: +# Macros and functions defined in this file: # * CreateEngineBuildAndInstallTarget # @@ -19,12 +19,17 @@ set(myBuildTarget spring-${targetName}) set(${targetName}-Deps engine-${targetName} - manpages - userdocs - gamedata + basecontent unitsync ${DEPS_AI_ALL} ) + if (CREATE_MAN_PAGES) + LIST(APPEND ${targetName}-Deps manpages) + endif() + if (userdoc_INSTALL_HTML) + LIST(APPEND ${targetName}-Deps userdocs) + endif() + # Create a custom meta build target add_custom_target(${myBuildTarget} WORKING_DIRECTORY @@ -82,9 +87,7 @@ IF (WIN32 AND MINGW) SET(ENGINE_ICON "${ENGINE_SRC_ROOT_DIR}/icon.rc") ENDIF (WIN32 AND MINGW) - # spring-multithreaded is unmaintained / doesn't compile - # AddEngineBuild(multithreaded) ## ASIM GML OMP - AddEngineBuild(legacy) ## OMP + AddEngineBuild(legacy) endif (NOT HEADLESS_SYSTEM) AddEngineBuild(dedicated) diff -Nru spring-96.0~14.04~ppa4/rts/builds/dedicated/CMakeLists.txt spring-98.0~14.04~ppa6/rts/builds/dedicated/CMakeLists.txt --- spring-96.0~14.04~ppa4/rts/builds/dedicated/CMakeLists.txt 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/builds/dedicated/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -50,12 +50,12 @@ # OS X: # Cocoa requires the SDL libary, whenever the SDL headers are used, # due to some #define magic, which is practically impossible to workaround. - FIND_PACKAGE(SDL REQUIRED) - INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR}) + FIND_PACKAGE(SDL2 REQUIRED) + INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR}) ELSE (MINGW OR APPLE) # Use a direct copy of the GL and SDL headers, # as these may not be available on headless systems. - INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/SDL) + INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/SDL2) ENDIF (MINGW OR APPLE) @@ -69,6 +69,7 @@ ### Assemble sources IF (UNIX) SET(sources_engine_Platform_CrashHandler + ${ENGINE_SRC_ROOT_DIR}/System/Platform/CpuID.cpp ${ENGINE_SRC_ROOT_DIR}/System/Platform/Threading.cpp ${ENGINE_SRC_ROOT_DIR}/System/Platform/Linux/thread_backtrace.cpp ${ENGINE_SRC_ROOT_DIR}/System/Platform/Linux/CrashHandler.cpp) @@ -78,6 +79,7 @@ ${ENGINE_SRC_ROOT_DIR}/System/Platform/Win/CrashHandler.cpp) ELSE () SET(sources_engine_Platform_CrashHandler + ${ENGINE_SRC_ROOT_DIR}/System/Platform/CpuID.cpp ${ENGINE_SRC_ROOT_DIR}/System/Platform/Threading.cpp ${ENGINE_SRC_ROOT_DIR}/System/Platform/Mac/CrashHandler.cpp) ENDIF () @@ -93,8 +95,9 @@ ${ENGINE_SRC_ROOT_DIR}/System/Config/ConfigVariable.cpp ${ENGINE_SRC_ROOT_DIR}/System/CRC.cpp ${ENGINE_SRC_ROOT_DIR}/System/Platform/errorhandler.cpp - ${ENGINE_SRC_ROOT_DIR}/System/Platform/Misc.cpp ${ENGINE_SRC_ROOT_DIR}/System/Platform/CmdLineParams.cpp + ${ENGINE_SRC_ROOT_DIR}/System/Platform/CpuID.cpp + ${ENGINE_SRC_ROOT_DIR}/System/Platform/Misc.cpp ${ENGINE_SRC_ROOT_DIR}/System/Platform/ScopedFileLock.cpp ${ENGINE_SRC_ROOT_DIR}/System/Platform/Threading.cpp ${ENGINE_SRC_ROOT_DIR}/System/TdfParser.cpp @@ -148,24 +151,21 @@ ) -# Compile dedicated server shared library -ADD_LIBRARY(springserver-static STATIC EXCLUDE_FROM_ALL ${engineDedicatedSources}) -Add_Dependencies(springserver-static generateVersionFiles) -TARGET_LINK_LIBRARIES(springserver-static ${engineDedicatedLibraries}) -IF (MINGW) - TARGET_LINK_LIBRARIES (springserver-static ${WS2_32_LIBRARY} ${IMAGEHLP_LIBRARY}) -ENDIF (MINGW) - # Compile dedicated server executable ADD_EXECUTABLE(engine-dedicated ${ENGINE_SRC_ROOT_DIR}/Map/MapParser.cpp + ${engineDedicatedSources} ${sources_engine_System_Log_sinkConsole} ${sources_engine_System_Log_sinkFile} ${sources_engine_System_Log_sinkOutputDebugString} ${ENGINE_ICON} main ) -TARGET_LINK_LIBRARIES(engine-dedicated springserver-static) +TARGET_LINK_LIBRARIES(engine-dedicated ${engineDedicatedLibraries}) +IF (MINGW) + TARGET_LINK_LIBRARIES(engine-dedicated ${WS2_32_LIBRARY} ${IMAGEHLP_LIBRARY} ${WINMM_LIBRARY}) +ENDIF (MINGW) +Add_Dependencies(engine-dedicated generateVersionFiles) INSTALL(TARGETS engine-dedicated DESTINATION ${BINDIR}) @@ -173,16 +173,5 @@ # use cases: # * make spring-dedicated # * make install-spring-dedicated -set(springDsDeps - engine-dedicated - springserver - gamedata - unitsync - ) -set(springDsInstallDirs - "rts/builds/dedicated" - "tools/unitsync" - "cont" - ) CreateEngineBuildAndInstallTarget(dedicated) -add_dependencies(spring-dedicated springDsDeps springDsInstallDirs) + diff -Nru spring-96.0~14.04~ppa4/rts/builds/dedicated/main.cpp spring-98.0~14.04~ppa6/rts/builds/dedicated/main.cpp --- spring-96.0~14.04~ppa4/rts/builds/dedicated/main.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/builds/dedicated/main.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -166,7 +166,7 @@ if (!fh.LoadStringData(scriptText)) throw content_error("script cannot be read: " + scriptName); - settings.Init(scriptText); + settings.LoadFromStartScript(scriptText); gameSetup = new CGameSetup(); // to store the gamedata inside if (!gameSetup->Init(scriptText)) { diff -Nru spring-96.0~14.04~ppa4/rts/builds/headless/CMakeLists.txt spring-98.0~14.04~ppa6/rts/builds/headless/CMakeLists.txt --- spring-96.0~14.04~ppa4/rts/builds/headless/CMakeLists.txt 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/builds/headless/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -12,6 +12,7 @@ ADD_DEFINITIONS(-DBITMAP_NO_OPENGL) REMOVE_DEFINITIONS(-DAVI_CAPTURING) +include_directories(${OPENAL_INCLUDE_DIR}) IF (MINGW OR APPLE) # Windows: # We still need these header files, @@ -21,30 +22,31 @@ # Cocoa requires the SDL libary, whenever the SDL headers are used, # due to some #define magic, which is practically impossible to workaround. FIND_PACKAGE(OpenGL REQUIRED) - FIND_PACKAGE(SDL REQUIRED) - INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR}) + FIND_PACKAGE(SDL2 REQUIRED) + INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR}) ELSE (MINGW OR APPLE) # Use a direct copy of the GL and SDL headers, # as these may not be available on headless systems. INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) - INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/SDL) + INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/SDL2) ENDIF (MINGW OR APPLE) # headlessstubs are our stubs that replace libGL, libGLU, libGLEW, libSDL (yes really!) LIST(APPEND engineHeadlessLibraries headlessStubs) -LIST(APPEND engineHeadlessLibraries no-sound) +LIST(APPEND engineHeadlessLibraries ${SPRING_SIM_LIBRARIES}) LIST(APPEND engineHeadlessLibraries engineSystemNet) LIST(APPEND engineHeadlessLibraries ${engineCommonLibraries}) LIST(APPEND engineHeadlessLibraries engineaGui) - +LIST(APPEND engineHeadlessLibraries no-sound) +LIST(APPEND engineHeadlessLibraries engineSim) INCLUDE_DIRECTORIES(${ENGINE_SRC_ROOT_DIR}/lib/assimp/include) ### Build the executable ADD_EXECUTABLE(engine-headless ${engineSources} ${ENGINE_ICON}) -TARGET_LINK_LIBRARIES(engine-headless ${engineHeadlessLibraries}) +TARGET_LINK_LIBRARIES(engine-headless no-sound ${engineHeadlessLibraries} no-sound) IF (MINGW) # To enable console output/force a console window to open diff -Nru spring-96.0~14.04~ppa4/rts/builds/legacy/CMakeLists.txt spring-98.0~14.04~ppa6/rts/builds/legacy/CMakeLists.txt --- spring-96.0~14.04~ppa4/rts/builds/legacy/CMakeLists.txt 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/builds/legacy/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -9,18 +9,30 @@ ### Assemble libraries -FIND_PACKAGE(SDL REQUIRED) -SET(engineIncludes ${SDL_INCLUDE_DIR}) -SET(engineLibraries ${SDL_LIBRARY}) +FIND_PACKAGE(SDL2 REQUIRED) +SET(engineIncludes ${SDL2_INCLUDE_DIR}) +SET(engineLibraries ${SDL2_LIBRARY}) FIND_PACKAGE_STATIC(OpenGL REQUIRED) FIND_PACKAGE_STATIC(GLEW 1.5.1 REQUIRED) LIST(APPEND engineLibraries ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${GLEW_LIBRARIES}) -if (MSVC) - LIST(APPEND engineIncludes ${GLEW_INCLUDE_DIR}) -endif(MSVC) +LIST(APPEND engineIncludes ${GLEW_INCLUDE_DIR}) +FIND_PACKAGE_STATIC(FontConfig) +IF (FONTCONFIG_FOUND) + LIST(APPEND engineIncludes ${FONTCONFIG_INCLUDE_DIR}) + LIST(APPEND engineLibraries ${FONTCONFIG_LIBRARIES}) + ADD_DEFINITIONS(-DUSE_FONTCONFIG) + IF (PREFER_STATIC_LIBS) + PREFER_STATIC_LIBS() + FIND_LIBRARY(EXPAT_LIBRARY expat) + UNPREFER_STATIC_LIBS() + LIST(APPEND engineLibraries ${EXPAT_LIBRARY}) + ENDIF (PREFER_STATIC_LIBS) +ENDIF (FONTCONFIG_FOUND) + +FindFreetypeHack() # hack to find different named freetype.dll FIND_PACKAGE_STATIC(Freetype REQUIRED) foreach(f ${FREETYPE_INCLUDE_DIRS}) LIST(APPEND engineIncludes ${f}) @@ -58,6 +70,8 @@ LIST(APPEND engineLibraries ${engineCommonLibraries}) LIST(APPEND engineLibraries engineaGui) LIST(APPEND engineLibraries ${Boost_THREAD_LIBRARY}) +LIST(APPEND engineLibraries ${SPRING_SIM_LIBRARIES}) +LIST(APPEND engineLibraries engineSim) ### Assemble external incude dirs LIST(APPEND engineIncludes ${OPENAL_INCLUDE_DIR}) diff -Nru spring-96.0~14.04~ppa4/rts/builds/multithreaded/CMakeLists.txt spring-98.0~14.04~ppa6/rts/builds/multithreaded/CMakeLists.txt --- spring-96.0~14.04~ppa4/rts/builds/multithreaded/CMakeLists.txt 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/builds/multithreaded/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ -# Place executables and shared libs under "build-dir/", -# instead of under "build-dir/rts/" -# This way, we have the build-dir structure more like the install-dir one, -# which makes testing spring in the builddir easier, eg. like this: -# cd build-dir -# SPRING_DATADIR=$(pwd) ./spring -SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") -SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") - - -### Assemble libraries -FIND_PACKAGE(SDL REQUIRED) -SET(engineIncludes ${SDL_INCLUDE_DIR}) -SET(engineLibraries ${SDL_LIBRARY}) - - -FIND_PACKAGE_STATIC(OpenGL REQUIRED) -FIND_PACKAGE_STATIC(GLEW 1.5.1 REQUIRED) -LIST(APPEND engineLibraries ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${GLEW_LIBRARIES}) -if (MSVC) - LIST(APPEND engineIncludes ${GLEW_INCLUDE_DIR}) -endif(MSVC) - -FIND_PACKAGE_STATIC(Freetype REQUIRED) -foreach(f ${FREETYPE_INCLUDE_DIRS}) - LIST(APPEND engineIncludes ${f}) -endforeach(f) -LIST(APPEND engineLibraries ${FREETYPE_LIBRARIES}) - -IF (PREFER_STATIC_LIBS) - # dependencies of FreeType - FIND_PACKAGE_STATIC(BZip2 REQUIRED) - LIST(APPEND engineLibraries ${BZIP2_LIBRARIES}) -ENDIF (PREFER_STATIC_LIBS) - -IF (UNIX) - FIND_PACKAGE_STATIC(X11 REQUIRED) - LIST(APPEND engineLibraries ${X11_Xcursor_LIB} ${X11_X11_LIB}) - - IF (PREFER_STATIC_LIBS) - # dependencies of X11/XCursor - FIND_PACKAGE_STATIC(XCB REQUIRED) - LIST(APPEND engineLibraries ${X11_Xrender_LIB} ${X11_Xfixes_LIB} ${XCB_LIBRARIES} ${X11_Xau_LIB} ${X11_Xdmcp_LIB}) - ENDIF (PREFER_STATIC_LIBS) -ENDIF (UNIX) - -IF (APPLE) - FIND_LIBRARY(COREFOUNDATION_LIBRARY Foundation) - LIST(APPEND engineLibraries ${COREFOUNDATION_LIBRARY}) -ENDIF (APPLE) - -if (USE_LIBSQUISH) - LIST(APPEND engineLibraries squish rgetc1) -endif (USE_LIBSQUISH) - -LIST(APPEND engineLibraries ${sound-impl}) -LIST(APPEND engineLibraries ${Boost_THREAD_LIBRARY}) -LIST(APPEND engineLibraries engineSystemNet) -LIST(APPEND engineLibraries ${engineCommonLibraries}) -LIST(APPEND engineLibraries engineaGui) - - -### Assemble external incude dirs -LIST(APPEND engineIncludes ${OPENAL_INCLUDE_DIR}) - -INCLUDE_DIRECTORIES(${engineIncludes}) - -if (MSVC) - # set vmg flag to work around small pointer-to-member bug in spring - # and enable multi-processor compiling - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /vmg /MP") -endif(MSVC) - -### Assemble defines -ADD_DEFINITIONS(-DUSE_GML) - -# USE_GML requires this -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${NO_TLS_DIRECT_SEG_REFS}") - -# USE_GML_SIM requires USE_GML -ADD_DEFINITIONS(-DUSE_GML_SIM) - -if (USE_GML_DEBUG) - ADD_DEFINITIONS(-DUSE_GML_DEBUG) -endif (USE_GML_DEBUG) - -### Build the executable -ADD_EXECUTABLE(engine-multithreaded ${EXE_FLAGS} ${engineSources} ${ENGINE_ICON} ${engineHeaders}) -TARGET_LINK_LIBRARIES(engine-multithreaded gml ${engineLibraries}) - - -### Install the executable -INSTALL(TARGETS engine-multithreaded DESTINATION ${BINDIR}) - -CreateEngineBuildAndInstallTarget(multithreaded) - diff -Nru spring-96.0~14.04~ppa4/rts/CMakeLists.txt spring-98.0~14.04~ppa6/rts/CMakeLists.txt --- spring-96.0~14.04~ppa4/rts/CMakeLists.txt 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -29,9 +29,6 @@ EndIf () endif (SYNCDEBUG) -# Only used by GML build, but used in builds/GML and lib/gml -option(USE_GML_DEBUG "Use GML call debugging?" FALSE) - ### give error when not found FIND_PACKAGE_STATIC(DevIL REQUIRED) @@ -104,7 +101,7 @@ Add_Subdirectory(Sim) #Add_Subdirectory(System) # this is already added in ../ -SET(engineSources +MakeGlobalVar(engineSources ${sources_engine_Game} ${sources_engine_Net} ${sources_engine_Lua} diff -Nru spring-96.0~14.04~ppa4/rts/ExternalAI/AICallback.cpp spring-98.0~14.04~ppa6/rts/ExternalAI/AICallback.cpp --- spring-96.0~14.04~ppa4/rts/ExternalAI/AICallback.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/ExternalAI/AICallback.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -301,16 +301,12 @@ int CAICallback::CreateGroup() { - GML_RECMUTEX_LOCK(group); // CreateGroup - const CGroup* g = gh->CreateNewGroup(); return g->id; } void CAICallback::EraseGroup(int groupId) { - GML_RECMUTEX_LOCK(group); // EraseGroup - if (CHECK_GROUPID(groupId)) { if (gh->groups[groupId]) { gh->RemoveGroup(gh->groups[groupId]); @@ -324,8 +320,6 @@ CUnit* unit = GetMyTeamUnit(unitId); if (unit) { - GML_RECMUTEX_LOCK(group); // AddUnitToGroup - if (CHECK_GROUPID(groupId) && gh->groups[groupId]) { added = unit->SetGroup(gh->groups[groupId]); } @@ -1055,7 +1049,7 @@ float CAICallback::GetElevation(float x, float z) { - return ground->GetHeightReal(x, z); + return CGround::GetHeightReal(x, z); } @@ -1144,8 +1138,6 @@ tdu.facing = facing; std::pair tp(gs->frameNum + lifetime, tdu); - GML_STDMUTEX_LOCK(temp); // DrawUnit - if (transparent) { unitDrawer->tempTransparentDrawUnits.insert(tp); } else { @@ -1454,34 +1446,33 @@ } break; case AIHCAddMapPointId: { const AIHCAddMapPoint* cmdData = static_cast(data); - net->Send(CBaseNetProtocol::Get().SendMapDrawPoint(team, (short)cmdData->pos.x, (short)cmdData->pos.z, std::string(cmdData->label), false)); + /* + TODO: gu->myPlayerNum makes the command to look like as it comes from the local player, + "team" should be used (but needs some major changes in other engine parts) + */ + net->Send(CBaseNetProtocol::Get().SendMapDrawPoint(gu->myPlayerNum, (short)cmdData->pos.x, (short)cmdData->pos.z, std::string(cmdData->label), false)); return 1; } break; case AIHCAddMapLineId: { const AIHCAddMapLine* cmdData = static_cast(data); - net->Send(CBaseNetProtocol::Get().SendMapDrawLine(team, (short)cmdData->posfrom.x, (short)cmdData->posfrom.z, (short)cmdData->posto.x, (short)cmdData->posto.z, false)); + // see TODO above + net->Send(CBaseNetProtocol::Get().SendMapDrawLine(gu->myPlayerNum, (short)cmdData->posfrom.x, (short)cmdData->posfrom.z, (short)cmdData->posto.x, (short)cmdData->posto.z, false)); return 1; } break; case AIHCRemoveMapPointId: { const AIHCRemoveMapPoint* cmdData = static_cast(data); - net->Send(CBaseNetProtocol::Get().SendMapErase(team, (short)cmdData->pos.x, (short)cmdData->pos.z)); + // see TODO above + net->Send(CBaseNetProtocol::Get().SendMapErase(gu->myPlayerNum, (short)cmdData->pos.x, (short)cmdData->pos.z)); return 1; } break; - case AIHCSendStartPosId: { - const AIHCSendStartPos* cmdData = static_cast(data); - SendStartPos(cmdData->ready, cmdData->pos); - return 1; - } break; - case AIHCGetUnitDefByIdId: { - // NOTE: this command should never arrive, handled in SSkirmishAICallbackImpl - return 0; - } break; - case AIHCGetWeaponDefByIdId: { - // NOTE: this command should never arrive, handled in SSkirmishAICallbackImpl - return 0; - } break; - case AIHCGetFeatureDefByIdId: { - // NOTE: this command should never arrive, handled in SSkirmishAICallbackImpl + case AIHCSendStartPosId: + case AIHCGetUnitDefByIdId: + case AIHCGetWeaponDefByIdId: + case AIHCGetFeatureDefByIdId: + case AIHCGetDataDirId: + { + // NOTE: these commands should never arrive, handled in SSkirmishAICallbackImpl + assert(false); return 0; } break; @@ -1547,15 +1538,6 @@ return 1; } break; - case AIHCGetDataDirId: { - // do nothing - // this event will never end up here, as - // it is handled in the C layer directly - // see Clb_DataDirs_allocatePath in rts/ExternalAI/Interface/SSkirmishAICallback.h - - return 0; - } break; - case AIHCDebugDrawId: { AIHCDebugDraw* cmdData = static_cast(data); @@ -1771,7 +1753,6 @@ verify(); int a = 0; - GML_RECMUTEX_LOCK(sel); // GetSelectedUnit // check if the allyteam of the player running // the AI lib matches the AI's actual allyteam if (gu->myAllyTeam == teamHandler->AllyTeam(team)) { diff -Nru spring-96.0~14.04~ppa4/rts/ExternalAI/AIInterfaceKey.cpp spring-98.0~14.04~ppa6/rts/ExternalAI/AIInterfaceKey.cpp --- spring-96.0~14.04~ppa4/rts/ExternalAI/AIInterfaceKey.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/ExternalAI/AIInterfaceKey.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -6,12 +6,12 @@ #include -CR_BIND(AIInterfaceKey, ); +CR_BIND(AIInterfaceKey, ) CR_REG_METADATA(AIInterfaceKey, ( CR_MEMBER(shortName), CR_MEMBER(version) - )); + )) AIInterfaceKey::AIInterfaceKey( const std::string& shortName, diff -Nru spring-96.0~14.04~ppa4/rts/ExternalAI/AIInterfaceKey.h spring-98.0~14.04~ppa6/rts/ExternalAI/AIInterfaceKey.h --- spring-96.0~14.04~ppa4/rts/ExternalAI/AIInterfaceKey.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/ExternalAI/AIInterfaceKey.h 2014-10-07 20:09:51.000000000 +0000 @@ -11,7 +11,7 @@ * Used to uniquely identify an AI Interface within the engine. */ class AIInterfaceKey { - CR_DECLARE_STRUCT(AIInterfaceKey); + CR_DECLARE_STRUCT(AIInterfaceKey) public: AIInterfaceKey( diff -Nru spring-96.0~14.04~ppa4/rts/ExternalAI/AIInterfaceLibrary.cpp spring-98.0~14.04~ppa6/rts/ExternalAI/AIInterfaceLibrary.cpp --- spring-96.0~14.04~ppa4/rts/ExternalAI/AIInterfaceLibrary.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/ExternalAI/AIInterfaceLibrary.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -19,6 +19,7 @@ , initialized(false) , info(_info) { + sAIInterfaceLibrary = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; libFilePath = FindLibFile(); diff -Nru spring-96.0~14.04~ppa4/rts/ExternalAI/AILibraryManager.cpp spring-98.0~14.04~ppa6/rts/ExternalAI/AILibraryManager.cpp --- spring-96.0~14.04~ppa4/rts/ExternalAI/AILibraryManager.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/ExternalAI/AILibraryManager.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -87,19 +87,19 @@ if (info->second.size() >= 2) { duplicateInterfaceInfos[info->first] = info->second; - if (LOG_IS_ENABLED(L_WARNING)) { - LOG_L(L_WARNING, "Duplicate AI Interface Info found:"); - LOG_L(L_WARNING, "\tfor interface: %s %s", + if (LOG_IS_ENABLED(L_ERROR)) { + LOG_L(L_ERROR, "Duplicate AI Interface Info found:"); + LOG_L(L_ERROR, "\tfor interface: %s %s", info->first.GetShortName().c_str(), info->first.GetVersion().c_str()); - LOG_L(L_WARNING, "\tin files:"); + LOG_L(L_ERROR, "\tin files:"); const std::string* lastDir = NULL; std::set::const_iterator dir; for (dir = info->second.begin(); dir != info->second.end(); ++dir) { - LOG_L(L_WARNING, "\t%s", dir->c_str()); + LOG_L(L_ERROR, "\t%s", dir->c_str()); lastDir = &(*dir); } - LOG_L(L_WARNING, "\tusing: %s", lastDir->c_str()); + LOG_L(L_ERROR, "\tusing: %s", lastDir->c_str()); } } } diff -Nru spring-96.0~14.04~ppa4/rts/ExternalAI/CMakeLists.txt spring-98.0~14.04~ppa6/rts/ExternalAI/CMakeLists.txt --- spring-96.0~14.04~ppa4/rts/ExternalAI/CMakeLists.txt 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/ExternalAI/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -21,6 +21,6 @@ "${CMAKE_CURRENT_SOURCE_DIR}/SkirmishAILibrary.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/SkirmishAILibraryInfo.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/SkirmishAIWrapper.cpp" + PARENT_SCOPE ) -MakeGlobal(sources_engine_ExternalAI) diff -Nru spring-96.0~14.04~ppa4/rts/ExternalAI/EngineOutHandler.cpp spring-98.0~14.04~ppa6/rts/ExternalAI/EngineOutHandler.cpp --- spring-96.0~14.04~ppa4/rts/ExternalAI/EngineOutHandler.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/ExternalAI/EngineOutHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -34,7 +34,7 @@ CR_MEMBER(id_skirmishAI), CR_MEMBER(team_skirmishAIs), CR_RESERVED(128) -)); +)) static inline bool IsUnitInLosOrRadarOfAllyTeam(const CUnit& unit, const int allyTeamId) { @@ -417,7 +417,7 @@ } const bool attackerInLosOrRadar = attacker && IsUnitInLosOrRadarOfAllyTeam(*attacker, damaged.allyteam); for (ids_t::iterator ai = team_skirmishAIs[dt].begin(); ai != team_skirmishAIs[dt].end(); ++ai) { - CSkirmishAIWrapper* saw = id_skirmishAI[*ai]; + const CSkirmishAIWrapper* saw = id_skirmishAI[*ai]; int visibleAttackerUnitId = -1; if (attackerInLosOrRadar || saw->IsCheatEventsEnabled()) { visibleAttackerUnitId = attackerUnitId; @@ -526,9 +526,7 @@ // send only to AI's in team for (aiIDsIter = aiIDs.begin(); aiIDsIter != aiIDs.end(); ++aiIDsIter) { - const size_t aiID = aiIDs[*aiIDsIter]; - - CSkirmishAIWrapper* wrapperAI = id_skirmishAI[aiID]; + CSkirmishAIWrapper* wrapperAI = id_skirmishAI[*aiIDsIter]; wrapperAI->SendLuaMessage(inData, &outData[n++]); } } else { diff -Nru spring-96.0~14.04~ppa4/rts/ExternalAI/EngineOutHandler.h spring-98.0~14.04~ppa6/rts/ExternalAI/EngineOutHandler.h --- spring-96.0~14.04~ppa4/rts/ExternalAI/EngineOutHandler.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/ExternalAI/EngineOutHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -23,7 +23,7 @@ void handleAIException(const char* description); class CEngineOutHandler : public CObject { - CR_DECLARE(CEngineOutHandler); + CR_DECLARE(CEngineOutHandler) ~CEngineOutHandler(); @@ -90,11 +90,6 @@ */ void DestroySkirmishAI(const size_t skirmishAIId); - - void SetCheating(bool enable); - bool IsCheating() const; - - void Load(std::istream* s); void Save(std::ostream* s); diff -Nru spring-96.0~14.04~ppa4/rts/ExternalAI/Interface/AISCommands.h spring-98.0~14.04~ppa6/rts/ExternalAI/Interface/AISCommands.h --- spring-96.0~14.04~ppa4/rts/ExternalAI/Interface/AISCommands.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/ExternalAI/Interface/AISCommands.h 2014-10-07 20:09:51.000000000 +0000 @@ -377,8 +377,7 @@ /** * Returns the approximate path cost between two points. - * - for pathType {Ground_Move=0, Hover_Move=1, Ship_Move=2}, - * @see UnitDef_MoveData_getMoveType() + * - for pathType @see UnitDef_MoveData_getPathType() * - goalRadius defines a goal area within which any square could be accepted as * path target. If a singular goal position is wanted, use 0.0f. * default: 8.0f @@ -392,7 +391,7 @@ int pathType; /// default: 8.0f float goalRadius; - int ret_approximatePathLength; + float ret_approximatePathLength; }; //$ COMMAND_PATH_GET_APPROXIMATE_LENGTH Pathing_getApproximateLength struct SGetNextWaypointPathCommand { diff -Nru spring-96.0~14.04~ppa4/rts/ExternalAI/Interface/SSkirmishAICallback.h spring-98.0~14.04~ppa6/rts/ExternalAI/Interface/SSkirmishAICallback.h --- spring-96.0~14.04~ppa4/rts/ExternalAI/Interface/SSkirmishAICallback.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/ExternalAI/Interface/SSkirmishAICallback.h 2014-10-07 20:09:51.000000000 +0000 @@ -398,6 +398,42 @@ */ void (CALLING_CONV *Game_getCategoryName)(int skirmishAIId, int categoryFlag, char* name, int name_sizeMax); + /** + * This is a set of parameters that is created by SetGameRulesParam() and may change during the game. + * Each parameter is uniquely identified only by its id (which is the index in the vector). + * Parameters may or may not have a name. + * @return visible to skirmishAIId parameters. + * If cheats are enabled, this will return all parameters. + */ + int (CALLING_CONV *Game_getGameRulesParams)(int skirmishAIId, int* paramIds, int paramIds_sizeMax); //$ FETCHER:MULTI:IDs:GameRulesParam:paramIds + + /** + * @return only visible to skirmishAIId parameter. + * If cheats are enabled, this will return parameter despite it's losStatus. + */ + int (CALLING_CONV *Game_getGameRulesParamByName)(int skirmishAIId, const char* rulesParamName); //$ REF:RETURN->GameRulesParam + + /** + * @return only visible to skirmishAIId parameter. + * If cheats are enabled, this will return parameter despite it's losStatus. + */ + int (CALLING_CONV *Game_getGameRulesParamById)(int skirmishAIId, int rulesParamId); //$ REF:RETURN->GameRulesParam + + /** + * Not every mod parameter has a name. + */ + const char* (CALLING_CONV *GameRulesParam_getName)(int skirmishAIId, int gameRulesParamId); + + /** + * @return float value of parameter if it's set, 0.0 otherwise. + */ + float (CALLING_CONV *GameRulesParam_getValueFloat)(int skirmishAIId, int gameRulesParamId); + + /** + * @return string value of parameter if it's set, empty string otherwise. + */ + const char* (CALLING_CONV *GameRulesParam_getValueString)(int skirmishAIId, int gameRulesParamId); + // END misc callback functions @@ -1192,20 +1228,40 @@ int (CALLING_CONV *Unit_getDef)(int skirmishAIId, int unitId); //$ REF:RETURN->UnitDef /** - * This is a set of parameters that is initialized - * in CreateUnitRulesParams() and may change during the game. - * Each parameter is uniquely identified only by its id - * (which is the index in the vector). + * This is a set of parameters that is created by SetUnitRulesParam() and may change during the game. + * Each parameter is uniquely identified only by its id (which is the index in the vector). * Parameters may or may not have a name. + * @return visible to skirmishAIId parameters. + * If cheats are enabled, this will return all parameters. + */ + int (CALLING_CONV *Unit_getUnitRulesParams)(int skirmishAIId, int unitId, int* paramIds, int paramIds_sizeMax); //$ FETCHER:MULTI:IDs:UnitRulesParam:paramIds + + /** + * @return only visible to skirmishAIId parameter. + * If cheats are enabled, this will return parameter despite it's losStatus. */ - int (CALLING_CONV *Unit_getModParams)(int skirmishAIId, int unitId); //$ FETCHER:MULTI:NUM:ModParam + int (CALLING_CONV *Unit_getUnitRulesParamByName)(int skirmishAIId, int unitId, const char* rulesParamName); //$ REF:RETURN->UnitRulesParam + + /** + * @return only visible to skirmishAIId parameter. + * If cheats are enabled, this will return parameter despite it's losStatus. + */ + int (CALLING_CONV *Unit_getUnitRulesParamById)(int skirmishAIId, int unitId, int rulesParamId); //$ REF:RETURN->UnitRulesParam /** * Not every mod parameter has a name. */ - const char* (CALLING_CONV *Unit_ModParam_getName)(int skirmishAIId, int unitId, int modParamId); + const char* (CALLING_CONV *Unit_UnitRulesParam_getName)(int skirmishAIId, int unitId, int unitRulesParamId); + + /** + * @return float value of parameter if it's set, 0.0 otherwise. + */ + float (CALLING_CONV *Unit_UnitRulesParam_getValueFloat)(int skirmishAIId, int unitId, int unitRulesParamId); - float (CALLING_CONV *Unit_ModParam_getValue)(int skirmishAIId, int unitId, int modParamId); + /** + * @return string value of parameter if it's set, empty string otherwise. + */ + const char* (CALLING_CONV *Unit_UnitRulesParam_getValueString)(int skirmishAIId, int unitId, int unitRulesParamId); int (CALLING_CONV *Unit_getTeam)(int skirmishAIId, int unitId); @@ -1335,6 +1391,52 @@ // END OBJECT Unit +// BEGINN OBJECT Team + bool (CALLING_CONV *Team_hasAIController)(int skirmishAIId, int teamId); + + int (CALLING_CONV *getEnemyTeams)(int skirmishAIId, int* teamIds, int teamIds_sizeMax); //$ FETCHER:MULTI:IDs:Team:teamIds + + int (CALLING_CONV *getAllyTeams)(int skirmishAIId, int* teamIds, int teamIds_sizeMax); //$ FETCHER:MULTI:IDs:Team:teamIds + + /** + * This is a set of parameters that is created by SetTeamRulesParam() and may change during the game. + * Each parameter is uniquely identified only by its id (which is the index in the vector). + * Parameters may or may not have a name. + * @return visible to skirmishAIId parameters. + * If cheats are enabled, this will return all parameters. + */ + int (CALLING_CONV *Team_getTeamRulesParams)(int skirmishAIId, int teamId, int* paramIds, int paramIds_sizeMax); //$ FETCHER:MULTI:IDs:TeamRulesParam:paramIds + + /** + * @return only visible to skirmishAIId parameter. + * If cheats are enabled, this will return parameter despite it's losStatus. + */ + int (CALLING_CONV *Team_getTeamRulesParamByName)(int skirmishAIId, int teamId, const char* rulesParamName); //$ REF:RETURN->TeamRulesParam + + /** + * @return only visible to skirmishAIId parameter. + * If cheats are enabled, this will return parameter despite it's losStatus. + */ + int (CALLING_CONV *Team_getTeamRulesParamById)(int skirmishAIId, int teamId, int rulesParamId); //$ REF:RETURN->TeamRulesParam + + /** + * Not every mod parameter has a name. + */ + const char* (CALLING_CONV *Team_TeamRulesParam_getName)(int skirmishAIId, int teamId, int teamRulesParamId); + + /** + * @return float value of parameter if it's set, 0.0 otherwise. + */ + float (CALLING_CONV *Team_TeamRulesParam_getValueFloat)(int skirmishAIId, int teamId, int teamRulesParamId); + + /** + * @return string value of parameter if it's set, empty string otherwise. + */ + const char* (CALLING_CONV *Team_TeamRulesParam_getValueString)(int skirmishAIId, int teamId, int teamRulesParamId); + +// END OBJECT Team + + // BEGINN OBJECT Group int (CALLING_CONV *getGroups)(int skirmishAIId, int* groupIds, int groupIds_sizeMax); //$ FETCHER:MULTI:IDs:Group:groupIds diff -Nru spring-96.0~14.04~ppa4/rts/ExternalAI/SkirmishAIBase.h spring-98.0~14.04~ppa6/rts/ExternalAI/SkirmishAIBase.h --- spring-96.0~14.04~ppa4/rts/ExternalAI/SkirmishAIBase.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/ExternalAI/SkirmishAIBase.h 2014-10-07 20:09:51.000000000 +0000 @@ -29,7 +29,7 @@ * It is used on the Game-Server and on clients (as a base class). */ class SkirmishAIBase : public TeamController { - CR_DECLARE(SkirmishAIBase); + CR_DECLARE(SkirmishAIBase) public: typedef std::map customOpts; @@ -52,7 +52,7 @@ */ class SkirmishAIStatistics : public TeamControllerStatistics { - CR_DECLARE_STRUCT(SkirmishAIStatistics); + CR_DECLARE_STRUCT(SkirmishAIStatistics) public: /** diff -Nru spring-96.0~14.04~ppa4/rts/ExternalAI/SkirmishAIData.cpp spring-98.0~14.04~ppa6/rts/ExternalAI/SkirmishAIData.cpp --- spring-96.0~14.04~ppa4/rts/ExternalAI/SkirmishAIData.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/ExternalAI/SkirmishAIData.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -5,22 +5,22 @@ #include "System/creg/STL_Map.h" #include "System/Platform/byteorder.h" // for swabDWord -CR_BIND_DERIVED(SkirmishAIBase, TeamController, ); +CR_BIND_DERIVED(SkirmishAIBase, TeamController, ) CR_REG_METADATA(SkirmishAIBase, ( CR_MEMBER(hostPlayer), CR_ENUM_MEMBER(status) -)); +)) -CR_BIND(SkirmishAIStatistics, ); +CR_BIND(SkirmishAIStatistics, ) CR_REG_METADATA(SkirmishAIStatistics, ( CR_MEMBER(numCommands), CR_MEMBER(unitCommands), CR_MEMBER(cpuTime) -)); +)) -CR_BIND_DERIVED(SkirmishAIData, SkirmishAIBase, ); +CR_BIND_DERIVED(SkirmishAIData, SkirmishAIBase, ) CR_REG_METADATA(SkirmishAIData, ( CR_MEMBER(shortName), CR_MEMBER(version), @@ -28,7 +28,7 @@ CR_MEMBER(options), CR_MEMBER(isLuaAI), CR_MEMBER(currentStats) -)); +)) void SkirmishAIStatistics::swab() { diff -Nru spring-96.0~14.04~ppa4/rts/ExternalAI/SkirmishAIData.h spring-98.0~14.04~ppa6/rts/ExternalAI/SkirmishAIData.h --- spring-96.0~14.04~ppa4/rts/ExternalAI/SkirmishAIData.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/ExternalAI/SkirmishAIData.h 2014-10-07 20:09:51.000000000 +0000 @@ -17,7 +17,7 @@ * @see Game/GameSetup */ class SkirmishAIData : public SkirmishAIBase { - CR_DECLARE(SkirmishAIData); + CR_DECLARE(SkirmishAIData) public: std::string shortName; diff -Nru spring-96.0~14.04~ppa4/rts/ExternalAI/SkirmishAIHandler.cpp spring-98.0~14.04~ppa6/rts/ExternalAI/SkirmishAIHandler.cpp --- spring-96.0~14.04~ppa4/rts/ExternalAI/SkirmishAIHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/ExternalAI/SkirmishAIHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -17,7 +17,7 @@ #include -CR_BIND(CSkirmishAIHandler,); +CR_BIND(CSkirmishAIHandler,) CR_REG_METADATA(CSkirmishAIHandler, ( CR_MEMBER(id_ai), @@ -27,7 +27,7 @@ CR_MEMBER(gameInitialized), CR_MEMBER(luaAIShortNames), CR_IGNORED(currentAIId) -)); +)) CSkirmishAIHandler& CSkirmishAIHandler::GetInstance() diff -Nru spring-96.0~14.04~ppa4/rts/ExternalAI/SkirmishAIHandler.h spring-98.0~14.04~ppa6/rts/ExternalAI/SkirmishAIHandler.h --- spring-96.0~14.04~ppa4/rts/ExternalAI/SkirmishAIHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/ExternalAI/SkirmishAIHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -20,7 +20,7 @@ */ class CSkirmishAIHandler { - CR_DECLARE_STRUCT(CSkirmishAIHandler); + CR_DECLARE_STRUCT(CSkirmishAIHandler) CSkirmishAIHandler(); ~CSkirmishAIHandler(); diff -Nru spring-96.0~14.04~ppa4/rts/ExternalAI/SkirmishAIKey.cpp spring-98.0~14.04~ppa6/rts/ExternalAI/SkirmishAIKey.cpp --- spring-96.0~14.04~ppa4/rts/ExternalAI/SkirmishAIKey.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/ExternalAI/SkirmishAIKey.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -6,13 +6,13 @@ #include -CR_BIND(SkirmishAIKey, ); +CR_BIND(SkirmishAIKey, ) CR_REG_METADATA(SkirmishAIKey, ( CR_MEMBER(shortName), CR_MEMBER(version), CR_MEMBER(interface) - )); + )) SkirmishAIKey::SkirmishAIKey( const std::string& shortName, diff -Nru spring-96.0~14.04~ppa4/rts/ExternalAI/SkirmishAIKey.h spring-98.0~14.04~ppa6/rts/ExternalAI/SkirmishAIKey.h --- spring-96.0~14.04~ppa4/rts/ExternalAI/SkirmishAIKey.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/ExternalAI/SkirmishAIKey.h 2014-10-07 20:09:51.000000000 +0000 @@ -20,7 +20,7 @@ * Used to uniquely identify a Skirmish AI within the engine. */ class SkirmishAIKey { - CR_DECLARE_STRUCT(SkirmishAIKey); + CR_DECLARE_STRUCT(SkirmishAIKey) public: SkirmishAIKey( diff -Nru spring-96.0~14.04~ppa4/rts/ExternalAI/SkirmishAIWrapper.cpp spring-98.0~14.04~ppa6/rts/ExternalAI/SkirmishAIWrapper.cpp --- spring-96.0~14.04~ppa4/rts/ExternalAI/SkirmishAIWrapper.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/ExternalAI/SkirmishAIWrapper.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -47,7 +47,7 @@ CR_SERIALIZER(Serialize), CR_POSTLOAD(PostLoad) -)); +)) /// used only by creg CSkirmishAIWrapper::CSkirmishAIWrapper(): diff -Nru spring-96.0~14.04~ppa4/rts/ExternalAI/SkirmishAIWrapper.h spring-98.0~14.04~ppa6/rts/ExternalAI/SkirmishAIWrapper.h --- spring-96.0~14.04~ppa4/rts/ExternalAI/SkirmishAIWrapper.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/ExternalAI/SkirmishAIWrapper.h 2014-10-07 20:09:51.000000000 +0000 @@ -24,7 +24,7 @@ */ class CSkirmishAIWrapper : public CObject { private: - CR_DECLARE(CSkirmishAIWrapper); + CR_DECLARE(CSkirmishAIWrapper) /// used only by creg CSkirmishAIWrapper(); diff -Nru spring-96.0~14.04~ppa4/rts/ExternalAI/SSkirmishAICallbackImpl.cpp spring-98.0~14.04~ppa6/rts/ExternalAI/SSkirmishAICallbackImpl.cpp --- spring-96.0~14.04~ppa4/rts/ExternalAI/SSkirmishAICallbackImpl.cpp 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/ExternalAI/SSkirmishAICallbackImpl.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -18,6 +18,7 @@ #include "Map/MetalMap.h" #include "Map/MapInfo.h" #include "Lua/LuaRulesParams.h" +#include "Lua/LuaHandleSynced.h" #include "Sim/Units/UnitDef.h" #include "Sim/Units/UnitDefHandler.h" #include "Sim/Units/UnitHandler.h" @@ -110,48 +111,181 @@ static const CUnit* getUnit(int unitId) { - if (unitId < MAX_UNITS) { - return unitHandler->units[unitId]; - } else { - return NULL; - } + std::vector& units = unitHandler->units; + return (unitId < units.size()) ? units[unitId] : NULL; } static bool isAlliedUnit(int skirmishAIId, const CUnit* unit) { return teamHandler->AlliedTeams(unit->team, skirmishAIId_teamId[skirmishAIId]); } -static inline bool unitModParamIsValidId(const CUnit& unit, int modParamId) { - return ((size_t)modParamId < unit.modParams.size()); +static inline bool modParamIsValidId(const LuaRulesParams::Params& params, int modParamId) { + return ((size_t)modParamId < params.size()); } -static bool unitModParamIsVisible(int skirmishAIId, const CUnit& unit, - int modParamId) -{ +static int unitModParamLosMask(int skirmishAIId, const CUnit* unit) { + const int teamId = skirmishAIId_teamId[skirmishAIId]; + const int allyID = teamHandler->AllyTeam(teamId); + const int losStatus = unit->losStatus[allyID]; + + int losMask = LuaRulesParams::RULESPARAMLOS_PUBLIC_MASK; + + if (isAlliedUnit(skirmishAIId, unit) || skirmishAiCallback_Cheats_isEnabled(skirmishAIId)) { + losMask |= LuaRulesParams::RULESPARAMLOS_PRIVATE_MASK; + } else if (teamHandler->AlliedTeams(unit->team, teamId)) { + // ingame alliances + losMask |= LuaRulesParams::RULESPARAMLOS_ALLIED_MASK; + } else if (losStatus & LOS_INLOS) { + losMask |= LuaRulesParams::RULESPARAMLOS_INLOS_MASK; + } else if (losStatus & LOS_INRADAR) { + losMask |= LuaRulesParams::RULESPARAMLOS_INRADAR_MASK; + } + + return losMask; +} + +static inline bool modParamIsVisible(const LuaRulesParams::Param& param, const int losMask) { + return (param.los & losMask) > 0; +} + +static const CTeam* getTeam(int teamId) { + return (teamId < teamHandler->ActiveTeams()) ? teamHandler->Team(teamId) : NULL; +} - if (unitModParamIsValidId(unit, modParamId)) { - const int allyID = teamHandler->AllyTeam(teamId); - const int losStatus = unit.losStatus[allyID]; - - int losMask = LuaRulesParams::RULESPARAMLOS_PUBLIC_MASK; - - if (isAlliedUnit(skirmishAIId, &unit) - || skirmishAiCallback_Cheats_isEnabled(skirmishAIId)) { - losMask |= LuaRulesParams::RULESPARAMLOS_PRIVATE_MASK; - } else if (teamHandler->AlliedTeams(unit.team, teamId)) { - // ingame alliances - losMask |= LuaRulesParams::RULESPARAMLOS_ALLIED_MASK; - } else if (losStatus & LOS_INLOS) { - losMask |= LuaRulesParams::RULESPARAMLOS_INLOS_MASK; - } else if (losStatus & LOS_INRADAR) { - losMask |= LuaRulesParams::RULESPARAMLOS_INRADAR_MASK; +static bool isAlliedTeam(int skirmishAIId, const CTeam* team) { + return teamHandler->AlliedTeams(team->teamNum, skirmishAIId_teamId[skirmishAIId]); +} + +static int teamModParamLosMask(int skirmishAIId, const CTeam* team) { + + const int teamId = skirmishAIId_teamId[skirmishAIId]; + int losMask = LuaRulesParams::RULESPARAMLOS_PUBLIC_MASK; + + if (isAlliedTeam(skirmishAIId, team) || skirmishAiCallback_Cheats_isEnabled(skirmishAIId)) { + losMask |= LuaRulesParams::RULESPARAMLOS_PRIVATE_MASK; + } else if (teamHandler->AlliedTeams(team->teamNum, teamId)) { + // ingame alliances + losMask |= LuaRulesParams::RULESPARAMLOS_ALLIED_MASK; + } + + return losMask; +} + +static inline int gameModParamLosMask(void) { + return LuaRulesParams::RULESPARAMLOS_PRIVATE_MASK; +} + +static int getRulesParams(const LuaRulesParams::Params& params, const int losMask, + int* paramIds, int paramIds_sizeMax) +{ + if (paramIds == NULL) { + // Count number of visible modParams + size_t params_size = 0; + for (size_t i = 0; i < params.size(); i++) { + if (modParamIsVisible(params[i], losMask)) { + params_size++; + } } + return params_size; + } - return ((unit.modParams[modParamId].los & losMask) > 0); + // Fill Ids from visible modParams + size_t params_size = 0; + for (size_t i = 0; i < params.size(); i++) { + const LuaRulesParams::Param& p = params[i]; + if (modParamIsVisible(p, losMask)) { + paramIds[params_size] = i; + params_size++; + if (params_size >= paramIds_sizeMax) { + break; + } + } } - return false; + return params_size; +} + +static int getRulesParamByName(const LuaRulesParams::Params& params, const LuaRulesParams::HashMap& paramsMap, const int losMask, + const char* rulesParamName) +{ + int value = -1; + + const LuaRulesParams::HashMap::const_iterator pmi = paramsMap.find(rulesParamName); + if (pmi == paramsMap.end()) { + return value; + } + + if (modParamIsVisible(params[pmi->second], losMask)) { + value = pmi->second; + } + + return value; +} + +static int getRulesParamById(const LuaRulesParams::Params& params, const int losMask, + int rulesParamId) +{ + int value = -1; + + if (modParamIsValidId(params, rulesParamId)) { + const LuaRulesParams::Param& param = params[rulesParamId]; + if (modParamIsVisible(param, losMask)) { + value = rulesParamId; + } + } + + return value; +} + +static const char* getRulesParamNameById(const LuaRulesParams::Params& params, const LuaRulesParams::HashMap& paramsMap, const int losMask, + int rulesParamId) +{ + const char* name = ""; + + if (modParamIsValidId(params, rulesParamId) && modParamIsVisible(params[rulesParamId], losMask)) { + std::map::const_iterator mi, mb, me; + mb = paramsMap.begin(); + me = paramsMap.end(); + for (mi = mb; mi != me; ++mi) { + if (mi->second == rulesParamId) { + name = mi->first.c_str(); + break; + } + } + } + + return name; +} + +static float getRulesParamFloatValueById(const LuaRulesParams::Params& params, const int losMask, + int rulesParamId) +{ + float value = 0.0f; + + if (modParamIsValidId(params, rulesParamId)) { + const LuaRulesParams::Param& param = params[rulesParamId]; + if (modParamIsVisible(param, losMask)) { + value = param.valueInt; + } + } + + return value; +} + +static const char* getRulesParamStringValueById(const LuaRulesParams::Params& params, const int losMask, + int rulesParamId) +{ + const char* value = ""; + + if (modParamIsValidId(params, rulesParamId)) { + const LuaRulesParams::Param& param = params[rulesParamId]; + if (modParamIsVisible(param, losMask)) { + value = param.valueString.c_str(); + } + } + + return value; } static inline const UnitDef* getUnitDefById(int skirmishAIId, int unitDefId) { @@ -183,18 +317,16 @@ return featureDef; } -static int wrapper_HandleCommand(CAICallback* clb, CAICheats* clbCheat, - int cmdId, void* cmdData) { - - int ret; +//FIXME: get rid of this function (=call functions directly) +static int wrapper_HandleCommand(CAICallback* clb, CAICheats* clbCheat, int cmdId, void* cmdData) { if (clbCheat != NULL) { - ret = clbCheat->HandleCommand(cmdId, cmdData); - } else { - ret = clb->HandleCommand(cmdId, cmdData); + const int ret = clbCheat->HandleCommand(cmdId, cmdData); + if (ret != 0) { //cheat interface handled the command + return ret; + } } - - return ret; + return clb->HandleCommand(cmdId, cmdData); } EXPORT(int) skirmishAiCallback_Engine_handleCommand(int skirmishAIId, int toId, int commandId, @@ -265,8 +397,7 @@ case COMMAND_SEND_START_POS: { const SSendStartPosCommand* cmd = static_cast(commandData); - AIHCSendStartPos data = {cmd->ready, cmd->pos_posF3}; - wrapper_HandleCommand(clb, clbCheat, AIHCSendStartPosId, &data); + clb->SendStartPos(cmd->ready, cmd->pos_posF3); break; } case COMMAND_DRAWER_POINT_ADD: @@ -361,33 +492,23 @@ break; } */ - case COMMAND_PATH_INIT: - { + case COMMAND_PATH_INIT: { SInitPathCommand* cmd = static_cast(commandData); - cmd->ret_pathId = clb->InitPath(cmd->start_posF3, - cmd->end_posF3, cmd->pathType, cmd->goalRadius); + cmd->ret_pathId = clb->InitPath(cmd->start_posF3, cmd->end_posF3, cmd->pathType, cmd->goalRadius); break; } - case COMMAND_PATH_GET_APPROXIMATE_LENGTH: - { - SGetApproximateLengthPathCommand* cmd = - static_cast(commandData); - cmd->ret_approximatePathLength = - clb->GetPathLength(cmd->start_posF3, cmd->end_posF3, - cmd->pathType, cmd->goalRadius); + case COMMAND_PATH_GET_APPROXIMATE_LENGTH: { + SGetApproximateLengthPathCommand* cmd = static_cast(commandData); + cmd->ret_approximatePathLength = clb->GetPathLength(cmd->start_posF3, cmd->end_posF3, cmd->pathType, cmd->goalRadius); break; } - case COMMAND_PATH_GET_NEXT_WAYPOINT: - { - SGetNextWaypointPathCommand* cmd = - static_cast(commandData); + case COMMAND_PATH_GET_NEXT_WAYPOINT: { + SGetNextWaypointPathCommand* cmd = static_cast(commandData); clb->GetNextWaypoint(cmd->pathId).copyInto(cmd->ret_nextWaypoint_posF3_out); break; } - case COMMAND_PATH_FREE: - { - const SFreePathCommand* cmd = static_cast(commandData); - clb->FreePath(cmd->pathId); + case COMMAND_PATH_FREE: { + clb->FreePath(static_cast(commandData)->pathId); break; } @@ -1272,13 +1393,38 @@ const std::vector& names = CCategoryHandler::Instance()->GetCategoryNames(categoryFlag); - const char* theName = '\0'; + const char* theName = ""; if (!names.empty()) { theName = names.begin()->c_str(); } STRCPY_T(name, name_sizeMax, theName); } +EXPORT(int) skirmishAiCallback_Game_getGameRulesParams(int skirmishAIId, int* paramIds, int paramIds_sizeMax) { + return getRulesParams(CLuaHandleSynced::GetGameParams(), gameModParamLosMask(), paramIds, paramIds_sizeMax); +} + +EXPORT(int) skirmishAiCallback_Game_getGameRulesParamByName(int skirmishAIId, const char* rulesParamName) { + return getRulesParamByName(CLuaHandleSynced::GetGameParams(), CLuaHandleSynced::GetGameParamsMap(), gameModParamLosMask(), rulesParamName); +} + +EXPORT(int) skirmishAiCallback_Game_getGameRulesParamById(int skirmishAIId, int rulesParamId) { + return getRulesParamById(CLuaHandleSynced::GetGameParams(), gameModParamLosMask(), rulesParamId); +} + +EXPORT(const char*) skirmishAiCallback_Game_GameRulesParam_getName(int skirmishAIId, int gameRulesParamId) { + return getRulesParamNameById(CLuaHandleSynced::GetGameParams(), CLuaHandleSynced::GetGameParamsMap(), gameModParamLosMask(), gameRulesParamId); +} + +EXPORT(float) skirmishAiCallback_Game_GameRulesParam_getValueFloat(int skirmishAIId, int gameRulesParamId) { + return getRulesParamFloatValueById(CLuaHandleSynced::GetGameParams(), gameModParamLosMask(), gameRulesParamId); +} + +EXPORT(const char*) skirmishAiCallback_Game_GameRulesParam_getValueString(int skirmishAIId, int gameRulesParamId) { + return getRulesParamStringValueById(CLuaHandleSynced::GetGameParams(), gameModParamLosMask(), gameRulesParamId); +} + + EXPORT(float) skirmishAiCallback_Gui_getViewRange(int skirmishAIId) { float viewRange; @@ -1658,6 +1804,10 @@ resources_size = 0; } + if (tmpMap == NULL) { + return 0; + } + int i; for (i=0; i < resources_size; ++i) { resources[i] = tmpMap[i]; @@ -3112,48 +3262,64 @@ } } -EXPORT(int) skirmishAiCallback_Unit_getModParams(int skirmishAIId, int unitId) { +EXPORT(int) skirmishAiCallback_Unit_getUnitRulesParams(int skirmishAIId, int unitId, int* paramIds, int paramIds_sizeMax) { const CUnit* unit = getUnit(unitId); - if (unit && /*(skirmishAiCallback_Cheats_isEnabled(skirmishAIId) || */isAlliedUnit(skirmishAIId, unit)/*)*/) { - return unit->modParams.size(); - } else { + if (!unit) { return 0; } + + return getRulesParams(unit->modParams, unitModParamLosMask(skirmishAIId, unit), paramIds, paramIds_sizeMax); } -EXPORT(const char*) skirmishAiCallback_Unit_ModParam_getName(int skirmishAIId, - int unitId, int modParamId) -{ - const char* name = ""; +EXPORT(int) skirmishAiCallback_Unit_getUnitRulesParamByName(int skirmishAIId, int unitId, const char* rulesParamName) { const CUnit* unit = getUnit(unitId); - if (unit && unitModParamIsVisible(skirmishAIId, *unit, modParamId)) { - std::map::const_iterator mi, mb, me; - mb = unit->modParamsMap.begin(); - me = unit->modParamsMap.end(); - for (mi = mb; mi != me; ++mi) { - if (mi->second == modParamId) { - name = mi->first.c_str(); - } - } + if (!unit) { + return 0; } - return name; + return getRulesParamByName(unit->modParams, unit->modParamsMap, unitModParamLosMask(skirmishAIId, unit), rulesParamName); } -EXPORT(float) skirmishAiCallback_Unit_ModParam_getValue(int skirmishAIId, - int unitId, int modParamId) -{ - float value = 0.0f; +EXPORT(int) skirmishAiCallback_Unit_getUnitRulesParamById(int skirmishAIId, int unitId, int rulesParamId) { const CUnit* unit = getUnit(unitId); - if (unit && unitModParamIsVisible(skirmishAIId, *unit, modParamId)) { - //FIXME add function to get string params, too! - value = unit->modParams[modParamId].valueInt; + if (!unit) { + return 0; } - return value; + return getRulesParamById(unit->modParams, unitModParamLosMask(skirmishAIId, unit), rulesParamId); +} + +EXPORT(const char*) skirmishAiCallback_Unit_UnitRulesParam_getName(int skirmishAIId, int unitId, int unitRulesParamId) { + + const CUnit* unit = getUnit(unitId); + if (!unit) { + return ""; + } + + return getRulesParamNameById(unit->modParams, unit->modParamsMap, unitModParamLosMask(skirmishAIId, unit), unitRulesParamId); +} + +EXPORT(float) skirmishAiCallback_Unit_UnitRulesParam_getValueFloat(int skirmishAIId, int unitId, int unitRulesParamId) { + + const CUnit* unit = getUnit(unitId); + if (!unit) { + return 0.0f; + } + + return getRulesParamFloatValueById(unit->modParams, unitModParamLosMask(skirmishAIId, unit), unitRulesParamId); +} + +EXPORT(const char*) skirmishAiCallback_Unit_UnitRulesParam_getValueString(int skirmishAIId, int unitId, int unitRulesParamId) { + + const CUnit* unit = getUnit(unitId); + if (!unit) { + return ""; + } + + return getRulesParamStringValueById(unit->modParams, unitModParamLosMask(skirmishAIId, unit), unitRulesParamId); } EXPORT(int) skirmishAiCallback_Unit_getTeam(int skirmishAIId, int unitId) { @@ -3602,6 +3768,125 @@ return a; } + +//########### BEGINN Team +EXPORT(bool) skirmishAiCallback_Team_hasAIController(int skirmishAIId, int teamId) { + + for (auto& tid : skirmishAIId_teamId) { + if (tid.second == teamId) { + return true; + } + } + return false; +} + +EXPORT(int) skirmishAiCallback_getEnemyTeams(int skirmishAIId, int* teamIds, int teamIds_sizeMax) { + + int a = 0; + + const int teamId = skirmishAIId_teamId[skirmishAIId]; + if (teamIds != NULL) { + for (int i = 0; i < teamHandler->ActiveTeams() && a < teamIds_sizeMax; i++) { + if (!teamHandler->AlliedTeams(i, teamId)) { + teamIds[a++] = i; + } + } + } else { + for (int i = 0; i < teamHandler->ActiveTeams(); i++) { + if (!teamHandler->AlliedTeams(i, teamId)) { + a++; + } + } + } + + return a; +} + +EXPORT(int) skirmishAiCallback_getAllyTeams(int skirmishAIId, int* teamIds, int teamIds_sizeMax) { + + int a = 0; + + const int teamId = skirmishAIId_teamId[skirmishAIId]; + if (teamIds != NULL) { + for (int i = 0; i < teamHandler->ActiveTeams() && a < teamIds_sizeMax; i++) { + if (teamHandler->AlliedTeams(i, teamId)) { + teamIds[a++] = i; + } + } + } else { + for (int i = 0; i < teamHandler->ActiveTeams(); i++) { + if (teamHandler->AlliedTeams(i, teamId)) { + a++; + } + } + } + + return a; +} + +EXPORT(int) skirmishAiCallback_Team_getTeamRulesParams(int skirmishAIId, int teamId, int* paramIds, int paramIds_sizeMax) { + + const CTeam* team = getTeam(teamId); + if (!team) { + return 0; + } + + return getRulesParams(team->modParams, teamModParamLosMask(skirmishAIId, team), paramIds, paramIds_sizeMax); +} + +EXPORT(int) skirmishAiCallback_Team_getTeamRulesParamByName(int skirmishAIId, int teamId, const char* rulesParamName) { + + const CTeam* team = getTeam(teamId); + if (!team) { + return 0; + } + + return getRulesParamByName(team->modParams, team->modParamsMap, teamModParamLosMask(skirmishAIId, team), rulesParamName); +} + +EXPORT(int) skirmishAiCallback_Team_getTeamRulesParamById(int skirmishAIId, int teamId, int rulesParamId) { + + const CTeam* team = getTeam(teamId); + if (!team) { + return 0; + } + + return getRulesParamById(team->modParams, teamModParamLosMask(skirmishAIId, team), rulesParamId); +} + +EXPORT(const char*) skirmishAiCallback_Team_TeamRulesParam_getName(int skirmishAIId, int teamId, int teamRulesParamId) { + + const CTeam* team = getTeam(teamId); + if (!team) { + return ""; + } + + return getRulesParamNameById(team->modParams, team->modParamsMap, teamModParamLosMask(skirmishAIId, team), teamRulesParamId); +} + +EXPORT(float) skirmishAiCallback_Team_TeamRulesParam_getValueFloat(int skirmishAIId, int teamId, int teamRulesParamId) { + + const CTeam* team = getTeam(teamId); + if (!team) { + return 0.0f; + } + + return getRulesParamFloatValueById(team->modParams, teamModParamLosMask(skirmishAIId, team), teamRulesParamId); +} + +EXPORT(const char*) skirmishAiCallback_Team_TeamRulesParam_getValueString(int skirmishAIId, int teamId, int teamRulesParamId) { + + const CTeam* team = getTeam(teamId); + if (!team) { + return ""; + } + + return getRulesParamStringValueById(team->modParams, teamModParamLosMask(skirmishAIId, team), teamRulesParamId); +} + +//########### END Team + + //########### BEGINN FeatureDef EXPORT(int) skirmishAiCallback_getFeatureDefs(int skirmishAIId, int* featureDefIds, int featureDefIds_sizeMax) { @@ -4401,7 +4686,6 @@ } EXPORT(int) skirmishAiCallback_getGroups(int skirmishAIId, int* groupIds, int groupIds_sizeMax) { - GML_RECMUTEX_LOCK(group); // skirmishAiCallback_getGroups const std::vector& gs = grouphandlers[skirmishAIId_teamId[skirmishAIId]]->groups; const int groupIds_sizeReal = gs.size(); @@ -4594,6 +4878,12 @@ callback->Game_getCategoryFlag = &skirmishAiCallback_Game_getCategoryFlag; callback->Game_getCategoriesFlag = &skirmishAiCallback_Game_getCategoriesFlag; callback->Game_getCategoryName = &skirmishAiCallback_Game_getCategoryName; + callback->Game_getGameRulesParams = &skirmishAiCallback_Game_getGameRulesParams; + callback->Game_getGameRulesParamByName = &skirmishAiCallback_Game_getGameRulesParamByName; + callback->Game_getGameRulesParamById = &skirmishAiCallback_Game_getGameRulesParamById; + callback->GameRulesParam_getName = &skirmishAiCallback_Game_GameRulesParam_getName; + callback->GameRulesParam_getValueFloat = &skirmishAiCallback_Game_GameRulesParam_getValueFloat; + callback->GameRulesParam_getValueString = &skirmishAiCallback_Game_GameRulesParam_getValueString; callback->Gui_getViewRange = &skirmishAiCallback_Gui_getViewRange; callback->Gui_getScreenX = &skirmishAiCallback_Gui_getScreenX; callback->Gui_getScreenY = &skirmishAiCallback_Gui_getScreenY; @@ -4851,9 +5141,12 @@ callback->getTeamUnits = &skirmishAiCallback_getTeamUnits; callback->getSelectedUnits = &skirmishAiCallback_getSelectedUnits; callback->Unit_getDef = &skirmishAiCallback_Unit_getDef; - callback->Unit_getModParams = &skirmishAiCallback_Unit_getModParams; - callback->Unit_ModParam_getName = &skirmishAiCallback_Unit_ModParam_getName; - callback->Unit_ModParam_getValue = &skirmishAiCallback_Unit_ModParam_getValue; + callback->Unit_getUnitRulesParams = &skirmishAiCallback_Unit_getUnitRulesParams; + callback->Unit_getUnitRulesParamByName = &skirmishAiCallback_Unit_getUnitRulesParamByName; + callback->Unit_getUnitRulesParamById = &skirmishAiCallback_Unit_getUnitRulesParamById; + callback->Unit_UnitRulesParam_getName = &skirmishAiCallback_Unit_UnitRulesParam_getName; + callback->Unit_UnitRulesParam_getValueFloat = &skirmishAiCallback_Unit_UnitRulesParam_getValueFloat; + callback->Unit_UnitRulesParam_getValueString = &skirmishAiCallback_Unit_UnitRulesParam_getValueString; callback->Unit_getTeam = &skirmishAiCallback_Unit_getTeam; callback->Unit_getAllyTeam = &skirmishAiCallback_Unit_getAllyTeam; callback->Unit_getAiHint = &skirmishAiCallback_Unit_getAiHint; @@ -4893,6 +5186,15 @@ callback->Unit_isNeutral = &skirmishAiCallback_Unit_isNeutral; callback->Unit_getBuildingFacing = &skirmishAiCallback_Unit_getBuildingFacing; callback->Unit_getLastUserOrderFrame = &skirmishAiCallback_Unit_getLastUserOrderFrame; + callback->Team_hasAIController = &skirmishAiCallback_Team_hasAIController; + callback->getEnemyTeams = &skirmishAiCallback_getEnemyTeams; + callback->getAllyTeams = &skirmishAiCallback_getAllyTeams; + callback->Team_getTeamRulesParams = &skirmishAiCallback_Team_getTeamRulesParams; + callback->Team_getTeamRulesParamByName = &skirmishAiCallback_Team_getTeamRulesParamByName; + callback->Team_getTeamRulesParamById = &skirmishAiCallback_Team_getTeamRulesParamById; + callback->Team_TeamRulesParam_getName = &skirmishAiCallback_Team_TeamRulesParam_getName; + callback->Team_TeamRulesParam_getValueFloat = &skirmishAiCallback_Team_TeamRulesParam_getValueFloat; + callback->Team_TeamRulesParam_getValueString = &skirmishAiCallback_Team_TeamRulesParam_getValueString; callback->getGroups = &skirmishAiCallback_getGroups; callback->Group_getSupportedCommands = &skirmishAiCallback_Group_getSupportedCommands; callback->Group_SupportedCommand_getId = &skirmishAiCallback_Group_SupportedCommand_getId; diff -Nru spring-96.0~14.04~ppa4/rts/ExternalAI/SSkirmishAICallbackImpl.h spring-98.0~14.04~ppa6/rts/ExternalAI/SSkirmishAICallbackImpl.h --- spring-96.0~14.04~ppa4/rts/ExternalAI/SSkirmishAICallbackImpl.h 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/ExternalAI/SSkirmishAICallbackImpl.h 2014-10-07 20:09:51.000000000 +0000 @@ -125,6 +125,18 @@ EXPORT(void ) skirmishAiCallback_Game_getCategoryName(int skirmishAIId, int categoryFlag, char* name, int name_sizeMax); +EXPORT(int ) skirmishAiCallback_Game_getGameRulesParams(int skirmishAIId, int* paramIds, int paramIds_sizeMax); + +EXPORT(int ) skirmishAiCallback_Game_getGameRulesParamByName(int skirmishAIId, const char* rulesParamName); + +EXPORT(int ) skirmishAiCallback_Game_getGameRulesParamById(int skirmishAIId, int rulesParamId); + +EXPORT(const char* ) skirmishAiCallback_Game_GameRulesParam_getName(int skirmishAIId, int gameRulesParamId); + +EXPORT(float ) skirmishAiCallback_Game_GameRulesParam_getValueFloat(int skirmishAIId, int gameRulesParamId); + +EXPORT(const char* ) skirmishAiCallback_Game_GameRulesParam_getValueString(int skirmishAIId, int gameRulesParamId); + // END misc callback functions @@ -670,11 +682,17 @@ EXPORT(int ) skirmishAiCallback_Unit_getDef(int skirmishAIId, int unitId); -EXPORT(int ) skirmishAiCallback_Unit_getModParams(int skirmishAIId, int unitId); +EXPORT(int ) skirmishAiCallback_Unit_getUnitRulesParams(int skirmishAIId, int unitId, int* paramIds, int paramIds_sizeMax); + +EXPORT(int ) skirmishAiCallback_Unit_getUnitRulesParamByName(int skirmishAIId, int unitId, const char* rulesParamName); + +EXPORT(int ) skirmishAiCallback_Unit_getUnitRulesParamById(int skirmishAIId, int unitId, int rulesParamId); -EXPORT(const char* ) skirmishAiCallback_Unit_ModParam_getName(int skirmishAIId, int unitId, int modParamId); +EXPORT(const char* ) skirmishAiCallback_Unit_UnitRulesParam_getName(int skirmishAIId, int unitId, int unitRulesParamId); -EXPORT(float ) skirmishAiCallback_Unit_ModParam_getValue(int skirmishAIId, int unitId, int modParamId); +EXPORT(float ) skirmishAiCallback_Unit_UnitRulesParam_getValueFloat(int skirmishAIId, int unitId, int unitRulesParamId); + +EXPORT(const char* ) skirmishAiCallback_Unit_UnitRulesParam_getValueString(int skirmishAIId, int unitId, int unitRulesParamId); EXPORT(int ) skirmishAiCallback_Unit_getTeam(int skirmishAIId, int unitId); @@ -759,6 +777,28 @@ // END OBJECT Unit +// BEGINN OBJECT Team +EXPORT(bool ) skirmishAiCallback_Team_hasAIController(int skirmishAIId, int teamId); + +EXPORT(int ) skirmishAiCallback_getEnemyTeams(int skirmishAIId, int* teamIds, int teamIds_sizeMax); + +EXPORT(int ) skirmishAiCallback_getAllyTeams(int skirmishAIId, int* teamIds, int teamIds_sizeMax); + +EXPORT(int ) skirmishAiCallback_Team_getTeamRulesParams(int skirmishAIId, int teamId, int* paramIds, int paramIds_sizeMax); + +EXPORT(int ) skirmishAiCallback_Team_getTeamRulesParamByName(int skirmishAIId, int teamId, const char* rulesParamName); + +EXPORT(int ) skirmishAiCallback_Team_getTeamRulesParamById(int skirmishAIId, int teamId, int rulesParamId); + +EXPORT(const char* ) skirmishAiCallback_Team_TeamRulesParam_getName(int skirmishAIId, int teamId, int teamRulesParamId); + +EXPORT(float ) skirmishAiCallback_Team_TeamRulesParam_getValueFloat(int skirmishAIId, int teamId, int teamRulesParamId); + +EXPORT(const char* ) skirmishAiCallback_Team_TeamRulesParam_getValueString(int skirmishAIId, int teamId, int teamRulesParamId); + +// END OBJECT Team + + // BEGINN OBJECT Group EXPORT(int ) skirmishAiCallback_getGroups(int skirmishAIId, int* groupIds, int groupIds_sizeMax); diff -Nru spring-96.0~14.04~ppa4/rts/Game/Action.h spring-98.0~14.04~ppa6/rts/Game/Action.h --- spring-96.0~14.04~ppa4/rts/Game/Action.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/Action.h 2014-10-07 20:09:51.000000000 +0000 @@ -4,6 +4,7 @@ #define ACTION_H #include +#include "Game/UI/KeySet.h" class Action { @@ -15,6 +16,8 @@ std::string extra; ///< everything but the first word std::string rawline; ///< includes the command, case preserved std::string boundWith; ///< the string that defined the binding keyset + + CKeyChain keyChain; ///< the bounded keychain/keyset }; #endif // ACTION_H diff -Nru spring-96.0~14.04~ppa4/rts/Game/Camera/FPSController.cpp spring-98.0~14.04~ppa6/rts/Game/Camera/FPSController.cpp --- spring-96.0~14.04~ppa4/rts/Game/Camera/FPSController.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/Camera/FPSController.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -72,7 +72,7 @@ pos.x = Clamp(pos.x, xMin, xMax); pos.z = Clamp(pos.z, zMin, zMax); - const float gndHeight = ground->GetHeightAboveWater(pos.x, pos.z, false); + const float gndHeight = CGround::GetHeightAboveWater(pos.x, pos.z, false); const float yMin = gndHeight + 5.0f; const float yMax = 9000.0f; pos.y = Clamp(pos.y, yMin, yMax); @@ -91,7 +91,7 @@ CCameraController::SetPos(newPos); if (!gu->fpsMode) { - pos.y = ground->GetHeightAboveWater(pos.x, pos.z, false) + oldHeight; + pos.y = CGround::GetHeightAboveWater(pos.x, pos.z, false) + oldHeight; } UpdateVectors(); } diff -Nru spring-96.0~14.04~ppa4/rts/Game/Camera/FreeController.cpp spring-98.0~14.04~ppa6/rts/Game/Camera/FreeController.cpp --- spring-96.0~14.04~ppa4/rts/Game/Camera/FreeController.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/Camera/FreeController.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,7 +1,7 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ #include -#include +#include #include "FreeController.h" #include "Game/Camera.h" @@ -125,13 +125,13 @@ // adjustment to match the ground slope float autoTiltVel = 0.0f; if (gndLock && (autoTilt > 0.0f)) { - const float gndHeight = ground->GetHeightReal(pos.x, pos.z, false); + const float gndHeight = CGround::GetHeightReal(pos.x, pos.z, false); if (pos.y < (gndHeight + gndOffset + 1.0f)) { float3 hDir; hDir.y = 0.0f; hDir.x = (float)math::sin(camera->rot.y); hDir.z = (float)math::cos(camera->rot.y); - const float3 gndNormal = ground->GetSmoothNormal(pos.x, pos.z, false); + const float3 gndNormal = CGround::GetSmoothNormal(pos.x, pos.z, false); const float dot = gndNormal.dot(hDir); const float gndRotX = (float)math::acos(dot) - (PI * 0.5f); const float rotXdiff = (gndRotX - camera->rot.x); @@ -165,9 +165,9 @@ const float dGrav = (gravity * ft); vel.y += dGrav; if (slide > 0.0f) { - const float gndHeight = ground->GetHeightReal(pos.x, pos.z, false); + const float gndHeight = CGround::GetHeightReal(pos.x, pos.z, false); if (pos.y < (gndHeight + gndOffset + 1.0f)) { - const float3 gndNormal = ground->GetSmoothNormal(pos.x, pos.z, false); + const float3 gndNormal = CGround::GetSmoothNormal(pos.x, pos.z, false); const float dotVal = gndNormal.y; const float scale = (dotVal * slide * -dGrav); vel.x += (gndNormal.x * scale); @@ -217,9 +217,9 @@ } // setup ground lock - const float gndHeight = ground->GetHeightReal(pos.x, pos.z, false); + const float gndHeight = CGround::GetHeightReal(pos.x, pos.z, false); - if (keyInput->IsKeyPressed(SDLK_LSHIFT)) { + if (KeyInput::GetKeyModState(KMOD_SHIFT)) { if (ctrlVelY > 0.0f) { gndLock = false; } else if ((gndOffset > 0.0f) && (ctrlVelY < 0.0f) && @@ -285,13 +285,13 @@ const float qy = (move.y == 0.0f) ? 0.0f : (move.y > 0.0f ? 1.0f : -1.0f); const float qx = (move.x == 0.0f) ? 0.0f : (move.x > 0.0f ? 1.0f : -1.0f); - const float speed = (keyInput->IsKeyPressed(SDLK_LMETA))? 4.0f * scrollSpeed : scrollSpeed; - const float aspeed = (keyInput->IsKeyPressed(SDLK_LMETA))? 2.0f * tiltSpeed : tiltSpeed; + const float speed = (KeyInput::GetKeyModState(KMOD_GUI))? 4.0f * scrollSpeed : scrollSpeed; + const float aspeed = (KeyInput::GetKeyModState(KMOD_GUI))? 2.0f * tiltSpeed : tiltSpeed; - if (keyInput->IsKeyPressed(SDLK_LCTRL)) { + if (KeyInput::GetKeyModState(KMOD_CTRL)) { avel.x += (aspeed * -qy); // tilt } - else if (keyInput->IsKeyPressed(SDLK_LSHIFT)) { + else if (KeyInput::GetKeyModState(KMOD_SHIFT)) { vel.y += (speed * -qy); // up/down } else { @@ -301,7 +301,7 @@ if (tracking) { avel.y += (aspeed * qx); // turntable rotation } - else if (!keyInput->GetKeyState(SDLK_LALT) == invertAlt) { + else if (!KeyInput::GetKeyModState(KMOD_ALT) == invertAlt) { vel.z += (speed * qx); // left/right } else { @@ -314,54 +314,54 @@ void CFreeController::MouseMove(float3 move) { - const boost::uint8_t prevAlt = keyInput->GetKeyState(SDLK_LALT); - const boost::uint8_t prevCtrl = keyInput->GetKeyState(SDLK_LCTRL); - const boost::uint8_t prevShift = keyInput->GetKeyState(SDLK_LSHIFT); + const boost::uint8_t prevAlt = KeyInput::GetKeyModState(KMOD_ALT); + const boost::uint8_t prevCtrl = KeyInput::GetKeyModState(KMOD_CTRL); + const boost::uint8_t prevShift = KeyInput::GetKeyModState(KMOD_SHIFT); - keyInput->SetKeyState(SDLK_LCTRL, !prevCtrl); - keyInput->SetKeyState(SDLK_LALT, (invertAlt == !prevAlt)); + KeyInput::SetKeyModState(KMOD_CTRL, !prevCtrl); + KeyInput::SetKeyModState(KMOD_ALT, (invertAlt == !prevAlt)); KeyMove(move); - keyInput->SetKeyState(SDLK_LALT, prevAlt); - keyInput->SetKeyState(SDLK_LCTRL, prevCtrl); - keyInput->SetKeyState(SDLK_LSHIFT, prevShift); + KeyInput::SetKeyModState(KMOD_ALT, prevAlt); + KeyInput::SetKeyModState(KMOD_CTRL, prevCtrl); + KeyInput::SetKeyModState(KMOD_SHIFT, prevShift); } void CFreeController::ScreenEdgeMove(float3 move) { - const boost::uint8_t prevAlt = keyInput->GetKeyState(SDLK_LALT); - const boost::uint8_t prevCtrl = keyInput->GetKeyState(SDLK_LCTRL); - const boost::uint8_t prevShift = keyInput->GetKeyState(SDLK_LSHIFT); + const boost::uint8_t prevAlt = KeyInput::GetKeyModState(KMOD_ALT); + const boost::uint8_t prevCtrl = KeyInput::GetKeyModState(KMOD_CTRL); + const boost::uint8_t prevShift = KeyInput::GetKeyModState(KMOD_SHIFT); - keyInput->SetKeyState(SDLK_LALT, (invertAlt == !prevAlt)); + KeyInput::SetKeyModState(KMOD_ALT, (invertAlt == !prevAlt)); KeyMove(move); - keyInput->SetKeyState(SDLK_LALT, prevAlt); - keyInput->SetKeyState(SDLK_LCTRL, prevCtrl); - keyInput->SetKeyState(SDLK_LSHIFT, prevShift); + KeyInput::SetKeyModState(KMOD_ALT, prevAlt); + KeyInput::SetKeyModState(KMOD_CTRL, prevCtrl); + KeyInput::SetKeyModState(KMOD_SHIFT, prevShift); } void CFreeController::MouseWheelMove(float move) { - const boost::uint8_t prevCtrl = keyInput->GetKeyState(SDLK_LCTRL); - const boost::uint8_t prevShift = keyInput->GetKeyState(SDLK_LSHIFT); + const boost::uint8_t prevCtrl = KeyInput::GetKeyModState(KMOD_CTRL); + const boost::uint8_t prevShift = KeyInput::GetKeyModState(KMOD_SHIFT); - keyInput->SetKeyState(SDLK_LCTRL, 0); - keyInput->SetKeyState(SDLK_LSHIFT, 1); + KeyInput::SetKeyModState(KMOD_CTRL, 0); + KeyInput::SetKeyModState(KMOD_SHIFT, 1); KeyMove(float3(0.0f, move, 0.0f)); - keyInput->SetKeyState(SDLK_LCTRL, prevCtrl); - keyInput->SetKeyState(SDLK_LSHIFT, prevShift); + KeyInput::SetKeyModState(KMOD_CTRL, prevCtrl); + KeyInput::SetKeyModState(KMOD_SHIFT, prevShift); } void CFreeController::SetPos(const float3& newPos) { - const float h = ground->GetHeightReal(newPos.x, newPos.z, false); + const float h = CGround::GetHeightReal(newPos.x, newPos.z, false); const float3 target = float3(newPos.x, h, newPos.z); // const float3 target = newPos; const float yDiff = pos.y - target.y; @@ -375,7 +375,7 @@ CCameraController::SetPos(newPos); pos.y = oldPosY; if (gndOffset != 0.0f) { - const float h = ground->GetHeightReal(pos.x, pos.z, false); + const float h = CGround::GetHeightReal(pos.x, pos.z, false); const float absH = h + math::fabsf(gndOffset); if (pos.y < absH) { pos.y = absH; @@ -391,7 +391,7 @@ { const float x = max(0.1f, min(float3::maxxpos - 0.1f, pos.x)); const float z = max(0.1f, min(float3::maxzpos - 0.1f, pos.z)); - return float3(x, ground->GetHeightAboveWater(x, z, false) + 5.0f, z); + return float3(x, CGround::GetHeightAboveWater(x, z, false) + 5.0f, z); } diff -Nru spring-96.0~14.04~ppa4/rts/Game/Camera/OrbitController.cpp spring-98.0~14.04~ppa6/rts/Game/Camera/OrbitController.cpp --- spring-96.0~14.04~ppa4/rts/Game/Camera/OrbitController.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/Camera/OrbitController.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -3,7 +3,7 @@ #include #include -#include +#include #include "OrbitController.h" #include "Game/Camera.h" @@ -40,7 +40,7 @@ void COrbitController::Init(const float3& p, const float3& tar) { const float l = (tar == ZeroVector)? - std::max(ground->LineGroundCol(p, p + camera->forward * 1024.0f, false), 512.0f): + std::max(CGround::LineGroundCol(p, p + camera->forward * 1024.0f, false), 512.0f): p.distance(tar); const float3 t = (tar == ZeroVector)? (p + camera->forward * l): tar; @@ -61,7 +61,7 @@ void COrbitController::Update() { - if (!keyInput->IsKeyPressed(SDLK_LMETA)) { + if (!KeyInput::GetKeyModState(KMOD_GUI)) { return; } @@ -158,7 +158,7 @@ void COrbitController::Orbit() { camera->SetPos(cen + GetOrbitPos()); - camera->SetPos((camera->GetPos() + XZVector) + (UpVector * std::max(camera->GetPos().y, ground->GetHeightReal(camera->GetPos().x, camera->GetPos().z, false)))); + camera->SetPos((camera->GetPos() + XZVector) + (UpVector * std::max(camera->GetPos().y, CGround::GetHeightReal(camera->GetPos().x, camera->GetPos().z, false)))); camera->forward = (cen - camera->GetPos()).ANormalize(); camera->up = UpVector; } @@ -175,8 +175,8 @@ // don't allow orbit center or ourselves to drop below the terrain - const float camGH = ground->GetHeightReal(camera->GetPos().x, camera->GetPos().z, false); - const float cenGH = ground->GetHeightReal(cen.x, cen.z, false); + const float camGH = CGround::GetHeightReal(camera->GetPos().x, camera->GetPos().z, false); + const float cenGH = CGround::GetHeightReal(cen.x, cen.z, false); if (camera->GetPos().y < camGH) { camera->SetPos((camera->GetPos() * XZVector) + (UpVector * camGH)); @@ -215,7 +215,7 @@ void COrbitController::SetPos(const float3& newPos) { - if (keyInput->IsKeyPressed(SDLK_LMETA)) { + if (KeyInput::GetKeyModState(KMOD_GUI)) { return; } @@ -225,7 +225,7 @@ cen.x += dx; cen.z += dz; - cen.y = ground->GetHeightReal(cen.x, cen.z, false); + cen.y = CGround::GetHeightReal(cen.x, cen.z, false); camera->SetPos(camera->GetPos() + float3(dx, 0.0f, dz)); Init(camera->GetPos(), cen); diff -Nru spring-96.0~14.04~ppa4/rts/Game/Camera/OverheadController.cpp spring-98.0~14.04~ppa6/rts/Game/Camera/OverheadController.cpp --- spring-96.0~14.04~ppa4/rts/Game/Camera/OverheadController.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/Camera/OverheadController.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,6 +1,6 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ -#include +#include #include #include "OverheadController.h" @@ -35,10 +35,10 @@ enabled = configHandler->GetBool("OverheadEnabled"); fov = configHandler->GetFloat("OverheadFOV"); - if (ground && globalRendering) { + if (globalRendering) { // make whole map visible const float h = std::max(pos.x / globalRendering->aspectRatio, pos.z); - height = ground->GetHeightAboveWater(pos.x, pos.z, false) + (2.5f * h); + height = CGround::GetHeightAboveWater(pos.x, pos.z, false) + (2.5f * h); } maxHeight = 9.5f * std::max(gs->mapx, gs->mapy); @@ -66,8 +66,8 @@ } move *= 100 * middleClickScrollSpeed; - pos.x += move.x * pixelSize * (1 + keyInput->GetKeyState(SDLK_LSHIFT) * 3) * scrollSpeed; - pos.z += move.y * pixelSize * (1 + keyInput->GetKeyState(SDLK_LSHIFT) * 3) * scrollSpeed; + pos.x += move.x * pixelSize * (1 + KeyInput::GetKeyModState(KMOD_SHIFT) * 3) * scrollSpeed; + pos.z += move.y * pixelSize * (1 + KeyInput::GetKeyModState(KMOD_SHIFT) * 3) * scrollSpeed; UpdateVectors(); } @@ -84,14 +84,14 @@ camHandler->CameraTransition(0.05f); - const float shiftSpeed = (keyInput->IsKeyPressed(SDLK_LSHIFT) ? 3.0f : 1.0f); + const float shiftSpeed = (KeyInput::GetKeyModState(KMOD_SHIFT) ? 3.0f : 1.0f); const float altZoomDist = height * move * 0.007f * shiftSpeed; // tilt the camera if LCTRL is pressed // // otherwise holding down LALT uses 'instant-zoom' // from here to the end of the function (smoothed) - if (keyInput->IsKeyPressed(SDLK_LCTRL)) { + if (KeyInput::GetKeyModState(KMOD_CTRL)) { zscale *= (1.0f + (0.01f * move * tiltSpeed * shiftSpeed)); zscale = Clamp(zscale, 0.05f, 10.0f); } else { @@ -103,13 +103,13 @@ if ((height - dif) < 60.0f) { dif = height - 60.0f; } - if (keyInput->IsKeyPressed(SDLK_LALT)) { + if (KeyInput::GetKeyModState(KMOD_ALT)) { // instazoom in to standard view dif = (height - oldAltHeight) / mouse->dir.y * dir.y; } float3 wantedPos = cpos + mouse->dir * dif; - float newHeight = ground->LineGroundCol(wantedPos, wantedPos + dir * 15000, false); + float newHeight = CGround::LineGroundCol(wantedPos, wantedPos + dir * 15000, false); if (newHeight < 0.0f) { newHeight = height * (1.0f + move * 0.007f * shiftSpeed); @@ -123,7 +123,7 @@ } } else { // ZOOM OUT from mid screen - if (keyInput->IsKeyPressed(SDLK_LALT)) { + if (KeyInput::GetKeyModState(KMOD_ALT)) { // instazoom out to maximum height if (height < maxHeight*0.5f && changeAltHeight) { oldAltHeight = height; @@ -138,7 +138,7 @@ } // instant-zoom: turn on the smooth transition and reset the camera tilt - if (keyInput->IsKeyPressed(SDLK_LALT)) { + if (KeyInput::GetKeyModState(KMOD_ALT)) { zscale = 0.5f; camHandler->CameraTransition(1.0f); } else { @@ -153,7 +153,7 @@ { pos.x = Clamp(pos.x, 0.01f, gs->mapx * SQUARE_SIZE - 0.01f); pos.z = Clamp(pos.z, 0.01f, gs->mapy * SQUARE_SIZE - 0.01f); - pos.y = ground->GetHeightAboveWater(pos.x, pos.z, false); + pos.y = CGround::GetHeightAboveWater(pos.x, pos.z, false); height = Clamp(height, 60.0f, maxHeight); dir = float3(0.0f, -1.0f, flipped ? zscale : -zscale).ANormalize(); } @@ -203,6 +203,7 @@ SetStateFloat(sm, "height", height); SetStateFloat(sm, "zscale", zscale); SetStateBool (sm, "flipped", flipped); + UpdateVectors(); return true; } diff -Nru spring-96.0~14.04~ppa4/rts/Game/Camera/OverviewController.cpp spring-98.0~14.04~ppa6/rts/Game/Camera/OverviewController.cpp --- spring-96.0~14.04~ppa4/rts/Game/Camera/OverviewController.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/Camera/OverviewController.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -17,7 +17,7 @@ pos.x = gs->mapx * 0.5f * SQUARE_SIZE; pos.z = gs->mapy * 0.5f * SQUARE_SIZE; const float height = std::max(pos.x / globalRendering->aspectRatio, pos.z); - pos.y = ground->GetHeightAboveWater(pos.x, pos.z, false) + (2.5f * height); + pos.y = CGround::GetHeightAboveWater(pos.x, pos.z, false) + (2.5f * height); dir = float3(0.0f, -1.0f, -0.001f).ANormalize(); } @@ -49,7 +49,7 @@ float3 COverviewController::SwitchFrom() const { float3 dir = mouse->dir; - float length = ground->LineGroundCol(pos, pos + dir * 50000, false); + float length = CGround::LineGroundCol(pos, pos + dir * 50000, false); float3 rpos = pos + dir * length; if (!globalRendering->dualScreenMode) { diff -Nru spring-96.0~14.04~ppa4/rts/Game/Camera/RotOverheadController.cpp spring-98.0~14.04~ppa6/rts/Game/Camera/RotOverheadController.cpp --- spring-96.0~14.04~ppa4/rts/Game/Camera/RotOverheadController.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/Camera/RotOverheadController.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -58,7 +58,7 @@ void CRotOverheadController::MouseWheelMove(float move) { - const float gheight = ground->GetHeightAboveWater(pos.x, pos.z, false); + const float gheight = CGround::GetHeightAboveWater(pos.x, pos.z, false); float height = pos.y - gheight; height *= (1.0f + (move * mouseScale)); @@ -77,7 +77,7 @@ pos.x = Clamp(pos.x, 0.01f, gs->mapx * SQUARE_SIZE - 0.01f); pos.z = Clamp(pos.z, 0.01f, gs->mapy * SQUARE_SIZE - 0.01f); - float h = ground->GetHeightAboveWater(pos.x, pos.z, false); + float h = CGround::GetHeightAboveWater(pos.x, pos.z, false); pos.y = Clamp(pos.y, h + 5, 9000.0f); oldHeight = pos.y - h; } @@ -85,7 +85,7 @@ void CRotOverheadController::SetPos(const float3& newPos) { CCameraController::SetPos(newPos); - pos.y = ground->GetHeightAboveWater(pos.x, pos.z, false) + oldHeight; + pos.y = CGround::GetHeightAboveWater(pos.x, pos.z, false) + oldHeight; UpdateVectors(); } diff -Nru spring-96.0~14.04~ppa4/rts/Game/Camera/SmoothController.cpp spring-98.0~14.04~ppa6/rts/Game/Camera/SmoothController.cpp --- spring-96.0~14.04~ppa4/rts/Game/Camera/SmoothController.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/Camera/SmoothController.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,6 +1,6 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ -#include +#include #include #include "SmoothController.h" @@ -40,10 +40,10 @@ fov = configHandler->GetFloat("SmoothFOV"); lastSource = Noone; - if (ground && globalRendering) { + if (globalRendering) { // make whole map visible const float h = std::max(pos.x / globalRendering->aspectRatio, pos.z); - height = ground->GetHeightAboveWater(pos.x, pos.z, false) + (2.5f * h); + height = CGround::GetHeightAboveWater(pos.x, pos.z, false) + (2.5f * h); } maxHeight = 9.5f * std::max(gs->mapx, gs->mapy); @@ -112,9 +112,9 @@ // do little smoothing here (and because its little it won't hurt if it depends on framerate) static float3 lastMove = ZeroVector; const float3 thisMove( - move.x * pixelSize * (1 + keyInput->GetKeyState(SDLK_LSHIFT) * 3) * scrollSpeed, + move.x * pixelSize * (1 + KeyInput::GetKeyModState(KMOD_SHIFT) * 3) * scrollSpeed, 0.0f, - move.y * pixelSize * (1 + keyInput->GetKeyState(SDLK_LSHIFT) * 3) * scrollSpeed + move.y * pixelSize * (1 + KeyInput::GetKeyModState(KMOD_SHIFT) * 3) * scrollSpeed ); pos += (thisMove + lastMove) / 2.0f; @@ -130,14 +130,14 @@ camHandler->CameraTransition(0.05f); - const float shiftSpeed = (keyInput->IsKeyPressed(SDLK_LSHIFT) ? 3.0f : 1.0f); + const float shiftSpeed = (KeyInput::GetKeyModState(KMOD_SHIFT) ? 3.0f : 1.0f); const float altZoomDist = height * move * 0.007f * shiftSpeed; // tilt the camera if LCTRL is pressed // // otherwise holding down LALT uses 'instant-zoom' // from here to the end of the function (smoothed) - if (keyInput->IsKeyPressed(SDLK_LCTRL)) { + if (KeyInput::GetKeyModState(KMOD_CTRL)) { zscale *= (1.0f + (0.01f * move * tiltSpeed * shiftSpeed)); zscale = Clamp(zscale, 0.05f, 10.0f); } else { @@ -149,13 +149,13 @@ if ((height - dif) < 60.0f) { dif = height - 60.0f; } - if (keyInput->IsKeyPressed(SDLK_LALT)) { + if (KeyInput::GetKeyModState(KMOD_ALT)) { // instazoom in to standard view dif = (height - oldAltHeight) / mouse->dir.y * dir.y; } float3 wantedPos = cpos + mouse->dir * dif; - float newHeight = ground->LineGroundCol(wantedPos, wantedPos + dir * 15000, false); + float newHeight = CGround::LineGroundCol(wantedPos, wantedPos + dir * 15000, false); if (newHeight < 0.0f) { newHeight = height * (1.0f + move * 0.007f * shiftSpeed); @@ -169,7 +169,7 @@ } } else { // ZOOM OUT from mid screen - if (keyInput->IsKeyPressed(SDLK_LALT)) { + if (KeyInput::GetKeyModState(KMOD_ALT)) { // instazoom out to maximum height if (height < maxHeight*0.5f && changeAltHeight) { oldAltHeight = height; @@ -184,7 +184,7 @@ } // instant-zoom: turn on the smooth transition and reset the camera tilt - if (keyInput->IsKeyPressed(SDLK_LALT)) { + if (KeyInput::GetKeyModState(KMOD_ALT)) { zscale = 0.5f; camHandler->CameraTransition(1.0f); } else { @@ -199,7 +199,7 @@ { pos.x = Clamp(pos.x, 0.01f, gs->mapx * SQUARE_SIZE - 0.01f); pos.z = Clamp(pos.z, 0.01f, gs->mapy * SQUARE_SIZE - 0.01f); - pos.y = ground->GetHeightAboveWater(pos.x, pos.z, false); + pos.y = CGround::GetHeightAboveWater(pos.x, pos.z, false); height = Clamp(height, 60.0f, maxHeight); dir = float3(0.0f, -1.0f, flipped ? zscale : -zscale).ANormalize(); } @@ -212,7 +212,7 @@ float3 SmoothController::GetPos() const { float3 cpos = pos - dir * height; - cpos.y = std::max(cpos.y, ground->GetHeightAboveWater(cpos.x, cpos.z, false) + 5.0f); + cpos.y = std::max(cpos.y, CGround::GetHeightAboveWater(cpos.x, cpos.z, false) + 5.0f); return cpos; } @@ -252,6 +252,7 @@ SetStateFloat(sm, "height", height); SetStateFloat(sm, "zscale", zscale); SetStateBool (sm, "flipped", flipped); + UpdateVectors(); return true; } diff -Nru spring-96.0~14.04~ppa4/rts/Game/Camera/TWController.cpp spring-98.0~14.04~ppa6/rts/Game/Camera/TWController.cpp --- spring-96.0~14.04~ppa4/rts/Game/Camera/TWController.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/Camera/TWController.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,7 +1,7 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ #include -#include +#include #include "TWController.h" #include "Game/Camera.h" @@ -41,7 +41,7 @@ void CTWController::MouseMove(float3 move) { - move *= (1 + keyInput->GetKeyState(SDLK_LSHIFT) * 3) * pixelSize; + move *= (1 + KeyInput::GetKeyModState(KMOD_SHIFT) * 3) * pixelSize; float3 flatForward = camera->forward; flatForward.y = 0; @@ -73,7 +73,7 @@ { pos.x = Clamp(pos.x, 0.01f, gs->mapx * SQUARE_SIZE - 0.01f); pos.z = Clamp(pos.z, 0.01f, gs->mapy * SQUARE_SIZE - 0.01f); - pos.y = ground->GetHeightAboveWater(pos.x, pos.z, false); + pos.y = CGround::GetHeightAboveWater(pos.x, pos.z, false); camera->rot.x = Clamp(camera->rot.x, -PI * 0.4f, -0.1f); @@ -95,8 +95,8 @@ float dist = -camera->rot.x * 1500; float3 cpos = pos - dir * dist; - if (cpos.y < ground->GetHeightAboveWater(cpos.x, cpos.z, false) + 5) - cpos.y = ground->GetHeightAboveWater(cpos.x, cpos.z, false) + 5; + if (cpos.y < CGround::GetHeightAboveWater(cpos.x, cpos.z, false) + 5) + cpos.y = CGround::GetHeightAboveWater(cpos.x, cpos.z, false) + 5; return cpos; } diff -Nru spring-96.0~14.04~ppa4/rts/Game/Camera.cpp spring-98.0~14.04~ppa6/rts/Game/Camera.cpp --- spring-96.0~14.04~ppa4/rts/Game/Camera.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/Camera.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -198,7 +198,7 @@ // to {+/-}UpVector which would cause vector degeneracy when // calculating right and up // - if (std::fabs(forward.y) >= 0.99f) { + if (std::fabs(forward.y) >= 0.999f) { // make sure we can still yaw at limits of pitch // (since CamHandler only updates forward, which // is derived from rot) @@ -296,7 +296,6 @@ void CCamera::GetFrustumSides(float miny, float maxy, float scale, bool negSide) { - GML_RECMUTEX_LOCK(cam); // GetFrustumSides ClearFrustumSides(); // note: order does not matter @@ -315,7 +314,6 @@ bool upwardDir, bool negSide) { - GML_RECMUTEX_LOCK(cam); // GetFrustumSide // compose an orthonormal axis-system around float3 xdir = (zdir.cross(UpVector)).UnsafeANormalize(); float3 ydir = (zdir.cross(xdir)).UnsafeANormalize(); @@ -359,7 +357,6 @@ } void CCamera::ClipFrustumLines(bool neg, const float zmin, const float zmax) { - GML_RECMUTEX_LOCK(cam); // ClipFrustumLines std::vector& lines = neg? negFrustumSides: posFrustumSides; std::vector::iterator fli, fli2; @@ -392,12 +389,6 @@ float CCamera::GetMoveDistance(float* time, float* speed, int idx) const { - // NOTE: - // lastFrameTime is MUCH smaller when map edge is in view - // timer is not accurate enough to return non-zero values - // for the majority of the time this condition holds, and - // so the camera will barely react to key input since most - // frames will effectively be 'skipped' (looks like lag) float camDeltaTime = globalRendering->lastFrameTime; float camMoveSpeed = 1.0f; @@ -408,8 +399,8 @@ if (speed != NULL) { *speed = camMoveSpeed; } switch (idx) { - case MOVE_STATE_UP: { camMoveSpeed *= ( 1.0f * movState[idx]); } break; - case MOVE_STATE_DWN: { camMoveSpeed *= (-1.0f * movState[idx]); } break; + case MOVE_STATE_UP: { camMoveSpeed *= float(movState[idx]); } break; + case MOVE_STATE_DWN: { camMoveSpeed *= -float(movState[idx]); } break; default: { } break; @@ -418,14 +409,14 @@ return (camDeltaTime * 0.2f * camMoveSpeed); } -float3 CCamera::GetMoveVectorFromState(bool fromKeyState, bool* disableTracker) +float3 CCamera::GetMoveVectorFromState(bool fromKeyState) const { float camDeltaTime = 1.0f; float camMoveSpeed = 1.0f; (void) GetMoveDistance(&camDeltaTime, &camMoveSpeed, -1); - float3 v = FwdVector * camMoveSpeed; + float3 v; if (fromKeyState) { v.y += (camDeltaTime * 0.001f * movState[MOVE_STATE_FWD]); @@ -443,9 +434,7 @@ v.x -= (camDeltaTime * 0.001f * (mouse->lastx < 2)); } - (*disableTracker) |= (v.x != 0.0f); - (*disableTracker) |= (v.y != 0.0f); - + v.z = camMoveSpeed; return v; } diff -Nru spring-96.0~14.04~ppa4/rts/Game/Camera.h spring-98.0~14.04~ppa6/rts/Game/Camera.h --- spring-96.0~14.04~ppa4/rts/Game/Camera.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/Camera.h 2014-10-07 20:09:51.000000000 +0000 @@ -52,7 +52,6 @@ bool upwardDir, bool negSide); void ClearFrustumSides() { - GML_RECMUTEX_LOCK(cam); // ClearFrustumSides posFrustumSides.clear(); negFrustumSides.clear(); @@ -78,7 +77,7 @@ void SetFov(float fov); float GetMoveDistance(float* time, float* speed, int idx) const; - float3 GetMoveVectorFromState(bool fromKeyState, bool* disableTracker); + float3 GetMoveVectorFromState(bool fromKeyState) const; void SetMovState(int idx, bool b) { movState[idx] = b; } void SetRotState(int idx, bool b) { rotState[idx] = b; } @@ -112,12 +111,10 @@ }; const std::vector GetNegFrustumSides() const { - GML_RECMUTEX_LOCK(cam); // GetNegFrustumSides return negFrustumSides; } const std::vector GetPosFrustumSides() const { - GML_RECMUTEX_LOCK(cam); // GetPosFrustumSides return posFrustumSides; } diff -Nru spring-96.0~14.04~ppa4/rts/Game/CameraHandler.cpp spring-98.0~14.04~ppa6/rts/Game/CameraHandler.cpp --- spring-96.0~14.04~ppa4/rts/Game/CameraHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/CameraHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -128,7 +128,6 @@ void CCameraHandler::UpdateCam() { - GML_RECMUTEX_LOCK(cam); // UpdateCam //??? a lot CameraControllers depend on the calling every frame the 1st part of the if-clause //if (cameraTimeEnd < 0.0f) @@ -160,8 +159,6 @@ void CCameraHandler::CameraTransition(float nsecs) { - GML_RECMUTEX_LOCK(cam); // CameraTransition - UpdateCam(); // prevents camera stutter when multithreading nsecs = std::max(nsecs, 0.0f) * cameraTimeFactor; @@ -178,7 +175,6 @@ void CCameraHandler::SetCameraMode(unsigned int mode) { - GML_RECMUTEX_LOCK(cam); // SetCameraMode if ((mode >= camControllers.size()) || (mode == static_cast(currCamCtrlNum))) { return; @@ -197,7 +193,6 @@ void CCameraHandler::SetCameraMode(const std::string& modeName) { - GML_RECMUTEX_LOCK(cam); // SetCameraMode const int modeNum = GetModeIndex(modeName); if (modeNum >= 0) { @@ -209,7 +204,6 @@ int CCameraHandler::GetModeIndex(const std::string& name) const { - GML_RECMUTEX_LOCK(cam); // GetModeIndex std::map::const_iterator it = nameMap.find(name); if (it != nameMap.end()) { @@ -221,7 +215,6 @@ void CCameraHandler::PushMode() { - GML_RECMUTEX_LOCK(cam); // PushMode controllerStack.push(GetCurrentControllerNum()); } @@ -229,7 +222,6 @@ void CCameraHandler::PopMode() { - GML_RECMUTEX_LOCK(cam); // PopMode if (!controllerStack.empty()) { SetCameraMode(controllerStack.top()); @@ -240,7 +232,6 @@ void CCameraHandler::ToggleState() { - GML_RECMUTEX_LOCK(cam); // ToggleState CameraTransition(1.0f); @@ -268,7 +259,6 @@ void CCameraHandler::ToggleOverviewCamera() { - GML_RECMUTEX_LOCK(cam); // ToggleOverviewCamera CameraTransition(1.0f); if (controllerStack.empty()) { @@ -283,7 +273,6 @@ void CCameraHandler::SaveView(const std::string& name) { - GML_RECMUTEX_LOCK(cam); // SaveView if (name.empty()) return; @@ -297,7 +286,6 @@ bool CCameraHandler::LoadView(const std::string& name) { - GML_RECMUTEX_LOCK(cam); // LoadView if (name.empty()) { return false; @@ -329,7 +317,6 @@ void CCameraHandler::GetState(CCameraController::StateMap& sm) const { - GML_RECMUTEX_LOCK(cam); // GetState sm.clear(); sm["mode"] = (float)currCamCtrlNum; @@ -340,7 +327,6 @@ bool CCameraHandler::SetState(const CCameraController::StateMap& sm) { - GML_RECMUTEX_LOCK(cam); // SetState CCameraController::StateMap::const_iterator it = sm.find("mode"); if (it != sm.end()) { @@ -361,7 +347,6 @@ const std::string CCameraHandler::GetCurrentControllerName() const { - GML_RECMUTEX_LOCK(cam); // GetCurrentControllerName return currCamCtrl->GetName(); } @@ -369,7 +354,6 @@ void CCameraHandler::PushAction(const Action& action) { - GML_RECMUTEX_LOCK(cam); // PushAction const std::string cmd = action.command; @@ -408,6 +392,7 @@ } else { taCam->flipped = !taCam->flipped; } + taCam->KeyMove(ZeroVector); //FIXME add a more clean way to force a call to ::UpdateVectors() } if (smCam) { if (!action.extra.empty()) { @@ -415,6 +400,7 @@ } else { smCam->flipped = !smCam->flipped; } + smCam->KeyMove(ZeroVector); //FIXME add a more clean way to force a call to ::UpdateVectors() } } else if (cmd == "viewsave") { @@ -439,7 +425,6 @@ bool CCameraHandler::LoadViewData(const ViewData& vd) { - GML_RECMUTEX_LOCK(cam); // LoadViewData if (vd.empty()) { return false; diff -Nru spring-96.0~14.04~ppa4/rts/Game/ClientSetup.cpp spring-98.0~14.04~ppa6/rts/Game/ClientSetup.cpp --- spring-96.0~14.04~ppa4/rts/Game/ClientSetup.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/ClientSetup.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -4,6 +4,7 @@ #include "System/TdfParser.h" #include "System/Exceptions.h" +#include "System/MsgStrings.h" #include "System/Log/ILog.h" #include "System/Config/ConfigHandler.h" #include "System/Util.h" @@ -11,17 +12,30 @@ #include "System/Platform/errorhandler.h" #endif -static const unsigned int DEFAULT_HOST_PORT = 8452; -static const std::string DEFAULT_HOST_IP = ""; // -> any local address -static const std::string DEFAULT_HOST_PORT_STR = IntToString(DEFAULT_HOST_PORT); - -ClientSetup::ClientSetup(): - hostPort(DEFAULT_HOST_PORT), - isHost(false) + +CONFIG(std::string, HostIPDefault).defaultValue("localhost").description("Default IP to use for hosting if not specified in script.txt"); +CONFIG(int, HostPortDefault).defaultValue(8452).minimumValue(0).maximumValue(65535).description("Default Port to use for hosting if not specified in script.txt"); + +ClientSetup::ClientSetup() + : hostIP(configHandler->GetString("HostIPDefault")) + , hostPort(configHandler->GetInt("HostPortDefault")) + , isHost(false) +{ +} + + +void ClientSetup::SanityCheck() { + if (myPlayerName.empty()) myPlayerName = UnnamedPlayerName; + StringReplaceInPlace(myPlayerName, ' ', '_'); + + if (hostIP == "none") { + hostIP = ""; + } } -void ClientSetup::Init(const std::string& setup) + +void ClientSetup::LoadFromStartScript(const std::string& setup) { TdfParser file(setup.c_str(), setup.length()); @@ -30,14 +44,8 @@ } // Technical parameters - file.GetDef(hostIP, DEFAULT_HOST_IP, "GAME\\HostIP"); - if (StringToLower(hostIP) == "localhost") { - // FIXME temporary hack: we do not support (host-)names. - // "localhost" was the only name supported in the past. - // added 7. January 2011, to be removed in ~ 1 year - hostIP = "127.0.0.1"; - } - file.GetDef(hostPort, DEFAULT_HOST_PORT_STR, "GAME\\HostPort"); + file.GetDef(hostIP, hostIP, "GAME\\HostIP"); + file.GetDef(hostPort, IntToString(hostPort), "GAME\\HostPort"); file.GetDef(myPlayerName, "", "GAME\\MyPlayerName"); file.GetDef(myPasswd, "", "GAME\\MyPasswd"); @@ -51,6 +59,7 @@ } #endif + //FIXME WTF std::string sourceport, autohostip, autohostport; if (file.SGetValue(sourceport, "GAME\\SourcePort")) { configHandler->SetString("SourcePort", sourceport, true); @@ -61,11 +70,4 @@ if (file.SGetValue(autohostport, "GAME\\AutohostPort")) { configHandler->SetString("AutohostPort", autohostport, true); } - - if (file.SectionExist("OPTIONS")) { - const std::map& options = file.GetAllValues("OPTIONS"); - for (std::map::const_iterator it = options.begin(); it != options.end(); ++it) { - configHandler->SetString(it->first, it->second, true); - } - } } diff -Nru spring-96.0~14.04~ppa4/rts/Game/ClientSetup.h spring-98.0~14.04~ppa6/rts/Game/ClientSetup.h --- spring-96.0~14.04~ppa4/rts/Game/ClientSetup.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/ClientSetup.h 2014-10-07 20:09:51.000000000 +0000 @@ -5,12 +5,14 @@ #include + class ClientSetup { public: ClientSetup(); - void Init(const std::string& setup); + void LoadFromStartScript(const std::string& setup); + void SanityCheck(); std::string myPlayerName; std::string myPasswd; @@ -18,6 +20,7 @@ //! if this client is not the server player, the IP address we connect to //! if this client is the server player, the IP address that other players connect to std::string hostIP; + //! if this client is not the server player, the port which we connect over //! if this client is the server player, the port over which we accept incoming connections int hostPort; diff -Nru spring-96.0~14.04~ppa4/rts/Game/CMakeLists.txt spring-98.0~14.04~ppa6/rts/Game/CMakeLists.txt --- spring-96.0~14.04~ppa4/rts/Game/CMakeLists.txt 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -1,7 +1,7 @@ # This list was created using this *nix shell command: # > find . -name "*.cpp" | sort -SET(sources_engine_Game +MakeGlobalVar(sources_engine_Game "${CMAKE_CURRENT_SOURCE_DIR}/Action.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/AviVideoCapturing.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Benchmark.cpp" @@ -55,7 +55,6 @@ "${CMAKE_CURRENT_SOURCE_DIR}/UI/HwMouseCursor.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/UI/InfoConsole.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/UI/InputReceiver.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/UI/KeyAutoBinder.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/UI/KeyBindings.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/UI/KeyCodes.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/UI/KeySet.cpp" @@ -75,4 +74,3 @@ "${CMAKE_CURRENT_SOURCE_DIR}/WordCompletion.cpp" ) -MakeGlobal(sources_engine_Game) diff -Nru spring-96.0~14.04~ppa4/rts/Game/ConsoleHistory.cpp spring-98.0~14.04~ppa6/rts/Game/ConsoleHistory.cpp --- spring-96.0~14.04~ppa4/rts/Game/ConsoleHistory.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/ConsoleHistory.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,8 +1,5 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ -#include "lib/gml/gmlmut.h" - - #include "ConsoleHistory.h" @@ -25,8 +22,6 @@ void CConsoleHistory::ResetPosition() { - GML_STDMUTEX_LOCK(hist); // ResetPosition - pos = lines.end(); return; } @@ -34,8 +29,6 @@ bool CConsoleHistory::AddLine(const std::string& msg) { - GML_STDMUTEX_LOCK(hist); // AddLine - std::string message; if ((msg.find_first_of("aAsS") == 0) && (msg[1] == ':')) { message = msg.substr(2); @@ -72,8 +65,6 @@ std::string CConsoleHistory::NextLine(const std::string& current) { - GML_STDMUTEX_LOCK(hist); // NextLine - std::string prefix, message; if ((current.find_first_of("aAsS") == 0) && (current[1] == ':')) { prefix = current.substr(0, 2); @@ -111,8 +102,6 @@ std::string CConsoleHistory::PrevLine(const std::string& current) { - GML_STDMUTEX_LOCK(hist); // PrevLine - std::string prefix, message; if ((current.find_first_of("aAsS") == 0) && (current[1] == ':')) { prefix = current.substr(0, 2); diff -Nru spring-96.0~14.04~ppa4/rts/Game/FPSUnitController.cpp spring-98.0~14.04~ppa6/rts/Game/FPSUnitController.cpp --- spring-96.0~14.04~ppa4/rts/Game/FPSUnitController.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/FPSUnitController.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -50,9 +50,9 @@ CFeature* hitFeature; // SYNCED, do NOT use GuiTraceRay which also checks gu->spectatingFullView - float hitDist = TraceRay::TraceRay(pos, viewDir, controllee->maxRange, 0, controllee, hitUnit, hitFeature); + float hitDist = TraceRay::TraceRay(pos, viewDir, controllee->maxRange, Collision::NOCLOAKED, controllee, hitUnit, hitFeature); - if (hitUnit) { + if (hitUnit != NULL) { targetUnit = hitUnit; targetDist = hitDist; targetPos = hitUnit->pos; @@ -72,7 +72,7 @@ // projectiles can gain extra flighttime and travel further // // NOTE: CWeapon::AttackGround checks range via TryTarget - if ((targetPos.y - ground->GetHeightReal(targetPos.x, targetPos.z)) <= SQUARE_SIZE) { + if ((targetPos.y - CGround::GetHeightReal(targetPos.x, targetPos.z)) <= SQUARE_SIZE) { controllee->AttackGround(targetPos, true, true, true); } } diff -Nru spring-96.0~14.04~ppa4/rts/Game/GameController.cpp spring-98.0~14.04~ppa6/rts/Game/GameController.cpp --- spring-96.0~14.04~ppa4/rts/Game/GameController.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/GameController.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -12,7 +12,6 @@ : userWriting(false) , writingPos(0) , ignoreNextChar(false) - , ignoreChar(0) { } @@ -37,13 +36,13 @@ } -int CGameController::KeyPressed(unsigned short key, bool isRepeat) +int CGameController::KeyPressed(int key, bool isRepeat) { return 0; } -int CGameController::KeyReleased(unsigned short key) +int CGameController::KeyReleased(int key) { return 0; } diff -Nru spring-96.0~14.04~ppa4/rts/Game/GameController.h spring-98.0~14.04~ppa6/rts/Game/GameController.h --- spring-96.0~14.04~ppa4/rts/Game/GameController.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/GameController.h 2014-10-07 20:09:51.000000000 +0000 @@ -13,8 +13,8 @@ virtual bool Draw(); virtual bool Update(); - virtual int KeyPressed(unsigned short key, bool isRepeat); - virtual int KeyReleased(unsigned short key); + virtual int KeyPressed(int key, bool isRepeat); + virtual int KeyReleased(int key); virtual void ResizeEvent() {} /// true if user is writing @@ -22,7 +22,6 @@ /// current writing position int writingPos; bool ignoreNextChar; - char ignoreChar; std::string userInput; std::string userPrompt; diff -Nru spring-96.0~14.04~ppa4/rts/Game/Game.cpp spring-98.0~14.04~ppa6/rts/Game/Game.cpp --- spring-96.0~14.04~ppa4/rts/Game/Game.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/Game.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -17,7 +17,6 @@ #include "Camera.h" #include "CameraHandler.h" #include "ChatMessage.h" -#include "ClientSetup.h" #include "CommandMessage.h" #include "ConsoleHistory.h" #include "GameHelper.h" @@ -48,8 +47,9 @@ #include "Rendering/Env/ITreeDrawer.h" #include "Rendering/Env/IWater.h" #include "Rendering/Env/CubeMapHandler.h" +#include "Rendering/Fonts/CFontTexture.h" #include "Rendering/DebugColVolDrawer.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Rendering/FeatureDrawer.h" #include "Rendering/LineDrawer.h" #include "Rendering/Screenshot.h" @@ -80,6 +80,7 @@ #include "Lua/LuaSyncedRead.h" #include "Lua/LuaUI.h" #include "Lua/LuaUnsyncedCtrl.h" +#include "Lua/LuaUtils.h" #include "Map/BaseGroundDrawer.h" #include "Map/MapDamage.h" #include "Map/MapInfo.h" @@ -143,7 +144,6 @@ #include "System/FileSystem/ArchiveScanner.h" #include "System/FileSystem/FileSystem.h" #include "System/FileSystem/VFSHandler.h" -#include "System/FileSystem/SimpleParser.h" #include "System/LoadSave/LoadSaveHandler.h" #include "System/LoadSave/DemoRecorder.h" #include "System/Log/ILog.h" @@ -151,23 +151,17 @@ #include "System/Platform/CrashHandler.h" #include "System/Platform/Watchdog.h" #include "System/Sound/ISound.h" -#include "System/Sound/SoundChannels.h" +#include "System/Sound/ISoundChannels.h" #include "System/Sync/DumpState.h" #include "System/Sync/SyncedPrimitiveIO.h" #include "System/Sync/SyncTracer.h" #include "System/TimeProfiler.h" #include -#include "lib/lua/include/LuaUser.h" +#include #undef CreateDirectory -#ifdef USE_GML -#include "lib/gml/gmlsrv.h" -extern gmlClientServer* gmlProcessor; -#endif - - CONFIG(bool, WindowedEdgeMove).defaultValue(true).description("Sets whether moving the mouse cursor to the screen edge will move the camera across the map."); CONFIG(bool, FullscreenEdgeMove).defaultValue(true).description("see WindowedEdgeMove, just for fullscreen mode"); CONFIG(bool, ShowFPS).defaultValue(false).description("Displays current framerate."); @@ -183,7 +177,7 @@ CGame* game = NULL; -CR_BIND(CGame, (std::string(""), std::string(""), NULL)); +CR_BIND(CGame, (std::string(""), std::string(""), NULL)) CR_REG_METADATA(CGame, ( CR_IGNORED(finishedLoading), @@ -212,7 +206,6 @@ CR_MEMBER(gameID), //CR_MEMBER(infoConsole), //CR_MEMBER(consoleHistory), - CR_IGNORED(hotBinding), CR_IGNORED(inputTextPosX), CR_IGNORED(inputTextPosY), CR_IGNORED(inputTextSizeX), @@ -223,7 +216,7 @@ CR_IGNORED(consumeSpeedMult), CR_POSTLOAD(PostLoad) -)); +)) @@ -302,7 +295,7 @@ j.name = "EventHandler::CollectGarbage"; // static initialization is done BEFORE Spring's time-epoch is set JobDispatcher::AddJob(j, spring_notime + spring_time(j.startDirect ? 0 : (1000.0f / j.freq))); -); +) DO_ONCE_FNC( JobDispatcher::Job j; @@ -313,15 +306,15 @@ j.freq = 1; j.name = "Profiler::Update"; JobDispatcher::AddJob(j, spring_notime + spring_time(j.startDirect ? 0 : (1000.0f / j.freq))); -); +) CGame::CGame(const std::string& mapName, const std::string& modName, ILoadSaveHandler* saveFile) : gameDrawMode(gameNotDrawing) - , numDrawFrames(0) , lastSimFrame(-1) , lastNumQueuedSimFrames(-1) + , numDrawFrames(0) , frameStartTime(spring_gettime()) , lastSimFrameTime(spring_gettime()) , lastDrawFrameTime(spring_gettime()) @@ -333,10 +326,10 @@ , updateDeltaSeconds(0.0f) , totalGameTime(0) , hideInterface(false) - , noSpectatorChat(false) , skipping(false) , playing(false) , chatting(false) + , noSpectatorChat(false) , msgProcTimeLeft(0.0f) , consumeSpeedMult(1.0f) , skipStartFrame(0) @@ -348,11 +341,11 @@ , skipOldUserSpeed(0.0f) , skipLastDrawTime(spring_gettime()) , speedControl(-1) - , defsParser(NULL) - , saveFile(saveFile) , infoConsole(NULL) , consoleHistory(NULL) , worldDrawer(NULL) + , defsParser(NULL) + , saveFile(saveFile) , finishedLoading(false) , gameOver(false) { @@ -385,9 +378,6 @@ modInfo.Init(modName.c_str()); - GML::EnableCallChainWarnings(!!showMTInfo); - GML::Init(); // modinfo plays key part in MT enable/disable - // FIXME: THIS HAS ALREADY BEEN CALLED! (SpringApp::Initialize) // Threading::InitThreadPool(); Threading::SetThreadScheduler(); @@ -396,7 +386,7 @@ mapInfo = new CMapInfo(gameSetup->MapFile(), gameSetup->mapName); } - showMTInfo = (showMTInfo != 0)? globalConfig->GetMultiThreadLua() : -1; + showMTInfo = -1; if (!sideParser.Load()) { throw content_error(sideParser.GetErrorLog()); @@ -482,7 +472,7 @@ LOG("[%s][10]", __FUNCTION__); SafeDelete(pathManager); - SafeDelete(ground); + SafeDelete(readMap); SafeDelete(smoothGround); SafeDelete(groundBlockingObjectMap); SafeDelete(radarHandler); @@ -525,7 +515,6 @@ void CGame::LoadGame(const std::string& mapName, bool threaded) { - GML::ThreadNumber(GML_LOAD_THREAD_NUM); // NOTE: // this is needed for LuaHandle::CallOut*UpdateCallIn // the main-thread is NOT the same as the load-thread @@ -542,6 +531,8 @@ if (!gu->globalQuit) LoadInterface(); if (!gu->globalQuit) LoadLua(); if (!gu->globalQuit) LoadFinalize(); + if (!gu->globalQuit) InitSkirmishAIs(); + finishedLoading = true; if (!gu->globalQuit && saveFile) { loadscreen->SetLoadMessage("Loading game"); @@ -563,11 +554,10 @@ CWordCompletion::CreateInstance(); + loadscreen->SetLoadMessage("Parsing Map Information"); + // simulation components helper = new CGameHelper(); - ground = new CGround(); - - loadscreen->SetLoadMessage("Parsing Map Information"); readMap = CReadMap::LoadMap(mapName); groundBlockingObjectMap = new CGroundBlockingObjectMap(gs->mapSquares); @@ -640,7 +630,7 @@ ENTER_SYNCED_CODE(); loadscreen->SetLoadMessage("Creating Smooth Height Mesh"); - smoothGround = new SmoothHeightMesh(ground, float3::maxxpos, float3::maxzpos, SQUARE_SIZE * 2, SQUARE_SIZE * 40); + smoothGround = new SmoothHeightMesh(float3::maxxpos, float3::maxzpos, SQUARE_SIZE * 2, SQUARE_SIZE * 40); loadscreen->SetLoadMessage("Creating QuadField & CEGs"); moveDefHandler = new MoveDefHandler(defsParser); @@ -667,10 +657,27 @@ losHandler = new CLosHandler(); radarHandler = new CRadarHandler(false); + // pre-load the PFS, gets finalized after Lua + // + // features loaded from the map (and any terrain changes + // made by Lua while loading) would otherwise generate a + // queue of pending PFS updates, which should be consumed + // to avoid blocking regular updates from being processed + // but doing so was impossible without stalling the loading + // thread for *minutes* (in the worst-case scenario) + // + // the only disadvantage is that LuaPathFinder can not be + // used during Lua initialization anymore (not a concern) + // + // NOTE: + // the cache written to disk will reflect changes made by + // Lua which can vary each run with {mod,map}options, etc + // --> need a way to let Lua flush it or re-calculate map + // checksum (over heightmap + blockmap, not raw archive) mapDamage = IMapDamage::GetMapDamage(); pathManager = IPathManager::GetInstance(modInfo.pathFinderSystem); - // load map-specific features after pathManager so it knows about them (via TerrainChange) + // load map-specific features loadscreen->SetLoadMessage("Initializing Map Features"); featureHandler->LoadFeaturesFromMap(saveFile != NULL); @@ -817,13 +824,43 @@ defsParser = NULL; } +void CGame::InitSkirmishAIs() +{ + if (gameSetup->hostDemo) { + return; + } + + // create a Skirmish AI if required + const CSkirmishAIHandler::ids_t& localAIs = skirmishAIHandler.GetSkirmishAIsByPlayer(gu->myPlayerNum); + + if (!localAIs.empty()) { + loadscreen->SetLoadMessage("Loading Skirmish AIs"); + + for (auto ai = localAIs.begin(); ai != localAIs.end(); ++ai) { + skirmishAIHandler.CreateLocalSkirmishAI(*ai); + } + } +} + void CGame::LoadFinalize() { - loadscreen->SetLoadMessage("Initializing PathCache"); + ENTER_SYNCED_CODE(); eventHandler.GamePreload(); - pathManager->UpdateFull(); // mapfeatures are not in written pathcaches, so we need to repath those & other stuff done by Lua + LEAVE_SYNCED_CODE(); - loadscreen->SetLoadMessage("Finalizing"); + { + loadscreen->SetLoadMessage("[" + std::string(__FUNCTION__) + "] finalizing PFS"); + + ENTER_SYNCED_CODE(); + const boost::uint64_t dt = pathManager->Finalize(); + const boost::uint32_t cs = pathManager->GetPathCheckSum(); + LEAVE_SYNCED_CODE(); + + loadscreen->SetLoadMessage( + "[" + std::string(__FUNCTION__) + "] finalized PFS " + + "(" + IntToString(dt, "%ld") + "ms, checksum " + IntToString(cs, "%08x") + ")" + ); + } if (CBenchmark::enabled) { static CBenchmark benchmark; @@ -833,8 +870,6 @@ lastSimFrameTime = lastReadNetTime; lastDrawFrameTime = lastReadNetTime; updateDeltaSeconds = 0.0f; - - finishedLoading = true; } @@ -861,36 +896,24 @@ } -int CGame::KeyPressed(unsigned short key, bool isRepeat) +int CGame::KeyPressed(int key, bool isRepeat) { if (!gameOver && !isRepeat) { playerHandler->Player(gu->myPlayerNum)->currentStats.keyPresses++; } - // Get the list of possible key actions const CKeySet ks(key, false); - const CKeyBindings::ActionList& actionList = keyBindings->GetActionList(ks); + curKeyChain.push_back(key, spring_gettime(), isRepeat); - if (!hotBinding.empty()) { - if (key == SDLK_ESCAPE) { - hotBinding.clear(); - } - else if (!keyCodes->IsModifier(key) && (key != keyBindings->GetFakeMetaKey())) { - string cmd = "bind"; - cmd += " " + ks.GetString(false); - cmd += " " + hotBinding; - keyBindings->ExecuteCommand(cmd); - hotBinding.clear(); - LOG("%s", cmd.c_str()); - } - return 0; - } + // Get the list of possible key actions + //LOG_L(L_DEBUG, "curKeyChain: %s", curKeyChain.GetString().c_str()); + const CKeyBindings::ActionList& actionList = keyBindings->GetActionList(curKeyChain); if (userWriting) { - for (unsigned int actionIndex = 0; actionIndex < actionList.size(); actionIndex++) { - if (ProcessKeyPressAction(key, actionList[actionIndex])) { + for (const Action& action: actionList) { + if (ProcessKeyPressAction(key, action)) { // the key was used, ignore it (ex: alt+a) - ignoreNextChar = (actionIndex < (actionList.size() - 1)); + ignoreNextChar = true; break; } } @@ -899,26 +922,24 @@ } // try the input receivers - std::list& inputReceivers = GetInputReceivers(); - std::list::iterator ri; - for (ri = inputReceivers.begin(); ri != inputReceivers.end(); ++ri) { - CInputReceiver* recv = *ri; + for (CInputReceiver* recv: GetInputReceivers()) { if (recv && recv->KeyPressed(key, isRepeat)) { return 0; } } + // try our list of actions - for (unsigned int i = 0; i < actionList.size(); ++i) { - if (ActionPressed(key, actionList[i], isRepeat)) { + for (const Action& action: actionList) { + if (ActionPressed(key, action, isRepeat)) { return 0; } } // maybe a widget is interested? - if (guihandler != NULL) { - for (unsigned int i = 0; i < actionList.size(); ++i) { - guihandler->PushLayoutCommand(actionList[i].rawline, false); + if (luaUI != NULL) { + for (const Action& action: actionList) { + luaUI->GotChatMsg(action.rawline, false); } } @@ -926,17 +947,14 @@ } -int CGame::KeyReleased(unsigned short k) +int CGame::KeyReleased(int k) { - if ((userWriting) && (((k>=' ') && (k<='Z')) || (k==8) || (k==190))) { + if (userWriting && keyCodes->IsPrintable(k)) { return 0; } // try the input receivers - std::list& inputReceivers = GetInputReceivers(); - std::list::iterator ri; - for (ri = inputReceivers.begin(); ri != inputReceivers.end(); ++ri) { - CInputReceiver* recv = *ri; + for (CInputReceiver* recv: GetInputReceivers()) { if (recv && recv->KeyReleased(k)) { return 0; } @@ -945,8 +963,8 @@ // try our list of actions CKeySet ks(k, true); const CKeyBindings::ActionList& al = keyBindings->GetActionList(ks); - for (int i = 0; i < (int)al.size(); ++i) { - if (ActionReleased(al[i])) { + for (const Action& action: al) { + if (ActionReleased(action)) { return 0; } } @@ -965,11 +983,6 @@ JobDispatcher::Update(); net->Update(); - //TODO: why? it already gets called with `true` in ::Draw()? - if (!skipping) { - UpdateUI(false); - } - // When video recording do step by step simulation, so each simframe gets a corresponding videoframe // FIXME: SERVER ALREADY DOES THIS BY ITSELF if (videoCapturing->IsCapturing() && playing && gameServer != NULL) { @@ -982,8 +995,7 @@ if (!gameOver) { if (net->NeedsReconnect()) { - extern ClientSetup* startsetup; - net->AttemptReconnect(startsetup->myPlayerName, startsetup->myPasswd, SpringVersion::GetFull()); + net->AttemptReconnect(SpringVersion::GetFull()); } if (net->CheckTimeout(0, gs->frameNum == 0)) { @@ -1045,10 +1057,8 @@ skipLastDrawTime = currentTime; - if (!GML::SimEnabled() || !GML::MultiThreadSim()) { - DrawSkip(); - return true; - } + DrawSkip(); + return true; } numDrawFrames++; @@ -1071,7 +1081,6 @@ frameStartTime = currentTime; numDrawFrames = 0; - if (GML::SimEnabled()) GML_RESET_LOCK_TIME(); //FIXME move to a GML update place? } const bool doDrawWorld = hideInterface || !minimap->GetMaximized() || minimap->GetMinimized(); @@ -1079,6 +1088,7 @@ lastSimFrame = gs->frameNum; // set camera + UpdateCam(); camHandler->UpdateCam(); camera->Update(); @@ -1088,7 +1098,7 @@ if (doDrawWorld) { worldDrawer->Update(); CNamedTextures::Update(); - modelParser->Update(); + CFontTexture::Update(); if (newSimFrame) { projectileDrawer->UpdateTextures(); @@ -1115,11 +1125,9 @@ sound->UpdateListener(camera->GetPos(), camera->forward, camera->up, unsyncedUpdateDeltaTime); } - UpdateUI(true); - SetDrawMode(gameNormalDraw); //TODO move to ::Draw()? - if (luaUI) { luaUI->CheckStack(); luaUI->ExecuteUIEventBatch(); } + if (luaUI) { luaUI->CheckStack(); } if (luaGaia) { luaGaia->CheckStack(); } if (luaRules) { luaRules->CheckStack(); } @@ -1129,45 +1137,59 @@ LOG_L(L_ERROR, "5 errors deep in LuaUI, disabling..."); } - guihandler->PushLayoutCommand("disable"); + CLuaUI::FreeHandler(); LOG_L(L_ERROR, "Type '/luaui reload' in the chat to re-enable LuaUI."); LOG_L(L_ERROR, "===>>> Please report this error to the forum or mantis with your infolog.txt"); } + if (chatting && !userWriting) { + consoleHistory->AddLine(userInput); + + std::string msg = userInput; + std::string pfx = ""; + + if ((userInput.find_first_of("aAsS") == 0) && (userInput[1] == ':')) { + pfx = userInput.substr(0, 2); + msg = userInput.substr(2); + } + if ((msg[0] == '/') && (msg[1] == '/')) { + msg = msg.substr(1); + } + userInput = pfx + msg; + SendNetChat(userInput); + chatting = false; + userInput = ""; + writingPos = 0; + } + + if (inMapDrawer->IsWantLabel() && !userWriting) { + if (userInput.size() > 200) { + // avoid troubles with long lines + userInput = userInput.substr(0, 200); + writingPos = (int)userInput.length(); + } + inMapDrawer->SendWaitingInput(userInput); + userInput = ""; + writingPos = 0; + } + assert(infoConsole); infoConsole->PushNewLinesToEventHandler(); + infoConsole->Update(); configHandler->Update(); mouse->Update(); mouse->UpdateCursors(); guihandler->Update(); - LuaUnsyncedCtrl::ClearUnitCommandQueues(); eventHandler.Update(); + eventHandler.DbgTimingInfo(TIMING_UNSYNCED, currentTime, spring_now()); return false; } -#if defined(USE_GML) && GML_ENABLE_DRAW bool CGame::Draw() { - gmlProcessor->Work(&CGame::DrawMTcb,NULL,NULL,this,GML::ThreadCount(),TRUE,NULL,1,2,2,FALSE); - return true; -} -#else -bool CGame::DrawMT() { - return true; -} -#endif - - -#if defined(USE_GML) && GML_ENABLE_DRAW -bool CGame::DrawMT() { -#else -bool CGame::Draw() { -#endif - GML_STDMUTEX_LOCK(draw); //Draw - const spring_time currentTimePreUpdate = spring_gettime(); if (UpdateUnsynced(currentTimePreUpdate)) @@ -1303,8 +1325,7 @@ if (!hideInterface) { std::list& inputReceivers = GetInputReceivers(); - std::list::reverse_iterator ri; - for (ri = inputReceivers.rbegin(); ri != inputReceivers.rend(); ++ri) { + for (auto ri = inputReceivers.rbegin(); ri != inputReceivers.rend(); ++ri) { CInputReceiver* rcvr = *ri; if (rcvr) { rcvr->Draw(); @@ -1320,106 +1341,35 @@ glEnable(GL_TEXTURE_2D); - #define DBG_FONT_FLAGS (FONT_SCALE | FONT_NORM | FONT_SHADOW) #define KEY_FONT_FLAGS (FONT_SCALE | FONT_CENTER | FONT_NORM) #define INF_FONT_FLAGS (FONT_RIGHT | FONT_SCALE | FONT_NORM | (FONT_OUTLINE * guihandler->GetOutlineFonts())) - if (globalRendering->drawdebug) { - //print some infos (fps,gameframe,particles) - font->Begin(); - font->SetTextColor(1,1,0.5f,0.8f); - - font->glFormat(0.03f, 0.02f, 1.0f, DBG_FONT_FLAGS, "FPS: %0.1f SimFPS: %0.1f SimFrame: %d Speed: %2.2f (%2.2f) Particles: %d (%d)", - globalRendering->FPS, gu->simFPS, gs->frameNum, gs->speedFactor, gs->wantedSpeedFactor, projectileHandler->syncedProjectiles.size() + projectileHandler->unsyncedProjectiles.size(), projectileHandler->currentParticles); - - // 16ms := 60fps := 30simFPS + 30drawFPS - font->glFormat(0.03f, 0.07f, 0.7f, DBG_FONT_FLAGS, "avgFrame: %s%2.1fms\b avgDrawFrame: %s%2.1fms\b avgSimFrame: %s%2.1fms\b", - (gu->avgFrameTime > 30) ? "\xff\xff\x01\x01" : "", gu->avgFrameTime, - (gu->avgDrawFrameTime > 16) ? "\xff\xff\x01\x01" : "", gu->avgDrawFrameTime, - (gu->avgSimFrameTime > 16) ? "\xff\xff\x01\x01" : "", gu->avgSimFrameTime - ); - - const int2 pfsUpdates = pathManager->GetNumQueuedUpdates(); - const char* fmtString = "[%s-PFS] queued updates: %i %i"; - - switch (pathManager->GetPathFinderType()) { - case PFS_TYPE_DEFAULT: { - font->glFormat(0.03f, 0.12f, 0.7f, DBG_FONT_FLAGS, fmtString, "DEFAULT", pfsUpdates.x, pfsUpdates.y); - } break; - case PFS_TYPE_QTPFS: { - font->glFormat(0.03f, 0.12f, 0.7f, DBG_FONT_FLAGS, fmtString, "QT", pfsUpdates.x, pfsUpdates.y); - } break; - } - - SLuaInfo luaInfo = {0, 0, 0, 0}; - spring_lua_alloc_get_stats(&luaInfo); - - font->glFormat( - 0.03f, 0.15f, 0.7f, DBG_FONT_FLAGS, - "Lua-allocated memory: %.1fMB (%.5uK allocs : %.5u usecs : %.1u states)", - luaInfo.allocedBytes / 1024.0f / 1024.0f, - luaInfo.numLuaAllocs / 1000, - luaInfo.luaAllocTime, - luaInfo.numLuaStates - ); - - font->End(); - } - if (userWriting) { DrawInputText(); } - if (!hotBinding.empty()) { - glColor4f(1.0f, 0.3f, 0.3f, 1.0f); - font->glPrint(0.5f, 0.6f, 3.0f, KEY_FONT_FLAGS, "Hit keyset for:"); - glColor4f(0.3f, 1.0f, 0.3f, 1.0f); - font->glFormat(0.5f, 0.5f, 3.0f, KEY_FONT_FLAGS, "%s", hotBinding.c_str()); - glColor4f(0.3f, 0.3f, 1.0f, 1.0f); - font->glPrint(0.5f, 0.4f, 3.0f, KEY_FONT_FLAGS, "(or Escape)"); - } - if (!hideInterface) { smallFont->Begin(); if (showClock) { - char buf[32]; const int seconds = (gs->frameNum / GAME_SPEED); if (seconds < 3600) { - SNPRINTF(buf, sizeof(buf), "%02i:%02i", seconds / 60, seconds % 60); + smallFont->glFormat(0.99f, 0.94f, 1.0f, INF_FONT_FLAGS, "%02i:%02i", seconds / 60, seconds % 60); } else { - SNPRINTF(buf, sizeof(buf), "%02i:%02i:%02i", seconds / 3600, (seconds / 60) % 60, seconds % 60); + smallFont->glFormat(0.99f, 0.94f, 1.0f, INF_FONT_FLAGS, "%02i:%02i:%02i", seconds / 3600, (seconds / 60) % 60, seconds % 60); } - - smallFont->glPrint(0.99f, 0.94f, 1.0f, INF_FONT_FLAGS, buf); } if (showFPS) { - char buf[32]; - SNPRINTF(buf, sizeof(buf), "%.0f", globalRendering->FPS); - const float4 yellow(1.0f, 1.0f, 0.25f, 1.0f); smallFont->SetColors(&yellow,NULL); - smallFont->glPrint(0.99f, 0.92f, 1.0f, INF_FONT_FLAGS, buf); + smallFont->glFormat(0.99f, 0.92f, 1.0f, INF_FONT_FLAGS, "%.0f", globalRendering->FPS); } if (showSpeed) { - char buf[32]; - SNPRINTF(buf, sizeof(buf), "%2.2f", gs->speedFactor); - const float4 speedcol(1.0f, gs->speedFactor < gs->wantedSpeedFactor * 0.99f ? 0.25f : 1.0f, 0.25f, 1.0f); smallFont->SetColors(&speedcol, NULL); - smallFont->glPrint(0.99f, 0.90f, 1.0f, INF_FONT_FLAGS, buf); - } - - if (GML::SimEnabled() && showMTInfo != -1) { - const char* pstr = "LUA-EXP-SIZE(MT): %2.1fK LUA-SYNC-CPU(MT): %2.1fms"; - char buf[80]; - SNPRINTF(buf, sizeof(buf), pstr, LuaUtils::exportedDataSize / 1000.0f, GML_LOCK_TIME()); - const float warnMix = std::max(LuaUtils::exportedDataSize / 5000.0f, (GML_LOCK_TIME() - 1.0f) / 50.0f); - const float4 warncol(float(spring_tomsecs(currentTimePreDraw) & 128) * warnMix, 1.0f - warnMix, 0.0f,1.0f); - smallFont->SetColors(&warncol, NULL); - smallFont->glPrint(0.99f, 0.88f, 1.0f, INF_FONT_FLAGS, buf); + smallFont->glFormat(0.99f, 0.90f, 1.0f, INF_FONT_FLAGS, "%2.2f", gs->speedFactor); } CPlayerRosterDrawer::Draw(); @@ -1427,9 +1377,6 @@ smallFont->End(); } - if (GML::SimEnabled() && skipping) - DrawSkip(false); - mouse->DrawCursor(); glEnable(GL_DEPTH_TEST); @@ -1443,6 +1390,8 @@ const spring_time currentTimePostDraw = spring_gettime(); gu->avgDrawFrameTime = mix(gu->avgDrawFrameTime, (currentTimePostDraw - currentTimePreDraw).toMilliSecsf(), 0.05f); + eventHandler.DbgTimingInfo(TIMING_VIDEO, currentTimePreDraw, currentTimePostDraw); + return true; } @@ -1472,20 +1421,23 @@ const string tempstring = userPrompt + userInput; // draw the caret - const int caretPos = userPrompt.length() + writingPos; - const string caretStr = tempstring.substr(0, caretPos); - const float caretWidth = fontSize * font->GetTextWidth(caretStr) * globalRendering->pixelX; - - char c = (writingPos >= userInput.size()) ? '\0' : userInput[writingPos]; - if (c == 0) { c = ' '; } - - const float cw = fontSize * font->GetCharacterWidth(c) * globalRendering->pixelX; - const float csx = inputTextPosX + caretWidth; - glDisable(GL_TEXTURE_2D); - const float f = 0.5f * (1.0f + fastmath::sin(spring_now().toMilliSecsf() * 0.015f)); - glColor4f(f, f, f, 0.75f); - glRectf(csx, inputTextPosY, csx + cw, inputTextPosY + fontSize * font->GetLineHeight() * globalRendering->pixelY); - glEnable(GL_TEXTURE_2D); + { + const int caretPosStr = userPrompt.length() + writingPos; + const string caretStr = tempstring.substr(0, caretPosStr); + const float caretPos = fontSize * font->GetTextWidth(caretStr) * globalRendering->pixelX; + const float caretHeight = fontSize * font->GetLineHeight() * globalRendering->pixelY; + int cpos = writingPos; + char32_t c = Utf8GetNextChar(userInput, cpos); + if (c == 0) c = ' '; // make caret always visible + const float cw = fontSize * font->GetCharacterWidth(c) * globalRendering->pixelX; + const float csx = inputTextPosX + caretPos; + + glDisable(GL_TEXTURE_2D); + const float f = 0.5f * (1.0f + fastmath::sin(spring_now().toMilliSecsf() * 0.015f)); + glColor4f(f, f, f, 0.75f); + glRectf(csx, inputTextPosY, csx + cw, inputTextPosY + caretHeight); + glEnable(GL_TEXTURE_2D); + } // setup the color static float4 const defColor(1.0f, 1.0f, 1.0f, 1.0f); @@ -1541,18 +1493,6 @@ // TODO: notify Lua of this also? team->SetDefaultStartPos(); } - - // create a Skirmish AI if required - // TODO: is this needed? - if (!gameSetup->hostDemo) { - const CSkirmishAIHandler::ids_t& localAIs = skirmishAIHandler.GetSkirmishAIsInTeam(a, gu->myPlayerNum); - - CSkirmishAIHandler::ids_t::const_iterator ai; - - for (ai = localAIs.begin(); ai != localAIs.end(); ++ai) { - skirmishAIHandler.CreateLocalSkirmishAI(*ai); - } - } } eventHandler.GameStart(); @@ -1566,7 +1506,6 @@ // and both share the same SimFrame! eventHandler.GameFrame(0); - GML::PrintStartupMessage(showMTInfo); } @@ -1588,7 +1527,6 @@ if (!skipping) { // everything here is unsynced and should ideally moved to Game::Update() - infoConsole->Update(); waitCommandsAI.Update(); geometricObjects->Update(); sound->NewFrame(); @@ -1627,6 +1565,8 @@ gu->avgSimFrameTime = mix(gu->avgSimFrameTime, (lastSimFrameTime - lastFrameTime).toMilliSecsf(), 0.05f); gu->avgSimFrameTime = std::max(gu->avgSimFrameTime, 0.001f); + eventHandler.DbgTimingInfo(TIMING_SIM, lastFrameTime, lastSimFrameTime); + #ifdef HEADLESS { const float msecMaxSimFrameTime = 1000.0f / (GAME_SPEED * gs->wantedSpeedFactor); @@ -1647,87 +1587,42 @@ } - -void CGame::UpdateUI(bool updateCam) +void CGame::UpdateCam() { - if (updateCam) { - CPlayer* player = playerHandler->Player(gu->myPlayerNum); - FPSUnitController& fpsCon = player->fpsController; - - if (fpsCon.oldDCpos != ZeroVector) { - GML_STDMUTEX_LOCK(pos); // UpdateUI + //FIXME move to camHandler - camHandler->GetCurrentController().SetPos(fpsCon.oldDCpos); - fpsCon.oldDCpos = ZeroVector; - } + CCameraController& cc = camHandler->GetCurrentController(); + FPSUnitController& fpsCon = playerHandler->Player(gu->myPlayerNum)->fpsController; + if (fpsCon.oldDCpos != ZeroVector) { + cc.SetPos(fpsCon.oldDCpos); + fpsCon.oldDCpos = ZeroVector; } if (!gu->fpsMode) { - bool disableTracker = false; - float3 camMoveVector = camera->GetMoveVectorFromState(true, &disableTracker); - - if (!updateCam) { - if (disableTracker && camHandler->GetCurrentController().DisableTrackingByKey()) { - unitTracker.Disable(); - } - } else { - camHandler->GetCurrentController().KeyMove(camMoveVector); - } + // Note: GetMoveVectorFromState doesn't return a vec3, instead it returns a xy-vector and in its + // z-component it returns a speed scaling factor! - // cancel out x- and y-components, leave .z (movement-speed) - camMoveVector *= FwdVector; + // key scrolling + const float3 camMoveVector = camera->GetMoveVectorFromState(true); + const bool moved = ((camMoveVector * XYVector).SqLength() > 0.0f); + if (moved && cc.DisableTrackingByKey()) unitTracker.Disable(); + if (moved) cc.KeyMove(camMoveVector); + // screen edge scrolling if ((globalRendering->fullScreen && fullscreenEdgeMove) || (!globalRendering->fullScreen && windowedEdgeMove)) { - disableTracker = false; - camMoveVector = camera->GetMoveVectorFromState(false, &disableTracker); - - if (!updateCam && disableTracker) { - unitTracker.Disable(); - } + const float3 camMoveVector = camera->GetMoveVectorFromState(false); + const bool moved = ((camMoveVector * XYVector).SqLength() > 0.0f); + if (moved) unitTracker.Disable(); + if (moved) cc.ScreenEdgeMove(camMoveVector); } - if (updateCam) { - camHandler->GetCurrentController().ScreenEdgeMove(camMoveVector); - camHandler->GetCurrentController().MouseWheelMove(camera->GetMoveDistance(NULL, NULL, CCamera::MOVE_STATE_UP )); - camHandler->GetCurrentController().MouseWheelMove(camera->GetMoveDistance(NULL, NULL, CCamera::MOVE_STATE_DWN)); - } + // mouse wheel zoom + float mouseWheelDir = camera->GetMoveDistance(NULL, NULL, CCamera::MOVE_STATE_UP); + mouseWheelDir += camera->GetMoveDistance(NULL, NULL, CCamera::MOVE_STATE_DWN); + if (math::fabsf(mouseWheelDir) > 0.0f) cc.MouseWheelMove(mouseWheelDir); } - if (updateCam) { - camHandler->GetCurrentController().Update(); - - if (chatting && !userWriting) { - consoleHistory->AddLine(userInput); - - string msg = userInput; - string pfx = ""; - - if ((userInput.find_first_of("aAsS") == 0) && (userInput[1] == ':')) { - pfx = userInput.substr(0, 2); - msg = userInput.substr(2); - } - if ((msg[0] == '/') && (msg[1] == '/')) { - msg = msg.substr(1); - } - userInput = pfx + msg; - SendNetChat(userInput); - chatting = false; - userInput = ""; - writingPos = 0; - } - - if (inMapDrawer->IsWantLabel() && !userWriting) { - if (userInput.size() > 200) { - // avoid troubles with long lines - userInput = userInput.substr(0, 200); - writingPos = (int)userInput.length(); - } - inMapDrawer->SendWaitingInput(userInput); - userInput = ""; - writingPos = 0; - ignoreChar = 0; - } - } + cc.Update(); } @@ -1856,20 +1751,20 @@ const bool allied = teamHandler->Ally(msgAllyTeam, gu->myAllyTeam); if (gu->spectating || (allied && !player->spectator)) { LOG("%sAllies: %s", label.c_str(), s.c_str()); - Channels::UserInterface.PlaySample(chatSound, 5); + Channels::UserInterface->PlaySample(chatSound, 5); } } else if (msg.destination == ChatMessage::TO_SPECTATORS) { if (gu->spectating || myMsg) { LOG("%sSpectators: %s", label.c_str(), s.c_str()); - Channels::UserInterface.PlaySample(chatSound, 5); + Channels::UserInterface->PlaySample(chatSound, 5); } } else if (msg.destination == ChatMessage::TO_EVERYONE) { const bool specsOnly = noSpectatorChat && (player && player->spectator); if (gu->spectating || !specsOnly) { LOG("%s%s", label.c_str(), s.c_str()); - Channels::UserInterface.PlaySample(chatSound, 5); + Channels::UserInterface->PlaySample(chatSound, 5); } } else if ((msg.destination < playerHandler->ActivePlayers()) && player) @@ -1877,7 +1772,7 @@ // player <-> player and spectator <-> spectator are allowed if (msg.destination == gu->myPlayerNum && player->spectator == gu->spectating) { LOG("%sPrivate: %s", label.c_str(), s.c_str()); - Channels::UserInterface.PlaySample(chatSound, 5); + Channels::UserInterface->PlaySample(chatSound, 5); } else if (player->playerNum == gu->myPlayerNum) { @@ -2013,113 +1908,6 @@ } - -void CGame::SelectUnits(const string& line) -{ - const vector &args = CSimpleParser::Tokenize(line, 0); - for (int i = 0; i < (int)args.size(); i++) { - const string& arg = args[i]; - if (arg == "clear") { - selectedUnitsHandler.ClearSelected(); - } - else if ((arg[0] == '+') || (arg[0] == '-')) { - char* endPtr; - const char* startPtr = arg.c_str() + 1; - const int unitIndex = strtol(startPtr, &endPtr, 10); - if (endPtr == startPtr) { - continue; // bad number - } - if ((unitIndex < 0) || (static_cast(unitIndex) >= unitHandler->MaxUnits())) { - continue; // bad index - } - CUnit* unit = unitHandler->units[unitIndex]; - if (unit == NULL) { - continue; // bad pointer - } - if (!gu->spectatingFullSelect) { - const CUnitSet& teamUnits = teamHandler->Team(gu->myTeam)->units; - if (teamUnits.find(unit) == teamUnits.end()) { - continue; // not mine to select - } - } - - // perform the selection - if (arg[0] == '+') { - selectedUnitsHandler.AddUnit(unit); - } else { - selectedUnitsHandler.RemoveUnit(unit); - } - } - } -} - - -void CGame::SelectCycle(const string& command) -{ - static set unitIDs; - static int lastID = -1; - - GML_RECMUTEX_LOCK(sel); // SelectCycle - - const CUnitSet& selUnits = selectedUnitsHandler.selectedUnits; - - if (command == "restore") { - selectedUnitsHandler.ClearSelected(); - set::const_iterator it; - for (it = unitIDs.begin(); it != unitIDs.end(); ++it) { - CUnit* unit = unitHandler->units[*it]; - if (unit != NULL) { - selectedUnitsHandler.AddUnit(unit); - } - } - return; - } - - if (selUnits.size() >= 2) { - // assign the cycle units - unitIDs.clear(); - CUnitSet::const_iterator it; - for (it = selUnits.begin(); it != selUnits.end(); ++it) { - unitIDs.insert((*it)->id); - } - selectedUnitsHandler.ClearSelected(); - lastID = *unitIDs.begin(); - selectedUnitsHandler.AddUnit(unitHandler->units[lastID]); - return; - } - - // clean the list - set tmpSet; - set::const_iterator it; - for (it = unitIDs.begin(); it != unitIDs.end(); ++it) { - if (unitHandler->units[*it] != NULL) { - tmpSet.insert(*it); - } - } - unitIDs = tmpSet; - if ((lastID >= 0) && (unitHandler->units[lastID] == NULL)) { - lastID = -1; - } - - // selectedUnits size is 0 or 1 - selectedUnitsHandler.ClearSelected(); - if (!unitIDs.empty()) { - set::const_iterator fit = unitIDs.find(lastID); - if (fit == unitIDs.end()) { - lastID = *unitIDs.begin(); - } else { - ++fit; - if (fit != unitIDs.end()) { - lastID = *fit; - } else { - lastID = *unitIDs.begin(); - } - } - selectedUnitsHandler.AddUnit(unitHandler->units[lastID]); - } -} - - //FIXME remove! void CGame::ReColorTeams() { @@ -2178,8 +1966,8 @@ } // maybe a widget is interested? - if (guihandler != NULL) { - guihandler->PushLayoutCommand(action.rawline, false); //FIXME add return argument! + if (luaUI != NULL) { + luaUI->GotChatMsg(action.rawline, false); //FIXME add return argument! } return false; @@ -2195,8 +1983,8 @@ SyncedAction syncedAction(action, playerID); executor->ExecuteAction(syncedAction); } else if (gs->frameNum > 1) { - if (luaRules) luaRules->SyncedActionFallback(action.rawline, playerID); - if (luaGaia) luaGaia->SyncedActionFallback(action.rawline, playerID); + eventHandler.SyncedActionFallback(action.rawline, playerID); + //FIXME add unsynced one? } } diff -Nru spring-96.0~14.04~ppa4/rts/Game/Game.h spring-98.0~14.04~ppa6/rts/Game/Game.h --- spring-96.0~14.04~ppa4/rts/Game/Game.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/Game.h 2014-10-07 20:09:51.000000000 +0000 @@ -5,15 +5,14 @@ #include #include -#include #include "GameController.h" +#include "Game/UI/KeySet.h" #include "System/creg/creg_cond.h" #include "System/Misc/SpringTime.h" class IWater; class CConsoleHistory; -class CKeySet; class CInfoConsole; class LuaParser; class LuaInputReceiver; @@ -29,7 +28,7 @@ class CGame : public CGameController { private: - CR_DECLARE_STRUCT(CGame); + CR_DECLARE_STRUCT(CGame) public: CGame(const std::string& mapName, const std::string& modName, ILoadSaveHandler* saveFile); @@ -65,6 +64,7 @@ void PostLoadRendering(); void LoadInterface(); void LoadLua(); + void InitSkirmishAIs(); void LoadFinalize(); void PostLoad(); @@ -85,11 +85,6 @@ bool ProcessKeyPressAction(unsigned int key, const Action& action); bool ProcessAction(const Action& action, unsigned int key = -1, bool isRepeat = false); - void SetHotBinding(const std::string& action) { hotBinding = action; } - - void SelectUnits(const std::string& line); - void SelectCycle(const std::string& command); - void ReloadCOB(const std::string& msg, int player); void ReloadCEGs(const std::string& tag); @@ -116,15 +111,15 @@ void DrawSkip(bool blackscreen = true); void DrawInputText(); - void UpdateUI(bool cam); + void UpdateCam(); /// Format and display a chat message received over network void HandleChatMsg(const ChatMessage& msg); /// Called when a key is released by the user - int KeyReleased(unsigned short k); + int KeyReleased(int k); /// Called when the key is pressed by the user (can be called several times due to key repeat) - int KeyPressed(unsigned short k, bool isRepeat); + int KeyPressed(int k, bool isRepeat); bool ActionPressed(unsigned int key, const Action& action, bool isRepeat); bool ActionReleased(const Action& action); @@ -191,7 +186,7 @@ /// Prevents spectator msgs from being seen by players bool noSpectatorChat; - std::string hotBinding; + CTimedKeyChain curKeyChain; std::string userInputPrefix; /// > diff -Nru spring-96.0~14.04~ppa4/rts/Game/GameHelper.cpp spring-98.0~14.04~ppa6/rts/Game/GameHelper.cpp --- spring-96.0~14.04~ppa4/rts/Game/GameHelper.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/GameHelper.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -6,7 +6,6 @@ #include "GameSetup.h" #include "Game/GlobalUnsynced.h" #include "Lua/LuaUI.h" -#include "Lua/LuaRules.h" #include "Map/Ground.h" #include "Map/MapDamage.h" #include "Map/ReadMap.h" @@ -38,11 +37,10 @@ #include "Sim/Weapons/Weapon.h" #include "System/EventHandler.h" #include "System/myMath.h" -#include "System/Sound/SoundChannels.h" +#include "System/Sound/ISoundChannels.h" #include "System/Sync/SyncTracer.h" #define NUM_WAITING_DAMAGE_LISTS 128 -#define PLAY_SOUNDS 1 ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -157,6 +155,7 @@ void CGameHelper::DoExplosionDamage( CFeature* feature, + CUnit* owner, const float3& expPos, const float expRadius, const float expEdgeEffect, @@ -183,14 +182,13 @@ const float3 impulseDir = (volPos - expPos).SafeNormalize(); const float3 expImpulse = impulseDir * modImpulseScale; - feature->DoDamage(damages * expDistanceMod, expImpulse, NULL, weaponDefID, projectileID); + feature->DoDamage(damages * expDistanceMod, expImpulse, owner, weaponDefID, projectileID); } void CGameHelper::DamageObjectsInExplosionRadius( const ExplosionParams& params, - const float3& expPos, const float expRad, const int weaponDefID ) { @@ -205,7 +203,7 @@ const unsigned int oldNumUnits = *(cache.GetNumUnitsPtr()); const unsigned int oldNumFeatures = *(cache.GetNumFeaturesPtr()); - quadField->GetUnitsAndFeaturesColVol(expPos, expRad, units, features, cache.GetNumUnitsPtr(), cache.GetNumFeaturesPtr()); + quadField->GetUnitsAndFeaturesColVol(params.pos, expRad, units, features, cache.GetNumUnitsPtr(), cache.GetNumFeaturesPtr()); const unsigned int newNumUnits = *(cache.GetNumUnitsPtr()); const unsigned int newNumFeatures = *(cache.GetNumFeaturesPtr()); @@ -217,20 +215,18 @@ // not keep track of end-markers --> certain objects // would not be damaged AT ALL (!) for (unsigned int n = oldNumUnits; n < newNumUnits; n++) { - DoExplosionDamage(units[n], params.owner, expPos, expRad, params.explosionSpeed, params.edgeEffectiveness, params.ignoreOwner, params.damages, weaponDefID, params.projectileID); + DoExplosionDamage(units[n], params.owner, params.pos, expRad, params.explosionSpeed, params.edgeEffectiveness, params.ignoreOwner, params.damages, weaponDefID, params.projectileID); } // damage all features within the explosion radius for (unsigned int n = oldNumFeatures; n < newNumFeatures; n++) { - DoExplosionDamage(features[n], expPos, expRad, params.edgeEffectiveness, params.damages, weaponDefID, params.projectileID); + DoExplosionDamage(features[n], params.owner, params.pos, expRad, params.edgeEffectiveness, params.damages, weaponDefID, params.projectileID); } cache.Reset(oldNumUnits, oldNumFeatures); } void CGameHelper::Explosion(const ExplosionParams& params) { - const float3 expDir = params.dir; - const float3 expPos = params.pos; const DamageArray& damages = params.damages; // if weaponDef is NULL, this is a piece-explosion @@ -244,15 +240,15 @@ const float craterAOE = std::max(1.0f, params.craterAreaOfEffect); const float damageAOE = std::max(1.0f, params.damageAreaOfEffect); - const float realHeight = ground->GetHeightReal(expPos.x, expPos.z); - const float altitude = expPos.y - realHeight; + const float realHeight = CGround::GetHeightReal(params.pos); + const float altitude = (params.pos).y - realHeight; // NOTE: event triggers before damage is applied to objects - const bool noGfx = eventHandler.Explosion(weaponDefID, params.projectileID, expPos, params.owner); + const bool noGfx = eventHandler.Explosion(weaponDefID, params.projectileID, params.pos, params.owner); if (luaUI != NULL) { if (weaponDef != NULL && weaponDef->cameraShake > 0.0f) { - luaUI->ShockFront(expPos, weaponDef->cameraShake, damageAOE); + luaUI->ShockFront(params.pos, weaponDef->cameraShake, damageAOE); } } @@ -261,7 +257,7 @@ DoExplosionDamage( params.hitUnit, params.owner, - expPos, + params.pos, damageAOE, params.explosionSpeed, params.edgeEffectiveness, @@ -275,7 +271,8 @@ if (params.hitFeature != NULL) { DoExplosionDamage( params.hitFeature, - expPos, + params.owner, + params.pos, damageAOE, params.edgeEffectiveness, params.damages, @@ -284,7 +281,7 @@ ); } } else { - DamageObjectsInExplosionRadius(params, expPos, damageAOE, weaponDefID); + DamageObjectsInExplosionRadius(params, damageAOE, weaponDefID); // deform the map if the explosion was above-ground // (but had large enough radius to touch the ground) @@ -296,7 +293,7 @@ const float craterStrength = (damageDepth + damages.craterBoost) * damages.craterMult; const float craterRadius = craterAOE - altitude; - mapDamage->Explosion(expPos, craterStrength, craterRadius); + mapDamage->Explosion(params.pos, craterStrength, craterRadius); } } } @@ -304,8 +301,8 @@ if (!noGfx) { explGenHandler->GenExplosion( explosionID, - expPos, - expDir, + params.pos, + params.dir, damages.GetDefaultDamage(), damageAOE, params.gfxMod, @@ -314,24 +311,22 @@ ); } - CExplosionEvent explosionEvent(expPos, damages.GetDefaultDamage(), damageAOE, weaponDef); + CExplosionEvent explosionEvent(params.pos, damages.GetDefaultDamage(), damageAOE, weaponDef); CExplosionCreator::FireExplosionEvent(explosionEvent); - #if (PLAY_SOUNDS == 1) if (weaponDef != NULL) { const GuiSoundSet& soundSet = weaponDef->hitSound; - const unsigned int soundFlags = CCustomExplosionGenerator::GetFlagsFromHeight(expPos.y, altitude); + const unsigned int soundFlags = CCustomExplosionGenerator::GetFlagsFromHeight(params.pos.y, altitude); const unsigned int soundMask = CCustomExplosionGenerator::SPW_WATER | CCustomExplosionGenerator::SPW_UNDERWATER; const int soundNum = ((soundFlags & soundMask) != 0); const int soundID = soundSet.getID(soundNum); if (soundID > 0) { - Channels::Battle.PlaySample(soundID, expPos, soundSet.getVolume(soundNum)); + Channels::Battle->PlaySample(soundID, params.pos, soundSet.getVolume(soundNum)); } } - #endif } @@ -359,8 +354,6 @@ template static inline void QueryUnits(TFilter filter, TQuery& query) { - GML_RECMUTEX_LOCK(qnum); // QueryUnits - const vector &quads = quadField->GetQuads(query.pos, query.radius); const int tempNum = gs->tempNum++; @@ -484,7 +477,7 @@ } }; - }; // end of namespace Filter + } // end of namespace Filter namespace Query { @@ -632,8 +625,8 @@ } }; - }; // end of namespace Query -}; // end of namespace + } // end of namespace Query +} // end of namespace // Use this instead of unit->tempNum here, because it requires a mutex lock that will deadlock if luaRules is invoked simultaneously. // Not the cleanest solution, but faster than e.g. a std::set, and this function is called quite frequently. @@ -680,7 +673,7 @@ if (!modInfo.targetableTransportedUnits) continue; // the transportee might be "hidden" below terrain, in which case we can't target it - if (targetUnit->pos.y < ground->GetHeightReal(targetUnit->pos.x, targetUnit->pos.z)) + if (targetUnit->pos.y < CGround::GetHeightReal(targetUnit->pos.x, targetUnit->pos.z)) continue; } if (tempTargetUnits[targetUnit->id] == tempNum) { @@ -749,10 +742,8 @@ } } - if (luaRules != NULL) { - if (!luaRules->AllowWeaponTarget(attacker->id, targetUnit->id, weapon->weaponNum, weaponDef->id, &targetPriority)) { - continue; - } + if (!eventHandler.AllowWeaponTarget(attacker->id, targetUnit->id, weapon->weaponNum, weaponDef->id, &targetPriority)) { + continue; } targets.insert(std::pair(targetPriority, targetUnit)); @@ -1004,7 +995,7 @@ // (so we do not care about maxHeightDif constraints either) // TODO: maybe respect waterline if is in water if (!unitdef->IsImmobileUnit()) - return (std::max(pos.y, ground->GetHeightReal(pos.x, pos.z, synced))); + return (std::max(pos.y, CGround::GetHeightReal(pos.x, pos.z, synced))); const float* orgHeightMap = readMap->GetOriginalHeightMapSynced(); const float* curHeightMap = readMap->GetCornerHeightMapSynced(); @@ -1186,13 +1177,13 @@ int allyteam, bool synced ) { - if (!pos.IsInMap()) + if (!pos.IsInBounds()) return BUILDSQUARE_BLOCKED; const int yardxpos = int(pos.x + (SQUARE_SIZE >> 1)) / SQUARE_SIZE; const int yardypos = int(pos.z + (SQUARE_SIZE >> 1)) / SQUARE_SIZE; - const float groundHeight = ground->GetHeightReal(pos.x, pos.z, synced); + const float groundHeight = CGround::GetHeightReal(pos.x, pos.z, synced); BuildSquareStatus ret = BUILDSQUARE_OPEN; CSolidObject* so = groundBlockingObjectMap->GroundBlocked(yardxpos, yardypos); @@ -1254,28 +1245,33 @@ } } + // check maxHeightDif constraint (structures only) + // // if we are capable of floating, only test local // height difference IF terrain is above sea-level - if (!unitDef->floatOnWater || groundHeight > 0.0f) { - const float* orgHeightMap = readMap->GetOriginalHeightMapSynced(); - const float* curHeightMap = readMap->GetCornerHeightMapSynced(); - - #ifdef USE_UNSYNCED_HEIGHTMAP - if (!synced) { - orgHeightMap = readMap->GetCornerHeightMapUnsynced(); - curHeightMap = readMap->GetCornerHeightMapUnsynced(); - } - #endif + if (unitDef->IsImmobileUnit()) { + if (!unitDef->floatOnWater || groundHeight > 0.0f) { + const float* orgHeightMap = readMap->GetOriginalHeightMapSynced(); + const float* curHeightMap = readMap->GetCornerHeightMapSynced(); + + #ifdef USE_UNSYNCED_HEIGHTMAP + if (!synced) { + orgHeightMap = readMap->GetCornerHeightMapUnsynced(); + curHeightMap = readMap->GetCornerHeightMapUnsynced(); + } + #endif - const int sqx = pos.x / SQUARE_SIZE; - const int sqz = pos.z / SQUARE_SIZE; + const int sqx = pos.x / SQUARE_SIZE; + const int sqz = pos.z / SQUARE_SIZE; - const float orgHgt = orgHeightMap[sqz * gs->mapxp1 + sqx]; - const float curHgt = curHeightMap[sqz * gs->mapxp1 + sqx]; - const float difHgt = unitDef->maxHeightDif; + // FIXME: we do not want to use maxHeightDif for a MOBILE unit! + const float orgHgt = orgHeightMap[sqz * gs->mapxp1 + sqx]; + const float curHgt = curHeightMap[sqz * gs->mapxp1 + sqx]; + const float difHgt = unitDef->maxHeightDif; - if (pos.y > std::max(orgHgt + difHgt, curHgt + difHgt)) { return BUILDSQUARE_BLOCKED; } - if (pos.y < std::min(orgHgt - difHgt, curHgt - difHgt)) { return BUILDSQUARE_BLOCKED; } + if (pos.y > std::max(orgHgt + difHgt, curHgt + difHgt)) { return BUILDSQUARE_BLOCKED; } + if (pos.y < std::min(orgHgt - difHgt, curHgt - difHgt)) { return BUILDSQUARE_BLOCKED; } + } } if (!unitDef->CheckTerrainConstraints(moveDef, groundHeight)) @@ -1293,8 +1289,6 @@ Command CGameHelper::GetBuildCommand(const float3& pos, const float3& dir) { float3 tempF1 = pos; - GML_STDMUTEX_LOCK(cai); // GetBuildCommand - CCommandQueue::iterator ci; const std::list& units = unitHandler->activeUnits; diff -Nru spring-96.0~14.04~ppa4/rts/Game/GameHelper.h spring-98.0~14.04~ppa6/rts/Game/GameHelper.h --- spring-96.0~14.04~ppa4/rts/Game/GameHelper.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/GameHelper.h 2014-10-07 20:09:51.000000000 +0000 @@ -67,6 +67,8 @@ CGameHelper(); ~CGameHelper(); + CGameHelper(const CGameHelper&) = delete; // no-copy + static void GetEnemyUnits(const float3& pos, float searchRadius, int searchAllyteam, std::vector& found); static void GetEnemyUnitsNoLosTest(const float3& pos, float searchRadius, int searchAllyteam, std::vector& found); static CUnit* GetClosestUnit(const float3& pos, float searchRadius); @@ -137,6 +139,7 @@ ); void DoExplosionDamage( CFeature* feature, + CUnit* owner, const float3& expPos, const float expRadius, const float expEdgeEffect, @@ -145,7 +148,7 @@ const int projectileID ); - void DamageObjectsInExplosionRadius(const ExplosionParams& params, const float3& expPos, const float expRad, const int weaponDefID); + void DamageObjectsInExplosionRadius(const ExplosionParams& params, const float expRad, const int weaponDefID); void Explosion(const ExplosionParams& params); private: @@ -180,6 +183,7 @@ struct ObjectCache { public: + ObjectCache() : numUnits(0), numFeatures(0) {} bool Empty() const { return (units.empty() || features.empty()); } void Init(unsigned int maxUnits, unsigned int maxFeatures) { units.resize(maxUnits, NULL); diff -Nru spring-96.0~14.04~ppa4/rts/Game/GameSetup.cpp spring-98.0~14.04~ppa6/rts/Game/GameSetup.cpp --- spring-96.0~14.04~ppa4/rts/Game/GameSetup.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/GameSetup.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -17,11 +17,11 @@ #include #include -CR_BIND(CGameSetup,); +CR_BIND(CGameSetup,) CR_REG_METADATA(CGameSetup, ( CR_MEMBER(gameSetupText), CR_POSTLOAD(PostLoad) -)); +)) CGameSetup* gameSetup = NULL; @@ -202,6 +202,15 @@ } } +void CGameSetup::LoadMutators(const TdfParser& file, std::vector& mutatorsList) +{ + for (int a = 0; a < 10; ++a) { + std::string s = file.SGetValueDef("", IntToString(a, "GAME\\MUTATOR%i")); + if (s.empty()) break; + mutatorsList.push_back(s); + } +} + void CGameSetup::LoadPlayers(const TdfParser& file, std::set& nameList) { numDemoPlayers = 0; @@ -504,6 +513,7 @@ RemapTeams(); RemapAllyteams(); + LoadMutators(file, mutatorsList); LoadUnitRestrictions(file); // Postprocessing diff -Nru spring-96.0~14.04~ppa4/rts/Game/GameSetup.h spring-98.0~14.04~ppa6/rts/Game/GameSetup.h --- spring-96.0~14.04~ppa4/rts/Game/GameSetup.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/GameSetup.h 2014-10-07 20:09:51.000000000 +0000 @@ -18,7 +18,7 @@ class CGameSetup { - CR_DECLARE_STRUCT(CGameSetup); + CR_DECLARE_STRUCT(CGameSetup) public: CGameSetup(); @@ -58,6 +58,7 @@ const std::vector& GetTeamStartingDataCont() const { return teamStartingData; } const std::vector& GetAllyStartingDataCont() const { return allyStartingData; } const std::vector& GetAIStartingDataCont() const { return skirmishAIStartingData; } + const std::vector& GetMutatorsCont() const { return mutatorsList; } const std::string MapFile() const; @@ -113,6 +114,8 @@ * @pre mapName, numTeams, teamStartNum initialized and the map loaded (LoadMap()) */ void LoadStartPositionsFromMap(); + + void LoadMutators(const TdfParser& file, std::vector& mutatorsList); /** * @brief Load unit restrictions * @post restrictedUnits initialized @@ -157,6 +160,7 @@ std::vector teamStartingData; std::vector allyStartingData; std::vector skirmishAIStartingData; + std::vector mutatorsList; std::map team_skirmishAI; std::map restrictedUnits; diff -Nru spring-96.0~14.04~ppa4/rts/Game/GameVersion.cpp spring-98.0~14.04~ppa6/rts/Game/GameVersion.cpp --- spring-96.0~14.04~ppa4/rts/Game/GameVersion.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/GameVersion.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -77,24 +77,6 @@ #define GV_ADD_SPACE " " #endif -#if defined USE_GML_SIM - GV_ADD_SPACE "ASIM" - #undef GV_ADD_SPACE - #define GV_ADD_SPACE " " -#endif - -#if defined USE_GML - GV_ADD_SPACE "GML" - #undef GV_ADD_SPACE - #define GV_ADD_SPACE " " -#endif - -#if defined USE_GML_DEBUG - GV_ADD_SPACE "GDB" - #undef GV_ADD_SPACE - #define GV_ADD_SPACE " " -#endif - #if defined TRACE_SYNC GV_ADD_SPACE "Sync-Trace" #undef GV_ADD_SPACE diff -Nru spring-96.0~14.04~ppa4/rts/Game/GameVersion.h spring-98.0~14.04~ppa6/rts/Game/GameVersion.h --- spring-96.0~14.04~ppa4/rts/Game/GameVersion.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/GameVersion.h 2014-10-07 20:09:51.000000000 +0000 @@ -115,6 +115,6 @@ * @see GetAdditional */ extern const std::string& GetFull(); -}; +} #endif // GAME_VERSION_H diff -Nru spring-96.0~14.04~ppa4/rts/Game/GlobalUnsynced.cpp spring-98.0~14.04~ppa6/rts/Game/GlobalUnsynced.cpp --- spring-96.0~14.04~ppa4/rts/Game/GlobalUnsynced.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/GlobalUnsynced.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -32,7 +32,7 @@ const float CGlobalUnsynced::reconnectSimDrawBalance = 0.15f; UnsyncedRNG CGlobalUnsynced::rng; -CR_BIND(CGlobalUnsynced, ); +CR_BIND(CGlobalUnsynced, ) CR_REG_METADATA(CGlobalUnsynced, ( CR_IGNORED(simFPS), @@ -52,7 +52,7 @@ CR_MEMBER(spectatingFullSelect), CR_IGNORED(fpsMode), CR_IGNORED(globalQuit) -)); +)) CGlobalUnsynced::CGlobalUnsynced() { diff -Nru spring-96.0~14.04~ppa4/rts/Game/GlobalUnsynced.h spring-98.0~14.04~ppa6/rts/Game/GlobalUnsynced.h --- spring-96.0~14.04~ppa4/rts/Game/GlobalUnsynced.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/GlobalUnsynced.h 2014-10-07 20:09:51.000000000 +0000 @@ -16,7 +16,7 @@ * Contains globally accessible data that does not remain synced */ class CGlobalUnsynced { - CR_DECLARE_STRUCT(CGlobalUnsynced); + CR_DECLARE_STRUCT(CGlobalUnsynced) CGlobalUnsynced(); ~CGlobalUnsynced(); diff -Nru spring-96.0~14.04~ppa4/rts/Game/GUI/PlayerRosterDrawer.cpp spring-98.0~14.04~ppa6/rts/Game/GUI/PlayerRosterDrawer.cpp --- spring-96.0~14.04~ppa4/rts/Game/GUI/PlayerRosterDrawer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/GUI/PlayerRosterDrawer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -8,7 +8,7 @@ #include "Game/UI/GuiHandler.h" #include "Game/Players/Player.h" #include "Game/Players/PlayerHandler.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Rendering/GlobalRendering.h" #include "Sim/Misc/GlobalConstants.h" #include "Sim/Misc/GlobalSynced.h" diff -Nru spring-96.0~14.04~ppa4/rts/Game/IActionExecutor.h spring-98.0~14.04~ppa6/rts/Game/IActionExecutor.h --- spring-96.0~14.04~ppa4/rts/Game/IActionExecutor.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/IActionExecutor.h 2014-10-07 20:09:51.000000000 +0000 @@ -29,6 +29,7 @@ const Action& action; }; + template class IActionExecutor { @@ -75,20 +76,6 @@ this->description = description; } - /** - * Sets a bool according to the value encoded in a string. - * The conversion works like this: - * - "" -> toggle-value - * - "0" -> false - * - "1" -> true - */ - static void SetBoolArg(bool& container, const std::string& newValue); - - /** - * Logs the enabled/disabled status of a sub-system of the engine. - */ - static void LogSystemStatus(const std::string& system, bool status); - private: /** * Executes one instance of an action of this type. @@ -106,9 +93,9 @@ * Because this is a template enabled class, * the implementations have to be in the same file. */ - template -bool IActionExecutor::ExecuteAction(const action_t& action) const { +bool IActionExecutor::ExecuteAction(const action_t& action) const +{ //assert(action.GetAction().command == GetCommand()); if (IsCheatRequired() && !gs->cheatEnabled) { @@ -121,24 +108,11 @@ } } -template -void IActionExecutor::SetBoolArg(bool& container, const std::string& newValue) { - - if (newValue.empty()) { - // toggle - container = !container; - } else { - // set - const int num = atoi(newValue.c_str()); - container = (num != 0); - } -} - -template -void IActionExecutor::LogSystemStatus(const std::string& system, bool status) { +/// Logs the enabled/disabled status of a sub-system of the engine. +static inline void LogSystemStatus(const std::string& system, const bool status) +{ LOG("%s is %s!", system.c_str(), (status ? "enabled" : "disabled")); } - #endif // I_ACTION_EXECUTOR_H diff -Nru spring-96.0~14.04~ppa4/rts/Game/InMapDraw.cpp spring-98.0~14.04~ppa6/rts/Game/InMapDraw.cpp --- spring-96.0~14.04~ppa4/rts/Game/InMapDraw.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/InMapDraw.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -24,7 +24,7 @@ #include "Net/Protocol/NetProtocol.h" #include "System/Log/ILog.h" #include "System/Sound/ISound.h" -#include "System/Sound/SoundChannels.h" +#include "System/Sound/ISoundChannels.h" CInMapDraw* inMapDrawer = NULL; @@ -56,7 +56,7 @@ // even if this message is not intented for our ears LOG("%s added point: %s", sender->name.c_str(), label->c_str()); eventHandler.LastMessagePosition(*pos0); - Channels::UserInterface.PlaySample(blippSound, *pos0); + Channels::UserInterface->PlaySample(blippSound, *pos0); minimap->AddNotification(*pos0, OnesVector, 1.0f); } @@ -146,7 +146,7 @@ float3 CInMapDraw::GetMouseMapPos() // TODO move to some more global place? { - const float dist = ground->LineGroundCol(camera->GetPos(), camera->GetPos() + (mouse->dir * globalRendering->viewRange * 1.4f), false); + const float dist = CGround::LineGroundCol(camera->GetPos(), camera->GetPos() + (mouse->dir * globalRendering->viewRange * 1.4f), false); if (dist < 0) { return float3(-1.0f, 1.0f, -1.0f); } @@ -223,13 +223,13 @@ void CInMapDraw::SetSpecMapDrawingAllowed(bool state) { allowSpecMapDrawing = state; - LOG("Spectator map drawing is %s", allowSpecMapDrawing? "disabled": "enabled"); + LOG("[%s] spectator map-drawing is %s", __FUNCTION__, allowSpecMapDrawing? "enabled": "disabled"); } void CInMapDraw::SetLuaMapDrawingAllowed(bool state) { allowLuaMapDrawing = state; - LOG("Lua map drawing is %s", allowLuaMapDrawing? "disabled": "enabled"); + LOG("[%s] Lua map-drawing is %s", __FUNCTION__, allowLuaMapDrawing? "enabled": "disabled"); } @@ -269,7 +269,7 @@ game->userWriting = true; wantLabel = true; game->userPrompt = "Label: "; - game->ignoreChar = '\xA7'; // should do something better here + game->ignoreNextChar = true; } diff -Nru spring-96.0~14.04~ppa4/rts/Game/InMapDrawModel.cpp spring-98.0~14.04~ppa6/rts/Game/InMapDrawModel.cpp --- spring-96.0~14.04~ppa4/rts/Game/InMapDrawModel.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/InMapDrawModel.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -11,12 +11,11 @@ #include "Sim/Misc/TeamHandler.h" #include "System/EventHandler.h" #include "System/creg/STL_List.h" -#include "lib/gml/gmlmut.h" CInMapDrawModel* inMapDrawerModel = NULL; -CR_BIND(CInMapDrawModel, ); +CR_BIND(CInMapDrawModel, ) CR_REG_METADATA(CInMapDrawModel, ( CR_MEMBER(drawQuadsX), CR_MEMBER(drawQuadsY), @@ -25,33 +24,33 @@ CR_MEMBER(numPoints), CR_MEMBER(numLines), CR_POSTLOAD(PostLoad) -)); +)) -CR_BIND(CInMapDrawModel::MapDrawPrimitive, (false, -1, NULL)); +CR_BIND(CInMapDrawModel::MapDrawPrimitive, (false, -1, NULL)) CR_REG_METADATA_SUB(CInMapDrawModel, MapDrawPrimitive, ( CR_MEMBER(spectator), CR_MEMBER(teamID)//, //CR_MEMBER(teamController) -)); +)) -CR_BIND_DERIVED(CInMapDrawModel::MapPoint, CInMapDrawModel::MapDrawPrimitive, (false, -1, NULL, ZeroVector, "")); +CR_BIND_DERIVED(CInMapDrawModel::MapPoint, CInMapDrawModel::MapDrawPrimitive, (false, -1, NULL, ZeroVector, "")) CR_REG_METADATA_SUB(CInMapDrawModel, MapPoint, ( CR_MEMBER(pos), CR_MEMBER(label) -)); +)) -CR_BIND_DERIVED(CInMapDrawModel::MapLine, CInMapDrawModel::MapDrawPrimitive, (false, -1, NULL, ZeroVector, ZeroVector)); +CR_BIND_DERIVED(CInMapDrawModel::MapLine, CInMapDrawModel::MapDrawPrimitive, (false, -1, NULL, ZeroVector, ZeroVector)) CR_REG_METADATA_SUB(CInMapDrawModel, MapLine, ( CR_MEMBER(pos1), CR_MEMBER(pos2) -)); +)) -CR_BIND(CInMapDrawModel::DrawQuad, ); +CR_BIND(CInMapDrawModel::DrawQuad, ) CR_REG_METADATA_SUB(CInMapDrawModel, DrawQuad, /*( CR_MEMBER(points), CR_MEMBER(lines) -)*/); +)*/) @@ -127,7 +126,7 @@ float3 pos = constPos; pos.ClampInBounds(); - pos.y = ground->GetHeightAboveWater(pos.x, pos.z, false) + 2.0f; + pos.y = CGround::GetHeightAboveWater(pos.x, pos.z, false) + 2.0f; // event clients may process the point // if their owner is allowed to see it @@ -135,7 +134,6 @@ return false; } - GML_STDMUTEX_LOCK(inmap); // LocalPoint // let the engine handle it (disallowed // points added here are filtered while @@ -164,14 +162,13 @@ float3 pos2 = constPos2; pos1.ClampInBounds(); pos2.ClampInBounds(); - pos1.y = ground->GetHeightAboveWater(pos1.x, pos1.z, false) + 2.0f; - pos2.y = ground->GetHeightAboveWater(pos2.x, pos2.z, false) + 2.0f; + pos1.y = CGround::GetHeightAboveWater(pos1.x, pos1.z, false) + 2.0f; + pos2.y = CGround::GetHeightAboveWater(pos2.x, pos2.z, false) + 2.0f; if (AllowedMsg(sender) && eventHandler.MapDrawCmd(playerID, MAPDRAW_LINE, &pos1, &pos2, NULL)) { return false; } - GML_STDMUTEX_LOCK(inmap); // LocalLine MapLine line(sender->spectator, sender->team, sender, pos1, pos2); @@ -194,13 +191,12 @@ float3 pos = constPos; pos.ClampInBounds(); - pos.y = ground->GetHeightAboveWater(pos.x, pos.z, false) + 2.0f; + pos.y = CGround::GetHeightAboveWater(pos.x, pos.z, false) + 2.0f; if (AllowedMsg(sender) && eventHandler.MapDrawCmd(playerID, MAPDRAW_ERASE, &pos, NULL, NULL)) { return; } - GML_STDMUTEX_LOCK(inmap); // LocalErase const float radius = 100.0f; const int maxY = drawQuadsY - 1; diff -Nru spring-96.0~14.04~ppa4/rts/Game/InMapDrawModel.h spring-98.0~14.04~ppa6/rts/Game/InMapDrawModel.h --- spring-96.0~14.04~ppa4/rts/Game/InMapDrawModel.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/InMapDrawModel.h 2014-10-07 20:09:51.000000000 +0000 @@ -20,11 +20,11 @@ */ class CInMapDrawModel { - CR_DECLARE_STRUCT(CInMapDrawModel); - CR_DECLARE_SUB(MapDrawPrimitive); - CR_DECLARE_SUB(MapPoint); - CR_DECLARE_SUB(MapLine); - CR_DECLARE_SUB(DrawQuad); + CR_DECLARE_STRUCT(CInMapDrawModel) + CR_DECLARE_SUB(MapDrawPrimitive) + CR_DECLARE_SUB(MapPoint) + CR_DECLARE_SUB(MapLine) + CR_DECLARE_SUB(DrawQuad) public: static const size_t DRAW_QUAD_SIZE; @@ -48,7 +48,7 @@ struct MapDrawPrimitive { - CR_DECLARE(MapDrawPrimitive); + CR_DECLARE(MapDrawPrimitive) public: MapDrawPrimitive(bool spectator, int teamID, const TeamController* teamController) @@ -83,7 +83,7 @@ }; struct MapPoint : public MapDrawPrimitive { - CR_DECLARE(MapPoint); + CR_DECLARE(MapPoint) public: MapPoint(bool spectator, int teamID, const TeamController* teamController, const float3& pos, const std::string& label) @@ -101,7 +101,7 @@ }; struct MapLine : public MapDrawPrimitive { - CR_DECLARE(MapLine); + CR_DECLARE(MapLine) public: MapLine(bool spectator, int teamID, const TeamController* teamController, const float3& pos1, const float3& pos2) @@ -129,7 +129,7 @@ * cell of a grid structure. */ struct DrawQuad { - CR_DECLARE_STRUCT(DrawQuad); + CR_DECLARE_STRUCT(DrawQuad) std::list points; std::list lines; }; diff -Nru spring-96.0~14.04~ppa4/rts/Game/LoadScreen.cpp spring-98.0~14.04~ppa6/rts/Game/LoadScreen.cpp --- spring-96.0~14.04~ppa4/rts/Game/LoadScreen.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/LoadScreen.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,6 +1,7 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ #include +#include #include "Rendering/GL/myGL.h" #include "LoadScreen.h" @@ -14,7 +15,7 @@ #include "ExternalAI/SkirmishAIHandler.h" #include "Lua/LuaIntro.h" #include "Map/MapInfo.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Rendering/GlobalRendering.h" #include "Rendering/Textures/Bitmap.h" #include "Rendering/Textures/NamedTextures.h" @@ -29,12 +30,10 @@ #include "System/FileSystem/FileHandler.h" #include "System/Platform/Watchdog.h" #include "System/Sound/ISound.h" -#include "System/Sound/SoundChannels.h" +#include "System/Sound/ISoundChannels.h" -#if !defined(HEADLESS) && !defined(NO_SOUND) - #include "System/Sound/EFX.h" - #include "System/Sound/EFXPresets.h" -#endif +#include "System/Sound/OpenAL/EFX.h" +#include "System/Sound/OpenAL/EFXPresets.h" #include @@ -83,6 +82,7 @@ #endif //! Create a thread during the loading that pings the host/server, so it knows that this client is still alive/loading + net->KeepUpdating(true); netHeartbeatThread = new boost::thread(boost::bind(&CNetProtocol::UpdateLoop, net)); game = new CGame(mapName, modName, saveFile); @@ -105,7 +105,7 @@ const std::string mapStartMusic(mapInfo->GetStringValue("Startmusic")); if (!mapStartMusic.empty()) - Channels::BGMusic.StreamPlay(mapStartMusic); + Channels::BGMusic->StreamPlay(mapStartMusic); } try { @@ -136,7 +136,7 @@ delete gameLoadThread; gameLoadThread = NULL; if (net) - net->SetLoading(false); + net->KeepUpdating(false); if (netHeartbeatThread) netHeartbeatThread->join(); delete netHeartbeatThread; netHeartbeatThread = NULL; @@ -211,7 +211,7 @@ } -int CLoadScreen::KeyPressed(unsigned short k, bool isRepeat) +int CLoadScreen::KeyPressed(int k, bool isRepeat) { //FIXME add mouse events if (LuaIntro) @@ -221,7 +221,7 @@ } -int CLoadScreen::KeyReleased(unsigned short k) +int CLoadScreen::KeyReleased(int k) { if (LuaIntro) LuaIntro->KeyRelease(k); @@ -244,6 +244,11 @@ return true; } + if (!mtLoading) { + // without this call the window manager would think the window is unresponsive and thus asks for hard kill + SDL_PollEvent(NULL); + } + CNamedTextures::Update(); return true; } @@ -270,13 +275,11 @@ if (LuaIntro) { LuaIntro->Update(); LuaIntro->DrawGenesis(); - } - - ClearScreen(); - - if (LuaIntro) { + ClearScreen(); LuaIntro->DrawLoadScreen(); } else { + ClearScreen(); + float xDiv = 0.0f; float yDiv = 0.0f; const float ratioComp = globalRendering->aspectRatio / aspectRatio; @@ -316,22 +319,18 @@ } } + // Always render Spring's license notice font->Begin(); font->SetOutlineColor(0.0f,0.0f,0.0f,0.65f); font->SetTextColor(1.0f,1.0f,1.0f,1.0f); - if (GML::Enabled()) { - font->glFormat(0.5f,0.06f, globalRendering->viewSizeY / 35.0f, FONT_OUTLINE | FONT_CENTER | FONT_NORM, - "Spring %s (%d threads)", SpringVersion::GetFull().c_str(), GML::ThreadCount()); - } else { - font->glFormat(0.5f,0.06f, globalRendering->viewSizeY / 35.0f, FONT_OUTLINE | FONT_CENTER | FONT_NORM, + font->glFormat(0.5f,0.06f, globalRendering->viewSizeY / 35.0f, FONT_OUTLINE | FONT_CENTER | FONT_NORM, "Spring %s", SpringVersion::GetFull().c_str()); - } font->glFormat(0.5f,0.02f, globalRendering->viewSizeY / 50.0f, FONT_OUTLINE | FONT_CENTER | FONT_NORM, "This program is distributed under the GNU General Public License, see license.html for more info"); font->End(); if (!mtLoading) - SDL_GL_SwapBuffers(); + SDL_GL_SwapWindow(globalRendering->window); return true; } @@ -366,8 +365,10 @@ //! Here it is done for the loading thread, for the mainthread it is done in CLoadScreen::Update() good_fpu_control_registers(curLoadMessage.c_str()); - if (!mtLoading) + if (!mtLoading) { + Update(); Draw(); + } } diff -Nru spring-96.0~14.04~ppa4/rts/Game/LoadScreen.h spring-98.0~14.04~ppa6/rts/Game/LoadScreen.h --- spring-96.0~14.04~ppa4/rts/Game/LoadScreen.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/LoadScreen.h 2014-10-07 20:09:51.000000000 +0000 @@ -40,9 +40,9 @@ void ResizeEvent(); /// Called when a key is released by the user - int KeyReleased(unsigned short k); + int KeyReleased(int k); /// Called when the key is pressed by the user (can be called several times due to key repeat) - int KeyPressed(unsigned short k,bool isRepeat); + int KeyPressed(int k,bool isRepeat); private: diff -Nru spring-96.0~14.04~ppa4/rts/Game/Players/PlayerBase.cpp spring-98.0~14.04~ppa6/rts/Game/Players/PlayerBase.cpp --- spring-96.0~14.04~ppa4/rts/Game/Players/PlayerBase.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/Players/PlayerBase.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -6,7 +6,7 @@ #include "System/creg/STL_Map.h" -CR_BIND_DERIVED(PlayerBase,TeamController, ); +CR_BIND_DERIVED(PlayerBase,TeamController, ) CR_REG_METADATA(PlayerBase, ( CR_MEMBER(rank), CR_MEMBER(countryCode), @@ -16,7 +16,7 @@ CR_MEMBER(desynced), CR_MEMBER(cpuUsage), CR_MEMBER(customValues) -)); +)) diff -Nru spring-96.0~14.04~ppa4/rts/Game/Players/PlayerBase.h spring-98.0~14.04~ppa6/rts/Game/Players/PlayerBase.h --- spring-96.0~14.04~ppa4/rts/Game/Players/PlayerBase.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/Players/PlayerBase.h 2014-10-07 20:09:51.000000000 +0000 @@ -14,7 +14,7 @@ */ class PlayerBase : public TeamController { - CR_DECLARE(PlayerBase); + CR_DECLARE(PlayerBase) public: typedef std::map customOpts; diff -Nru spring-96.0~14.04~ppa4/rts/Game/Players/Player.cpp spring-98.0~14.04~ppa6/rts/Game/Players/Player.cpp --- spring-96.0~14.04~ppa4/rts/Game/Players/Player.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/Players/Player.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -12,7 +12,6 @@ #include "Game/SelectedUnitsHandler.h" #include "Game/UI/MouseHandler.h" #include "Game/UI/UnitTracker.h" -#include "Lua/LuaRules.h" #include "Lua/LuaUI.h" #include "Map/ReadMap.h" #include "Sim/Misc/TeamHandler.h" @@ -25,7 +24,7 @@ #include "System/creg/STL_Set.h" -CR_BIND_DERIVED(CPlayer, PlayerBase, ); +CR_BIND_DERIVED(CPlayer, PlayerBase, ) CR_REG_METADATA(CPlayer, ( CR_MEMBER(active), CR_MEMBER(playerNum), @@ -33,7 +32,7 @@ CR_MEMBER(currentStats), //CR_MEMBER(fpsController), FIXME add their classes to creg CR_MEMBER(controlledTeams) -)); +)) ////////////////////////////////////////////////////////////////////// @@ -184,7 +183,7 @@ return; } - if (luaRules == NULL || luaRules->AllowDirectUnitControl(this->playerNum, newControlleeUnit)) { + if (eventHandler.AllowDirectUnitControl(this->playerNum, newControlleeUnit)) { newControlleeUnit->fpsControlPlayer = this; fpsController.SetControlleeUnit(newControlleeUnit); selectedUnitsHandler.ClearNetSelect(this->playerNum); diff -Nru spring-96.0~14.04~ppa4/rts/Game/Players/Player.h spring-98.0~14.04~ppa6/rts/Game/Players/Player.h --- spring-96.0~14.04~ppa4/rts/Game/Players/Player.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/Players/Player.h 2014-10-07 20:09:51.000000000 +0000 @@ -21,7 +21,7 @@ class CPlayer : public PlayerBase { public: - CR_DECLARE(CPlayer); + CR_DECLARE(CPlayer) enum { PLAYER_RDYSTATE_UPDATED = 0, diff -Nru spring-96.0~14.04~ppa4/rts/Game/Players/PlayerHandler.cpp spring-98.0~14.04~ppa6/rts/Game/Players/PlayerHandler.cpp --- spring-96.0~14.04~ppa4/rts/Game/Players/PlayerHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/Players/PlayerHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -5,17 +5,16 @@ #include "PlayerHandler.h" #include "Player.h" -#include "lib/gml/gmlmut.h" #include "Sim/Misc/GlobalConstants.h" #include "Game/GameSetup.h" #include "Game/SelectedUnitsHandler.h" -CR_BIND(CPlayerHandler,); +CR_BIND(CPlayerHandler,) CR_REG_METADATA(CPlayerHandler, ( CR_MEMBER(players), CR_RESERVED(64) -)); +)) CPlayerHandler* playerHandler; @@ -91,14 +90,10 @@ void CPlayerHandler::AddPlayer(const CPlayer& player) { - GML_MSTMUTEX_DOUNLOCK(sim); // AddPlayer - temporarily unlock this mutex to prevent a deadlock - const int oldSize = players.size(); const int newSize = std::max((int)players.size(), player.playerNum + 1); { - GML_STDMUTEX_LOCK(draw); // AddPlayer - rendering accesses Player(x) in too many places, lock the entire draw thread - for (unsigned int i = oldSize; i < newSize; ++i) { // fill gap with stubs CPlayer* stub = new CPlayer(); @@ -116,5 +111,4 @@ newPlayer->fpsController.SetControllerPlayer(newPlayer); } - GML_MSTMUTEX_DOLOCK(sim); // AddPlayer - restore unlocked mutex } diff -Nru spring-96.0~14.04~ppa4/rts/Game/Players/PlayerHandler.h spring-98.0~14.04~ppa6/rts/Game/Players/PlayerHandler.h --- spring-96.0~14.04~ppa4/rts/Game/Players/PlayerHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/Players/PlayerHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -15,7 +15,7 @@ class CPlayerHandler { public: - CR_DECLARE_STRUCT(CPlayerHandler); + CR_DECLARE_STRUCT(CPlayerHandler) ~CPlayerHandler(); @@ -43,14 +43,14 @@ /** * @brief Number of players the game was created for - * + * * Will change at runtime, for example if a new spectator joins */ int ActivePlayers() const { return players.size(); } /** * @brief Number of players in a team - * + * * Will change during runtime (Connection lost, died, ...). * This excludes spectators and AIs. */ @@ -58,7 +58,7 @@ /** * @brief is the supplied id a valid playerId? - * + * * Will change during at runtime when a new spectator joins */ bool IsValidPlayer(int id) const { diff -Nru spring-96.0~14.04~ppa4/rts/Game/Players/PlayerStatistics.cpp spring-98.0~14.04~ppa6/rts/Game/Players/PlayerStatistics.cpp --- spring-96.0~14.04~ppa4/rts/Game/Players/PlayerStatistics.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/Players/PlayerStatistics.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -4,14 +4,14 @@ #include "System/Platform/byteorder.h" -CR_BIND(PlayerStatistics, ); +CR_BIND(PlayerStatistics, ) CR_REG_METADATA(PlayerStatistics, ( CR_MEMBER(mousePixels), CR_MEMBER(mouseClicks), CR_MEMBER(keyPresses), CR_MEMBER(numCommands), CR_MEMBER(unitCommands) -)); +)) PlayerStatistics::PlayerStatistics() diff -Nru spring-96.0~14.04~ppa4/rts/Game/Players/PlayerStatistics.h spring-98.0~14.04~ppa6/rts/Game/Players/PlayerStatistics.h --- spring-96.0~14.04~ppa4/rts/Game/Players/PlayerStatistics.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/Players/PlayerStatistics.h 2014-10-07 20:09:51.000000000 +0000 @@ -12,7 +12,7 @@ struct PlayerStatistics : public TeamControllerStatistics { public: - CR_DECLARE_STRUCT(PlayerStatistics); + CR_DECLARE_STRUCT(PlayerStatistics) PlayerStatistics(); diff -Nru spring-96.0~14.04~ppa4/rts/Game/Players/TeamController.cpp spring-98.0~14.04~ppa6/rts/Game/Players/TeamController.cpp --- spring-96.0~14.04~ppa4/rts/Game/Players/TeamController.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/Players/TeamController.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,8 +2,8 @@ #include "TeamController.h" // for swabDWord -CR_BIND(TeamController, ); +CR_BIND(TeamController, ) CR_REG_METADATA(TeamController, ( CR_MEMBER(team), CR_MEMBER(name) -)); +)) diff -Nru spring-96.0~14.04~ppa4/rts/Game/Players/TeamController.h spring-98.0~14.04~ppa6/rts/Game/Players/TeamController.h --- spring-96.0~14.04~ppa4/rts/Game/Players/TeamController.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/Players/TeamController.h 2014-10-07 20:09:51.000000000 +0000 @@ -19,7 +19,7 @@ class TeamController { public: - CR_DECLARE(TeamController); + CR_DECLARE(TeamController) /** * @brief Constructor assigning default values. diff -Nru spring-96.0~14.04~ppa4/rts/Game/PreGame.cpp spring-98.0~14.04~ppa6/rts/Game/PreGame.cpp --- spring-96.0~14.04~ppa4/rts/Game/PreGame.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/PreGame.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,7 +1,7 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ #include -#include +#include #include #include @@ -24,8 +24,7 @@ #include "aGui/Gui.h" #include "ExternalAI/SkirmishAIHandler.h" -#include "Menu/SelectMenu.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Sim/Misc/GlobalSynced.h" #include "Sim/Misc/GlobalConstants.h" #include "Sim/Misc/TeamHandler.h" @@ -46,6 +45,10 @@ #include "System/Net/UnpackPacket.h" #include "System/Platform/errorhandler.h" #include "lib/luasocket/src/restrictions.h" +#ifdef SYNCDEBUG + #include "System/Sync/SyncDebugger.h" +#endif + using netcode::RawPacket; using std::string; @@ -53,22 +56,27 @@ CONFIG(bool, DemoFromDemo).defaultValue(false); CPreGame* pregame = NULL; -extern SelectMenu* selectMenu; -CPreGame::CPreGame(const ClientSetup* setup) : - settings(setup), - savefile(NULL), - timer(spring_gettime()), - wantDemo(true) +CPreGame::CPreGame(boost::shared_ptr setup) + : settings(setup) + , savefile(NULL) + , timer(spring_gettime()) + , wantDemo(true) { net = new CNetProtocol(); activeController = this; +#ifdef SYNCDEBUG + CSyncDebugger::GetInstance()->Initialize(settings->isHost, 64); //FIXME: add actual number of player +#endif + if (!settings->isHost) { //don't allow luasocket to connect to the host + LOG("Connecting to: %s:%i", settings->hostIP.c_str(), settings->hostPort); luaSocketRestrictions->addRule(CLuaSocketRestrictions::UDP_CONNECT, settings->hostIP, settings->hostPort, false); net->InitClient(settings->hostIP.c_str(), settings->hostPort, settings->myPlayerName, settings->myPasswd, SpringVersion::GetFull()); } else { + LOG("Hosting on: %s:%i", settings->hostIP.c_str(), settings->hostPort); net->InitLocalClient(); } } @@ -78,7 +86,6 @@ { // don't delete infoconsole, its beeing reused by CGame agui::gui->Draw(); // delete leftover gui elements (remove once the gui is drawn ingame) - selectMenu = NULL; pregame = NULL; } @@ -108,10 +115,10 @@ StartServer(savefile->scriptText); } -int CPreGame::KeyPressed(unsigned short k,bool isRepeat) +int CPreGame::KeyPressed(int k, bool isRepeat) { if (k == SDLK_ESCAPE) { - if (keyInput->IsKeyPressed(SDLK_LSHIFT)) { + if (KeyInput::GetKeyModState(KMOD_SHIFT)) { LOG("User exited"); gu->globalQuit = true; } else { @@ -457,28 +464,37 @@ } } - gs->SetRandSeed(gameData->GetRandomSeed(), true); - LOG("Using map: %s", gameSetup->mapName.c_str()); + // Load archives into VFS + { + // Load Map archive + LOG("Using map: %s", gameSetup->mapName.c_str()); + vfsHandler->AddArchiveWithDeps(gameSetup->mapName, false); + + // Load Mutators (if any) + for (const std::string& mut: gameSetup->GetMutatorsCont()) { + LOG("Using mutator: %s", mut.c_str()); + vfsHandler->AddArchiveWithDeps(mut, false); + } + + // Load Game archive + LOG("Using game: %s", gameSetup->modName.c_str()); + vfsHandler->AddArchiveWithDeps(gameSetup->modName, false); + modArchive = archiveScanner->ArchiveFromName(gameSetup->modName); + LOG("Using game archive: %s", modArchive.c_str()); + } - vfsHandler->AddArchiveWithDeps(gameSetup->mapName, false); + // Check checksums of map & game try { archiveScanner->CheckArchive(gameSetup->mapName, gameData->GetMapChecksum()); } catch (const content_error& ex) { LOG_L(L_WARNING, "Incompatible map-checksum: %s", ex.what()); } - - LOG("Using game: %s", gameSetup->modName.c_str()); - vfsHandler->AddArchiveWithDeps(gameSetup->modName, false); - modArchive = archiveScanner->ArchiveFromName(gameSetup->modName); - LOG("Using game archive: %s", modArchive.c_str()); - try { archiveScanner->CheckArchive(modArchive, gameData->GetModChecksum()); } catch (const content_error& ex) { LOG_L(L_WARNING, "Incompatible game-checksum: %s", ex.what()); } - if (net != NULL && wantDemo) { assert(net->GetDemoRecorder() == NULL); @@ -487,7 +503,7 @@ recorder->SaveToDemo(packet->data, packet->length, net->GetPacketTime(gs->frameNum)); net->SetDemoRecorder(recorder); - LOG("recording demo: %s", (recorder->GetName()).c_str()); + LOG("Recording demo to: %s", (recorder->GetName()).c_str()); } } diff -Nru spring-96.0~14.04~ppa4/rts/Game/PreGame.h spring-98.0~14.04~ppa6/rts/Game/PreGame.h --- spring-96.0~14.04~ppa4/rts/Game/PreGame.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/PreGame.h 2014-10-07 20:09:51.000000000 +0000 @@ -5,12 +5,10 @@ #include #include -#include #include "GameController.h" #include "System/Misc/SpringTime.h" -class CInfoConsole; class ILoadSaveHandler; class GameData; class ClientSetup; @@ -36,7 +34,7 @@ class CPreGame : public CGameController { public: - CPreGame(const ClientSetup* setup); + CPreGame(boost::shared_ptr setup); virtual ~CPreGame(); void LoadSetupscript(const std::string& script); @@ -44,7 +42,7 @@ void LoadSavefile(const std::string& save); bool Draw(); - int KeyPressed(unsigned short k, bool isRepeat); + int KeyPressed(int k, bool isRepeat); bool Update(); private: @@ -63,10 +61,10 @@ We won't start until we received this */ - boost::scoped_ptr gameData; - const ClientSetup* settings; + boost::shared_ptr gameData; + boost::shared_ptr settings; std::string modArchive; - ILoadSaveHandler *savefile; + ILoadSaveHandler* savefile; spring_time timer; bool wantDemo; diff -Nru spring-96.0~14.04~ppa4/rts/Game/SelectedUnitsAI.cpp spring-98.0~14.04~ppa6/rts/Game/SelectedUnitsAI.cpp --- spring-96.0~14.04~ppa4/rts/Game/SelectedUnitsAI.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/SelectedUnitsAI.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -96,7 +96,6 @@ return true; } - void CSelectedUnitsHandlerAI::GiveCommandNet(Command &c, int player) { const std::vector& netSelected = selectedUnitsHandler.netSelected[player]; @@ -444,7 +443,7 @@ float3 pos; pos.x = rightPos.x + (movePos.x * (dir.x / dir.y)) - (movePos.z * (dir.z/dir.y)); pos.z = rightPos.z + (movePos.x * (dir.z / dir.y)) + (movePos.z * (dir.x/dir.y)); - pos.y = ground->GetHeightAboveWater(pos.x, pos.z); + pos.y = CGround::GetHeightAboveWater(pos.x, pos.z); Command c(command->GetID(), command->options, pos); @@ -480,8 +479,6 @@ const unsigned int targetsCount = targets.size(); const unsigned int selectedCount = selected.size(); - unsigned int realCount = 0; - if (selectedCount == 0) return; @@ -513,7 +510,7 @@ // get the group center float3 midPos; - + unsigned int realCount = 0; for (unsigned int s = 0; s < selectedCount; s++) { CUnit* unit = unitHandler->units[selected[s]]; @@ -529,7 +526,7 @@ realCount++; } - if (realCount <= 0) + if (realCount == 0) return; midPos /= realCount; diff -Nru spring-96.0~14.04~ppa4/rts/Game/SelectedUnitsHandler.cpp spring-98.0~14.04~ppa6/rts/Game/SelectedUnitsHandler.cpp --- spring-96.0~14.04~ppa4/rts/Game/SelectedUnitsHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/SelectedUnitsHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -29,22 +29,22 @@ #include "Sim/Units/Groups/Group.h" #include "Sim/Units/UnitTypes/TransportUnit.h" #include "System/Config/ConfigHandler.h" +#include "System/Color.h" #include "System/EventHandler.h" #include "System/Log/ILog.h" #include "System/Util.h" #include "Net/Protocol/NetProtocol.h" #include "System/Net/PackPacket.h" +#include "System/FileSystem/SimpleParser.h" #include "System/Input/KeyInput.h" #include "System/Sound/ISound.h" -#include "System/Sound/SoundChannels.h" +#include "System/Sound/ISoundChannels.h" #include -#include +#include #include -#define PLAY_SOUNDS 1 - CONFIG(bool, BuildIconsFirst).defaultValue(false); CONFIG(bool, AutoAddBuiltUnitsToFactoryGroup).defaultValue(false).description("Controls whether or not units built by factories will inherit that factory's unit group."); CONFIG(bool, AutoAddBuiltUnitsToSelectedGroup).defaultValue(false); @@ -96,95 +96,75 @@ CSelectedUnitsHandler::AvailableCommandsStruct CSelectedUnitsHandler::GetAvailableCommands() { - GML_RECMUTEX_LOCK(grpsel); // GetAvailableCommands - possibleCommandsChanged = false; int commandPage = 1000; int foundGroup = -2; int foundGroup2 = -2; - map states; + std::map states; - for (CUnitSet::const_iterator ui = selectedUnits.begin(); ui != selectedUnits.end(); ++ui) { - const std::vector* c = &((*ui)->commandAI->GetPossibleCommands()); - std::vector::const_iterator ci; - for (ci = c->begin(); ci != c->end(); ++ci) { - states[ci->id] = ci->disabled ? 2 : 1; + for (const CUnit* u: selectedUnits) { + const std::vector& c = u->commandAI->GetPossibleCommands(); + for (const CommandDescription& cmdDesc: c) { + states[cmdDesc.id] = cmdDesc.disabled ? 2 : 1; } - if ((*ui)->commandAI->lastSelectedCommandPage < commandPage) { - commandPage = (*ui)->commandAI->lastSelectedCommandPage; + if (u->commandAI->lastSelectedCommandPage < commandPage) { + commandPage = u->commandAI->lastSelectedCommandPage; } - if (foundGroup == -2 && (*ui)->group) { - foundGroup = (*ui)->group->id; + if (foundGroup == -2 && u->group) { + foundGroup = u->group->id; } - if (!(*ui)->group || foundGroup!=(*ui)->group->id) { + if (!u->group || foundGroup != u->group->id) { foundGroup = -1; } - if (foundGroup2 == -2 && (*ui)->group) { - foundGroup2 = (*ui)->group->id; + if (foundGroup2 == -2 && u->group) { + foundGroup2 = u->group->id; } - if (foundGroup2 >= 0 && (*ui)->group && (*ui)->group->id != foundGroup2) { + if (foundGroup2 >= 0 && u->group && u->group->id != foundGroup2) { foundGroup2 = -1; } } - std::vector groupCommands; - - std::vector commands ; + std::vector commands; // load the first set (separating build and non-build commands) - for (CUnitSet::const_iterator ui = selectedUnits.begin(); ui != selectedUnits.end(); ++ui) { - const std::vector* c = &((*ui)->commandAI->GetPossibleCommands()); - std::vector::const_iterator ci; - for (ci = c->begin(); ci != c->end(); ++ci) { + for (const CUnit* u: selectedUnits) { + const std::vector& c = u->commandAI->GetPossibleCommands(); + for (const CommandDescription& cmdDesc: c) { if (buildIconsFirst) { - if (ci->id >= 0) { continue; } + if (cmdDesc.id >= 0) { continue; } } else { - if (ci->id < 0) { continue; } + if (cmdDesc.id < 0) { continue; } } - if (ci->showUnique && selectedUnits.size() > 1) { + if (cmdDesc.showUnique && selectedUnits.size() > 1) { continue; } - if (states[ci->id] > 0) { - commands.push_back(*ci); - states[ci->id] = 0; + if (states[cmdDesc.id] > 0) { + commands.push_back(cmdDesc); + states[cmdDesc.id] = 0; } } } - if (!buildIconsFirst && !gs->noHelperAIs) { - std::vector::const_iterator ci; - for(ci = groupCommands.begin(); ci != groupCommands.end(); ++ci) { - commands.push_back(*ci); - } - } - // load the second set (all those that have not already been included) - for (CUnitSet::const_iterator ui = selectedUnits.begin(); ui != selectedUnits.end(); ++ui) { - std::vector* c = &(*ui)->commandAI->GetPossibleCommands(); - std::vector::const_iterator ci; - for (ci = c->begin(); ci != c->end(); ++ci) { + for (const CUnit* u: selectedUnits) { + const std::vector& c = u->commandAI->GetPossibleCommands(); + for (const CommandDescription& cmdDesc: c) { if (buildIconsFirst) { - if (ci->id < 0) { continue; } + if (cmdDesc.id < 0) { continue; } } else { - if (ci->id >= 0) { continue; } + if (cmdDesc.id >= 0) { continue; } } - if (ci->showUnique && selectedUnits.size() > 1) { + if (cmdDesc.showUnique && selectedUnits.size() > 1) { continue; } - if (states[ci->id] > 0) { - commands.push_back(*ci); - states[ci->id] = 0; + if (states[cmdDesc.id] > 0) { + commands.push_back(cmdDesc); + states[cmdDesc.id] = 0; } } } - if (buildIconsFirst && !gs->noHelperAIs) { - std::vector::const_iterator ci; - for (ci = groupCommands.begin(); ci != groupCommands.end(); ++ci) { - commands.push_back(*ci); - } - } AvailableCommandsStruct ac; ac.commandPage = commandPage; @@ -195,8 +175,6 @@ void CSelectedUnitsHandler::GiveCommand(Command c, bool fromUser) { - GML_RECMUTEX_LOCK(grpsel); // GiveCommand - if (gu->spectating && !gs->godMode) return; if (selectedUnits.empty()) @@ -264,19 +242,15 @@ SendCommand(c); - #if (PLAY_SOUNDS == 1) if (!selectedUnits.empty()) { CUnitSet::const_iterator ui = selectedUnits.begin(); - Channels::UnitReply.PlayRandomSample((*ui)->unitDef->sounds.ok, *ui); + Channels::UnitReply->PlayRandomSample((*ui)->unitDef->sounds.ok, *ui); } - #endif } void CSelectedUnitsHandler::HandleUnitBoxSelection(const float4& planeRight, const float4& planeLeft, const float4& planeTop, const float4& planeBottom) { - GML_RECMUTEX_LOCK(sel); // SelectUnits - CUnit* unit = NULL; int addedunits = 0; int team, lastTeam; @@ -297,7 +271,7 @@ const float4 vec((*ui)->midPos, 1.0f); if (vec.dot4(planeRight) < 0.0f && vec.dot4(planeLeft) < 0.0f && vec.dot4(planeTop) < 0.0f && vec.dot4(planeBottom) < 0.0f) { - if (keyInput->IsKeyPressed(SDLK_LCTRL) && (selectedUnits.find(*ui) != selectedUnits.end())) { + if (KeyInput::GetKeyModState(KMOD_CTRL) && (selectedUnits.find(*ui) != selectedUnits.end())) { RemoveUnit(*ui); } else { AddUnit(*ui); @@ -308,21 +282,17 @@ } } - #if (PLAY_SOUNDS == 1) if (addedunits >= 2) { - Channels::UserInterface.PlaySample(soundMultiselID); + Channels::UserInterface->PlaySample(soundMultiselID); } else if (addedunits == 1) { - Channels::UnitReply.PlayRandomSample(unit->unitDef->sounds.select, unit); + Channels::UnitReply->PlayRandomSample(unit->unitDef->sounds.select, unit); } - #endif } void CSelectedUnitsHandler::HandleSingleUnitClickSelection(CUnit* unit, bool doInViewTest) { - GML_RECMUTEX_LOCK(sel); // SelectUnits - //FIXME make modular? const CMouseHandler::ButtonPressEvt& bp = mouse->buttons[SDL_BUTTON_LEFT]; @@ -332,7 +302,7 @@ return; if (bp.lastRelease < (gu->gameTime - mouse->doubleClickTime)) { - if (keyInput->IsKeyPressed(SDLK_LCTRL) && (selectedUnits.find(unit) != selectedUnits.end())) { + if (KeyInput::GetKeyModState(KMOD_CTRL) && (selectedUnits.find(unit) != selectedUnits.end())) { RemoveUnit(unit); } else { AddUnit(unit); @@ -353,7 +323,7 @@ CUnitSet& teamUnits = teamHandler->Team(team)->units; for (ui = teamUnits.begin(); ui != teamUnits.end(); ++ui) { if ((*ui)->unitDef->id == unit->unitDef->id) { - if (!doInViewTest || keyInput->IsKeyPressed(SDLK_LCTRL) || camera->InView((*ui)->midPos)) { + if (!doInViewTest || KeyInput::GetKeyModState(KMOD_CTRL) || camera->InView((*ui)->midPos)) { AddUnit(*ui); } } @@ -361,9 +331,7 @@ } } - #if (PLAY_SOUNDS == 1) - Channels::UnitReply.PlayRandomSample(unit->unitDef->sounds.select, unit); - #endif + Channels::UnitReply->PlayRandomSample(unit->unitDef->sounds.select, unit); } @@ -381,8 +349,6 @@ return; } - GML_RECMUTEX_LOCK(sel); // AddUnit - if (selectedUnits.insert(unit).second) AddDeathDependence(unit, DEPENDENCE_SELECTED); selectionChanged = true; @@ -398,8 +364,6 @@ void CSelectedUnitsHandler::RemoveUnit(CUnit* unit) { - GML_RECMUTEX_LOCK(sel); // RemoveUnit - if (selectedUnits.erase(unit)) DeleteDeathDependence(unit, DEPENDENCE_SELECTED); selectionChanged = true; @@ -411,12 +375,9 @@ void CSelectedUnitsHandler::ClearSelected() { - GML_RECMUTEX_LOCK(sel); // ClearSelected - - CUnitSet::iterator ui; - for (ui = selectedUnits.begin(); ui != selectedUnits.end(); ++ui) { - (*ui)->isSelected = false; - DeleteDeathDependence(*ui, DEPENDENCE_SELECTED); + for (CUnit* u: selectedUnits) { + u->isSelected = false; + DeleteDeathDependence(u, DEPENDENCE_SELECTED); } selectedUnits.clear(); @@ -428,18 +389,15 @@ void CSelectedUnitsHandler::SelectGroup(int num) { - GML_RECMUTEX_LOCK(grpsel); // SelectGroup - not needed? only reading group - ClearSelected(); selectedGroup=num; CGroup* group=grouphandlers[gu->myTeam]->groups[num]; - CUnitSet::iterator ui; - for (ui = group->units.begin(); ui != group->units.end(); ++ui) { - if (!(*ui)->noSelect) { - (*ui)->isSelected = true; - selectedUnits.insert(*ui); - AddDeathDependence(*ui, DEPENDENCE_SELECTED); + for (CUnit* u: group->units) { + if (!u->noSelect) { + u->isSelected = true; + selectedUnits.insert(u); + AddDeathDependence(u, DEPENDENCE_SELECTED); } } @@ -448,6 +406,105 @@ } +void CSelectedUnitsHandler::SelectUnits(const std::string& line) +{ + const std::vector& args = CSimpleParser::Tokenize(line, 0); + for (int i = 0; i < (int)args.size(); i++) { + const std::string& arg = args[i]; + if (arg == "clear") { + selectedUnitsHandler.ClearSelected(); + } + else if ((arg[0] == '+') || (arg[0] == '-')) { + char* endPtr; + const char* startPtr = arg.c_str() + 1; + const int unitIndex = strtol(startPtr, &endPtr, 10); + if (endPtr == startPtr) { + continue; // bad number + } + if ((unitIndex < 0) || (static_cast(unitIndex) >= unitHandler->MaxUnits())) { + continue; // bad index + } + CUnit* unit = unitHandler->units[unitIndex]; + if (unit == NULL) { + continue; // bad pointer + } + if (!gu->spectatingFullSelect) { + const CUnitSet& teamUnits = teamHandler->Team(gu->myTeam)->units; + if (teamUnits.find(unit) == teamUnits.end()) { + continue; // not mine to select + } + } + + // perform the selection + if (arg[0] == '+') { + AddUnit(unit); + } else { + RemoveUnit(unit); + } + } + } +} + + +void CSelectedUnitsHandler::SelectCycle(const std::string& command) +{ + static std::set unitIDs; + static int lastID = -1; + + if (command == "restore") { + ClearSelected(); + for (const int& unitID: unitIDs) { + CUnit* unit = unitHandler->units[unitID]; + if (unit != NULL) { + AddUnit(unit); + } + } + return; + } + + if (selectedUnits.size() >= 2) { + // assign the cycle units + unitIDs.clear(); + for (const CUnit* u: selectedUnits) { + unitIDs.insert(u->id); + } + ClearSelected(); + lastID = *unitIDs.begin(); + AddUnit(unitHandler->units[lastID]); + return; + } + + // clean the list + std::set tmpSet; + for (const int& unitID: unitIDs) { + if (unitHandler->units[unitID] != NULL) { + tmpSet.insert(unitID); + } + } + unitIDs = tmpSet; + if ((lastID >= 0) && (unitHandler->units[lastID] == NULL)) { + lastID = -1; + } + + // selectedUnits size is 0 or 1 + ClearSelected(); + if (!unitIDs.empty()) { + std::set::const_iterator fit = unitIDs.find(lastID); + if (fit == unitIDs.end()) { + lastID = *unitIDs.begin(); + } else { + ++fit; + if (fit != unitIDs.end()) { + lastID = *fit; + } else { + lastID = *unitIDs.begin(); + } + } + AddUnit(unitHandler->units[lastID]); + } +} + + void CSelectedUnitsHandler::Draw() { glDisable(GL_TEXTURE_2D); @@ -458,7 +515,11 @@ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glLineWidth(cmdColors.UnitBoxLineWidth()); - GML_RECMUTEX_LOCK(grpsel); // Draw + SColor color1(cmdColors.unitBox); + SColor color2(cmdColors.unitBox); + color2.r = 255 - color2.r; + color2.g = 255 - color2.g; + color2.b = 255 - color2.b; if (cmdColors.unitBox[3] > 0.05f) { const CUnitSet* unitSet; @@ -500,26 +561,12 @@ float3(unit->drawPos.x + mhxsize, unit->drawPos.y, unit->drawPos.z - mhzsize), }; - const unsigned char color1[4] = { - (unsigned char)( cmdColors.unitBox[0] * 255 ), - (unsigned char)( cmdColors.unitBox[1] * 255 ), - (unsigned char)( cmdColors.unitBox[2] * 255 ), - (unsigned char)( cmdColors.unitBox[3] * 255 ) - }; - va->AddVertexQC(verts[0], color1); va->AddVertexQC(verts[1], color1); va->AddVertexQC(verts[2], color1); va->AddVertexQC(verts[3], color1); if (globalRendering->drawdebug && (mhxsize != uhxsize || mhzsize != uhzsize)) { - const unsigned char color2[4] = { - (unsigned char)( (1.0f - cmdColors.unitBox[0]) * 255 ), - (unsigned char)( (1.0f - cmdColors.unitBox[1]) * 255 ), - (unsigned char)( (1.0f - cmdColors.unitBox[2]) * 255 ), - (unsigned char)( cmdColors.unitBox[3] * 255 ) - }; - va->AddVertexQC(verts[4], color2); va->AddVertexQC(verts[5], color2); va->AddVertexQC(verts[6], color2); @@ -534,13 +581,11 @@ // (or old-style, whenever the shift key is being held down) if (cmdColors.buildBox[3] > 0.0f) { if (!selectedUnits.empty() && - ((cmdColors.BuildBoxesOnShift() && keyInput->IsKeyPressed(SDLK_LSHIFT)) || + ((cmdColors.BuildBoxesOnShift() && KeyInput::GetKeyModState(KMOD_SHIFT)) || ((guihandler->inCommand >= 0) && (guihandler->inCommand < int(guihandler->commands.size())) && (guihandler->commands[guihandler->inCommand].id < 0)))) { - GML_STDMUTEX_LOCK(cai); // Draw - bool myColor = true; glColor4fv(cmdColors.buildBox); @@ -580,8 +625,6 @@ void CSelectedUnitsHandler::DependentDied(CObject *o) { - GML_RECMUTEX_LOCK(sel); // DependentDied - maybe superfluous, too late anyway - selectedUnits.erase(static_cast(o)); selectionChanged = true; possibleCommandsChanged = true; @@ -710,8 +753,6 @@ return luaCmd; } - GML_RECMUTEX_LOCK(sel); // GetDefaultCmd - // return the default if there are no units selected CUnitSet::const_iterator ui = selectedUnits.begin(); if (ui == selectedUnits.end()) { @@ -747,8 +788,6 @@ void CSelectedUnitsHandler::PossibleCommandChange(CUnit* sender) { - GML_RECMUTEX_LOCK(sel); // PossibleCommandChange - if (sender == NULL || selectedUnits.find(sender) != selectedUnits.end()) possibleCommandsChanged = true; } @@ -773,20 +812,14 @@ glLineWidth(cmdColors.QueuedLineWidth()); - GML_RECMUTEX_LOCK(unit); // DrawCommands - GML_RECMUTEX_LOCK(feat); // DrawCommands - GML_RECMUTEX_LOCK(grpsel); // DrawCommands - GML_STDMUTEX_LOCK(cai); // DrawCommands - - CUnitSet::iterator ui; if (selectedGroup != -1) { CUnitSet& groupUnits = grouphandlers[gu->myTeam]->groups[selectedGroup]->units; - for(ui = groupUnits.begin(); ui != groupUnits.end(); ++ui) { - commandDrawer->Draw((*ui)->commandAI); + for(CUnit* u: groupUnits) { + commandDrawer->Draw(u->commandAI); } } else { - for(ui = selectedUnits.begin(); ui != selectedUnits.end(); ++ui) { - commandDrawer->Draw((*ui)->commandAI); + for(CUnit* u: selectedUnits) { + commandDrawer->Draw(u->commandAI); } } @@ -808,8 +841,6 @@ { std::string s = ""; { - GML_RECMUTEX_LOCK(sel); // GetTooltip - called from TooltipConsole::Draw --> MouseHandler::GetCurrentTooltip --> GetTooltip - if (!selectedUnits.empty()) { const CUnit* unit = (*selectedUnits.begin()); const CTeam* team = NULL; @@ -821,7 +852,6 @@ } else { s = unit->tooltip; } - } if (selectedUnits.empty()) { @@ -835,8 +865,6 @@ } { - GML_RECMUTEX_LOCK(sel); // GetTooltip - int numFuel = 0; float maxHealth = 0.0f, curHealth = 0.0f; float maxFuel = 0.0f, curFuel = 0.0f; @@ -847,9 +875,7 @@ #define MULTI_TEAM -64 int ctrlTeam = NO_TEAM; - CUnitSet::const_iterator ui; - for (ui = selectedUnits.begin(); ui != selectedUnits.end(); ++ui) { - const CUnit* unit = *ui; + for (const CUnit* unit: selectedUnits) { maxHealth += unit->maxHealth; curHealth += unit->health; exp += unit->experience; @@ -906,11 +932,8 @@ void CSelectedUnitsHandler::SetCommandPage(int page) { - GML_RECMUTEX_LOCK(sel); // SetCommandPage - called from CGame::Draw --> RunLayoutCommand --> LayoutIcons --> RevertToCmdDesc - - CUnitSet::iterator ui; - for (ui = selectedUnits.begin(); ui != selectedUnits.end(); ++ui) { - (*ui)->commandAI->lastSelectedCommandPage = page; + for (const CUnit* u: selectedUnits) { + u->commandAI->lastSelectedCommandPage = page; } } @@ -920,7 +943,6 @@ { if (selectionChanged) { // send new selection - GML_RECMUTEX_LOCK(sel); // SendSelection // first, convert CUnit* to unit IDs. std::vector selectedUnitIDs(selectedUnits.size()); diff -Nru spring-96.0~14.04~ppa4/rts/Game/SelectedUnitsHandler.h spring-98.0~14.04~ppa6/rts/Game/SelectedUnitsHandler.h --- spring-96.0~14.04~ppa4/rts/Game/SelectedUnitsHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/SelectedUnitsHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -59,6 +59,9 @@ bool IsGroupSelected(int groupID) const { return (selectedGroup == groupID); } int GetSelectedGroup() const { return selectedGroup; } + void SelectUnits(const std::string& line); + void SelectCycle(const std::string& command); + public: CUnitSet selectedUnits; diff -Nru spring-96.0~14.04~ppa4/rts/Game/SyncedGameCommands.cpp spring-98.0~14.04~ppa6/rts/Game/SyncedGameCommands.cpp --- spring-96.0~14.04~ppa4/rts/Game/SyncedGameCommands.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/SyncedGameCommands.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -42,7 +42,7 @@ " commands to be usable") {} bool Execute(const SyncedAction& action) const { - SetBoolArg(gs->cheatEnabled, action.GetArgs()); + InverseOrSetBool(gs->cheatEnabled, action.GetArgs()); LogSystemStatus("Cheating", gs->cheatEnabled); return true; } @@ -55,7 +55,7 @@ "Enables/Disables widgets (LuaUI control)") {} bool Execute(const SyncedAction& action) const { - SetBoolArg(gs->noHelperAIs, action.GetArgs()); + InverseOrSetBool(gs->noHelperAIs, action.GetArgs()); selectedUnitsHandler.PossibleCommandChange(NULL); LogSystemStatus("LuaUI control", gs->noHelperAIs); return true; @@ -70,7 +70,7 @@ bool Execute(const SyncedAction& action) const { bool disabled; - SetBoolArg(disabled, action.GetArgs()); + InverseOrSetBool(disabled, action.GetArgs()); inMapDrawer->SetSpecMapDrawingAllowed(!disabled); return true; } @@ -85,7 +85,7 @@ "replays, which will DESYNC them)", true) {} bool Execute(const SyncedAction& action) const { - SetBoolArg(gs->godMode, action.GetArgs()); + InverseOrSetBool(gs->godMode, action.GetArgs()); CLuaUI::UpdateTeams(); LogSystemStatus("God-Mode", gs->godMode); CPlayer::UpdateControlledTeams(); @@ -193,7 +193,7 @@ "Enables/Disables spectators to use the chat") {} bool Execute(const SyncedAction& action) const { - SetBoolArg(game->noSpectatorChat, action.GetArgs()); + InverseOrSetBool(game->noSpectatorChat, action.GetArgs()); LogSystemStatus("Spectators chat", !game->noSpectatorChat); return true; } @@ -232,7 +232,7 @@ bool Execute(const SyncedAction& action) const { bool devMode = CLuaHandle::GetDevMode(); - SetBoolArg(devMode, action.GetArgs()); + InverseOrSetBool(devMode, action.GetArgs()); CLuaHandle::SetDevMode(devMode); LogSystemStatus("Lua dev-mode (can cause desyncs if enabled)", devMode); return true; @@ -247,7 +247,7 @@ " through Lua", true) {} bool Execute(const SyncedAction& action) const { - SetBoolArg(gs->editDefsEnabled, action.GetArgs()); + InverseOrSetBool(gs->editDefsEnabled, action.GetArgs()); LogSystemStatus("Unit-, Feature- & Weapon-Def editing", gs->editDefsEnabled); return true; @@ -283,14 +283,8 @@ if (luaRules != NULL && arg == "enable") { LOG_L(L_WARNING, "LuaRules is already loaded"); } else { - GML_MSTMUTEX_DOUNLOCK(sim); // temporarily unlock this mutex to prevent a deadlock - { - GML_STDMUTEX_LOCK(draw); // the draw thread accesses luaRules in too many places, so we lock the entire draw thread - - CLuaRules::FreeHandler(); - CLuaRules::LoadHandler(); - } - GML_MSTMUTEX_DOLOCK(sim); // restore unlocked mutex + CLuaRules::FreeHandler(); + CLuaRules::LoadHandler(); if (luaRules) { LOG("LuaRules loaded"); @@ -303,18 +297,14 @@ if (!gs->cheatEnabled) { LOG_L(L_WARNING, "Cheating required to disable synced scripts"); } else { - GML_MSTMUTEX_DOUNLOCK(sim); // temporarily unlock this mutex to prevent a deadlock - { - GML_STDMUTEX_LOCK(draw); // the draw thread accesses luaRules in too many places, so we lock the entire draw thread - - CLuaRules::FreeHandler(); - } - GML_MSTMUTEX_DOLOCK(sim); // restore unlocked mutex + CLuaRules::FreeHandler(); LOG("LuaRules disabled"); } } else if (luaRules) { luaRules->GotChatMsg(arg, action.GetPlayerID()); + } else { + LOG("LuaRules is not loaded"); } return true; @@ -368,7 +358,7 @@ } else if (luaGaia) { luaGaia->GotChatMsg(arg, action.GetPlayerID()); } else { - LOG("LuaGaia disabled"); + LOG("LuaGaia is not loaded"); } return true; diff -Nru spring-96.0~14.04~ppa4/rts/Game/TraceRay.cpp spring-98.0~14.04~ppa6/rts/Game/TraceRay.cpp --- spring-96.0~14.04~ppa4/rts/Game/TraceRay.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/TraceRay.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -90,7 +90,9 @@ // firing-cone is centered along dir2D with radius // (usually baseSize != 0 // so weapons with spread = 0 will test against a - // cylinder, not an infinitely thin line) + // cylinder, not an infinitely thin line as safety + // measure against friendly-fire damage in tightly + // packed unit groups) // // return true iff the world-space point // lies on or inside the object's collision volume @@ -129,8 +131,7 @@ if (globalRendering->drawdebugtraceray && Threading::IsSimThread()) { // FIXME? seems to under-estimate gravity near edge of range - // (Cannon and MissileLauncher both subtract 30 elmos from it - // in HaveFreeLineOfFire???) + // (place objects along trajectory of a cannon to visualize) #define go geometricObjects if (ret) { @@ -169,6 +170,7 @@ const bool ignoreFeatures = ((avoidFlags & Collision::NOFEATURES ) != 0); const bool ignoreNeutrals = ((avoidFlags & Collision::NONEUTRALS ) != 0); const bool ignoreGround = ((avoidFlags & Collision::NOGROUND ) != 0); + const bool ignoreCloaked = ((avoidFlags & Collision::NOCLOAKED ) != 0); const bool ignoreUnits = ignoreEnemies && ignoreAllies && ignoreNeutrals; @@ -179,8 +181,6 @@ return -1.0f; if (!ignoreFeatures || !ignoreUnits) { - GML_RECMUTEX_LOCK(quad); // TraceRay - CollisionQuery cq; int* begQuad = NULL; @@ -235,9 +235,11 @@ continue; if (ignoreAllies && u->allyteam == owner->allyteam) continue; + if (ignoreEnemies && u->allyteam != owner->allyteam) + continue; if (ignoreNeutrals && u->IsNeutral()) continue; - if (ignoreEnemies && u->allyteam != owner->allyteam) + if (ignoreCloaked && u->IsCloaked()) continue; if (CCollisionHandler::DetectHit(u, start, start + dir * length, &cq, true)) { @@ -252,14 +254,16 @@ } } } - if (hitUnit) + + if (hitUnit != NULL) { hitFeature = NULL; + } } } if (!ignoreGround) { // ground intersection - const float groundLength = ground->LineGroundCol(start, start + dir * length); + const float groundLength = CGround::LineGroundCol(start, start + dir * length); if (length > groundLength && groundLength > 0.0f) { length = groundLength; @@ -291,7 +295,7 @@ // ground and water-plane intersection const float guiRayLength = length; - const float groundRayLength = ground->LineGroundCol(start, start + dir * guiRayLength, false); + const float groundRayLength = CGround::LineGroundCol(start, start + dir * guiRayLength, false); const float waterRayLength = math::floorf(math::fabs(start.y / std::min(dir.y, -0.00001f))); float minRayLength = groundRayLength; @@ -307,8 +311,6 @@ if (groundOnly) return minRayLength; - GML_RECMUTEX_LOCK(quad); // GuiTraceRay - int* begQuad = NULL; int* endQuad = NULL; @@ -423,8 +425,6 @@ int avoidFlags, CUnit* owner) { - GML_RECMUTEX_LOCK(quad); // TestCone - int* begQuad = NULL; int* endQuad = NULL; @@ -506,8 +506,6 @@ int avoidFlags, CUnit* owner) { - GML_RECMUTEX_LOCK(quad); // TestTrajectoryCone - int* begQuad = NULL; int* endQuad = NULL; @@ -518,8 +516,6 @@ const bool ignoreNeutrals = ((avoidFlags & Collision::NONEUTRALS ) != 0); const bool ignoreFeatures = ((avoidFlags & Collision::NOFEATURES ) != 0); - const float safetyRadii[2] = {2.0f, 0.5f}; - for (int* quadPtr = begQuad; quadPtr != endQuad; ++quadPtr) { const CQuadField::Quad& quad = quadField->GetQuad(*quadPtr); @@ -536,7 +532,7 @@ if (!u->HasCollidableStateBit(CSolidObject::CSTATE_BIT_QUADMAPRAYS)) continue; - if (TestTrajectoryConeHelper(from, dir, length, linear, quadratic, spread, safetyRadii[u->immobile], u)) { + if (TestTrajectoryConeHelper(from, dir, length, linear, quadratic, spread, 0.0f, u)) { return true; } } @@ -557,7 +553,7 @@ if (!u->HasCollidableStateBit(CSolidObject::CSTATE_BIT_QUADMAPRAYS)) continue; - if (TestTrajectoryConeHelper(from, dir, length, linear, quadratic, spread, safetyRadii[u->immobile], u)) + if (TestTrajectoryConeHelper(from, dir, length, linear, quadratic, spread, 0.0f, u)) return true; } } diff -Nru spring-96.0~14.04~ppa4/rts/Game/TraceRay.h spring-98.0~14.04~ppa6/rts/Game/TraceRay.h --- spring-96.0~14.04~ppa4/rts/Game/TraceRay.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/TraceRay.h 2014-10-07 20:09:51.000000000 +0000 @@ -16,12 +16,14 @@ NOFEATURES = 4, NONEUTRALS = 8, NOGROUND = 16, - BOOLEAN = 32, // skip further testings after the first collision + NOCLOAKED = 32, + BOOLEAN = 64, // skip further tests after the first collision (unused) NOUNITS = NOENEMIES | NOFRIENDLIES | NONEUTRALS }; } namespace TraceRay { + // TODO: extend with allyTeam param s.t. we can add Collision::NO{LOS,RADAR}, etc. float TraceRay( const float3& start, const float3& dir, diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/CursorIcons.cpp spring-98.0~14.04~ppa6/rts/Game/UI/CursorIcons.cpp --- spring-96.0~14.04~ppa4/rts/Game/UI/CursorIcons.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/CursorIcons.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -10,7 +10,7 @@ #include "Sim/Units/CommandAI/Command.h" #include "Game/Camera.h" #include "Game/GameHelper.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Rendering/UnitDrawer.h" #include "Rendering/GL/myGL.h" #include "Sim/Units/UnitDef.h" @@ -78,7 +78,7 @@ if (icons.empty() || !cmdColors.UseQueueIcons()) { return; } - + glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); @@ -86,12 +86,12 @@ glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); - + glColor4f(1.0f, 1.0f, 1.0f, cmdColors.QueueIconAlpha()); - + int currentCmd = (icons.begin()->cmd + 1); // force the first binding const CMouseCursor* currentCursor = NULL; - + std::set::iterator it; for (it = icons.begin(); it != icons.end(); ++it) { const int command = it->cmd; @@ -109,7 +109,7 @@ } } } - + DrawTexts(); // use the same transformation glMatrixMode(GL_PROJECTION); @@ -154,7 +154,7 @@ glEnable(GL_DEPTH_TEST); glColor4f(1.0f, 1.0f, 1.0f, 0.3f); - + for (auto it = buildIcons.begin() ; it != buildIcons.end(); ++it) { CUnitDrawer::DrawBuildingSample(unitDefHandler->GetUnitDefByID(-(it->cmd)), it->team, it->pos, it->facing); } @@ -179,7 +179,6 @@ case CMD_FIGHT: cursorName = "Fight"; break; case CMD_ATTACK: cursorName = "Attack"; break; case CMD_AREA_ATTACK: cursorName = "Area attack"; break; - case CMD_LOOPBACKATTACK: cursorName = "Attack"; break; case CMD_GUARD: cursorName = "Guard"; break; case CMD_REPAIR: cursorName = "Repair"; break; case CMD_LOAD_ONTO: cursorName = "Load units"; break; diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/EndGameBox.cpp spring-98.0~14.04~ppa6/rts/Game/UI/EndGameBox.cpp --- spring-96.0~14.04~ppa4/rts/Game/UI/EndGameBox.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/EndGameBox.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -8,7 +8,7 @@ #include "Game/SelectedUnitsHandler.h" #include "Game/Players/Player.h" #include "Game/Players/PlayerHandler.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Rendering/GL/VertexArray.h" #include "Sim/Misc/GlobalSynced.h" #include "Sim/Misc/TeamHandler.h" @@ -38,7 +38,7 @@ } return c; -}; +} bool CEndGameBox::enabled = true; diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/GameInfo.cpp spring-98.0~14.04~ppa6/rts/Game/UI/GameInfo.cpp --- spring-96.0~14.04~ppa4/rts/Game/UI/GameInfo.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/GameInfo.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -4,7 +4,7 @@ #include "GameInfo.h" #include "MouseHandler.h" #include "Rendering/GL/myGL.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Game/GameSetup.h" #include "Game/GameVersion.h" #include "Sim/Misc/Team.h" @@ -16,7 +16,7 @@ #include "System/FileSystem/FileSystem.h" #include "System/Util.h" -#include +#include #include using std::string; @@ -123,7 +123,7 @@ labels.push_back("Game Name:"); values.push_back(gameSetup->modName); - labels.push_back("PathFinder:"); + labels.push_back("PFS Name:"); switch (pathManager->GetPathFinderType()) { case PFS_TYPE_DEFAULT: { values.push_back("Default"); } break; case PFS_TYPE_QTPFS: { values.push_back("QTPFS" ); } break; @@ -188,7 +188,7 @@ } -bool CGameInfo::KeyPressed(unsigned short key, bool isRepeat) +bool CGameInfo::KeyPressed(int key, bool isRepeat) { if (key == SDLK_ESCAPE) { delete this; diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/GameInfo.h spring-98.0~14.04~ppa6/rts/Game/UI/GameInfo.h --- spring-96.0~14.04~ppa4/rts/Game/UI/GameInfo.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/GameInfo.h 2014-10-07 20:09:51.000000000 +0000 @@ -37,7 +37,7 @@ bool MousePress(int x, int y, int button); void MouseRelease(int x, int y, int button); - bool KeyPressed(unsigned short key, bool isRepeat); + bool KeyPressed(int key, bool isRepeat); bool IsAbove(int x, int y); std::string GetTooltip(int x,int y); void Draw(); diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/GameSetupDrawer.cpp spring-98.0~14.04~ppa6/rts/Game/UI/GameSetupDrawer.cpp --- spring-96.0~14.04~ppa4/rts/Game/UI/GameSetupDrawer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/GameSetupDrawer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -12,13 +12,11 @@ #include "Net/GameServer.h" #include "Sim/Misc/GlobalSynced.h" #include "Sim/Misc/TeamHandler.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Net/Protocol/NetProtocol.h" #include "System/Config/ConfigHandler.h" #include "System/EventHandler.h" -#include - #include #include #include @@ -87,8 +85,8 @@ startState = "Choose start pos"; } else if (gameServer) { // we are the host and can get the show on the road by force - const CKeyBindings::HotkeyList fsKeys = keyBindings->GetHotkeys("forcestart"); - const std::string& fsKey = fsKeys.empty() ? "" : fsKeys.front(); + const CKeyBindings::HotkeyList& fsKeys = keyBindings->GetHotkeys("forcestart"); + const std::string fsKey = fsKeys.empty() ? "" : *fsKeys.begin(); startState = std::string("Waiting for players, press ") + fsKey + " to force start"; } else { startState = "Waiting for players"; diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/GuiHandler.cpp spring-98.0~14.04~ppa6/rts/Game/UI/GuiHandler.cpp --- spring-96.0~14.04~ppa4/rts/Game/UI/GuiHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/GuiHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -24,7 +24,7 @@ #include "Map/MapInfo.h" #include "Map/MetalMap.h" #include "Map/ReadMap.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Rendering/IconHandler.h" #include "Rendering/UnitDrawer.h" #include "Rendering/GL/glExtra.h" @@ -48,7 +48,7 @@ #include "System/Util.h" #include "System/Input/KeyInput.h" #include "System/Sound/ISound.h" -#include "System/Sound/SoundChannels.h" +#include "System/Sound/ISoundChannels.h" #include "System/FileSystem/FileHandler.h" #include "System/FileSystem/SimpleParser.h" @@ -56,7 +56,7 @@ #include #include -#include +#include #include CONFIG(bool, MiniMapMarker).defaultValue(true); @@ -85,8 +85,7 @@ curIconCommand(-1), actionOffset(0), drawSelectionInfo(true), - gatherMode(false), - hasLuaUILayoutCommands(false) + gatherMode(false) { icons = new IconInfo[16]; iconsSize = 16; @@ -117,18 +116,16 @@ delete[] icons; - std::map::iterator it; - for (it = textureMap.begin(); it != textureMap.end(); ++it) { - const GLuint texID = it->second; - glDeleteTextures (1, &texID); + for (auto& p: textureMap) { + glDeleteTextures(1, &p.second); } } bool CGuiHandler::GetQueueKeystate() const { - return (!invertQueueKey && keyInput->IsKeyPressed(SDLK_LSHIFT)) || - (invertQueueKey && !keyInput->IsKeyPressed(SDLK_LSHIFT)); + return (!invertQueueKey && KeyInput::GetKeyModState(KMOD_SHIFT)) || + (invertQueueKey && !KeyInput::GetKeyModState(KMOD_SHIFT)); } @@ -515,8 +512,6 @@ bool defCmd, validInCommand, samePage; CommandDescription cmdDesc; { - GML_RECMUTEX_LOCK(gui); // LayoutIcons - updates inCommand. Called from CGame::Draw --> RunLayoutCommand - defCmd = (mouse->buttons[SDL_BUTTON_RIGHT].pressed && (defaultCmdMemory >= 0) && (inCommand < 0) && @@ -539,7 +534,7 @@ forceLayoutUpdate = false; } - if (luaUI && luaUI->HasLayoutButtons()) { + if (luaUI && luaUI->WantsEvent("LayoutButtons")) { if (LayoutCustomIcons(useSelectionPage)) { if (validInCommand) { RevertToCmdDesc(cmdDesc, defCmd, samePage); @@ -547,12 +542,10 @@ return; // we're done here } else { - PushLayoutCommand("disable"); + CLuaUI::FreeHandler(); } } - GML_RECMUTEX_LOCK(gui); // LayoutIcons - // get the commands to process CSelectedUnitsHandler::AvailableCommandsStruct ac; ac = selectedUnitsHandler.GetAvailableCommands(); @@ -884,7 +877,6 @@ void CGuiHandler::GiveCommand(Command& cmd, bool fromUser) { - GML_STDMUTEX_LOCK(cmd); // GiveCommand commandsToGive.push_back(std::pair(cmd, fromUser)); } @@ -892,7 +884,6 @@ void CGuiHandler::GiveCommandsNow() { std::vector< std::pair > commandsToGiveTemp; { - GML_STDMUTEX_LOCK(cmd); // GiveCommandsNow commandsToGiveTemp.swap(commandsToGive); } @@ -954,14 +945,10 @@ void CGuiHandler::Update() { - RunLayoutCommands(); - SetCursorIcon(); { - GML_RECMUTEX_LOCK(gui); // Update - updates inCommand - - if (!invertQueueKey && (needShift && !keyInput->IsKeyPressed(SDLK_LSHIFT))) { + if (!invertQueueKey && (needShift && !KeyInput::GetKeyModState(KMOD_SHIFT))) { SetShowingMetal(false); inCommand=-1; needShift=false; @@ -1082,19 +1069,27 @@ if (dist <= 0.0f) return false; - for (CUnitSet::const_iterator it = selectedUnitsHandler.selectedUnits.begin(); it != selectedUnitsHandler.selectedUnits.end(); ++it) { - const CUnit* u = *it; - - // assume mobile units can get within weapon range of groundPos - // (mobile *kamikaze* units can attack by blowing themselves up) - if (!u->immobile) - return (u->unitDef->canKamikaze || !u->weapons.empty()); + for (const CUnit* u: selectedUnitsHandler.selectedUnits) { + // mobile kamikaze can always move into range + //FIXME do a range check in case of immobile kamikaze (-> mines) + if (u->unitDef->canKamikaze && !u->immobile) + return true; - for (unsigned int n = 0; n < u->weapons.size(); n++) { - u->weapons[n]->AdjustTargetPosToWater(modGroundPos = groundPos, targetUnit == NULL); + for (const CWeapon* w: u->weapons) { + w->AdjustTargetPosToWater(modGroundPos = groundPos, targetUnit == NULL); - if (u->weapons[n]->TryTarget(modGroundPos, false, targetUnit)) { - return true; + if (u->immobile) { + // immobile unit + // check range and weapon target properties + if (w->TryTarget(modGroundPos, false, targetUnit)) { + return true; + } + } else { + // mobile units can always move into range + // only check if we got a weapon that can shot the target (i.e. anti-air/anti-sub) + if (w->TestTarget(modGroundPos, false, targetUnit)) { + return true; + } } } } @@ -1106,8 +1101,6 @@ bool CGuiHandler::MousePress(int x, int y, int button) { { - GML_RECMUTEX_LOCK(gui); // MousePress - updates inCommand - if (button != SDL_BUTTON_LEFT && button != SDL_BUTTON_RIGHT && button != -SDL_BUTTON_RIGHT && button != -SDL_BUTTON_LEFT) return false; @@ -1156,10 +1149,6 @@ void CGuiHandler::MouseRelease(int x, int y, int button, const float3& cameraPos, const float3& mouseDir) { - GML_THRMUTEX_LOCK(unit, GML_DRAW); // MouseRelease - GML_THRMUTEX_LOCK(feat, GML_DRAW); // MouseRelease - GML_RECMUTEX_LOCK(gui); // MouseRelease - if (button != SDL_BUTTON_LEFT && button != SDL_BUTTON_RIGHT && button != -SDL_BUTTON_RIGHT && button != -SDL_BUTTON_LEFT) return; @@ -1175,7 +1164,7 @@ return; } - if (!invertQueueKey && needShift && !keyInput->IsKeyPressed(SDLK_LSHIFT)) { + if (!invertQueueKey && needShift && !KeyInput::GetKeyModState(KMOD_SHIFT)) { SetShowingMetal(false); inCommand = -1; needShift = false; @@ -1211,7 +1200,7 @@ Command c = GetCommand(x, y, button, false, cameraPos, mouseDir); if (c.GetID() == CMD_FAILED) { // indicates we should not finish the current command - Channels::UserInterface.PlaySample(failedSound, 5); + Channels::UserInterface->PlaySample(failedSound, 5); return; } @@ -1228,8 +1217,6 @@ bool CGuiHandler::SetActiveCommand(int cmdIndex, bool rightMouseButton) { - GML_RECMUTEX_LOCK(gui); // SetActiveCommand - updates inCommand - if (cmdIndex >= (int)commands.size()) { return false; } @@ -1337,26 +1324,26 @@ // setup the mouse and key states const bool prevLMB = mouse->buttons[SDL_BUTTON_LEFT].pressed; const bool prevRMB = mouse->buttons[SDL_BUTTON_RIGHT].pressed; - const boost::uint8_t prevAlt = keyInput->IsKeyPressed(SDLK_LALT); - const boost::uint8_t prevCtrl = keyInput->IsKeyPressed(SDLK_LCTRL); - const boost::uint8_t prevMeta = keyInput->IsKeyPressed(SDLK_LMETA); - const boost::uint8_t prevShift = keyInput->IsKeyPressed(SDLK_LSHIFT); + const boost::uint8_t prevAlt = KeyInput::GetKeyModState(KMOD_ALT); + const boost::uint8_t prevCtrl = KeyInput::GetKeyModState(KMOD_CTRL); + const boost::uint8_t prevMeta = KeyInput::GetKeyModState(KMOD_GUI); + const boost::uint8_t prevShift = KeyInput::GetKeyModState(KMOD_SHIFT); mouse->buttons[SDL_BUTTON_LEFT].pressed = leftMouseButton; mouse->buttons[SDL_BUTTON_RIGHT].pressed = rightMouseButton; - keyInput->SetKeyState(SDLK_LALT, alt); - keyInput->SetKeyState(SDLK_LCTRL, ctrl); - keyInput->SetKeyState(SDLK_LMETA, meta); - keyInput->SetKeyState(SDLK_LSHIFT, shift); + KeyInput::SetKeyModState(KMOD_ALT, alt); + KeyInput::SetKeyModState(KMOD_CTRL, ctrl); + KeyInput::SetKeyModState(KMOD_GUI, meta); + KeyInput::SetKeyModState(KMOD_SHIFT, shift); const bool retval = SetActiveCommand(cmdIndex, effectiveRMB); // revert the mouse and key states - keyInput->SetKeyState(SDLK_LSHIFT, prevShift); - keyInput->SetKeyState(SDLK_LMETA, prevMeta); - keyInput->SetKeyState(SDLK_LCTRL, prevCtrl); - keyInput->SetKeyState(SDLK_LALT, prevAlt); + KeyInput::SetKeyModState(KMOD_SHIFT, prevShift); + KeyInput::SetKeyModState(KMOD_GUI, prevMeta); + KeyInput::SetKeyModState(KMOD_CTRL, prevCtrl); + KeyInput::SetKeyModState(KMOD_ALT, prevAlt); mouse->buttons[SDL_BUTTON_RIGHT].pressed = prevRMB; mouse->buttons[SDL_BUTTON_LEFT].pressed = prevLMB; @@ -1449,14 +1436,14 @@ static bool CheckCustomCmdMods(bool rightMouseButton, ModGroup& inMods) { - if (((inMods.alt == Required) && !keyInput->IsKeyPressed(SDLK_LALT)) || - ((inMods.alt == Forbidden) && keyInput->IsKeyPressed(SDLK_LALT)) || - ((inMods.ctrl == Required) && !keyInput->IsKeyPressed(SDLK_LCTRL)) || - ((inMods.ctrl == Forbidden) && keyInput->IsKeyPressed(SDLK_LCTRL)) || - ((inMods.meta == Required) && !keyInput->IsKeyPressed(SDLK_LMETA)) || - ((inMods.meta == Forbidden) && keyInput->IsKeyPressed(SDLK_LMETA)) || - ((inMods.shift == Required) && !keyInput->IsKeyPressed(SDLK_LSHIFT)) || - ((inMods.shift == Forbidden) && keyInput->IsKeyPressed(SDLK_LSHIFT)) || + if (((inMods.alt == Required) && !KeyInput::GetKeyModState(KMOD_ALT)) || + ((inMods.alt == Forbidden) && KeyInput::GetKeyModState(KMOD_ALT)) || + ((inMods.ctrl == Required) && !KeyInput::GetKeyModState(KMOD_CTRL)) || + ((inMods.ctrl == Forbidden) && KeyInput::GetKeyModState(KMOD_CTRL)) || + ((inMods.meta == Required) && !KeyInput::GetKeyModState(KMOD_GUI)) || + ((inMods.meta == Forbidden) && KeyInput::GetKeyModState(KMOD_GUI)) || + ((inMods.shift == Required) && !KeyInput::GetKeyModState(KMOD_SHIFT)) || + ((inMods.shift == Forbidden) && KeyInput::GetKeyModState(KMOD_SHIFT)) || ((inMods.right == Required) && !rightMouseButton) || ((inMods.right == Forbidden) && rightMouseButton)) { return false; @@ -1467,8 +1454,6 @@ void CGuiHandler::RunCustomCommands(const std::vector& cmds, bool rightMouseButton) { -// GML_RECMUTEX_LOCK(gui); // RunCustomCommands - called from LuaUnsyncedCtrl::SendCommands - static int depth = 0; if (depth > 8) { return; // recursion protection @@ -1481,29 +1466,25 @@ ModGroup outMods; // controls the state of the modifiers (ex: "group1") if (ParseCustomCmdMods(copy, inMods, outMods)) { if (CheckCustomCmdMods(rightMouseButton, inMods)) { - const bool tmpAlt = !!keyInput->GetKeyState(SDLK_LALT); - const bool tmpCtrl = !!keyInput->GetKeyState(SDLK_LCTRL); - const bool tmpMeta = !!keyInput->GetKeyState(SDLK_LMETA); - const bool tmpShift = !!keyInput->GetKeyState(SDLK_LSHIFT); - - if (outMods.alt == Required) { keyInput->SetKeyState(SDLK_LALT, 1); } - if (outMods.alt == Forbidden) { keyInput->SetKeyState(SDLK_LALT, 0); } - if (outMods.ctrl == Required) { keyInput->SetKeyState(SDLK_LCTRL, 1); } - if (outMods.ctrl == Forbidden) { keyInput->SetKeyState(SDLK_LCTRL, 0); } - if (outMods.meta == Required) { keyInput->SetKeyState(SDLK_LMETA, 1); } - if (outMods.meta == Forbidden) { keyInput->SetKeyState(SDLK_LMETA, 0); } - if (outMods.shift == Required) { keyInput->SetKeyState(SDLK_LSHIFT, 1); } - if (outMods.shift == Forbidden) { keyInput->SetKeyState(SDLK_LSHIFT, 0); } + const bool tmpAlt = !!KeyInput::GetKeyModState(KMOD_ALT); + const bool tmpCtrl = !!KeyInput::GetKeyModState(KMOD_CTRL); + const bool tmpMeta = !!KeyInput::GetKeyModState(KMOD_GUI); + const bool tmpShift = !!KeyInput::GetKeyModState(KMOD_SHIFT); + + if (outMods.alt != DontCare) { KeyInput::SetKeyModState(KMOD_ALT, int(outMods.alt == Required)); } + if (outMods.ctrl != DontCare) { KeyInput::SetKeyModState(KMOD_CTRL, int(outMods.ctrl == Required)); } + if (outMods.meta != DontCare) { KeyInput::SetKeyModState(KMOD_GUI, int(outMods.meta == Required)); } + if (outMods.shift != DontCare) { KeyInput::SetKeyModState(KMOD_SHIFT, int(outMods.shift == Required)); } Action action(copy); if (!ProcessLocalActions(action)) { game->ProcessAction(action); } - keyInput->SetKeyState(SDLK_LALT, tmpAlt); - keyInput->SetKeyState(SDLK_LCTRL, tmpCtrl); - keyInput->SetKeyState(SDLK_LMETA, tmpMeta); - keyInput->SetKeyState(SDLK_LSHIFT, tmpShift); + KeyInput::SetKeyModState(KMOD_ALT, tmpAlt); + KeyInput::SetKeyModState(KMOD_CTRL, tmpCtrl); + KeyInput::SetKeyModState(KMOD_GUI, tmpMeta); + KeyInput::SetKeyModState(KMOD_SHIFT, tmpShift); } } } @@ -1513,8 +1494,6 @@ bool CGuiHandler::AboveGui(int x, int y) { - GML_RECMUTEX_LOCK(gui); // AboveGui - called from CMouseHandler::GetCurrentTooltip --> IsAbove - if (iconsCount <= 0) { return false; } @@ -1546,9 +1525,9 @@ options |= SHIFT_KEY; } } - if (keyInput->IsKeyPressed(SDLK_LCTRL)) { options |= CONTROL_KEY; } - if (keyInput->IsKeyPressed(SDLK_LALT) ) { options |= ALT_KEY; } - if (keyInput->IsKeyPressed(SDLK_LMETA)) { options |= META_KEY; } + if (KeyInput::GetKeyModState(KMOD_CTRL)) { options |= CONTROL_KEY; } + if (KeyInput::GetKeyModState(KMOD_ALT) ) { options |= ALT_KEY; } + if (KeyInput::GetKeyModState(KMOD_GUI)) { options |= META_KEY; } return options; } @@ -1590,9 +1569,6 @@ int cmdID = -1; { - GML_THRMUTEX_LOCK(unit, GML_DRAW); // GetDefaultCommand - GML_THRMUTEX_LOCK(feat, GML_DRAW); // GetDefaultCommand - CUnit* unit = NULL; CFeature* feature = NULL; if ((ir == minimap) && (minimap->FullProxy())) { @@ -1611,8 +1587,6 @@ cmdID = selectedUnitsHandler.GetDefaultCmd(unit, feature); } - GML_RECMUTEX_LOCK(gui); // GetDefaultCommand - // make sure the command is currently available for (int c = 0; c < (int)commands.size(); c++) { if (cmdID == commands[c].id) { @@ -1652,24 +1626,6 @@ selectedUnitsHandler.SetCommandPage(activePage); return true; } - else if (action.command == "hotbind") { - const int iconPos = IconAtPos(mouse->lastx, mouse->lasty); - const int iconCmd = (iconPos >= 0) ? icons[iconPos].commandsID : -1; - if ((iconCmd >= 0) && ((size_t)iconCmd < commands.size())) { - game->SetHotBinding(commands[iconCmd].action); - } - return true; - } - else if (action.command == "hotunbind") { - const int iconPos = IconAtPos(mouse->lastx, mouse->lasty); - const int iconCmd = (iconPos >= 0) ? icons[iconPos].commandsID : -1; - if ((iconCmd >= 0) && ((size_t)iconCmd < commands.size())) { - std::string cmd = "unbindaction " + commands[iconCmd].action; - keyBindings->ExecuteCommand(cmd); - LOG("%s", cmd.c_str()); - } - return true; - } else if (action.command == "showcommands") { // bonus command for debugging LOG("Available Commands:"); @@ -1689,10 +1645,6 @@ LOG("commands.size() = " _STPF_, commands.size()); return true; } - else if (action.command == "luaui") { - PushLayoutCommand(action.extra); - return true; - } else if (action.command == "invqueuekey") { if (action.extra.empty()) { invertQueueKey = !invertQueueKey; @@ -1708,63 +1660,6 @@ } -void CGuiHandler::RunLayoutCommand(const std::string& command) -{ - const bool dualStates = (LUA_MT_OPT & LUA_STATE) && (globalConfig->GetMultiThreadLua() == MT_LUA_DUAL_ALL || globalConfig->GetMultiThreadLua() == MT_LUA_DUAL_UNMANAGED); - - if (command == "reload" || command == "enable" || (dualStates && command == "update")) { - if (luaUI && luaUI->IsRunning()) { - // NOTE: causes a SEGV through RunCallIn() - LOG_L(L_WARNING, "Can not reload from within LuaUI, yet"); - return; - } - if (luaUI == NULL) { - LOG("Loading: \"%s\"", "luaui.lua"); // FIXME - CLuaUI::LoadHandler(); - if (luaUI == NULL) { - LoadConfig("ctrlpanel.txt"); - LOG_L(L_WARNING, "Loading failed"); - } - } else { - if (command == "enable") { - LOG_L(L_WARNING, "LuaUI is already enabled"); - } else { - LOG("Reloading: \"%s\"", "luaui.lua"); // FIXME - CLuaUI::FreeHandler(); - CLuaUI::LoadHandler(); - if (luaUI == NULL) { - LoadConfig("ctrlpanel.txt"); - LOG_L(L_WARNING, "Reloading failed"); - } - } - } - LayoutIcons(false); - } - else if (command == "disable") { - if (luaUI && luaUI->IsRunning()) { - // NOTE: might cause a SEGV through RunCallIn() - LOG_L(L_WARNING, "Can not disable from within LuaUI, yet"); - return; - } - if (luaUI != NULL) { - CLuaUI::FreeHandler(); - LoadConfig("ctrlpanel.txt"); - LOG("Disabled LuaUI"); - } - LayoutIcons(false); - } - else { - if (luaUI != NULL) { - luaUI->ConfigCommand(command); - } else { - //LOG_L(L_DEBUG, "[%s] LuaUI is not loaded (command=\"%s\")", __FUNCTION__, command.c_str()); - } - } - - return; -} - - bool CGuiHandler::ProcessBuildActions(const Action& action) { const std::string& arg = StringToLower(action.extra); @@ -1830,10 +1725,8 @@ } -bool CGuiHandler::KeyPressed(unsigned short key, bool isRepeat) +bool CGuiHandler::KeyPressed(int key, bool isRepeat) { - GML_RECMUTEX_LOCK(gui); // KeyPressed - updates inCommand - if (key == SDLK_ESCAPE && activeMousePress) { activeMousePress = false; inCommand = -1; @@ -1846,18 +1739,17 @@ return true; } - CKeySet ks(key, false); - const CKeyBindings::ActionList& al = keyBindings->GetActionList(ks); + const CKeySet ks(key, false); // setup actionOffset + //WTF a bit more documentation??? int tmpActionOffset = actionOffset; if ((inCommand < 0) || (lastKeySet.Key() < 0)){ actionOffset = 0; tmpActionOffset = 0; lastKeySet.Reset(); } - else if (!keyCodes->IsModifier(ks.Key()) && - (ks.Key() != keyBindings->GetFakeMetaKey())) { + else if (!ks.IsPureModifier()) { // not a modifier if ((ks == lastKeySet) && (ks.Key() >= 0)) { actionOffset++; @@ -1867,8 +1759,9 @@ } } + const CKeyBindings::ActionList& al = keyBindings->GetActionList(ks); for (int ali = 0; ali < (int)al.size(); ++ali) { - const int actionIndex = (ali + tmpActionOffset) % (int)al.size(); + const int actionIndex = (ali + tmpActionOffset) % (int)al.size(); //???? const Action& action = al[actionIndex]; if (SetActiveCommand(action, ks, actionIndex)) { return true; @@ -1886,8 +1779,6 @@ return true; } - GML_RECMUTEX_LOCK(gui); // SetActiveCommand - updates inCommand, called by LuaUnsyncedCtrl - // See if we have a positional icon command int iconCmd = -1; if (!action.extra.empty() && (action.command == "iconpos")) { @@ -2046,16 +1937,14 @@ } -bool CGuiHandler::KeyReleased(unsigned short key) +bool CGuiHandler::KeyReleased(int key) { return false; } void CGuiHandler::FinishCommand(int button) { - GML_RECMUTEX_LOCK(gui); // FinishCommand - updates inCommand - - if ((button == SDL_BUTTON_LEFT) && (keyInput->IsKeyPressed(SDLK_LSHIFT) || invertQueueKey)) { + if ((button == SDL_BUTTON_LEFT) && (KeyInput::GetKeyModState(KMOD_SHIFT) || invertQueueKey)) { needShift = true; } else { SetShowingMetal(false); @@ -2072,8 +1961,6 @@ std::string CGuiHandler::GetTooltip(int x, int y) { - GML_RECMUTEX_LOCK(gui); // GetTooltip - called from LuaUnsyncedRead::GetCurrentTooltip --> CMouseHandler::GetCurrentTooltip - std::string s; const int iconPos = IconAtPos(x, y); @@ -2085,13 +1972,11 @@ s = commands[iconCmd].name; } - const CKeyBindings::HotkeyList& hl = - keyBindings->GetHotkeys(commands[iconCmd].action); + const CKeyBindings::HotkeyList& hl = keyBindings->GetHotkeys(commands[iconCmd].action); if(!hl.empty()){ - s+="\nHotkeys:"; - for (int i = 0; i < (int)hl.size(); ++i) { - s+=" "; - s+=hl[i]; + s += "\nHotkeys:"; + for (const std::string& hk: hl) { + s += " " + hk; } } } @@ -2105,8 +1990,6 @@ // mousehandler::getcurrenttooltip --> CMiniMap::gettooltip --> GetBuildTooltip std::string CGuiHandler::GetBuildTooltip() const { - GML_RECMUTEX_LOCK(gui); // GetBuildTooltip - called from LuaUnsyncedRead::GetCurrentTooltip --> MouseHandler::GetCurrentTooltip - if ((inCommand >= 0) && ((size_t)inCommand < commands.size()) && (commands[inCommand].type == CMDTYPE_ICON_BUILDING)) { return commands[inCommand].tooltip; @@ -2173,10 +2056,6 @@ } } - GML_THRMUTEX_LOCK(unit, GML_DRAW); // GetCommand - GML_THRMUTEX_LOCK(feat, GML_DRAW); // GetCommand - GML_RECMUTEX_LOCK(gui); // GetCommand - updates inCommand - if ((tempInCommand >= 0) && ((size_t)tempInCommand < commands.size())) { switch(commands[tempInCommand].type) { @@ -2195,7 +2074,7 @@ } case CMDTYPE_ICON_MAP: { - const float dist = ground->LineGroundCol(cameraPos, cameraPos + (mouseDir * globalRendering->viewRange * 1.4f), false); + const float dist = CGround::LineGroundCol(cameraPos, cameraPos + (mouseDir * globalRendering->viewRange * 1.4f), false); if (dist < 0) { return defaultRet; } @@ -2205,7 +2084,7 @@ } case CMDTYPE_ICON_BUILDING: { - const float dist = ground->LineGroundCol(cameraPos, cameraPos + mouseDir * globalRendering->viewRange * 1.4f, false); + const float dist = CGround::LineGroundCol(cameraPos, cameraPos + mouseDir * globalRendering->viewRange * 1.4f, false); if (dist < 0) { return defaultRet; } @@ -2219,7 +2098,7 @@ std::vector buildPos; BuildInfo bi(unitdef, pos, buildFacing); if (GetQueueKeystate() && (button == SDL_BUTTON_LEFT)) { - const float dist = ground->LineGroundCol( + const float dist = CGround::LineGroundCol( mouse->buttons[SDL_BUTTON_LEFT].camPos, mouse->buttons[SDL_BUTTON_LEFT].camPos + mouse->buttons[SDL_BUTTON_LEFT].dir * globalRendering->viewRange * 1.4f, @@ -2288,7 +2167,7 @@ } case CMDTYPE_ICON_FRONT: { - float dist = ground->LineGroundCol( + float dist = CGround::LineGroundCol( mouse->buttons[button].camPos, mouse->buttons[button].camPos + mouse->buttons[button].dir * globalRendering->viewRange * 1.4f, @@ -2303,7 +2182,7 @@ Command c(commands[tempInCommand].id, CreateOptions(button), pos); if (mouse->buttons[button].movement > 30) { // only create the front if the mouse has moved enough - dist = ground->LineGroundCol(cameraPos, cameraPos + mouseDir * globalRendering->viewRange * 1.4f, false); + dist = CGround::LineGroundCol(cameraPos, cameraPos + mouseDir * globalRendering->viewRange * 1.4f, false); if (dist < 0) { return defaultRet; } @@ -2360,7 +2239,7 @@ } } } else { // created area - float dist = ground->LineGroundCol( + float dist = CGround::LineGroundCol( mouse->buttons[button].camPos, mouse->buttons[button].camPos + mouse->buttons[button].dir * globalRendering->viewRange * 1.4f, @@ -2372,7 +2251,7 @@ } const float3 pos = mouse->buttons[button].camPos + mouse->buttons[button].dir * dist; c.PushPos(pos); - dist = ground->LineGroundCol(cameraPos, cameraPos + mouseDir * globalRendering->viewRange * 1.4f, false); + dist = CGround::LineGroundCol(cameraPos, cameraPos + mouseDir * globalRendering->viewRange * 1.4f, false); if (dist < 0) { return defaultRet; } @@ -2409,7 +2288,7 @@ } } else { // created rectangle - float dist = ground->LineGroundCol( + float dist = CGround::LineGroundCol( mouse->buttons[button].camPos, mouse->buttons[button].camPos + mouse->buttons[button].dir * globalRendering->viewRange * 1.4f, @@ -2419,7 +2298,7 @@ return defaultRet; } const float3 startPos = mouse->buttons[button].camPos + mouse->buttons[button].dir * dist; - dist = ground->LineGroundCol(cameraPos, cameraPos + mouseDir * globalRendering->viewRange * 1.4f, false); + dist = CGround::LineGroundCol(cameraPos, cameraPos + mouseDir * globalRendering->viewRange * 1.4f, false); if (dist < 0) { return defaultRet; } @@ -2445,8 +2324,6 @@ static bool WouldCancelAnyQueued(const BuildInfo& b) { - GML_RECMUTEX_LOCK(sel); // WouldCancelAnyQueued - called from DrawMapStuff -> GetBuildPos --> FillRowOfBuildPos - Command c = b.CreateCommand(); CUnitSet::iterator ui = selectedUnitsHandler.selectedUnits.begin(); for (; ui != selectedUnitsHandler.selectedUnits.end(); ++ui) { @@ -2480,9 +2357,7 @@ BuildInfo other; // the unit around which buildings can be circled - if (GetQueueKeystate() && keyInput->IsKeyPressed(SDLK_LCTRL)) { - GML_RECMUTEX_LOCK(quad); // GetBuildCommand - accesses activeunits - called from DrawMapStuff -> GetBuildPos - + if (GetQueueKeystate() && KeyInput::GetKeyModState(KMOD_CTRL)) { CUnit* unit; CFeature* feature; TraceRay::GuiTraceRay(cameraPos, mouseDir, globalRendering->viewRange * 1.4f, NULL, unit, feature, true); @@ -2501,7 +2376,7 @@ } } - if (other.def && GetQueueKeystate() && keyInput->IsKeyPressed(SDLK_LCTRL)) { + if (other.def && GetQueueKeystate() && KeyInput::GetKeyModState(KMOD_CTRL)) { // circle build around building int oxsize = other.GetXSize() * SQUARE_SIZE; int ozsize = other.GetZSize() * SQUARE_SIZE; @@ -2533,8 +2408,8 @@ const int znum = (int)((math::fabs(delta.z) + zsize * 1.4f)/zsize); float zstep = (int)((0 < delta.z) ? zsize : -zsize); - if (keyInput->IsKeyPressed(SDLK_LALT)) { // build a rectangle - if (keyInput->IsKeyPressed(SDLK_LCTRL)) { // hollow rectangle + if (KeyInput::GetKeyModState(KMOD_ALT)) { // build a rectangle + if (KeyInput::GetKeyModState(KMOD_CTRL)) { // hollow rectangle if ((1 < xnum) && (1 < znum)) { // go "down" on the "left" side FillRowOfBuildPos(startInfo, start.x , start.z + zstep , 0, zstep, znum - 1, 0, false, ret); @@ -2565,9 +2440,9 @@ } else { // build a line const bool xDominatesZ = math::fabs(delta.x) > math::fabs(delta.z); if (xDominatesZ) { - zstep = keyInput->IsKeyPressed(SDLK_LCTRL) ? 0 : xstep * delta.z / (delta.x ? delta.x : 1); + zstep = KeyInput::GetKeyModState(KMOD_CTRL) ? 0 : xstep * delta.z / (delta.x ? delta.x : 1); } else { - xstep = keyInput->IsKeyPressed(SDLK_LCTRL) ? 0 : zstep * delta.x / (delta.z ? delta.z : 1); + xstep = KeyInput::GetKeyModState(KMOD_CTRL) ? 0 : zstep * delta.x / (delta.z ? delta.z : 1); } FillRowOfBuildPos(startInfo, start.x, start.z, xstep, zstep, xDominatesZ ? xnum : znum, 0, false, ret); } @@ -2582,7 +2457,7 @@ return; // leave it centered } pos0 = pos1 + ((pos0 - pos1) * 0.5f); - pos0.y = ground->GetHeightReal(pos0.x, pos0.z, false); + pos0.y = CGround::GetHeightReal(pos0.x, pos0.z, false); } @@ -2745,8 +2620,8 @@ const char scriptType = str[1]; switch (scriptType) { case 'u': { luaHandle = luaUI; break; } - case 'g': { luaHandle = luaGaia; break; } - case 'm': { luaHandle = luaRules; break; } + case 'g': { luaHandle = &luaGaia->unsyncedLuaHandle; break; } + case 'm': { luaHandle = &luaRules->unsyncedLuaHandle; break; } default: { break; } } if (luaHandle == NULL) { @@ -2840,6 +2715,9 @@ return false; } + assert(xscale<=0.5); //border >= 50% makes no sence + assert(yscale<=0.5); + // calculate the scaled quad const float x1 = b.x1 + (xIconSize * xscale); const float x2 = b.x2 - (xIconSize * xscale); @@ -3169,8 +3047,6 @@ void CGuiHandler::DrawSelectionInfo() { - GML_RECMUTEX_LOCK(sel); // DrawSelectionInfo - called from Draw --> DrawButtons - if (!selectedUnitsHandler.selectedUnits.empty()) { std::ostringstream buf; @@ -3486,7 +3362,7 @@ maxRadius = atof(cmdDesc.params[0].c_str()); } if (mouse->buttons[button].movement > 4) { - float dist = ground->LineGroundCol( + float dist = CGround::LineGroundCol( mouse->buttons[button].camPos, mouse->buttons[button].camPos + mouse->buttons[button].dir * globalRendering->viewRange * 1.4f, @@ -3496,7 +3372,7 @@ break; } float3 pos=mouse->buttons[button].camPos+mouse->buttons[button].dir*dist; - dist = ground->LineGroundCol(cameraPos, cameraPos + mouseDir * globalRendering->viewRange * 1.4f, false); + dist = CGround::LineGroundCol(cameraPos, cameraPos + mouseDir * globalRendering->viewRange * 1.4f, false); if (dist < 0) { break; } @@ -3540,7 +3416,7 @@ } case CMDTYPE_ICON_UNIT_OR_RECTANGLE:{ if (mouse->buttons[button].movement >= 16) { - float dist = ground->LineGroundCol( + float dist = CGround::LineGroundCol( mouse->buttons[button].camPos, mouse->buttons[button].camPos + mouse->buttons[button].dir * globalRendering->viewRange * 1.4f, @@ -3550,7 +3426,7 @@ break; } const float3 pos1 = mouse->buttons[button].camPos+mouse->buttons[button].dir*dist; - dist = ground->LineGroundCol(cameraPos, cameraPos + mouseDir * globalRendering->viewRange * 1.4f, false); + dist = CGround::LineGroundCol(cameraPos, cameraPos + mouseDir * globalRendering->viewRange * 1.4f, false); if (dist < 0) { break; } @@ -3584,8 +3460,6 @@ // draw the ranges for the unit that is being pointed at const CUnit* pointedAt = NULL; - GML_RECMUTEX_LOCK(unit); // DrawMapStuff - if (GetQueueKeystate()) { CUnit* unit = NULL; CFeature* feature = NULL; @@ -3686,8 +3560,6 @@ if ((inCommand >= 0) && ((size_t)inCommand < commands.size()) && (commands[inCommand].type == CMDTYPE_ICON_BUILDING)) { { // limit the locking scope to avoid deadlock - GML_STDMUTEX_LOCK(cai); // DrawMapStuff - // draw build distance for all immobile builders during build commands const std::map& builderCAIs = unitHandler->builderCAIs; std::map::const_iterator bi; @@ -3713,7 +3585,7 @@ } } - float dist = ground->LineGroundCol(cameraPos, cameraPos + mouseDir * globalRendering->viewRange * 1.4f, false); + float dist = CGround::LineGroundCol(cameraPos, cameraPos + mouseDir * globalRendering->viewRange * 1.4f, false); if (dist > 0) { const UnitDef* unitdef = unitDefHandler->GetUnitDefByID(-commands[inCommand].id); if (unitdef) { @@ -3722,7 +3594,7 @@ std::vector buildPos; const CMouseHandler::ButtonPressEvt& bp = mouse->buttons[SDL_BUTTON_LEFT]; if (GetQueueKeystate() && bp.pressed) { - const float dist = ground->LineGroundCol(bp.camPos, bp.camPos + bp.dir * globalRendering->viewRange * 1.4f, false); + const float dist = CGround::LineGroundCol(bp.camPos, bp.camPos + bp.dir * globalRendering->viewRange * 1.4f, false); const float3 pos2 = bp.camPos + bp.dir * dist; buildPos = GetBuildPos(BuildInfo(unitdef, pos2, buildFacing), BuildInfo(unitdef, pos, buildFacing), cameraPos, mouseDir); @@ -3778,8 +3650,6 @@ std::vector cv; if (GetQueueKeystate()) { - GML_RECMUTEX_LOCK(sel); // DrawMapStuff - Command c = bpi->CreateCommand(); std::vector temp; CUnitSet::iterator ui = selectedUnitsHandler.selectedUnits.begin(); @@ -3812,8 +3682,6 @@ if ((inCommand>=0 && (size_t)inCommand0 && commands[defcmd].id==CMD_ATTACK) ) { - GML_RECMUTEX_LOCK(sel); // DrawMapStuff - for(CUnitSet::iterator si=selectedUnitsHandler.selectedUnits.begin(); si!=selectedUnitsHandler.selectedUnits.end(); ++si) { CUnit* unit = *si; if (unit == pointedAt) { @@ -3862,7 +3730,7 @@ { bc[0] * d[7], bc[1] * d[7], bc[2] * d[7], bc[3] }, }; - const float groundLevel = ground->GetHeightAboveWater(cameraPos.x, cameraPos.z, false); + const float groundLevel = CGround::GetHeightAboveWater(cameraPos.x, cameraPos.z, false); static float spinTime = 0.0f; spinTime = math::fmod(spinTime + globalRendering->lastFrameTime * 0.001f, 60.0f); @@ -3915,19 +3783,17 @@ } if ((cmd == CMD_MOVE) || (cmd == CMD_GATHERWAIT)) { - if (!keyInput->IsKeyPressed(SDLK_LCTRL) && !keyInput->IsKeyPressed(SDLK_LALT) && !keyInput->IsKeyPressed(SDLK_LMETA)) { + if (!KeyInput::GetKeyModState(KMOD_CTRL) && !KeyInput::GetKeyModState(KMOD_ALT) && !KeyInput::GetKeyModState(KMOD_GUI)) { return; } } else if ((cmd == CMD_FIGHT) || (cmd == CMD_PATROL)) { - if (!keyInput->IsKeyPressed(SDLK_LCTRL)) { + if (!KeyInput::GetKeyModState(KMOD_CTRL)) { return; } } else { return; } - GML_RECMUTEX_LOCK(sel); // DrawCentroidCursor - called From CMouseHandler::DrawCursor - const CUnitSet& selUnits = selectedUnitsHandler.selectedUnits; if (selUnits.size() < 2) { return; @@ -3970,7 +3836,7 @@ for(int a=0;a<=40;++a){ float3 p(fastmath::cos(a*2*PI/40)*radius,0,fastmath::sin(a*2*PI/40)*radius); p+=pos; - p.y=ground->GetHeightAboveWater(p.x, p.z, false); + p.y=CGround::GetHeightAboveWater(p.x, p.z, false); glVertexf3(p); } glEnd(); @@ -3985,12 +3851,12 @@ if(bp.movement<5){ return; } - float dist = ground->LineGroundCol(bp.camPos, bp.camPos + bp.dir * globalRendering->viewRange * 1.4f, false); + float dist = CGround::LineGroundCol(bp.camPos, bp.camPos + bp.dir * globalRendering->viewRange * 1.4f, false); if(dist<0){ return; } float3 pos1=bp.camPos+bp.dir*dist; - dist = ground->LineGroundCol(cameraPos, cameraPos + mouseDir * globalRendering->viewRange * 1.4f, false); + dist = CGround::LineGroundCol(cameraPos, cameraPos + mouseDir * globalRendering->viewRange * 1.4f, false); if(dist<0){ return; } @@ -4003,7 +3869,7 @@ float3 side=forward.cross(UpVector); if(pos1.SqDistance2D(pos2)>maxSize*maxSize){ pos2=pos1+side*maxSize; - pos2.y=ground->GetHeightAboveWater(pos2.x, pos2.z, false); + pos2.y=CGround::GetHeightAboveWater(pos2.x, pos2.z, false); } glColor4f(0.5f, 1.0f, 0.5f, 0.5f); @@ -4049,7 +3915,7 @@ const float d = (float)i; p.x = pos1.x + (d * delta.x); p.z = pos1.z + (d * delta.z); - p.y = ground->GetHeightAboveWater(p.x, p.z, false); + p.y = CGround::GetHeightAboveWater(p.x, p.z, false); p.y -= 100.f; glVertexf3(p); p.y += 200.f; glVertexf3(p); } @@ -4104,10 +3970,10 @@ static void DrawCornerPosts(const float3& pos0, const float3& pos1) { const float3 lineVector(0.0f, 128.0f, 0.0f); - const float3 corner0(pos0.x, ground->GetHeightAboveWater(pos0.x, pos0.z, false), pos0.z); - const float3 corner1(pos1.x, ground->GetHeightAboveWater(pos1.x, pos1.z, false), pos1.z); - const float3 corner2(pos0.x, ground->GetHeightAboveWater(pos0.x, pos1.z, false), pos1.z); - const float3 corner3(pos1.x, ground->GetHeightAboveWater(pos1.x, pos0.z, false), pos0.z); + const float3 corner0(pos0.x, CGround::GetHeightAboveWater(pos0.x, pos0.z, false), pos0.z); + const float3 corner1(pos1.x, CGround::GetHeightAboveWater(pos1.x, pos1.z, false), pos1.z); + const float3 corner2(pos0.x, CGround::GetHeightAboveWater(pos0.x, pos1.z, false), pos1.z); + const float3 corner3(pos1.x, CGround::GetHeightAboveWater(pos1.x, pos0.z, false), pos0.z); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glLineWidth(2.0f); @@ -4306,7 +4172,7 @@ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(color[0], color[1], color[2], 0.9f); glLineWidth(2.0f); - const float3 base(pos.x, ground->GetHeightAboveWater(pos.x, pos.z, false), pos.z); + const float3 base(pos.x, CGround::GetHeightAboveWater(pos.x, pos.z, false), pos.z); glBegin(GL_LINES); glVertexf3(base); glVertexf3(base + float3(0.0f, 128.0f, 0.0f)); @@ -4334,43 +4200,3 @@ /******************************************************************************/ /******************************************************************************/ - - -void CGuiHandler::PushLayoutCommand(const std::string& cmd, bool luaCmd) { - if (GML::SimEnabled()) { - GML_STDMUTEX_LOCK(laycmd); // PushLayoutCommand - - layoutCommands.push_back(cmd); - if(luaCmd) - hasLuaUILayoutCommands = true; - } else { - RunLayoutCommand(cmd); - } -} - -void CGuiHandler::RunLayoutCommands() { - if (!GML::SimEnabled() || layoutCommands.empty()) - return; - - bool luaCmd; - std::vector layoutCmds; - { - GML_STDMUTEX_LOCK(laycmd); // RunLayoutCommands - - layoutCmds.swap(layoutCommands); - luaCmd = hasLuaUILayoutCommands; - hasLuaUILayoutCommands = false; - } - - if(luaCmd) { - GML_MSTMUTEX_LOCK(sim, -1); // RunLayoutCommands - - for (std::vector::const_iterator cit = layoutCmds.begin(); cit != layoutCmds.end(); ++cit) { - RunLayoutCommand(*cit); - } - } else { - for (std::vector::const_iterator cit = layoutCmds.begin(); cit != layoutCmds.end(); ++cit) { - RunLayoutCommand(*cit); - } - } -} diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/GuiHandler.h spring-98.0~14.04~ppa6/rts/Game/UI/GuiHandler.h --- spring-96.0~14.04~ppa4/rts/Game/UI/GuiHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/GuiHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -33,8 +33,8 @@ void DrawCentroidCursor(); bool AboveGui(int x, int y); - bool KeyPressed(unsigned short key, bool isRepeat); - bool KeyReleased(unsigned short key); + bool KeyPressed(int key, bool isRepeat); + bool KeyReleased(int key); bool MousePress(int x, int y, int button); void MouseRelease(int x, int y, int button) { @@ -99,8 +99,8 @@ void SetBuildFacing(unsigned int facing); void SetBuildSpacing(int spacing); - void PushLayoutCommand(const std::string& cmd, bool luaCmd = true); - void RunLayoutCommands(); + void LayoutIcons(bool useSelectionPage); + bool LoadConfig(const std::string& cfg); public: std::vector commands; @@ -111,7 +111,6 @@ private: void GiveCommand(Command& cmd, bool fromUser = true); void GiveCommandsNow(); - void LayoutIcons(bool useSelectionPage); bool LayoutCustomIcons(bool useSelectionPage); void ResizeIconArray(unsigned int size); void AppendPrevAndNext(std::vector& cmds); @@ -163,7 +162,6 @@ void LoadDefaults(); void SanitizeConfig(); - bool LoadConfig(const std::string& cfg); void ParseFillOrder(const std::string& text); bool ProcessLocalActions(const Action& action); @@ -244,7 +242,6 @@ int failedSound; std::vector layoutCommands; - bool hasLuaUILayoutCommands; std::vector< std::pair > commandsToGive; }; diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/HwMouseCursor.cpp spring-98.0~14.04~ppa6/rts/Game/UI/HwMouseCursor.cpp --- spring-96.0~14.04~ppa4/rts/Game/UI/HwMouseCursor.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/HwMouseCursor.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,8 +2,9 @@ #include "System/Platform/Win/win32.h" #if !defined(HEADLESS) -#include "Rendering/Textures/Bitmap.h" + #include "Rendering/Textures/Bitmap.h" #endif +#include "Rendering/GlobalRendering.h" #if defined(__APPLE__) || defined(HEADLESS) // no hardware cursor support for mac's and headless build @@ -29,6 +30,7 @@ #include "System/myMath.h" #include // for memset +#include #include #include #include @@ -518,14 +520,14 @@ SDL_SysWMinfo info; SDL_VERSION(&info.version); - if (!SDL_GetWMInfo(&info)) { + if (!SDL_GetWindowWMInfo(globalRendering->window, &info)) { + LOG_L(L_ERROR, "SDL error: can't get X11 window info"); XcursorImagesDestroy(cis); cimages.clear(); - LOG_L(L_ERROR, "SDL error: can't get X11 window info"); return; } - cursor = XcursorImagesLoadCursor(info.info.x11.display,cis); + cursor = XcursorImagesLoadCursor(info.info.x11.display, cis); XcursorImagesDestroy(cis); cimages.clear(); } @@ -534,21 +536,19 @@ { SDL_SysWMinfo info; SDL_VERSION(&info.version); - if (!SDL_GetWMInfo(&info)) { + if (!SDL_GetWindowWMInfo(globalRendering->window, &info)) { LOG_L(L_ERROR, "SDL error: can't get X11 window info"); return; } // do between lock/unlock so SDL's default cursors doesn't flicker in - info.info.x11.lock_func(); - SDL_ShowCursor(SDL_ENABLE); - XDefineCursor(info.info.x11.display, info.info.x11.window, cursor); - info.info.x11.unlock_func(); + SDL_ShowCursor(SDL_ENABLE); + XDefineCursor(info.info.x11.display, info.info.x11.window, cursor); } CHwX11Cursor::CHwX11Cursor() { - cursor = 0; - hotSpot=CMouseCursor::Center; + cursor = 0; + hotSpot = CMouseCursor::Center; xmaxsize = ymaxsize = 0; } @@ -561,7 +561,7 @@ if (cursor!=0) { SDL_SysWMinfo info; SDL_VERSION(&info.version); - if (!SDL_GetWMInfo(&info)) { + if (!SDL_GetWindowWMInfo(globalRendering->window, &info)) { LOG_L(L_ERROR, "SDL error: can't get X11 window info"); return; } diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/InfoConsole.cpp spring-98.0~14.04~ppa6/rts/Game/UI/InfoConsole.cpp --- spring-96.0~14.04~ppa4/rts/Game/UI/InfoConsole.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/InfoConsole.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,20 +2,17 @@ #include "Rendering/GL/myGL.h" - #include "InfoConsole.h" #include "InputReceiver.h" #include "GuiHandler.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "System/EventHandler.h" #include "System/Config/ConfigHandler.h" #include "System/Log/LogSinkHandler.h" -#include - #define border 7 -CONFIG(int, InfoMessageTime).defaultValue(400); +CONFIG(int, InfoMessageTime).defaultValue(10).description("Timeout till old messages disappear from the ingame console."); CONFIG(std::string, InfoConsoleGeometry).defaultValue("0.26 0.96 0.41 0.205"); ////////////////////////////////////////////////////////////////////// @@ -27,15 +24,13 @@ CInfoConsole::CInfoConsole() : CEventClient("InfoConsole", 999, false) - , fontScale(1.0f) , enabled(true) , lastMsgIter(lastMsgPositions.begin()) , newLines(0) , rawId(0) - , lastTime(0) + , fontScale(1.0f) + , maxLines(1) { - data.clear(); - lifetime = configHandler->GetInt("InfoMessageTime"); const std::string geo = configHandler->GetString("InfoConsoleGeometry"); @@ -48,6 +43,9 @@ height = 0.205f; } + if (width == 0.f || height == 0.f) + enabled = false; + fontSize = fontScale * smallFont->GetSize(); logSinkHandler.AddSink(this); @@ -64,10 +62,12 @@ { if (!enabled) return; if (!smallFont) return; + if (data.empty()) return; - boost::recursive_mutex::scoped_lock scoped_lock(infoConsoleMutex); // XXX is this really needed? + boost::recursive_mutex::scoped_lock scoped_lock(infoConsoleMutex); - if(!data.empty() && (guihandler && !guihandler->GetOutlineFonts())){ + if (guihandler && !guihandler->GetOutlineFonts()) { + // draw a black background when not using outlined font glDisable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -92,10 +92,9 @@ if (guihandler && guihandler->GetOutlineFonts()) fontOptions |= FONT_OUTLINE; - std::deque::iterator ili; - for (ili = data.begin(); ili != data.end(); ++ili) { + for (int i = 0; i < std::min(data.size(), maxLines); ++i) { curY -= fontHeight; - smallFont->glPrint(curX, curY, fontSize, fontOptions, ili->text); + smallFont->glPrint(curX, curY, fontSize, fontOptions, data[i].text); } smallFont->End(); @@ -105,14 +104,25 @@ void CInfoConsole::Update() { boost::recursive_mutex::scoped_lock scoped_lock(infoConsoleMutex); - if (lastTime > 0) { - lastTime--; + if (data.empty()) + return; + + // pop old messages after timeout + if (data[0].timeout <= spring_gettime()) { + data.pop_front(); } - if (!data.empty()) { - data.begin()->time--; - if (data[0].time <= 0) { - data.pop_front(); - } + + if (!smallFont) + return; + + // if we have more lines then we can show, remove the oldest one, + // and make sure the others are shown long enough + const float maxHeight = (height * globalRendering->viewSizeY) - (border * 2); + maxLines = (smallFont->GetLineHeight() > 0) + ? math::floor(maxHeight / (fontSize * smallFont->GetLineHeight())) + : 1; // this will likely be the case on HEADLESS only + for (size_t i = data.size(); i > maxLines; i--) { + data.pop_front(); } } @@ -144,13 +154,10 @@ int CInfoConsole::GetRawLines(std::deque& lines) { - int tmp; - { - boost::recursive_mutex::scoped_lock scoped_lock(infoConsoleMutex); - lines = rawData; - tmp = newLines; - newLines = 0; - } + boost::recursive_mutex::scoped_lock scoped_lock(infoConsoleMutex); + lines = rawData; + int tmp = newLines; + newLines = 0; return tmp; } @@ -160,65 +167,55 @@ { boost::recursive_mutex::scoped_lock scoped_lock(infoConsoleMutex); - RawLine rl(text, section, level, rawId); - rawId++; - rawData.push_back(rl); if (rawData.size() > maxRawLines) { rawData.pop_front(); } if (newLines < maxRawLines) { - newLines++; + ++newLines; } + rawData.emplace_back(text, section, level, rawId++); if (!smallFont) { return; } - const float maxWidth = (width * globalRendering->viewSizeX) - (border * 2); - const float maxHeight = (height * globalRendering->viewSizeY) - (border * 2); - const unsigned int maxLines = (smallFont->GetLineHeight() > 0) - ? math::floor(maxHeight / (fontSize * smallFont->GetLineHeight())) - : 1; // this will likely be the case on HEADLESS only - - std::list lines = smallFont->Wrap(text, fontSize, maxWidth); + // !!! Warning !!! + // We must not remove elements from `data` here + // cause ::Draw() iterats that container, and it's + // possible that it calls LOG(), which will end + // in here. So if we would remove stuff here it's + // possible that we delete a var that is used in + // Draw() & co, and so we might invalidate references + // (e.g. of std::strings) and cause SIGFAULTs! + const float maxWidth = (width * globalRendering->viewSizeX) - (2 * border); + std::string wrappedText = smallFont->Wrap(text, fontSize, maxWidth); + std::list lines = smallFont->SplitIntoLines(toustring(wrappedText)); - std::list::iterator il; - for (il = lines.begin(); il != lines.end(); ++il) { + for (auto& line: lines) { // add the line to the console - InfoLine l; - data.push_back(l); - data.back().text = *il; - data.back().time = lifetime - lastTime; - lastTime = lifetime; - } - - // if we have more lines then we can show, remove the oldest one, - // and make sure the others are shown long enough - for (size_t i = data.size(); i > maxLines; i--) { - data[1].time += data[0].time; - data.pop_front(); + data.emplace_back(); + InfoLine& l = data.back(); + l.text = std::move(line); + l.timeout = spring_gettime() + spring_secs(lifetime); } } void CInfoConsole::LastMessagePosition(const float3& pos) { - if (lastMsgPositions.size() < maxLastMsgPos) { - lastMsgPositions.push_front(pos); - } else { - lastMsgPositions.push_front(pos); + if (lastMsgPositions.size() >= maxLastMsgPos) { lastMsgPositions.pop_back(); } + lastMsgPositions.push_front(pos); // reset the iterator when a new msg comes in lastMsgIter = lastMsgPositions.begin(); } -const float3& CInfoConsole::GetMsgPos() +const float3& CInfoConsole::GetMsgPos(const float3& defaultPos) { - if (lastMsgPositions.empty()) { - return ZeroVector; - } + if (lastMsgPositions.empty()) + return defaultPos; // advance the position const float3& p = *(lastMsgIter++); diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/InfoConsole.h spring-98.0~14.04~ppa6/rts/Game/UI/InfoConsole.h --- spring-96.0~14.04~ppa4/rts/Game/UI/InfoConsole.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/InfoConsole.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,9 +7,9 @@ #include "System/float3.h" #include "System/EventClient.h" #include "System/Log/LogSinkHandler.h" +#include "System/Misc/SpringTime.h" #include -#include #include #include #include @@ -27,24 +27,13 @@ void RecordLogMessage(const std::string& section, int level, const std::string& text); - bool WantsEvent(const std::string& eventName) { return (eventName == "LastMessagePosition"); } void LastMessagePosition(const float3& pos); - const float3& GetMsgPos(); - int GetMsgPosCount() const { - return lastMsgPositions.size(); - } + const float3& GetMsgPos(const float3& defaultPos = ZeroVector); + unsigned int GetMsgPosCount() const { return lastMsgPositions.size(); } - - int lifetime; - float xpos; - float ypos; - float width; - float height; - float fontScale; - float fontSize; bool enabled; public: @@ -58,33 +47,41 @@ , section(section) , level(level) , id(id) - , time(0) {} std::string text; std::string section; int level; int id; - boost::uint32_t time; }; - int GetRawLines(std::deque& copy); + int GetRawLines(std::deque& copy); private: + struct InfoLine { + std::string text; + spring_time timeout; + }; + std::list lastMsgPositions; std::list::iterator lastMsgIter; std::deque rawData; + std::deque data; + size_t newLines; int rawId; - struct InfoLine { - std::string text; - int time; - }; - int lastTime; - std::deque data; - mutable boost::recursive_mutex infoConsoleMutex; + + int lifetime; + float xpos; + float ypos; + float width; + float height; + float fontScale; + float fontSize; + + size_t maxLines; }; #endif /* INFO_CONSOLE_H */ diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/InputReceiver.h spring-98.0~14.04~ppa6/rts/Game/UI/InputReceiver.h --- spring-96.0~14.04~ppa4/rts/Game/UI/InputReceiver.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/InputReceiver.h 2014-10-07 20:09:51.000000000 +0000 @@ -20,8 +20,8 @@ virtual ~CInputReceiver(); public: - virtual bool KeyPressed(unsigned short key, bool isRepeat) { return false; } - virtual bool KeyReleased(unsigned short key) { return false; } + virtual bool KeyPressed(int key, bool isRepeat) { return false; } + virtual bool KeyReleased(int key) { return false; } virtual bool MousePress(int x, int y, int button) { return false; } virtual void MouseMove(int x, int y, int dx, int dy, int button) {} diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/KeyAutoBinder.cpp spring-98.0~14.04~ppa6/rts/Game/UI/KeyAutoBinder.cpp --- spring-96.0~14.04~ppa4/rts/Game/UI/KeyAutoBinder.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/KeyAutoBinder.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,389 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#include - -#include "KeyAutoBinder.h" - -#include "LuaInclude.h" - -#include "KeyBindings.h" -#include "KeyBindingsLog.h" -#include "Sim/Misc/Team.h" -#include "Lua/LuaDefs.h" -#include "Lua/LuaCallInCheck.h" -#include "Lua/LuaConstGame.h" -#include "Lua/LuaUnitDefs.h" -#include "Lua/LuaWeaponDefs.h" -#include "Map/ReadMap.h" -#include "Sim/Misc/CategoryHandler.h" -#include "Sim/Misc/DamageArrayHandler.h" -#include "Sim/Misc/Wind.h" -#include "Sim/Misc/ModInfo.h" -#include "Sim/Projectiles/Projectile.h" -#include "Sim/Units/UnitDef.h" -#include "Sim/Units/UnitDefHandler.h" -#include "System/FileSystem/FileHandler.h" -#include "System/FileSystem/SimpleParser.h" -#include "System/Util.h" - -#ifdef LOG_SECTION_CURRENT - #undef LOG_SECTION_CURRENT -#endif -#define LOG_SECTION_CURRENT LOG_SECTION_KEY_BINDINGS - - -static const string UnitDefsName = "UnitDefs"; -static const string ReqFuncName = "HasReqs"; -static const string SortFuncName = "IsBetter"; -static const string CompareFuncName = "Compare"; - - -#ifndef _WIN32 -static const string endlStr = "\n"; -#else -static const string endlStr = "\r\n"; -#endif - - -/******************************************************************************/ - -CKeyAutoBinder::CKeyAutoBinder() - : CLuaHandle("KeyAutoBinder", 1234, false) -{ - if (!IsValid()) - return; - - BEGIN_ITERATE_LUA_STATES(); - - LoadCompareFunc(L); - - // load the standard libraries - LUA_OPEN_LIB(L, luaopen_base); - LUA_OPEN_LIB(L, luaopen_math); - LUA_OPEN_LIB(L, luaopen_table); - LUA_OPEN_LIB(L, luaopen_string); - LUA_OPEN_LIB(L, luaopen_debug); - //LUA_OPEN_LIB(L, luaopen_io); - //LUA_OPEN_LIB(L, luaopen_os); - //LUA_OPEN_LIB(L, luaopen_package); - - // load the spring libraries - lua_pushvalue(L, LUA_GLOBALSINDEX); - if (!AddEntriesToTable(L, "Game", LuaConstGame::PushEntries) || - !AddEntriesToTable(L, UnitDefsName.c_str(), LuaUnitDefs::PushEntries) || - !AddEntriesToTable(L, "WeaponDefs", LuaWeaponDefs::PushEntries)) { - LOG_L(L_ERROR, "Failed loading Lua libraries"); - } - - lua_settop(L, 0); - - END_ITERATE_LUA_STATES(); -} - - -CKeyAutoBinder::~CKeyAutoBinder() -{ -} - - -string CKeyAutoBinder::LoadFile(const string& filename) const -{ - CFileHandler f(filename, SPRING_VFS_RAW); - - string code; - if (!f.LoadStringData(code)) { - code.clear(); - } - return code; -} - - -bool CKeyAutoBinder::LoadCode(lua_State *L, const string& code, const string& debug) -{ - if (!IsValid()) - return false; - - lua_settop(L, 0); - - int error; - error = luaL_loadbuffer(L, code.c_str(), code.size(), debug.c_str()); - if (error != 0) { - LOG_L(L_ERROR, "Loading: %s", lua_tostring(L, -1)); - lua_pop(L, 1); - return false; - } - SetRunning(L, true); // just for the sake of consistency - error = lua_pcall(L, 0, 0, 0); - SetRunning(L, false); - if (error != 0) { - LOG_L(L_ERROR, "Running: %s", lua_tostring(L, -1)); - lua_pop(L, 1); - return false; - } - - return true; -} - - -bool CKeyAutoBinder::LoadCompareFunc(lua_State *L) -{ - std::stringstream code(endlStr); - - // handy sorting comparison routine - code << "function " << CompareFuncName << "(a, b)" << endlStr; - code << " if (type(a) == \"number\") then" << endlStr; - code << " if (a > b) then return 1.0; end" << endlStr; - code << " if (a < b) then return -1.0; end" << endlStr; - code << " elseif (type(a) == \"boolean\") then" << endlStr; - code << " if (a and not b) then return 1.0; end" << endlStr; - code << " if (not a and b) then return -1.0; end" << endlStr; - code << " elseif (type(a) == \"string\") then" << endlStr; - code << " if (a > b) then return 1.0; end" << endlStr; - code << " if (a < b) then return -1.0; end" << endlStr; - code << " end" << endlStr; - code << " return 0.0" << endlStr; - code << "end" << endlStr; - - const std::string codeStr = code.str(); - - LOG_L(L_DEBUG, "%s", codeStr.c_str()); - - if (!LoadCode(L, codeStr, CompareFuncName + "()")) { - return false; - } - - return true; -} - - -/******************************************************************************/ -/******************************************************************************/ - -static CKeyAutoBinder* thisBinder = NULL; -static lua_State* tmpLuaState = NULL; - - -bool CKeyAutoBinder::UnitDefHolder::operator<(const UnitDefHolder& m) const -{ - return thisBinder->IsBetter(tmpLuaState, udID, m.udID); -} - - -/******************************************************************************/ - -bool CKeyAutoBinder::BindBuildType(const string& keystr, - const vector& requirements, - const vector& sortCriteria, - const vector& chords) -{ - if (!IsValid()) - return false; - - SELECT_LUA_STATE(); - - lua_settop(L, 0); - - const string reqCall = MakeRequirementCall(requirements); - const string sortCall = MakeSortCriteriaCall(sortCriteria); - - if (LOG_IS_ENABLED(L_DEBUG)) { - LOG_L(L_DEBUG, "--reqCall(%s):", keystr.c_str()); - LOG_L(L_DEBUG, "%s", reqCall.c_str()); - LOG_L(L_DEBUG, "--sortCall(%s):", keystr.c_str()); - LOG_L(L_DEBUG, "%s", sortCall.c_str()); - } - - if (!LoadCode(L, reqCall, keystr + ":" + ReqFuncName + "()") || - !LoadCode(L, sortCall, keystr + ":" + SortFuncName + "()")) { - return false; - } - - vector defs; - - const std::map& udMap = unitDefHandler->unitDefIDsByName; - std::map::const_iterator udIt; - for (udIt = udMap.begin(); udIt != udMap.end(); ++udIt) { - const UnitDef* ud = unitDefHandler->GetUnitDefByID(udIt->second); - if (ud == NULL) { - continue; - } - if (HasRequirements(L, ud->id)) { - UnitDefHolder udh(ud->id, ud); - defs.push_back(udh); - } - } - - // sort the results - tmpLuaState = L; - thisBinder = this; - sort(defs.begin(), defs.end()); - - // add the bindings - const string bindStr = "bind"; - for (unsigned int i = 0; i < defs.size(); i++) { - const string lowerName = StringToLower(defs[i].ud->name); - const string action = string("buildunit_") + lowerName; - keyBindings->ExecuteCommand(bindStr + " " + keystr + " " + action); - if ((i < chords.size()) && (StringToLower(chords[i]) != "none")) { - keyBindings->ExecuteCommand(bindStr + " " + chords[i] + " " + action); - } - LOG_L(L_DEBUG, "auto-%s %s %s", - bindStr.c_str(), keystr.c_str(), action.c_str()); - } - - return true; -} - - -string CKeyAutoBinder::ConvertBooleanSymbols(const string& text) const -{ - string newText = text; - newText = StringReplace(newText, "&&", " and "); - newText = StringReplace(newText, "||", " or "); - newText = StringReplace(newText, "!", " not "); - return newText; -} - - -string CKeyAutoBinder::AddUnitDefPrefix(const string& text, - const string& prefix) const -{ - std::stringstream result(""); - const char* end = text.c_str(); - - while (end[0] != 0) { - const char* c = end; - while ((c[0] != 0) && !isalpha(c[0]) && (c[0] != '_')) { c++; } - result << string(end, c - end).c_str(); - if (c[0] == 0) { - break; - } - const char* start = c; - while ((c[0] != 0) && (isalnum(c[0]) || (c[0] == '_'))) { c++; } - string word(start, c - start); - if (LuaUnitDefs::IsDefaultParam(word)) { - result << prefix << "." << word; - } else if ((word == "custom") && (c[0] == '.')) { - result << prefix; - } else { - result << word; - } - end = c; - } - - return result.str(); -} - - -string CKeyAutoBinder::MakeRequirementCall(const vector& requirements) -{ - std::stringstream code(""); - - code << "function " << ReqFuncName << "(thisID)" << endlStr; - - const int count = (int)requirements.size(); - - if (count <= 0) { - code << "return false" << endlStr; - code << "end" << endlStr; - return code.str(); - } - - code << "local this = " << UnitDefsName << "[thisID]" << endlStr; - - if (StringToLower(requirements[0]) == "rawlua") { - for (int i = 1; i < count; i++) { - code << requirements[i] << endlStr; - } - code << "end" << endlStr; - return code.str(); - } - - code << "return "; - const int lastReq = (count - 1); - for (int i = 0; i < count; i++) { - code << "("; - code << requirements[i]; - code << ")"; - if (i != lastReq) { - code << " and "; - } - } - code << endlStr << "end" << endlStr; - - return ConvertBooleanSymbols(AddUnitDefPrefix(code.str(), "this")); -} - - -string CKeyAutoBinder::MakeSortCriteriaCall(const vector& sortCriteria) -{ - std::stringstream code(""); - - code << "function " << SortFuncName << "(thisID, thatID)" << endlStr; - - const int count = (int)sortCriteria.size(); - - if (count <= 0) { - code << "return false" << endlStr; - code << "end" << endlStr; - return code.str(); - } - - code << "local this = " << UnitDefsName << "[thisID]" << endlStr; - code << "local that = " << UnitDefsName << "[thatID]" << endlStr; - - if (StringToLower(sortCriteria[0]) == "rawlua") { - for (int i = 1; i < count; i++) { - code << sortCriteria[i] << endlStr; - } - code << "end" << endlStr; - return code.str(); - } - - for (int i = 0; i < count; i++) { - const string natural = ConvertBooleanSymbols(sortCriteria[i]); - const string thisStr = AddUnitDefPrefix(natural, "this"); - const string thatStr = AddUnitDefPrefix(natural, "that"); - code << "local test = " << CompareFuncName << "(" << thisStr << ", " << thatStr << ")" << endlStr; - code << "if (test ~= 0.0) then return (test > 0.0) end" << endlStr; - } - code << "return false" << endlStr; - code << "end" << endlStr; - - return ConvertBooleanSymbols(code.str()); -} - - -bool CKeyAutoBinder::HasRequirements(lua_State* L, int unitDefID) -{ - lua_getglobal(L, ReqFuncName.c_str()); - lua_pushnumber(L, unitDefID); - const int error = lua_pcall(L, 1, 1, 0); - if (error != 0) { - LOG_L(L_ERROR, "Running %s(%i)\n %s", - ReqFuncName.c_str(), unitDefID, lua_tostring(L, -1)); - lua_pop(L, 1); - return false; - } - const bool value = !!lua_toboolean(L, -1); - lua_pop(L, 1); - return value; -} - - -bool CKeyAutoBinder::IsBetter(lua_State* L, int thisDefID, int thatDefID) -{ - lua_getglobal(L, SortFuncName.c_str()); - lua_pushnumber(L, thisDefID); - lua_pushnumber(L, thatDefID); - const int error = lua_pcall(L, 2, 1, 0); - if (error != 0) { - LOG_L(L_ERROR, "Running %s(%i, %i)\n %s", - SortFuncName.c_str(), thisDefID, thatDefID, lua_tostring(L, -1)); - lua_pop(L, 1); - return false; - } - const bool value = !!lua_toboolean(L, -1); - lua_pop(L, 1); - return value; -} diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/KeyAutoBinder.h spring-98.0~14.04~ppa6/rts/Game/UI/KeyAutoBinder.h --- spring-96.0~14.04~ppa4/rts/Game/UI/KeyAutoBinder.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/KeyAutoBinder.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#ifndef KEY_AUTO_BINDER_H -#define KEY_AUTO_BINDER_H - -#include -#include -#include - -#include "Lua/LuaHandle.h" - -struct UnitDef; -struct lua_State; - - -class CKeyAutoBinder : public CLuaHandle -{ - public: - CKeyAutoBinder(); - ~CKeyAutoBinder(); - - bool BindBuildType(const string& keystr, - const vector& requirements, - const vector& sortCriteria, - const vector& chords); - - private: - string LoadFile(const string& filename) const; - bool LoadCode(lua_State *L, const string& code, const string& debug); - bool LoadCompareFunc(lua_State *L); - string MakeRequirementCall(const vector& requirements); - string MakeSortCriteriaCall(const vector& sortCriteria); - string AddUnitDefPrefix(const string& text, const string& pre) const; - string ConvertBooleanSymbols(const string& text) const; - bool HasRequirements(lua_State* L, int unitDefID); - bool IsBetter(lua_State* L, int thisDefID, int thatDefID); - - private: - class UnitDefHolder { - public: - UnitDefHolder(int udID, const UnitDef* ud) : udID(udID), ud(ud) {} - bool operator<(const UnitDefHolder&) const; - - int udID; - const UnitDef* ud; - }; - - friend class CKeyAutoBinder::UnitDefHolder; -}; - -#endif /* KEY_AUTO_BINDER_H */ diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/KeyBindings.cpp spring-98.0~14.04~ppa6/rts/Game/UI/KeyBindings.cpp --- spring-96.0~14.04~ppa4/rts/Game/UI/KeyBindings.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/KeyBindings.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,66 +1,60 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#include -#include -#include +#include #include "KeyBindings.h" -#include "KeyBindingsLog.h" -#include "SDL_keysym.h" #include "KeyCodes.h" #include "KeySet.h" -#include "SelectionKeyHandler.h" -#include "KeyAutoBinder.h" #include "Sim/Units/UnitDef.h" #include "Sim/Units/UnitDefHandler.h" #include "System/FileSystem/FileHandler.h" #include "System/FileSystem/SimpleParser.h" #include "System/Log/ILog.h" -#include "System/Log/DefaultFilter.h" #include "System/Util.h" +#include "System/Config/ConfigHandler.h" + + +#define LOG_SECTION_KEY_BINDINGS "KeyBindings" +LOG_REGISTER_SECTION_GLOBAL(LOG_SECTION_KEY_BINDINGS) +// use the specific section for all LOG*() calls in this source file #ifdef LOG_SECTION_CURRENT #undef LOG_SECTION_CURRENT #endif #define LOG_SECTION_CURRENT LOG_SECTION_KEY_BINDINGS +CONFIG(int, KeyChainTimeout).defaultValue(750).minimumValue(0).description("Timeout in milliseconds waiting for a key chain shortcut."); + + CKeyBindings* keyBindings = NULL; -static const struct DefaultBinding { +struct DefaultBinding { const char* key; const char* action; -} -defaultBindings[] = { - - { "esc", "quitmessage" }, - { "Shift+esc", "quitmenu" }, - { "Ctrl+Shift+esc", "quitforce" }, - { "Any+pause", "pause" }, - - { "c", "controlunit" }, - { "Any+h", "sharedialog" }, - { "Any+l", "togglelos" }, - { "Any+;", "toggleradarandjammer" }, +}; - { "Any+tab", "toggleoverview" }, +static const std::vector defaultBindings = { + { "esc", "quitmessage" }, + { "Shift+esc", "quitmenu" }, + { "Ctrl+Shift+esc", "quitforce" }, + { "Any+pause", "pause" }, + + { "c", "controlunit" }, + { "Any+h", "sharedialog" }, + { "Any+i", "gameinfo" }, { "Any+j", "mouse2" }, { "backspace", "mousestate" }, { "Shift+backspace", "togglecammode" }, - { "Ctrl+backspace", "togglecammode" }, - - { "Any+i", "gameinfo" }, + { "Ctrl+backspace", "togglecammode" }, + { "Any+tab", "toggleoverview" }, - { "Any+enter", "chat" }, - { "Ctrl+enter", "chatall" }, - { "Ctrl+enter", "chatswitchall" }, - { "Alt+enter", "chatally" }, - { "Alt+enter", "chatswitchally" }, - { "Shift+enter", "chatspec" }, - { "Shift+enter", "chatswitchspec" }, + { "Any+enter", "chat" }, + { "Ctrl+ctrl,Ctrl+ctrl", "chatswitchall" }, + { "Alt+alt,Alt+alt", "chatswitchally" }, + { "Shift+shift,Shift+shift", "chatswitchspec" }, { "Any+tab", "edit_complete" }, { "Any+backspace", "edit_backspace" }, @@ -83,9 +77,6 @@ { "Any+home", "increaseViewRadius" }, { "Any+end", "decreaseViewRadius" }, - { "Ctrl+insert", "hotbind" }, - { "Ctrl+delete", "hotunbind" }, - { "Alt+insert", "speedup" }, { "Alt+delete", "slowdown" }, { "Alt+=", "speedup" }, @@ -197,22 +188,31 @@ { "Any+f5", "HideInterface" }, { "Any+f6", "NoSound" }, { "Any+f7", "DynamicSky" }, + { "Any+l", "togglelos" }, + { "Any+;", "toggleradarandjammer" }, - { "Ctrl+Shift+f8", "savegame" }, - { "Any+f9", "showhealthbars" }, // MT only + { "Ctrl+Shift+f8", "savegame" }, { "Ctrl+Shift+f10", "createvideo" }, { "Any+f11", "screenshot" }, { "Any+f12", "screenshot" }, + { "Alt+enter", "fullscreen" }, // NOTE: Up bindings are currently converted to press bindings // (see KeySet.cpp / DISALLOW_RELEASE_BINDINGS) + { "Any+`,Any+`", "drawlabel" }, + { "Any+\\,Any+\\", "drawlabel" }, + { "Any+~,Any+~", "drawlabel" }, + { "Any+§,Any+§", "drawlabel" }, + { "Any+`", "drawinmap" }, { "Up+Any+`", "drawinmap" }, { "Any+\\", "drawinmap" }, { "Up+Any+\\", "drawinmap" }, - { "Any+0xa7", "drawinmap" }, - { "Up+Any+0xa7", "drawinmap" }, + { "Any+~", "drawinmap" }, + { "Up+Any+~", "drawinmap" }, + { "Any+§", "drawinmap" }, + { "Up+Any+§", "drawinmap" }, { "Any+up", "moveforward" }, { "Up+Any+up", "moveforward" }, @@ -232,7 +232,6 @@ { "Any+shift", "movefast" }, { "Up+Any+shift", "movefast" }, - // selection keys { "Ctrl+a", "select AllMap++_ClearSelection_SelectAll+" }, { "Ctrl+b", "select AllMap+_Builder_Idle+_ClearSelection_SelectOne+" }, @@ -250,12 +249,12 @@ // CKeyBindings // -CKeyBindings::CKeyBindings(): - fakeMetaKey(1), - userCommand(true), - debugEnabled(false) +CKeyBindings::CKeyBindings() + : fakeMetaKey(1) + , buildHotkeyMap(true) + , debugEnabled(false) + , keyChainTimeout(750) { - statefulCommands.insert("drawinmap"); statefulCommands.insert("moveforward"); statefulCommands.insert("moveback"); @@ -279,27 +278,27 @@ RegisterAction("keyprint"); RegisterAction("keysyms"); RegisterAction("keycodes"); + + configHandler->NotifyOnChange(this); } CKeyBindings::~CKeyBindings() { + configHandler->RemoveObserver(this); } /******************************************************************************/ -const CKeyBindings::ActionList& - CKeyBindings::GetActionList(const CKeySet& ks) const +const CKeyBindings::ActionList& CKeyBindings::GetActionList(const CKeySet& ks) const { static const ActionList empty; - const ActionList* alPtr = NULL; + const ActionList* alPtr = ∅ if (ks.AnyMod()) { KeyMap::const_iterator it = bindings.find(ks); - if (it == bindings.end()) { - alPtr = ∅ - } else { + if (it != bindings.end()) { alPtr = &(it->second); } } @@ -311,18 +310,15 @@ KeyMap::const_iterator ait = bindings.find(anyMod); const bool haveNormal = (nit != bindings.end()); const bool haveAnyMod = (ait != bindings.end()); - if (!haveNormal && !haveAnyMod) { - alPtr = ∅ - } - else if (haveNormal && !haveAnyMod) { + if (haveNormal && !haveAnyMod) { alPtr = &(nit->second); } else if (!haveNormal && haveAnyMod) { alPtr = &(ait->second); } - else { + else if (haveNormal && haveAnyMod) { // combine the two lists (normal first) - static ActionList merged; + static ActionList merged; //FIXME switch to thread_local when all buildbots are using >=gcc4.7 merged = nit->second; merged.insert(merged.end(), ait->second.begin(), ait->second.end()); alPtr = &merged; @@ -330,15 +326,14 @@ } if (debugEnabled) { - const bool isEmpty = (alPtr == &empty); - LOG("GetAction: %s (0x%03X)%s", - ks.GetString(false).c_str(), ks.Key(), - (isEmpty ? " EMPTY" : "")); - if (!isEmpty) { - const ActionList& al = *alPtr; - for (size_t i = 0; i < al.size(); ++i) { - LOG(" %s \"%s\" %s", al[i].command.c_str(), al[i].rawline.c_str(), al[i].boundWith.c_str()); + LOG("GetActions: hex=0x%02X acii=\"%s\":", ks.Key(), ks.GetString(false).c_str()); + if (alPtr != &empty) { + int i = 1; + for (const auto& a: *alPtr) { + LOG(" %i. action=\"%s\" rawline=\"%s\" shortcut=\"%s\"", i++, a.command.c_str(), a.rawline.c_str(), a.boundWith.c_str()); } + } else { + LOG(" EMPTY"); } } @@ -346,28 +341,80 @@ } -const CKeyBindings::HotkeyList& - CKeyBindings::GetHotkeys(const string& action) const +const CKeyBindings::ActionList& CKeyBindings::GetActionList(const CKeyChain& kc) const +{ + static ActionList out; //FIXME switch to thread_local when all buildbots are using >=gcc4.7 + out.clear(); + + if (kc.empty()) + return out; + + const CKeyBindings::ActionList& al = GetActionList(kc.back()); + for (const Action& action: al) { + if (kc.fit(action.keyChain)) + out.push_back(action); + } + return out; +} + + +const CKeyBindings::HotkeyList& CKeyBindings::GetHotkeys(const std::string& action) const { ActionMap::const_iterator it = hotkeys.find(action); if (it == hotkeys.end()) { static HotkeyList empty; return empty; } - const HotkeyList& hl = it->second; - return hl; + return it->second; } /******************************************************************************/ -bool CKeyBindings::Bind(const string& keystr, const string& line) +static bool ParseKeyChain_kernel(const std::string& keystr, CKeyChain* kc) { + kc->clear(); CKeySet ks; - if (!ParseKeySet(keystr, ks)) { - LOG_L(L_WARNING, "Bind: could not parse key: %s", keystr.c_str()); - return false; + std::stringstream ss(keystr); + while (ss.good()) { + char kcstr[256]; + ss.getline(kcstr, 256, ','); + std::string kstr(kcstr); + if (!ks.Parse(kstr, false)) { + return false; + } + kc->emplace_back(ks); } + return true; +} + + +static bool ParseKeyChain(std::string keystr, CKeyChain* kc, const size_t pos = std::string::npos) +{ + // recursive function to allow "," as seperator-char & as shortcut + // -> when parsing fails, this functions replaces one by one all "," by their hexcode + // and tries then to reparse it + // -> i.e. ",,," will at the end parsed as "0x2c,0x2c" + + const size_t cpos = keystr.rfind(',', pos); + + if (ParseKeyChain_kernel(keystr, kc)) + return true; + + if (cpos == std::string::npos) + return false; + + const size_t nextpos = (cpos > 0) ? cpos - 1 : std::string::npos; + if ((nextpos != std::string::npos) && ParseKeyChain(keystr, kc, nextpos)) + return true; + + keystr.replace(cpos, 1, IntToString(keyCodes->GetCode(","), "%#x")); + return ParseKeyChain(keystr, kc, cpos); +} + + +bool CKeyBindings::Bind(const std::string& keystr, const std::string& line) +{ Action action(line); action.boundWith = keystr; if (action.command.empty()) { @@ -375,6 +422,12 @@ return false; } + if (!ParseKeyChain(keystr, &action.keyChain) || action.keyChain.empty()) { + LOG_L(L_WARNING, "Bind: could not parse key: %s", keystr.c_str()); + return false; + } + CKeySet& ks = action.keyChain.back(); + // Try to be safe, force AnyMod mode for stateful commands if (statefulCommands.find(action.command) != statefulCommands.end()) { ks.SetAnyBit(); @@ -382,39 +435,35 @@ KeyMap::iterator it = bindings.find(ks); if (it == bindings.end()) { - // new entry, push it + // create new keyset entry and push it command ActionList& al = bindings[ks]; al.push_back(action); } else { - if (it->first != ks) { - // not a match, push it - ActionList& al = it->second; - al.push_back(action); - } - else { - // an exact keyset match, check the command - ActionList& al = it->second; - int i; - for (i = 0; i < (int)al.size(); i++) { - if (action.command == al[i].command) { - break; - } - } - if (i == (int)al.size()) { - // not a match, push it - al.push_back(action); + ActionList& al = it->second; + assert(it->first == ks); + + // check if the command is already found to the given keyset + bool found = false; + for (const Action& act: al) { + if (act.command == action.command) { + found = true; + break; } } + if (!found) { + // not yet bound, push it + al.push_back(action); + } } return true; } -bool CKeyBindings::UnBind(const string& keystr, const string& command) +bool CKeyBindings::UnBind(const std::string& keystr, const std::string& command) { CKeySet ks; - if (!ParseKeySet(keystr, ks)) { + if (!ks.Parse(keystr)) { LOG_L(L_WARNING, "UnBind: could not parse key: %s", keystr.c_str()); return false; } @@ -432,10 +481,10 @@ } -bool CKeyBindings::UnBindKeyset(const string& keystr) +bool CKeyBindings::UnBindKeyset(const std::string& keystr) { CKeySet ks; - if (!ParseKeySet(keystr, ks)) { + if (!ks.Parse(keystr)) { LOG_L(L_WARNING, "UnBindKeyset: could not parse key: %s", keystr.c_str()); return false; } @@ -446,11 +495,12 @@ bindings.erase(it); success = true; } + return success; } -bool CKeyBindings::UnBindAction(const string& command) +bool CKeyBindings::UnBindAction(const std::string& command) { bool success = false; @@ -461,10 +511,7 @@ success = true; } if (al.empty()) { - KeyMap::iterator it_next = it; - ++it_next; - bindings.erase(it); - it = it_next; + it = bindings.erase(it); } else { ++it; } @@ -473,7 +520,7 @@ } -bool CKeyBindings::SetFakeMetaKey(const string& keystr) +bool CKeyBindings::SetFakeMetaKey(const std::string& keystr) { CKeySet ks; if (StringToLower(keystr) == "none") { @@ -488,7 +535,8 @@ return true; } -bool CKeyBindings::AddKeySymbol(const string& keysym, const string& code) + +bool CKeyBindings::AddKeySymbol(const std::string& keysym, const std::string& code) { CKeySet ks; if (!ks.Parse(code)) { @@ -503,53 +551,27 @@ } -bool CKeyBindings::AddNamedKeySet(const string& name, const string& keystr) -{ - CKeySet ks; - if (!ks.Parse(keystr)) { - LOG_L(L_WARNING, "AddNamedKeySet: could not parse keyset: %s", keystr.c_str()); - return false; - } - if ((ks.Key() < 0) || !CKeyCodes::IsValidLabel(name)) { - LOG_L(L_WARNING, "AddNamedKeySet: bad custom keyset name: %s", name.c_str()); - return false; - } - namedKeySets[name] = ks; - return true; -} - - -bool CKeyBindings::RemoveCommandFromList(ActionList& al, const string& command) +bool CKeyBindings::RemoveCommandFromList(ActionList& al, const std::string& command) { bool success = false; - for (int i = 0; i < (int)al.size(); ++i) { - if (al[i].command == command) { + ActionList::iterator it = al.begin(); + while (it != al.end()) { + if (it->command == command) { + it = al.erase(it); success = true; - for (int j = (i + 1); j < (int)al.size(); ++j) { - al[j - 1] = al[j]; - } - al.resize(al.size() - 1); + } else { + ++it; } } return success; } -bool CKeyBindings::ParseKeySet(const string& keystr, CKeySet& ks) const +void CKeyBindings::ConfigNotify(const std::string& key, const std::string& value) { - if (keystr[0] != NamedKeySetChar) { - return ks.Parse(keystr); - } - else { - const string keysetName = keystr.substr(1); - NamedKeySetMap::const_iterator it = namedKeySets.find(keysetName); - if (it != namedKeySets.end()) { - ks = it->second; - } else { - return false; - } + if (key == "KeyChainTimeout") { + keyChainTimeout = atoi(value.c_str()); } - return true; } @@ -558,9 +580,8 @@ void CKeyBindings::LoadDefaults() { SetFakeMetaKey("space"); - const int count = sizeof(defaultBindings) / sizeof(defaultBindings[0]); - for (int i = 0; i < count; ++i) { - Bind(defaultBindings[i].key, defaultBindings[i].action); + for (const auto& b: defaultBindings) { + Bind(b.key, b.action); } } @@ -585,24 +606,24 @@ Print(); } else if (action.command == "keysyms") { - keyCodes->PrintNameToCode(); // move to CKeyCodes? + keyCodes->PrintNameToCode(); //TODO move to CKeyCodes? } else if (action.command == "keycodes") { - keyCodes->PrintCodeToName(); // move to CKeyCodes? + keyCodes->PrintCodeToName(); //TODO move to CKeyCodes? } else { ExecuteCommand(action.rawline); } } -bool CKeyBindings::ExecuteCommand(const string& line) +bool CKeyBindings::ExecuteCommand(const std::string& line) { - const vector words = CSimpleParser::Tokenize(line, 2); + const std::vector words = CSimpleParser::Tokenize(line, 2); if (words.empty()) { return false; } - const string command = StringToLower(words[0]); + const std::string command = StringToLower(words[0]); if (command == "keydebug") { if (words.size() == 1) { @@ -616,9 +637,6 @@ else if ((command == "fakemeta") && (words.size() > 1)) { if (!SetFakeMetaKey(words[1])) { return false; } } - else if ((command == "keyset") && (words.size() > 2)) { - if (!AddNamedKeySet(words[1], words[2])) { return false; } - } else if ((command == "keysym") && (words.size() > 2)) { if (!AddKeySymbol(words[1], words[2])) { return false; } } @@ -637,134 +655,47 @@ else if (command == "unbindall") { bindings.clear(); keyCodes->Reset(); - namedKeySets.clear(); - typeBindings.clear(); Bind("enter", "chat"); // bare minimum } else { return false; } - if (userCommand) { - Sanitize(); + if (buildHotkeyMap) { + BuildHotkeyMap(); } return false; } -bool CKeyBindings::Load(const string& filename) +bool CKeyBindings::Load(const std::string& filename) { -// inComment = false; CFileHandler ifs(filename); CSimpleParser parser(ifs); - - userCommand = false; // temporarily disable Sanitize() calls - + buildHotkeyMap = false; // temporarily disable BuildHotkeyMap() calls LoadDefaults(); - while (true) { - const string line = parser.GetCleanLine(); - if (line.empty()) { - break; - } - if (!ExecuteCommand(line)) { - ParseTypeBind(parser, line); - } - } - - Sanitize(); - - userCommand = true; // re-enable Sanitize() calls - - return true; -} - - -bool CKeyBindings::ParseTypeBind(CSimpleParser& parser, const string& line) -{ - BuildTypeBinding btb; - - const vector words = parser.Tokenize(line, 2); - if ((words.size() == 3) && - (words[2] == "{") && (StringToLower(words[0]) == "bindbuildtype")) { - btb.keystr = words[1]; - } else { - return false; + while (!parser.Eof()) { + const std::string line = parser.GetCleanLine(); + ExecuteCommand(line); } - while (true) { - const string line = parser.GetCleanLine(); - if (line.empty()) { - return false; - } - - const vector words = parser.Tokenize(line, 1); - if ((words.size() == 1) && (words[0] == "}")) { - break; - } - - const string command = StringToLower(words[0]); - - if ((command == "req") || (command == "require")) { - if (words.size() > 1) { - btb.reqs.push_back(words[1]); - } - } - else if (command == "sort") { - if (words.size() > 1) { - btb.sorts.push_back(words[1]); - } - } - else if (command == "chords") { - // split them up, tack them on (in order) - const vector chords = parser.Tokenize(line, 0); - for (int i = 1; i < (int)chords.size(); i++) { - btb.chords.push_back(chords[i]); - } - } - } - - typeBindings.push_back(btb); - - CKeyAutoBinder autoBinder; - if (!autoBinder.BindBuildType(btb.keystr, - btb.reqs, btb.sorts, btb.chords)) { - return false; - } - - return true; -} - - -void CKeyBindings::Sanitize() -{ - // FIXME -- do something extra here? - // (seems as though removing the Up states fixed most of the problems) BuildHotkeyMap(); + buildHotkeyMap = true; // re-enable BuildHotkeyMap() calls + return true; } void CKeyBindings::BuildHotkeyMap() { + // create reverse map of bindings ([action] -> key shortcuts) hotkeys.clear(); - KeyMap::const_iterator kit; - for (kit = bindings.begin(); kit != bindings.end(); ++kit) { - const CKeySet ks = kit->first; - const string keystr = ks.GetString(true); - const ActionList& al = kit->second; - for (int i = 0; i < (int)al.size(); ++i) { - HotkeyList& hl = hotkeys[al[i].command + ((al[i].extra == "") ? "" : " " + al[i].extra)]; - int j; - for (j = 0; j < (int)hl.size(); ++j) { - if (hl[j] == keystr) { - break; - } - } - if (j == (int)hl.size()) { - hl.push_back(keystr); - } + for (const auto& p: bindings) { + for (const Action& action: p.second) { + HotkeyList& hl = hotkeys[action.command + ((action.extra == "") ? "" : " " + action.extra)]; + hl.insert(action.boundWith); } } } @@ -778,7 +709,7 @@ } -bool CKeyBindings::Save(const string& filename) const +bool CKeyBindings::Save(const std::string& filename) const { FILE* out = fopen(filename.c_str(), "wt"); if (out == NULL) { @@ -786,9 +717,7 @@ } const bool success = FileSave(out); - fclose(out); - return success; } @@ -813,25 +742,13 @@ fprintf(out, "fakemeta %s\n\n", keyCodes->GetName(fakeMetaKey).c_str()); } - // save the named keysets - NamedKeySetMap::const_iterator ks_it; - for (ks_it = namedKeySets.begin(); ks_it != namedKeySets.end(); ++ks_it) { - fprintf(out, "keyset %-15s %s\n", - ks_it->first.c_str(), ks_it->second.GetString(false).c_str()); - } - if (!namedKeySets.empty()) { - fprintf(out, "\n"); - } - // save the bindings - KeyMap::const_iterator it; - for (it = bindings.begin(); it != bindings.end(); ++it) { - const ActionList& al = it->second; - for (int i = 0; i < (int)al.size(); ++i) { - const Action& action = al[i]; - string comment; + for (const auto& p: bindings) { + const ActionList& al = p.second; + for (const Action& action: al) { + std::string comment; if (unitDefHandler && (action.command.find("buildunit_") == 0)) { - const string unitName = action.command.substr(10); + const std::string unitName = action.command.substr(10); const UnitDef* unitDef = unitDefHandler->GetUnitDefByName(unitName); if (unitDef) { comment = " // " + unitDef->humanName + " - " + unitDef->tooltip; @@ -839,12 +756,12 @@ } if (comment.empty()) { fprintf(out, "bind %18s %s\n", - action.boundWith.c_str(), - action.rawline.c_str()); + action.boundWith.c_str(), + action.rawline.c_str()); } else { fprintf(out, "bind %18s %-20s%s\n", - action.boundWith.c_str(), - action.rawline.c_str(), comment.c_str()); + action.boundWith.c_str(), + action.rawline.c_str(), comment.c_str()); } } } diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/KeyBindings.h spring-98.0~14.04~ppa6/rts/Game/UI/KeyBindings.h --- spring-96.0~14.04~ppa4/rts/Game/UI/KeyBindings.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/KeyBindings.h 2014-10-07 20:09:51.000000000 +0000 @@ -3,7 +3,6 @@ #ifndef KEYBINDINGS_H #define KEYBINDINGS_H -#include #include #include #include @@ -13,13 +12,15 @@ #include "Game/Console.h" #include "Game/Action.h" -class CUnit; -class CSimpleParser; class CKeyBindings : public CommandReceiver { public: + typedef std::vector ActionList; + typedef std::set HotkeyList; + + public: CKeyBindings(); ~CKeyBindings(); @@ -27,10 +28,8 @@ bool Save(const std::string& filename) const; void Print() const; - typedef std::vector ActionList; - typedef std::vector HotkeyList; - const ActionList& GetActionList(const CKeySet& ks) const; + const ActionList& GetActionList(const CKeyChain& kc) const; const HotkeyList& GetHotkeys(const std::string& action) const; virtual void PushAction(const Action&); @@ -38,12 +37,13 @@ int GetFakeMetaKey() const { return fakeMetaKey; } - public: - static const char NamedKeySetChar = '&'; + // Receive configuration notifications (for KeyChainTimeout) + void ConfigNotify(const std::string& key, const std::string& value); + + int GetKeyChainTimeout() const { return keyChainTimeout; } protected: void LoadDefaults(); - void Sanitize(); void BuildHotkeyMap(); bool Bind(const std::string& keystring, const std::string& action); @@ -52,39 +52,25 @@ bool UnBindAction(const std::string& action); bool SetFakeMetaKey(const std::string& keystring); bool AddKeySymbol(const std::string& keysym, const std::string& code); - bool AddNamedKeySet(const std::string& name, const std::string& keyset); - bool ParseTypeBind(CSimpleParser& parser, const std::string& line); - bool ParseKeySet(const std::string& keystr, CKeySet& ks) const; - bool RemoveCommandFromList(ActionList& al, const std::string& command); + static bool RemoveCommandFromList(ActionList& al, const std::string& command); bool FileSave(FILE* file) const; protected: typedef std::map KeyMap; // keyset to action - KeyMap bindings; - typedef std::map ActionMap; // action to keyset + KeyMap bindings; ActionMap hotkeys; - typedef std::map NamedKeySetMap; // user defined keysets - NamedKeySetMap namedKeySets; - - struct BuildTypeBinding { - std::string keystr; // principal keyset - std::vector reqs; // requirements - std::vector sorts; // sorting criteria - std::vector chords; // enumerated keyset chords - }; - std::vector typeBindings; - // commands that use both Up and Down key presses std::set statefulCommands; int fakeMetaKey; - bool userCommand; + bool buildHotkeyMap; private: bool debugEnabled; + int keyChainTimeout; }; diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/KeyBindingsLog.h spring-98.0~14.04~ppa6/rts/Game/UI/KeyBindingsLog.h --- spring-96.0~14.04~ppa4/rts/Game/UI/KeyBindingsLog.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/KeyBindingsLog.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#ifndef _KEY_BINDINGS_LOG_H_ -#define _KEY_BINDINGS_LOG_H_ - -#define LOG_SECTION_KEY_BINDINGS "KeyBindings" - -// use the specific section for all LOG*() calls in this source file -/* -#ifdef LOG_SECTION_CURRENT - #undef LOG_SECTION_CURRENT -#endif -#define LOG_SECTION_CURRENT LOG_SECTION_KEY_BINDINGS -*/ - -#include "System/Log/ILog.h" - -LOG_REGISTER_SECTION_GLOBAL(LOG_SECTION_KEY_BINDINGS) - -#endif // _KEY_BINDINGS_LOG_H_ diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/KeyCodes.cpp spring-98.0~14.04~ppa6/rts/Game/UI/KeyCodes.cpp --- spring-96.0~14.04~ppa4/rts/Game/UI/KeyCodes.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/KeyCodes.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -4,7 +4,7 @@ #include "KeyCodes.h" -#include "SDL_keysym.h" +#include "SDL_keycode.h" #include "System/Log/ILog.h" #include "System/Util.h" @@ -14,7 +14,7 @@ int CKeyCodes::GetCode(const std::string& name) const { - std::map::const_iterator it = nameToCode.find(name); + const auto it = nameToCode.find(name); if (it == nameToCode.end()) { return -1; } @@ -24,7 +24,7 @@ std::string CKeyCodes::GetName(int code) const { - std::map::const_iterator it = codeToName.find(code); + const auto it = codeToName.find(code); if (it == codeToName.end()) { char buf[64]; SNPRINTF(buf, sizeof(buf), "0x%03X", code); @@ -36,7 +36,7 @@ std::string CKeyCodes::GetDefaultName(int code) const { - std::map::const_iterator it = defaultCodeToName.find(code); + const auto it = defaultCodeToName.find(code); if (it == defaultCodeToName.end()) { char buf[64]; SNPRINTF(buf, sizeof(buf), "0x%03X", code); @@ -51,11 +51,11 @@ if ((code < 0) || !IsValidLabel(name)) { return false; } - + const std::string keysym = StringToLower(name); // do not allow existing keysyms to be renamed - std::map::const_iterator name_it = nameToCode.find(keysym); + const auto name_it = nameToCode.find(keysym); if (name_it != nameToCode.end()) { return false; } @@ -85,20 +85,31 @@ } -bool CKeyCodes::IsModifier(int code) const +bool CKeyCodes::IsModifier(int code) { switch (code) { case SDLK_LALT: case SDLK_LCTRL: - case SDLK_LMETA: + case SDLK_LGUI: case SDLK_LSHIFT: + case SDLK_RALT: + case SDLK_RCTRL: + case SDLK_RGUI: + case SDLK_RSHIFT: return true; } return false; } -void CKeyCodes::AddPair(const std::string& name, int code) +bool CKeyCodes::IsPrintable(int code) +{ + return (printableCodes.find(code) != printableCodes.end()); +} + + + +void CKeyCodes::AddPair(const std::string& name, const int code, const bool printable) { if (nameToCode.find(name) == nameToCode.end()) { nameToCode[name] = code; @@ -106,6 +117,8 @@ if (codeToName.find(code) == codeToName.end()) { codeToName[code] = name; } + if (printable) + printableCodes.insert(code); } @@ -123,40 +136,43 @@ AddPair("backspace", SDLK_BACKSPACE); AddPair("tab", SDLK_TAB); AddPair("clear", SDLK_CLEAR); - AddPair("enter", SDLK_RETURN); + AddPair("enter", SDLK_RETURN); //FIXME AddPair("return", SDLK_RETURN); AddPair("pause", SDLK_PAUSE); AddPair("esc", SDLK_ESCAPE); AddPair("escape", SDLK_ESCAPE); - AddPair("space", SDLK_SPACE); + AddPair("space", SDLK_SPACE, true); AddPair("delete", SDLK_DELETE); // ASCII mapped keysyms - for (unsigned char i = ' '; i <= '~'; ++i) { + for (unsigned char i = ' '; i <= 'z'; ++i) { if (!isupper(i)) { - AddPair(std::string(1, i), i); + AddPair(std::string(1, i), i, true); } } - nameToCode["\xA7"] = 220; + AddPair("§", 0xA7, true); + AddPair("~", SDLK_BACKQUOTE, true); + AddPair("tilde", SDLK_BACKQUOTE, true); + AddPair("backquote", SDLK_BACKQUOTE, true); /* Numeric keypad */ - AddPair("numpad0", SDLK_KP0); - AddPair("numpad1", SDLK_KP1); - AddPair("numpad2", SDLK_KP2); - AddPair("numpad3", SDLK_KP3); - AddPair("numpad4", SDLK_KP4); - AddPair("numpad5", SDLK_KP5); - AddPair("numpad6", SDLK_KP6); - AddPair("numpad7", SDLK_KP7); - AddPair("numpad8", SDLK_KP8); - AddPair("numpad9", SDLK_KP9); - AddPair("numpad.", SDLK_KP_PERIOD); - AddPair("numpad/", SDLK_KP_DIVIDE); - AddPair("numpad*", SDLK_KP_MULTIPLY); - AddPair("numpad-", SDLK_KP_MINUS); - AddPair("numpad+", SDLK_KP_PLUS); - AddPair("numpad=", SDLK_KP_EQUALS); + AddPair("numpad0", SDLK_KP_0, true); + AddPair("numpad1", SDLK_KP_1, true); + AddPair("numpad2", SDLK_KP_2, true); + AddPair("numpad3", SDLK_KP_3, true); + AddPair("numpad4", SDLK_KP_4, true); + AddPair("numpad5", SDLK_KP_5, true); + AddPair("numpad6", SDLK_KP_6, true); + AddPair("numpad7", SDLK_KP_7, true); + AddPair("numpad8", SDLK_KP_8, true); + AddPair("numpad9", SDLK_KP_9, true); + AddPair("numpad.", SDLK_KP_PERIOD, true); + AddPair("numpad/", SDLK_KP_DIVIDE, true); + AddPair("numpad*", SDLK_KP_MULTIPLY, true); + AddPair("numpad-", SDLK_KP_MINUS, true); + AddPair("numpad+", SDLK_KP_PLUS, true); + AddPair("numpad=", SDLK_KP_EQUALS, true); AddPair("numpad_enter", SDLK_KP_ENTER); /* Arrows + Home/End pad */ @@ -194,29 +210,25 @@ AddPair("shift", SDLK_LSHIFT); AddPair("ctrl", SDLK_LCTRL); AddPair("alt", SDLK_LALT); - AddPair("meta", SDLK_LMETA); + AddPair("meta", SDLK_LGUI); // I doubt these can be used correctly anyway (without special support in other parts of the spring code...) //AddPair("super", SDLK_LSUPER); /* Left "Windows" key */ //AddPair("mode", SDLK_MODE); /* "Alt Gr" key */ //AddPair("compose", SDLK_COMPOSE); /* Multi-key compose key */ /* Miscellaneous function keys */ - //AddPair("help", SDLK_HELP); - AddPair("printscreen", SDLK_PRINT); + AddPair("help", SDLK_HELP); + AddPair("printscreen", SDLK_PRINTSCREEN); + AddPair("print", SDLK_PRINTSCREEN); //AddPair("sysreq", SDLK_SYSREQ); //AddPair("break", SDLK_BREAK); //AddPair("menu", SDLK_MENU); - // These conflict with "joy*" nameToCode. //AddPair("power", SDLK_POWER); /* Power Macintosh power key */ //AddPair("euro", SDLK_EURO); /* Some european keyboards */ //AddPair("undo", SDLK_UNDO); /* Atari keyboard has Undo */ - // Are these required for someone?? - //AddPair("'<'", 226); - //AddPair("','", 188); - //AddPair("'.'", 190); - - AddPair("joyx", 400); + //XXX Do they work? > NO + /*AddPair("joyx", 400); AddPair("joyy", 401); AddPair("joyz", 402); AddPair("joyw", 403); @@ -231,28 +243,26 @@ AddPair("joyup", 320); AddPair("joydown", 321); AddPair("joyleft", 322); - AddPair("joyright", 323); + AddPair("joyright", 323);*/ - // remember our defaults - defaultNameToCode = nameToCode; - defaultCodeToName = codeToName; + // remember our defaults + defaultNameToCode = nameToCode; + defaultCodeToName = codeToName; } void CKeyCodes::PrintNameToCode() const { - std::map::const_iterator it; - for (it = nameToCode.begin(); it != nameToCode.end(); ++it) { - LOG("KEYNAME: %13s = 0x%03X", it->first.c_str(), it->second); + for (const auto& p: nameToCode) { + LOG("KEYNAME: %13s = 0x%03X", p.first.c_str(), p.second); } } void CKeyCodes::PrintCodeToName() const { - std::map::const_iterator it; - for (it = codeToName.begin(); it != codeToName.end(); ++it) { - LOG("KEYCODE: 0x%03X = '%s'", it->first, it->second.c_str()); + for (const auto& p: codeToName) { + LOG("KEYCODE: 0x%03X = '%s'", p.first, p.second.c_str()); } } @@ -260,14 +270,12 @@ void CKeyCodes::SaveUserKeySymbols(FILE* file) const { bool output = false; - std::map::const_iterator user_it; - for (user_it = nameToCode.begin(); user_it != nameToCode.end(); ++user_it) { - std::map::const_iterator def_it; - const std::string& keysym = user_it->first; - def_it = defaultNameToCode.find(keysym); + for (const auto& p: nameToCode) { + const std::string& keysym = p.first; + const auto def_it = defaultNameToCode.find(keysym); if (def_it == defaultNameToCode.end()) { // this keysym is not standard - const int code = user_it->second; + const int code = p.second; std::string name = GetDefaultName(code); if (name.empty()) { char buf[16]; diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/KeyCodes.h spring-98.0~14.04~ppa6/rts/Game/UI/KeyCodes.h --- spring-96.0~14.04~ppa4/rts/Game/UI/KeyCodes.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/KeyCodes.h 2014-10-07 20:09:51.000000000 +0000 @@ -6,6 +6,7 @@ #include #include #include +#include class CKeyCodes { public: @@ -19,7 +20,8 @@ bool AddKeySymbol(const std::string& name, int code); - bool IsModifier(int code) const; + static bool IsModifier(int code); + bool IsPrintable(int code); void PrintNameToCode() const; void PrintCodeToName() const; @@ -30,13 +32,14 @@ static bool IsValidLabel(const std::string& label); protected: - void AddPair(const std::string& name, int code); + void AddPair(const std::string& name, const int code, const bool printable = false); protected: std::map nameToCode; std::map codeToName; std::map defaultNameToCode; std::map defaultCodeToName; + std::set printableCodes; }; extern CKeyCodes* keyCodes; diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/KeySet.cpp spring-98.0~14.04~ppa6/rts/Game/UI/KeySet.cpp --- spring-96.0~14.04~ppa4/rts/Game/UI/KeySet.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/KeySet.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -3,14 +3,14 @@ #include "KeySet.h" #include "KeyCodes.h" +#include "KeyBindings.h" #include "System/Log/ILog.h" #include "System/Util.h" #include "System/Input/KeyInput.h" -#include -#include -#include +#include + #define DISALLOW_RELEASE_BINDINGS @@ -40,15 +40,21 @@ } +bool CKeySet::IsPureModifier() const +{ + return (CKeyCodes::IsModifier(Key()) || (Key() == keyBindings->GetFakeMetaKey())); +} + + CKeySet::CKeySet(int k, bool release) { key = k; modifiers = 0; - if (keyInput->IsKeyPressed(SDLK_LALT)) { modifiers |= KS_ALT; } - if (keyInput->IsKeyPressed(SDLK_LCTRL)) { modifiers |= KS_CTRL; } - if (keyInput->IsKeyPressed(SDLK_LMETA)) { modifiers |= KS_META; } - if (keyInput->IsKeyPressed(SDLK_LSHIFT)) { modifiers |= KS_SHIFT; } + if (KeyInput::GetKeyModState(KMOD_ALT)) { modifiers |= KS_ALT; } + if (KeyInput::GetKeyModState(KMOD_CTRL)) { modifiers |= KS_CTRL; } + if (KeyInput::GetKeyModState(KMOD_GUI)) { modifiers |= KS_META; } + if (KeyInput::GetKeyModState(KMOD_SHIFT)) { modifiers |= KS_SHIFT; } #ifndef DISALLOW_RELEASE_BINDINGS if (release) { modifiers |= KS_RELEASE; } @@ -89,7 +95,6 @@ return true; } if (s.find(abbr) == 0) { - s.erase(0, abbr.size()); return true; } @@ -97,7 +102,7 @@ } -bool CKeySet::Parse(const std::string& token) +bool CKeySet::Parse(const std::string& token, bool showerror) { Reset(); @@ -119,7 +124,13 @@ #ifdef DISALLOW_RELEASE_BINDINGS modifiers &= ~KS_RELEASE; #endif - + + if (s.empty()) { + Reset(); + if (showerror) LOG_L(L_ERROR, "KeySet: Missing key"); + return false; + } + // remove ''s, if present if ((s.size() >= 2) && (s[0] == '\'') && (s[s.size() - 1] == '\'')) { s = s.substr(1, s.size() - 2); @@ -131,22 +142,17 @@ key = strtol(start, &end, 16); if (end == start) { Reset(); - LOG_L(L_ERROR, "KeySet: Bad hex value: %s", s.c_str()); - return false; - } - if (key >= SDLK_LAST) { - Reset(); - LOG_L(L_ERROR, "KeySet: Hex value out of range: %s", s.c_str()); + if (showerror) LOG_L(L_ERROR, "KeySet: Bad hex value: %s", s.c_str()); return false; } } else { if ((keyCodes != NULL) && (key = keyCodes->GetCode(s)) < 0) { Reset(); - LOG_L(L_ERROR, "KeySet: Bad keysym: %s", s.c_str()); + if (showerror) LOG_L(L_ERROR, "KeySet: Bad keysym: %s", s.c_str()); return false; } } - + if (keyCodes != NULL && keyCodes->IsModifier(key)) { modifiers |= KS_ANYMOD; } @@ -157,3 +163,41 @@ return true; } + + +/******************************************************************************/ +// +// CTimedKeyChain +// + +void CTimedKeyChain::push_back(const int key, const spring_time t, const bool isRepeat) +{ + assert(keyBindings); + + // clear chain on timeout + const auto dropTime = t - spring_msecs(keyBindings->GetKeyChainTimeout()); + if (!empty() && times.back() < dropTime) { + clear(); + } + + CKeySet ks(key, false); + + // append repeating keystrokes only wjen they differ from the last + if (isRepeat && (!empty() && ks == back())) + return; + + // When you want to press c,alt+b you will press the c(down),c(up),alt(down),b(down) + // -> the chain will be: c,Alt+alt,Alt+b + // this should now match "c,alt+b", so we need to get rid of the redundant Alt+alt . + // Still we want to support "Alt+alt,Alt+alt" (double click alt), so only override e.g. the last in chain + // when the new keypress is _not_ a modifier. + if (!empty() && !ks.IsPureModifier() && back().IsPureModifier() && (back().Mod() == ks.Mod())) { + times.back() = t; + back() = ks; + return; + } + + // push new to front + CKeyChain::emplace_back(ks); + times.emplace_back(t); +} diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/KeySet.h spring-98.0~14.04~ppa6/rts/Game/UI/KeySet.h --- spring-96.0~14.04~ppa4/rts/Game/UI/KeySet.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/KeySet.h 2014-10-07 20:09:51.000000000 +0000 @@ -4,7 +4,9 @@ #define KEYSET_H #include -#include +#include +#include "System/Misc/SpringTime.h" + class CKeySet { public: @@ -14,7 +16,7 @@ void Reset(); void SetAnyBit(); void ClearModifiers(); - bool Parse(const std::string& token); + bool Parse(const std::string& token, bool showerror = true); std::string GetString(bool useDefaultKeysym) const; @@ -28,6 +30,7 @@ }; int Key() const { return key; } + unsigned char Mod() const { return modifiers; } bool Alt() const { return !!(modifiers & KS_ALT); } bool Ctrl() const { return !!(modifiers & KS_CTRL); } bool Meta() const { return !!(modifiers & KS_META); } @@ -35,6 +38,8 @@ bool AnyMod() const { return !!(modifiers & KS_ANYMOD); } bool Release() const { return !!(modifiers & KS_RELEASE); } + bool IsPureModifier() const; + bool operator<(const CKeySet& ks) const { if (key < ks.key) { return true; } @@ -44,6 +49,11 @@ return false; } + bool fit(const CKeySet& ks) const + { + return (key == ks.key) && ((modifiers == ks.modifiers) || AnyMod() || ks.AnyMod()); + } + bool operator==(const CKeySet& ks) const { return ((key == ks.key) && (modifiers == ks.modifiers)); @@ -63,4 +73,62 @@ }; +class CKeyChain : public std::deque +{ + public: + bool operator<(const CKeyChain& kc) const + { + if (size() < kc.size()) { return true; } + if (size() > kc.size()) { return false; } + if (empty()) { return false; } + return (back() < kc.back()); + } + + bool operator==(const CKeyChain& needle) const + { + if (size() != needle.size()) + return false; + + return std::equal(needle.rbegin(), needle.rend(), rbegin()); + } + + bool fit(const CKeyChain& needle) const + { + // Scans the chain (*this) for a needle from the _back_ + // e.g. chain=a,b,c,d will fit needle=b,c,d but won't fit needle=a,b,c! + + if (size() < needle.size()) + return false; + + return std::equal(needle.rbegin(), needle.rend(), rbegin(), [](const CKeySet& a, const CKeySet& b) { return b.fit(a); }); + } + + std::string GetString() const + { + std::string s; + for (const CKeySet& ks: *this) { + if (!s.empty()) s += ","; + s += ks.GetString(true); + } + return s; + } +}; + + +class CTimedKeyChain : public CKeyChain +{ + public: + std::deque times; + + void clear() + { + CKeyChain::clear(); + times.clear(); + } + + void push_back(const int key, const spring_time t, const bool isRepeat); + void emplace_back(const CKeySet& ks, const spring_time t) { assert(false); } +}; + + #endif /* KEYSET_H */ diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/MiniMap.cpp spring-98.0~14.04~ppa6/rts/Game/UI/MiniMap.cpp --- spring-96.0~14.04~ppa4/rts/Game/UI/MiniMap.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/MiniMap.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,6 +1,6 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ -#include +#include #include #include "lib/gml/ThreadSafeContainers.h" @@ -22,7 +22,6 @@ #include "Game/Players/Player.h" #include "Game/UI/UnitTracker.h" #include "Sim/Misc/TeamHandler.h" -#include "Lua/LuaUI.h" // FIXME: for GML #include "Lua/LuaUnsyncedCtrl.h" #include "Map/BaseGroundDrawer.h" #include "Map/Ground.h" @@ -50,7 +49,7 @@ #include "System/TimeProfiler.h" #include "System/Input/KeyInput.h" #include "System/FileSystem/SimpleParser.h" -#include "System/Sound/SoundChannels.h" +#include "System/Sound/ISoundChannels.h" #include @@ -487,9 +486,7 @@ void CMiniMap::SelectUnits(int x, int y) const { - GML_RECMUTEX_LOCK(sel); //FIXME redundant? (selectedUnits already has mutexes) - - if (!keyInput->IsKeyPressed(SDLK_LSHIFT) && !keyInput->IsKeyPressed(SDLK_LCTRL)) { + if (!KeyInput::GetKeyModState(KMOD_SHIFT) && !KeyInput::GetKeyModState(KMOD_CTRL)) { selectedUnitsHandler.ClearSelected(); } @@ -620,7 +617,7 @@ } else { width = std::min(globalRendering->viewSizeX, width); } - if (keyInput->IsKeyPressed(SDLK_LSHIFT)) { + if (KeyInput::GetKeyModState(KMOD_SHIFT)) { width = (height * gs->mapx) / gs->mapy; } width = std::max(5, width); @@ -661,7 +658,7 @@ if (button == SDL_BUTTON_LEFT) { if (showButtons && maximizeBox.Inside(x, y)) { - ToggleMaximized(!!keyInput->GetKeyState(SDLK_LSHIFT)); + ToggleMaximized(!!KeyInput::GetKeyModState(KMOD_SHIFT)); return; } @@ -792,13 +789,9 @@ return buildTip; } - { - GML_THRMUTEX_LOCK(unit, GML_DRAW); // GetTooltip - - const CUnit* unit = GetSelectUnit(GetMapPosition(x, y)); - if (unit) { - return CTooltipConsole::MakeUnitString(unit); - } + const CUnit* unit = GetSelectUnit(GetMapPosition(x, y)); + if (unit) { + return CTooltipConsole::MakeUnitString(unit); } const string selTip = selectedUnitsHandler.GetTooltip(); @@ -829,7 +822,7 @@ /******************************************************************************/ -void CMiniMap::DrawCircle(const float3& pos, float radius) +void CMiniMap::DrawCircle(const float3& pos, float radius) const { glPushMatrix(); glTranslatef(pos.x, pos.y, pos.z); @@ -844,14 +837,13 @@ glPopMatrix(); } -void CMiniMap::DrawSquare(const float3& pos, float xsize, float zsize) +void CMiniMap::DrawSquare(const float3& pos, float xsize, float zsize) const { float verts[] = { pos.x + xsize, 0.0f, pos.z + zsize, pos.x - xsize, 0.0f, pos.z + zsize, pos.x - xsize, 0.0f, pos.z - zsize, pos.x + xsize, 0.0f, pos.z - zsize - }; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, verts); @@ -864,12 +856,25 @@ { minimap->DrawCircle(pos, radius); } + + void CMiniMap::DrawSurfaceSquare(const float3& pos, float xsize, float ysize) { minimap->DrawSquare(pos, xsize, ysize); } +void CMiniMap::ApplyConstraintsMatrix() const +{ + if (!renderToTexture) { + glTranslatef(xpos * globalRendering->pixelX, ypos * globalRendering->pixelY, 0.0f); + glScalef(width * globalRendering->pixelX, height * globalRendering->pixelY, 1.0f); + } +} + + +/******************************************************************************/ + void CMiniMap::Update() { if (minimized || width == 0 || height == 0) @@ -886,91 +891,11 @@ nextDrawScreen = spring_gettime() + spring_msecs(1000.0f / refreshRate); fbo.Bind(); - if (minimapTexSize != int2(width, height)) { - minimapTexSize = int2(width, height); - multisampledFBO = (fbo.GetMaxSamples() > 1); - - if (multisampledFBO) { - // multisampled FBO we are render to - fbo.Detach(GL_COLOR_ATTACHMENT0_EXT); // delete old RBO - fbo.CreateRenderBufferMultisample(GL_COLOR_ATTACHMENT0_EXT, GL_RGBA8, minimapTexSize.x, minimapTexSize.y, 4); - //fbo.CreateRenderBuffer(GL_DEPTH_ATTACHMENT_EXT, GL_DEPTH_COMPONENT16, minimapTexSize.x, minimapTexSize.y); - - if (!fbo.CheckStatus("MINIMAP")) { - fbo.Detach(GL_COLOR_ATTACHMENT0_EXT); - multisampledFBO = false; - } - } - - glDeleteTextures(1, &minimapTex); - glGenTextures(1, &minimapTex); - - glBindTexture(GL_TEXTURE_2D, minimapTex); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, minimapTexSize.x, minimapTexSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); - - if (multisampledFBO) { - // resolve FBO with attached final texture target - fboResolve.Bind(); - fboResolve.AttachTexture(minimapTex); - - if (!fboResolve.CheckStatus("MINIMAP-RESOLVE")) { - renderToTexture = false; - return; - } - } else { - // directly render to texture without multisampling (fallback solution) - fbo.Bind(); - fbo.AttachTexture(minimapTex); - - if (!fbo.CheckStatus("MINIMAP-RESOLVE")) { - renderToTexture = false; - return; - } - } - } + if (minimapTexSize != int2(width, height)) + ResizeTextureCache(); fbo.Bind(); - // draws minimap into FBO - { - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - gluOrtho2D(0,1,0,1); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - - const int2 oldPos(xpos, ypos); - xpos = 0.0f; - ypos = 0.0f; - - glViewport(0, 0, minimapTexSize.x, minimapTexSize.y); - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); - DrawForReal(false, true); - - xpos = oldPos.x; - ypos = oldPos.y; - - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - - // resolve multisampled FBO if there is one - if (multisampledFBO) { - glBindFramebufferEXT(GL_READ_FRAMEBUFFER, fbo.fboId); - glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, fboResolve.fboId); - glBlitFramebufferEXT( - 0, 0, minimapTexSize.x, minimapTexSize.y, - 0, 0, minimapTexSize.x, minimapTexSize.y, - GL_COLOR_BUFFER_BIT, GL_NEAREST); - } - } + UpdateTextureCache(); // no need, gets done in CGame //fbo.Unbind(); @@ -979,91 +904,144 @@ } -void CMiniMap::Draw() +void CMiniMap::ResizeTextureCache() { - if (!slaveDrawMode) { - { - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glPushAttrib(GL_DEPTH_BUFFER_BIT); - glDisable(GL_DEPTH_TEST); - glDepthFunc(GL_LEQUAL); - glDepthMask(GL_FALSE); - glDisable(GL_TEXTURE_2D); - glMatrixMode(GL_MODELVIEW); - - if (minimized) { - DrawMinimizedButton(); - glPopAttrib(); - glEnable(GL_TEXTURE_2D); - return; - } + minimapTexSize = int2(width, height); + multisampledFBO = (fbo.GetMaxSamples() > 1); - // draw the frameborder - if (!globalRendering->dualScreenMode && !maximized) { - DrawFrame(); - } + if (multisampledFBO) { + // multisampled FBO we are render to + fbo.Detach(GL_COLOR_ATTACHMENT0_EXT); // delete old RBO + fbo.CreateRenderBufferMultisample(GL_COLOR_ATTACHMENT0_EXT, GL_RGBA8, minimapTexSize.x, minimapTexSize.y, 4); + //fbo.CreateRenderBuffer(GL_DEPTH_ATTACHMENT_EXT, GL_DEPTH_COMPONENT16, minimapTexSize.x, minimapTexSize.y); + + if (!fbo.CheckStatus("MINIMAP")) { + fbo.Detach(GL_COLOR_ATTACHMENT0_EXT); + multisampledFBO = false; + } + } - glPopAttrib(); + glDeleteTextures(1, &minimapTex); + glGenTextures(1, &minimapTex); + + glBindTexture(GL_TEXTURE_2D, minimapTex); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, minimapTexSize.x, minimapTexSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); + + if (multisampledFBO) { + // resolve FBO with attached final texture target + fboResolve.Bind(); + fboResolve.AttachTexture(minimapTex); + + if (!fboResolve.CheckStatus("MINIMAP-RESOLVE")) { + renderToTexture = false; + return; } + } else { + // directly render to texture without multisampling (fallback solution) + fbo.Bind(); + fbo.AttachTexture(minimapTex); - DrawForReal(true); + if (!fbo.CheckStatus("MINIMAP-RESOLVE")) { + renderToTexture = false; + return; + } } } -void CMiniMap::ApplyConstraintsMatrix() const +void CMiniMap::UpdateTextureCache() { - if (!renderToTexture) { - glTranslatef(xpos * globalRendering->pixelX, ypos * globalRendering->pixelY, 0.0f); - glScalef(width * globalRendering->pixelX, height * globalRendering->pixelY, 1.0f); + // draws minimap into FBO + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + gluOrtho2D(0,1,0,1); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + + const int2 oldPos(xpos, ypos); + xpos = 0.0f; + ypos = 0.0f; + + glViewport(0, 0, minimapTexSize.x, minimapTexSize.y); + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + DrawForReal(false, true); + + xpos = oldPos.x; + ypos = oldPos.y; + + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + + // resolve multisampled FBO if there is one + if (multisampledFBO) { + glBindFramebufferEXT(GL_READ_FRAMEBUFFER, fbo.fboId); + glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, fboResolve.fboId); + glBlitFramebufferEXT( + 0, 0, minimapTexSize.x, minimapTexSize.y, + 0, 0, minimapTexSize.x, minimapTexSize.y, + GL_COLOR_BUFFER_BIT, GL_NEAREST); } } -void CMiniMap::DrawForReal(bool use_geo, bool updateTex) -{ - SCOPED_TIMER("MiniMap::DrawForReal"); +/******************************************************************************/ - if (minimized) +void CMiniMap::Draw() +{ + if (slaveDrawMode) return; - glActiveTexture(GL_TEXTURE0); + // Draw Border + { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glPushAttrib(GL_DEPTH_BUFFER_BIT); + glDisable(GL_DEPTH_TEST); + glDepthFunc(GL_LEQUAL); + glDepthMask(GL_FALSE); + glDisable(GL_TEXTURE_2D); + glMatrixMode(GL_MODELVIEW); - // Render `cached` minimap - if (renderToTexture && !updateTex) { - glPushAttrib(GL_COLOR_BUFFER_BIT); - glBindTexture(GL_TEXTURE_2D, minimapTex); - glEnable(GL_TEXTURE_2D); - glDisable(GL_BLEND); + if (minimized) { + DrawMinimizedButton(); + glPopAttrib(); + glEnable(GL_TEXTURE_2D); + return; + } - if (use_geo) { - glPushMatrix(); - glTranslatef(xpos * globalRendering->pixelX, ypos * globalRendering->pixelY, 0.0f); - glScalef(width * globalRendering->pixelX, height * globalRendering->pixelY, 1.0f); + // draw the frameborder + if (!globalRendering->dualScreenMode && !maximized) { + DrawFrame(); } - glColor4f(1,1,1,1); - glBegin(GL_QUADS); - glTexCoord2f(0.0, 0.0); glVertex2f(0.0f, 0.0f); - glTexCoord2f(1.0, 0.0); glVertex2f(1.0f, 0.0f); - glTexCoord2f(1.0, 1.0); glVertex2f(1.0f, 1.0f); - glTexCoord2f(0.0, 1.0); glVertex2f(0.0f, 1.0f); - glEnd(); + glPopAttrib(); + } - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + // Draw Minimap itself + DrawForReal(true); +} - DrawCameraFrustumAndMouseSelection(); - if (use_geo) - glPopMatrix(); +void CMiniMap::DrawForReal(bool use_geo, bool updateTex) +{ + SCOPED_TIMER("MiniMap::DrawForReal"); - glDisable(GL_TEXTURE_2D); - glColor4f(1,1,1,1); - glPopAttrib(); + if (minimized) + return; + + glActiveTexture(GL_TEXTURE0); + + if ((!updateTex) && RenderCachedTexture(use_geo)) return; - } glPushAttrib(GL_DEPTH_BUFFER_BIT); glEnable(GL_BLEND); @@ -1091,182 +1069,43 @@ setSurfaceSquareFunc(DrawSurfaceSquare); cursorIcons.Enable(false); - glColor4f(0.6f, 0.6f, 0.6f, 1.0f); - - // don't mirror the map texture with flipped cameras - glMatrixMode(GL_TEXTURE); - glPushMatrix(); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - - // draw the map - glDisable(GL_ALPHA_TEST); - glDisable(GL_BLEND); - readMap->DrawMinimap(); - glEnable(GL_BLEND); - - glMatrixMode(GL_TEXTURE); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - // clip everything outside of the minimap box - { - const double plane0[4] = {0,-1,0,1}; - const double plane1[4] = {0,1,0,0}; - const double plane2[4] = {-1,0,0,1}; - const double plane3[4] = {1,0,0,0}; - - glClipPlane(GL_CLIP_PLANE0, plane0); // clip bottom - glClipPlane(GL_CLIP_PLANE1, plane1); // clip top - glClipPlane(GL_CLIP_PLANE2, plane2); // clip right - glClipPlane(GL_CLIP_PLANE3, plane3); // clip left + SetClipPlanes(false); + glEnable(GL_CLIP_PLANE0); + glEnable(GL_CLIP_PLANE1); + glEnable(GL_CLIP_PLANE2); + glEnable(GL_CLIP_PLANE3); + + DrawBackground(); + + // allow the LUA scripts to overdraw the background image + SetClipPlanes(true); + eventHandler.DrawInMiniMapBackground(); + SetClipPlanes(false); - glEnable(GL_CLIP_PLANE0); - glEnable(GL_CLIP_PLANE1); - glEnable(GL_CLIP_PLANE2); - glEnable(GL_CLIP_PLANE3); - } + DrawUnitIcons(); + DrawWorldStuff(); - // switch to top-down map/world coords (z is twisted with y compared to the real map/world coords) - glPushMatrix(); - glTranslatef(0.0f, +1.0f, 0.0f); - glScalef(+1.0f / (gs->mapx * SQUARE_SIZE), -1.0f / (gs->mapy * SQUARE_SIZE), 1.0f); - - glEnable(GL_TEXTURE_2D); - glEnable(GL_ALPHA_TEST); - glAlphaFunc(GL_GREATER, 0.0f); - - { - GML_RECMUTEX_LOCK(unit); // DrawForReal - unitDrawer->DrawUnitMiniMapIcons(); - } - - glDisable(GL_ALPHA_TEST); - glDisable(GL_TEXTURE_2D); - - glPushMatrix(); - glRotatef(-90.0f, +1.0f, 0.0f, 0.0f); // real 'world' coordinates - glScalef(1.0f, 0.0f, 1.0f); // skip the y-coord (Lua's DrawScreen is perspective and so any z-coord in it influence the x&y, too) - - // draw the projectiles - if (drawProjectiles) { - glPointSize(1.0f); - WorkaroundATIPointSizeBug(); - projectileDrawer->DrawProjectilesMiniMap(); - } - - // draw the queued commands - // - // NOTE: this needlessly adds to the CursorIcons list, but at least - // they are not drawn (because the input receivers are drawn - // after the command queues) - - LuaUnsyncedCtrl::DrawUnitCommandQueues(); - if ((drawCommands > 0) && guihandler->GetQueueKeystate()) { - selectedUnitsHandler.DrawCommands(); - } - - glLineWidth(2.5f); - lineDrawer.DrawAll(); - glLineWidth(1.0f); - - // draw the selection shape, and some ranges - if (drawCommands > 0) { - guihandler->DrawMapStuff(!!drawCommands); - } - - { - GML_RECMUTEX_LOCK(sel); // DrawForReal - - // draw unit ranges - const float radarSquare = radarHandler->radarDiv; - CUnitSet& selUnits = selectedUnitsHandler.selectedUnits; - for(CUnitSet::iterator si = selUnits.begin(); si != selUnits.end(); ++si) { - CUnit* unit = *si; - if (unit->radarRadius && !unit->beingBuilt && unit->activated) { - glColor3fv(cmdColors.rangeRadar); - DrawCircle(unit->pos, (unit->radarRadius * radarSquare)); - } - if (unit->sonarRadius && !unit->beingBuilt && unit->activated) { - glColor3fv(cmdColors.rangeSonar); - DrawCircle(unit->pos, (unit->sonarRadius * radarSquare)); - } - if (unit->jammerRadius && !unit->beingBuilt && unit->activated) { - glColor3fv(cmdColors.rangeJammer); - DrawCircle(unit->pos, (unit->jammerRadius * radarSquare)); - } - // change if someone someday create a non stockpiled interceptor - const CWeapon* w = unit->stockpileWeapon; - if((w != NULL) && w->weaponDef->interceptor) { - if (w->numStockpiled) { - glColor3fv(cmdColors.rangeInterceptorOn); - } else { - glColor3fv(cmdColors.rangeInterceptorOff); - } - DrawCircle(unit->pos, w->weaponDef->coverageRange); - } - } - } - - glPopMatrix(); // revert to the 2d xform - - glMatrixMode(GL_MODELVIEW); if (use_geo) { glPopMatrix(); } - glPopMatrix(); glPopAttrib(); glEnable(GL_TEXTURE_2D); - { - // prepare ClipPlanes for Lua's DrawInMinimap Modelview matrix - - // quote from glClipPlane spec: - // "When glClipPlane is called, equation is transformed by the inverse of the modelview matrix and stored in the resulting eye coordinates. - // Subsequent changes to the modelview matrix have no effect on the stored plane-equation components." - // -> we have to use the same modelview matrix when calling glClipPlane and later draw calls - - // set the modelview matrix to the same as used in Lua's DrawInMinimap - glPushMatrix(); - glLoadIdentity(); - glScalef(1.0f / width, 1.0f / height, 1.0f); - - const double plane0[4] = {0, -1, 0, double(height)}; - const double plane1[4] = {0, 1, 0, 0}; - const double plane2[4] = {-1, 0, 0, double(width)}; - const double plane3[4] = {1, 0, 0, 0}; - - glClipPlane(GL_CLIP_PLANE0, plane0); // clip bottom - glClipPlane(GL_CLIP_PLANE1, plane1); // clip top - glClipPlane(GL_CLIP_PLANE2, plane2); // clip right - glClipPlane(GL_CLIP_PLANE3, plane3); // clip left - - glPopMatrix(); - } - - glMatrixMode(GL_TEXTURE); { - glPushMatrix(); - } - glMatrixMode(GL_PROJECTION); { - glPushMatrix(); - } - glMatrixMode(GL_MODELVIEW); { - glPushMatrix(); - } - // allow the LUA scripts to draw into the minimap + SetClipPlanes(true); eventHandler.DrawInMiniMap(); - glMatrixMode(GL_TEXTURE); { - glPopMatrix(); - } - glMatrixMode(GL_PROJECTION); { - glPopMatrix(); - } - glMatrixMode(GL_MODELVIEW); { + if (!updateTex) { + glPushMatrix(); + glTranslatef(xpos * globalRendering->pixelX, ypos * globalRendering->pixelY, 0.0f); + glScalef(width * globalRendering->pixelX, height * globalRendering->pixelY, 1.0f); + DrawCameraFrustumAndMouseSelection(); glPopMatrix(); } + // Finish + // Reset of GL state if (use_geo && globalRendering->dualScreenMode) glViewport(globalRendering->viewPosX,0,globalRendering->viewSizeX,globalRendering->viewSizeY); @@ -1279,41 +1118,25 @@ cursorIcons.Enable(true); setSurfaceCircleFunc(NULL); setSurfaceSquareFunc(NULL); - - if (!updateTex) { - glPushMatrix(); - glTranslatef(xpos * globalRendering->pixelX, ypos * globalRendering->pixelY, 0.0f); - glScalef(width * globalRendering->pixelX, height * globalRendering->pixelY, 1.0f); - DrawCameraFrustumAndMouseSelection(); - glPopMatrix(); - } } +/******************************************************************************/ +/******************************************************************************/ + void CMiniMap::DrawCameraFrustumAndMouseSelection() { glDisable(GL_TEXTURE_2D); - glPushMatrix(); // clip everything outside of the minimap box - { - const double plane0[4] = {0,-1,0,1}; - const double plane1[4] = {0,1,0,0}; - const double plane2[4] = {-1,0,0,1}; - const double plane3[4] = {1,0,0,0}; - - glClipPlane(GL_CLIP_PLANE0, plane0); // clip bottom - glClipPlane(GL_CLIP_PLANE1, plane1); // clip top - glClipPlane(GL_CLIP_PLANE2, plane2); // clip right - glClipPlane(GL_CLIP_PLANE3, plane3); // clip left - - glEnable(GL_CLIP_PLANE0); - glEnable(GL_CLIP_PLANE1); - glEnable(GL_CLIP_PLANE2); - glEnable(GL_CLIP_PLANE3); - } + SetClipPlanes(false); + glEnable(GL_CLIP_PLANE0); + glEnable(GL_CLIP_PLANE1); + glEnable(GL_CLIP_PLANE2); + glEnable(GL_CLIP_PLANE3); // switch to top-down map/world coords (z is twisted with y compared to the real map/world coords) + glPushMatrix(); glTranslatef(0.0f, +1.0f, 0.0f); glScalef(+1.0f / (gs->mapx * SQUARE_SIZE), -1.0f / (gs->mapy * SQUARE_SIZE), 1.0f); @@ -1323,16 +1146,15 @@ cam2->ClipFrustumLines(true, -10000.0f, 400096.0f); const std::vector negSides = cam2->GetNegFrustumSides(); - std::vector::const_iterator fli; CVertexArray* va = GetVertexArray(); va->Initialize(); va->EnlargeArrays(negSides.size() * 2, 0, VA_SIZE_2D0); - for (fli = negSides.begin(); fli != negSides.end(); ++fli) { - if (fli->minz < fli->maxz) { - va->AddVertex2dQ0(fli->base + (fli->dir * fli->minz), fli->minz); - va->AddVertex2dQ0(fli->base + (fli->dir * fli->maxz), fli->maxz); + for (auto& fl: negSides) { + if (fl.minz < fl.maxz) { + va->AddVertexQ2d0((fl.dir * fl.minz) + fl.base, fl.minz); + va->AddVertexQ2d0((fl.dir * fl.maxz) + fl.base, fl.maxz); } } @@ -1361,10 +1183,10 @@ CVertexArray* va = GetVertexArray(); va->Initialize(); va->EnlargeArrays(4, 0, VA_SIZE_2D0); - va->AddVertex2dQ0(oldPos.x, oldPos.z); - va->AddVertex2dQ0(newPos.x, oldPos.z); - va->AddVertex2dQ0(newPos.x, newPos.z); - va->AddVertex2dQ0(oldPos.x, newPos.z); + va->AddVertexQ2d0(oldPos.x, oldPos.z); + va->AddVertexQ2d0(newPos.x, oldPos.z); + va->AddVertexQ2d0(newPos.x, newPos.z); + va->AddVertexQ2d0(oldPos.x, newPos.z); va->DrawArray2d0(GL_LINE_LOOP); glLineWidth(1.0f); @@ -1563,6 +1385,8 @@ ni = notes.erase(ni); continue; } + + const SColor color(ni->color[0], ni->color[1], ni->color[2], ni->color[3]); for (int a = 0; a < 3; ++a) { const float modage = age + a * 0.1f; const float rot = modage * 3; @@ -1578,8 +1402,6 @@ } const float sinSize = fastmath::sin(rot) * size; const float cosSize = fastmath::cos(rot) * size; - - const SColor color(ni->color[0], ni->color[1], ni->color[2], ni->color[3]); va->AddVertexC(float3(ni->pos.x + sinSize, ni->pos.z + cosSize, 0.0f),color); va->AddVertexC(float3(ni->pos.x + cosSize, ni->pos.z - sinSize, 0.0f),color); va->AddVertexC(float3(ni->pos.x + cosSize, ni->pos.z - sinSize, 0.0f),color); @@ -1595,4 +1417,208 @@ } + +bool CMiniMap::RenderCachedTexture(bool use_geo) +{ + if (!renderToTexture) { + return false; + } + + glPushAttrib(GL_COLOR_BUFFER_BIT); + glBindTexture(GL_TEXTURE_2D, minimapTex); + glEnable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + + if (use_geo) { + glPushMatrix(); + glTranslatef(xpos * globalRendering->pixelX, ypos * globalRendering->pixelY, 0.0f); + glScalef(width * globalRendering->pixelX, height * globalRendering->pixelY, 1.0f); + } + + glColor4f(1,1,1,1); + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); glVertex2f(0.0f, 0.0f); + glTexCoord2f(1.0, 0.0); glVertex2f(1.0f, 0.0f); + glTexCoord2f(1.0, 1.0); glVertex2f(1.0f, 1.0f); + glTexCoord2f(0.0, 1.0); glVertex2f(0.0f, 1.0f); + glEnd(); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + DrawCameraFrustumAndMouseSelection(); + + if (use_geo) + glPopMatrix(); + + glDisable(GL_TEXTURE_2D); + glColor4f(1,1,1,1); + glPopAttrib(); + return true; +} + + +void CMiniMap::DrawBackground() const +{ + glColor4f(0.6f, 0.6f, 0.6f, 1.0f); + //glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + + // don't mirror the map texture with flipped cameras + glMatrixMode(GL_TEXTURE); + glPushMatrix(); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + + // draw the map + glDisable(GL_ALPHA_TEST); + glDisable(GL_BLEND); + readMap->DrawMinimap(); + glEnable(GL_BLEND); + + glMatrixMode(GL_TEXTURE); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); +} + + +void CMiniMap::DrawUnitIcons() const +{ + // switch to top-down map/world coords (z is twisted with y compared to the real map/world coords) + glPushMatrix(); + glTranslatef(0.0f, +1.0f, 0.0f); + glScalef(+1.0f / (gs->mapx * SQUARE_SIZE), -1.0f / (gs->mapy * SQUARE_SIZE), 1.0f); + + glEnable(GL_TEXTURE_2D); + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GREATER, 0.0f); + + unitDrawer->DrawUnitMiniMapIcons(); + + glDisable(GL_ALPHA_TEST); + glDisable(GL_TEXTURE_2D); + + glPopMatrix(); +} + + +void CMiniMap::DrawUnitRanges() const +{ + // draw unit ranges + const float radarSquare = radarHandler->radarDiv; + CUnitSet& selUnits = selectedUnitsHandler.selectedUnits; + for(const CUnit* unit: selUnits) { + // LOS Ranges + if (unit->radarRadius && !unit->beingBuilt && unit->activated) { + glColor3fv(cmdColors.rangeRadar); + DrawCircle(unit->pos, (unit->radarRadius * radarSquare)); + } + if (unit->sonarRadius && !unit->beingBuilt && unit->activated) { + glColor3fv(cmdColors.rangeSonar); + DrawCircle(unit->pos, (unit->sonarRadius * radarSquare)); + } + if (unit->jammerRadius && !unit->beingBuilt && unit->activated) { + glColor3fv(cmdColors.rangeJammer); + DrawCircle(unit->pos, (unit->jammerRadius * radarSquare)); + } + + // Interceptor Ranges + for (const CWeapon* w: unit->weapons) { + auto& wd = *w->weaponDef; + if ((w->range > 300) && wd.interceptor) { + if (w->numStockpiled || !wd.stockpile) { + glColor3fv(cmdColors.rangeInterceptorOn); + } else { + glColor3fv(cmdColors.rangeInterceptorOff); + } + DrawCircle(unit->pos, wd.coverageRange); + } + } + } +} + + +void CMiniMap::DrawWorldStuff() const +{ + glPushMatrix(); + glTranslatef(0.0f, +1.0f, 0.0f); + glScalef(+1.0f / (gs->mapx * SQUARE_SIZE), -1.0f / (gs->mapy * SQUARE_SIZE), 1.0f); + glRotatef(-90.0f, +1.0f, 0.0f, 0.0f); // real 'world' coordinates + glScalef(1.0f, 0.0f, 1.0f); // skip the y-coord (Lua's DrawScreen is perspective and so any z-coord in it influence the x&y, too) + + // draw the projectiles + if (drawProjectiles) { + glPointSize(1.0f); + WorkaroundATIPointSizeBug(); + projectileDrawer->DrawProjectilesMiniMap(); + } + + // draw the queued commands + // + // NOTE: this needlessly adds to the CursorIcons list, but at least + // they are not drawn (because the input receivers are drawn + // after the command queues) + LuaUnsyncedCtrl::DrawUnitCommandQueues(); + if ((drawCommands > 0) && guihandler->GetQueueKeystate()) { + selectedUnitsHandler.DrawCommands(); + } + + glLineWidth(2.5f); + lineDrawer.DrawAll(); + glLineWidth(1.0f); + + // draw the selection shape, and some ranges + if (drawCommands > 0) { + guihandler->DrawMapStuff(!!drawCommands); + } + + DrawUnitRanges(); + + glPopMatrix(); +} + + +void CMiniMap::SetClipPlanes(const bool lua) const +{ + if (lua) { + // prepare ClipPlanes for Lua's DrawInMinimap Modelview matrix + + // quote from glClipPlane spec: + // "When glClipPlane is called, equation is transformed by the inverse of the modelview matrix and stored in the resulting eye coordinates. + // Subsequent changes to the modelview matrix have no effect on the stored plane-equation components." + // -> we have to use the same modelview matrix when calling glClipPlane and later draw calls + + // set the modelview matrix to the same as used in Lua's DrawInMinimap + glPushMatrix(); + glLoadIdentity(); + glScalef(1.0f / width, 1.0f / height, 1.0f); + + const double plane0[4] = {0, -1, 0, double(height)}; + const double plane1[4] = {0, 1, 0, 0}; + const double plane2[4] = {-1, 0, 0, double(width)}; + const double plane3[4] = {1, 0, 0, 0}; + + glClipPlane(GL_CLIP_PLANE0, plane0); // clip bottom + glClipPlane(GL_CLIP_PLANE1, plane1); // clip top + glClipPlane(GL_CLIP_PLANE2, plane2); // clip right + glClipPlane(GL_CLIP_PLANE3, plane3); // clip left + + glPopMatrix(); + } else { + // clip everything outside of the minimap box + const double plane0[4] = {0,-1,0,1}; + const double plane1[4] = {0,1,0,0}; + const double plane2[4] = {-1,0,0,1}; + const double plane3[4] = {1,0,0,0}; + + glClipPlane(GL_CLIP_PLANE0, plane0); // clip bottom + glClipPlane(GL_CLIP_PLANE1, plane1); // clip top + glClipPlane(GL_CLIP_PLANE2, plane2); // clip right + glClipPlane(GL_CLIP_PLANE3, plane3); // clip left + } +} + + + /******************************************************************************/ diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/MiniMap.h spring-98.0~14.04~ppa6/rts/Game/UI/MiniMap.h --- spring-96.0~14.04~ppa4/rts/Game/UI/MiniMap.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/MiniMap.h 2014-10-07 20:09:51.000000000 +0000 @@ -81,17 +81,26 @@ void ProxyMousePress(int x, int y, int button); void ProxyMouseRelease(int x, int y, int button); + bool RenderCachedTexture(const bool use_geo); + void DrawBackground() const; + void DrawUnitIcons() const; + void DrawUnitRanges() const; + void DrawWorldStuff() const; + void DrawCameraFrustumAndMouseSelection(); + void SetClipPlanes(const bool lua) const; + void DrawFrame(); void DrawNotes(); void DrawButtons(); void DrawMinimizedButton(); void DrawUnitHighlight(const CUnit* unit); - void DrawCircle(const float3& pos, float radius); - void DrawSquare(const float3& pos, float xsize, float zsize); + void DrawCircle(const float3& pos, float radius) const; + void DrawSquare(const float3& pos, float xsize, float zsize) const; const icon::CIconData* GetUnitIcon(const CUnit* unit, float& scale) const; - void DrawCameraFrustumAndMouseSelection(); + void UpdateTextureCache(); + void ResizeTextureCache(); protected: static void DrawSurfaceCircle(const float3& pos, float radius, unsigned int resolution); diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/MouseHandler.cpp spring-98.0~14.04~ppa6/rts/Game/UI/MouseHandler.cpp --- spring-96.0~14.04~ppa4/rts/Game/UI/MouseHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/MouseHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -20,11 +20,10 @@ #include "Game/Players/PlayerHandler.h" #include "Game/UI/UnitTracker.h" #include "Lua/LuaInputReceiver.h" -#include "Lua/LuaUI.h" // FIXME: for GML #include "Map/Ground.h" #include "Map/MapDamage.h" #include "Rendering/GlobalRendering.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Rendering/GL/myGL.h" #include "Rendering/Textures/Bitmap.h" #include "Sim/Features/FeatureDef.h" @@ -50,7 +49,7 @@ // can't be up there since those contain conflicting definitions #include #include -#include +#include CONFIG(bool, HardwareCursor).defaultValue(false).description("Sets hardware mouse cursor rendering. If you have a low framerate, your mouse cursor will seem \"laggy\". Setting hardware cursor will render the mouse cursor separately from spring and the mouse will behave normally. Note, not all GPU drivers support it in fullscreen mode!"); @@ -133,6 +132,7 @@ CMouseHandler::~CMouseHandler() { + configHandler->RemoveObserver(this); if (hwHide) SDL_ShowCursor(SDL_ENABLE); @@ -342,11 +342,11 @@ */ void CMouseHandler::GetSelectionBoxCoeff(const float3& pos1, const float3& dir1, const float3& pos2, const float3& dir2, float2& topright, float2& btmleft) { - float dist = ground->LineGroundCol(pos1, pos1 + dir1 * globalRendering->viewRange * 1.4f, false); + float dist = CGround::LineGroundCol(pos1, pos1 + dir1 * globalRendering->viewRange * 1.4f, false); if(dist < 0) dist = globalRendering->viewRange * 1.4f; float3 gpos1 = pos1 + dir1 * dist; - dist = ground->LineGroundCol(pos2, pos2 + dir2 * globalRendering->viewRange * 1.4f, false); + dist = CGround::LineGroundCol(pos2, pos2 + dir2 * globalRendering->viewRange * 1.4f, false); if(dist < 0) dist = globalRendering->viewRange * 1.4f; float3 gpos2 = pos2 + dir2 * dist; @@ -393,8 +393,6 @@ return; } - GML_RECMUTEX_LOCK(sel); //FIXME redundant? (selectedUnits already has mutexes) - // Switch camera mode on a middle click that wasn't a middle mouse drag scroll. // the latter is determined by the time the mouse was held down: // switch (dragScrollThreshold) @@ -413,7 +411,7 @@ if ((button == SDL_BUTTON_LEFT) && !buttons[button].chorded) { ButtonPressEvt& bp = buttons[SDL_BUTTON_LEFT]; - if (!keyInput->IsKeyPressed(SDLK_LSHIFT) && !keyInput->IsKeyPressed(SDLK_LCTRL)) { + if (!KeyInput::GetKeyModState(KMOD_SHIFT) && !KeyInput::GetKeyModState(KMOD_CTRL)) { selectedUnitsHandler.ClearSelected(); } @@ -551,9 +549,6 @@ CFeature* feature; { - GML_THRMUTEX_LOCK(unit, GML_DRAW); // GetCurrentTooltip - GML_THRMUTEX_LOCK(feat, GML_DRAW); // GetCurrentTooltip - dist = TraceRay::GuiTraceRay(camera->GetPos(), dir, range, NULL, unit, feature, true, false, true); if (unit) return CTooltipConsole::MakeUnitString(unit); @@ -941,9 +936,11 @@ } } - for (it = cursorFileMap.begin(); it != cursorFileMap.end(); ++it) { + for (it = cursorFileMap.begin(); it != cursorFileMap.end(); ) { if (it->second == cursor) { it = set_erase(cursorFileMap, it); + } else { + ++it; } } diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/ProfileDrawer.cpp spring-98.0~14.04~ppa6/rts/Game/UI/ProfileDrawer.cpp --- spring-96.0~14.04~ppa4/rts/Game/UI/ProfileDrawer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/ProfileDrawer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,28 +1,64 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ #include +#include #include "ProfileDrawer.h" +#include "InputReceiver.h" +#include "Game/GlobalUnsynced.h" +#include "System/EventHandler.h" +#include "System/Rectangle.h" #include "System/ThreadPool.h" #include "System/TimeProfiler.h" #include "Rendering/GL/myGL.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Rendering/GlobalRendering.h" #include "Rendering/GL/VertexArray.h" #include "Sim/Misc/GlobalConstants.h" // for GAME_SPEED +#include "Sim/Misc/GlobalSynced.h" +#include "Sim/Path/IPathManager.h" +#include "Sim/Projectiles/ProjectileHandler.h" +#include "lib/lua/include/LuaUser.h" ProfileDrawer* ProfileDrawer::instance = NULL; +static const float start_x = 0.6f; +static const float end_x = 0.99f; +static const float start_y = 0.95f; +static const float lineHeight = 0.017f; + +static const auto DBG_FONT_FLAGS = (FONT_SCALE | FONT_NORM | FONT_SHADOW); + +typedef std::pair TimeSlice; +static std::deque vidFrames; +static std::deque simFrames; +static std::deque lgcFrames; +static std::deque swpFrames; +static std::deque uusFrames; + + +ProfileDrawer::ProfileDrawer() +: CEventClient("[ProfileDrawer]", 199991, false) +{ + autoLinkEvents = true; + RegisterLinkedEvents(this); + eventHandler.AddClient(this); +} + + +ProfileDrawer::~ProfileDrawer() +{ +} + + void ProfileDrawer::SetEnabled(bool enable) { if (enable) { assert(instance == NULL); instance = new ProfileDrawer(); - GML_STDMUTEX_LOCK_NOPROF(time); // SetEnabled // reset peak indicators each time the drawer is restarted - std::map::iterator pi; - for (pi = profiler.profile.begin(); pi != profiler.profile.end(); ++pi) - (*pi).second.peak = 0.0f; + for (auto& p: profiler.profile) + p.second.peak = 0.0f; } else { ProfileDrawer* tmpInstance = instance; instance = NULL; @@ -30,90 +66,272 @@ } } + bool ProfileDrawer::IsEnabled() { return (instance != NULL); } -static const float start_x = 0.6f; -static const float end_x = 0.99f; -static const float end_y = 0.99f; -static const float start_y = 0.965f; -void ProfileDrawer::Draw() + +static void DrawTimeSlice(std::deque& frames, const spring_time curTime, const spring_time maxHist, const float drawArea[4]) +{ + // remove old entries + while (!frames.empty() && (curTime - frames.front().second) > maxHist) { + frames.pop_front(); + } + + const float y1 = drawArea[1]; + const float y2 = drawArea[3]; + + // render + CVertexArray* va = GetVertexArray(); + va->Initialize(); + for (TimeSlice& ts: frames) { + float x1 = (ts.first % maxHist).toSecsf() / maxHist.toSecsf(); + float x2 = (ts.second % maxHist).toSecsf() / maxHist.toSecsf(); + x2 = std::max(x1 + globalRendering->pixelX, x2); + + x1 = drawArea[0] + x1 * (drawArea[2] - drawArea[0]); + x2 = drawArea[0] + x2 * (drawArea[2] - drawArea[0]); + + va->AddVertex0(x1, y1, 0.0f); + va->AddVertex0(x1, y2, 0.0f); + va->AddVertex0(x2, y2, 0.0f); + va->AddVertex0(x2, y1, 0.0f); + + const float mx1 = x1 + 3 * globalRendering->pixelX; + const float mx2 = x2 - 3 * globalRendering->pixelX; + if (mx1 < mx2) { + va->AddVertex0(mx1, y1 + 3 * globalRendering->pixelX, 0.0f); + va->AddVertex0(mx1, y2 - 3 * globalRendering->pixelX, 0.0f); + va->AddVertex0(mx2, y2 - 3 * globalRendering->pixelX, 0.0f); + va->AddVertex0(mx2, y1 + 3 * globalRendering->pixelX, 0.0f); + } + } + + va->DrawArray0(GL_QUADS); +} + + +static void DrawThreadBarcode() +{ + const float maxHist_f = 4.0f; + const spring_time curTime = spring_now(); + const spring_time maxHist = spring_secs(maxHist_f); + auto& coreProf = profiler.profileCore; + const auto numThreads = coreProf.size(); + + const float drawArea[4] = {0.01f, 0.30f, (start_x / 2), 0.35f}; + + // background + CVertexArray* va = GetVertexArray(); + va->Initialize(); + va->AddVertex0(drawArea[0] - 10 * globalRendering->pixelX, drawArea[1] - 10 * globalRendering->pixelY, 0.0f); + va->AddVertex0(drawArea[0] - 10 * globalRendering->pixelX, drawArea[3] + 10 * globalRendering->pixelY, 0.0f); + va->AddVertex0(drawArea[2] + 10 * globalRendering->pixelX, drawArea[3] + 10 * globalRendering->pixelY, 0.0f); + va->AddVertex0(drawArea[2] + 10 * globalRendering->pixelX, drawArea[1] - 10 * globalRendering->pixelY, 0.0f); + glColor4f(0.0f,0.0f,0.0f, 0.5f); + va->DrawArray0(GL_QUADS); + + // title + font->glFormat(drawArea[0], drawArea[3], 0.7f, FONT_TOP | DBG_FONT_FLAGS, "ThreadPool (%.0fsec)", maxHist_f); + + // bars + glColor4f(1.0f,0.0f,0.0f, 0.6f); + int i = 0; + for (auto& frames: coreProf) { + float drawArea2[4] = {drawArea[0], 0.f, drawArea[2], 0.f}; + drawArea2[1] = drawArea[1] + ((drawArea[3] - drawArea[1]) / numThreads) * i++; + drawArea2[3] = drawArea[1] + ((drawArea[3] - drawArea[1]) / numThreads) * i - 4 * globalRendering->pixelY; + DrawTimeSlice(frames, curTime, maxHist, drawArea2); + } + + // feeder + va = GetVertexArray(); + va->Initialize(); + const float r = (curTime % maxHist).toSecsf() / maxHist_f; + const float xf = drawArea[0] + r * (drawArea[2] - drawArea[0]); + va->AddVertex0(xf, drawArea[1], 0.0f); + va->AddVertex0(xf, drawArea[3], 0.0f); + va->AddVertex0(xf + 5 * globalRendering->pixelX, drawArea[3], 0.0f); + va->AddVertex0(xf + 5 * globalRendering->pixelX, drawArea[1], 0.0f); + glColor3f(1.0f,0.0f,0.0f); + va->DrawArray0(GL_QUADS); +} + + +static void DrawFrameBarcode() +{ + const float maxHist_f = 0.5f; + const spring_time curTime = spring_now(); + const spring_time maxHist = spring_secs(maxHist_f); + float drawArea[4] = {0.01f, 0.2f, start_x - 0.05f, 0.25f}; + + // background + CVertexArray* va = GetVertexArray(); + va->Initialize(); + va->AddVertex0(drawArea[0] - 10 * globalRendering->pixelX, drawArea[1] - 10 * globalRendering->pixelY, 0.0f); + va->AddVertex0(drawArea[0] - 10 * globalRendering->pixelX, drawArea[3] + 20 * globalRendering->pixelY, 0.0f); + va->AddVertex0(drawArea[2] + 10 * globalRendering->pixelX, drawArea[3] + 20 * globalRendering->pixelY, 0.0f); + va->AddVertex0(drawArea[2] + 10 * globalRendering->pixelX, drawArea[1] - 10 * globalRendering->pixelY, 0.0f); + glColor4f(0.0f,0.0f,0.0f, 0.5f); + va->DrawArray0(GL_QUADS); + + // title and legend + font->glFormat(drawArea[0], drawArea[3] + 10 * globalRendering->pixelY, 0.7f, FONT_TOP | DBG_FONT_FLAGS, + "Frame Grapher (%.2fsec)" + "\xff\xff\x80\xff GC" + "\xff\xff\xff\x01 Unsynced" + "\xff\x01\x01\xff Swap" + "\xff\x01\xff\x01 Video" + "\xff\xff\x01\x01 Sim" + , maxHist_f); + + // gc frames + glColor4f(1.0f,0.5f,1.0f, 0.55f); + DrawTimeSlice(lgcFrames, curTime, maxHist, drawArea); + + // updateunsynced frames + glColor4f(1.0f,1.0f,0.0f, 0.9f); + DrawTimeSlice(uusFrames, curTime, maxHist, drawArea); + + // video swap frames + glColor4f(0.0f,0.0f,1.0f, 0.55f); + DrawTimeSlice(swpFrames, curTime, maxHist, drawArea); + + // video frames + glColor4f(0.0f,1.0f,0.0f, 0.55f); + DrawTimeSlice(vidFrames, curTime, maxHist, drawArea); + + // sim frames + glColor4f(1.0f,0.0f,0.0f, 0.55f); + DrawTimeSlice(simFrames, curTime, maxHist, drawArea); + + // draw `feeder` indicating current time pos + va = GetVertexArray(); + va->Initialize(); + // draw feeder + const float r = (curTime % maxHist).toSecsf() / maxHist_f; + const float xf = drawArea[0] + r * (drawArea[2] - drawArea[0]); + va->AddVertex0(xf, drawArea[1], 0.0f); + va->AddVertex0(xf, drawArea[3], 0.0f); + va->AddVertex0(xf + 10 * globalRendering->pixelX, drawArea[3], 0.0f); + va->AddVertex0(xf + 10 * globalRendering->pixelX, drawArea[1], 0.0f); + + // draw scale (horizontal bar that indicates 30FPS timing length) + const float xs1 = drawArea[2] - 1.f/(30.f*maxHist_f) * (drawArea[2] - drawArea[0]); + const float xs2 = drawArea[2] + 0.0f * (drawArea[2] - drawArea[0]); + va->AddVertex0(xs1, drawArea[3] + 2 * globalRendering->pixelY, 0.0f); + va->AddVertex0(xs1, drawArea[3] + 10 * globalRendering->pixelY, 0.0f); + va->AddVertex0(xs2, drawArea[3] + 10 * globalRendering->pixelY, 0.0f); + va->AddVertex0(xs2, drawArea[3] + 2 * globalRendering->pixelY, 0.0f); + glColor4f(1.0f,0.0f,0.0f, 1.0f); + va->DrawArray0(GL_QUADS); +} + + +static void DrawProfiler() { - GML_STDMUTEX_LOCK_NOPROF(time); // Draw + font->SetTextColor(1,1,1,1); // draw the background of the window - glDisable(GL_TEXTURE_2D); - glColor4f(0.0f, 0.0f, 0.5f, 0.5f); - if(!profiler.profile.empty()){ - glBegin(GL_TRIANGLE_STRIP); - glVertex3f(start_x, end_y, 0); - glVertex3f(end_x, end_y, 0); - glVertex3f(start_x, end_y-profiler.profile.size()*0.024f-0.01f, 0); - glVertex3f(end_x, end_y-profiler.profile.size()*0.024f-0.01f, 0); - glEnd(); + { + CVertexArray* va = GetVertexArray(); + va->Initialize(); + va->AddVertex0(start_x, start_y + lineHeight + 0.005f, 0); + va->AddVertex0(end_x, start_y + lineHeight + 0.005f, 0); + va->AddVertex0(start_x, start_y - profiler.profile.size() * lineHeight - 0.01f, 0); + va->AddVertex0(end_x, start_y - profiler.profile.size() * lineHeight - 0.01f, 0); + glColor4f(0.0f, 0.0f, 0.5f, 0.5f); + va->DrawArray0(GL_TRIANGLE_STRIP); } - std::map::iterator pi; + const float textSize = 0.5f; - // draw the textual info (total-time, short-time percentual time, timer-name) - int y = 0; - font->Begin(); - for (pi = profiler.profile.begin(); pi != profiler.profile.end(); ++pi, ++y) { - const float fStartY = start_y - y * 0.024f; + // table header + { + const float fStartY = start_y + 0.005f; float fStartX = start_x + 0.005f + 0.015f + 0.005f; // print total-time running since application start fStartX += 0.04f; - font->glFormat(fStartX, fStartY, 0.7f, FONT_BASELINE | FONT_SCALE | FONT_NORM | FONT_RIGHT, "%.2fs", pi->second.total.toSecsf()); + font->glFormat(fStartX, fStartY, textSize, FONT_SHADOW | FONT_DESCENDER | FONT_SCALE | FONT_NORM | FONT_RIGHT, "totaltime"); // print percent of CPU time used within the last 500ms + fStartX += 0.06f; + font->glFormat(fStartX, fStartY, textSize, FONT_SHADOW | FONT_DESCENDER | FONT_SCALE | FONT_NORM | FONT_RIGHT, "cur-%%usage"); fStartX += 0.04f; - font->glFormat(fStartX, fStartY, 0.7f, FONT_BASELINE | FONT_SCALE | FONT_NORM | FONT_RIGHT, "%.2f%%", pi->second.percent * 100); + font->glFormat(fStartX, fStartY, textSize, FONT_SHADOW | FONT_DESCENDER | FONT_SCALE | FONT_NORM | FONT_RIGHT, "max-%%usage"); fStartX += 0.04f; - font->glFormat(fStartX, fStartY, 0.7f, FONT_BASELINE | FONT_SCALE | FONT_NORM | FONT_RIGHT, "\xff\xff%c%c%.2f%%", pi->second.newPeak?1:255, pi->second.newPeak?1:255, pi->second.peak * 100); + font->glFormat(fStartX, fStartY, textSize, FONT_SHADOW | FONT_DESCENDER | FONT_SCALE | FONT_NORM | FONT_RIGHT, "lag"); + + // print timer name + fStartX += 0.01f; + font->glFormat(fStartX, fStartY, textSize, FONT_SHADOW | FONT_DESCENDER | FONT_SCALE | FONT_NORM, "title"); + } + + // draw the textual info (total-time, short-time percentual time, timer-name) + int y = 1; + for (auto pi = profiler.profile.begin(); pi != profiler.profile.end(); ++pi, ++y) { + const auto& profileData = pi->second; + + const float fStartY = start_y - y * lineHeight; + float fStartX = start_x + 0.005f + 0.015f + 0.005f; + + // print total-time running since application start fStartX += 0.04f; - font->glFormat(fStartX, fStartY, 0.7f, FONT_BASELINE | FONT_SCALE | FONT_NORM | FONT_RIGHT, "\xff\xff%c%c%.0fms", pi->second.newLagPeak?1:255, pi->second.newLagPeak?1:255, pi->second.maxLag); + font->glFormat(fStartX, fStartY, textSize, FONT_DESCENDER | FONT_SCALE | FONT_NORM | FONT_RIGHT, "%.2fs", profileData.total.toSecsf()); + + // print percent of CPU time used within the last 500ms + fStartX += 0.06f; + font->glFormat(fStartX, fStartY, textSize, FONT_DESCENDER | FONT_SCALE | FONT_NORM | FONT_RIGHT, "%.2f%%", profileData.percent * 100); + fStartX += 0.04f; + font->glFormat(fStartX, fStartY, textSize, FONT_DESCENDER | FONT_SCALE | FONT_NORM | FONT_RIGHT, "\xff\xff%c%c%.2f%%", profileData.newPeak?1:255, profileData.newPeak?1:255, profileData.peak * 100); + fStartX += 0.04f; + font->glFormat(fStartX, fStartY, textSize, FONT_DESCENDER | FONT_SCALE | FONT_NORM | FONT_RIGHT, "\xff\xff%c%c%.0fms", profileData.newLagPeak?1:255, profileData.newLagPeak?1:255, profileData.maxLag); // print timer name fStartX += 0.01f; - font->glFormat(fStartX, fStartY, 0.7f, FONT_BASELINE | FONT_SCALE | FONT_NORM, pi->first); + font->glFormat(fStartX, fStartY, textSize, FONT_DESCENDER | FONT_SCALE | FONT_NORM, pi->first); } - font->End(); + // draw the Timer selection boxes + const float boxSize = lineHeight*0.9; + const float selOffset = boxSize*0.2; glPushMatrix(); - glTranslatef(start_x + 0.005f, start_y, 0); - glScalef(0.015f, 0.02f, 0.02f); - glBegin(GL_QUADS); - int i = 0; - for (pi = profiler.profile.begin(); pi != profiler.profile.end(); ++pi, ++i){ - glColorf3((float3)pi->second.color); - glVertex3f(0, 0 - i * 1.2f, 0); - glVertex3f(1, 0 - i * 1.2f, 0); - glVertex3f(1, 1 - i * 1.2f, 0); - glVertex3f(0, 1 - i * 1.2f, 0); - } - glEnd(); - // draw the 'graph view disabled' cross - glBegin(GL_LINES); - i = 0; - glColor3f(1,0,0); - for (pi = profiler.profile.begin(); pi != profiler.profile.end(); ++pi, ++i){ - if (!pi->second.showGraph) { - glVertex3f(0, 0 - i * 1.2f, 0); - glVertex3f(1, 1 - i * 1.2f, 0); - glVertex3f(1, 0 - i * 1.2f, 0); - glVertex3f(0, 1 - i * 1.2f, 0); + glTranslatef(start_x + 0.005f, start_y + boxSize, 0); // we are now at upper left of first box + CVertexArray* va = GetVertexArray(); + CVertexArray* va2 = GetVertexArray(); + va->Initialize(); + va2->Initialize(); + int i = 1; + for (auto pi = profiler.profile.begin(); pi != profiler.profile.end(); ++pi, ++i){ + auto& fc = pi->second.color; + SColor c(fc[0], fc[1], fc[2]); + va->AddVertexC(float3(0, -i*lineHeight, 0), c); // upper left + va->AddVertexC(float3(0, -i*lineHeight-boxSize, 0), c); // lower left + va->AddVertexC(float3(boxSize, -i*lineHeight-boxSize, 0), c); // lower right + va->AddVertexC(float3(boxSize, -i*lineHeight, 0), c); // upper right + + if (pi->second.showGraph) { + va2->AddVertex0(lineHeight+selOffset, -i*lineHeight-selOffset, 0); // upper left + va2->AddVertex0(lineHeight+selOffset, -i*lineHeight-boxSize+selOffset, 0); // lower left + va2->AddVertex0(lineHeight+boxSize-selOffset, -i*lineHeight-boxSize+selOffset, 0); // lower right + va2->AddVertex0(lineHeight+boxSize-selOffset, -i*lineHeight-selOffset, 0); // upper right } } - glEnd(); + // draw the boxes + va->DrawArrayC(GL_QUADS); + // draw the 'graph view disabled' cross + glColor3f(1,0,0); + va2->DrawArray0(GL_QUADS); glPopMatrix(); // draw the graph - for (pi = profiler.profile.begin(); pi != profiler.profile.end(); ++pi) { + glLineWidth(3.0f); + for (auto pi = profiler.profile.begin(); pi != profiler.profile.end(); ++pi) { if (!pi->second.showGraph) { continue; } @@ -127,78 +345,112 @@ const float p = pi->second.frames[a].toSecsf() * GAME_SPEED; const float x = start_x + (a * steps_x); const float y = 0.02f + (p * 0.96f); - va->AddVertex0(float3(x, y, 0.0f)); + va->AddVertex0(x, y, 0.0f); } + glColorf3((float3)pi->second.color); va->DrawArray0(GL_LINE_STRIP); } + glLineWidth(1.0f); +} -#ifdef DEBUG - const float maxHist = 4.0f; - const auto curTime = spring_gettime(); - const float r = std::fmod(curTime.toSecsf(), maxHist) / maxHist; +static void DrawInfoText() +{ + // background CVertexArray* va = GetVertexArray(); va->Initialize(); - auto& coreProf = profiler.profileCore; - for (int i = 0; i < coreProf.size(); ++i) { - if (coreProf[i].empty()) - continue; + va->AddVertex0(0.01f - 10 * globalRendering->pixelX, 0.02f - 10 * globalRendering->pixelY, 0.0f); + va->AddVertex0(0.01f - 10 * globalRendering->pixelX, 0.16f + 20 * globalRendering->pixelY, 0.0f); + va->AddVertex0(start_x - 0.05f + 10 * globalRendering->pixelX, 0.16f + 20 * globalRendering->pixelY, 0.0f); + va->AddVertex0(start_x - 0.05f + 10 * globalRendering->pixelX, 0.02f - 10 * globalRendering->pixelY, 0.0f); + glColor4f(0.0f,0.0f,0.0f, 0.5f); + va->DrawArray0(GL_QUADS); - const float y1 = 0.1f * i; - const float y2 = 0.1f * (i+1); + //print some infos (fps,gameframe,particles) + font->SetTextColor(1,1,0.5f,0.8f); - while (!coreProf[i].empty() && (curTime - coreProf[i].front().second) > spring_secs(maxHist)) - coreProf[i].pop_front(); + font->glFormat(0.01f, 0.02f, 1.0f, DBG_FONT_FLAGS, "FPS: %0.1f SimFPS: %0.1f SimFrame: %d Speed: %2.2f (%2.2f) Particles: %d (%d)", + globalRendering->FPS, gu->simFPS, gs->frameNum, gs->speedFactor, gs->wantedSpeedFactor, projectileHandler->syncedProjectiles.size() + projectileHandler->unsyncedProjectiles.size(), projectileHandler->currentParticles); - for (const auto& data: coreProf[i]) { - float x1 = std::fmod(data.first.toSecsf(), maxHist) / maxHist; - float x2 = std::fmod(data.second.toSecsf(), maxHist) / maxHist; - x2 = std::max(x1 + globalRendering->pixelX, x2); + // 16ms := 60fps := 30simFPS + 30drawFPS + font->glFormat(0.01f, 0.07f, 0.7f, DBG_FONT_FLAGS, "avgFrame: %s%2.1fms\b avgDrawFrame: %s%2.1fms\b avgSimFrame: %s%2.1fms\b", + (gu->avgFrameTime > 30) ? "\xff\xff\x01\x01" : "", gu->avgFrameTime, + (gu->avgDrawFrameTime > 16) ? "\xff\xff\x01\x01" : "", gu->avgDrawFrameTime, + (gu->avgSimFrameTime > 16) ? "\xff\xff\x01\x01" : "", gu->avgSimFrameTime + ); + + const int2 pfsUpdates = pathManager->GetNumQueuedUpdates(); + const char* fmtString = "[%s-PFS] queued updates: %i %i"; + + switch (pathManager->GetPathFinderType()) { + case PFS_TYPE_DEFAULT: { + font->glFormat(0.01f, 0.12f, 0.7f, DBG_FONT_FLAGS, fmtString, "DEFAULT", pfsUpdates.x, pfsUpdates.y); + } break; + case PFS_TYPE_QTPFS: { + font->glFormat(0.01f, 0.12f, 0.7f, DBG_FONT_FLAGS, fmtString, "QT", pfsUpdates.x, pfsUpdates.y); + } break; + } - va->AddVertex0(float3(x1, y1, 0.0f)); - va->AddVertex0(float3(x1, y2, 0.0f)); + SLuaInfo luaInfo = {0, 0, 0, 0}; + spring_lua_alloc_get_stats(&luaInfo); - va->AddVertex0(float3(x2, y2, 0.0f)); - va->AddVertex0(float3(x2, y1, 0.0f)); - } - } + font->glFormat( + 0.01f, 0.15f, 0.7f, DBG_FONT_FLAGS, + "Lua-allocated memory: %.1fMB (%.5uK allocs : %.5u usecs : %.1u states)", + luaInfo.allocedBytes / 1024.0f / 1024.0f, + luaInfo.numLuaAllocs / 1000, + luaInfo.luaAllocTime, + luaInfo.numLuaStates + ); +} - const float y1 = 0.0f; - const float y2 = 0.1f * (ThreadPool::GetNumThreads()); - va->AddVertex0(float3(r, y1, 0.0f)); - va->AddVertex0(float3(r, y2, 0.0f)); - va->AddVertex0(float3(r + 10 * globalRendering->pixelX, y2, 0.0f)); - va->AddVertex0(float3(r + 10 * globalRendering->pixelX, y1, 0.0f)); - glColor3f(1.0f,0.0f,0.0f); - va->DrawArray0(GL_QUADS); -#endif +void ProfileDrawer::DrawScreen() +{ + SCOPED_TIMER("ProfileDrawer"); + + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + gluOrtho2D(0,1,0,1); + + glDisable(GL_TEXTURE_2D); + font->Begin(); + font->SetTextColor(1,1,0.5f,0.8f); + + DrawThreadBarcode(); + DrawFrameBarcode(); + DrawProfiler(); + DrawInfoText(); + + font->End(); + glColor4f(1.0f,1.0f,1.0f,1.0f); glEnable(GL_TEXTURE_2D); + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); } bool ProfileDrawer::MousePress(int x, int y, int button) { - GML_STDMUTEX_LOCK_NOPROF(time); // MousePress - - const float mx = MouseX(x); - const float my = MouseY(y); - - // check if a Timer selection box was hit - if (mxend_x || myend_y) { + if (!IsAbove(x, y)) return false; - } - const int selIndex = (int) ((end_y - my) / 0.024f); + const float my = CInputReceiver::MouseY(y); + const int selIndex = (int) ((start_y - my) / lineHeight); // switch the selected Timers showGraph value if ((selIndex >= 0) && (selIndex < profiler.profile.size())) { - std::map::iterator pi = profiler.profile.begin(); - for (int i = 0; i < selIndex; i++) { - ++pi; - } + auto pi = profiler.profile.begin(); + std::advance(pi, selIndex); pi->second.showGraph = !pi->second.showGraph; + return true; } return false; @@ -206,23 +458,38 @@ bool ProfileDrawer::IsAbove(int x, int y) { - GML_STDMUTEX_LOCK_NOPROF(time); // IsAbove - - const float mx = MouseX(x); - const float my = MouseY(y); + const float mx = CInputReceiver::MouseX(x); + const float my = CInputReceiver::MouseY(y); // check if a Timer selection box was hit - if (mxend_x || myend_y) { + if (mxend_x || mystart_y) { return false; } return true; } -ProfileDrawer::ProfileDrawer() -{ -} -ProfileDrawer::~ProfileDrawer() +void ProfileDrawer::DbgTimingInfo(DbgTimingInfoType type, const spring_time start, const spring_time end) { + if (!IsEnabled()) + return; + + switch (type) { + case TIMING_VIDEO: { + vidFrames.emplace_back(start, end); + } break; + case TIMING_SIM: { + simFrames.emplace_back(start, end); + } break; + case TIMING_GC: { + lgcFrames.emplace_back(start, end); + } break; + case TIMING_SWAP: { + swpFrames.emplace_back(start, end); + } break; + case TIMING_UNSYNCED: { + uusFrames.emplace_back(start, end); + } break; + } } diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/ProfileDrawer.h spring-98.0~14.04~ppa6/rts/Game/UI/ProfileDrawer.h --- spring-96.0~14.04~ppa4/rts/Game/UI/ProfileDrawer.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/ProfileDrawer.h 2014-10-07 20:09:51.000000000 +0000 @@ -3,17 +3,23 @@ #ifndef PROFILE_DRAWER #define PROFILE_DRAWER -#include "InputReceiver.h" +#include "System/EventClient.h" -class ProfileDrawer : public CInputReceiver +class ProfileDrawer : public CEventClient { public: + // CEventClient interface + bool GetFullRead() const { return true; } + int GetReadAllyTeam() const { return AllAccessTeam; } + +public: static void SetEnabled(bool enable); static bool IsEnabled(); - virtual void Draw(); + virtual void DrawScreen(); virtual bool MousePress(int x, int y, int button); - virtual bool IsAbove(int x, int y); + virtual bool IsAbove(int x, int y); + virtual void DbgTimingInfo(DbgTimingInfoType type, const spring_time start, const spring_time end); private: ProfileDrawer(); diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/QuitBox.cpp spring-98.0~14.04~ppa6/rts/Game/UI/QuitBox.cpp --- spring-96.0~14.04~ppa4/rts/Game/UI/QuitBox.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/QuitBox.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ #include "Game/GlobalUnsynced.h" #include "Game/Players/Player.h" #include "Game/Players/PlayerHandler.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Rendering/GL/myGL.h" #include "Sim/Misc/GlobalSynced.h" #include "Sim/Misc/ModInfo.h" @@ -19,7 +19,7 @@ #include "System/LoadSave/LoadSaveHandler.h" #include "System/MsgStrings.h" -#include +#include #define MAX_QUIT_TEAMS (teamHandler->ActiveTeams() - 1) @@ -365,7 +365,7 @@ } -bool CQuitBox::KeyPressed(unsigned short key, bool isRepeat) +bool CQuitBox::KeyPressed(int key, bool isRepeat) { if (key == SDLK_ESCAPE) { delete this; diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/QuitBox.h spring-98.0~14.04~ppa6/rts/Game/UI/QuitBox.h --- spring-96.0~14.04~ppa4/rts/Game/UI/QuitBox.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/QuitBox.h 2014-10-07 20:09:51.000000000 +0000 @@ -21,7 +21,7 @@ bool MousePress(int x, int y, int button); void MouseRelease(int x,int y,int button); void MouseMove(int x, int y, int dx,int dy, int button); - bool KeyPressed(unsigned short key, bool isRepeat); + bool KeyPressed(int key, bool isRepeat); private: ContainerBox box; diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/ResourceBar.cpp spring-98.0~14.04~ppa6/rts/Game/UI/ResourceBar.cpp --- spring-96.0~14.04~ppa4/rts/Game/UI/ResourceBar.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/ResourceBar.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -6,7 +6,7 @@ #include "GuiHandler.h" #include "Game/GlobalUnsynced.h" #include "Rendering/GL/myGL.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Sim/Misc/TeamHandler.h" #include "Sim/Misc/GlobalSynced.h" #include "Net/Protocol/NetProtocol.h" @@ -58,7 +58,7 @@ } return c; -}; +} void CResourceBar::Draw() diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/SelectionKeyHandler.cpp spring-98.0~14.04~ppa6/rts/Game/UI/SelectionKeyHandler.cpp --- spring-96.0~14.04~ppa4/rts/Game/UI/SelectionKeyHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/SelectionKeyHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,7 +1,6 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ #include -#include #include "Game/Camera/CameraController.h" #include "Game/Camera.h" @@ -113,17 +112,17 @@ #define DECLARE_FILTER(name, condition) \ DECLARE_FILTER_EX(name, 0, condition, ,) - DECLARE_FILTER(Builder, unit->unitDef->buildSpeed > 0); - DECLARE_FILTER(Building, dynamic_cast(unit) != NULL); - DECLARE_FILTER(Transport, unit->unitDef->transportCapacity > 0); - DECLARE_FILTER(Aircraft, unit->unitDef->canfly); - DECLARE_FILTER(Weapons, !unit->weapons.empty()); - DECLARE_FILTER(Idle, unit->commandAI->commandQue.empty()); + DECLARE_FILTER(Builder, unit->unitDef->buildSpeed > 0) + DECLARE_FILTER(Building, dynamic_cast(unit) != NULL) + DECLARE_FILTER(Transport, unit->unitDef->transportCapacity > 0) + DECLARE_FILTER(Aircraft, unit->unitDef->canfly) + DECLARE_FILTER(Weapons, !unit->weapons.empty()) + DECLARE_FILTER(Idle, unit->commandAI->commandQue.empty()) DECLARE_FILTER(Waiting, !unit->commandAI->commandQue.empty() && - (unit->commandAI->commandQue.front().GetID() == CMD_WAIT)); - DECLARE_FILTER(InHotkeyGroup, unit->group != NULL); - DECLARE_FILTER(Radar, unit->radarRadius || unit->sonarRadius || unit->jammerRadius); - DECLARE_FILTER(ManualFireUnit, unit->unitDef->canManualFire); + (unit->commandAI->commandQue.front().GetID() == CMD_WAIT)) + DECLARE_FILTER(InHotkeyGroup, unit->group != NULL) + DECLARE_FILTER(Radar, unit->radarRadius || unit->sonarRadius || unit->jammerRadius) + DECLARE_FILTER(ManualFireUnit, unit->unitDef->canManualFire) DECLARE_FILTER_EX(WeaponRange, 1, unit->maxRange > minRange, float minRange; @@ -131,7 +130,7 @@ minRange = atof(value.c_str()); }, minRange=0.0f; - ); + ) DECLARE_FILTER_EX(AbsoluteHealth, 1, unit->health > minHealth, float minHealth; @@ -139,7 +138,7 @@ minHealth = atof(value.c_str()); }, minHealth=0.0f; - ); + ) DECLARE_FILTER_EX(RelativeHealth, 1, unit->health / unit->maxHealth > minHealth, float minHealth; @@ -147,7 +146,7 @@ minHealth = atof(value.c_str()) * 0.01f; // convert from percent }, minHealth=0.0f; - ); + ) DECLARE_FILTER_EX(InPrevSel, 0, prevTypes.find(unit->unitDef->id) != prevTypes.end(), std::set prevTypes; @@ -158,14 +157,14 @@ prevTypes.insert((*si)->unitDef->id); } }, - ); + ) DECLARE_FILTER_EX(NameContain, 1, unit->unitDef->humanName.find(name) != std::string::npos, std::string name; void SetParam(int index, const std::string& value) { name = value; }, - ); + ) DECLARE_FILTER_EX(Category, 1, unit->category == cat, unsigned int cat; @@ -173,7 +172,7 @@ cat = CCategoryHandler::Instance()->GetCategory(value); }, cat=0; - ); + ) //FIXME: std::strtof is in C99 which M$ doesn't bother to support. #ifdef _MSC_VER #define STRTOF strtod @@ -201,19 +200,17 @@ } }, wantedValue=0.0f; - ); + ) #undef DECLARE_FILTER_EX #undef DECLARE_FILTER #undef STRTOF -}; +} void CSelectionKeyHandler::DoSelection(std::string selectString) { - GML_RECMUTEX_LOCK(sel); // DoSelection - std::list selection; // guicontroller->AddText(selectString.c_str()); @@ -260,7 +257,7 @@ ReadDelimiter(selectString); float maxDist=atof(ReadToken(selectString).c_str()); - float dist = ground->LineGroundCol(camera->GetPos(), camera->GetPos() + mouse->dir * 8000, false); + float dist = CGround::LineGroundCol(camera->GetPos(), camera->GetPos() + mouse->dir * 8000, false); float3 mp=camera->GetPos()+mouse->dir*dist; if (cylindrical) { mp.y = 0; diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/ShareBox.cpp spring-98.0~14.04~ppa6/rts/Game/UI/ShareBox.cpp --- spring-96.0~14.04~ppa4/rts/Game/UI/ShareBox.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/ShareBox.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,14 +7,14 @@ #include "Game/SelectedUnitsHandler.h" #include "Game/Players/Player.h" #include "Game/Players/PlayerHandler.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Rendering/GL/myGL.h" #include "Sim/Misc/GlobalSynced.h" #include "Sim/Misc/TeamHandler.h" #include "Net/Protocol/NetProtocol.h" #include "System/MsgStrings.h" -#include +#include #define MAX_SHARE_TEAMS (teamHandler->ActiveTeams() - 1) @@ -418,7 +418,7 @@ } } -bool CShareBox::KeyPressed(unsigned short key, bool isRepeat) +bool CShareBox::KeyPressed(int key, bool isRepeat) { if (key == SDLK_ESCAPE) { delete this; diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/ShareBox.h spring-98.0~14.04~ppa6/rts/Game/UI/ShareBox.h --- spring-96.0~14.04~ppa4/rts/Game/UI/ShareBox.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/ShareBox.h 2014-10-07 20:09:51.000000000 +0000 @@ -19,7 +19,7 @@ bool MousePress(int x, int y, int button); void MouseRelease(int x, int y, int button); void MouseMove(int x, int y, int dx, int dy, int button); - bool KeyPressed(unsigned short key, bool isRepeat); + bool KeyPressed(int key, bool isRepeat); private: ContainerBox box; diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/StartPosSelecter.cpp spring-98.0~14.04~ppa6/rts/Game/UI/StartPosSelecter.cpp --- spring-96.0~14.04~ppa4/rts/Game/UI/StartPosSelecter.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/StartPosSelecter.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -10,7 +10,7 @@ #include "Game/Players/Player.h" #include "Map/Ground.h" #include "Rendering/GL/myGL.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Net/Protocol/NetProtocol.h" @@ -67,7 +67,7 @@ if ((showReadyBox && InBox(mx, my, readyBox)) || gs->frameNum > 0) return (!Ready(false)); - const float dist = ground->LineGroundCol(camera->GetPos(), camera->GetPos() + mouse->dir * globalRendering->viewRange * 1.4f, false); + const float dist = CGround::LineGroundCol(camera->GetPos(), camera->GetPos() + mouse->dir * globalRendering->viewRange * 1.4f, false); if (dist < 0.0f) return true; @@ -80,22 +80,18 @@ return true; } -void CStartPosSelecter::Draw() -{ - if (gu->spectating) { - delete this; - return; - } +void CStartPosSelecter::DrawStartBox() const +{ glPushMatrix(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glMatrixMode(GL_MODELVIEW); + camera->Update(); glColor4f(0.2f,0.8f,0.2f,0.5f); glDisable(GL_TEXTURE_2D); glEnable(GL_DEPTH_TEST); - glBegin(GL_QUADS); const std::vector& allyStartData = CGameSetup::GetAllyStartingData(); const AllyTeam& myStartData = allyStartData[gu->myAllyTeam]; @@ -106,17 +102,14 @@ const float dy = (myStartData.startRectBottom - myStartData.startRectTop) * gs->mapy * SQUARE_SIZE / 10; const float dx = (myStartData.startRectRight - myStartData.startRectLeft) * gs->mapx * SQUARE_SIZE / 10; - const float mx = float(mouse->lastx) / globalRendering->viewSizeX; - const float my = (globalRendering->viewSizeY - float(mouse->lasty)) / globalRendering->viewSizeY; - - // draw starting-rectangle restrictions + glBegin(GL_QUADS); for (int a = 0; a < 10; ++a) { float3 pos1(bx + (a ) * dx, 0.0f, by); float3 pos2(bx + (a + 1) * dx, 0.0f, by); - pos1.y = ground->GetHeightAboveWater(pos1.x, pos1.z, false); - pos2.y = ground->GetHeightAboveWater(pos2.x, pos2.z, false); + pos1.y = CGround::GetHeightAboveWater(pos1.x, pos1.z, false); + pos2.y = CGround::GetHeightAboveWater(pos2.x, pos2.z, false); glVertexf3(pos1); glVertexf3(pos2); @@ -125,8 +118,8 @@ pos1 = float3(bx + (a ) * dx, 0.0f, by + dy * 10.0f); pos2 = float3(bx + (a + 1) * dx, 0.0f, by + dy * 10.0f); - pos1.y = ground->GetHeightAboveWater(pos1.x, pos1.z, false); - pos2.y = ground->GetHeightAboveWater(pos2.x, pos2.z, false); + pos1.y = CGround::GetHeightAboveWater(pos1.x, pos1.z, false); + pos2.y = CGround::GetHeightAboveWater(pos2.x, pos2.z, false); glVertexf3(pos1); glVertexf3(pos2); @@ -135,8 +128,8 @@ pos1 = float3(bx, 0.0f, by + dy * (a )); pos2 = float3(bx, 0.0f, by + dy * (a + 1)); - pos1.y = ground->GetHeightAboveWater(pos1.x, pos1.z, false); - pos2.y = ground->GetHeightAboveWater(pos2.x, pos2.z, false); + pos1.y = CGround::GetHeightAboveWater(pos1.x, pos1.z, false); + pos2.y = CGround::GetHeightAboveWater(pos2.x, pos2.z, false); glVertexf3(pos1); glVertexf3(pos2); @@ -145,8 +138,8 @@ pos1 = float3(bx + dx * 10.0f, 0.0f, by + dy * (a )); pos2 = float3(bx + dx * 10.0f, 0.0f, by + dy * (a + 1)); - pos1.y = ground->GetHeightAboveWater(pos1.x, pos1.z, false); - pos2.y = ground->GetHeightAboveWater(pos2.x, pos2.z, false); + pos1.y = CGround::GetHeightAboveWater(pos1.x, pos1.z, false); + pos2.y = CGround::GetHeightAboveWater(pos2.x, pos2.z, false); glVertexf3(pos1); glVertexf3(pos2); @@ -159,15 +152,31 @@ glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); + glDisable(GL_DEPTH_TEST); + glColor4f(1.0f,1.0f,1.0f,1.0f); +} - glDisable(GL_TEXTURE_2D); - glEnable(GL_BLEND); - glDisable(GL_ALPHA_TEST); + +void CStartPosSelecter::Draw() +{ + if (gu->spectating) { + delete this; + return; + } + + // lua-fied! + //DrawStartBox(); if (!showReadyBox) return; + const float mx = float(mouse->lastx) / globalRendering->viewSizeX; + const float my = (globalRendering->viewSizeY - float(mouse->lasty)) / globalRendering->viewSizeY; + + glEnable(GL_BLEND); + glDisable(GL_ALPHA_TEST); + if (InBox(mx, my, readyBox)) { glColor4f(0.7f, 0.2f, 0.2f, guiAlpha); } else { diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/StartPosSelecter.h spring-98.0~14.04~ppa6/rts/Game/UI/StartPosSelecter.h --- spring-96.0~14.04~ppa4/rts/Game/UI/StartPosSelecter.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/StartPosSelecter.h 2014-10-07 20:09:51.000000000 +0000 @@ -21,6 +21,9 @@ static CStartPosSelecter* GetSelector() { return selector; } private: + void DrawStartBox() const; + +private: ContainerBox readyBox; float3 setStartPos; diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/TooltipConsole.cpp spring-98.0~14.04~ppa6/rts/Game/UI/TooltipConsole.cpp --- spring-96.0~14.04~ppa4/rts/Game/UI/TooltipConsole.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/TooltipConsole.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -11,7 +11,7 @@ #include "Map/MetalMap.h" #include "Map/ReadMap.h" #include "Rendering/GL/myGL.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Sim/Features/Feature.h" #include "Sim/Features/FeatureDef.h" #include "Sim/Misc/LosHandler.h" diff -Nru spring-96.0~14.04~ppa4/rts/Game/UI/UnitTracker.cpp spring-98.0~14.04~ppa6/rts/Game/UI/UnitTracker.cpp --- spring-96.0~14.04~ppa4/rts/Game/UI/UnitTracker.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UI/UnitTracker.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -85,8 +85,6 @@ void CUnitTracker::Track() { - GML_RECMUTEX_LOCK(sel); // Track - CUnitSet& units = selectedUnitsHandler.selectedUnits; CleanTrackGroup(); @@ -121,8 +119,6 @@ void CUnitTracker::MakeTrackGroup() { - GML_RECMUTEX_LOCK(sel); // MakeTrackGroup - trackGroup.clear(); CUnitSet& units = selectedUnitsHandler.selectedUnits; CUnitSet::const_iterator it; @@ -291,7 +287,7 @@ lastUpdateTime = gs->frameNum + globalRendering->timeOffset; float3 modPlanePos(u->drawPos - (u->frontdir * u->radius * 3)); - const float minHeight = ground->GetHeightReal(modPlanePos.x, modPlanePos.z, false) + (u->radius * 2); + const float minHeight = CGround::GetHeightReal(modPlanePos.x, modPlanePos.z, false) + (u->radius * 2); if (modPlanePos.y < minHeight) { modPlanePos.y = minHeight; } diff -Nru spring-96.0~14.04~ppa4/rts/Game/UnsyncedGameCommands.cpp spring-98.0~14.04~ppa6/rts/Game/UnsyncedGameCommands.cpp --- spring-96.0~14.04~ppa4/rts/Game/UnsyncedGameCommands.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/UnsyncedGameCommands.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,7 +1,6 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ #include "UnsyncedGameCommands.h" -#include "lib/gml/gmlcnf.h" #include "UnsyncedActionExecutor.h" #include "SyncedGameCommands.h" @@ -42,7 +41,7 @@ #include "Rendering/Env/IWater.h" #include "Rendering/Shaders/ShaderHandler.h" #include "Rendering/FeatureDrawer.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Rendering/Env/IGroundDecalDrawer.h" #include "Rendering/HUDDrawer.h" #include "Rendering/Screenshot.h" @@ -55,6 +54,7 @@ #include "Sim/Misc/TeamHandler.h" #include "Sim/Units/Scripts/UnitScript.h" #include "Sim/Units/Groups/GroupHandler.h" +#include "Sim/Projectiles/ProjectileHandler.h" #include "UI/CommandColors.h" #include "UI/EndGameBox.h" #include "UI/GameInfo.h" @@ -62,6 +62,7 @@ #include "UI/InfoConsole.h" #include "UI/InputReceiver.h" #include "UI/KeyBindings.h" +#include "UI/KeyCodes.h" #include "UI/MiniMap.h" #include "UI/QuitBox.h" #include "UI/ResourceBar.h" @@ -75,12 +76,12 @@ #include "System/Log/ILog.h" #include "System/GlobalConfig.h" #include "Net/Protocol/NetProtocol.h" -#include "System/Input/KeyInput.h" #include "System/FileSystem/SimpleParser.h" #include "System/Sound/ISound.h" -#include "System/Sound/SoundChannels.h" +#include "System/Sound/ISoundChannels.h" #include "System/Sync/DumpState.h" #include "System/Util.h" +#include "System/EventHandler.h" #include @@ -127,6 +128,9 @@ // TODO CGame stuff in UnsyncedGameCommands: refactor (or move) bool CGame::ProcessKeyPressAction(unsigned int key, const Action& action) { + if (!userWriting) + return false; + if (action.command == "edit_return") { userWriting = false; writingPos = 0; @@ -190,25 +194,39 @@ return true; } else if (action.command == "chatswitchally") { - if ((userInput.find_first_of("aAsS") == 0) && (userInput[1] == ':')) { + if ((userInput.find_first_of("aA") == 0) && (userInput[1] == ':')) { + // already are in ally chat -> toggle it off + userInput = userInput.substr(2); + writingPos = std::max(0, writingPos - 2); + userInputPrefix = ""; + } + else if ((userInput.find_first_of("sS") == 0) && (userInput[1] == ':')) { + // are in spec chat -> switch it to ally chat userInput[0] = 'a'; + userInputPrefix = "a:"; } else { userInput = "a:" + userInput; writingPos += 2; + userInputPrefix = "a:"; } - - userInputPrefix = "a:"; return true; } else if (action.command == "chatswitchspec") { - if ((userInput.find_first_of("aAsS") == 0) && (userInput[1] == ':')) { + if ((userInput.find_first_of("sS") == 0) && (userInput[1] == ':')) { + // already are in spec chat -> toggle it off + userInput = userInput.substr(2); + writingPos = std::max(0, writingPos - 2); + userInputPrefix = ""; + } + else if ((userInput.find_first_of("aA") == 0) && (userInput[1] == ':')) { + // are in ally chat -> switch it to spec chat userInput[0] = 's'; + userInputPrefix = "s:"; } else { userInput = "s:" + userInput; writingPos += 2; + userInputPrefix = "s:"; } - - userInputPrefix = "s:"; return true; } else if (action.command == "pastetext") { @@ -226,14 +244,15 @@ else if (action.command == "edit_backspace") { if (!userInput.empty() && (writingPos > 0)) { - userInput.erase(writingPos - 1, 1); - writingPos--; + int prev=Utf8PrevChar(userInput,writingPos); + userInput.erase(prev, writingPos-prev); + writingPos=prev; } return true; } else if (action.command == "edit_delete") { if (!userInput.empty() && (writingPos < (int)userInput.size())) { - userInput.erase(writingPos, 1); + userInput.erase(writingPos, Utf8CharLen(userInput,writingPos)); } return true; } @@ -246,14 +265,14 @@ return true; } else if (action.command == "edit_prev_char") { - writingPos = std::max(0, std::min((int)userInput.length(), writingPos - 1)); + writingPos = Utf8PrevChar(userInput,writingPos); return true; } else if (action.command == "edit_next_char") { - writingPos = std::max(0, std::min((int)userInput.length(), writingPos + 1)); + writingPos = Utf8NextChar(userInput,writingPos); return true; } - else if (action.command == "edit_prev_word") { + else if (action.command == "edit_prev_word") { //TODO It don't seems to work correctly with utf-8 // prev word const char* s = userInput.c_str(); int p = writingPos; @@ -262,7 +281,7 @@ writingPos = p; return true; } - else if (action.command == "edit_next_word") { + else if (action.command == "edit_next_word") { //TODO It don't seems to work correctly with utf-8 const int len = (int)userInput.length(); const char* s = userInput.c_str(); int p = writingPos; @@ -372,7 +391,7 @@ "") {} // TODO bool Execute(const UnsyncedAction& action) const { - game->SelectUnits(action.GetArgs()); //TODO give it a return argument? + selectedUnitsHandler.SelectUnits(action.GetArgs()); //TODO give it a return argument? return true; } }; @@ -385,7 +404,7 @@ "") {} // TODO bool Execute(const UnsyncedAction& action) const { - game->SelectCycle(action.GetArgs()); //TODO give it a return argument? + selectedUnitsHandler.SelectCycle(action.GetArgs()); //TODO give it a return argument? return true; } }; @@ -444,7 +463,7 @@ if (!action.GetArgs().empty()) { bool enable = true; - SetBoolArg(enable, action.GetArgs()); + InverseOrSetBool(enable, action.GetArgs()); if (enable != smfGD->ToggleMapBorder()) smfGD->ToggleMapBorder(); @@ -514,7 +533,7 @@ if (!canUseShaders) return false; - SetBoolArg(unitDrawer->UseAdvShadingRef(), action.GetArgs()); + InverseOrSetBool(unitDrawer->UseAdvShadingRef(), action.GetArgs()); LogSystemStatus("model shaders", unitDrawer->UseAdvShading()); return true; } @@ -535,7 +554,7 @@ if (!canUseShaders) return false; - SetBoolArg(gd->UseAdvShadingRef(), action.GetArgs()); + InverseOrSetBool(gd->UseAdvShadingRef(), action.GetArgs()); LogSystemStatus("map shaders", gd->UseAdvShading()); return true; } @@ -680,9 +699,6 @@ if (pos.x >= 0) { inMapDrawer->SetDrawMode(false); inMapDrawer->PromptLabel(pos); - if ((action.GetKey() >= SDLK_SPACE) && (action.GetKey() <= SDLK_DELETE)) { - game->ignoreNextChar=true; - } } else { LOG_L(L_WARNING, "/DrawLabel: move mouse over the map"); } @@ -719,8 +735,6 @@ "Moves the camera to the center of the currently selected units") {} bool Execute(const UnsyncedAction& action) const { - GML_RECMUTEX_LOCK(sel); // ActionPressed - const CUnitSet& selUnits = selectedUnitsHandler.selectedUnits; if (selUnits.empty()) return false; @@ -1202,9 +1216,9 @@ bool Execute(const UnsyncedAction& action) const { if (!action.IsRepeat()) { - grouphandlers[gu->myTeam]->GroupCommand(groupId); + return grouphandlers[gu->myTeam]->GroupCommand(groupId); } - return true; + return false; } private: @@ -1219,6 +1233,9 @@ "Moves the camera to show the position of the last message") {} bool Execute(const UnsyncedAction& action) const { + if (game->infoConsole->GetMsgPosCount() == 0) + return false; + // cycle through the positions camHandler->CameraTransition(0.6f); camHandler->GetCurrentController().SetPos(game->infoConsole->GetMsgPos()); @@ -1247,11 +1264,7 @@ game->userInput = game->userInputPrefix; game->writingPos = (int)game->userInput.length(); game->chatting = true; - //this command can get called too from console or lua, if so GetKey is -1, don't drop next char then - if (action.GetKey() != SDLK_RETURN && action.GetKey() != -1 ) { - game->ignoreNextChar = true; - } - + game->ignoreNextChar = true; game->consoleHistory->ResetPosition(); return true; } @@ -1311,44 +1324,6 @@ -class ShowHealthBarsActionExecutor : public IUnsyncedActionExecutor { -public: - ShowHealthBarsActionExecutor() : IUnsyncedActionExecutor("ShowHealthBars", - "Enable/Disable rendering of health-bars for units") {} - - bool Execute(const UnsyncedAction& action) const { - if (!GML::Enabled()) - return false; -#ifdef USE_GML - SetBoolArg(unitDrawer->showHealthBars, action.GetArgs()); - LogSystemStatus("rendering of health-bars", unitDrawer->showHealthBars); -#endif // USE_GML - return true; - } -}; - - - -class ShowRezurectionBarsActionExecutor : public IUnsyncedActionExecutor { -public: - ShowRezurectionBarsActionExecutor() : IUnsyncedActionExecutor("ShowRezBars", - "Enable/Disable rendering of resource-bars for features") {} - - bool Execute(const UnsyncedAction& action) const { - if (!GML::Enabled()) - return false; -#ifdef USE_GML - bool showResBars = featureDrawer->GetShowRezBars(); - SetBoolArg(showResBars, action.GetArgs()); - featureDrawer->SetShowRezBars(showResBars); - LogSystemStatus("rendering of resource-bars for features", featureDrawer->GetShowRezBars()); -#endif // USE_GML - return true; - } -}; - - - class PauseActionExecutor : public IUnsyncedActionExecutor { public: PauseActionExecutor() : IUnsyncedActionExecutor("Pause", @@ -1362,10 +1337,9 @@ // do not need to update lastReadNetTime, gets // done when NETMSG_PAUSE makes the round-trip bool newPause = gs->paused; - SetBoolArg(newPause, action.GetArgs()); + InverseOrSetBool(newPause, action.GetArgs()); net->Send(CBaseNetProtocol::Get().SendPause(gu->myPlayerNum, newPause)); return true; - } }; @@ -1388,24 +1362,36 @@ }; - -// XXX unlucky name; maybe make this "Sound {0|1}" instead (bool arg or toggle) -class NoSoundActionExecutor : public IUnsyncedActionExecutor { +class MuteActionExecutor : public IUnsyncedActionExecutor { public: - NoSoundActionExecutor() : IUnsyncedActionExecutor("NoSound", - "Enable/Disable the sound system") {} + MuteActionExecutor() : IUnsyncedActionExecutor("MuteSound", + "Mute/Unmute the current sound system") {} bool Execute(const UnsyncedAction& action) const { // toggle sound->Mute(); - LogSystemStatus("Sound", !sound->IsMuted()); + LogSystemStatus("Mute", sound->IsMuted()); + return true; + } +}; + +class SoundActionExecutor : public IUnsyncedActionExecutor { +public: + SoundActionExecutor() : IUnsyncedActionExecutor("SoundDevice", + "Switch the sound output system (currently only OpenAL / NullAudio)") {} + + bool Execute(const UnsyncedAction& action) const { + + // toggle + LogSystemStatus("Sound", !sound->ChangeOutput()); return true; } }; + class SoundChannelEnableActionExecutor : public IUnsyncedActionExecutor { public: SoundChannelEnableActionExecutor() : IUnsyncedActionExecutor("SoundChannelEnable", @@ -1424,15 +1410,15 @@ enable = true; if (channel == "UnitReply") - Channels::UnitReply.Enable(enable); + Channels::UnitReply->Enable(enable); else if (channel == "General") - Channels::General.Enable(enable); + Channels::General->Enable(enable); else if (channel == "Battle") - Channels::Battle.Enable(enable); + Channels::Battle->Enable(enable); else if (channel == "UserInterface") - Channels::UserInterface.Enable(enable); + Channels::UserInterface->Enable(enable); else if (channel == "Music") - Channels::BGMusic.Enable(enable); + Channels::BGMusic->Enable(enable); else LOG_L(L_WARNING, "/%s: wrong channel name \"%s\"", GetCommand().c_str(), channel.c_str()); @@ -1465,7 +1451,7 @@ bool Execute(const UnsyncedAction& action) const { - SetBoolArg(treeDrawer->drawTrees, action.GetArgs()); + InverseOrSetBool(treeDrawer->drawTrees, action.GetArgs()); LogSystemStatus("rendering of engine trees", treeDrawer->drawTrees); return true; } @@ -1480,7 +1466,7 @@ bool Execute(const UnsyncedAction& action) const { - SetBoolArg(sky->dynamicSky, action.GetArgs()); + InverseOrSetBool(sky->dynamicSky, action.GetArgs()); LogSystemStatus("dynamic-sky rendering", sky->dynamicSky); return true; } @@ -1496,7 +1482,7 @@ bool Execute(const UnsyncedAction& action) const { bool dynamicSun = sky->GetLight()->IsDynamic(); - SetBoolArg(dynamicSun, action.GetArgs()); + InverseOrSetBool(dynamicSun, action.GetArgs()); sky->SetLight(dynamicSun); LogSystemStatus("dynamic-sun rendering", sky->GetLight()->IsDynamic()); return true; @@ -1505,146 +1491,6 @@ -#ifdef USE_GML -class MultiThreadDrawGroundActionExecutor : public IUnsyncedActionExecutor { -public: - MultiThreadDrawGroundActionExecutor() : IUnsyncedActionExecutor("MultiThreadDrawGround", - "Enable/Disable multi threaded ground rendering") {} - - bool Execute(const UnsyncedAction& action) const { - if (!GML::Enabled()) - return false; - CBaseGroundDrawer* gd = readMap->GetGroundDrawer(); - SetBoolArg(gd->multiThreadDrawGround, action.GetArgs()); - configHandler->Set("MultiThreadDrawGround", gd->multiThreadDrawGround ? 1 : 0); - LogSystemStatus("Multi threaded ground rendering", gd->multiThreadDrawGround); - return true; - } -}; - - - -class MultiThreadDrawGroundShadowActionExecutor : public IUnsyncedActionExecutor { -public: - MultiThreadDrawGroundShadowActionExecutor() : IUnsyncedActionExecutor("MultiThreadDrawGroundShadow", - "Enable/Disable multi threaded ground shadow rendering") {} - - bool Execute(const UnsyncedAction& action) const { - if (!GML::Enabled()) - return false; - CBaseGroundDrawer* gd = readMap->GetGroundDrawer(); - SetBoolArg(gd->multiThreadDrawGroundShadow, action.GetArgs()); - configHandler->Set("MultiThreadDrawGroundShadow", gd->multiThreadDrawGroundShadow ? 1 : 0); - LogSystemStatus("Multi threaded ground shadow rendering", gd->multiThreadDrawGroundShadow); - return true; - } -}; - - - -class MultiThreadDrawUnitActionExecutor : public IUnsyncedActionExecutor { -public: - MultiThreadDrawUnitActionExecutor() : IUnsyncedActionExecutor("MultiThreadDrawUnit", - "Enable/Disable multi threaded unit rendering") {} - - bool Execute(const UnsyncedAction& action) const { - if (!GML::Enabled()) - return false; - SetBoolArg(unitDrawer->multiThreadDrawUnit, action.GetArgs()); - configHandler->Set("MultiThreadDrawUnit", unitDrawer->multiThreadDrawUnit ? 1 : 0); - LogSystemStatus("Multi threaded unit rendering", unitDrawer->multiThreadDrawUnit); - return true; - } -}; - - - -class MultiThreadDrawUnitShadowActionExecutor : public IUnsyncedActionExecutor { -public: - MultiThreadDrawUnitShadowActionExecutor() : IUnsyncedActionExecutor("MultiThreadDrawUnitShadow", - "Enable/Disable multi threaded unit shadow rendering") {} - - bool Execute(const UnsyncedAction& action) const { - if (!GML::Enabled()) - return false; - SetBoolArg(unitDrawer->multiThreadDrawUnitShadow, action.GetArgs()); - configHandler->Set("MultiThreadDrawUnitShadow", unitDrawer->multiThreadDrawUnitShadow ? 1 : 0); - LogSystemStatus("Multi threaded unit shadow rendering", unitDrawer->multiThreadDrawUnitShadow); - return true; - } -}; - - - -class MultiThreadDrawActionExecutor : public IUnsyncedActionExecutor { -public: - MultiThreadDrawActionExecutor() : IUnsyncedActionExecutor("MultiThreadDraw", - "Enable/Disable multi threaded rendering") {} - - bool Execute(const UnsyncedAction& action) const { - if (!GML::Enabled()) - return false; - CBaseGroundDrawer* gd = readMap->GetGroundDrawer(); - bool mtEnabled = IsMTEnabled(); - SetBoolArg(mtEnabled, action.GetArgs()); - gd->multiThreadDrawGround = mtEnabled; - unitDrawer->multiThreadDrawUnit = mtEnabled; - unitDrawer->multiThreadDrawUnitShadow = mtEnabled; - if (!mtEnabled) { - gd->multiThreadDrawGroundShadow = false; - } - LogSystemStatus("Multithreaded rendering", IsMTEnabled()); - return true; - } - - static bool IsMTEnabled() { - CBaseGroundDrawer* gd = readMap->GetGroundDrawer(); - // find out if most of the MT stuff is on or off so we can toggle based on that - return - ((gd->multiThreadDrawGround ? 1 : 0) - + (unitDrawer->multiThreadDrawUnit ? 1 : 0) - + (unitDrawer->multiThreadDrawUnitShadow ? 1 : 0)) - > 1; - } -}; - - - -class MultiThreadSimActionExecutor : public IUnsyncedActionExecutor { -public: - MultiThreadSimActionExecutor(bool inv = false) : IUnsyncedActionExecutor("MultiThreadSim", - "Enable/Disable separate simulation thread"), inverse(inv) {} - - bool inverse; - bool Execute(const UnsyncedAction& action) const { - if (!GML::Enabled()) - return false; -# if GML_ENABLE_SIM - bool mtEnabled = MultiThreadDrawActionExecutor::IsMTEnabled(); - // HACK GetInnerAction() should not be used here - bool mtSim = (StringToLower(action.GetInnerAction().command) == "multithread") ? ((inverse && action.GetArgs().empty()) ? !mtEnabled : mtEnabled) : GML::MultiThreadSim(); - SetBoolArg(mtSim, action.GetArgs()); - GML::MultiThreadSim(mtSim); - - LogSystemStatus("Separate simulation thread", GML::MultiThreadSim()); -# endif // GML_ENABLE_SIM - return true; - } -}; - - - -class MultiThreadActionExecutor : public SequentialActionExecutor { -public: - MultiThreadActionExecutor() : SequentialActionExecutor("MultiThread") { - AddExecutor(new MultiThreadDrawActionExecutor()); - AddExecutor(new MultiThreadSimActionExecutor(true)); - } -}; -#endif // USE_GML - - - class SpeedControlActionExecutor : public IUnsyncedActionExecutor { public: SpeedControlActionExecutor() : IUnsyncedActionExecutor("SpeedControl", @@ -1698,7 +1544,7 @@ "Hide/Show the GUI controlls") {} bool Execute(const UnsyncedAction& action) const { - SetBoolArg(game->hideInterface, action.GetArgs()); + InverseOrSetBool(game->hideInterface, action.GetArgs()); return true; } }; @@ -1721,6 +1567,35 @@ +class FullscreenActionExecutor : public IUnsyncedActionExecutor { +public: + FullscreenActionExecutor() : IUnsyncedActionExecutor("Fullscreen", + "Switches fullscreen mode") {} + + bool Execute(const UnsyncedAction& action) const { + if (!action.GetArgs().empty()) { + globalRendering->fullScreen = (atoi(action.GetArgs().c_str()) != 0); + } else { + globalRendering->fullScreen = !globalRendering->fullScreen; + } + + const bool borderless = configHandler->GetBool("WindowBorderless"); + if (globalRendering->fullScreen) { + if (borderless) { + SDL_SetWindowFullscreen(globalRendering->window, SDL_WINDOW_FULLSCREEN_DESKTOP); + } else { + SDL_SetWindowFullscreen(globalRendering->window, SDL_WINDOW_FULLSCREEN); + } + } else { + SDL_SetWindowFullscreen(globalRendering->window, 0); + SDL_SetWindowBordered(globalRendering->window, borderless ? SDL_FALSE : SDL_TRUE); + } + return true; + } +}; + + + class IncreaseViewRadiusActionExecutor : public IUnsyncedActionExecutor { public: IncreaseViewRadiusActionExecutor() : IUnsyncedActionExecutor("IncreaseViewRadius", @@ -2032,8 +1907,8 @@ if (inputReceivers.empty() || dynamic_cast(inputReceivers.front())) return false; - const CKeyBindings::HotkeyList quitList = keyBindings->GetHotkeys("quitmenu"); - const std::string quitKey = quitList.empty() ? "" : quitList.front(); + const CKeyBindings::HotkeyList& quitList = keyBindings->GetHotkeys("quitmenu"); + const std::string quitKey = quitList.empty() ? "" : *quitList.begin(); LOG("Press %s to access the quit menu", quitKey.c_str()); return true; } @@ -2125,23 +2000,18 @@ "Prevents/Enables the mouse from leaving the game window (windowed mode only)") {} bool Execute(const UnsyncedAction& action) const { - SDL_GrabMode newMode; + SDL_bool newMode; if (action.GetArgs().empty()) { - const SDL_GrabMode curMode = SDL_WM_GrabInput(SDL_GRAB_QUERY); - switch (curMode) { - default: // make compiler happy - case SDL_GRAB_OFF: newMode = SDL_GRAB_ON; break; - case SDL_GRAB_ON: newMode = SDL_GRAB_OFF; break; - } + newMode = (SDL_GetWindowGrab(globalRendering->window)) ? SDL_FALSE : SDL_TRUE; } else { if (atoi(action.GetArgs().c_str())) { - newMode = SDL_GRAB_ON; + newMode = SDL_TRUE; } else { - newMode = SDL_GRAB_OFF; + newMode = SDL_FALSE; } } - SDL_WM_GrabInput(newMode); - LogSystemStatus("Input grabbing", (newMode == SDL_GRAB_ON)); + SDL_SetWindowGrab(globalRendering->window, newMode); + LogSystemStatus("Input grabbing", (newMode == SDL_TRUE)); return true; } }; @@ -2155,7 +2025,7 @@ bool Execute(const UnsyncedAction& action) const { - SetBoolArg(game->showClock, action.GetArgs()); + InverseOrSetBool(game->showClock, action.GetArgs()); configHandler->Set("ShowClock", game->showClock ? 1 : 0); LogSystemStatus("small digital clock", game->showClock); return true; @@ -2205,7 +2075,7 @@ bool Execute(const UnsyncedAction& action) const { - SetBoolArg(game->showFPS, action.GetArgs()); + InverseOrSetBool(game->showFPS, action.GetArgs()); configHandler->Set("ShowFPS", game->showFPS ? 1 : 0); LogSystemStatus("frames-per-second indicator", game->showFPS); return true; @@ -2221,7 +2091,7 @@ bool Execute(const UnsyncedAction& action) const { - SetBoolArg(game->showSpeed, action.GetArgs()); + InverseOrSetBool(game->showSpeed, action.GetArgs()); configHandler->Set("ShowSpeed", game->showSpeed ? 1 : 0); LogSystemStatus("simulation speed indicator", game->showSpeed); return true; @@ -2229,27 +2099,6 @@ }; - -class MTInfoActionExecutor : public IUnsyncedActionExecutor { -public: - MTInfoActionExecutor() : IUnsyncedActionExecutor("MTInfo", - "Shows/Hides the multi threading info panel") {} - - bool Execute(const UnsyncedAction& action) const { - if (!GML::Enabled()) - return false; - bool showMTInfo = (game->showMTInfo != -1); - SetBoolArg(showMTInfo, action.GetArgs()); - configHandler->Set("ShowMTInfo", showMTInfo ? 1 : 0); - int mtl = globalConfig->GetMultiThreadLua(); - game->showMTInfo = showMTInfo ? mtl : -1; - GML::EnableCallChainWarnings(!!game->showMTInfo); - return true; - } -}; - - - class TeamHighlightActionExecutor : public IUnsyncedActionExecutor { public: TeamHighlightActionExecutor() : IUnsyncedActionExecutor("TeamHighlight", @@ -2392,7 +2241,7 @@ bool Execute(const UnsyncedAction& action) const { bool safeMode = LuaOpenGL::GetSafeMode(); - SetBoolArg(safeMode, action.GetArgs()); + InverseOrSetBool(safeMode, action.GetArgs()); LuaOpenGL::SetSafeMode(safeMode); LogSystemStatus("OpenGL safe-mode", LuaOpenGL::GetSafeMode()); return true; @@ -2410,7 +2259,7 @@ if (!resourceBar) return false; - SetBoolArg(resourceBar->enabled, action.GetArgs()); + InverseOrSetBool(resourceBar->enabled, action.GetArgs()); return true; } }; @@ -2427,7 +2276,7 @@ if (!tooltip) return false; - SetBoolArg(tooltip->enabled, action.GetArgs()); + InverseOrSetBool(tooltip->enabled, action.GetArgs()); return true; } }; @@ -2443,7 +2292,7 @@ if (!game->infoConsole) return false; - SetBoolArg(game->infoConsole->enabled, action.GetArgs()); + InverseOrSetBool(game->infoConsole->enabled, action.GetArgs()); return true; } }; @@ -2456,7 +2305,7 @@ "Enables/Disables the statistics graphs shown at the end of the game") {} bool Execute(const UnsyncedAction& action) const { - SetBoolArg(CEndGameBox::enabled, action.GetArgs()); + InverseOrSetBool(CEndGameBox::enabled, action.GetArgs()); return true; } }; @@ -2471,7 +2320,7 @@ bool Execute(const UnsyncedAction& action) const { bool drawHUD = hudDrawer->GetDraw(); - SetBoolArg(drawHUD, action.GetArgs()); + InverseOrSetBool(drawHUD, action.GetArgs()); hudDrawer->SetDraw(drawHUD); return true; } @@ -2487,7 +2336,7 @@ bool Execute(const UnsyncedAction& action) const { bool aiDebugDraw = debugDrawerAI->GetDraw(); - SetBoolArg(aiDebugDraw, action.GetArgs()); + InverseOrSetBool(aiDebugDraw, action.GetArgs()); debugDrawerAI->SetDraw(aiDebugDraw); LogSystemStatus("SkirmishAI debug drawing", debugDrawerAI->GetDraw()); return true; @@ -2503,7 +2352,7 @@ bool Execute(const UnsyncedAction& action) const { - SetBoolArg(globalRendering->drawMapMarks, action.GetArgs()); + InverseOrSetBool(globalRendering->drawMapMarks, action.GetArgs()); LogSystemStatus("map marks rendering", globalRendering->drawMapMarks); return true; } @@ -2519,7 +2368,7 @@ bool Execute(const UnsyncedAction& action) const { bool allMarksVisible = inMapDrawerModel->GetAllMarksVisible(); - SetBoolArg(allMarksVisible, action.GetArgs()); + InverseOrSetBool(allMarksVisible, action.GetArgs()); inMapDrawerModel->SetAllMarksVisible(allMarksVisible); return true; } @@ -2549,7 +2398,7 @@ bool Execute(const UnsyncedAction& action) const { bool luaMapDrawingAllowed = inMapDrawer->GetLuaMapDrawingAllowed(); - SetBoolArg(luaMapDrawingAllowed, action.GetArgs()); + InverseOrSetBool(luaMapDrawingAllowed, action.GetArgs()); inMapDrawer->SetLuaMapDrawingAllowed(luaMapDrawingAllowed); return true; } @@ -2560,13 +2409,61 @@ class LuaUIActionExecutor : public IUnsyncedActionExecutor { public: LuaUIActionExecutor() : IUnsyncedActionExecutor("LuaUI", - "Allow/Disallow Lua to draw (GUI elements)") {} + "Allows one to reload or disable LuaUI, or alternatively to send" + " a chat message to LuaUI") {} bool Execute(const UnsyncedAction& action) const { if (!guihandler) return false; - guihandler->PushLayoutCommand(action.GetArgs()); + const std::string& command = action.GetArgs(); + + if (command == "reload" || command == "enable") { + if (luaUI && luaUI->IsRunning()) { + // NOTE: causes a SEGV through RunCallIn() + LOG_L(L_WARNING, "Can not reload from within LuaUI, yet"); + return true; + } + if (luaUI == NULL) { + LOG("Loading: \"%s\"", "luaui.lua"); // FIXME duplicate of below + CLuaUI::LoadHandler(); + if (luaUI == NULL) { + guihandler->LoadConfig("ctrlpanel.txt"); + LOG_L(L_WARNING, "Loading failed"); + } + } else { + if (command == "enable") { + LOG_L(L_WARNING, "LuaUI is already enabled"); + } else { + LOG("Reloading: \"%s\"", "luaui.lua"); // FIXME + CLuaUI::FreeHandler(); + CLuaUI::LoadHandler(); + if (luaUI == NULL) { + guihandler->LoadConfig("ctrlpanel.txt"); + LOG_L(L_WARNING, "Reloading failed"); + } + } + } + guihandler->LayoutIcons(false); + } + else if (command == "disable") { + if (luaUI && luaUI->IsRunning()) { + // NOTE: might cause a SEGV through RunCallIn() + LOG_L(L_WARNING, "Can not disable from within LuaUI, yet"); + return true; + } + if (luaUI != NULL) { + CLuaUI::FreeHandler(); + LOG("Disabled LuaUI"); + } + guihandler->LayoutIcons(false); + } + else if (luaUI) { + luaUI->GotChatMsg(command, 0); + } else { + LOG_L(L_DEBUG, "LuaUI is not loaded"); + } + return true; } }; @@ -2582,7 +2479,7 @@ bool Execute(const UnsyncedAction& action) const { bool modUICtrl = CLuaHandle::GetModUICtrl(); - SetBoolArg(modUICtrl, action.GetArgs()); + InverseOrSetBool(modUICtrl, action.GetArgs()); CLuaHandle::SetModUICtrl(modUICtrl); configHandler->Set("LuaModUICtrl", modUICtrl ? 1 : 0); return true; @@ -2594,7 +2491,7 @@ class MiniMapActionExecutor : public IUnsyncedActionExecutor { public: MiniMapActionExecutor() : IUnsyncedActionExecutor("MiniMap", - "Show/Hide the mini-map provided by the engine") {} + "FIXME document subcommands") {} bool Execute(const UnsyncedAction& action) const { if (!minimap) @@ -2616,7 +2513,7 @@ bool Execute(const UnsyncedAction& action) const { bool drawDecals = IGroundDecalDrawer::GetDrawDecals(); - SetBoolArg(drawDecals, action.GetArgs()); + InverseOrSetBool(drawDecals, action.GetArgs()); IGroundDecalDrawer::SetDrawDecals(drawDecals); LogSystemStatus("Ground-decals rendering", IGroundDecalDrawer::GetDrawDecals()); @@ -2680,7 +2577,7 @@ return false; bool gatherMode = guihandler->GetGatherMode(); - SetBoolArg(gatherMode, action.GetArgs()); + InverseOrSetBool(gatherMode, action.GetArgs()); guihandler->SetGatherMode(gatherMode); LogSystemStatus("Gather-Mode", guihandler->GetGatherMode()); return true; @@ -2834,7 +2731,7 @@ bool Execute(const UnsyncedAction& action) const { CBaseGroundDrawer* gd = readMap->GetGroundDrawer(); - SetBoolArg(gd->WireFrameModeRef(), action.GetArgs()); + InverseOrSetBool(gd->WireFrameModeRef(), action.GetArgs()); // TODO: make this a separate action // sky->wireframe = gd->WireFrameMode(); LogSystemStatus("wireframe map-drawing mode", gd->WireFrameMode()); @@ -2850,7 +2747,7 @@ } bool Execute(const UnsyncedAction& action) const { - SetBoolArg(DebugColVolDrawer::enable, action.GetArgs()); + InverseOrSetBool(DebugColVolDrawer::enable, action.GetArgs()); return true; } }; @@ -2882,29 +2779,6 @@ -class SetGammaActionExecutor : public IUnsyncedActionExecutor { -public: - SetGammaActionExecutor() : IUnsyncedActionExecutor("SetGamma", - "Set the rendering gamma value(s) through SDL") {} - - bool Execute(const UnsyncedAction& action) const { - float r, g, b; - const int count = sscanf(action.GetArgs().c_str(), "%f %f %f", &r, &g, &b); - if (count == 1) { - SDL_SetGamma(r, r, r); - LOG("Set gamma value"); - } else if (count == 3) { - SDL_SetGamma(r, g, b); - LOG("Set gamma values"); - } else { - LOG_L(L_WARNING, "Unknown gamma format"); - } - return true; - } -}; - - - class CrashActionExecutor : public IUnsyncedActionExecutor { public: CrashActionExecutor() : IUnsyncedActionExecutor("Crash", @@ -2965,7 +2839,7 @@ } else { const float3& pos = camera->GetPos(); const float3& dir = mouse->dir; - const float dist = ground->LineGroundCol(pos, pos + (dir * 30000.0f)); + const float dist = CGround::LineGroundCol(pos, pos + (dir * 30000.0f)); givePos = pos + (dir * dist); } @@ -3355,32 +3229,23 @@ AddActionExecutor(new TrackActionExecutor()); AddActionExecutor(new TrackOffActionExecutor()); AddActionExecutor(new TrackModeActionExecutor()); - AddActionExecutor(new ShowHealthBarsActionExecutor()); // MT only - AddActionExecutor(new ShowRezurectionBarsActionExecutor()); // MT only AddActionExecutor(new PauseActionExecutor()); AddActionExecutor(new DebugActionExecutor()); AddActionExecutor(new DebugColVolDrawerActionExecutor()); AddActionExecutor(new DebugPathDrawerActionExecutor()); AddActionExecutor(new DebugTraceRayDrawerActionExecutor()); - AddActionExecutor(new NoSoundActionExecutor()); + AddActionExecutor(new MuteActionExecutor()); + AddActionExecutor(new SoundActionExecutor()); AddActionExecutor(new SoundChannelEnableActionExecutor()); AddActionExecutor(new CreateVideoActionExecutor()); AddActionExecutor(new DrawTreesActionExecutor()); AddActionExecutor(new DynamicSkyActionExecutor()); AddActionExecutor(new DynamicSunActionExecutor()); -#ifdef USE_GML - AddActionExecutor(new MultiThreadDrawGroundActionExecutor()); - AddActionExecutor(new MultiThreadDrawGroundShadowActionExecutor()); - AddActionExecutor(new MultiThreadDrawUnitActionExecutor()); - AddActionExecutor(new MultiThreadDrawUnitShadowActionExecutor()); - AddActionExecutor(new MultiThreadDrawActionExecutor()); - AddActionExecutor(new MultiThreadSimActionExecutor()); - AddActionExecutor(new MultiThreadActionExecutor()); -#endif // USE_GML AddActionExecutor(new SpeedControlActionExecutor()); AddActionExecutor(new GameInfoActionExecutor()); AddActionExecutor(new HideInterfaceActionExecutor()); AddActionExecutor(new HardwareCursorActionExecutor()); + AddActionExecutor(new FullscreenActionExecutor()); AddActionExecutor(new IncreaseViewRadiusActionExecutor()); AddActionExecutor(new DecreaseViewRadiusActionExecutor()); AddActionExecutor(new MoreTreesActionExecutor()); @@ -3412,7 +3277,6 @@ AddActionExecutor(new CrossActionExecutor()); AddActionExecutor(new FPSActionExecutor()); AddActionExecutor(new SpeedActionExecutor()); - AddActionExecutor(new MTInfoActionExecutor()); AddActionExecutor(new TeamHighlightActionExecutor()); AddActionExecutor(new InfoActionExecutor()); AddActionExecutor(new CmdColorsActionExecutor()); @@ -3444,7 +3308,6 @@ AddActionExecutor(new DistDrawActionExecutor()); AddActionExecutor(new LODScaleActionExecutor()); AddActionExecutor(new WireMapActionExecutor()); - AddActionExecutor(new SetGammaActionExecutor()); AddActionExecutor(new CrashActionExecutor()); AddActionExecutor(new ExceptionActionExecutor()); AddActionExecutor(new DivByZeroActionExecutor()); diff -Nru spring-96.0~14.04~ppa4/rts/Game/WaitCommandsAI.cpp spring-98.0~14.04~ppa6/rts/Game/WaitCommandsAI.cpp --- spring-96.0~14.04~ppa4/rts/Game/WaitCommandsAI.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/WaitCommandsAI.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -33,49 +33,49 @@ static const int updatePeriod = 3; // in GAME_SPEED, 100 ms -CR_BIND(CWaitCommandsAI, ); +CR_BIND(CWaitCommandsAI, ) CR_REG_METADATA(CWaitCommandsAI, ( CR_MEMBER(waitMap), CR_MEMBER(unackedMap) -)); +)) -CR_BIND_DERIVED_INTERFACE(CWaitCommandsAI::Wait, CObject); +CR_BIND_DERIVED_INTERFACE(CWaitCommandsAI::Wait, CObject) CR_REG_METADATA_SUB(CWaitCommandsAI,Wait, ( CR_MEMBER(code), CR_MEMBER(key), CR_MEMBER(valid), CR_MEMBER(deadTime), CR_POSTLOAD(PostLoad) -)); +)) -CR_BIND_DERIVED(CWaitCommandsAI::TimeWait, CWaitCommandsAI::Wait, (1,0)); +CR_BIND_DERIVED(CWaitCommandsAI::TimeWait, CWaitCommandsAI::Wait, (1,0)) CR_REG_METADATA_SUB(CWaitCommandsAI,TimeWait , ( CR_MEMBER(unit), CR_MEMBER(enabled), CR_MEMBER(duration), CR_MEMBER(endFrame), CR_MEMBER(factory) -)); +)) -CR_BIND_DERIVED(CWaitCommandsAI::DeathWait, CWaitCommandsAI::Wait, (Command())); +CR_BIND_DERIVED(CWaitCommandsAI::DeathWait, CWaitCommandsAI::Wait, (Command())) CR_REG_METADATA_SUB(CWaitCommandsAI,DeathWait , ( CR_MEMBER(waitUnits), CR_MEMBER(deathUnits), CR_MEMBER(unitPos) -)); +)) -CR_BIND_DERIVED(CWaitCommandsAI::SquadWait, CWaitCommandsAI::Wait, (Command())); +CR_BIND_DERIVED(CWaitCommandsAI::SquadWait, CWaitCommandsAI::Wait, (Command())) CR_REG_METADATA_SUB(CWaitCommandsAI,SquadWait , ( CR_MEMBER(squadCount), CR_MEMBER(buildUnits), CR_MEMBER(waitUnits), CR_MEMBER(stateText) -)); +)) -CR_BIND_DERIVED(CWaitCommandsAI::GatherWait, CWaitCommandsAI::Wait, (Command())); +CR_BIND_DERIVED(CWaitCommandsAI::GatherWait, CWaitCommandsAI::Wait, (Command())) CR_REG_METADATA_SUB(CWaitCommandsAI,GatherWait , ( CR_MEMBER(waitUnits) -)); +)) /******************************************************************************/ /******************************************************************************/ @@ -145,8 +145,6 @@ void CWaitCommandsAI::AddTimeWait(const Command& cmd) { - GML_RECMUTEX_LOCK(sel); // AddTimeWait - // save the current selection const CUnitSet tmpSet = selectedUnitsHandler.selectedUnits; CUnitSet::const_iterator it; @@ -440,8 +438,6 @@ void CWaitCommandsAI::Wait::SendCommand(const Command& cmd, const CUnitSet& unitSet) { - GML_RECMUTEX_LOCK(sel); // SendCommand - if (unitSet.empty()) { return; } @@ -668,8 +664,6 @@ CWaitCommandsAI::DeathWait::DeathWait(const Command& cmd) : Wait(CMD_WAITCODE_DEATHWAIT) { - GML_RECMUTEX_LOCK(sel); // DeathWait - const CUnitSet& selUnits = selectedUnitsHandler.selectedUnits; if (cmd.params.size() == 1) { @@ -881,8 +875,6 @@ CWaitCommandsAI::SquadWait::SquadWait(const Command& cmd) : Wait(CMD_WAITCODE_SQUADWAIT) { - GML_RECMUTEX_LOCK(sel); // SquadWait - if (cmd.params.size() != 1) { return; } @@ -1037,8 +1029,6 @@ CWaitCommandsAI::GatherWait::GatherWait(const Command& cmd) : Wait(CMD_WAITCODE_GATHERWAIT) { - GML_RECMUTEX_LOCK(sel); // GatherWait - if (!cmd.params.empty()) { return; } diff -Nru spring-96.0~14.04~ppa4/rts/Game/WaitCommandsAI.h spring-98.0~14.04~ppa6/rts/Game/WaitCommandsAI.h --- spring-96.0~14.04~ppa4/rts/Game/WaitCommandsAI.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/WaitCommandsAI.h 2014-10-07 20:09:51.000000000 +0000 @@ -19,12 +19,12 @@ class CWaitCommandsAI { - CR_DECLARE_STRUCT(CWaitCommandsAI); - CR_DECLARE_SUB(Wait); - CR_DECLARE_SUB(TimeWait); - CR_DECLARE_SUB(DeathWait); - CR_DECLARE_SUB(SquadWait); - CR_DECLARE_SUB(GatherWait); + CR_DECLARE_STRUCT(CWaitCommandsAI) + CR_DECLARE_SUB(Wait) + CR_DECLARE_SUB(TimeWait) + CR_DECLARE_SUB(DeathWait) + CR_DECLARE_SUB(SquadWait) + CR_DECLARE_SUB(GatherWait) public: CWaitCommandsAI(); ~CWaitCommandsAI(); @@ -63,7 +63,7 @@ private: // Wait Base Class class Wait : public CObject { - CR_DECLARE(Wait); + CR_DECLARE(Wait) public: virtual ~Wait(); virtual void DependentDied(CObject* o) = 0; // from CObject @@ -106,7 +106,7 @@ // TimeWait class TimeWait : public Wait { - CR_DECLARE(TimeWait); + CR_DECLARE(TimeWait) public: static TimeWait* New(const Command& cmd, CUnit* unit); static TimeWait* New(int duration, CUnit* unit); @@ -131,7 +131,7 @@ // DeathWait class DeathWait : public Wait { - CR_DECLARE(DeathWait); + CR_DECLARE(DeathWait) public: static DeathWait* New(const Command& cmd); ~DeathWait(); @@ -153,7 +153,7 @@ // SquadWait class SquadWait : public Wait { - CR_DECLARE(SquadWait); + CR_DECLARE(SquadWait) public: static SquadWait* New(const Command& cmd); ~SquadWait(); @@ -175,7 +175,7 @@ // GatherWait class GatherWait : public Wait { - CR_DECLARE(GatherWait); + CR_DECLARE(GatherWait) public: static GatherWait* New(const Command& cmd); ~GatherWait(); diff -Nru spring-96.0~14.04~ppa4/rts/Game/WordCompletion.cpp spring-98.0~14.04~ppa6/rts/Game/WordCompletion.cpp --- spring-96.0~14.04~ppa4/rts/Game/WordCompletion.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Game/WordCompletion.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -118,6 +118,8 @@ words["/setminspeed "] = sl; words["/kick "] = sl; words["/kickbynum "] = sl; + words["/mute "] = sl; + words["/mutebynum "] = sl; } diff -Nru spring-96.0~14.04~ppa4/rts/lib/CMakeLists.txt spring-98.0~14.04~ppa6/rts/lib/CMakeLists.txt --- spring-96.0~14.04~ppa4/rts/lib/CMakeLists.txt 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -10,7 +10,6 @@ ADD_SUBDIRECTORY(assimp) if (NOT HEADLESS_SYSTEM) - Add_Subdirectory(gml) if (USE_LIBSQUISH) ADD_SUBDIRECTORY(rg-etc1) diff -Nru spring-96.0~14.04~ppa4/rts/lib/gml/CMakeLists.txt spring-98.0~14.04~ppa6/rts/lib/gml/CMakeLists.txt --- spring-96.0~14.04~ppa4/rts/lib/gml/CMakeLists.txt 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/gml/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ - - -ADD_DEFINITIONS(-DUSE_GML) - -# USE_GML requires this -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${NO_TLS_DIRECT_SEG_REFS}") - -# USE_GML_SIM requires USE_GML -ADD_DEFINITIONS(-DUSE_GML_SIM) - -if (USE_GML_DEBUG) - ADD_DEFINITIONS(-DUSE_GML_DEBUG) -endif (USE_GML_DEBUG) - -FIND_PACKAGE(SDL REQUIRED) -FIND_PACKAGE_STATIC(GLEW 1.5.1 REQUIRED) -INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR} ${GLEW_INCLUDE_DIR}) - -SET(gmlSources - "ThreadSafeContainers.cpp" - "gml.cpp" - "gml_base.cpp" - "speedy-tls.cpp" - ) - -ADD_LIBRARY(gml STATIC EXCLUDE_FROM_ALL ${gmlSources}) -TARGET_LINK_LIBRARIES(gml ${SDL_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${GLEW_LIBRARIES}) - diff -Nru spring-96.0~14.04~ppa4/rts/lib/gml/gml_base.cpp spring-98.0~14.04~ppa6/rts/lib/gml/gml_base.cpp --- spring-96.0~14.04~ppa4/rts/lib/gml/gml_base.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/gml/gml_base.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,185 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#ifdef USE_GML - -#include "gml_base.h" -#include "gmlsrv.h" - -#include "Game/UI/KeyBindings.h" -#include "Lua/LuaConfig.h" -#include "Sim/Units/Unit.h" -#include "Sim/Misc/GlobalSynced.h" -#include "System/OffscreenGLContext.h" -#include "System/SpringApp.h" -#include "System/Config/ConfigHandler.h" -#include "System/Log/ILog.h" -#include "System/Platform/Threading.h" -#include "System/Platform/Watchdog.h" - -//GPU debug tools report calls to gl functions from different threads as errors -> disable in safemode -CONFIG(bool, MultiThreadShareLists).defaultValue(true).safemodeValue(false).description("render-helper threads"); -CONFIG(bool, MultiThreadSim).defaultValue(true); - - -extern gmlClientServer *gmlProcessor; - -COffscreenGLContext* ogc[GML_MAX_NUM_THREADS] = { NULL }; - - - -#if GML_ENABLE_SIM - -static void gmlSimLoop(void*) -{ - try { - while(gmlKeepRunning && !gmlStartSim) { - // the other thread may ClearPrimaryTimers(), so it is not enough to disable the watchdog timer once - Watchdog::ClearTimer(WDT_SIM, true); - SDL_Delay((gs->frameNum > 1) ? 500 : 100); - } - - if (gmlKeepRunning) { - if (gmlShareLists) - ogc[0]->WorkerThreadPost(); - - Threading::SetAffinityHelper("Sim", configHandler->GetUnsigned("SetCoreAffinitySim")); - - Watchdog::ClearTimer(WDT_SIM); - - while(gmlKeepRunning) { - if(!gmlMultiThreadSim) { - while(!gmlMultiThreadSim && gmlKeepRunning) { - Watchdog::ClearTimer(WDT_SIM, true); - SDL_Delay(500); - } - } - - //FIXME activeController could change while processing this branch. Better make it safe with a mutex? - if (activeController) { - Watchdog::ClearTimer(WDT_SIM); - gmlProcessor->ExpandAuxQueue(); - - if (!Threading::UpdateGameController(activeController)) - gmlKeepRunning = false; - - gmlProcessor->GetQueue(); - } - - boost::thread::yield(); - } - - if(gmlShareLists) - ogc[0]->WorkerThreadFree(); - } - } CATCH_SPRING_ERRORS -} - -#endif - -namespace GML { - - void Init() - { - if (!Enabled()) - return; - gmlShareLists = configHandler->GetBool("MultiThreadShareLists"); - if (!gmlShareLists) { - gmlMaxServerThreadNum = GML_LOAD_THREAD_NUM; - gmlMaxShareThreadNum = GML_LOAD_THREAD_NUM; - gmlNoGLThreadNum = GML_SIM_THREAD_NUM; - } - gmlThreadCountOverride = configHandler->GetInt("MultiThreadCount"); - gmlThreadCount = GML_CPU_COUNT; - - if (gmlShareLists) { // create offscreen OpenGL contexts - for (int i = 0; i < gmlThreadCount; ++i) - ogc[i] = new COffscreenGLContext(); - } - - gmlProcessor = new gmlClientServer; - #if GML_ENABLE_SIM - gmlMultiThreadSim = configHandler->GetBool("MultiThreadSim"); - - gmlKeepRunning = true; - gmlStartSim = false; - - // start sim thread - gmlProcessor->AuxWork(&gmlSimLoop, NULL); - #endif - } - - void Exit() - { - if (!Enabled()) - return; - if (gmlProcessor) { - #if GML_ENABLE_SIM - gmlKeepRunning = false; // wait for sim to finish - while (!gmlProcessor->PumpAux()) - boost::thread::yield(); - #endif - delete gmlProcessor; - gmlProcessor = NULL; - - if (gmlShareLists) { - for (int i = 0; i < gmlThreadCount; ++i) { - delete ogc[i]; - ogc[i] = NULL; - } - } - } - } - - void PumpAux() - { - #if GML_ENABLE_SIM - if (gmlProcessor) - gmlProcessor->PumpAux(); - #endif - } - - bool SimThreadRunning() - { - if (!Enabled()) - return false; - #if GML_ENABLE_SIM - if (!gmlStartSim && gmlMultiThreadSim && gs->frameNum > 0) { - gmlStartSim = true; - } - return (gmlStartSim && gmlMultiThreadSim); - #else - return false; - #endif - } - - void PrintStartupMessage(int showMTInfo) { - if (showMTInfo == -1) - return; - if (showMTInfo != MT_LUA_NONE) { - if (showMTInfo == MT_LUA_SINGLE || showMTInfo == MT_LUA_SINGLE_BATCH || showMTInfo == MT_LUA_DUAL_EXPORT) { - LOG("[Threading] Multithreading is enabled but currently running in compatibility mode %d", showMTInfo); - } else { - LOG("[Threading] Multithreading is enabled and currently running in mode %d", showMTInfo); - } - if (showMTInfo == MT_LUA_SINGLE) { - CKeyBindings::HotkeyList lslist = keyBindings->GetHotkeys("luaui selector"); - std::string lskey = lslist.empty() ? "" : " (press " + lslist.front() + ")"; - LOG("[Threading] Games that use lua based rendering may run very slow in this mode, " - "indicated by a high LUA-SYNC-CPU(MT) value displayed in the upper right corner"); - LOG("[Threading] Consider MultiThreadLua = %d in the settings to improve performance, " - "or try to disable LuaShaders and all rendering widgets%s", (int)MT_LUA_SINGLE_BATCH, lskey.c_str()); - } else if (showMTInfo == MT_LUA_SINGLE_BATCH) { - LOG("[Threading] Games that use lua gadget based rendering may run very slow in this mode, " - "indicated by a high LUA-SYNC-CPU(MT) value displayed in the upper right corner"); - } else if (showMTInfo == MT_LUA_DUAL_EXPORT) { - LOG("[Threading] Games that use lua gadgets which export data may run very slow in this mode, " - "indicated by a high LUA-EXP-SIZE(MT) value displayed in the upper right corner"); - } - } else if (configHandler->GetBool("EnableUnsafeAndBrokenMT")) { - LOG("[Threading] Multithreading is disabled because the game or system appears incompatible"); - LOG("[Threading] MultiThreadCount > 1 in the settings will forcefully enable multithreading"); - } - } -}; - -#endif // USE_GML diff -Nru spring-96.0~14.04~ppa4/rts/lib/gml/gml_base.h spring-98.0~14.04~ppa6/rts/lib/gml/gml_base.h --- spring-96.0~14.04~ppa4/rts/lib/gml/gml_base.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/gml/gml_base.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#ifndef GML_BASE_H_ -#define GML_BASE_H_ - -#include "gmlcls.h" - -#ifdef USE_GML -#include "System/Misc/SpringTime.h" - -namespace GML { - void Init(); - void Exit(); - void PumpAux(); - bool SimThreadRunning(); - void PrintStartupMessage(int showMTInfo); - inline bool IsSimThread() { return gmlThreadNumber == GML_SIM_THREAD_NUM; } - inline bool ShareLists() { return gmlShareLists; } - inline bool MultiThreadSim() { return gmlMultiThreadSim; } - inline void MultiThreadSim(bool mts) { gmlMultiThreadSim = mts; } - inline int ThreadNumber() { return gmlThreadNumber; } - inline void ThreadNumber(int num) { set_threadnum(num); } - inline int ThreadCount() { return gmlThreadCount; } - inline void SetLuaUIState(lua_State *L) { gmlLuaUIState = L; } - inline void SetCheckCallChain(bool cc) { gmlCheckCallChain = cc; } - inline void EnableCallChainWarnings(bool cw) { gmlCallChainWarning = (cw ? 0 : GML_MAX_CALL_CHAIN_WARNINGS); } - inline unsigned int UpdateTicks() { gmlNextTickUpdate = 100; return gmlCurrentTicks = spring_clock::GetTicks(); } - inline void GetTicks(unsigned int &var) { var = (--gmlNextTickUpdate > 0) ? gmlCurrentTicks : UpdateTicks(); } - inline bool ServerActive() { return gmlServerActive; } -}; -#else -namespace GML { - inline void Init() {} - inline void Exit() {} - inline void PumpAux() {} - inline void PrintStartupMessage(int showMTInfo) {} - inline bool SimThreadRunning() { return false; } - inline bool IsSimThread() { return false; } - inline bool ShareLists() { return false; } - inline bool MultiThreadSim() { return false; } - inline void MultiThreadSim(bool mts) {} - inline int ThreadNumber() { return 0; } - inline void ThreadNumber(int num) { } - inline int ThreadCount() { return 1; } - inline void SetLuaUIState(void *L) {} - inline void SetCheckCallChain(bool cc) {} - inline void EnableCallChainWarnings(bool cw) {} - inline unsigned int UpdateTicks() { return 0; } - inline void GetTicks(unsigned int &var) {} - inline bool ServerActive() { return false; } -}; -#endif - -#endif // GML_BASE_H_ diff -Nru spring-96.0~14.04~ppa4/rts/lib/gml/gmlcls.h spring-98.0~14.04~ppa6/rts/lib/gml/gmlcls.h --- spring-96.0~14.04~ppa4/rts/lib/gml/gmlcls.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/gml/gmlcls.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,1110 +0,0 @@ -// GML - OpenGL Multithreading Library -// for Spring http://springrts.com -// Author: Mattias "zerver" Radeskog -// (C) Ware Zerver Tech. http://zerver.net -// Ware Zerver Tech. licenses this library -// to be used, distributed and modified -// freely for any purpose, as long as -// this notice remains unchanged - -#ifndef GMLCLASSES_H -#define GMLCLASSES_H - -#include "gmlcnt.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "gmlcnf.h" - -extern bool gmlShareLists; // use glShareLists to allow certain opengl calls in sim and rendering helper threads, unfortunately this may reduce the FPS a bit -extern int gmlMaxServerThreadNum; -extern int gmlMaxShareThreadNum; -extern int gmlNoGLThreadNum; -extern volatile bool gmlMultiThreadSim; -extern volatile bool gmlStartSim; -extern volatile bool gmlKeepRunning; -struct lua_State; -extern lua_State *gmlLuaUIState; -extern bool gmlCheckCallChain; -extern int gmlCallChainWarning; -extern int gmlNextTickUpdate; -extern unsigned gmlCurrentTicks; -extern volatile bool gmlServerActive; - -#define GML_QUOTE(x) #x - -extern bool ThreadRegistered(); - -// memory barriers for different platforms -#if defined(__APPLE__) -# include -# define GML_MEMBAR OSMemoryBarrier() -#elif defined(__GNUC__) -# if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) -# define GML_MEMBAR __sync_synchronize() -# elif defined( __ppc__ ) || defined( __powerpc__) || defined( __PPC__ ) -# define GML_MEMBAR asm volatile("sync":::"memory") -# elif defined( __i386__ ) || defined( __i486__ ) || defined( __i586__ ) || defined( __i686__ ) || defined( __x86_64__ ) -# define GML_MEMBAR asm volatile("mfence":::"memory") -# endif -#elif defined(_MSC_VER) -# if (_MSC_VER >= 1400) -# define GML_MEMBAR // no barrier needed for MSVS 2005 -# else -# define GML_MEMBAR MemoryBarrier() // _asm {lock add [esp], 0} -# endif -#elif defined(__BORLANDC__) -# define GML_MEMBAR _asm {lock add [esp], 0} -#endif - -#ifdef GML_MEMBAR -# define GML_ORDERED_VOLATILE 1 -#else -# define GML_ORDERED_VOLATILE 0 -# define GML_MEMBAR -#endif - -// optimize by assuming volatile accesses are -// guaranteed not to be reordered (MSVS 2005 or memory barrier needed) -// http://msdn.microsoft.com/en-us/library/12a04hfd(VS.80).aspx -// http://msdn.microsoft.com/en-us/library/ms686355(VS.85).aspx -// http://msdn.microsoft.com/en-us/library/bb310595(VS.85).aspx - -#if GML_ORDERED_VOLATILE -# define GML_VOLATILE(x) *(x volatile *)& -# define GML_MUTEX -# define GML_MUTEX_LOCK() -# define GML_MUTEX_UNLOCK() -#else -# define GML_VOLATILE(x) -# define GML_MUTEX gmlMutex mutex -# define GML_MUTEX_LOCK() mutex.Lock() -# define GML_MUTEX_UNLOCK() mutex.Unlock() -#endif - -#ifdef _MSC_VER -# define GML_TYPENAME typename -#else -# define GML_TYPENAME -#endif - -#ifndef _WIN32 //defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) -# define GML_USE_SPEEDY_TLS 1 -# include "System/Platform/errorhandler.h" -# include "speedy-tls.h" -#else -# define GML_USE_SPEEDY_TLS 0 -#endif - -#define set_threadnum(val) gmlThreadNumber=val - -#if GML_ENABLE -# ifdef _MSC_VER -# if GML_MSC_TLS_OPT -inline int get_threadnum(void) { - int val; - __asm { -# if !defined(_WIN64) || !GML_64BIT_USE_GS - mov EAX, FS:[14h] -# else - mov EAX, GS:[28h] -# endif - mov [val], EAX - } - return val; -} -# define gmlThreadNumber get_threadnum() -# undef set_threadnum -inline void set_threadnum(int val) { - if (ThreadRegistered()) - return; - - __asm { - mov EAX, [val] -# if !defined(_WIN64) || !GML_64BIT_USE_GS - mov FS:[14h], EAX -# else - mov GS:[28h], EAX -# endif - } -} -# else -extern __declspec(thread) int gmlThreadNumber; -# endif -# else -# if GML_GCC_TLS_FIX || GML_USE_SPEEDY_TLS -inline int get_threadnum(void) { - int val; -# if GML_USE_SPEEDY_TLS - speedy_tls_get_int32(0, 0, 4, val); -# else -# if !defined(_WIN64) || !GML_64BIT_USE_GS - __asm__("mov %%fs:0x14, %0" : "=r" (val) : : ); -# else - __asm__("mov %%gs:0x28, %0" : "=r" (val) : : ); -# endif -# endif - return val; -} -# define gmlThreadNumber get_threadnum() -# undef set_threadnum -inline void set_threadnum(int val) { - if (ThreadRegistered()) - return; - -# if GML_USE_SPEEDY_TLS - if (speedy_tls_init(sizeof(int))<0) { // this works because we only set the thread number once per thread - handleerror(NULL, "Failed to initialize Thread Local Storage", "GML error:", MBF_OK | MBF_EXCL); - } - speedy_tls_put_int32(0, 0, 4, val); -# else -# if !defined(_WIN64) || !GML_64BIT_USE_GS - __asm__ __volatile__("mov %0,%%fs:0x14" : : "r" (val)); -# else - __asm__ __volatile__("mov %0,%%gs:0x28" : : "r" (val)); -# endif -# endif -} -# else -extern __thread int gmlThreadNumber; -# endif -# endif -#else -extern int gmlThreadNumber; -#endif - -extern int gmlThreadCount; -extern int gmlThreadCountOverride; -#define GML_CPU_COUNT (gmlThreadCountOverride ? gmlThreadCountOverride : boost::thread::hardware_concurrency() ) -#define GML_IF_SERVER_THREAD(thread) if(!GML_ENABLE || (thread <= gmlMaxServerThreadNum)) -#define GML_IF_SHARE_THREAD(thread) if(!GML_ENABLE || (thread <= gmlMaxShareThreadNum)) -extern int gmlItemsConsumed; - -typedef unsigned char BYTE; -typedef int BOOL_; - -#define TRUE 1 -#define FALSE 0 -#define EXTERN -#define GML_VP_ARRAY_BUFFER (1<<(16+GL_VERTEX_ARRAY-GL_VERTEX_ARRAY)) -#define GML_CP_ARRAY_BUFFER (1<<(16+GL_COLOR_ARRAY-GL_VERTEX_ARRAY)) -#define GML_TCP_ARRAY_BUFFER (1<<(16+GL_TEXTURE_COORD_ARRAY-GL_VERTEX_ARRAY)) -#define GML_IP_ARRAY_BUFFER (1<<(16+GL_INDEX_ARRAY-GL_VERTEX_ARRAY)) -#define GML_NP_ARRAY_BUFFER (1<<(16+GL_NORMAL_ARRAY-GL_VERTEX_ARRAY)) -#define GML_EFP_ARRAY_BUFFER (1<<(16+GL_EDGE_FLAG_ARRAY-GL_VERTEX_ARRAY)) -#define GML_ELEMENT_ARRAY_BUFFER (1<<29) - -#ifdef _WIN32 -# ifdef __MINGW32__ -# define GML_APIENTRY __stdcall -# elif (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__) -# define GML_APIENTRY __stdcall -# else -# define GML_APIENTRY -# endif -# ifndef GML_GLAPIENTRY -# define GML_GLAPIENTRY GML_APIENTRY -# endif -#else /* _UNIX */ -# define GML_APIENTRY -# ifndef GML_GLAPIENTRY -# define GML_GLAPIENTRY -# endif -#endif /* _WIN32 */ - -template -class gmlBaseMutexLock { - char lockdata[sizeof(T)]; -public: - gmlBaseMutexLock(U& m) { - if (GML::Enabled()) - new (lockdata) T(m); - } - virtual ~gmlBaseMutexLock() { - if (GML::Enabled()) { -#if (BOOST_VERSION >= 103500) - typedef typename boost::template unique_lock lock_t; - ((T*)lockdata)->lock_t::~unique_lock(); -#else - typedef typename boost::template scoped_lock lock_t; - ((T*)lockdata)->lock_t::~scoped_lock(); -#endif - } - } -}; - -typedef gmlBaseMutexLock gmlMutexScopedLock; -typedef gmlBaseMutexLock gmlRecursiveMutexScopedLock; - - -class gmlRecursiveScopedLock { - char sl_lock[sizeof(boost::recursive_mutex::scoped_lock)]; -#if GML_DEBUG_MUTEX - boost::recursive_mutex* m1; -#endif -public: - gmlRecursiveScopedLock(boost::recursive_mutex& m, bool locked = true) { - if (GML::Enabled()) { -#if (BOOST_VERSION >= 103500) - if (locked) { - new (sl_lock) boost::recursive_mutex::scoped_lock(m); - } else { - new (sl_lock) boost::recursive_mutex::scoped_lock(m, boost::defer_lock); - } -#else - new (sl_lock) boost::recursive_mutex::scoped_lock(m, locked); -#endif -#if GML_DEBUG_MUTEX - if (locked) { - m1 = &m; - GML_STDMUTEX_LOCK(lm); - std::map& lockmmap = lockmmaps[GML::ThreadNumber()]; - std::map::iterator locki = lockmmap.find(m1); - if (locki == lockmmap.end()) { - lockmmap[m1] = 1; - } else { - lockmmap[m1] = (*locki).second + 1; - } - } else { - m1 = NULL; - } -#endif - } - } - virtual ~gmlRecursiveScopedLock() { - if (GML::Enabled()) { -#if (BOOST_VERSION >= 103500) - ((boost::recursive_mutex::scoped_lock*)sl_lock)->~unique_lock(); -#else - ((boost::recursive_mutex::scoped_lock*)sl_lock)->~scoped_lock(); -#endif -#if GML_DEBUG_MUTEX - if (m1) { - GML_STDMUTEX_LOCK(lm); - std::map& lockmmap = lockmmaps[GML::ThreadNumber()]; - lockmmap[m1] = (*lockmmap.find(m1)).second - 1; - } -#endif - } - } -}; - -// gmlMutex - exploits the boost mutex to get direct access to the Lock/Unlock methods -class gmlMutex { - boost::mutex sl_mutex; - BYTE sl_lock[sizeof(boost::mutex::scoped_lock)*GML_MAX_NUM_THREADS]; -public: - gmlMutex() { - } - virtual ~gmlMutex() { - } - void Lock(int wait = 0) { - if (GML::Enabled()) { - extern volatile bool gmlMutexLockWait; - if (wait < 0) - gmlMutexLockWait = true; - else if (wait > 0) { - // a really weird bug, this mutex does not seem to immediately wake up waiting - // threads when unlocked, and this can cause a live-lock unless we wait a bit - while (gmlMutexLockWait) - boost::thread::yield(); - } - new (((boost::mutex::scoped_lock *)sl_lock)+gmlThreadNumber) boost::mutex::scoped_lock(sl_mutex); - if (wait < 0) - gmlMutexLockWait = false; - } - } - void Unlock() { - if (GML::Enabled()) { -#if (BOOST_VERSION >= 103500) - (((boost::mutex::scoped_lock *)sl_lock)+gmlThreadNumber)->~unique_lock(); -#else - (((boost::mutex::scoped_lock *)sl_lock)+gmlThreadNumber)->~scoped_lock(); -#endif - } - } -}; - -// gmlLock - combines boost mutex+lock into one covenient package -class gmlLock { - boost::try_mutex sl_mutex; - BYTE sl_lock[sizeof(boost::try_mutex::scoped_try_lock)*GML_MAX_NUM_THREADS]; - -public: - gmlLock() { - } - virtual ~gmlLock() { - } - bool Lock() { - boost::try_mutex::scoped_try_lock *lock=((boost::try_mutex::scoped_try_lock *)sl_lock)+gmlThreadNumber; -#if (BOOST_VERSION >= 103600) - new (lock) boost::try_mutex::scoped_try_lock(sl_mutex); - if(lock->owns_lock()) - return true; - lock->~try_lock_wrapper(); -#elif (BOOST_VERSION >= 103500) - new (lock) boost::try_mutex::scoped_try_lock(sl_mutex,boost::try_to_lock); - if(lock->owns_lock()) - return true; - lock->~unique_lock(); -#else - new (lock) boost::try_mutex::scoped_try_lock(sl_mutex); - if(lock->locked()) - return true; - lock->~scoped_try_lock(); -#endif - return false; - } - void Unlock() { -#if (BOOST_VERSION >= 103600) - (((boost::try_mutex::scoped_try_lock *)sl_lock)+gmlThreadNumber)->~try_lock_wrapper(); -#elif (BOOST_VERSION >= 103500) - (((boost::try_mutex::scoped_try_lock *)sl_lock)+gmlThreadNumber)->~unique_lock(); -#else - (((boost::try_mutex::scoped_try_lock *)sl_lock)+gmlThreadNumber)->~scoped_try_lock(); -#endif - } -}; - -#include - -template -class gmlVectorIter { -public: - T *p; - gmlVectorIter():p(NULL) {} - gmlVectorIter(T *d) {p=d;} - void operator=(const GML_TYPENAME gmlVectorIter &i) {p=i.p;} - GML_TYPENAME gmlVectorIter &operator++() {++p; return *this;} - GML_TYPENAME gmlVectorIter operator++(int) {return GML_TYPENAME gmlVectorIter(p++);} - int operator!=(const GML_TYPENAME gmlVectorIter &i) const {return p!=i.p;} - - ptrdiff_t operator-(const GML_TYPENAME gmlVectorIter &i) const {return p-i.p;} - int operator<(const GML_TYPENAME gmlVectorIter &i) const {return p &operator--() {--p; return *this;} - GML_TYPENAME gmlVectorIter operator--(int) {return GML_TYPENAME gmlVectorIter(p--);} - GML_TYPENAME gmlVectorIter operator+(int i) const {return GML_TYPENAME gmlVectorIter(p+i);} - GML_TYPENAME gmlVectorIter operator-(int i) const {return GML_TYPENAME gmlVectorIter(p-i);} - int operator==(const GML_TYPENAME gmlVectorIter &i) const {return p==i.p;} - T &operator*() {return *p;} - - typedef std::random_access_iterator_tag iterator_category; - typedef T value_type; - typedef ptrdiff_t difference_type; - typedef T* pointer; - typedef T& reference; -}; - -// gmlClassVector - partially thread safe vector class for storing advanced types (classes etc.) -// The array will be resized automatically when using the functions acquire() and release() -// using "volatile" optimizations result in about 300% performance gain under normal load -// high load will make "volatile" optimizations run about 3 times slower compared to mutex -template -class gmlClassVector { - T *data; -#if GML_ORDERED_VOLATILE - gmlCount count; - volatile long added; -#else - gmlMutex mutex; - long added; -#endif - int maxsize; - int doshrink; - int shrinksize; - int nalloc; - -public: - gmlClassVector():doshrink(0),shrinksize(0),nalloc(0), -#if GML_ORDERED_VOLATILE - count(0), -#endif - added(0) { - data=(T *)malloc(1*sizeof(T)); - maxsize=1; - } - - ~gmlClassVector() { - if(added>nalloc) - nalloc=added; - for(int i=0; i iterator; - - iterator begin() { - return iterator(data); - } - - iterator end() { - return iterator(data+added); - } - - long size() const { - return added; - } - - const bool empty() const { - return !added; - } - - const T &operator[](int i) const { - return data[i]; - } - - T &operator[](int i) { - return data[i]; - } - - T &acquire(int i) { // thread safe -#if GML_ORDERED_VOLATILE - long sz; - while(TRUE) { - if(added<=i) { - if(count<=i) { - if((sz=++count)<=i+1) { - if(added==sz-1) { - T *da=GML_VOLATILE(T *) data; - int ms; - if(sz==(ms=GML_VOLATILE(int) maxsize)) - Expand(da,ms); - new ((void *)(volatile T *)(da+sz-1)) T(); - GML_MEMBAR; - ++added; - } - else { - --count; - while(count!=added) - boost::thread::yield(); - } - } - else { - --count; - } - } - } - else { - long sz=++count; - if(added==sz-1) { - return (GML_VOLATILE(T *)data)[i]; - } - --count; - while(count!=added) - boost::thread::yield(); - } - } -#else - mutex.Lock(); - while(added<=i) { - long sz=++added; - if(sz==maxsize) - Expand(data,maxsize); - new (data+sz-1) T(); - } - return data[i]; -#endif - } - - void release() { // thread safe -#if GML_ORDERED_VOLATILE - --count; -#else - mutex.Unlock(); -#endif - } - - void push_back(const T &d) { // thread safe -#if GML_ORDERED_VOLATILE - while(TRUE) { - long sz=++count; - if(added==sz-1) { - T *da=GML_VOLATILE(T *) data; - int ms; - if(sz==(ms=GML_VOLATILE(int) maxsize)) - Expand(da,ms); - new ((void *)(volatile T *)(da+sz-1)) T(d); - GML_MEMBAR; - ++added; - return; - } - else { - --count; - while(count!=added) - boost::thread::yield(); - } - } -#else - mutex.Lock(); - long sz=++added; - if(sz==maxsize) - Expand(data,maxsize); - new (data+sz-1) T(d); - mutex.Unlock(); -#endif - } - - // this is probably overkill since realloced memory will never be cached in registers anyway - BYTE *volatile_realloc(BYTE *dt, const int osz, const int sz) { -#if GML_ORDERED_VOLATILE - BYTE *dtn=(BYTE *)malloc(sz); - for(int i=0; i>1; - doshrink=0; - for(int i=ms; inalloc) - nalloc=added; - long sz=added; -#if GML_ORDERED_VOLATILE - count%=0; -#endif - added=0; - if(sz>=shrinksize) - doshrink=0; - else if(++doshrink>=10) - Shrink(); - } -}; - -// gmlVector - partially thread safe vector class for storing simple types (int, pointer etc) -// using "volatile" optimizations result in about 300% performance gain under normal load -// high load will make "volatile" optimizations run about 3 times slower compared to mutex -template -class gmlVector { - T *data; -#if GML_ORDERED_VOLATILE - gmlCount count; - volatile long added; -#else - gmlMutex mutex; - long added; -#endif - int maxsize; - int doshrink; - int shrinksize; - -public: - gmlVector() : -#if GML_ORDERED_VOLATILE - count(0), -#endif - added(0), - doshrink(0), - shrinksize(0) - { - data=(T *)malloc(1*sizeof(T)); - maxsize=1; - } - gmlVector(const GML_TYPENAME gmlVector &vec): -#if GML_ORDERED_VOLATILE - count(0), -#endif - added(0) { - memcpy(this,&vec,sizeof(GML_TYPENAME gmlVector)); - data=(T *)malloc(vec.maxsize*sizeof(T)); - memcpy(data,vec.data,vec.maxsize*sizeof(T)); - } - - void swap(GML_TYPENAME gmlVector &vec) { -#if GML_ORDERED_VOLATILE - long tcount = count; - count %= vec.count; - vec.count %= tcount; -#endif - T *tdata = data; - long tadded = added; - int tmaxsize = maxsize; - int tdoshrink = doshrink; - int tshrinksize = shrinksize; - data = vec.data; - added = vec.added; - maxsize = vec.maxsize; - doshrink = vec.doshrink; - shrinksize = vec.shrinksize; - vec.data = tdata; - vec.added = tadded; - vec.maxsize = tmaxsize; - vec.doshrink = tdoshrink; - vec.shrinksize = tshrinksize; - } - - gmlVector &operator=(const GML_TYPENAME gmlVector &vec) { -#if GML_ORDERED_VOLATILE - count%=vec.count; -#endif - added=vec.added; - if(added>=maxsize) { - maxsize=vec.maxsize; - data=(T *)realloc(data, maxsize*sizeof(T)); - shrinksize=vec.shrinksize; - } - memcpy(data,vec.data,added*sizeof(T)); - if(added>=shrinksize) - doshrink=0; - else if(++doshrink>=10) - Shrink(); - return *this; - } - - ~gmlVector() { - free(data); - } - - typedef GML_TYPENAME gmlVectorIter iterator; - - iterator begin() const { - return iterator(data); - } - - iterator end() const { - return iterator(data+added); - } - - const long size() const { - return added; - } - - const bool empty() const { - return !added; - } - - const T &operator[](const int i) const { - return data[i]; - } - - T &operator[](const int i) { - return data[i]; - } - - void push_back(const T &d) { // thread safe -#if GML_ORDERED_VOLATILE - long sz=++count; - while(added!=sz-1) - boost::thread::yield(); - T *da=GML_VOLATILE(T *) data; - int ms; - if(sz==(ms=GML_VOLATILE(int) maxsize)) - Expand(da,ms); - *(volatile T *)(da+sz-1)=d; - GML_MEMBAR; - ++added; -#else - mutex.Lock(); - long sz=++added; - if(sz==maxsize) - Expand(data,maxsize); - data[sz-1]=d; - mutex.Unlock(); -#endif - } - - // this is probably overkill since realloced memory will never be cached in registers anyway - BYTE *volatile_realloc(BYTE *dt, const int osz, const int sz) { -#if GML_ORDERED_VOLATILE - BYTE *dtn=(BYTE *)malloc(sz); - for(int i=0; i>1; - doshrink=0; - data=(T *)realloc(data,ms*sizeof(T)); - maxsize=ms; - } - - void clear() { - long sz=added; -#if GML_ORDERED_VOLATILE - count%=0; -#endif - added=0; - if(sz>=shrinksize) - doshrink=0; - else if(++doshrink>=10) - Shrink(); - } -}; - - -template -class gmlItemSequenceServer { - typedef void (GML_GLAPIENTRY * delitemseqfun)(T, S); - C genfun; - delitemseqfun delfun; - gmlCount req; - gmlCount avail; - int pregen; - int arr_size; - T *item_arr; - gmlCount req_large; - gmlCount avail_large; - gmlCount size_large; - int pregen_large; - int large_arr_size; - T *large_item_arr; - S *large_size_arr; - GML_MUTEX; - -public: - gmlItemSequenceServer(C gf, delitemseqfun df, int sz, int pg, int sz_l, int pg_l): - req(0),avail(0),req_large(0),avail_large(0),size_large(2) { - genfun=gf; - delfun=df; - pregen=pg; - arr_size=sz; - item_arr=new T[arr_size]; - memset(item_arr,0,arr_size*sizeof(T)); - pregen_large=pg_l; - large_arr_size=sz_l; - large_item_arr=new T[large_arr_size]; - large_size_arr=new S[large_arr_size]; - memset(large_item_arr,0,large_arr_size*sizeof(T)); - memset(large_size_arr,0,large_arr_size*sizeof(S)); - } - - virtual ~gmlItemSequenceServer() { - delete [] item_arr; - delete [] large_item_arr; - delete [] large_size_arr; - } - - inline void GenerateItems() { - // small - int i; - while(availn) - (*delfun)(ip+n,szv-n); // del excessive - if(szv=n) - return ip; - } - } -}; - - -template -class gmlSingleItemServer { - C genfun; - gmlCount req; - gmlCount avail; - int pregen; - int arr_size; - T *arr; - GML_MUTEX; - -public: - gmlSingleItemServer(C gf, int sz, int pg):req(0),avail(0) { - genfun=gf; - pregen=pg; - arr_size=sz; - arr=new T[arr_size]; - memset(arr,0,arr_size*sizeof(T)); - } - - virtual ~gmlSingleItemServer() { - delete [] arr; - } - - inline void GenerateItems() { - int i; - while(avail -class gmlMultiItemServer { - C genfun; - gmlCount req; - gmlCount avail; - int pregen; - int arr_size; - T *arr; - GML_MUTEX; - -public: - gmlMultiItemServer(C gf, int sz, int pg):req(0),avail(0) { - genfun=gf; - pregen=pg; - arr_size=sz; - arr=new T[arr_size]; - memset(arr,0,arr_size*sizeof(T)); - } - - virtual ~gmlMultiItemServer() { - delete [] arr; - } - - inline void GenerateItems() { - int i; - while(avail -class gmlCircularQueue { - CR_DECLARE_STRUCT(gmlCircularQueue); - T elements[S+1]; - size_t front,back; - size_t csize,msize; -public: - gmlCircularQueue(): front(0), back(0), csize(0), msize(S) { - } - ~gmlCircularQueue() { - } - void push_back(const T &a) { - elements[back] = a; - if(csize == msize) { - if(front == msize) - front = 0; - else - ++front; - } - else - ++csize; - if(back == msize) - back = 0; - else - ++back; - } - void push_front(const T &a) { - int newfront = (front == 0) ? msize : front - 1; - elements[newfront] = a; - front = newfront; - if(csize != msize) - ++csize; - else if(back == 0) - back = msize; - else - --back; - } - T &pop_back() { -#ifdef _DEBUG - assert(csize != 0); -#endif - --csize; - if(back == 0) - back = msize; - else - --back; - return elements[back]; - } - T &pop_front() { -#ifdef _DEBUG - assert(csize != 0); -#endif - --csize; - T &ret = elements[front]; - if(front == msize) - front = 0; - else - ++front; - return ret; - } - volatile size_t size() { - return *(volatile size_t *)&csize; - } - T &operator[](size_t i) { - return elements[(front + i) % (msize + 1)]; - } - const T &operator[](size_t i) const { - return elements[(front + i) % (msize + 1)]; - } - bool empty() { - return csize == 0; - } - void clear() { - csize = 0; - back = front; - } - void resize(size_t i, const T v = T()) { - if(i > msize) - i = msize; - for (int j = csize; j < i; ++j) - (*this)[back + j] = v; - csize = i; - back = (front + i) % (msize + 1); - } - -template - class CQIter { - size_t p; - W *q; - public: - CQIter() {} - CQIter(size_t d, W *r) {p=d; q=r;} - void operator=(const CQIter &i) {p=i.p;} - CQIter &operator++() {++p; return *this;} - CQIter operator++(int) {return CQIter(p++);} - int operator!=(const CQIter &i) const {return p() {return &(*q)[p];} - }; - typedef CQIter iterator; - typedef CQIter const_iterator; - - iterator begin() { - return iterator(front, this); - } - iterator end() { - return iterator(front + csize, this); - } - const_iterator begin() const { - return const_iterator(front, this); - } - const_iterator end() const { - return const_iterator(front + csize, this); - } -}; - - - - -#endif diff -Nru spring-96.0~14.04~ppa4/rts/lib/gml/gmlcnf.h spring-98.0~14.04~ppa6/rts/lib/gml/gmlcnf.h --- spring-96.0~14.04~ppa4/rts/lib/gml/gmlcnf.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/gml/gmlcnf.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -// GML - OpenGL Multithreading Library -// for Spring http://springrts.com -// Author: Mattias "zerver" Radeskog -// (C) Ware Zerver Tech. http://zerver.net -// Ware Zerver Tech. licenses this library -// to be used, distributed and modified -// freely for any purpose, as long as -// this notice remains unchanged - -#ifndef GMLCONFIG_H -#define GMLCONFIG_H - -#ifdef USE_GML -# define GML_ENABLE 1 // multithreaded drawing of units and ground -#else -# define GML_ENABLE 0 // manually enable opengl multithreading here -#endif - -#ifdef USE_GML_SIM -# define GML_ENABLE_SIM (GML_ENABLE && 1) // runs a completely independent thread loop for the Sim -#else -# define GML_ENABLE_SIM 0 // manually enable sim thread here -#endif - -#ifdef USE_GML_DEBUG -# define GML_CALL_DEBUG 0 // manually force enable call debugging here -#else -# define GML_CALL_DEBUG (GML_ENABLE && GML_ENABLE_SIM && 1) // checks for calls made from the wrong thread (enabled by default) -#endif - -#define GML_ENABLE_DRAW (GML_ENABLE && 0) // draws everything in a separate thread (for testing only, will degrade performance) -#define GML_SERVER_GLCALL 1 // allows the server thread (0) to make direct GL calls -#define GML_INIT_QUEUE_SIZE 10 // initial queue size, will be reallocated, but must be >= 4 -#define GML_USE_NO_ERROR 1 // glGetError always returns success (to improve performance) -#define GML_USE_DEFAULT 1// compile/link/buffer status always returns TRUE/COMPLETE (to improve performance) -#define GML_USE_CACHE 1 // certain glGet calls may use data cached during gmlInit (to improve performance) -//#define GML_USE_QUADRIC_SERVER 1 // use server thread to create/delete quadrics -#define GML_AUX_PREALLOC 128*1024 // preallocation size for aux queue to reduce risk for hang if gl calls happen to be made from Sim thread -#define GML_ENABLE_ITEMSERVER_CHECK (GML_ENABLE_SIM && 1) // if calls to itemserver are made from Sim, output errors to log -#define GML_UPDSRV_INTERVAL 10 -#define GML_ALTERNATE_SYNCMODE 1 // mutex-protected synced execution, slower but more portable -#define GML_ENABLE_TLS_CHECK 1 // check if Thread Local Storage appears to be working -#define GML_GCC_TLS_FIX 1 // fix buggy TLS in GCC by using the Win32 TIB (faster also!) -#define GML_MSC_TLS_OPT 1 // use the Win32 TIB for TLS in MSVC (possibly faster) -#define GML_64BIT_USE_GS 1 // 64-bit OS will use the GS register for TLS (untested feature) -#define GML_LOCKED_GMLCOUNT_ASSIGNMENT 0 // experimental feature, probably not needed -#define GML_NO_THREAD_NUM -1 // no thread number flag -#define GML_DRAW_THREAD_NUM 0 // thread number of draw thread -#define GML_LOAD_THREAD_NUM 1 // thread number of game loading thread -#define GML_SIM_THREAD_NUM 2 // thread number of sim thread -#define GML_DEBUG_MUTEX 0 // debugs the mutex locking order -#define GML_MAX_CALL_CHAIN_WARNINGS 5 // max number of warnings for invalid chained calls from synced Lua to LuaUI -#define GML_MAX_NUM_THREADS (32+2) // extra for the Sim & Loading threads -#define GML_COMPATIBLE_MODE 1 // enable to make a MT build that can switch to fully ST compatible mode - -//#define BOOST_AC_USE_PTHREADS -extern bool gmlEnabled; - -namespace GML { -#ifdef USE_GML - inline bool Enabled() { return (!GML_COMPATIBLE_MODE) || gmlEnabled; } - inline void Enable(bool enable) { gmlEnabled = enable; } - inline bool SimEnabled() { return Enabled() && (GML_ENABLE_SIM ? true : false); } -#else - inline bool Enabled() { return false; } - inline void Enable(bool /*enable*/) {} - inline bool SimEnabled() { return false; } -#endif -}; - -#endif diff -Nru spring-96.0~14.04~ppa4/rts/lib/gml/gmlcnt.h spring-98.0~14.04~ppa6/rts/lib/gml/gmlcnt.h --- spring-96.0~14.04~ppa4/rts/lib/gml/gmlcnt.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/gml/gmlcnt.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,276 +0,0 @@ -// GML - OpenGL Multithreading Library -// for Spring http://springrts.com -// Author: Mattias "zerver" Radeskog -// (C) Ware Zerver Tech. http://zerver.net -// Ware Zerver Tech. licenses this library -// to be used, distributed and modified -// freely for any purpose, as long as -// this notice remains unchanged - -// This code is largely based on boost::detail::atomic_count -// -// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd. -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef GMLCNT_H -#define GMLCNT_H - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -#include - -// evaluate which locking method to use -#if !defined(BOOST_HAS_THREADS) - #define GML_THREADS_NO_BOOST_THREADS -#elif defined(BOOST_AC_USE_PTHREADS) - #define GML_THREADS_PTHREADS -#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) - #define GML_THREADS_ATOMIC -#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) - #define GML_THREADS_BOOST_INTERLOCK -#elif defined( __GNUC__ ) && ( __GNUC__ * 100 + __GNUC_MINOR__ >= 401 ) && !defined( __arm__ ) && !defined( __hppa ) && ( !defined( __INTEL_COMPILER ) || defined( __ia64__ ) ) - #define GML_THREADS_SYNC -#elif defined(__GLIBCPP__) || defined(__GLIBCXX__) - #define GML_THREADS_ATOMICITY -#elif defined(BOOST_HAS_PTHREADS) - #define BOOST_AC_USE_PTHREADS - #define GML_THREADS_PTHREADS -#endif - -/////////////////////////////////////////////////////////////////////////////////////////////////////////// -#if defined(GML_THREADS_NO_BOOST_THREADS) - -typedef long gmlCount; - -/////////////////////////////////////////////////////////////////////////////////////////////////////////// -#elif defined(GML_THREADS_PTHREADS) - -#include - -class gmlCount { -private: - - class scoped_lock { - public: - - scoped_lock(pthread_mutex_t & m): m_(m) { - pthread_mutex_lock(&m_); - } - - ~scoped_lock() { - pthread_mutex_unlock(&m_); - } - - private: - - pthread_mutex_t & m_; - }; - -public: - - explicit gmlCount(long v): value_(v) { - pthread_mutex_init(&mutex_, 0); - } - - ~gmlCount() { - pthread_mutex_destroy(&mutex_); - } - - long operator++() { - scoped_lock lock(mutex_); - return ++value_; - } - - long operator--() { - scoped_lock lock(mutex_); - return --value_; - } - - operator long() const { - scoped_lock lock(mutex_); - return value_; - } - - long value_; - -private: - - gmlCount(gmlCount const &); - gmlCount & operator=(gmlCount const &); - - mutable pthread_mutex_t mutex_; -}; - -/////////////////////////////////////////////////////////////////////////////////////////////////////////// -#elif defined(GML_THREADS_ATOMIC) - -class gmlCount { -public: - - explicit gmlCount( long v ) : value_( static_cast< int >( v ) ) {} - - long operator++() { - return atomic_exchange_and_add( &value_, 1 ) + 1; - } - - long operator--() { - return atomic_exchange_and_add( &value_, -1 ) - 1; - } - - operator long() const { - return atomic_exchange_and_add( &value_, 0 ); - } - - mutable int value_; - -private: - - gmlCount(gmlCount const &); - gmlCount & operator=(gmlCount const &); - -private: - - static int atomic_exchange_and_add( int * pw, int dv ) { - // int r = *pw; - // *pw += dv; - // return r; - - int r; - - __asm__ __volatile__ - ( - "lock\n\t" - "xadd %1, %0": - "+m"( *pw ), "=r"( r ): // outputs (%0, %1) - "1"( dv ): // inputs (%2 == %1) - "memory", "cc" // clobbers - ); - - return r; - } -}; - -/////////////////////////////////////////////////////////////////////////////////////////////////////////// -#elif defined(GML_THREADS_BOOST_INTERLOCK) - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif - -#include - -class gmlCount { -public: - - explicit gmlCount( long v ): value_( v ) {} - - long operator++() { - return BOOST_INTERLOCKED_INCREMENT( &value_ ); - } - - long operator--() { - return BOOST_INTERLOCKED_DECREMENT( &value_ ); - } - - operator long() const { - return static_cast( value_ ); - } - - long value_; - -private: - - gmlCount( gmlCount const & ); - gmlCount & operator=( gmlCount const & ); -}; - -/////////////////////////////////////////////////////////////////////////////////////////////////////////// -#elif defined(GML_THREADS_SYNC) - -#if defined( __ia64__ ) && defined( __INTEL_COMPILER ) -# include -#endif - -class gmlCount { -public: - - explicit gmlCount( long v ) : value_( v ) {} - - long operator++() { - return __sync_add_and_fetch( &value_, 1 ); - } - - long operator--() { - return __sync_add_and_fetch( &value_, -1 ); - } - - operator long() const { - return __sync_fetch_and_add( &value_, 0 ); - } - - mutable long value_; - -private: - - gmlCount(gmlCount const &); - gmlCount & operator=(gmlCount const &); -}; - -/////////////////////////////////////////////////////////////////////////////////////////////////////////// -#elif defined(GML_THREADS_ATOMICITY) - -#include - -#if defined(__GLIBCXX__) // g++ 3.4+ - -using __gnu_cxx::__atomic_add; -using __gnu_cxx::__exchange_and_add; - -#endif - -class gmlCount { -public: - - explicit gmlCount(long v) : value_(v) {} - - long operator++() { - return __exchange_and_add(&value_, 1) + 1; - } - - long operator--() { - return __exchange_and_add(&value_, -1) - 1; - } - - operator long() const { - return __exchange_and_add(&value_, 0); - } - - mutable _Atomic_word value_; - -private: - - gmlCount(gmlCount const &); - gmlCount & operator=(gmlCount const &); -}; - -/////////////////////////////////////////////////////////////////////////////////////////////////////////// -#else - -#error Unrecognized threading platform - -#endif - -#ifdef BOOST_HAS_THREADS - -inline void operator%=(gmlCount& a, long val) { - a.value_=val; -} - -#endif - -#endif // #ifndef GMLCNT_H diff -Nru spring-96.0~14.04~ppa4/rts/lib/gml/gml.cpp spring-98.0~14.04~ppa6/rts/lib/gml/gml.cpp --- spring-96.0~14.04~ppa4/rts/lib/gml/gml.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/gml/gml.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,1188 +0,0 @@ -// GML - OpenGL Multithreading Library -// for Spring http://springrts.com -// Author: Mattias "zerver" Radeskog -// (C) Ware Zerver Tech. http://zerver.net -// Ware Zerver Tech. licenses this library -// to be used, distributed and modified -// freely for any purpose, as long as -// this notice remains unchanged - -// GML works by "patching" all OpenGL calls. It is injected via a #include "gml.h" statement located in myGL.h. -// All files that need GL should therefore include myGL.h. INCLUDING gl.h, glu.h, glext.h ... IS FORBIDDEN. -// When a client thread (gmlThreadNumber > 2) executes a GL call, it is redirected into a queue. -// The server thread (gmlThreadNumber = 0) will then consume GL calls from the queues of each thread. -// When the server thread makes a GL call, it calls directly into OpenGL of course. -// The game load thread (gmlThreadNumber = 1) can also make GL calls. -// The sim thread (gmlThreadNumber = 2) is allowed to make GL calls only if gmlShareLists is enabled. - -// Since a single server thread makes all GL calls, there is no point in multithreading code that contains -// lots of GL calls but almost no CPU intensive calculations. Also, there is no point in multithreading -// functions that take very short execution time to complete. The overhead of starting and managing the threads -// will defeat any possible performance benefit. - -// Certain calls need synchronization. For example, all glGet*** functions return a value that must -// be available to the thread immediately. The client thread works around this by requesting the -// server to run in synced mode. This means the client will halt and ask the server to begin consuming -// GL calls from its queue until it reaches the sync point containing the GL call that returns the value. -// Running synced is expensive performance wise, so glGet*** etc should be avoided at all cost in threaded code. - -// Instructions for adding new GL functions to GML: -// 1. add the GML_MAKEFUN***(Function, ...) statement to the long list of declarations at the end of gmlfun.h -// 2. add the corresponding GML_MAKEHANDLER***(Function) statment to the QueueHandler function below -// 3. add #undef glFunction to the list in the upper half of gmldef.h -// 4. add #define glFunction gmlFunction to the list in the lower half of gmldef.h -// Please note: Some functions may require more advanced coding to implement -// If a function is not yet supported by GML, a compile error pointing to 'GML_FUNCTION_NOT_IMPLEMENTED' will occur - -bool gmlEnabled = true; - -#ifdef USE_GML - -#include -#include "gmlcls.h" -#include "gmlque.h" - -#include "Game/UI/KeyBindings.h" -#include "Lua/LuaConfig.h" -#include "System/Log/ILog.h" -#include "System/Platform/Threading.h" - - -const char *gmlProfMutex = "lua"; -float gmlLockTime = 0; - -int gmlProcNumLoop = 25; -int gmlProcInterval = 8; -bool gmlShareLists = true; -int gmlMaxServerThreadNum = GML_SIM_THREAD_NUM; -int gmlMaxShareThreadNum = GML_MAX_NUM_THREADS; -int gmlNoGLThreadNum = GML_NO_THREAD_NUM; -volatile bool gmlMultiThreadSim = true; -volatile bool gmlStartSim = false; -volatile bool gmlKeepRunning = false; -volatile bool gmlServerActive = false; -volatile bool gmlMutexLockWait = false; - -#define EXEC_RUN (BYTE *)NULL -#define EXEC_SYNC (BYTE *)-1 -#define EXEC_RES (BYTE *)-2 - -// TLS (thread local storage) thread identifier -#if GML_ENABLE -# ifdef _MSC_VER -# if !GML_MSC_TLS_OPT -__declspec(thread) int gmlThreadNumber=0; -# endif -# else -# if !GML_GCC_TLS_FIX && !GML_USE_SPEEDY_TLS -__thread int gmlThreadNumber=0; -# endif -# endif -#else -int gmlThreadNumber=0; -#endif - -int gmlThreadCountOverride=0; // number of threads to use (can be manually overridden here) -int gmlThreadCount=0; // number of threads to use -int gmlItemsConsumed=0; - -int gmlNextTickUpdate=0; -unsigned gmlCurrentTicks; -bool gmlCheckCallChain=false; -int gmlCallChainWarning=0; - -std::set threadnums; - -#define GML_NOP 0 -const char *gmlFunctionNames[512]; -inline int gmlResetNames() { - for(int i=0; i<512; ++i) - gmlFunctionNames[i]=""; - return 0; -} -int gmlNamesDummy=gmlResetNames(); - -// cache maps for gmlInit -std::map gmlGetIntegervCache; -std::map gmlGetFloatvCache; -std::map gmlGetStringCache; - -// params to be cached by gmlInit -GLenum gmlIntParams[]={GL_MAX_TEXTURE_SIZE,GL_MAX_TEXTURE_UNITS,GL_MAX_TEXTURE_IMAGE_UNITS_ARB,GL_MAX_TEXTURE_COORDS_ARB,GL_MAX_TEXTURE_UNITS_ARB,GL_UNPACK_ALIGNMENT}; -GLenum gmlFloatParams[]={GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT}; -GLenum gmlStringParams[]={GL_VERSION,GL_VENDOR,GL_RENDERER,GL_EXTENSIONS}; - -// gmlInit caches certain glGet return values to -// reduce the need for synced queue execution -BOOL_ gmlInited=FALSE; -void gmlInit() { - if(gmlInited) - return; - for(int i=0; i gmlShaderServer_VERTEX(&glCreateShader_VERTEX, 2, 0); -gmlSingleItemServer gmlShaderServer_FRAGMENT(&glCreateShader_FRAGMENT, 2, 0); -gmlSingleItemServer gmlShaderServer_GEOMETRY_EXT(&glCreateShader_GEOMETRY_EXT, 2, 0); -gmlSingleItemServer gmlShaderObjectARBServer_VERTEX(&glCreateShaderObjectARB_VERTEX, 2, 0); -gmlSingleItemServer gmlShaderObjectARBServer_FRAGMENT(&glCreateShaderObjectARB_FRAGMENT, 2, 0); -gmlSingleItemServer gmlShaderObjectARBServer_GEOMETRY_EXT(&glCreateShaderObjectARB_GEOMETRY_EXT, 2, 0); -gmlSingleItemServer gmlQuadricServer(&gluNewQuadric, 100, 25); - -// Item server instances -#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 3) && (__GNUC_PATCHLEVEL__ == 0) -// gcc has issues with attributes in function pointers it seems -gmlSingleItemServer gmlProgramServer(&glCreateProgram, 2, 0); -gmlSingleItemServer gmlProgramObjectARBServer(&glCreateProgramObjectARB, 2, 0); - -gmlMultiItemServer gmlBufferARBServer(&glGenBuffersARB, 2, 0); -gmlMultiItemServer gmlFencesNVServer(&glGenFencesNV, 2, 0); -gmlMultiItemServer gmlProgramsARBServer(&glGenProgramsARB, 2, 0); -gmlMultiItemServer gmlRenderbuffersEXTServer(&glGenRenderbuffersEXT, 2, 0); -gmlMultiItemServer gmlFramebuffersEXTServer(&glGenFramebuffersEXT, 2, 0); -gmlMultiItemServer gmlQueryServer(&glGenQueries, 2, 0); -gmlMultiItemServer gmlBufferServer(&glGenBuffers, 2, 0); -#else -gmlSingleItemServer gmlProgramServer(&glCreateProgram, 2, 0); -gmlSingleItemServer gmlProgramObjectARBServer(&glCreateProgramObjectARB, 2, 0); - -gmlMultiItemServer gmlBufferARBServer(&glGenBuffersARB, 2, 0); -gmlMultiItemServer gmlFencesNVServer(&glGenFencesNV, 2, 0); -gmlMultiItemServer gmlProgramsARBServer(&glGenProgramsARB, 2, 0); -gmlMultiItemServer gmlRenderbuffersEXTServer(&glGenRenderbuffersEXT, 2, 0); -gmlMultiItemServer gmlFramebuffersEXTServer(&glGenFramebuffersEXT, 2, 0); -gmlMultiItemServer gmlQueryServer(&glGenQueries, 2, 0); -gmlMultiItemServer gmlBufferServer(&glGenBuffers, 2, 0); -#endif - -gmlMultiItemServer gmlTextureServer(&glGenTextures, 100, 25); - -#if GML_ENABLE_SIM -#include -boost::mutex caimutex; -boost::mutex decalmutex; -boost::mutex treemutex; -boost::mutex mapmutex; -boost::mutex inmapmutex; -boost::mutex tempmutex; -boost::mutex posmutex; -boost::mutex runitmutex; -boost::mutex netmutex; -boost::mutex histmutex; -boost::mutex timemutex; -boost::mutex watermutex; -boost::mutex dquemutex; -boost::mutex scarmutex; -boost::mutex trackmutex; -boost::mutex rprojmutex; -boost::mutex rflashmutex; -boost::mutex rpiecemutex; -boost::mutex rfeatmutex; -boost::mutex drawmutex; -boost::mutex scallmutex; -boost::mutex ulbatchmutex; -boost::mutex flbatchmutex; -boost::mutex olbatchmutex; -boost::mutex plbatchmutex; -boost::mutex glbatchmutex; -boost::mutex mlbatchmutex; -boost::mutex llbatchmutex; -boost::mutex cmdmutex; -boost::mutex xcallmutex; -boost::mutex blockmutex; -boost::mutex tnummutex; -boost::mutex ntexmutex; -boost::mutex catmutex; -boost::mutex grpchgmutex; -boost::mutex laycmdmutex; - -#include -boost::recursive_mutex unitmutex; -boost::recursive_mutex selmutex; -boost::recursive_mutex quadmutex; -boost::recursive_mutex featmutex; -boost::recursive_mutex grassmutex; -boost::recursive_mutex &guimutex=selmutex; -boost::recursive_mutex filemutex; -boost::recursive_mutex &qnummutex=quadmutex; -boost::recursive_mutex &groupmutex=selmutex; -boost::recursive_mutex &grpselmutex=selmutex; -boost::recursive_mutex projmutex; -boost::recursive_mutex objmutex; -boost::recursive_mutex modelmutex; -boost::recursive_mutex cammutex; - -gmlMutex simmutex; - -#if GML_DEBUG_MUTEX -boost::mutex lmmutex; -std::map lockmaps[GML_MAX_NUM_THREADS]; -std::map lockmmaps[GML_MAX_NUM_THREADS]; -#endif - -void gmlPrintCallChainWarning(const char *func) { - LOG_SL("Threading", L_ERROR, "Invalid attempt (%d/%d) to invoke LuaUI (%s) from another Lua environment, " - "certain widgets require LuaThreadingModel > %d to work properly with multithreading", gmlCallChainWarning, GML_MAX_CALL_CHAIN_WARNINGS, func, (int)MT_LUA_SINGLE_BATCH); -} - -#endif - -bool ThreadRegistered() { - boost::mutex::scoped_lock tnumlock(tnummutex); - Threading::NativeThreadId thid = Threading::GetCurrentThreadId(); - if (threadnums.find(thid) != threadnums.end()) - return true; - threadnums.insert(thid); - return false; -} -// GMLqueue implementation -gmlQueue::gmlQueue(): -ReadPos(0),WritePos(0),WriteSize(0),Read(0),Write(0),Locked1(FALSE),Locked2(FALSE),Reloc(FALSE),Sync(EXEC_RUN),WasSynced(FALSE), -ClientState(0), -CPsize(0), CPtype(0), CPstride(0), CPpointer(NULL), -EFPstride(0), EFPpointer(NULL), -IPtype(0), IPstride(0), IPpointer(NULL), -NPtype(0), NPstride(0), NPpointer(NULL), -TCPsize(0), TCPtype(0), TCPstride(0), TCPpointer(NULL), -ArrayBuffer(0), ElementArrayBuffer(0), PixelPackBuffer(0),PixelUnpackBuffer(0) -{ - Queue1=(BYTE *)malloc(GML_INIT_QUEUE_SIZE*sizeof(BYTE)); - Queue2=(BYTE *)malloc(GML_INIT_QUEUE_SIZE*sizeof(BYTE)); - Pos1=Queue1; - Pos2=Queue2; - Size1=Queue1+GML_INIT_QUEUE_SIZE; - Size2=Queue2+GML_INIT_QUEUE_SIZE; -} - -gmlQueue::~gmlQueue() { - delete Queue1; - delete Queue2; -} - -BYTE *gmlQueue::Realloc(BYTE **e) { - int oldsize=WriteSize-Write; - int newsize=oldsize*2; - int oldpos=WritePos-Write; - int olde=0; - if(e) - olde=*e-Write; - if(Write==Queue1) { - *(BYTE * volatile *)&Write=Queue1=(BYTE *)realloc(Queue1,newsize); - Size1=Queue1+newsize; - } - else { - *(BYTE * volatile *)&Write=Queue2=(BYTE *)realloc(Queue2,newsize); - Size2=Queue2+newsize; - } - *(BYTE * volatile *)&WritePos=Write+oldpos; - *(BYTE * volatile *)&WriteSize=Write+newsize; - - GML_MEMBAR; //# - - Reloc=FALSE; - if(e) - *e=Write+olde; - return WritePos; -} - -BYTE *gmlQueue::WaitRealloc(BYTE **e) { - int olde=0; - if(e) - olde=*e-Write; - - Reloc=TRUE; - while(Reloc) - boost::thread::yield(); - - GML_MEMBAR; //# - - if(e) - *e=(BYTE *)*(BYTE * volatile *)&Write+olde; - return (BYTE *)*(BYTE * volatile *)&WritePos; -} - -void gmlQueue::ReleaseWrite(BOOL_ final) { - if(Write==NULL) - return; -#if GML_ALTERNATE_SYNCMODE - if(WritePos==Write) { - *(int *)WritePos=GML_NOP; - WritePos+=sizeof(int); - } - - if(Write==Queue1) { - if(final) { - while(!Empty(2)) - boost::thread::yield(); - - if(WasSynced) { - Sync=WritePos; - while(Sync==WritePos) - boost::thread::yield(); - } - } - - Pos1=WritePos; - Locked1=FALSE; - Locks1.Unlock(); - } - else { - if(final) { - while(!Empty(1)) - boost::thread::yield(); - - if(WasSynced) { - Sync=WritePos; - while(Sync==WritePos) - boost::thread::yield(); - } - } - - Pos2=WritePos; - Locked2=FALSE; - Locks2.Unlock(); - } - - if(final && WasSynced) { - while(Sync!=EXEC_RUN) - boost::thread::yield(); - WasSynced=FALSE; - } - -#else - if(Write==Queue1) { - if(final) { - while(!Empty(2)) - boost::thread::yield(); - } - if(WasSynced) { - Sync=WritePos; - while(Sync==WritePos) - boost::thread::yield(); - WasSynced=FALSE; - } - Pos1=WritePos; - Locked1=FALSE; - Locks1.Unlock(); - } - else { - if(final) { - while(!Empty(1)) - boost::thread::yield(); - } - if(WasSynced) { - Sync=WritePos; - while(Sync==WritePos) - boost::thread::yield(); - WasSynced=FALSE; - } - Pos2=WritePos; - Locked2=FALSE; - Locks2.Unlock(); - } -#endif - Write=NULL; - WritePos=NULL; - WriteSize=NULL; -} - -BOOL_ gmlQueue::GetWrite(BOOL_ critical) { - while(1) { - if(!Locked1 && Empty(1)) { - if(Locks1.Lock()) { - Locked1=TRUE; - ReleaseWrite(critical==2); - WritePos=Write=Queue1; - WriteSize=Size1; - return TRUE; - } - } - if(!Locked2 && Empty(2)) { - if(Locks2.Lock()) { - Locked2=TRUE; - ReleaseWrite(critical==2); - WritePos=Write=Queue2; - WriteSize=Size2; - return TRUE; - } - } - if(!critical) - return FALSE; - boost::thread::yield(); - } -} - -void gmlQueue::ReleaseRead() { - if(Read==NULL) - return; - if(Read==Queue1) { - Pos1=Queue1; - Locked1=FALSE; - Locks1.Unlock(); - } - else { - Pos2=Queue2; - Locked2=FALSE; - Locks2.Unlock(); - } - Read=NULL; - ReadPos=NULL; -} - -BOOL_ gmlQueue::GetRead(BOOL_ critical) { - while(1) { - if(!Locked1 && !Empty(1)) { - if(Locks1.Lock()) { - Locked1=TRUE; - Read=Queue1; - ReadPos=Pos1; - return TRUE; - } - } - if(!Locked2 && !Empty(2)) { - if(Locks2.Lock()) { - Locked2=TRUE; - Read=Queue2; - ReadPos=Pos2; - return TRUE; - } - } - if(!critical) - return FALSE; - boost::thread::yield(); - } -} - - -void gmlQueue::SyncRequest() { - // make sure server is finished with other queue - if(Write==Queue1) { - while(!Empty(2)) - boost::thread::yield(); - } - else { - while(!Empty(1)) - boost::thread::yield(); - } - -#if GML_ALTERNATE_SYNCMODE - WasSynced=TRUE; - Sync=EXEC_SYNC; - while(Sync==EXEC_SYNC) // wait for syncmode confirmation before release - boost::thread::yield(); - - GetWrite(TRUE); // get new queue so server can get the old one - while(Sync!=EXEC_RES) // waiting for result - boost::thread::yield(); - - GML_MEMBAR; //# - - Sync=EXEC_RUN; // server may proceed (avoid entering sync again) -#else - BYTE *wp=WritePos; - *(BYTE * volatile *)&WritePos=wp; - WasSynced=TRUE; - Sync=EXEC_SYNC; - while(Sync==EXEC_SYNC) - boost::thread::yield(); -#endif -} - -#define GML_DT(name) ((gml##name##Data *)p) -#define GML_DATA(name,x) (GML_DT(name)->x) -#define GML_DATA_A(name) GML_DATA(name,A) -#define GML_DATA_B(name) GML_DATA_A(name),GML_DATA(name,B) -#define GML_DATA_C(name) GML_DATA_B(name),GML_DATA(name,C) -#define GML_DATA_D(name) GML_DATA_C(name),GML_DATA(name,D) -#define GML_DATA_E(name) GML_DATA_D(name),GML_DATA(name,E) -#define GML_DATA_F(name) GML_DATA_E(name),GML_DATA(name,F) -#define GML_DATA_G(name) GML_DATA_F(name),GML_DATA(name,G) -#define GML_DATA_H(name) GML_DATA_G(name),GML_DATA(name,H) -#define GML_DATA_I(name) GML_DATA_H(name),GML_DATA(name,I) -#define GML_DATA_J(name) GML_DATA_I(name),GML_DATA(name,J) - -#define GML_NEXT(name) p+=sizeof(gml##name##Data); break; -#define GML_NEXT_SIZE(name) p+=GML_DATA(name,size); break; -#define GML_CASE(name) case gml##name##Enum -#define GML_CALL(name,...) gl##name(__VA_ARGS__); -#define GML_EXEC(name,...) GML_CASE(name): GML_CALL(name,__VA_ARGS__) -#define GML_EXEC_RET(name,...) GML_CASE(name): GML_DATA(name,ret)=GML_CALL(name,__VA_ARGS__) - -// Handler definition macros -// These handlers execute GL commands from the queues -#define GML_MAKEHANDLER0(name)\ - GML_EXEC(name)\ - GML_NEXT(name) - -#define GML_MAKEHANDLER0R(name)\ - GML_EXEC_RET(name)\ - GML_NEXT(name) - -#define GML_MAKEHANDLER1(name)\ - GML_EXEC(name,GML_DATA_A(name))\ - GML_NEXT(name) - -#define GML_MAKEHANDLER1R(name)\ - GML_EXEC_RET(name,GML_DATA_A(name))\ - GML_NEXT(name) - -#define GML_MAKEHANDLER2(name)\ - GML_EXEC(name,GML_DATA_B(name))\ - GML_NEXT(name) - -#define GML_MAKEHANDLER2R(name)\ - GML_EXEC_RET(name,GML_DATA_B(name))\ - GML_NEXT(name) - -#define GML_MAKEHANDLER3(name)\ - GML_EXEC(name,GML_DATA_C(name))\ - GML_NEXT(name) - -#define GML_MAKEHANDLER4(name)\ - GML_EXEC(name,GML_DATA_D(name))\ - GML_NEXT(name) - -#define GML_MAKEHANDLER4R(name)\ - GML_EXEC_RET(name,GML_DATA_D(name))\ - GML_NEXT(name) - -#define GML_MAKEHANDLER5(name)\ - GML_EXEC(name,GML_DATA_E(name))\ - GML_NEXT(name) - -#define GML_MAKEHANDLER6(name)\ - GML_EXEC(name,GML_DATA_F(name))\ - GML_NEXT(name) - -#define GML_MAKEHANDLER7(name)\ - GML_EXEC(name,GML_DATA_G(name))\ - GML_NEXT(name) - -#define GML_MAKEHANDLER8(name)\ - GML_EXEC(name,GML_DATA_H(name))\ - GML_NEXT(name) - -#define GML_MAKEHANDLER9(name)\ - GML_EXEC(name,GML_DATA_I(name))\ - GML_NEXT(name) - -#define GML_MAKEHANDLER9R(name)\ - GML_EXEC_RET(name,GML_DATA_I(name))\ - GML_NEXT(name) - -#define GML_MAKEHANDLER10(name)\ - GML_EXEC(name,GML_DATA_J(name))\ - GML_NEXT(name) -//glTexImage1D -#define GML_MAKEHANDLER8S(name)\ - GML_EXEC(name,GML_DATA_G(name),GML_DATA(name,H)?((BYTE *)(GML_DATA(name,H)))-1:(BYTE *)(GML_DT(name)+1))\ - GML_NEXT_SIZE(name) -//glTexImage2D -#define GML_MAKEHANDLER9S(name)\ - GML_EXEC(name,GML_DATA_H(name),GML_DATA(name,I)?((BYTE *)(GML_DATA(name,I)))-1:(BYTE *)(GML_DT(name)+1))\ - GML_NEXT_SIZE(name) -//glTexImage3D -#define GML_MAKEHANDLER10S(name)\ - GML_EXEC(name,GML_DATA_I(name),GML_DATA(name,J)?((BYTE *)(GML_DATA(name,J)))-1:(BYTE *)(GML_DT(name)+1))\ - GML_NEXT_SIZE(name) -//glColor4fv -#define GML_MAKEHANDLER1V(name)\ - GML_EXEC(name,&(GML_DATA(name,A)))\ - GML_NEXT_SIZE(name) -//glFogfv -#define GML_MAKEHANDLER2V(name)\ - GML_EXEC(name,GML_DATA_A(name),&(GML_DATA(name,B)))\ - GML_NEXT_SIZE(name) -//glLight -#define GML_MAKEHANDLER3V(name)\ - GML_EXEC(name,GML_DATA_B(name),&(GML_DATA(name,C)))\ - GML_NEXT_SIZE(name) -//glUniformMatrix4fv -#define GML_MAKEHANDLER4V(name)\ - GML_EXEC(name,GML_DATA_C(name),&(GML_DATA(name,D)))\ - GML_NEXT_SIZE(name) -//glBufferDataARB -#define GML_MAKEHANDLER4VS(name)\ - GML_EXEC(name,GML_DATA_B(name),&(GML_DATA(name,C)),GML_DATA(name,D))\ - GML_NEXT_SIZE(name) -//glShaderSource -#define GML_MAKEHANDLER4VSS(name,type)\ - GML_CASE(name):\ - ptr=(BYTE *)GML_DT(name)+GML_DATA(name,lensize);\ - for(int i=0; itarget,va->size,va->type,va->normalized,0,va->buffer?va->pointer:(ptr+sizeof(VAstruct)));\ - ptr+=va->totalsize;\ - } - - -#define GML_MAKEHANDLER3VDA(name)\ - GML_CASE(name):\ - ptr=(BYTE *)(GML_DT(name)+1);\ - GML_MAKESUBHANDLER4(GL_VERTEX_ARRAY,glVertexPointer,VP,name)\ - GML_MAKESUBHANDLER4(GL_COLOR_ARRAY,glColorPointer,CP,name)\ - GML_MAKESUBHANDLER4(GL_TEXTURE_COORD_ARRAY,glTexCoordPointer,TCP,name)\ - GML_MAKESUBHANDLER3(GL_INDEX_ARRAY,glIndexPointer,IP,name)\ - GML_MAKESUBHANDLER3(GL_NORMAL_ARRAY,glNormalPointer,NP,name)\ - GML_MAKESUBHANDLER2(GL_EDGE_FLAG_ARRAY,glEdgeFlagPointer,EFP,name)\ - GML_MAKESUBHANDLERVA(name)\ - GML_CALL(name,GML_DATA(name,A),0,GML_DATA(name,C))\ - GML_NEXT_SIZE(name) - -#define GML_MAKEHANDLER4VDE(name)\ - GML_CASE(name):\ - ptr=(BYTE *)(GML_DT(name)+1);\ - GML_MAKESUBHANDLER4(GL_VERTEX_ARRAY,glVertexPointer,VP,name)\ - GML_MAKESUBHANDLER4(GL_COLOR_ARRAY,glColorPointer,CP,name)\ - GML_MAKESUBHANDLER4(GL_TEXTURE_COORD_ARRAY,glTexCoordPointer,TCP,name)\ - GML_MAKESUBHANDLER3(GL_INDEX_ARRAY,glIndexPointer,IP,name)\ - GML_MAKESUBHANDLER3(GL_NORMAL_ARRAY,glNormalPointer,NP,name)\ - GML_MAKESUBHANDLER2(GL_EDGE_FLAG_ARRAY,glEdgeFlagPointer,EFP,name)\ - GML_MAKESUBHANDLERVA(name)\ - if(GML_DATA(name,ClientState) & GML_ELEMENT_ARRAY_BUFFER)\ - GML_CALL(name,GML_DATA(name,A),GML_DATA(name,B),GML_DATA(name,C),GML_DATA(name,D))\ - else\ - GML_CALL(DrawArrays,GML_DATA(name,A),0,GML_DATA(name,B))\ - GML_NEXT_SIZE(name) - -#define GML_MAKEHANDLER6VDRE(name)\ - GML_CASE(name):\ - ptr=(BYTE *)(GML_DT(name)+1);\ - GML_MAKESUBHANDLER4(GL_VERTEX_ARRAY,glVertexPointer,VP,name)\ - GML_MAKESUBHANDLER4(GL_COLOR_ARRAY,glColorPointer,CP,name)\ - GML_MAKESUBHANDLER4(GL_TEXTURE_COORD_ARRAY,glTexCoordPointer,TCP,name)\ - GML_MAKESUBHANDLER3(GL_INDEX_ARRAY,glIndexPointer,IP,name)\ - GML_MAKESUBHANDLER3(GL_NORMAL_ARRAY,glNormalPointer,NP,name)\ - GML_MAKESUBHANDLER2(GL_EDGE_FLAG_ARRAY,glEdgeFlagPointer,EFP,name)\ - GML_MAKESUBHANDLERVA(name)\ - if(GML_DATA(name,ClientState) & GML_ELEMENT_ARRAY_BUFFER)\ - GML_CALL(name,GML_DATA(name,A),GML_DATA(name,B),GML_DATA(name,C),GML_DATA(name,D),GML_DATA(name,E),GML_DATA(name,F))\ - else\ - GML_CALL(DrawArrays,GML_DATA(name,A),0,GML_DATA(name,D))\ - GML_NEXT_SIZE(name) - -const char *gmlNOPDummy=(gmlFunctionNames[GML_NOP]="gmlNOP"); -#define GML_MAKENAME(name) EXTERN const char *gml##name##Dummy=(gmlFunctionNames[gml##name##Enum]=GML_QUOTE(gml##name)); -#include "gmlfun.h" -// this item server instance needs gmlDeleteLists from gmlfun.h, that is why it is declared down here -gmlItemSequenceServer gmlListServer(&glGenLists, &gmlDeleteLists, 100, 25, 20, 5); - -#if GML_CALL_DEBUG -lua_State *gmlCurrentLuaStates[GML_MAX_NUM_THREADS] = { NULL }; -lua_State *gmlLuaUIState=NULL; -#endif - -// queue handler - exequtes one GL command from queue (pointed to by p) -// ptr is a temporary variable used inside the handlers -inline void QueueHandler(BYTE *&p, BYTE *&ptr) { - switch(*(int *)p) { -#if GML_ALTERNATE_SYNCMODE - case GML_NOP: p+=sizeof(int); break; -#endif - GML_MAKEHANDLER1(Disable) - GML_MAKEHANDLER1(Enable) - GML_MAKEHANDLER2(BindTexture) - GML_MAKEHANDLER3(TexParameteri) - GML_MAKEHANDLER1(ActiveTextureARB) - GML_MAKEHANDLER4(Color4f) - GML_MAKEHANDLER3(Vertex3f) - GML_MAKEHANDLER3(TexEnvi) - GML_MAKEHANDLER2(TexCoord2f) - GML_MAKEHANDLER6(ProgramEnvParameter4fARB) - GML_MAKEHANDLER0(End) - GML_MAKEHANDLER1(Begin) - GML_MAKEHANDLER1(MatrixMode) - GML_MAKEHANDLER2(Vertex2f) - GML_MAKEHANDLER0(PopMatrix) - GML_MAKEHANDLER0(PushMatrix) - GML_MAKEHANDLER0(LoadIdentity) - GML_MAKEHANDLER3(Translatef) - GML_MAKEHANDLER2(BlendFunc) - GML_MAKEHANDLER1(CallList) - GML_MAKEHANDLER3(Color3f) - GML_MAKEHANDLER9S(TexImage2D) - GML_MAKEHANDLER1V(Color4fv) - GML_MAKEHANDLER2(BindProgramARB) - GML_MAKEHANDLER3(Scalef) - GML_MAKEHANDLER4(Viewport) - GML_MAKEHANDLER2V(DeleteTextures) - GML_MAKEHANDLER3(MultiTexCoord2fARB) - GML_MAKEHANDLER2(AlphaFunc) - GML_MAKEHANDLER1(DepthMask) - GML_MAKEHANDLER1(LineWidth) - GML_MAKEHANDLER2(BindFramebufferEXT) - GML_MAKEHANDLER4(Rotatef) - GML_MAKEHANDLER2(DeleteLists) - GML_MAKEHANDLER1(DisableClientState) - GML_MAKEHANDLER1(EnableClientState) - GML_MAKEHANDLER4(Rectf) - GML_MAKEHANDLER3V(Lightfv) - GML_MAKEHANDLER7S(uBuild2DMipmaps) - GML_MAKEHANDLER1(Clear) - GML_MAKEHANDLER0(EndList) - GML_MAKEHANDLER2(NewList) - GML_MAKEHANDLER4(ClearColor) - GML_MAKEHANDLER2(PolygonMode) - GML_MAKEHANDLER1(ActiveTexture) - GML_MAKEHANDLER2(Fogf) - GML_MAKEHANDLER1V(MultMatrixf) - GML_MAKEHANDLER6(Ortho) - GML_MAKEHANDLER0(PopAttrib) - GML_MAKEHANDLER3V(Materialfv) - GML_MAKEHANDLER2(PolygonOffset) - GML_MAKEHANDLER1(PushAttrib) - GML_MAKEHANDLER1(CullFace) - GML_MAKEHANDLER4(ColorMask) - GML_MAKEHANDLER1V(Vertex3fv) - GML_MAKEHANDLER3V(TexGenfv) - GML_MAKEHANDLER2(Vertex2d) - GML_MAKEHANDLER4(VertexPointer) - GML_MAKEHANDLER3VDA(DrawArrays) - GML_MAKEHANDLER2V(Fogfv) - GML_MAKEHANDLER5(FramebufferTexture2DEXT) - GML_MAKEHANDLER4(FramebufferTextureEXT) - GML_MAKEHANDLER4(TexCoordPointer) - GML_MAKEHANDLER9S(TexSubImage2D) - GML_MAKEHANDLER2V(ClipPlane) - GML_MAKEHANDLER4(Color4d) - GML_MAKEHANDLER2(LightModeli) - GML_MAKEHANDLER3(TexGeni) - GML_MAKEHANDLER3(TexParameterf) - GML_MAKEHANDLER8(CopyTexSubImage2D) - GML_MAKEHANDLER2V(DeleteFramebuffersEXT) - GML_MAKEHANDLER1V(LoadMatrixf) - GML_MAKEHANDLER1(ShadeModel) - GML_MAKEHANDLER1(UseProgram) - GML_MAKEHANDLER1(ClientActiveTextureARB) - GML_MAKEHANDLER2V(DeleteRenderbuffersEXT) - GML_MAKEHANDLER0(Flush) - GML_MAKEHANDLER3(Normal3f) - GML_MAKEHANDLER1(UseProgramObjectARB) - GML_MAKEHANDLER8VP(CompressedTexImage2DARB) - GML_MAKEHANDLER1(DeleteObjectARB) - GML_MAKEHANDLER2(Fogi) - GML_MAKEHANDLER1V(MultMatrixd) - GML_MAKEHANDLER2(PixelStorei) - GML_MAKEHANDLER2(PointParameterf) - GML_MAKEHANDLER3(TexCoord3f) - GML_MAKEHANDLER2(Uniform1i) - GML_MAKEHANDLER2(BindRenderbufferEXT) - GML_MAKEHANDLER1V(Color3fv) - GML_MAKEHANDLER1(DepthFunc) - GML_MAKEHANDLER2(Hint) - GML_MAKEHANDLER1(LogicOp) - GML_MAKEHANDLER3(StencilOp) - GML_MAKEHANDLER3V(TexEnvfv) - GML_MAKEHANDLER4V(UniformMatrix4fv) - GML_MAKEHANDLER4(uOrtho2D) - GML_MAKEHANDLER2(AttachObjectARB) - GML_MAKEHANDLER2(BindBufferARB) - GML_MAKEHANDLER1V(Color3ubv) - GML_MAKEHANDLER2(DetachObjectARB) - GML_MAKEHANDLER4(FramebufferRenderbufferEXT) - GML_MAKEHANDLER2(LineStipple) - GML_MAKEHANDLER1V(LoadMatrixd) - GML_MAKEHANDLER2(SetFenceNV) - GML_MAKEHANDLER3(StencilFunc) - GML_MAKEHANDLER10S(TexImage3D) - GML_MAKEHANDLER2(Uniform1f) - GML_MAKEHANDLER1(ClearStencil) - GML_MAKEHANDLER4(ColorPointer) - GML_MAKEHANDLER1(DeleteShader) - GML_MAKEHANDLER4VDE(DrawElements) - GML_MAKEHANDLER1(GenerateMipmap) - GML_MAKEHANDLER1(GenerateMipmapEXT) - GML_MAKEHANDLER3(Materialf) - GML_MAKEHANDLER3(NormalPointer) - GML_MAKEHANDLER3V(ProgramEnvParameter4fvARB) - GML_MAKEHANDLER4(RenderbufferStorageEXT) - GML_MAKEHANDLER1(StencilMask) - GML_MAKEHANDLER4(Uniform3f) - GML_MAKEHANDLER4(uPerspective) - GML_MAKEHANDLER1(ActiveStencilFaceEXT) - GML_MAKEHANDLER2(AttachShader) - GML_MAKEHANDLER10(BlitFramebufferEXT) - GML_MAKEHANDLER4VS(BufferDataARB) - GML_MAKEHANDLER1(ClearDepth) - GML_MAKEHANDLER3(Color3ub) - GML_MAKEHANDLER7VP(CompressedTexImage1DARB) - GML_MAKEHANDLER9VP(CompressedTexImage3DARB) - GML_MAKEHANDLER1(DrawBuffer) - GML_MAKEHANDLER1(FrontFace) - GML_MAKEHANDLER6(Frustum) - GML_MAKEHANDLER1(LinkProgramARB) - GML_MAKEHANDLER2(MultiTexCoord1f) - GML_MAKEHANDLER3(MultiTexCoord2f) - GML_MAKEHANDLER4(MultiTexCoord3f) - GML_MAKEHANDLER5(MultiTexCoord4f) - GML_MAKEHANDLER2V(PointParameterfv) - GML_MAKEHANDLER1(PointSize) - GML_MAKEHANDLER4V(ProgramStringARB) - GML_MAKEHANDLER3(SecondaryColor3f) - GML_MAKEHANDLER1(TexCoord1f) - GML_MAKEHANDLER4(TexCoord4f) - GML_MAKEHANDLER3(TexEnvf) - GML_MAKEHANDLER3(TexGenf) - GML_MAKEHANDLER8S(TexImage1D) - GML_MAKEHANDLER2(Uniform1iARB) - GML_MAKEHANDLER3(Uniform2f) - GML_MAKEHANDLER3(Uniform2fARB) - GML_MAKEHANDLER3(Uniform2i) - GML_MAKEHANDLER4(Uniform3fARB) - GML_MAKEHANDLER4(Uniform3i) - GML_MAKEHANDLER5(Uniform4f) - GML_MAKEHANDLER5(Uniform4i) - GML_MAKEHANDLER4V(UniformMatrix2fv) - GML_MAKEHANDLER4V(UniformMatrix3fv) - GML_MAKEHANDLER4(Vertex4f) - GML_MAKEHANDLER1(uDeleteQuadric) - GML_MAKEHANDLER2(uQuadricDrawStyle) - GML_MAKEHANDLER4(uSphere) - GML_MAKEHANDLER4(ClearAccum) - GML_MAKEHANDLER4(Color4ub) - GML_MAKEHANDLER1V(Color4ubv) - GML_MAKEHANDLER1(CompileShader) - GML_MAKEHANDLER1(CompileShaderARB) - GML_MAKEHANDLER8(CopyTexImage2D) - GML_MAKEHANDLER2V(DeleteBuffersARB) - GML_MAKEHANDLER2V(DeleteFencesNV) - GML_MAKEHANDLER1(DeleteProgram) - GML_MAKEHANDLER2V(DeleteProgramsARB) - GML_MAKEHANDLER2(DetachShader) - GML_MAKEHANDLER1(DisableVertexAttribArrayARB) - GML_MAKEHANDLER2V(DrawBuffersARB) - GML_MAKEHANDLER1(EdgeFlag) - GML_MAKEHANDLER1(EnableVertexAttribArrayARB) - GML_MAKEHANDLER0(Finish) - GML_MAKEHANDLER1(FinishFenceNV) - GML_MAKEHANDLER1(FogCoordf) - GML_MAKEHANDLER3(Lightf) - GML_MAKEHANDLER1(LinkProgram) - GML_MAKEHANDLER1V(Normal3fv) - GML_MAKEHANDLER2(RasterPos2i) - GML_MAKEHANDLER1(ReadBuffer) - GML_MAKEHANDLER4(Scissor) - GML_MAKEHANDLER4VSS(ShaderSource,GLchar) - GML_MAKEHANDLER4VSS(ShaderSourceARB,GLcharARB) - GML_MAKEHANDLER1V(TexCoord2fv) - GML_MAKEHANDLER3V(TexParameterfv) - GML_MAKEHANDLER3(Translated) - GML_MAKEHANDLER3V(Uniform1fv) - GML_MAKEHANDLER5(Uniform4fARB) - GML_MAKEHANDLER4V(UniformMatrix4fvARB) - GML_MAKEHANDLER6(VertexAttribPointerARB) - GML_MAKEHANDLER9(uLookAt) - GML_MAKEHANDLER2V(LightModelfv)// - GML_MAKEHANDLER2V(DeleteQueries) - GML_MAKEHANDLER1(BlendEquation) - GML_MAKEHANDLER2(StencilMaskSeparate) - GML_MAKEHANDLER4(StencilFuncSeparate) - GML_MAKEHANDLER4(StencilOpSeparate) - GML_MAKEHANDLER2(BeginQuery) - GML_MAKEHANDLER1(EndQuery) - GML_MAKEHANDLER3(GetQueryObjectiv) - GML_MAKEHANDLER3(GetQueryObjectuiv) - GML_MAKEHANDLER2(BlendEquationSeparate) - GML_MAKEHANDLER4(BlendFuncSeparate) - GML_MAKEHANDLER6(uCylinder) - GML_MAKEHANDLER2V(DeleteBuffers)// - GML_MAKEHANDLER2(BindBuffer) - GML_MAKEHANDLER4VS(BufferData) - GML_MAKEHANDLER2R(MapBuffer) - GML_MAKEHANDLER1R(UnmapBuffer) - GML_MAKEHANDLER8VP(CompressedTexImage2D) - GML_MAKEHANDLER1R(IsShader) - GML_MAKEHANDLER1R(IsProgram) - GML_MAKEHANDLER3(Vertex3i) - GML_MAKEHANDLER2(GetIntegerv)// - GML_MAKEHANDLER1R(CheckFramebufferStatusEXT) - GML_MAKEHANDLER2(GetFloatv) - GML_MAKEHANDLER1R(GetString) - GML_MAKEHANDLER2R(GetUniformLocationARB) - GML_MAKEHANDLER7(ReadPixels) - GML_MAKEHANDLER0R(GetError) - GML_MAKEHANDLER3(GetObjectParameterivARB) - GML_MAKEHANDLER2R(GetUniformLocation) - GML_MAKEHANDLER2(GetDoublev) - GML_MAKEHANDLER3(GetProgramiv) - GML_MAKEHANDLER7(GetActiveUniform) - GML_MAKEHANDLER2R(GetAttribLocationARB) - GML_MAKEHANDLER4(GetInfoLogARB) - GML_MAKEHANDLER4(GetProgramInfoLog) - GML_MAKEHANDLER3(GetProgramivARB) - GML_MAKEHANDLER4(GetShaderInfoLog) - GML_MAKEHANDLER3(GetShaderiv) - GML_MAKEHANDLER1R(IsRenderbufferEXT) - GML_MAKEHANDLER2R(MapBufferARB) - GML_MAKEHANDLER9R(uProject) - GML_MAKEHANDLER9R(uScaleImage) - GML_MAKEHANDLER1R(TestFenceNV) - GML_MAKEHANDLER3(IndexPointer)// - GML_MAKEHANDLER2(EdgeFlagPointer) - GML_MAKEHANDLER4(TrackMatrixNV) - GML_MAKEHANDLER3(ProgramParameteriEXT) - GML_MAKEHANDLER4(BlendColor) - GML_MAKEHANDLER6V(Map1f) - GML_MAKEHANDLER10V(Map2f) - GML_MAKEHANDLER3(MapGrid1f) - GML_MAKEHANDLER6(MapGrid2f) - GML_MAKEHANDLER3(EvalMesh1) - GML_MAKEHANDLER5(EvalMesh2) - GML_MAKEHANDLER1(EvalCoord1f) - GML_MAKEHANDLER2(EvalCoord2f) - GML_MAKEHANDLER1(EvalPoint1) - GML_MAKEHANDLER2(EvalPoint2) - GML_MAKEHANDLER1R(RenderMode) - GML_MAKEHANDLER2(SelectBuffer) - GML_MAKEHANDLER0(InitNames) - GML_MAKEHANDLER1(LoadName) - GML_MAKEHANDLER1(PushName) - GML_MAKEHANDLER0(PopName) - GML_MAKEHANDLER4(GetTexLevelParameteriv) - GML_MAKEHANDLER4(GetFramebufferAttachmentParameterivEXT) - GML_MAKEHANDLER3(GetRenderbufferParameterivEXT) - GML_MAKEHANDLER5(GetTexImage) - GML_MAKEHANDLER1R(IsTexture) - GML_MAKEHANDLER5(FramebufferTexture1DEXT) - GML_MAKEHANDLER6(FramebufferTexture3DEXT) - GML_MAKEHANDLER1(ClientActiveTexture) - GML_MAKEHANDLER3(MultiTexCoord2i) - GML_MAKEHANDLER3(GetQueryiv) - GML_MAKEHANDLER2(GetBooleanv) - GML_MAKEHANDLER1(ValidateProgram) - GML_MAKEHANDLER3V(Uniform1iv) - GML_MAKEHANDLER3V(Uniform2iv) - GML_MAKEHANDLER3V(Uniform3iv) - GML_MAKEHANDLER3V(Uniform4iv) - GML_MAKEHANDLER3V(Uniform2fv) - GML_MAKEHANDLER3V(Uniform3fv) - GML_MAKEHANDLER3V(Uniform4fv) - GML_MAKEHANDLER3V(Uniform1uiv) - GML_MAKEHANDLER3V(Uniform2uiv) - GML_MAKEHANDLER3V(Uniform3uiv) - GML_MAKEHANDLER3V(Uniform4uiv) - GML_MAKEHANDLER4R(MapBufferRange) - GML_MAKEHANDLER1(PrimitiveRestartIndexNV) - GML_MAKEHANDLER6VDRE(DrawRangeElements) - GML_MAKEHANDLER3(GetUniformfv) - GML_MAKEHANDLER3(GetUniformiv) - GML_MAKEHANDLER3(GetUniformuiv) - GML_MAKEHANDLER7(GetActiveAttrib) - GML_MAKEHANDLER2(GetAttribLocation) - GML_MAKEHANDLER3(BindAttribLocation) - GML_MAKEHANDLER3(GetCompressedTexImage) - } -} - -// Execute - executes all GL commands in the current read queue. -// Execution is non-synced -void gmlQueue::Execute() { -// int procs=0; - BYTE *p=Read; - BYTE *e=ReadPos; - BYTE *ptr=NULL; - while(p1 || (procs==1 && *(int *)Read!=GML_NOP)) -// LOG_SL("Threading", L_ERROR, "%d OpenGL calls detected in SimFrame()", procs); -} - -#include "gmlsrv.h" -class CUnit; -gmlClientServer *gmlProcessor=NULL; - -// ExecuteSynced - executes all GL commands in the current read queue. -// Execution is synced (this means it will stop at certain points -// to return values to the worker thread) -void gmlQueue::ExecuteSynced(void (gmlQueue::*execfun)() ) { -//int procs=0; -#if GML_ALTERNATE_SYNCMODE - BYTE *s; - while(1) { - int updsrv=0; - while((s=(BYTE *)Sync)==EXEC_RUN) { - if(Reloc) - Realloc(); - if(!gmlShareLists && ((updsrv++%GML_UPDSRV_INTERVAL)==0 || *(volatile int *)&gmlItemsConsumed>=GML_UPDSRV_INTERVAL)) - gmlUpdateServers(); - if(GetRead()) { - (this->*execfun)(); - ReleaseRead(); - } - boost::thread::yield(); - } - - if(s!=EXEC_SYNC) { // end addr - Sync=EXEC_SYNC; //NEW - GetRead(TRUE); - Sync=EXEC_RUN; // cannot allow worker to continue before right queue acquired - (this->*execfun)(); - ReleaseRead(); - break; - } - - Sync=EXEC_RUN; // sync confirmed - GetRead(TRUE); - (this->*execfun)(); - - GML_MEMBAR; //# - - Sync=EXEC_RES; // result available - ReleaseRead(); - while(Sync==EXEC_RES) // waiting for worker to acquire result - boost::thread::yield(); - } -#else - BYTE *p=Write; - BYTE *e=WritePos; - BYTE *ptr=NULL; - BOOL_ isq1=Write==Queue1; - BOOL_ end=FALSE; - int updsrv=0; - - while(TRUE) { - if(!end) { - while(TRUE) { - if(Reloc) - e=Realloc(&p); - if(!gmlShareLists && ((updsrv++%GML_UPDSRV_INTERVAL)==0 || *(volatile int *)&gmlItemsConsumed>=GML_UPDSRV_INTERVAL)) - gmlUpdateServers(); - BYTE *s=(BYTE *)Sync; - if(s!=EXEC_RUN) { - if(s!=EXEC_SYNC) { // end addr ready - end=TRUE; - e=s; - Sync=EXEC_RUN; - break; - } - if(p==*(BYTE * volatile *)&WritePos) // reached sync point - Sync=EXEC_RUN; - } - if(p<*(BYTE * volatile *)&WritePos) - break; - } - } - if(end) { - if(p==e) - break; - } -// GML_DEBUG("CmdSync ",*(int *)p, 2); - QueueHandler(p,ptr); -// ++procs; - } - if(isq1) { - while(Locked1) - boost::thread::yield(); - Pos1=Queue1; - } - else { - while(Locked2) - boost::thread::yield(); - Pos2=Queue2; - } -#endif -// GML_DEBUG("ExecuteSync ",procs, 2); -} - -#endif diff -Nru spring-96.0~14.04~ppa4/rts/lib/gml/gmldef.h spring-98.0~14.04~ppa6/rts/lib/gml/gmldef.h --- spring-96.0~14.04~ppa4/rts/lib/gml/gmldef.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/gml/gmldef.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,627 +0,0 @@ -// GML - OpenGL Multithreading Library -// for Spring http://springrts.com -// Author: Mattias "zerver" Radeskog -// (C) Ware Zerver Tech. http://zerver.net -// Ware Zerver Tech. licenses this library -// to be used, distributed and modified -// freely for any purpose, as long as -// this notice remains unchanged - -#undef glActiveStencilFaceEXT -#undef glActiveTexture -#undef glActiveTextureARB -#undef glAlphaFunc -#undef glAttachObjectARB -#undef glAttachShader -#undef glBegin -#undef glBeginQuery -#undef glBindAttribLocation -#undef glBindBuffer -#undef glBindBufferARB -#undef glBindFramebufferEXT -#undef glBindProgramARB -#undef glBindRenderbufferEXT -#undef glBindTexture -#undef glBlendColor -#undef glBlendEquation -#undef glBlendEquationSeparate -#undef glBlendFunc -#undef glBlendFuncSeparate -#undef glBlitFramebufferEXT -#undef glBufferData -#undef glBufferDataARB -#undef glCallList -#undef glCheckFramebufferStatusEXT -#undef glClear -#undef glClearAccum -#undef glClearColor -#undef glClearDepth -#undef glClearStencil -#undef glClientActiveTexture -#undef glClientActiveTextureARB -#undef glClipPlane -#undef glColor3f -#undef glColor3fv -#undef glColor3ub -#undef glColor3ubv -#undef glColor4d -#undef glColor4f -#undef glColor4fv -#undef glColor4ub -#undef glColor4ubv -#undef glColorMask -#undef glColorPointer -#undef glCompileShader -#undef glCompileShaderARB -#undef glCompressedTexImage1DARB -#undef glCompressedTexImage2D -#undef glCompressedTexImage2DARB -#undef glCompressedTexImage3DARB -#undef glCopyTexImage2D -#undef glCopyTexSubImage2D -#undef glCreateProgram -#undef glCreateProgramObjectARB -#undef glCreateShader -#undef glCreateShaderObjectARB -#undef glCullFace -#undef glDeleteBuffers -#undef glDeleteBuffersARB -#undef glDeleteFencesNV -#undef glDeleteFramebuffersEXT -#undef glDeleteLists -#undef glDeleteObjectARB -#undef glDeleteProgram -#undef glDeleteProgramsARB -#undef glDeleteQueries -#undef glDeleteRenderbuffersEXT -#undef glDeleteShader -#undef glDeleteTextures -#undef glDepthFunc -#undef glDepthMask -#undef glDetachObjectARB -#undef glDetachShader -#undef glDisable -#undef glDisableClientState -#undef glDisableVertexAttribArrayARB -#undef glDrawArrays -#undef glDrawBuffer -#undef glDrawBuffersARB -#undef glDrawElements -#undef glDrawRangeElements -#undef glEdgeFlag -#undef glEdgeFlagPointer -#undef glEnable -#undef glEnableClientState -#undef glEnableVertexAttribArrayARB -#undef glEnd -#undef glEndList -#undef glEndQuery -#undef glEvalCoord1f -#undef glEvalCoord2f -#undef glEvalMesh1 -#undef glEvalMesh2 -#undef glEvalPoint1 -#undef glEvalPoint2 -#undef glFinish -#undef glFinishFenceNV -#undef glFlush -#undef glFogCoordf -#undef glFogf -#undef glFogfv -#undef glFogi -#undef glFramebufferRenderbufferEXT -#undef glFramebufferTexture1DEXT -#undef glFramebufferTexture2DEXT -#undef glFramebufferTexture3DEXT -#undef glFramebufferTextureEXT -#undef glFrontFace -#undef glFrustum -#undef glGenBuffers -#undef glGenBuffersARB -#undef glGenFencesNV -#undef glGenFramebuffersEXT -#undef glGenLists -#undef glGenProgramsARB -#undef glGenQueries -#undef glGenRenderbuffersEXT -#undef glGenTextures -#undef glGenerateMipmap -#undef glGenerateMipmapEXT -#undef glGetActiveAttrib -#undef glGetActiveUniform -#undef glGetAttribLocation -#undef glGetAttribLocationARB -#undef glGetBooleanv -#undef glGetCompressedTexImage -#undef glGetDoublev -#undef glGetError -#undef glGetFloatv -#undef glGetFramebufferAttachmentParameterivEXT -#undef glGetInfoLogARB -#undef glGetIntegerv -#undef glGetObjectParameterivARB -#undef glGetProgramInfoLog -#undef glGetProgramiv -#undef glGetProgramivARB -#undef glGetQueryObjectiv -#undef glGetQueryObjectuiv -#undef glGetQueryiv -#undef glGetRenderbufferParameterivEXT -#undef glGetShaderInfoLog -#undef glGetShaderiv -#undef glGetString -#undef glGetTexImage -#undef glGetTexLevelParameteriv -#undef glGetUniformfv -#undef glGetUniformiv -#undef glGetUniformuiv -#undef glGetUniformLocation -#undef glGetUniformLocationARB -#undef glHint -#undef glIndexPointer -#undef glInitNames -#undef glIsProgram -#undef glIsRenderbufferEXT -#undef glIsShader -#undef glIsTexture -#undef glLightModelfv -#undef glLightModeli -#undef glLightf -#undef glLightfv -#undef glLineStipple -#undef glLineWidth -#undef glLinkProgram -#undef glLinkProgramARB -#undef glLoadIdentity -#undef glLoadMatrixd -#undef glLoadMatrixf -#undef glLoadName -#undef glLogicOp -#undef glMap1f -#undef glMap2f -#undef glMapBuffer -#undef glMapBufferARB -#undef glMapBufferRange -#undef glMapGrid1f -#undef glMapGrid2f -#undef glMaterialf -#undef glMaterialfv -#undef glMatrixMode -#undef glMultMatrixd -#undef glMultMatrixf -#undef glMultiTexCoord1f -#undef glMultiTexCoord2f -#undef glMultiTexCoord2fARB -#undef glMultiTexCoord2i -#undef glMultiTexCoord3f -#undef glMultiTexCoord4f -#undef glNewList -#undef glNormal3f -#undef glNormal3fv -#undef glNormalPointer -#undef glOrtho -#undef glPixelStorei -#undef glPointParameterf -#undef glPointParameterfv -#undef glPointSize -#undef glPolygonMode -#undef glPolygonOffset -#undef glPopAttrib -#undef glPopMatrix -#undef glPopName -#undef glPrimitiveRestartIndexNV -#undef glProgramEnvParameter4fARB -#undef glProgramEnvParameter4fvARB -#undef glProgramParameteriEXT -#undef glProgramStringARB -#undef glPushAttrib -#undef glPushMatrix -#undef glPushName -#undef glRasterPos2i -#undef glReadBuffer -#undef glReadPixels -#undef glRectf -#undef glRenderMode -#undef glRenderbufferStorageEXT -#undef glRotatef -#undef glScalef -#undef glScissor -#undef glSecondaryColor3f -#undef glSelectBuffer -#undef glSetFenceNV -#undef glShadeModel -#undef glShaderSource -#undef glShaderSourceARB -#undef glStencilFunc -#undef glStencilFuncSeparate -#undef glStencilMask -#undef glStencilMaskSeparate -#undef glStencilOp -#undef glStencilOpSeparate -#undef glTestFenceNV -#undef glTexCoord1f -#undef glTexCoord2f -#undef glTexCoord2fv -#undef glTexCoord3f -#undef glTexCoord4f -#undef glTexCoordPointer -#undef glTexEnvf -#undef glTexEnvfv -#undef glTexEnvi -#undef glTexGenf -#undef glTexGenfv -#undef glTexGeni -#undef glTexImage1D -#undef glTexImage2D -#undef glTexImage3D -#undef glTexParameterf -#undef glTexParameterfv -#undef glTexParameteri -#undef glTexSubImage2D -#undef glTrackMatrixNV -#undef glTranslated -#undef glTranslatef -#undef glUniform1f -#undef glUniform1fv -#undef glUniform1i -#undef glUniform1iv -#undef glUniform1iARB -#undef glUniform1uiv -#undef glUniform2f -#undef glUniform2fARB -#undef glUniform2fv -#undef glUniform2i -#undef glUniform2iv -#undef glUniform2uiv -#undef glUniform3f -#undef glUniform3fARB -#undef glUniform3fv -#undef glUniform3i -#undef glUniform3iv -#undef glUniform3uiv -#undef glUniform4f -#undef glUniform4fARB -#undef glUniform4fv -#undef glUniform4i -#undef glUniform4iv -#undef glUniform4uiv -#undef glUniformMatrix2fv -#undef glUniformMatrix3fv -#undef glUniformMatrix4fv -#undef glUniformMatrix4fvARB -#undef glUnmapBuffer -#undef glUseProgram -#undef glUseProgramObjectARB -#undef glValidateProgram -#undef glVertex2d -#undef glVertex2f -#undef glVertex3f -#undef glVertex3fv -#undef glVertex3i -#undef glVertex4f -#undef glVertexAttribPointerARB -#undef glVertexPointer -#undef glViewport -#undef gluBuild2DMipmaps -#undef gluCylinder -#undef gluDeleteQuadric -#undef gluLookAt -#undef gluNewQuadric -#undef gluOrtho2D -#undef gluPerspective -#undef gluProject -#undef gluQuadricDrawStyle -#undef gluScaleImage -#undef gluSphere - - -// ##################################################################### - -#define GML_NULL_CHECK(name) (GLEW_GET_FUN(__glew##name) ? &gml##name : GLEW_GET_FUN(__glew##name)) - -#define glActiveStencilFaceEXT gmlActiveStencilFaceEXT -#define glActiveTexture gmlActiveTexture -#define glActiveTextureARB gmlActiveTextureARB -#define glAlphaFunc gmlAlphaFunc -#define glAttachObjectARB gmlAttachObjectARB -#define glAttachShader gmlAttachShader -#define glBegin gmlBegin -#define glBeginQuery gmlBeginQuery -#define glBindAttribLocation gmlBindAttribLocation -#define glBindBuffer gmlBindBuffer -#define glBindBufferARB gmlBindBufferARB -#define glBindFramebufferEXT gmlBindFramebufferEXT -#define glBindProgramARB GML_NULL_CHECK(BindProgramARB) -#define glBindRenderbufferEXT gmlBindRenderbufferEXT -#define glBindTexture gmlBindTexture -#define glBlendColor gmlBlendColor -#define glBlendEquation GML_NULL_CHECK(BlendEquation) -#define glBlendEquationSeparate gmlBlendEquationSeparate -#define glBlendFunc gmlBlendFunc -#define glBlendFuncSeparate gmlBlendFuncSeparate -#define glBlitFramebufferEXT gmlBlitFramebufferEXT -#define glBufferData gmlBufferData -#define glBufferDataARB gmlBufferDataARB -#define glCallList gmlCallList -#define glCheckFramebufferStatusEXT gmlCheckFramebufferStatusEXT -#define glClear gmlClear -#define glClearAccum gmlClearAccum -#define glClearColor gmlClearColor -#define glClearDepth gmlClearDepth -#define glClearStencil gmlClearStencil -#define glClientActiveTexture gmlClientActiveTexture -#define glClientActiveTextureARB gmlClientActiveTextureARB -#define glClipPlane gmlClipPlane -#define glColor3f gmlColor3f -#define glColor3fv gmlColor3fv -#define glColor3ub gmlColor3ub -#define glColor3ubv gmlColor3ubv -#define glColor4d gmlColor4d -#define glColor4f gmlColor4f -#define glColor4fv gmlColor4fv -#define glColor4ub gmlColor4ub -#define glColor4ubv gmlColor4ubv -#define glColorMask gmlColorMask -#define glColorPointer gmlColorPointer -#define glCompileShader gmlCompileShader -#define glCompileShaderARB gmlCompileShaderARB -#define glCompressedTexImage1DARB gmlCompressedTexImage1DARB -#define glCompressedTexImage2D gmlCompressedTexImage2D -#define glCompressedTexImage2DARB gmlCompressedTexImage2DARB -#define glCompressedTexImage3DARB gmlCompressedTexImage3DARB -#define glCopyTexImage2D gmlCopyTexImage2D -#define glCopyTexSubImage2D gmlCopyTexSubImage2D -#define glCreateProgram GML_NULL_CHECK(CreateProgram) -#define glCreateProgramObjectARB gmlCreateProgramObjectARB -#define glCreateShader GML_NULL_CHECK(CreateShader) -#define glCreateShaderObjectARB gmlCreateShaderObjectARB -#define glCullFace gmlCullFace -#define glDeleteBuffers gmlDeleteBuffers -#define glDeleteBuffersARB gmlDeleteBuffersARB -#define glDeleteFencesNV gmlDeleteFencesNV -#define glDeleteFramebuffersEXT gmlDeleteFramebuffersEXT -#define glDeleteLists gmlDeleteLists -#define glDeleteObjectARB gmlDeleteObjectARB -#define glDeleteProgram GML_NULL_CHECK(DeleteProgram) -#define glDeleteProgramsARB GML_NULL_CHECK(DeleteProgramsARB) -#define glDeleteQueries gmlDeleteQueries -#define glDeleteRenderbuffersEXT gmlDeleteRenderbuffersEXT -#define glDeleteShader GML_NULL_CHECK(DeleteShader) -#define glDeleteTextures gmlDeleteTextures -#define glDepthFunc gmlDepthFunc -#define glDepthMask gmlDepthMask -#define glDetachObjectARB gmlDetachObjectARB -#define glDetachShader gmlDetachShader -#define glDisable gmlDisable -#define glDisableClientState gmlDisableClientState -#define glDisableVertexAttribArrayARB gmlDisableVertexAttribArrayARB -#define glDrawArrays gmlDrawArrays -#define glDrawBuffer gmlDrawBuffer -#define glDrawBuffersARB gmlDrawBuffersARB -#define glDrawElements gmlDrawElements -#define glDrawRangeElements gmlDrawRangeElements -#define glEdgeFlag gmlEdgeFlag -#define glEdgeFlagPointer gmlEdgeFlagPointer -#define glEnable gmlEnable -#define glEnableClientState gmlEnableClientState -#define glEnableVertexAttribArrayARB gmlEnableVertexAttribArrayARB -#define glEnd gmlEnd -#define glEndList gmlEndList -#define glEndQuery gmlEndQuery -#define glEvalCoord1f gmlEvalCoord1f -#define glEvalCoord2f gmlEvalCoord2f -#define glEvalMesh1 gmlEvalMesh1 -#define glEvalMesh2 gmlEvalMesh2 -#define glEvalPoint1 gmlEvalPoint1 -#define glEvalPoint2 gmlEvalPoint2 -#define glFinish gmlFinish -#define glFinishFenceNV gmlFinishFenceNV -#define glFlush gmlFlush -#define glFogCoordf gmlFogCoordf -#define glFogf gmlFogf -#define glFogfv gmlFogfv -#define glFogi gmlFogi -#define glFramebufferRenderbufferEXT gmlFramebufferRenderbufferEXT -#define glFramebufferTexture1DEXT gmlFramebufferTexture1DEXT -#define glFramebufferTexture2DEXT gmlFramebufferTexture2DEXT -#define glFramebufferTexture3DEXT gmlFramebufferTexture3DEXT -#define glFramebufferTextureEXT gmlFramebufferTextureEXT -#define glFrontFace gmlFrontFace -#define glFrustum gmlFrustum -#define glGenBuffers gmlGenBuffers -#define glGenBuffersARB gmlGenBuffersARB -#define glGenFencesNV gmlGenFencesNV -#define glGenFramebuffersEXT gmlGenFramebuffersEXT -#define glGenLists gmlGenLists -#define glGenProgramsARB GML_NULL_CHECK(GenProgramsARB) -#define glGenQueries gmlGenQueries -#define glGenRenderbuffersEXT gmlGenRenderbuffersEXT -#define glGenTextures gmlGenTextures -#define glGenerateMipmap GML_NULL_CHECK(GenerateMipmap) -#define glGenerateMipmapEXT GML_NULL_CHECK(GenerateMipmapEXT) -#define glGetActiveAttrib gmlGetActiveAttrib -#define glGetActiveUniform gmlGetActiveUniform -#define glGetAttribLocation gmlGetAttribLocation -#define glGetAttribLocationARB gmlGetAttribLocationARB -#define glGetBooleanv gmlGetBooleanv -#define glGetDoublev gmlGetDoublev -#define glGetCompressedTexImage gmlGetCompressedTexImage -#define glGetError gmlGetError -#define glGetFloatv gmlGetFloatv -#define glGetFramebufferAttachmentParameterivEXT gmlGetFramebufferAttachmentParameterivEXT -#define glGetInfoLogARB gmlGetInfoLogARB -#define glGetIntegerv gmlGetIntegerv -#define glGetObjectParameterivARB gmlGetObjectParameterivARB -#define glGetProgramInfoLog gmlGetProgramInfoLog -#define glGetProgramiv gmlGetProgramiv -#define glGetProgramivARB gmlGetProgramivARB -#define glGetQueryObjectiv gmlGetQueryObjectiv -#define glGetQueryObjectuiv gmlGetQueryObjectuiv -#define glGetQueryiv gmlGetQueryiv -#define glGetRenderbufferParameterivEXT gmlGetRenderbufferParameterivEXT -#define glGetShaderInfoLog gmlGetShaderInfoLog -#define glGetShaderiv gmlGetShaderiv -#define glGetString gmlGetString -#define glGetTexImage gmlGetTexImage -#define glGetTexLevelParameteriv gmlGetTexLevelParameteriv -#define glGetUniformfv gmlGetUniformfv -#define glGetUniformiv gmlGetUniformiv -#define glGetUniformuiv gmlGetUniformuiv -#define glGetUniformLocation gmlGetUniformLocation -#define glGetUniformLocationARB gmlGetUniformLocationARB -#define glHint gmlHint -#define glIndexPointer gmlIndexPointer -#define glInitNames gmlInitNames -#define glIsProgram gmlIsProgram -#define glIsRenderbufferEXT gmlIsRenderbufferEXT -#define glIsShader gmlIsShader -#define glIsTexture gmlIsTexture -#define glLightModelfv gmlLightModelfv -#define glLightModeli gmlLightModeli -#define glLightf gmlLightf -#define glLightfv gmlLightfv -#define glLineStipple gmlLineStipple -#define glLineWidth gmlLineWidth -#define glLinkProgram GML_NULL_CHECK(LinkProgram) -#define glLinkProgramARB gmlLinkProgramARB -#define glLoadIdentity gmlLoadIdentity -#define glLoadMatrixd gmlLoadMatrixd -#define glLoadMatrixf gmlLoadMatrixf -#define glLoadName gmlLoadName -#define glLogicOp gmlLogicOp -#define glMap1f gmlMap1f -#define glMap2f gmlMap2f -#define glMapBuffer gmlMapBuffer -#define glMapBufferARB gmlMapBufferARB -#define glMapBufferRange gmlMapBufferRange -#define glMapGrid1f gmlMapGrid1f -#define glMapGrid2f gmlMapGrid2f -#define glMaterialf gmlMaterialf -#define glMaterialfv gmlMaterialfv -#define glMatrixMode gmlMatrixMode -#define glMultMatrixd gmlMultMatrixd -#define glMultMatrixf gmlMultMatrixf -#define glMultiTexCoord1f gmlMultiTexCoord1f -#define glMultiTexCoord2f gmlMultiTexCoord2f -#define glMultiTexCoord2fARB gmlMultiTexCoord2fARB -#define glMultiTexCoord2i gmlMultiTexCoord2i -#define glMultiTexCoord3f gmlMultiTexCoord3f -#define glMultiTexCoord4f gmlMultiTexCoord4f -#define glNewList gmlNewList -#define glNormal3f gmlNormal3f -#define glNormal3fv gmlNormal3fv -#define glNormalPointer gmlNormalPointer -#define glOrtho gmlOrtho -#define glPixelStorei gmlPixelStorei -#define glPointParameterf gmlPointParameterf -#define glPointParameterfv gmlPointParameterfv -#define glPointSize gmlPointSize -#define glPolygonMode gmlPolygonMode -#define glPolygonOffset gmlPolygonOffset -#define glPopAttrib gmlPopAttrib -#define glPopMatrix gmlPopMatrix -#define glPopName gmlPopName -#define glPrimitiveRestartIndexNV gmlPrimitiveRestartIndexNV -#define glProgramEnvParameter4fARB gmlProgramEnvParameter4fARB -#define glProgramEnvParameter4fvARB gmlProgramEnvParameter4fvARB -#define glProgramParameteriEXT GML_NULL_CHECK(ProgramParameteriEXT) -#define glProgramStringARB gmlProgramStringARB -#define glPushAttrib gmlPushAttrib -#define glPushMatrix gmlPushMatrix -#define glPushName gmlPushName -#define glRasterPos2i gmlRasterPos2i -#define glReadBuffer gmlReadBuffer -#define glReadPixels gmlReadPixels -#define glRectf gmlRectf -#define glRenderMode gmlRenderMode -#define glRenderbufferStorageEXT gmlRenderbufferStorageEXT -#define glRotatef gmlRotatef -#define glScalef gmlScalef -#define glScissor gmlScissor -#define glSecondaryColor3f gmlSecondaryColor3f -#define glSelectBuffer gmlSelectBuffer -#define glSetFenceNV gmlSetFenceNV -#define glShadeModel gmlShadeModel -#define glShaderSource GML_NULL_CHECK(ShaderSource) -#define glShaderSourceARB gmlShaderSourceARB -#define glStencilFunc gmlStencilFunc -#define glStencilFuncSeparate gmlStencilFuncSeparate -#define glStencilMask gmlStencilMask -#define glStencilMaskSeparate gmlStencilMaskSeparate -#define glStencilOp gmlStencilOp -#define glStencilOpSeparate gmlStencilOpSeparate -#define glTestFenceNV gmlTestFenceNV -#define glTexCoord1f gmlTexCoord1f -#define glTexCoord2f gmlTexCoord2f -#define glTexCoord2fv gmlTexCoord2fv -#define glTexCoord3f gmlTexCoord3f -#define glTexCoord4f gmlTexCoord4f -#define glTexCoordPointer gmlTexCoordPointer -#define glTexEnvf gmlTexEnvf -#define glTexEnvfv gmlTexEnvfv -#define glTexEnvi gmlTexEnvi -#define glTexGenf gmlTexGenf -#define glTexGenfv gmlTexGenfv -#define glTexGeni gmlTexGeni -#define glTexImage1D gmlTexImage1D -#define glTexImage2D gmlTexImage2D -#define glTexImage3D gmlTexImage3D -#define glTexParameterf gmlTexParameterf -#define glTexParameterfv gmlTexParameterfv -#define glTexParameteri gmlTexParameteri -#define glTexSubImage2D gmlTexSubImage2D -#define glTrackMatrixNV gmlTrackMatrixNV -#define glTranslated gmlTranslated -#define glTranslatef gmlTranslatef -#define glUniform1f gmlUniform1f -#define glUniform1fv gmlUniform1fv -#define glUniform1i gmlUniform1i -#define glUniform1iv gmlUniform1iv -#define glUniform1iARB gmlUniform1iARB -#define glUniform1uiv gmlUniform1uiv -#define glUniform2f gmlUniform2f -#define glUniform2fARB gmlUniform2fARB -#define glUniform2fv gmlUniform2fv -#define glUniform2i gmlUniform2i -#define glUniform2iv gmlUniform2iv -#define glUniform2uiv gmlUniform2uiv -#define glUniform3f gmlUniform3f -#define glUniform3fARB gmlUniform3fARB -#define glUniform3fv gmlUniform3fv -#define glUniform3i gmlUniform3i -#define glUniform3iv gmlUniform3iv -#define glUniform3uiv gmlUniform3uiv -#define glUniform4f gmlUniform4f -#define glUniform4fARB gmlUniform4fARB -#define glUniform4fv gmlUniform4fv -#define glUniform4i gmlUniform4i -#define glUniform4iv gmlUniform4iv -#define glUniform4uiv gmlUniform4uiv -#define glUniformMatrix2fv gmlUniformMatrix2fv -#define glUniformMatrix3fv gmlUniformMatrix3fv -#define glUniformMatrix4fv gmlUniformMatrix4fv -#define glUniformMatrix4fvARB gmlUniformMatrix4fvARB -#define glUnmapBuffer gmlUnmapBuffer -#define glUseProgram GML_NULL_CHECK(UseProgram) -#define glUseProgramObjectARB gmlUseProgramObjectARB -#define glValidateProgram gmlValidateProgram -#define glVertex2d gmlVertex2d -#define glVertex2f gmlVertex2f -#define glVertex3f gmlVertex3f -#define glVertex3fv gmlVertex3fv -#define glVertex3i gmlVertex3i -#define glVertex4f gmlVertex4f -#define glVertexAttribPointerARB gmlVertexAttribPointerARB -#define glVertexPointer gmlVertexPointer -#define glViewport gmlViewport -#define gluBuild2DMipmaps gmluBuild2DMipmaps -#define gluCylinder gmluCylinder -#define gluDeleteQuadric gmluDeleteQuadric -#define gluLookAt gmluLookAt -#define gluNewQuadric gmluNewQuadric -#define gluOrtho2D gmluOrtho2D -#define gluPerspective gmluPerspective -#define gluProject gmluProject -#define gluQuadricDrawStyle gmluQuadricDrawStyle -#define gluScaleImage gmluScaleImage -#define gluSphere gmluSphere diff -Nru spring-96.0~14.04~ppa4/rts/lib/gml/gmlfun.h spring-98.0~14.04~ppa6/rts/lib/gml/gmlfun.h --- spring-96.0~14.04~ppa4/rts/lib/gml/gmlfun.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/gml/gmlfun.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,1452 +0,0 @@ -// GML - OpenGL Multithreading Library -// for Spring http://springrts.com -// Author: Mattias "zerver" Radeskog -// (C) Ware Zerver Tech. http://zerver.net -// Ware Zerver Tech. licenses this library -// to be used, distributed and modified -// freely for any purpose, as long as -// this notice remains unchanged - -#ifndef _GML_FUN_H -#define _GML_FUN_H - -#include -#include -#include "System/Log/ILog.h" -#include -#include -#include - -#define GML_ENABLE_DEBUG 0 - -#if GML_ENABLE_DEBUG -#define GML_DEBUG(str,val,type)\ -if(type==GML_ENABLE_DEBUG) {\ - FILE *f=fopen("C:\\GMLDBG.TXT","a");\ - if(f) {\ - fprintf(f,"%s line %d: %s %d\n",__FILE__,__LINE__,str,val);\ - fclose(f);\ - }\ -} -#else -#define GML_DEBUG(str,val,type) -#endif - -extern std::map gmlGetIntegervCache; -extern std::map gmlGetFloatvCache; -extern std::map gmlGetStringCache; -#define GML_CACHE(d,v,c,K,R) if(GML_USE_CACHE) {std::map::iterator it=c.find(K); if(it!=c.end()) {*R=(*it).second; return;}} -#define GML_CACHE_RET_STR(d,v,c,K) if(GML_USE_CACHE) {std::map::iterator it=c.find(K); if(it!=c.end()) {return (GLubyte *)(*it).second.c_str();}} -#define GML_DEFAULT(c,r) if(GML_USE_DEFAULT && (c)) {r; return;} -#define GML_DEFAULT_RET(c,r) if(GML_USE_DEFAULT && (c)) {return r;} -#define GML_DEFAULT_ERROR() if(GML_USE_NO_ERROR) return GL_NO_ERROR; - -//teximage, build2dmip -EXTERN inline int gmlNumArgsTexImage(int datatype) { - switch(datatype) { - case GL_COLOR_INDEX: - case GL_RED: - case GL_GREEN: - case GL_BLUE: - case GL_ALPHA: - case GL_LUMINANCE: - case GL_DEPTH_COMPONENT: - return 1; - case GL_LUMINANCE_ALPHA: - return 2; - case GL_RGB: - case GL_BGR_EXT: - return 3; - case GL_RGBA: - case GL_BGRA_EXT: - return 4; - default: - GML_DEBUG("gmlNumArgsTexImage", datatype, 1) - return 0; - } -} - -// glLight, glMaterial -EXTERN inline int gmlNumArgsLightMat(int datatype) { - switch(datatype) { - case GL_AMBIENT: - case GL_DIFFUSE: - case GL_SPECULAR: - case GL_EMISSION: // material - case GL_AMBIENT_AND_DIFFUSE: //mat - case GL_POSITION: - return 4; - case GL_SPOT_DIRECTION: - case GL_COLOR_INDEXES: //mat - return 3; - case GL_SHININESS: // mat - case GL_SPOT_EXPONENT: - case GL_SPOT_CUTOFF: - case GL_CONSTANT_ATTENUATION: - case GL_LINEAR_ATTENUATION: - case GL_QUADRATIC_ATTENUATION: - return 1; - default: - GML_DEBUG("gmlNumArgsLightMat", datatype, 1) - return 0; - } -} - -//glFog -EXTERN inline int gmlNumArgsFog(int datatype) { - switch(datatype) { - case GL_FOG_MODE: - case GL_FOG_DENSITY: - case GL_FOG_START: - case GL_FOG_END: - case GL_FOG_INDEX: - return 1; - case GL_FOG_COLOR: - return 4; - default: - GML_DEBUG("gmlNumArgsFog", datatype, 1) - return 0; - } -} - -//glTexGen -EXTERN inline int gmlNumArgsTexGen(int datatype) { - switch(datatype) { - case GL_TEXTURE_GEN_MODE: - return 1; - case GL_OBJECT_PLANE: - case GL_EYE_PLANE: - return 4; - default: - GML_DEBUG("gmlNumArgsTexGen", datatype, 1) - return 0; - } -} - -//glTexEnv -EXTERN inline int gmlNumArgsTexEnv(int datatype) { - switch(datatype) { - case GL_TEXTURE_ENV_MODE: - return 1; - case GL_TEXTURE_ENV_COLOR: - return 4; - default: - GML_DEBUG("gmlNumArgsTexEnv", datatype, 1) - return 0; - } -} - -//glPointParametefv -EXTERN inline int gmlNumArgsPointParam(int datatype) { - switch(datatype) { - case GL_POINT_SIZE_MIN: - case GL_POINT_SIZE_MAX: - case GL_POINT_FADE_THRESHOLD_SIZE: - case GL_POINT_SPRITE_COORD_ORIGIN: - return 1; - case GL_POINT_DISTANCE_ATTENUATION: - return 3; - default: - GML_DEBUG("gmlNumArgsPointParam", datatype, 1) - return 0; - } -} - -//glTexParameterfv -EXTERN inline int gmlNumArgsTexParam(int datatype) { - switch(datatype) { - case GL_TEXTURE_MIN_FILTER: - case GL_TEXTURE_MAG_FILTER: - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - case GL_TEXTURE_PRIORITY: - return 1; - case GL_TEXTURE_BORDER_COLOR: - return 4; - default: - GML_DEBUG("gmlNumArgsTexParam", datatype, 1) - return 0; - } -} - -//glLightModelfv -EXTERN inline int gmlNumArgsLightModel(int datatype) { - switch(datatype) { - case GL_LIGHT_MODEL_LOCAL_VIEWER: - case GL_LIGHT_MODEL_TWO_SIDE: - return 1; - case GL_LIGHT_MODEL_AMBIENT: - return 4; - default: - GML_DEBUG("gmlNumArgsLightModel", datatype, 1) - return 0; - } -} - -//glMap1f -EXTERN inline int gmlNumArgsMap1(int datatype) { - switch(datatype) { - case GL_MAP1_INDEX: - case GL_MAP1_TEXTURE_COORD_1: - return 1; - case GL_MAP1_TEXTURE_COORD_2: - return 2; - case GL_MAP1_VERTEX_3: - case GL_MAP1_NORMAL: - case GL_MAP1_TEXTURE_COORD_3: - return 3; - case GL_MAP1_VERTEX_4: - case GL_MAP1_COLOR_4: - case GL_MAP1_TEXTURE_COORD_4: - return 4; - default: - GML_DEBUG("gmlNumArgsMap1", datatype, 1) - return 0; - } -} - -//glMap2f -EXTERN inline int gmlNumArgsMap2(int datatype) { - switch(datatype) { - case GL_MAP2_INDEX: - case GL_MAP2_TEXTURE_COORD_1: - return 1; - case GL_MAP2_TEXTURE_COORD_2: - return 2; - case GL_MAP2_VERTEX_3: - case GL_MAP2_NORMAL: - case GL_MAP2_TEXTURE_COORD_3: - return 3; - case GL_MAP2_VERTEX_4: - case GL_MAP2_COLOR_4: - case GL_MAP2_TEXTURE_COORD_4: - return 4; - default: - GML_DEBUG("gmlNumArgsMap2", datatype, 1) - return 0; - } -} - -EXTERN inline int gmlSizeOf(int datatype) { - switch(datatype) { - case GL_UNSIGNED_BYTE: - return sizeof(GLubyte); - case GL_BYTE: - return sizeof(GLbyte); - case GL_BITMAP: - return sizeof(GLubyte); - case GL_UNSIGNED_SHORT: - return sizeof(GLushort); - case GL_SHORT: - return sizeof(GLshort); - case GL_UNSIGNED_INT: - return sizeof(GLuint); - case GL_INT: - return sizeof(GLint); - case GL_FLOAT: - return sizeof(GLfloat); - case GL_DOUBLE: - return sizeof(GLdouble); - default: - GML_DEBUG("gmlSizeOf", datatype, 1) - return 0; - } -} - - -#define GML_MAKEDATA(name) struct gml##name##Data { int type; -#define GML_MAKEDATA_A(name,tA) GML_MAKEDATA(name) tA A; -#define GML_MAKEDATA_B(name,tA,tB) GML_MAKEDATA_A(name,tA) tB B; -#define GML_MAKEDATA_C(name,tA,tB,tC) GML_MAKEDATA_B(name,tA,tB) tC C; -#define GML_MAKEDATA_D(name,tA,tB,tC,tD) GML_MAKEDATA_C(name,tA,tB,tC) tD D; -#define GML_MAKEDATA_E(name,tA,tB,tC,tD,tE) GML_MAKEDATA_D(name,tA,tB,tC,tD) tE E; -#define GML_MAKEDATA_F(name,tA,tB,tC,tD,tE,tF) GML_MAKEDATA_E(name,tA,tB,tC,tD,tE) tF F; -#define GML_MAKEDATA_G(name,tA,tB,tC,tD,tE,tF,tG) GML_MAKEDATA_F(name,tA,tB,tC,tD,tE,tF) tG G; -#define GML_MAKEDATA_H(name,tA,tB,tC,tD,tE,tF,tG,tH) GML_MAKEDATA_G(name,tA,tB,tC,tD,tE,tF,tG) tH H; -#define GML_MAKEDATA_I(name,tA,tB,tC,tD,tE,tF,tG,tH,tI) GML_MAKEDATA_H(name,tA,tB,tC,tD,tE,tF,tG,tH) tI I; -#define GML_MAKEDATA_J(name,tA,tB,tC,tD,tE,tF,tG,tH,tI,tJ) GML_MAKEDATA_I(name,tA,tB,tC,tD,tE,tF,tG,tH,tI) tJ J; -#define GML_MAKEVAR_SIZE() int size; -#define GML_MAKEVAR_RET(ft) volatile ft ret; - -#define GML_MAKEASS_A() p->A=A; -#define GML_MAKEASS_B() GML_MAKEASS_A() p->B=B; -#define GML_MAKEASS_C() GML_MAKEASS_B() p->C=C; -#define GML_MAKEASS_D() GML_MAKEASS_C() p->D=D; -#define GML_MAKEASS_E() GML_MAKEASS_D() p->E=E; -#define GML_MAKEASS_F() GML_MAKEASS_E() p->F=F; -#define GML_MAKEASS_G() GML_MAKEASS_F() p->G=G; -#define GML_MAKEASS_H() GML_MAKEASS_G() p->H=H; -#define GML_MAKEASS_I() GML_MAKEASS_H() p->I=I; -#define GML_MAKEASS_J() GML_MAKEASS_I() p->J=J; - -#define GML_RETVAL(ft) return (ft) *reinterpret_cast(&(p->ret)); - -#define GML_RELOC()\ - while(qd->WritePos+datasize>=qd->WriteSize)\ - qd->WaitRealloc(); - -#define GML_PREP_FIXED(name)\ - gmlQueue *qd=&gmlQueues[gmlThreadNumber];\ - int datasize=sizeof(gml##name##Data);\ - GML_RELOC()\ - gml##name##Data *p=reinterpret_cast(qd->WritePos);\ - p->type=gml##name##Enum; - -#define GML_UPD_POS()\ - qd->WritePos+=datasize; - -#define GML_UPD_SIZE()\ - p->size=datasize;\ - -#define GML_PREP_VAR(name,sizefun)\ - gmlQueue *qd=&gmlQueues[gmlThreadNumber];\ - int size=sizefun;\ - int datasize=sizeof(gml##name##Data)+size;\ - GML_RELOC()\ - gml##name##Data *p=reinterpret_cast(qd->WritePos);\ - p->type=gml##name##Enum; - -#define GML_PREP_VAR_SIZE(name,sizefun)\ - GML_PREP_VAR(name,sizefun)\ - GML_UPD_SIZE() - -#ifdef _MSC_VER -#define GML_FUNCTION __FUNCTION__ -#else -#define GML_FUNCTION __func__ -#endif - -#if GML_CALL_DEBUG -#include "lib/lua/include/lauxlib.h" -extern void gmlPrintCallChainWarning(const char *func); -extern float gmlLockTime; -extern lua_State *gmlCurrentLuaStates[GML_MAX_NUM_THREADS]; -class gmlCallDebugger { -public: - lua_State ** currentLuaState; - gmlCallDebugger(lua_State *L) { - currentLuaState = &gmlCurrentLuaStates[gmlThreadNumber]; - if(!*currentLuaState) - *currentLuaState = L; - else - currentLuaState = NULL; - } - ~gmlCallDebugger() { - if(currentLuaState) { - *currentLuaState = NULL; - } - } - static float getLockTime() { - return (gmlMultiThreadSim && gmlStartSim) ? gmlLockTime : 0.0f; - } - static void resetLockTime() { - gmlLockTime = 0; - } -}; -#define GML_CURRENT_LUA(currentLuaState) (currentLuaState ? "LUA" : "Unknown") -#define GML_THREAD_ERROR(msg, ret)\ - lua_State *currentLuaState = gmlCurrentLuaStates[gmlThreadNumber];\ - LOG_SL("Threading", L_ERROR, "Sim thread called %s (%s)", msg, GML_CURRENT_LUA(currentLuaState));\ - if(currentLuaState)\ - luaL_error(currentLuaState, "Invalid call");\ - ret -#if GML_CALL_DEBUG -#define GML_CHECK_CALL_CHAIN(luastate, ...)\ - if (gmlCheckCallChain) {\ - lua_State *currentLuaState = gmlCurrentLuaStates[gmlThreadNumber];\ - if (currentLuaState != NULL && currentLuaState != gmlLuaUIState && luastate == gmlLuaUIState) {\ - if (gmlCallChainWarning < GML_MAX_CALL_CHAIN_WARNINGS) {\ - ++gmlCallChainWarning;\ - gmlPrintCallChainWarning(GML_FUNCTION);\ - }\ - return __VA_ARGS__;\ - }\ - } -#else -#define GML_CHECK_CALL_CHAIN(luastate, ...) -#endif -#define GML_ITEMLOG_PRINT() GML_THREAD_ERROR(GML_FUNCTION,) -#define GML_DUMMYRET() return; -#define GML_DUMMYRETVAL(rettype)\ - rettype rdummy = (rettype)0;\ - return rdummy; -#define GML_IF_SIM_THREAD_RET(thread,name)\ - if(thread == gmlNoGLThreadNum) {\ - GML_THREAD_ERROR(GML_QUOTE(gml##name), GML_DUMMYRET())\ - } -#define GML_IF_SIM_THREAD_RETVAL(thread,name,rettype)\ - if(thread == gmlNoGLThreadNum) {\ - GML_THREAD_ERROR(GML_QUOTE(gml##name), GML_DUMMYRETVAL(rettype))\ - } -#else -#define GML_ITEMLOG_PRINT() LOG_SL("Threading", L_ERROR, "Sim thread called %s", GML_FUNCTION); -#define GML_DUMMYRET() -#define GML_DUMMYRETVAL(rettype) -#define GML_IF_SIM_THREAD_RET(thread,name) -#define GML_IF_SIM_THREAD_RETVAL(thread,name,rettype) -#endif - -#define GML_COND(name,...)\ - int threadnum = gmlThreadNumber;\ - GML_IF_SERVER_THREAD(threadnum) {\ - gl##name(__VA_ARGS__);\ - return;\ - }\ - GML_IF_SIM_THREAD_RET(threadnum,name) - -#define GML_COND0(name)\ - int threadnum = gmlThreadNumber;\ - GML_IF_SERVER_THREAD(threadnum) {\ - gl##name();\ - return;\ - }\ - GML_IF_SIM_THREAD_RET(threadnum,name) - -#define GML_COND_RET(name,rettype,...)\ - int threadnum = gmlThreadNumber;\ - GML_IF_SERVER_THREAD(threadnum) {\ - return gl##name(__VA_ARGS__);\ - }\ - GML_IF_SIM_THREAD_RETVAL(threadnum,name,rettype) - -#define GML_COND_RET0(name,rettype)\ - int threadnum = gmlThreadNumber;\ - GML_IF_SERVER_THREAD(threadnum) {\ - return gl##name();\ - }\ - GML_IF_SIM_THREAD_RETVAL(threadnum,name,rettype) - -EXTERN inline void gmlSync(gmlQueue *qd) { - qd->SyncRequest(); -} - -#define GML_SYNC_COND(arg,x) arg; - -#define GML_SYNC() gmlSync(qd) - -#ifndef GML_MAKENAME -# define GML_MAKENAME(name) -#endif - -#define GML_FUN(ftype,name,...) };\ - EXTERN const int gml##name##Enum=(__LINE__-__FIRSTLINE__);\ - GML_MAKENAME(name)\ - EXTERN inline ftype GML_GLAPIENTRY gml##name(__VA_ARGS__) - - -#if GML_ENABLE_ITEMSERVER_CHECK -#define GML_ITEMSERVER_CHECK(thread)\ - if(thread == gmlNoGLThreadNum) {\ - GML_ITEMLOG_PRINT()\ - GML_DUMMYRET()\ - } -#define GML_ITEMSERVER_CHECK_RET(thread,rettype)\ - if(thread == gmlNoGLThreadNum) {\ - GML_ITEMLOG_PRINT()\ - GML_DUMMYRETVAL(rettype)\ - } -#else -#define GML_ITEMSERVER_CHECK(thread) -#define GML_ITEMSERVER_CHECK_RET(thread,rettype) -#endif - -#define GML_MAKEFUN0(name)\ - GML_MAKEDATA(name)\ -GML_FUN(void, name) {\ - GML_COND0(name)\ - GML_PREP_FIXED(name)\ - GML_UPD_POS()\ -} - -#define GML_MAKEFUN0R(name,tR,cache)\ - GML_MAKEDATA(name)\ - GML_MAKEVAR_RET(tR)\ -GML_FUN(tR, name) {\ - GML_COND_RET0(name,tR)\ - cache\ - GML_PREP_FIXED(name)\ - GML_UPD_POS()\ - GML_SYNC();\ - GML_RETVAL(tR)\ -} - -#define GML_MAKEFUN1(name,tA)\ - GML_MAKEDATA_A(name,tA)\ -GML_FUN(void, name, tA A) {\ - GML_COND(name,A)\ - GML_PREP_FIXED(name)\ - GML_MAKEASS_A()\ - GML_UPD_POS()\ -} - -#define GML_MAKEFUN1R(name,tA,tR,cache)\ - GML_MAKEDATA_A(name,tA)\ - GML_MAKEVAR_RET(tR)\ -GML_FUN(tR, name, tA A) {\ - GML_COND_RET(name,tR,A)\ - cache\ - GML_PREP_FIXED(name)\ - GML_MAKEASS_A()\ - GML_UPD_POS()\ - GML_SYNC();\ - GML_RETVAL(tR)\ -} - -#define GML_MAKEFUN2(name,tA,tB,cache,...)\ - GML_MAKEDATA_B(name,tA,tB)\ -GML_FUN(void, name, tA A, tB B) {\ - GML_COND(name,A,B)\ - cache\ - GML_PREP_FIXED(name)\ - GML_MAKEASS_B()\ - GML_UPD_POS()\ - GML_SYNC_COND(__VA_ARGS__,)\ -} - -#define GML_MAKEFUN2B(name,tA,tB)\ - GML_MAKEDATA_B(name,tA,tB)\ -GML_FUN(void, name, tA A, tB B) {\ - GML_COND(name,A,B)\ - GML_PREP_FIXED(name)\ - GML_MAKEASS_B()\ - switch(A) {\ - case GL_ARRAY_BUFFER:\ - qd->ArrayBuffer=B; break;\ - case GL_ELEMENT_ARRAY_BUFFER:\ - qd->ElementArrayBuffer=B; break;\ - case GL_PIXEL_PACK_BUFFER:\ - qd->PixelPackBuffer=B; break;\ - case GL_PIXEL_UNPACK_BUFFER:\ - qd->PixelUnpackBuffer=B; break;\ - }\ - GML_UPD_POS()\ -} - - -#define GML_MAKEFUN2R(name,tA,tB,tR)\ - GML_MAKEDATA_B(name,tA,tB)\ - GML_MAKEVAR_RET(tR)\ -GML_FUN(tR, name, tA A,tB B) {\ - GML_COND_RET(name,tR,A,B)\ - GML_PREP_FIXED(name)\ - GML_MAKEASS_B()\ - GML_UPD_POS()\ - GML_SYNC();\ - GML_RETVAL(tR)\ -} - -#define GML_MAKEFUN3(name,tA,tB,tC,cache,...)\ - GML_MAKEDATA_C(name,tA,tB,tC)\ -GML_FUN(void, name, tA A, tB B, tC C) {\ - GML_COND(name,A,B,C)\ - cache\ - GML_PREP_FIXED(name)\ - GML_MAKEASS_C()\ - GML_UPD_POS()\ - GML_SYNC_COND(__VA_ARGS__,)\ -} - -#define GML_MAKEFUN4(name,tA,tB,tC,tD,...)\ - GML_MAKEDATA_D(name,tA,tB,tC,tD)\ -GML_FUN(void, name, tA A, tB B, tC C, tD D) {\ - GML_COND(name,A,B,C,D)\ - GML_PREP_FIXED(name)\ - GML_MAKEASS_D()\ - GML_UPD_POS()\ - GML_SYNC_COND(__VA_ARGS__,)\ -} - -#define GML_MAKEFUN4R(name,tA,tB,tC,tD,tR)\ - GML_MAKEDATA_D(name,tA,tB,tC,tD)\ - GML_MAKEVAR_RET(tR)\ -GML_FUN(tR, name, tA A, tB B, tC C, tD D) {\ - GML_COND_RET(name,tR,A,B,C,D)\ - GML_PREP_FIXED(name)\ - GML_MAKEASS_D()\ - GML_UPD_POS()\ - GML_SYNC();\ - GML_RETVAL(tR)\ -} - -#define GML_MAKEFUN5(name,tA,tB,tC,tD,tE,...)\ - GML_MAKEDATA_E(name,tA,tB,tC,tD,tE)\ -GML_FUN(void, name, tA A, tB B, tC C, tD D, tE E) {\ - GML_COND(name,A,B,C,D,E)\ - GML_PREP_FIXED(name)\ - GML_MAKEASS_E()\ - GML_UPD_POS()\ - GML_SYNC_COND(__VA_ARGS__,)\ -} - -#define GML_MAKEFUN6(name,tA,tB,tC,tD,tE,tF)\ - GML_MAKEDATA_F(name,tA,tB,tC,tD,tE,tF)\ -GML_FUN(void, name, tA A, tB B, tC C, tD D, tE E, tF F) {\ - GML_COND(name,A,B,C,D,E,F)\ - GML_PREP_FIXED(name)\ - GML_MAKEASS_F()\ - GML_UPD_POS()\ -} - -#define GML_MAKEFUN7(name,tA,tB,tC,tD,tE,tF,tG,...)\ - GML_MAKEDATA_G(name,tA,tB,tC,tD,tE,tF,tG)\ -GML_FUN(void, name, tA A, tB B, tC C, tD D, tE E, tF F, tG G) {\ - GML_COND(name,A,B,C,D,E,F,G)\ - GML_PREP_FIXED(name)\ - GML_MAKEASS_G()\ - GML_UPD_POS()\ - GML_SYNC_COND(__VA_ARGS__,)\ -} - -#define GML_MAKEFUN8(name,tA,tB,tC,tD,tE,tF,tG,tH)\ - GML_MAKEDATA_H(name,tA,tB,tC,tD,tE,tF,tG,tH)\ -GML_FUN(void, name, tA A, tB B, tC C, tD D, tE E, tF F, tG G, tH H) {\ - GML_COND(name,A,B,C,D,E,F,G,H)\ - GML_PREP_FIXED(name)\ - GML_MAKEASS_H()\ - GML_UPD_POS()\ -} - -#define GML_MAKEFUN9(name,tA,tB,tC,tD,tE,tF,tG,tH,tI)\ - GML_MAKEDATA_I(name,tA,tB,tC,tD,tE,tF,tG,tH,tI)\ -GML_FUN(void, name, tA A, tB B, tC C, tD D, tE E, tF F, tG G, tH H, tI I) {\ - GML_COND(name,A,B,C,D,E,F,G,H,I)\ - GML_PREP_FIXED(name)\ - GML_MAKEASS_I()\ - GML_UPD_POS()\ -} - -#define GML_MAKEFUN9R(name,tA,tB,tC,tD,tE,tF,tG,tH,tI,tR)\ - GML_MAKEDATA_I(name,tA,tB,tC,tD,tE,tF,tG,tH,tI)\ - GML_MAKEVAR_RET(tR)\ -GML_FUN(tR, name, tA A, tB B, tC C, tD D, tE E, tF F, tG G, tH H, tI I) {\ - GML_COND_RET(name,tR,A,B,C,D,E,F,G,H,I)\ - GML_PREP_FIXED(name)\ - GML_MAKEASS_I()\ - GML_UPD_POS()\ - GML_SYNC();\ - GML_RETVAL(tR)\ -} - - -#define GML_MAKEFUN10(name,tA,tB,tC,tD,tE,tF,tG,tH,tI,tJ)\ - GML_MAKEDATA_J(name,tA,tB,tC,tD,tE,tF,tG,tH,tI,tJ)\ -GML_FUN(void, name, tA A, tB B, tC C, tD D, tE E, tF F, tG G, tH H, tI I, tJ J) {\ - GML_COND(name,A,B,C,D,E,F,G,H,I,J)\ - GML_PREP_FIXED(name)\ - GML_MAKEASS_J()\ - GML_UPD_POS()\ -} - -#define GML_MAKEFUN7S(name,tA,tB,tC,tD,tE,tF,tG,sizefun)\ - GML_MAKEDATA_F(name,tA,tB,tC,tD,tE,tF)\ - GML_MAKEVAR_SIZE()\ -GML_FUN(void, name, tA A, tB B, tC C, tD D, tE E, tF F, tG *G) {\ - GML_COND(name,A,B,C,D,E,F,G)\ - GML_PREP_VAR_SIZE(name,sizefun)\ - GML_MAKEASS_F()\ - memcpy(p+1,G,size);\ - GML_UPD_POS()\ -} - -#define GML_PUB_COPY(name,var,ftype)\ - p->var=NULL;\ - if(qd->PixelUnpackBuffer) {\ - datasize=sizeof(gml##name##Data);\ - p->var=(ftype)((BYTE *)var+1);\ - }\ - else if(var!=NULL)\ - memcpy(p+1,var,size); - -#define GML_MAKEFUN8S(name,tA,tB,tC,tD,tE,tF,tG,tH,sizefun)\ - GML_MAKEDATA_H(name,tA,tB,tC,tD,tE,tF,tG,tH *)\ - GML_MAKEVAR_SIZE()\ -GML_FUN(void, name, tA A, tB B, tC C, tD D, tE E, tF F, tG G, tH *H) {\ - GML_COND(name,A,B,C,D,E,F,G,H)\ - GML_PREP_VAR(name,sizefun)\ - GML_MAKEASS_G()\ - GML_PUB_COPY(name,H,tH *)\ - GML_UPD_SIZE()\ - GML_UPD_POS()\ -} - -#define GML_MAKEFUN9S(name,tA,tB,tC,tD,tE,tF,tG,tH,tI,sizefun)\ - GML_MAKEDATA_I(name,tA,tB,tC,tD,tE,tF,tG,tH,tI *)\ - GML_MAKEVAR_SIZE()\ -GML_FUN(void, name, tA A, tB B, tC C, tD D, tE E, tF F, tG G, tH H, tI *I) {\ - GML_COND(name,A,B,C,D,E,F,G,H,I)\ - GML_PREP_VAR(name,sizefun)\ - GML_MAKEASS_H()\ - GML_PUB_COPY(name,I,tI *)\ - GML_UPD_SIZE()\ - GML_UPD_POS()\ -} - -#define GML_MAKEFUN10S(name,tA,tB,tC,tD,tE,tF,tG,tH,tI,tJ,sizefun)\ - GML_MAKEDATA_J(name,tA,tB,tC,tD,tE,tF,tG,tH,tI,tJ *)\ - GML_MAKEVAR_SIZE()\ -GML_FUN(void, name, tA A, tB B, tC C, tD D, tE E, tF F, tG G, tH H, tI I, tJ *J) {\ - GML_COND(name,A,B,C,D,E,F,G,H,I,J)\ - GML_PREP_VAR(name,sizefun)\ - GML_MAKEASS_I()\ - GML_PUB_COPY(name,J,tJ *)\ - GML_UPD_SIZE()\ - GML_UPD_POS()\ -} - -#define GML_MAKEFUN1V(name,tA,tX,count)\ - GML_MAKEDATA(name)\ - GML_MAKEVAR_SIZE()\ - tX A;\ -GML_FUN(void, name, tA* A) {\ - GML_COND(name,A)\ - GML_PREP_VAR_SIZE(name,(count-1)*sizeof(tX))\ - memcpy(&(p->A),A,size+sizeof(tX));\ - GML_UPD_POS()\ -} - -#define GML_MAKEFUN2V(name,tA,tB,tX,count)\ - GML_MAKEDATA_A(name,tA)\ - GML_MAKEVAR_SIZE()\ - tX B;\ -GML_FUN(void, name, tA A, tB* B) {\ - GML_COND(name,A,B)\ - GML_PREP_VAR_SIZE(name,(count-1)*sizeof(tX))\ - GML_MAKEASS_A()\ - memcpy(&(p->B),B,size+sizeof(tX));\ - GML_UPD_POS()\ -} - -#define GML_MAKEFUN3V(name,tA,tB,tC,tX,count)\ - GML_MAKEDATA_B(name,tA,tB)\ - GML_MAKEVAR_SIZE()\ - tX C;\ -GML_FUN(void, name, tA A, tB B, tC* C) {\ - GML_COND(name,A,B,C)\ - GML_PREP_VAR_SIZE(name,(count-1)*sizeof(tX))\ - GML_MAKEASS_B()\ - memcpy(&(p->C),C,size+sizeof(tX));\ - GML_UPD_POS()\ -} - -#define GML_MAKEFUN4V(name,tA,tB,tC,tD,tX,count)\ - GML_MAKEDATA_C(name,tA,tB,tC)\ - GML_MAKEVAR_SIZE()\ - tX D;\ -GML_FUN(void, name, tA A, tB B, tC C, tD *D) {\ - GML_COND(name,A,B,C,D)\ - GML_PREP_VAR_SIZE(name,(count-1)*sizeof(tX))\ - GML_MAKEASS_C()\ - memcpy(&(p->D),D,size+sizeof(tX));\ - GML_UPD_POS()\ -} - -#define GML_MAKEFUN4VS(name,tA,tB,tC,tD,tX,count)\ - GML_MAKEDATA_B(name,tA,tB)\ - tD D;\ - GML_MAKEVAR_SIZE()\ - tX C;\ -GML_FUN(void, name, tA A, tB B, tC *C, tD D) {\ - GML_COND(name,A,B,C,D)\ - GML_PREP_VAR_SIZE(name,(count-1)*sizeof(tX))\ - GML_MAKEASS_B()\ - p->D=D;\ - if(C!=NULL)\ - memcpy(&(p->C),C,size+sizeof(tX));\ - GML_UPD_POS()\ -} - -#define GML_MAKEFUN4VSS(name,tA,tB,tC,tD,count)\ - GML_MAKEDATA_B(name,tA,tB)\ - int lensize;\ - GML_MAKEVAR_SIZE()\ - tC *C;\ -GML_FUN(void, name, tA A, tB B, tC **C, tD *D) {\ - GML_COND(name,A,B,C,D)\ - GML_PREP_VAR(name,(count-1)*sizeof(tC *))\ - GML_MAKEASS_B()\ - p->lensize=datasize;\ - BYTE *e=(BYTE *)p+datasize;\ - for(int i=0; iC))[i]=sl;\ - --sl;\ - while(qd->WritePos+datasize>=qd->WriteSize)\ - p=(gml##name##Data *)qd->WaitRealloc(&e);\ - memcpy(e,C[i],sl);\ - e+=sl;\ - *e='\0';\ - ++e;\ - }\ - GML_UPD_SIZE()\ - GML_UPD_POS()\ -} - -#define GML_PUB_PCOPY(name,var,pvar,ftype)\ - p->pvar=NULL;\ - if(qd->PixelUnpackBuffer) {\ - datasize=sizeof(gml##name##Data);\ - p->pvar=(ftype *)var+1;\ - }\ - else if(var!=NULL)\ - memcpy(&(p->var),var,size+sizeof(ftype)); - -#define GML_STDCOPY1(type,count,stride,nargs)\ - for(int i=0; istride=nargs;\ - tX *e=&(p->F);\ - tF *v=F;\ - GML_STDCOPY1(tF,count,stride,nargs)\ - GML_UPD_POS()\ -} - -#define GML_STDCOPY2(type,count1,stride1,count2,stride2,nargs)\ - for(int i=0; istride1=nargs*count2;\ - p->stride2=nargs;\ - tX *e=&(p->J);\ - tJ *v=J;\ - GML_STDCOPY2(tJ,count1,stride1,count2,stride2,nargs)\ - GML_UPD_POS()\ -} - -#define GML_MAKEFUN7VP(name,tA,tB,tC,tD,tE,tF,tG,tX,count)\ - GML_MAKEDATA_F(name,tA,tB,tC,tD,tE,tF)\ - GML_MAKEVAR_SIZE()\ - tX *GP;\ - tX G;\ -GML_FUN(void, name, tA A, tB B, tC C, tD D, tE E, tF F, tG *G) {\ - GML_COND(name,A,B,C,D,E,F,G)\ - GML_PREP_VAR(name,(count-1)*sizeof(tX))\ - GML_MAKEASS_F()\ - GML_PUB_PCOPY(name,G,GP,tX)\ - GML_UPD_SIZE()\ - GML_UPD_POS()\ -} - -#define GML_MAKEFUN8VP(name,tA,tB,tC,tD,tE,tF,tG,tH,tX,count)\ - GML_MAKEDATA_G(name,tA,tB,tC,tD,tE,tF,tG)\ - GML_MAKEVAR_SIZE()\ - tX *HP;\ - tX H;\ -GML_FUN(void, name, tA A, tB B, tC C, tD D, tE E, tF F, tG G, tH *H) {\ - GML_COND(name,A,B,C,D,E,F,G,H)\ - GML_PREP_VAR(name,(count-1)*sizeof(tX))\ - GML_MAKEASS_G()\ - GML_PUB_PCOPY(name,H,HP,tX)\ - GML_UPD_SIZE()\ - GML_UPD_POS()\ -} - -#define GML_MAKEFUN9VP(name,tA,tB,tC,tD,tE,tF,tG,tH,tI,tX,count)\ - GML_MAKEDATA_H(name,tA,tB,tC,tD,tE,tF,tG,tH)\ - GML_MAKEVAR_SIZE()\ - tX *IP;\ - tX I;\ -GML_FUN(void, name, tA A, tB B, tC C, tD D, tE E, tF F, tG G, tH H, tI *I) {\ - GML_COND(name,A,B,C,D,E,F,G,H,I)\ - GML_PREP_VAR(name,(count-1)*sizeof(tX))\ - GML_MAKEASS_H()\ - GML_PUB_PCOPY(name,I,IP,tX)\ - GML_UPD_SIZE()\ - GML_UPD_POS()\ -} - -#define GML_MAKEFUN1CS(name,tA,arg)\ - GML_MAKEDATA_A(name,tA)\ -GML_FUN(void, name, tA A) {\ - GML_COND(name,A)\ - GML_PREP_FIXED(name)\ - GML_MAKEASS_A()\ - qd->ClientState arg (1<<(A-GL_VERTEX_ARRAY));\ - GML_UPD_POS()\ -} - -#define GML_MAKEFUN1VA(name,tA,arg,fun)\ - GML_MAKEDATA_A(name,tA)\ -GML_FUN(void, name, tA A) {\ - GML_COND(name,A)\ - GML_PREP_FIXED(name)\ - GML_MAKEASS_A()\ - qd->arg##set.fun(A);\ - GML_UPD_POS()\ -} - -#define GML_UPD_CS(arg)\ - if(qd->ArrayBuffer)\ - qd->ClientState |= GML_##arg##_ARRAY_BUFFER;\ - else\ - qd->ClientState &= ~GML_##arg##_ARRAY_BUFFER; - -#define GML_MAKEFUN2P(name,tA,tB,arg)\ - GML_MAKEDATA_B(name,tA,tB *)\ -GML_FUN(void, name, tA A, tB *B) {\ - GML_COND(name,A,B)\ - GML_PREP_FIXED(name)\ - GML_MAKEASS_B()\ - qd->arg##stride=A;\ - qd->arg##pointer=B;\ - GML_UPD_CS(arg)\ - GML_UPD_POS()\ -} - -#define GML_MAKEFUN3P(name,tA,tB,tC,arg)\ - GML_MAKEDATA_C(name,tA,tB,tC *)\ -GML_FUN(void, name, tA A, tB B, tC *C) {\ - GML_COND(name,A,B,C)\ - GML_PREP_FIXED(name)\ - GML_MAKEASS_C()\ - qd->arg##type=A;\ - qd->arg##stride=B;\ - qd->arg##pointer=C;\ - GML_UPD_CS(arg)\ - GML_UPD_POS()\ -} - -#define GML_MAKEFUN4P(name,tA,tB,tC,tD,arg)\ - GML_MAKEDATA_D(name,tA,tB,tC,tD *)\ -GML_FUN(void, name, tA A, tB B, tC C, tD *D) {\ - GML_COND(name,A,B,C,D)\ - GML_PREP_FIXED(name)\ - GML_MAKEASS_D()\ - qd->arg##size=A;\ - qd->arg##type=B;\ - qd->arg##stride=C;\ - qd->arg##pointer=D;\ - GML_UPD_CS(arg)\ - GML_UPD_POS()\ -} - -#define GML_MAKEFUN6P(name,tA,tB,tC,tD,tE,tF,arg)\ - GML_MAKEDATA_F(name,tA,tB,tC,tD,tE,tF *)\ -GML_FUN(void, name, tA A, tB B, tC C, tD D, tE E, tF *F) {\ - GML_COND(name,A,B,C,D,E,F)\ - GML_PREP_FIXED(name)\ - GML_MAKEASS_F()\ - qd->arg##map[A]=arg##data(B,C,D,E,F,qd->ArrayBuffer);\ - GML_UPD_POS()\ -} - -#define GML_MEMCOPY(count)\ - for(int i=0; iarg##stride;\ - if(itemstride==0)\ - itemstride=itemsize;\ - p->arg##totalsize=0;\ - p->arg##pointer=(GLvoid *)((BYTE *)qd->arg##pointer+first*itemstride);\ - sizeass;\ - typeass;\ - if(!(qd->ClientState & GML_##arg##_ARRAY_BUFFER)) {\ - p->arg##totalsize=itemsize*count;\ - datasize+=p->arg##totalsize;\ - while(qd->WritePos+datasize>=qd->WriteSize)\ - p=(gml##name##Data *)qd->WaitRealloc(&e);\ - BYTE *v=(BYTE *)p->arg##pointer;\ - copyfun\ - }\ - } - -#define GML_MAKEPOINTERDATA()\ - GLenum ClientState;\ - GLint VPsize;\ - GLenum VPtype;\ - GLvoid * VPpointer;\ - int VPtotalsize;\ - GLint CPsize;\ - GLenum CPtype;\ - GLvoid * CPpointer;\ - int CPtotalsize;\ - GLint TCPsize;\ - GLenum TCPtype;\ - GLvoid * TCPpointer;\ - int TCPtotalsize;\ - GLenum IPtype;\ - GLvoid * IPpointer;\ - int IPtotalsize;\ - GLenum NPtype;\ - GLvoid *NPpointer;\ - int NPtotalsize;\ - GLvoid * EFPpointer;\ - int EFPtotalsize;\ - int VAcount; - -#define GML_MAKESUBFUNVA(name,first,count,copyfun)\ - p->VAcount=qd->VAset.size();\ - std::set::iterator si=qd->VAset.begin();\ - while(si!=qd->VAset.end()) {\ - std::map::iterator mi=qd->VAmap.find(*si);\ - VAdata *vd=&(mi->second);\ - int itemstride=vd->stride;\ - int itemsize=vd->size*gmlSizeOf(vd->type);\ - if(itemstride==0)\ - itemstride=itemsize;\ - if(vd->buffer)\ - itemsize=0;\ - int totalsize=itemsize*count+sizeof(VAstruct);\ - datasize+=totalsize;\ - while(qd->WritePos+datasize>=qd->WriteSize)\ - p=(gml##name##Data *)qd->WaitRealloc(&e);\ - VAstruct *vs=(VAstruct *)e;\ - e+=sizeof(VAstruct);\ - vs->target=*si;\ - vs->size=vd->size;\ - vs->type=vd->type;\ - vs->normalized=vd->normalized;\ - vs->totalsize=totalsize;\ - vs->pointer=(GLvoid *)((BYTE *)vd->pointer+first*itemstride);\ - vs->buffer=vd->buffer;\ - if(!vd->buffer) {\ - BYTE *v=(BYTE *)vs->pointer;\ - copyfun\ - }\ - ++si;\ - } - - -#define GML_MAKEFUN3VDA(name,tA,tB,tC)\ - GML_MAKEDATA_C(name,tA,tB,tC)\ - GML_MAKEPOINTERDATA()\ - GML_MAKEVAR_SIZE()\ -GML_FUN(void, name, tA A, tB B, tC C) {\ - GML_COND(name,A,B,C)\ - GML_PREP_FIXED(name)\ - GML_MAKEASS_C()\ - GLenum clientstate=qd->ClientState & ~(qd->ClientState>>16);\ - p->ClientState=qd->ClientState;\ - BYTE *e=(BYTE *)(p+1);\ - GML_MAKESUBFUNDA(name,GL_VERTEX_ARRAY,VP,qd->VPsize*gmlSizeOf(qd->VPtype),p->VPsize=qd->VPsize,p->VPtype=qd->VPtype,B,C,GML_MEMCOPY(C))\ - GML_MAKESUBFUNDA(name,GL_COLOR_ARRAY,CP,qd->CPsize*gmlSizeOf(qd->CPtype),p->CPsize=qd->CPsize,p->CPtype=qd->CPtype,B,C,GML_MEMCOPY(C))\ - GML_MAKESUBFUNDA(name,GL_TEXTURE_COORD_ARRAY,TCP,qd->TCPsize*gmlSizeOf(qd->TCPtype),p->TCPsize=qd->TCPsize,p->TCPtype=qd->TCPtype,B,C,GML_MEMCOPY(C))\ - GML_MAKESUBFUNDA(name,GL_INDEX_ARRAY,IP,gmlSizeOf(qd->IPtype),,p->IPtype=qd->IPtype,B,C,GML_MEMCOPY(C))\ - GML_MAKESUBFUNDA(name,GL_NORMAL_ARRAY,NP,3*gmlSizeOf(qd->NPtype),,p->NPtype=qd->NPtype,B,C,GML_MEMCOPY(C))\ - GML_MAKESUBFUNDA(name,GL_EDGE_FLAG_ARRAY,EFP,sizeof(GLboolean),,,B,C,GML_MEMCOPY(C))\ - GML_MAKESUBFUNVA(name,B,C,GML_MEMCOPY(C))\ - GML_UPD_SIZE()\ - GML_UPD_POS()\ -} - - -#define GML_MAKEFUN4VDE(name,tA,tB,tC,tD)\ - GML_MAKEDATA_D(name,tA,tB,tC,tD *)\ - GML_MAKEPOINTERDATA()\ - GML_MAKEVAR_SIZE()\ -GML_FUN(void, name, tA A, tB B, tC C, tD *D) {\ - GML_COND(name,A,B,C,D)\ - GML_PREP_FIXED(name)\ - GML_MAKEASS_D()\ - BYTE *e=(BYTE *)(p+1);\ - GLenum clientstate=qd->ClientState & ~(qd->ClientState>>16);\ - p->ClientState=qd->ClientState;\ - if(qd->ElementArrayBuffer)\ - p->ClientState |= GML_ELEMENT_ARRAY_BUFFER;\ - GML_MAKESUBFUNDA(name,GL_VERTEX_ARRAY,VP,qd->VPsize*gmlSizeOf(qd->VPtype),p->VPsize=qd->VPsize,p->VPtype=qd->VPtype,0,B,GML_IDXCOPY(B,C,D))\ - GML_MAKESUBFUNDA(name,GL_COLOR_ARRAY,CP,qd->CPsize*gmlSizeOf(qd->CPtype),p->CPsize=qd->CPsize,p->CPtype=qd->CPtype,0,B,GML_IDXCOPY(B,C,D))\ - GML_MAKESUBFUNDA(name,GL_TEXTURE_COORD_ARRAY,TCP,qd->TCPsize*gmlSizeOf(qd->TCPtype),p->TCPsize=qd->TCPsize,p->TCPtype=qd->TCPtype,0,B,GML_IDXCOPY(B,C,D))\ - GML_MAKESUBFUNDA(name,GL_INDEX_ARRAY,IP,gmlSizeOf(qd->IPtype),,p->IPtype=qd->IPtype,0,B,GML_IDXCOPY(B,C,D))\ - GML_MAKESUBFUNDA(name,GL_NORMAL_ARRAY,NP,3*gmlSizeOf(qd->NPtype),,p->NPtype=qd->NPtype,0,B,GML_IDXCOPY(B,C,D))\ - GML_MAKESUBFUNDA(name,GL_EDGE_FLAG_ARRAY,EFP,sizeof(GLboolean),,,0,B,GML_IDXCOPY(B,C,D))\ - GML_MAKESUBFUNVA(name,0,B,GML_IDXCOPY(B,C,D))\ - GML_UPD_SIZE()\ - GML_UPD_POS()\ -} - - -#define GML_MAKEFUN6VDRE(name,tA,tB,tC,tD,tE,tF)\ - GML_MAKEDATA_F(name,tA,tB,tC,tD,tE,tF *)\ - GML_MAKEPOINTERDATA()\ - GML_MAKEVAR_SIZE()\ -GML_FUN(void, name, tA A, tB B, tC C, tD D, tE E, tF *F) {\ - GML_COND(name,A,B,C,D,E,F)\ - GML_PREP_FIXED(name)\ - GML_MAKEASS_F()\ - BYTE *e=(BYTE *)(p+1);\ - GLenum clientstate=qd->ClientState & ~(qd->ClientState>>16);\ - p->ClientState=qd->ClientState;\ - if(qd->ElementArrayBuffer)\ - p->ClientState |= GML_ELEMENT_ARRAY_BUFFER;\ - GML_MAKESUBFUNDA(name,GL_VERTEX_ARRAY,VP,qd->VPsize*gmlSizeOf(qd->VPtype),p->VPsize=qd->VPsize,p->VPtype=qd->VPtype,0,D,GML_IDXCOPY(D,E,F))\ - GML_MAKESUBFUNDA(name,GL_COLOR_ARRAY,CP,qd->CPsize*gmlSizeOf(qd->CPtype),p->CPsize=qd->CPsize,p->CPtype=qd->CPtype,0,D,GML_IDXCOPY(D,E,F))\ - GML_MAKESUBFUNDA(name,GL_TEXTURE_COORD_ARRAY,TCP,qd->TCPsize*gmlSizeOf(qd->TCPtype),p->TCPsize=qd->TCPsize,p->TCPtype=qd->TCPtype,0,D,GML_IDXCOPY(D,E,F))\ - GML_MAKESUBFUNDA(name,GL_INDEX_ARRAY,IP,gmlSizeOf(qd->IPtype),,p->IPtype=qd->IPtype,0,D,GML_IDXCOPY(D,E,F))\ - GML_MAKESUBFUNDA(name,GL_NORMAL_ARRAY,NP,3*gmlSizeOf(qd->NPtype),,p->NPtype=qd->NPtype,0,D,GML_IDXCOPY(D,E,F))\ - GML_MAKESUBFUNDA(name,GL_EDGE_FLAG_ARRAY,EFP,sizeof(GLboolean),,,0,D,GML_IDXCOPY(D,E,F))\ - GML_MAKESUBFUNVA(name,0,D,GML_IDXCOPY(D,E,F))\ - GML_UPD_SIZE()\ - GML_UPD_POS()\ -} - - -const int __FIRSTLINE__=__LINE__; -GML_MAKEFUN1(Disable,GLenum) -GML_MAKEFUN1(Enable,GLenum) -GML_MAKEFUN2(BindTexture,GLenum,GLuint,) -GML_MAKEFUN3(TexParameteri,GLenum,GLenum,GLint,) -GML_MAKEFUN1(ActiveTextureARB,GLenum) -GML_MAKEFUN4(Color4f,GLfloat,GLfloat,GLfloat,GLfloat) -GML_MAKEFUN3(Vertex3f,GLfloat,GLfloat,GLfloat,) -GML_MAKEFUN3(TexEnvi,GLenum,GLenum,GLint,) -GML_MAKEFUN2(TexCoord2f,GLfloat,GLfloat,) -GML_MAKEFUN6(ProgramEnvParameter4fARB,GLenum,GLuint,GLfloat,GLfloat,GLfloat,GLfloat) -GML_MAKEFUN0(End) -GML_MAKEFUN1(Begin,GLenum) -GML_MAKEFUN1(MatrixMode,GLenum) -GML_MAKEFUN2(Vertex2f,GLfloat,GLfloat,) -GML_MAKEFUN0(PopMatrix) -GML_MAKEFUN0(PushMatrix) -GML_MAKEFUN0(LoadIdentity) -GML_MAKEFUN3(Translatef,GLfloat,GLfloat,GLfloat,) -GML_MAKEFUN2(BlendFunc,GLenum,GLenum,) -GML_MAKEFUN1(CallList,GLuint) -GML_MAKEFUN3(Color3f,GLfloat,GLfloat,GLfloat,) -GML_MAKEFUN9S(TexImage2D,GLenum,GLint,GLint,GLsizei,GLsizei,GLint,GLenum,GLenum,const GLvoid,D*E*gmlNumArgsTexImage(G)*gmlSizeOf(H)) -GML_MAKEFUN1V(Color4fv,const GLfloat,GLfloat,4) -GML_MAKEFUN2(BindProgramARB,GLenum,GLuint,) -GML_MAKEFUN3(Scalef,GLfloat,GLfloat,GLfloat,) -GML_MAKEFUN4(Viewport,GLint,GLint,GLsizei,GLsizei) -GML_MAKEFUN2V(DeleteTextures,GLsizei,const GLuint,GLuint,A) -GML_MAKEFUN3(MultiTexCoord2fARB,GLenum,GLfloat,GLfloat,) -GML_MAKEFUN2(AlphaFunc,GLenum,GLclampf,) -GML_MAKEFUN1(DepthMask,GLboolean) -GML_MAKEFUN1(LineWidth,GLfloat) -GML_MAKEFUN2(BindFramebufferEXT,GLenum,GLuint,) -GML_MAKEFUN4(Rotatef,GLfloat,GLfloat,GLfloat,GLfloat) -GML_MAKEFUN2(DeleteLists,GLuint,GLsizei,) -GML_MAKEFUN1CS(DisableClientState,GLenum,&=~) -GML_MAKEFUN1CS(EnableClientState,GLenum,|=) -GML_MAKEFUN4(Rectf,GLfloat,GLfloat,GLfloat,GLfloat) -GML_MAKEFUN3V(Lightfv,GLenum,GLenum,const GLfloat,GLfloat,gmlNumArgsLightMat(B)) -GML_MAKEFUN7S(uBuild2DMipmaps,GLenum,GLint,GLsizei,GLsizei,GLenum,GLenum,const GLvoid,C*D*gmlNumArgsTexImage(E)*gmlSizeOf(F)) -GML_MAKEFUN1(Clear,GLbitfield) -GML_MAKEFUN0(EndList) -GML_MAKEFUN2(NewList,GLuint,GLenum,) -GML_MAKEFUN4(ClearColor,GLclampf,GLclampf,GLclampf,GLclampf) -GML_MAKEFUN2(PolygonMode,GLenum,GLenum,) -GML_MAKEFUN1(ActiveTexture,GLenum) -GML_MAKEFUN2(Fogf,GLenum,GLfloat,) -GML_MAKEFUN1V(MultMatrixf,const GLfloat,GLfloat,16) -GML_MAKEFUN6(Ortho,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble) -GML_MAKEFUN0(PopAttrib) -GML_MAKEFUN3V(Materialfv,GLenum,GLenum,const GLfloat,GLfloat,gmlNumArgsLightMat(B)) -GML_MAKEFUN2(PolygonOffset,GLfloat,GLfloat,) -GML_MAKEFUN1(PushAttrib,GLbitfield) -GML_MAKEFUN1(CullFace,GLenum) -GML_MAKEFUN4(ColorMask,GLboolean,GLboolean,GLboolean,GLboolean) -GML_MAKEFUN1V(Vertex3fv,const GLfloat,GLfloat,3) -GML_MAKEFUN3V(TexGenfv,GLenum,GLenum,const GLfloat,GLfloat,gmlNumArgsTexGen(B)) -GML_MAKEFUN2(Vertex2d,GLdouble,GLdouble,) -GML_MAKEFUN4P(VertexPointer,GLint,GLenum,GLsizei,const GLvoid, VP) -GML_MAKEFUN3VDA(DrawArrays,GLenum,GLint,GLsizei) -GML_MAKEFUN2V(Fogfv,GLenum,const GLfloat,GLfloat,gmlNumArgsFog(A)) -GML_MAKEFUN5(FramebufferTexture2DEXT,GLenum,GLenum,GLenum,GLuint,GLint) -GML_MAKEFUN4(FramebufferTextureEXT,GLenum,GLenum,GLuint,GLint) -GML_MAKEFUN4P(TexCoordPointer,GLint,GLenum,GLsizei,const GLvoid, TCP) -GML_MAKEFUN9S(TexSubImage2D,GLenum,GLint,GLint,GLint,GLsizei,GLsizei,GLenum,GLenum,const GLvoid,E*F*gmlNumArgsTexImage(G)*gmlSizeOf(H)) -GML_MAKEFUN2V(ClipPlane,GLenum,const GLdouble,GLdouble,4) -GML_MAKEFUN4(Color4d,GLdouble,GLdouble,GLdouble,GLdouble) -GML_MAKEFUN2(LightModeli,GLenum,GLint,) -GML_MAKEFUN3(TexGeni,GLenum,GLenum,GLint,) -GML_MAKEFUN3(TexParameterf,GLenum,GLenum,GLfloat,) -GML_MAKEFUN8(CopyTexSubImage2D,GLenum,GLint,GLint,GLint,GLint,GLint,GLsizei,GLsizei) -GML_MAKEFUN2V(DeleteFramebuffersEXT,GLsizei,const GLuint,GLuint,A) -GML_MAKEFUN1V(LoadMatrixf,const GLfloat,GLfloat,16) -GML_MAKEFUN1(ShadeModel,GLenum) -GML_MAKEFUN1(UseProgram,GLuint) -GML_MAKEFUN1(ClientActiveTextureARB,GLenum) -GML_MAKEFUN2V(DeleteRenderbuffersEXT,GLsizei,const GLuint,GLuint,A) -GML_MAKEFUN0(Flush) -GML_MAKEFUN3(Normal3f,GLfloat,GLfloat,GLfloat,) -GML_MAKEFUN1(UseProgramObjectARB,GLhandleARB) -GML_MAKEFUN8VP(CompressedTexImage2DARB,GLenum,GLint,GLenum,GLsizei,GLsizei,GLint,GLsizei,const GLvoid,BYTE,G) -GML_MAKEFUN1(DeleteObjectARB,GLhandleARB) -GML_MAKEFUN2(Fogi,GLenum,GLint,) -GML_MAKEFUN1V(MultMatrixd,const GLdouble,GLdouble,16) -GML_MAKEFUN2(PixelStorei,GLenum,GLint,) -GML_MAKEFUN2(PointParameterf,GLenum,GLfloat,) -GML_MAKEFUN3(TexCoord3f,GLfloat,GLfloat,GLfloat,) -GML_MAKEFUN2(Uniform1i,GLint,GLint,) -GML_MAKEFUN2(BindRenderbufferEXT,GLenum,GLuint,) -GML_MAKEFUN1V(Color3fv,const GLfloat,GLfloat,3) -GML_MAKEFUN1(DepthFunc,GLenum) -GML_MAKEFUN2(Hint,GLenum,GLenum,) -GML_MAKEFUN1(LogicOp,GLenum) -GML_MAKEFUN3(StencilOp,GLenum,GLenum,GLenum,) -GML_MAKEFUN3V(TexEnvfv,GLenum,GLenum,const GLfloat,GLfloat,gmlNumArgsTexEnv(B)) -GML_MAKEFUN4V(UniformMatrix4fv,GLint,GLsizei,GLboolean,const GLfloat,GLfloat,16*B) -GML_MAKEFUN4(uOrtho2D,GLdouble,GLdouble,GLdouble,GLdouble) -GML_MAKEFUN2(AttachObjectARB,GLhandleARB,GLhandleARB,) -GML_MAKEFUN2B(BindBufferARB,GLenum,GLuint) -GML_MAKEFUN1V(Color3ubv,const GLubyte,GLubyte,3) -GML_MAKEFUN2(DetachObjectARB,GLhandleARB,GLhandleARB,) -GML_MAKEFUN4(FramebufferRenderbufferEXT,GLenum,GLenum,GLenum,GLuint) -GML_MAKEFUN2(LineStipple,GLint,GLushort,) -GML_MAKEFUN1V(LoadMatrixd,const GLdouble,GLdouble,16) -GML_MAKEFUN2(SetFenceNV,GLuint,GLenum,) -GML_MAKEFUN3(StencilFunc,GLenum,GLint,GLuint,) -GML_MAKEFUN10S(TexImage3D,GLenum,GLint,GLenum,GLsizei,GLsizei,GLsizei,GLint,GLenum,GLenum,const GLvoid,D*E*F*gmlNumArgsTexImage(H)*gmlSizeOf(I)) -GML_MAKEFUN2(Uniform1f,GLint,GLfloat,) -GML_MAKEFUN1(ClearStencil,GLint) -GML_MAKEFUN4P(ColorPointer,GLint,GLenum,GLsizei,const GLvoid, CP) -GML_MAKEFUN1(DeleteShader,GLuint) -GML_MAKEFUN4VDE(DrawElements,GLenum,GLsizei,GLenum,const GLvoid) -GML_MAKEFUN1(GenerateMipmap,GLenum) -GML_MAKEFUN1(GenerateMipmapEXT,GLenum) -GML_MAKEFUN3(Materialf,GLenum,GLenum,GLfloat,) -GML_MAKEFUN3P(NormalPointer,GLenum,GLsizei,const GLvoid, NP) -GML_MAKEFUN3V(ProgramEnvParameter4fvARB,GLenum,GLuint,const GLfloat,GLfloat,4) -GML_MAKEFUN4(RenderbufferStorageEXT,GLenum,GLenum,GLsizei,GLsizei) -GML_MAKEFUN1(StencilMask,GLuint) -GML_MAKEFUN4(Uniform3f,GLint,GLfloat,GLfloat,GLfloat) -GML_MAKEFUN4(uPerspective,GLdouble,GLdouble,GLdouble,GLdouble) -GML_MAKEFUN1(ActiveStencilFaceEXT,GLenum) -GML_MAKEFUN2(AttachShader,GLuint,GLuint,) -GML_MAKEFUN10(BlitFramebufferEXT,GLint,GLint,GLint,GLint,GLint,GLint,GLint,GLint,GLbitfield,GLenum) -GML_MAKEFUN4VS(BufferDataARB,GLenum,GLsizei,const GLvoid,GLenum,BYTE,B) -GML_MAKEFUN1(ClearDepth,GLclampd) -GML_MAKEFUN3(Color3ub,GLubyte,GLubyte,GLubyte,) -GML_MAKEFUN7VP(CompressedTexImage1DARB,GLenum,GLint,GLenum,GLsizei,GLint,GLsizei,const GLvoid,BYTE,F) -GML_MAKEFUN9VP(CompressedTexImage3DARB,GLenum,GLint,GLenum,GLsizei,GLsizei,GLsizei,GLint,GLsizei,const GLvoid,BYTE,H) -GML_MAKEFUN1(DrawBuffer,GLenum) -GML_MAKEFUN1(FrontFace,GLenum) -GML_MAKEFUN6(Frustum,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble) -GML_MAKEFUN1(LinkProgramARB,GLhandleARB) -GML_MAKEFUN2(MultiTexCoord1f,GLenum,GLfloat,) -GML_MAKEFUN3(MultiTexCoord2f,GLenum,GLfloat,GLfloat,) -GML_MAKEFUN4(MultiTexCoord3f,GLenum,GLfloat,GLfloat,GLfloat) -GML_MAKEFUN5(MultiTexCoord4f,GLenum,GLfloat,GLfloat,GLfloat,GLfloat) -// FIXME: the third parameter should be const, but on old systems opengl headers don't allow to -GML_MAKEFUN2V(PointParameterfv,GLenum,GLfloat,GLfloat,gmlNumArgsPointParam(A)) -GML_MAKEFUN1(PointSize,GLfloat) -GML_MAKEFUN4V(ProgramStringARB,GLenum,GLenum,GLsizei,const GLvoid,BYTE,C) -GML_MAKEFUN3(SecondaryColor3f,GLfloat,GLfloat,GLfloat,) -GML_MAKEFUN1(TexCoord1f,GLfloat) -GML_MAKEFUN4(TexCoord4f,GLfloat,GLfloat,GLfloat,GLfloat) -GML_MAKEFUN3(TexEnvf,GLenum,GLenum,GLfloat,) -GML_MAKEFUN3(TexGenf,GLenum,GLenum,GLfloat,) -GML_MAKEFUN8S(TexImage1D,GLenum,GLint,GLint,GLsizei,GLint,GLenum,GLenum,const GLvoid,D*gmlNumArgsTexImage(F)*gmlSizeOf(G)) -GML_MAKEFUN2(Uniform1iARB,GLint,GLint,) -GML_MAKEFUN3(Uniform2f,GLint,GLfloat,GLfloat,) -GML_MAKEFUN3(Uniform2fARB,GLint,GLfloat,GLfloat,) -GML_MAKEFUN3(Uniform2i,GLint,GLint,GLint,) -GML_MAKEFUN4(Uniform3fARB,GLint,GLfloat,GLfloat,GLfloat) -GML_MAKEFUN4(Uniform3i,GLint,GLint,GLint,GLint) -GML_MAKEFUN5(Uniform4f,GLint,GLfloat,GLfloat,GLfloat,GLfloat) -GML_MAKEFUN5(Uniform4i,GLint,GLint,GLint,GLint,GLint) -GML_MAKEFUN4V(UniformMatrix2fv,GLint,GLsizei,GLboolean,const GLfloat,GLfloat,4*B) -GML_MAKEFUN4V(UniformMatrix3fv,GLint,GLsizei,GLboolean,const GLfloat,GLfloat,9*B) -GML_MAKEFUN4(Vertex4f,GLfloat,GLfloat,GLfloat,GLfloat) -GML_MAKEFUN1(uDeleteQuadric,GLUquadric *) -GML_MAKEFUN2(uQuadricDrawStyle,GLUquadric *,GLenum,) -GML_MAKEFUN4(uSphere,GLUquadric *,GLdouble,GLint,GLint) -GML_MAKEFUN4(ClearAccum,GLfloat,GLfloat,GLfloat,GLfloat) -GML_MAKEFUN4(Color4ub,GLubyte,GLubyte,GLubyte,GLubyte) -GML_MAKEFUN1V(Color4ubv,const GLubyte,GLubyte,4) -GML_MAKEFUN1(CompileShader,GLuint) -GML_MAKEFUN1(CompileShaderARB,GLhandleARB) -GML_MAKEFUN8(CopyTexImage2D,GLenum,GLint,GLenum,GLint,GLint,GLsizei,GLsizei,GLint) -GML_MAKEFUN2V(DeleteBuffersARB,GLsizei,const GLuint,GLuint,A) -GML_MAKEFUN2V(DeleteFencesNV,GLsizei,const GLuint,GLuint,A) -GML_MAKEFUN1(DeleteProgram,GLuint) -GML_MAKEFUN2V(DeleteProgramsARB,GLsizei,const GLuint,GLuint,A) -GML_MAKEFUN2(DetachShader,GLuint,GLuint,) -GML_MAKEFUN1VA(DisableVertexAttribArrayARB,GLuint,VA,erase) -GML_MAKEFUN2V(DrawBuffersARB,GLsizei,const GLenum,GLenum,A) -GML_MAKEFUN1(EdgeFlag,GLboolean) -GML_MAKEFUN1VA(EnableVertexAttribArrayARB,GLuint,VA,insert) -GML_MAKEFUN0(Finish) -GML_MAKEFUN1(FinishFenceNV,GLuint) -GML_MAKEFUN1(FogCoordf,GLfloat) -GML_MAKEFUN3(Lightf,GLenum,GLenum,GLfloat,) -GML_MAKEFUN1(LinkProgram,GLuint) -GML_MAKEFUN1V(Normal3fv,const GLfloat,GLfloat,3) -GML_MAKEFUN2(RasterPos2i,GLint,GLint,) -GML_MAKEFUN1(ReadBuffer,GLenum) -GML_MAKEFUN4(Scissor,GLint,GLint,GLsizei,GLsizei) -GML_MAKEFUN4VSS(ShaderSource,GLuint,GLsizei,const GLchar,const GLint,B) -GML_MAKEFUN4VSS(ShaderSourceARB,GLhandleARB,GLsizei,const GLcharARB,const GLint,B) -GML_MAKEFUN1V(TexCoord2fv,const GLfloat,GLfloat,2) -GML_MAKEFUN3V(TexParameterfv,GLenum,GLenum,const GLfloat,GLfloat,gmlNumArgsTexParam(B)) -GML_MAKEFUN3(Translated,GLdouble,GLdouble,GLdouble,) -GML_MAKEFUN3V(Uniform1fv,GLint,GLsizei,const GLfloat,GLfloat,B) -GML_MAKEFUN5(Uniform4fARB,GLint,GLfloat,GLfloat,GLfloat,GLfloat) -GML_MAKEFUN4V(UniformMatrix4fvARB,GLint,GLsizei,GLboolean,const GLfloat,GLfloat,16*B); -GML_MAKEFUN6P(VertexAttribPointerARB,GLuint,GLint,GLenum,GLboolean,GLsizei,const GLvoid,VA) -GML_MAKEFUN9(uLookAt,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble,GLdouble) -GML_MAKEFUN2V(LightModelfv,GLenum,const GLfloat,GLfloat,gmlNumArgsLightModel(A)) -GML_MAKEFUN2V(DeleteQueries,GLsizei,const GLuint,GLuint,A)// -GML_MAKEFUN1(BlendEquation,GLenum) -GML_MAKEFUN2(StencilMaskSeparate,GLenum,GLuint,) -GML_MAKEFUN4(StencilFuncSeparate,GLenum,GLenum,GLint,GLuint) -GML_MAKEFUN4(StencilOpSeparate,GLenum,GLenum,GLenum,GLenum) -GML_MAKEFUN2(BeginQuery,GLenum,GLuint,) -GML_MAKEFUN1(EndQuery,GLenum) -GML_MAKEFUN3(GetQueryObjectiv,GLuint,GLenum,GLint *,,GML_SYNC()) -GML_MAKEFUN3(GetQueryObjectuiv,GLuint,GLenum,GLuint *,,GML_SYNC()) -GML_MAKEFUN2(BlendEquationSeparate,GLenum,GLenum,) -GML_MAKEFUN4(BlendFuncSeparate,GLenum,GLenum,GLenum,GLenum) -GML_MAKEFUN6(uCylinder,GLUquadric *,GLdouble,GLdouble,GLdouble,GLint,GLint) -GML_MAKEFUN2V(DeleteBuffers,GLsizei,const GLuint,GLuint,A)// -GML_MAKEFUN2B(BindBuffer,GLenum,GLuint) -GML_MAKEFUN4VS(BufferData,GLenum,GLsizeiptr,const GLvoid,GLenum,BYTE,B) -GML_MAKEFUN2R(MapBuffer,GLenum,GLenum,GLvoid *) -GML_MAKEFUN1R(UnmapBuffer,GLenum,GLboolean,) -GML_MAKEFUN8VP(CompressedTexImage2D,GLenum,GLint,GLenum,GLsizei,GLsizei,GLint,GLsizei,const GLvoid,BYTE,G) -GML_MAKEFUN1R(IsShader,GLuint, GLboolean,) -GML_MAKEFUN1R(IsProgram,GLuint, GLboolean,) -GML_MAKEFUN3(Vertex3i,GLint,GLint,GLint,) -GML_MAKEFUN2(GetIntegerv,GLenum,GLint *,GML_CACHE(GLenum,GLint,gmlGetIntegervCache,A,B),GML_SYNC())// -GML_MAKEFUN1R(CheckFramebufferStatusEXT,GLenum, GLenum,GML_DEFAULT_RET(A==GL_FRAMEBUFFER_EXT,GL_FRAMEBUFFER_COMPLETE_EXT)) -GML_MAKEFUN2(GetFloatv,GLenum,GLfloat *,GML_CACHE(GLenum,GLfloat,gmlGetFloatvCache,A,B),GML_SYNC()) -GML_MAKEFUN1R(GetString,GLenum,const GLubyte *,GML_CACHE_RET_STR(GLenum,std::string,gmlGetStringCache,A)) -GML_MAKEFUN2R(GetUniformLocationARB,GLhandleARB,const GLcharARB *, GLint) -GML_MAKEFUN7(ReadPixels,GLint,GLint,GLsizei,GLsizei,GLenum,GLenum,GLvoid *,GML_SYNC()) -GML_MAKEFUN0R(GetError,GLenum,GML_DEFAULT_ERROR()) -GML_MAKEFUN3(GetObjectParameterivARB,GLhandleARB,GLenum,GLint *,GML_DEFAULT(B==GL_OBJECT_COMPILE_STATUS_ARB || B==GL_OBJECT_LINK_STATUS_ARB,*C=GL_TRUE),GML_SYNC()) -GML_MAKEFUN2R(GetUniformLocation,GLuint,const GLchar *, GLint) -GML_MAKEFUN2(GetDoublev,GLenum, GLdouble *,,GML_SYNC()) -GML_MAKEFUN3(GetProgramiv,GLuint,GLenum,GLint *,,GML_SYNC()) -GML_MAKEFUN7(GetActiveUniform,GLuint,GLuint,GLsizei,GLsizei *,GLint *,GLenum *,GLchar *,GML_SYNC()) -GML_MAKEFUN2R(GetAttribLocationARB,GLhandleARB,const GLcharARB *, GLint) -GML_MAKEFUN4(GetInfoLogARB,GLhandleARB,GLsizei,GLsizei *,GLcharARB *,GML_SYNC()) -GML_MAKEFUN4(GetProgramInfoLog,GLuint,GLsizei,GLsizei *,GLchar *,GML_SYNC()) -GML_MAKEFUN3(GetProgramivARB,GLenum,GLenum,GLint *,,GML_SYNC()) -GML_MAKEFUN4(GetShaderInfoLog,GLuint,GLsizei,GLsizei *,GLchar *,GML_SYNC()) -GML_MAKEFUN3(GetShaderiv,GLuint,GLenum,GLint *,GML_DEFAULT(B==GL_COMPILE_STATUS,*C=GL_TRUE),GML_SYNC()) -GML_MAKEFUN1R(IsRenderbufferEXT,GLuint,GLboolean,) -GML_MAKEFUN2R(MapBufferARB,GLenum,GLenum,GLvoid *) -GML_MAKEFUN9R(uProject,GLdouble,GLdouble,GLdouble,const GLdouble *,const GLdouble *,const GLint *,GLdouble *,GLdouble *,GLdouble *,int) -GML_MAKEFUN9R(uScaleImage,GLenum,GLint,GLint,GLenum,const void *,GLint,GLint,GLenum,void *,int) -GML_MAKEFUN1R(TestFenceNV,GLuint,GLboolean,) -GML_MAKEFUN3P(IndexPointer,GLenum,GLsizei,const GLvoid, IP)// -GML_MAKEFUN2P(EdgeFlagPointer,GLsizei,const GLboolean, EFP) -GML_MAKEFUN4(TrackMatrixNV,GLenum,GLuint,GLenum,GLenum) -GML_MAKEFUN3(ProgramParameteriEXT,GLuint,GLenum,GLint,) -GML_MAKEFUN4(BlendColor,GLclampf,GLclampf,GLclampf,GLclampf) -GML_MAKEFUN6VST(Map1f,GLenum,GLfloat,GLfloat,GLint,GLint,const GLfloat,GLfloat,E,D,gmlNumArgsMap1(A)) -GML_MAKEFUN10VST(Map2f,GLenum,GLfloat,GLfloat,GLint,GLint,GLfloat,GLfloat,GLint,GLint,const GLfloat,GLfloat,E,D,I,H,gmlNumArgsMap2(A)) -GML_MAKEFUN3(MapGrid1f,GLint,GLfloat,GLfloat,) -GML_MAKEFUN6(MapGrid2f,GLint,GLfloat,GLfloat,GLint,GLfloat,GLfloat) -GML_MAKEFUN3(EvalMesh1,GLenum,GLint,GLint,) -GML_MAKEFUN5(EvalMesh2,GLenum,GLint,GLint,GLint,GLint) -GML_MAKEFUN1(EvalCoord1f,GLfloat) -GML_MAKEFUN2(EvalCoord2f,GLfloat,GLfloat,) -GML_MAKEFUN1(EvalPoint1,GLint) -GML_MAKEFUN2(EvalPoint2,GLint,GLint,) -GML_MAKEFUN1R(RenderMode,GLenum,GLint,) -GML_MAKEFUN2(SelectBuffer,GLsizei,GLuint *,,GML_SYNC()) -GML_MAKEFUN0(InitNames) -GML_MAKEFUN1(LoadName,GLuint) -GML_MAKEFUN1(PushName,GLuint) -GML_MAKEFUN0(PopName) -GML_MAKEFUN4(GetTexLevelParameteriv,GLenum,GLint,GLenum,GLint *,GML_SYNC()) -GML_MAKEFUN4(GetFramebufferAttachmentParameterivEXT,GLenum,GLenum,GLenum,GLint *,GML_SYNC()) -GML_MAKEFUN3(GetRenderbufferParameterivEXT,GLenum,GLenum,GLint *,,GML_SYNC()) -GML_MAKEFUN5(GetTexImage,GLenum,GLint,GLenum,GLenum,GLvoid *,GML_SYNC()) -GML_MAKEFUN1R(IsTexture,GLuint,GLboolean,) -GML_MAKEFUN5(FramebufferTexture1DEXT,GLenum,GLenum,GLenum,GLuint,GLint) -GML_MAKEFUN6(FramebufferTexture3DEXT,GLenum,GLenum,GLenum,GLuint,GLint,GLint) -GML_MAKEFUN1(ClientActiveTexture,GLenum) -GML_MAKEFUN3(MultiTexCoord2i,GLenum,GLint,GLint,) -GML_MAKEFUN3(GetQueryiv,GLenum,GLenum,GLint *,,GML_SYNC()) -GML_MAKEFUN2(GetBooleanv,GLenum, GLboolean *,,GML_SYNC()) -GML_MAKEFUN1(ValidateProgram,GLuint) -GML_MAKEFUN3V(Uniform1iv,GLint,GLsizei,const GLint,GLint,B) -GML_MAKEFUN3V(Uniform2iv,GLint,GLsizei,const GLint,GLint,2*B) -GML_MAKEFUN3V(Uniform3iv,GLint,GLsizei,const GLint,GLint,3*B) -GML_MAKEFUN3V(Uniform4iv,GLint,GLsizei,const GLint,GLint,4*B) -GML_MAKEFUN3V(Uniform2fv,GLint,GLsizei,const GLfloat,GLfloat,2*B) -GML_MAKEFUN3V(Uniform3fv,GLint,GLsizei,const GLfloat,GLfloat,3*B) -GML_MAKEFUN3V(Uniform4fv,GLint,GLsizei,const GLfloat,GLfloat,4*B) -GML_MAKEFUN3V(Uniform1uiv,GLint,GLsizei,const GLuint,GLuint,B) -GML_MAKEFUN3V(Uniform2uiv,GLint,GLsizei,const GLuint,GLuint,2*B) -GML_MAKEFUN3V(Uniform3uiv,GLint,GLsizei,const GLuint,GLuint,3*B) -GML_MAKEFUN3V(Uniform4uiv,GLint,GLsizei,const GLuint,GLuint,4*B) -GML_MAKEFUN4R(MapBufferRange,GLenum,GLintptr,GLsizeiptr,GLbitfield,GLvoid *) -GML_MAKEFUN1(PrimitiveRestartIndexNV,GLuint) -GML_MAKEFUN6VDRE(DrawRangeElements,GLenum,GLuint,GLuint,GLsizei,GLenum,const GLvoid) -GML_MAKEFUN3(GetUniformfv,GLuint,GLint,GLfloat *,,GML_SYNC()) -GML_MAKEFUN3(GetUniformiv,GLuint,GLint,GLint *,,GML_SYNC()) -GML_MAKEFUN3(GetUniformuiv,GLuint,GLint,GLuint *,,GML_SYNC()) -GML_MAKEFUN7(GetActiveAttrib,GLuint,GLuint,GLsizei,GLsizei *,GLint *,GLenum *,GLchar *,GML_SYNC()) -GML_MAKEFUN2R(GetAttribLocation,GLuint,const GLchar *,GLint) -GML_MAKEFUN3(BindAttribLocation,GLuint,GLuint,const GLchar *,) -GML_MAKEFUN3(GetCompressedTexImage,GLenum,GLint,GLvoid *,,GML_SYNC()) - -#endif // _GML_FUN_H diff -Nru spring-96.0~14.04~ppa4/rts/lib/gml/gml.h spring-98.0~14.04~ppa6/rts/lib/gml/gml.h --- spring-96.0~14.04~ppa4/rts/lib/gml/gml.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/gml/gml.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,233 +0,0 @@ -// GML - OpenGL Multithreading Library -// for Spring http://springrts.com -// Author: Mattias "zerver" Radeskog -// (C) Ware Zerver Tech. http://zerver.net -// Ware Zerver Tech. licenses this library -// to be used, distributed and modified -// freely for any purpose, as long as -// this notice remains unchanged - -#ifndef GML_H -#define GML_H - -#if defined USE_GML_SIM && !defined USE_GML -#error USE_GML_SIM requires USE_GML -#endif - -#include "gmlcnf.h" - -#define GML_MUTEX_PROFILER 0 // enables mutex profiler - -#ifdef USE_GML - -#define GML_MUTEX_PROFILE 0 // detailed profiling of specific mutex -extern const char *gmlProfMutex; -#define GML_PROC_PROFILER 0 // enables gmlprocessor profiler - -#include -#include - -#include -#include "gmlcls.h" -#include "gmlque.h" - -extern gmlQueue gmlQueues[GML_MAX_NUM_THREADS]; - -#include "gmlfun.h" - -#if GML_PROC_PROFILER - extern int gmlProcNumLoop; - extern int gmlProcInterval; - #define GML_PROFILER(name) \ - GML::Enabled() && name && (globalRendering->drawFrame & gmlProcInterval);\ - SCOPED_TIMER(!name ? "NoProc" : ((name && (globalRendering->drawFrame & gmlProcInterval)) ? " " GML_QUOTE(name) "MTProc" : " " GML_QUOTE(name) "Proc"));\ - for(int i = 0; i < (name ? gmlProcNumLoop : 1); ++i) -#else - #define GML_PROFILER(name) (GML::Enabled() && name); -#endif - -extern gmlSingleItemServer gmlShaderServer_VERTEX; -extern gmlSingleItemServer gmlShaderServer_FRAGMENT; -extern gmlSingleItemServer gmlShaderServer_GEOMETRY_EXT; -extern gmlSingleItemServer gmlShaderObjectARBServer_VERTEX; -extern gmlSingleItemServer gmlShaderObjectARBServer_FRAGMENT; -extern gmlSingleItemServer gmlShaderObjectARBServer_GEOMETRY_EXT; -extern gmlSingleItemServer gmlQuadricServer; - -#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 3) && (__GNUC_PATCHLEVEL__ == 0) -// gcc has issues with attributes in function pointers it seems -extern gmlSingleItemServer gmlProgramServer; -extern gmlSingleItemServer gmlProgramObjectARBServer; - -extern gmlMultiItemServer gmlBufferARBServer; -extern gmlMultiItemServer gmlFencesNVServer; -extern gmlMultiItemServer gmlProgramsARBServer; -extern gmlMultiItemServer gmlRenderbuffersEXTServer; -extern gmlMultiItemServer gmlFramebuffersEXTServer; -extern gmlMultiItemServer gmlQueryServer; -extern gmlMultiItemServer gmlBufferServer; -#else -extern gmlSingleItemServer gmlProgramServer; -extern gmlSingleItemServer gmlProgramObjectARBServer; - -extern gmlMultiItemServer gmlBufferARBServer; -extern gmlMultiItemServer gmlFencesNVServer; -extern gmlMultiItemServer gmlProgramsARBServer; -extern gmlMultiItemServer gmlRenderbuffersEXTServer; -extern gmlMultiItemServer gmlFramebuffersEXTServer; -extern gmlMultiItemServer gmlQueryServer; -extern gmlMultiItemServer gmlBufferServer; -#endif - -extern gmlMultiItemServer gmlTextureServer; - -extern gmlItemSequenceServer gmlListServer; - -extern void gmlInit(); - -#define GML_IF_NONCLIENT_THREAD(name,...)\ - int threadnum = gmlThreadNumber;\ - GML_IF_SHARE_THREAD(threadnum) {\ - name(__VA_ARGS__);\ - return;\ - }\ - GML_ITEMSERVER_CHECK(threadnum); - -#define GML_IF_NONCLIENT_THREAD_RET(ret,name,...)\ - int threadnum = gmlThreadNumber;\ - GML_IF_SHARE_THREAD(threadnum) {\ - return name(__VA_ARGS__);\ - }\ - GML_ITEMSERVER_CHECK_RET(threadnum,ret); - -EXTERN inline GLhandleARB GML_GLAPIENTRY gmlCreateProgram() { - GML_IF_NONCLIENT_THREAD_RET(GLhandleARB,glCreateProgram); - return gmlProgramServer.GetItems(); -} -EXTERN inline GLhandleARB GML_GLAPIENTRY gmlCreateProgramObjectARB() { - GML_IF_NONCLIENT_THREAD_RET(GLhandleARB,glCreateProgramObjectARB); - return gmlProgramObjectARBServer.GetItems(); -} -EXTERN inline GLhandleARB GML_GLAPIENTRY gmlCreateShader(GLenum type) { - GML_IF_NONCLIENT_THREAD_RET(GLhandleARB,glCreateShader,type); - if(type==GL_VERTEX_SHADER) - return gmlShaderServer_VERTEX.GetItems(); - if(type==GL_FRAGMENT_SHADER) - return gmlShaderServer_FRAGMENT.GetItems(); - if(type==GL_GEOMETRY_SHADER_EXT) - return gmlShaderServer_GEOMETRY_EXT.GetItems(); - return 0; -} -EXTERN inline GLhandleARB GML_GLAPIENTRY gmlCreateShaderObjectARB(GLenum type) { - GML_IF_NONCLIENT_THREAD_RET(GLhandleARB,glCreateShaderObjectARB,type); - if(type==GL_VERTEX_SHADER_ARB) - return gmlShaderObjectARBServer_VERTEX.GetItems(); - if(type==GL_FRAGMENT_SHADER_ARB) - return gmlShaderObjectARBServer_FRAGMENT.GetItems(); - if(type==GL_GEOMETRY_SHADER_EXT) - return gmlShaderObjectARBServer_GEOMETRY_EXT.GetItems(); - return 0; -} -EXTERN inline GLUquadric *GML_GLAPIENTRY gmluNewQuadric() { - GML_IF_NONCLIENT_THREAD_RET(GLUquadric *,gluNewQuadric); - return gmlQuadricServer.GetItems(); -} - -EXTERN inline void GML_GLAPIENTRY gmlGenTextures(GLsizei n, GLuint *items) { - GML_IF_NONCLIENT_THREAD(glGenTextures,n,items); - gmlTextureServer.GetItems(n, items); -} -EXTERN inline void GML_GLAPIENTRY gmlGenBuffersARB(GLsizei n, GLuint *items) { - GML_IF_NONCLIENT_THREAD(glGenBuffersARB,n,items); - gmlBufferARBServer.GetItems(n, items); -} -EXTERN inline void GML_GLAPIENTRY gmlGenFencesNV(GLsizei n, GLuint *items) { - GML_IF_NONCLIENT_THREAD(glGenFencesNV,n,items); - gmlFencesNVServer.GetItems(n, items); -} -EXTERN inline void GML_GLAPIENTRY gmlGenProgramsARB(GLsizei n, GLuint *items) { - GML_IF_NONCLIENT_THREAD(glGenProgramsARB,n,items); - gmlProgramsARBServer.GetItems(n, items); -} -EXTERN inline void GML_GLAPIENTRY gmlGenRenderbuffersEXT(GLsizei n, GLuint *items) { - GML_IF_NONCLIENT_THREAD(glGenRenderbuffersEXT,n,items); - gmlRenderbuffersEXTServer.GetItems(n, items); -} -EXTERN inline void GML_GLAPIENTRY gmlGenFramebuffersEXT(GLsizei n, GLuint *items) { - GML_IF_NONCLIENT_THREAD(glGenFramebuffersEXT,n,items); - gmlFramebuffersEXTServer.GetItems(n, items); -} -EXTERN inline void GML_GLAPIENTRY gmlGenQueries(GLsizei n, GLuint *items) { - GML_IF_NONCLIENT_THREAD(glGenQueries,n,items); - gmlQueryServer.GetItems(n, items); -} -EXTERN inline void GML_GLAPIENTRY gmlGenBuffers(GLsizei n, GLuint *items) { - GML_IF_NONCLIENT_THREAD(glGenBuffers,n,items); - gmlBufferServer.GetItems(n, items); -} - -EXTERN inline GLuint GML_GLAPIENTRY gmlGenLists(GLsizei items) { - GML_IF_NONCLIENT_THREAD_RET(GLuint,glGenLists,items); - return gmlListServer.GetItems(items); -} - -#include "gmlimp.h" -#include "gmldef.h" - -#define GML_VECTOR gmlVector -#define GML_CLASSVECTOR gmlClassVector - -#include "gmlmut.h" - -#if GML_ENABLE_SIM - -#if GML_CALL_DEBUG -#define GML_EXPGEN_CHECK() \ - if(gmlThreadNumber != GML_SIM_THREAD_NUM && gmlMultiThreadSim && gmlStartSim) {\ - lua_State *currentLuaState = gmlCurrentLuaStates[gmlThreadNumber];\ - LOG_SL("Threading", L_ERROR, "Draw thread created ExpGenSpawnable (%s)", GML_CURRENT_LUA(currentLuaState));\ - if(currentLuaState) luaL_error(currentLuaState,"Invalid call");\ - } -#define GML_CALL_DEBUGGER() gmlCallDebugger gmlCDBG(L); -#define GML_LOCK_TIME() (gmlCallDebugger::getLockTime()) -#define GML_RESET_LOCK_TIME() (gmlCallDebugger::resetLockTime()) -#else -#define GML_EXPGEN_CHECK() -#define GML_CALL_DEBUGGER() -#define GML_LOCK_TIME() 0 -#define GML_RESET_LOCK_TIME() -#endif - -#else - -#define GML_EXPGEN_CHECK() -#define GML_CALL_DEBUGGER() -#define GML_LOCK_TIME() 0 -#define GML_RESET_LOCK_TIME() - -#endif - -#else - -#define GML_VECTOR std::vector -#define GML_CLASSVECTOR std::vector - -#define GML_STDMUTEX_LOCK(name) -#define GML_RECMUTEX_LOCK(name) -#define GML_THRMUTEX_LOCK(name,thr) -#define GML_OBJMUTEX_LOCK(name,thr,...) -#define GML_STDMUTEX_LOCK_NOPROF(name) -#define GML_MSTMUTEX_LOCK(name,...) -#define GML_MSTMUTEX_DOLOCK(name) -#define GML_MSTMUTEX_DOUNLOCK(name) - -#define GML_EXPGEN_CHECK() -#define GML_CALL_DEBUGGER() -#define GML_LOCK_TIME() 0 -#define GML_RESET_LOCK_TIME() - -#endif // USE_GML - -#include "gml_base.h" - -#endif diff -Nru spring-96.0~14.04~ppa4/rts/lib/gml/gmlimp.h spring-98.0~14.04~ppa6/rts/lib/gml/gmlimp.h --- spring-96.0~14.04~ppa4/rts/lib/gml/gmlimp.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/gml/gmlimp.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,3140 +0,0 @@ -// GML - OpenGL Multithreading Library -// for Spring http://springrts.com -// Author: Mattias "zerver" Radeskog -// (C) Ware Zerver Tech. http://zerver.net -// Ware Zerver Tech. licenses this library -// to be used, distributed and modified -// freely for any purpose, as long as -// this notice remains unchanged - -#undef glAccum -#undef glActiveStencilFaceEXT -#undef glActiveTexture -#undef glActiveTextureARB -#undef glActiveVaryingNV -#undef glAddSwapHintRectWIN -#undef glAlphaFragmentOp1ATI -#undef glAlphaFragmentOp2ATI -#undef glAlphaFragmentOp3ATI -#undef glAlphaFunc -#undef glApplyTextureEXT -#undef glAreProgramsResidentNV -#undef glAreTexturesResident -#undef glAreTexturesResidentEXT -#undef glArrayElement -#undef glArrayElementEXT -#undef glArrayObjectATI -#undef glAsyncMarkerSGIX -#undef glAttachObjectARB -#undef glAttachShader -#undef glBegin -#undef glBeginFragmentShaderATI -#undef glBeginOcclusionQueryNV -#undef glBeginQuery -#undef glBeginQueryARB -#undef glBeginSceneEXT -#undef glBeginTransformFeedbackNV -#undef glBeginVertexShaderEXT -#undef glBindAttribLocation -#undef glBindAttribLocationARB -#undef glBindBuffer -#undef glBindBufferARB -#undef glBindBufferBaseNV -#undef glBindBufferOffsetNV -#undef glBindBufferRangeNV -#undef glBindFragDataLocationEXT -#undef glBindFragmentShaderATI -#undef glBindFramebufferEXT -#undef glBindLightParameterEXT -#undef glBindMaterialParameterEXT -#undef glBindParameterEXT -#undef glBindProgramARB -#undef glBindProgramNV -#undef glBindRenderbufferEXT -#undef glBindTexGenParameterEXT -#undef glBindTexture -#undef glBindTextureEXT -#undef glBindTextureUnitParameterEXT -#undef glBindVertexArrayAPPLE -#undef glBindVertexShaderEXT -#undef glBinormalPointerEXT -#undef glBitmap -#undef glBlendColor -#undef glBlendColorEXT -#undef glBlendEquation -#undef glBlendEquationEXT -#undef glBlendEquationSeparate -#undef glBlendEquationSeparateEXT -#undef glBlendFunc -#undef glBlendFuncSeparate -#undef glBlendFuncSeparateEXT -#undef glBlitFramebufferEXT -#undef glBufferData -#undef glBufferDataARB -#undef glBufferRegionEnabledEXT -#undef glBufferSubData -#undef glBufferSubDataARB -#undef glCallList -#undef glCallLists -#undef glCheckFramebufferStatusEXT -#undef glClampColorARB -#undef glClear -#undef glClearAccum -#undef glClearColor -#undef glClearColorIiEXT -#undef glClearColorIuiEXT -#undef glClearDepth -#undef glClearDepthdNV -#undef glClearDepthfOES -#undef glClearIndex -#undef glClearStencil -#undef glClientActiveTexture -#undef glClientActiveTextureARB -#undef glClientActiveVertexStreamATI -#undef glClipPlane -#undef glClipPlanefOES -#undef glColor3b -#undef glColor3bv -#undef glColor3d -#undef glColor3dv -#undef glColor3f -#undef glColor3fVertex3fSUN -#undef glColor3fVertex3fvSUN -#undef glColor3fv -#undef glColor3hNV -#undef glColor3hvNV -#undef glColor3i -#undef glColor3iv -#undef glColor3s -#undef glColor3sv -#undef glColor3ub -#undef glColor3ubv -#undef glColor3ui -#undef glColor3uiv -#undef glColor3us -#undef glColor3usv -#undef glColor4b -#undef glColor4bv -#undef glColor4d -#undef glColor4dv -#undef glColor4f -#undef glColor4fNormal3fVertex3fSUN -#undef glColor4fNormal3fVertex3fvSUN -#undef glColor4fv -#undef glColor4hNV -#undef glColor4hvNV -#undef glColor4i -#undef glColor4iv -#undef glColor4s -#undef glColor4sv -#undef glColor4ub -#undef glColor4ubVertex2fSUN -#undef glColor4ubVertex2fvSUN -#undef glColor4ubVertex3fSUN -#undef glColor4ubVertex3fvSUN -#undef glColor4ubv -#undef glColor4ui -#undef glColor4uiv -#undef glColor4us -#undef glColor4usv -#undef glColorFragmentOp1ATI -#undef glColorFragmentOp2ATI -#undef glColorFragmentOp3ATI -#undef glColorMask -#undef glColorMaskIndexedEXT -#undef glColorMaterial -#undef glColorPointer -#undef glColorPointerEXT -#undef glColorPointerListIBM -#undef glColorPointervINTEL -#undef glColorSubTable -#undef glColorSubTableEXT -#undef glColorTable -#undef glColorTableEXT -#undef glColorTableParameterfv -#undef glColorTableParameterfvSGI -#undef glColorTableParameteriv -#undef glColorTableParameterivSGI -#undef glColorTableSGI -#undef glCombinerInputNV -#undef glCombinerOutputNV -#undef glCombinerParameterfNV -#undef glCombinerParameterfvNV -#undef glCombinerParameteriNV -#undef glCombinerParameterivNV -#undef glCombinerStageParameterfvNV -#undef glCompileShader -#undef glCompileShaderARB -#undef glCompressedTexImage1D -#undef glCompressedTexImage1DARB -#undef glCompressedTexImage2D -#undef glCompressedTexImage2DARB -#undef glCompressedTexImage3D -#undef glCompressedTexImage3DARB -#undef glCompressedTexSubImage1D -#undef glCompressedTexSubImage1DARB -#undef glCompressedTexSubImage2D -#undef glCompressedTexSubImage2DARB -#undef glCompressedTexSubImage3D -#undef glCompressedTexSubImage3DARB -#undef glConvolutionFilter1D -#undef glConvolutionFilter1DEXT -#undef glConvolutionFilter2D -#undef glConvolutionFilter2DEXT -#undef glConvolutionParameterf -#undef glConvolutionParameterfEXT -#undef glConvolutionParameterfv -#undef glConvolutionParameterfvEXT -#undef glConvolutionParameteri -#undef glConvolutionParameteriEXT -#undef glConvolutionParameteriv -#undef glConvolutionParameterivEXT -#undef glCopyColorSubTable -#undef glCopyColorSubTableEXT -#undef glCopyColorTable -#undef glCopyColorTableSGI -#undef glCopyConvolutionFilter1D -#undef glCopyConvolutionFilter1DEXT -#undef glCopyConvolutionFilter2D -#undef glCopyConvolutionFilter2DEXT -#undef glCopyPixels -#undef glCopyTexImage1D -#undef glCopyTexImage1DEXT -#undef glCopyTexImage2D -#undef glCopyTexImage2DEXT -#undef glCopyTexSubImage1D -#undef glCopyTexSubImage1DEXT -#undef glCopyTexSubImage2D -#undef glCopyTexSubImage2DEXT -#undef glCopyTexSubImage3D -#undef glCopyTexSubImage3DEXT -#undef glCreateProgram -#undef glCreateProgramObjectARB -#undef glCreateShader -#undef glCreateShaderObjectARB -#undef glCullFace -#undef glCullParameterdvEXT -#undef glCullParameterfvEXT -#undef glCurrentPaletteMatrixARB -#undef glDeleteAsyncMarkersSGIX -#undef glDeleteBufferRegionEXT -#undef glDeleteBuffers -#undef glDeleteBuffersARB -#undef glDeleteFencesAPPLE -#undef glDeleteFencesNV -#undef glDeleteFragmentShaderATI -#undef glDeleteFramebuffersEXT -#undef glDeleteLists -#undef glDeleteObjectARB -#undef glDeleteOcclusionQueriesNV -#undef glDeleteProgram -#undef glDeleteProgramsARB -#undef glDeleteProgramsNV -#undef glDeleteQueries -#undef glDeleteQueriesARB -#undef glDeleteRenderbuffersEXT -#undef glDeleteShader -#undef glDeleteTextures -#undef glDeleteTexturesEXT -#undef glDeleteVertexArraysAPPLE -#undef glDeleteVertexShaderEXT -#undef glDepthBoundsEXT -#undef glDepthBoundsdNV -#undef glDepthFunc -#undef glDepthMask -#undef glDepthRange -#undef glDepthRangedNV -#undef glDepthRangefOES -#undef glDetachObjectARB -#undef glDetachShader -#undef glDetailTexFuncSGIS -#undef glDisable -#undef glDisableClientState -#undef glDisableIndexedEXT -#undef glDisableVariantClientStateEXT -#undef glDisableVertexAttribArray -#undef glDisableVertexAttribArrayARB -#undef glDrawArrays -#undef glDrawArraysEXT -#undef glDrawArraysInstancedEXT -#undef glDrawBuffer -#undef glDrawBufferRegionEXT -#undef glDrawBuffers -#undef glDrawBuffersARB -#undef glDrawBuffersATI -#undef glDrawElementArrayAPPLE -#undef glDrawElementArrayATI -#undef glDrawElements -#undef glDrawElementsInstancedEXT -#undef glDrawPixels -#undef glDrawRangeElementArrayAPPLE -#undef glDrawRangeElementArrayATI -#undef glDrawRangeElements -#undef glDrawRangeElementsEXT -#undef glEdgeFlag -#undef glEdgeFlagPointer -#undef glEdgeFlagPointerEXT -#undef glEdgeFlagPointerListIBM -#undef glEdgeFlagv -#undef glElementPointerAPPLE -#undef glElementPointerATI -#undef glEnable -#undef glEnableClientState -#undef glEnableIndexedEXT -#undef glEnableVariantClientStateEXT -#undef glEnableVertexAttribArray -#undef glEnableVertexAttribArrayARB -#undef glEnd -#undef glEndFragmentShaderATI -#undef glEndList -#undef glEndOcclusionQueryNV -#undef glEndQuery -#undef glEndQueryARB -#undef glEndSceneEXT -#undef glEndTransformFeedbackNV -#undef glEndVertexShaderEXT -#undef glEvalCoord1d -#undef glEvalCoord1dv -#undef glEvalCoord1f -#undef glEvalCoord1fv -#undef glEvalCoord2d -#undef glEvalCoord2dv -#undef glEvalCoord2f -#undef glEvalCoord2fv -#undef glEvalMapsNV -#undef glEvalMesh1 -#undef glEvalMesh2 -#undef glEvalPoint1 -#undef glEvalPoint2 -#undef glExecuteProgramNV -#undef glExtractComponentEXT -#undef glFeedbackBuffer -#undef glFinalCombinerInputNV -#undef glFinish -#undef glFinishAsyncSGIX -#undef glFinishFenceAPPLE -#undef glFinishFenceNV -#undef glFinishObjectAPPLE -#undef glFinishTextureSUNX -#undef glFlush -#undef glFlushPixelDataRangeNV -#undef glFlushRasterSGIX -#undef glFlushVertexArrayRangeAPPLE -#undef glFlushVertexArrayRangeNV -#undef glFogCoordPointer -#undef glFogCoordPointerEXT -#undef glFogCoordPointerListIBM -#undef glFogCoordd -#undef glFogCoorddEXT -#undef glFogCoorddv -#undef glFogCoorddvEXT -#undef glFogCoordf -#undef glFogCoordfEXT -#undef glFogCoordfv -#undef glFogCoordfvEXT -#undef glFogCoordhNV -#undef glFogCoordhvNV -#undef glFogFuncSGIS -#undef glFogf -#undef glFogfv -#undef glFogi -#undef glFogiv -#undef glFragmentColorMaterialEXT -#undef glFragmentColorMaterialSGIX -#undef glFragmentLightModelfEXT -#undef glFragmentLightModelfSGIX -#undef glFragmentLightModelfvEXT -#undef glFragmentLightModelfvSGIX -#undef glFragmentLightModeliEXT -#undef glFragmentLightModeliSGIX -#undef glFragmentLightModelivEXT -#undef glFragmentLightModelivSGIX -#undef glFragmentLightfEXT -#undef glFragmentLightfSGIX -#undef glFragmentLightfvEXT -#undef glFragmentLightfvSGIX -#undef glFragmentLightiEXT -#undef glFragmentLightiSGIX -#undef glFragmentLightivEXT -#undef glFragmentLightivSGIX -#undef glFragmentMaterialfEXT -#undef glFragmentMaterialfSGIX -#undef glFragmentMaterialfvEXT -#undef glFragmentMaterialfvSGIX -#undef glFragmentMaterialiEXT -#undef glFragmentMaterialiSGIX -#undef glFragmentMaterialivEXT -#undef glFragmentMaterialivSGIX -#undef glFrameZoomSGIX -#undef glFramebufferRenderbufferEXT -#undef glFramebufferTexture1DEXT -#undef glFramebufferTexture2DEXT -#undef glFramebufferTexture3DEXT -#undef glFramebufferTextureEXT -#undef glFramebufferTextureFaceEXT -#undef glFramebufferTextureLayerEXT -#undef glFreeObjectBufferATI -#undef glFrontFace -#undef glFrustum -#undef glFrustumfOES -#undef glGenAsyncMarkersSGIX -#undef glGenBuffers -#undef glGenBuffersARB -#undef glGenFencesAPPLE -#undef glGenFencesNV -#undef glGenFragmentShadersATI -#undef glGenFramebuffersEXT -#undef glGenLists -#undef glGenOcclusionQueriesNV -#undef glGenProgramsARB -#undef glGenProgramsNV -#undef glGenQueries -#undef glGenQueriesARB -#undef glGenRenderbuffersEXT -#undef glGenSymbolsEXT -#undef glGenTextures -#undef glGenTexturesEXT -#undef glGenVertexArraysAPPLE -#undef glGenVertexShadersEXT -#undef glGenerateMipmap -#undef glGenerateMipmapEXT -#undef glGetActiveAttrib -#undef glGetActiveAttribARB -#undef glGetActiveUniform -#undef glGetActiveUniformARB -#undef glGetActiveVaryingNV -#undef glGetArrayObjectfvATI -#undef glGetArrayObjectivATI -#undef glGetAttachedObjectsARB -#undef glGetAttachedShaders -#undef glGetAttribLocation -#undef glGetAttribLocationARB -#undef glGetBooleanIndexedvEXT -#undef glGetBooleanv -#undef glGetBufferParameteriv -#undef glGetBufferParameterivARB -#undef glGetBufferPointerv -#undef glGetBufferPointervARB -#undef glGetBufferSubData -#undef glGetBufferSubDataARB -#undef glGetClipPlane -#undef glGetClipPlanefOES -#undef glGetColorTable -#undef glGetColorTableEXT -#undef glGetColorTableParameterfv -#undef glGetColorTableParameterfvEXT -#undef glGetColorTableParameterfvSGI -#undef glGetColorTableParameteriv -#undef glGetColorTableParameterivEXT -#undef glGetColorTableParameterivSGI -#undef glGetColorTableSGI -#undef glGetCombinerInputParameterfvNV -#undef glGetCombinerInputParameterivNV -#undef glGetCombinerOutputParameterfvNV -#undef glGetCombinerOutputParameterivNV -#undef glGetCombinerStageParameterfvNV -#undef glGetCompressedTexImage -#undef glGetCompressedTexImageARB -#undef glGetConvolutionFilter -#undef glGetConvolutionFilterEXT -#undef glGetConvolutionParameterfv -#undef glGetConvolutionParameterfvEXT -#undef glGetConvolutionParameteriv -#undef glGetConvolutionParameterivEXT -#undef glGetDetailTexFuncSGIS -#undef glGetDoublev -#undef glGetError -#undef glGetFenceivNV -#undef glGetFinalCombinerInputParameterfvNV -#undef glGetFinalCombinerInputParameterivNV -#undef glGetFloatv -#undef glGetFogFuncSGIS -#undef glGetFragDataLocationEXT -#undef glGetFragmentLightfvEXT -#undef glGetFragmentLightfvSGIX -#undef glGetFragmentLightivEXT -#undef glGetFragmentLightivSGIX -#undef glGetFragmentMaterialfvEXT -#undef glGetFragmentMaterialfvSGIX -#undef glGetFragmentMaterialivEXT -#undef glGetFragmentMaterialivSGIX -#undef glGetFramebufferAttachmentParameterivEXT -#undef glGetHandleARB -#undef glGetHistogram -#undef glGetHistogramEXT -#undef glGetHistogramParameterfv -#undef glGetHistogramParameterfvEXT -#undef glGetHistogramParameteriv -#undef glGetHistogramParameterivEXT -#undef glGetImageTransformParameterfvHP -#undef glGetImageTransformParameterivHP -#undef glGetInfoLogARB -#undef glGetIntegerIndexedvEXT -#undef glGetIntegerv -#undef glGetInvariantBooleanvEXT -#undef glGetInvariantFloatvEXT -#undef glGetInvariantIntegervEXT -#undef glGetLightfv -#undef glGetLightiv -#undef glGetLocalConstantBooleanvEXT -#undef glGetLocalConstantFloatvEXT -#undef glGetLocalConstantIntegervEXT -#undef glGetMapAttribParameterfvNV -#undef glGetMapAttribParameterivNV -#undef glGetMapControlPointsNV -#undef glGetMapParameterfvNV -#undef glGetMapParameterivNV -#undef glGetMapdv -#undef glGetMapfv -#undef glGetMapiv -#undef glGetMaterialfv -#undef glGetMaterialiv -#undef glGetMinmax -#undef glGetMinmaxEXT -#undef glGetMinmaxParameterfv -#undef glGetMinmaxParameterfvEXT -#undef glGetMinmaxParameteriv -#undef glGetMinmaxParameterivEXT -#undef glGetObjectBufferfvATI -#undef glGetObjectBufferivATI -#undef glGetObjectParameterfvARB -#undef glGetObjectParameterivARB -#undef glGetOcclusionQueryivNV -#undef glGetOcclusionQueryuivNV -#undef glGetPixelMapfv -#undef glGetPixelMapuiv -#undef glGetPixelMapusv -#undef glGetPixelTransformParameterfvEXT -#undef glGetPixelTransformParameterivEXT -#undef glGetPointerv -#undef glGetPointervEXT -#undef glGetPolygonStipple -#undef glGetProgramEnvParameterdvARB -#undef glGetProgramEnvParameterfvARB -#undef glGetProgramInfoLog -#undef glGetProgramLocalParameterdvARB -#undef glGetProgramLocalParameterfvARB -#undef glGetProgramNamedParameterdvNV -#undef glGetProgramNamedParameterfvNV -#undef glGetProgramParameterdvNV -#undef glGetProgramParameterfvNV -#undef glGetProgramStringARB -#undef glGetProgramStringNV -#undef glGetProgramiv -#undef glGetProgramivARB -#undef glGetProgramivNV -#undef glGetQueryObjecti64vEXT -#undef glGetQueryObjectiv -#undef glGetQueryObjectivARB -#undef glGetQueryObjectui64vEXT -#undef glGetQueryObjectuiv -#undef glGetQueryObjectuivARB -#undef glGetQueryiv -#undef glGetQueryivARB -#undef glGetRenderbufferParameterivEXT -#undef glGetSeparableFilter -#undef glGetSeparableFilterEXT -#undef glGetShaderInfoLog -#undef glGetShaderSource -#undef glGetShaderSourceARB -#undef glGetShaderiv -#undef glGetSharpenTexFuncSGIS -#undef glGetString -#undef glGetTexBumpParameterfvATI -#undef glGetTexBumpParameterivATI -#undef glGetTexEnvfv -#undef glGetTexEnviv -#undef glGetTexFilterFuncSGIS -#undef glGetTexGendv -#undef glGetTexGenfv -#undef glGetTexGeniv -#undef glGetTexImage -#undef glGetTexLevelParameterfv -#undef glGetTexLevelParameteriv -#undef glGetTexParameterIivEXT -#undef glGetTexParameterIuivEXT -#undef glGetTexParameterPointervAPPLE -#undef glGetTexParameterfv -#undef glGetTexParameteriv -#undef glGetTrackMatrixivNV -#undef glGetTransformFeedbackVaryingNV -#undef glGetUniformBufferSizeEXT -#undef glGetUniformLocation -#undef glGetUniformLocationARB -#undef glGetUniformOffsetEXT -#undef glGetUniformfv -#undef glGetUniformfvARB -#undef glGetUniformiv -#undef glGetUniformivARB -#undef glGetUniformuiv -#undef glGetUniformuivEXT -#undef glGetVariantArrayObjectfvATI -#undef glGetVariantArrayObjectivATI -#undef glGetVariantBooleanvEXT -#undef glGetVariantFloatvEXT -#undef glGetVariantIntegervEXT -#undef glGetVariantPointervEXT -#undef glGetVaryingLocationNV -#undef glGetVertexAttribArrayObjectfvATI -#undef glGetVertexAttribArrayObjectivATI -#undef glGetVertexAttribIivEXT -#undef glGetVertexAttribIuivEXT -#undef glGetVertexAttribPointerv -#undef glGetVertexAttribPointervARB -#undef glGetVertexAttribPointervNV -#undef glGetVertexAttribdv -#undef glGetVertexAttribdvARB -#undef glGetVertexAttribdvNV -#undef glGetVertexAttribfv -#undef glGetVertexAttribfvARB -#undef glGetVertexAttribfvNV -#undef glGetVertexAttribiv -#undef glGetVertexAttribivARB -#undef glGetVertexAttribivNV -#undef glGlobalAlphaFactorbSUN -#undef glGlobalAlphaFactordSUN -#undef glGlobalAlphaFactorfSUN -#undef glGlobalAlphaFactoriSUN -#undef glGlobalAlphaFactorsSUN -#undef glGlobalAlphaFactorubSUN -#undef glGlobalAlphaFactoruiSUN -#undef glGlobalAlphaFactorusSUN -#undef glHint -#undef glHistogram -#undef glHistogramEXT -#undef glImageTransformParameterfHP -#undef glImageTransformParameterfvHP -#undef glImageTransformParameteriHP -#undef glImageTransformParameterivHP -#undef glIndexFuncEXT -#undef glIndexMask -#undef glIndexMaterialEXT -#undef glIndexPointer -#undef glIndexPointerEXT -#undef glIndexPointerListIBM -#undef glIndexd -#undef glIndexdv -#undef glIndexf -#undef glIndexfv -#undef glIndexi -#undef glIndexiv -#undef glIndexs -#undef glIndexsv -#undef glIndexub -#undef glIndexubv -#undef glInitNames -#undef glInsertComponentEXT -#undef glInterleavedArrays -#undef glIsAsyncMarkerSGIX -#undef glIsBuffer -#undef glIsBufferARB -#undef glIsEnabled -#undef glIsEnabledIndexedEXT -#undef glIsFenceAPPLE -#undef glIsFenceNV -#undef glIsFramebufferEXT -#undef glIsList -#undef glIsObjectBufferATI -#undef glIsOcclusionQueryNV -#undef glIsProgram -#undef glIsProgramARB -#undef glIsProgramNV -#undef glIsQuery -#undef glIsQueryARB -#undef glIsRenderbufferEXT -#undef glIsShader -#undef glIsTexture -#undef glIsTextureEXT -#undef glIsVariantEnabledEXT -#undef glIsVertexArrayAPPLE -#undef glLightEnviEXT -#undef glLightModelf -#undef glLightModelfv -#undef glLightModeli -#undef glLightModeliv -#undef glLightf -#undef glLightfv -#undef glLighti -#undef glLightiv -#undef glLineStipple -#undef glLineWidth -#undef glLinkProgram -#undef glLinkProgramARB -#undef glListBase -#undef glLoadIdentity -#undef glLoadMatrixd -#undef glLoadMatrixf -#undef glLoadName -#undef glLoadProgramNV -#undef glLoadTransposeMatrixd -#undef glLoadTransposeMatrixdARB -#undef glLoadTransposeMatrixf -#undef glLoadTransposeMatrixfARB -#undef glLockArraysEXT -#undef glLogicOp -#undef glMap1d -#undef glMap1f -#undef glMap2d -#undef glMap2f -#undef glMapBuffer -#undef glMapBufferARB -#undef glMapBufferRange -#undef glMapControlPointsNV -#undef glMapGrid1d -#undef glMapGrid1f -#undef glMapGrid2d -#undef glMapGrid2f -#undef glMapObjectBufferATI -#undef glMapParameterfvNV -#undef glMapParameterivNV -#undef glMaterialf -#undef glMaterialfv -#undef glMateriali -#undef glMaterialiv -#undef glMatrixIndexPointerARB -#undef glMatrixIndexubvARB -#undef glMatrixIndexuivARB -#undef glMatrixIndexusvARB -#undef glMatrixMode -#undef glMinmax -#undef glMinmaxEXT -#undef glMultMatrixd -#undef glMultMatrixf -#undef glMultTransposeMatrixd -#undef glMultTransposeMatrixdARB -#undef glMultTransposeMatrixf -#undef glMultTransposeMatrixfARB -#undef glMultiDrawArrays -#undef glMultiDrawArraysEXT -#undef glMultiDrawElementArrayAPPLE -#undef glMultiDrawElements -#undef glMultiDrawElementsEXT -#undef glMultiDrawRangeElementArrayAPPLE -#undef glMultiModeDrawArraysIBM -#undef glMultiModeDrawElementsIBM -#undef glMultiTexCoord1d -#undef glMultiTexCoord1dARB -#undef glMultiTexCoord1dv -#undef glMultiTexCoord1dvARB -#undef glMultiTexCoord1f -#undef glMultiTexCoord1fARB -#undef glMultiTexCoord1fv -#undef glMultiTexCoord1fvARB -#undef glMultiTexCoord1hNV -#undef glMultiTexCoord1hvNV -#undef glMultiTexCoord1i -#undef glMultiTexCoord1iARB -#undef glMultiTexCoord1iv -#undef glMultiTexCoord1ivARB -#undef glMultiTexCoord1s -#undef glMultiTexCoord1sARB -#undef glMultiTexCoord1sv -#undef glMultiTexCoord1svARB -#undef glMultiTexCoord2d -#undef glMultiTexCoord2dARB -#undef glMultiTexCoord2dv -#undef glMultiTexCoord2dvARB -#undef glMultiTexCoord2f -#undef glMultiTexCoord2fARB -#undef glMultiTexCoord2fv -#undef glMultiTexCoord2fvARB -#undef glMultiTexCoord2hNV -#undef glMultiTexCoord2hvNV -#undef glMultiTexCoord2i -#undef glMultiTexCoord2iARB -#undef glMultiTexCoord2iv -#undef glMultiTexCoord2ivARB -#undef glMultiTexCoord2s -#undef glMultiTexCoord2sARB -#undef glMultiTexCoord2sv -#undef glMultiTexCoord2svARB -#undef glMultiTexCoord3d -#undef glMultiTexCoord3dARB -#undef glMultiTexCoord3dv -#undef glMultiTexCoord3dvARB -#undef glMultiTexCoord3f -#undef glMultiTexCoord3fARB -#undef glMultiTexCoord3fv -#undef glMultiTexCoord3fvARB -#undef glMultiTexCoord3hNV -#undef glMultiTexCoord3hvNV -#undef glMultiTexCoord3i -#undef glMultiTexCoord3iARB -#undef glMultiTexCoord3iv -#undef glMultiTexCoord3ivARB -#undef glMultiTexCoord3s -#undef glMultiTexCoord3sARB -#undef glMultiTexCoord3sv -#undef glMultiTexCoord3svARB -#undef glMultiTexCoord4d -#undef glMultiTexCoord4dARB -#undef glMultiTexCoord4dv -#undef glMultiTexCoord4dvARB -#undef glMultiTexCoord4f -#undef glMultiTexCoord4fARB -#undef glMultiTexCoord4fv -#undef glMultiTexCoord4fvARB -#undef glMultiTexCoord4hNV -#undef glMultiTexCoord4hvNV -#undef glMultiTexCoord4i -#undef glMultiTexCoord4iARB -#undef glMultiTexCoord4iv -#undef glMultiTexCoord4ivARB -#undef glMultiTexCoord4s -#undef glMultiTexCoord4sARB -#undef glMultiTexCoord4sv -#undef glMultiTexCoord4svARB -#undef glNewBufferRegionEXT -#undef glNewList -#undef glNewObjectBufferATI -#undef glNormal3b -#undef glNormal3bv -#undef glNormal3d -#undef glNormal3dv -#undef glNormal3f -#undef glNormal3fVertex3fSUN -#undef glNormal3fVertex3fvSUN -#undef glNormal3fv -#undef glNormal3hNV -#undef glNormal3hvNV -#undef glNormal3i -#undef glNormal3iv -#undef glNormal3s -#undef glNormal3sv -#undef glNormalPointer -#undef glNormalPointerEXT -#undef glNormalPointerListIBM -#undef glNormalPointervINTEL -#undef glNormalStream3bATI -#undef glNormalStream3bvATI -#undef glNormalStream3dATI -#undef glNormalStream3dvATI -#undef glNormalStream3fATI -#undef glNormalStream3fvATI -#undef glNormalStream3iATI -#undef glNormalStream3ivATI -#undef glNormalStream3sATI -#undef glNormalStream3svATI -#undef glOrtho -#undef glOrthofOES -#undef glPNTrianglesfATI -#undef glPNTrianglesiATI -#undef glPassTexCoordATI -#undef glPassThrough -#undef glPixelDataRangeNV -#undef glPixelMapfv -#undef glPixelMapuiv -#undef glPixelMapusv -#undef glPixelStoref -#undef glPixelStorei -#undef glPixelTexGenSGIX -#undef glPixelTransferf -#undef glPixelTransferi -#undef glPixelTransformParameterfEXT -#undef glPixelTransformParameterfvEXT -#undef glPixelTransformParameteriEXT -#undef glPixelTransformParameterivEXT -#undef glPixelZoom -#undef glPointParameterf -#undef glPointParameterfARB -#undef glPointParameterfEXT -#undef glPointParameterfv -#undef glPointParameterfvARB -#undef glPointParameterfvEXT -#undef glPointParameteriNV -#undef glPointParameterivNV -#undef glPointSize -#undef glPollAsyncSGIX -#undef glPolygonMode -#undef glPolygonOffset -#undef glPolygonOffsetEXT -#undef glPolygonStipple -#undef glPopAttrib -#undef glPopClientAttrib -#undef glPopMatrix -#undef glPopName -#undef glPrimitiveRestartIndexNV -#undef glPrimitiveRestartNV -#undef glPrioritizeTextures -#undef glPrioritizeTexturesEXT -#undef glProgramBufferParametersIivNV -#undef glProgramBufferParametersIuivNV -#undef glProgramBufferParametersfvNV -#undef glProgramEnvParameter4dARB -#undef glProgramEnvParameter4dvARB -#undef glProgramEnvParameter4fARB -#undef glProgramEnvParameter4fvARB -#undef glProgramEnvParameterI4iNV -#undef glProgramEnvParameterI4ivNV -#undef glProgramEnvParameterI4uiNV -#undef glProgramEnvParameterI4uivNV -#undef glProgramEnvParameters4fvEXT -#undef glProgramEnvParametersI4ivNV -#undef glProgramEnvParametersI4uivNV -#undef glProgramLocalParameter4dARB -#undef glProgramLocalParameter4dvARB -#undef glProgramLocalParameter4fARB -#undef glProgramLocalParameter4fvARB -#undef glProgramLocalParameterI4iNV -#undef glProgramLocalParameterI4ivNV -#undef glProgramLocalParameterI4uiNV -#undef glProgramLocalParameterI4uivNV -#undef glProgramLocalParameters4fvEXT -#undef glProgramLocalParametersI4ivNV -#undef glProgramLocalParametersI4uivNV -#undef glProgramNamedParameter4dNV -#undef glProgramNamedParameter4dvNV -#undef glProgramNamedParameter4fNV -#undef glProgramNamedParameter4fvNV -#undef glProgramParameter4dNV -#undef glProgramParameter4dvNV -#undef glProgramParameter4fNV -#undef glProgramParameter4fvNV -#undef glProgramParameteriEXT -#undef glProgramParameters4dvNV -#undef glProgramParameters4fvNV -#undef glProgramStringARB -#undef glProgramVertexLimitNV -#undef glPushAttrib -#undef glPushClientAttrib -#undef glPushMatrix -#undef glPushName -#undef glRasterPos2d -#undef glRasterPos2dv -#undef glRasterPos2f -#undef glRasterPos2fv -#undef glRasterPos2i -#undef glRasterPos2iv -#undef glRasterPos2s -#undef glRasterPos2sv -#undef glRasterPos3d -#undef glRasterPos3dv -#undef glRasterPos3f -#undef glRasterPos3fv -#undef glRasterPos3i -#undef glRasterPos3iv -#undef glRasterPos3s -#undef glRasterPos3sv -#undef glRasterPos4d -#undef glRasterPos4dv -#undef glRasterPos4f -#undef glRasterPos4fv -#undef glRasterPos4i -#undef glRasterPos4iv -#undef glRasterPos4s -#undef glRasterPos4sv -#undef glReadBuffer -#undef glReadBufferRegionEXT -#undef glReadPixels -#undef glReadVideoPixelsSUN -#undef glRectd -#undef glRectdv -#undef glRectf -#undef glRectfv -#undef glRecti -#undef glRectiv -#undef glRects -#undef glRectsv -#undef glReferencePlaneSGIX -#undef glRenderMode -#undef glRenderbufferStorageEXT -#undef glRenderbufferStorageMultisampleCoverageNV -#undef glRenderbufferStorageMultisampleEXT -#undef glReplacementCodePointerSUN -#undef glReplacementCodeubSUN -#undef glReplacementCodeubvSUN -#undef glReplacementCodeuiColor3fVertex3fSUN -#undef glReplacementCodeuiColor3fVertex3fvSUN -#undef glReplacementCodeuiColor4fNormal3fVertex3fSUN -#undef glReplacementCodeuiColor4fNormal3fVertex3fvSUN -#undef glReplacementCodeuiColor4ubVertex3fSUN -#undef glReplacementCodeuiColor4ubVertex3fvSUN -#undef glReplacementCodeuiNormal3fVertex3fSUN -#undef glReplacementCodeuiNormal3fVertex3fvSUN -#undef glReplacementCodeuiSUN -#undef glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN -#undef glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN -#undef glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN -#undef glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN -#undef glReplacementCodeuiTexCoord2fVertex3fSUN -#undef glReplacementCodeuiTexCoord2fVertex3fvSUN -#undef glReplacementCodeuiVertex3fSUN -#undef glReplacementCodeuiVertex3fvSUN -#undef glReplacementCodeuivSUN -#undef glReplacementCodeusSUN -#undef glReplacementCodeusvSUN -#undef glRequestResidentProgramsNV -#undef glResetHistogram -#undef glResetHistogramEXT -#undef glResetMinmax -#undef glResetMinmaxEXT -#undef glResizeBuffersMESA -#undef glRotated -#undef glRotatef -#undef glSampleCoverage -#undef glSampleCoverageARB -#undef glSampleMapATI -#undef glSampleMaskEXT -#undef glSampleMaskSGIS -#undef glSamplePatternEXT -#undef glSamplePatternSGIS -#undef glScaled -#undef glScalef -#undef glScissor -#undef glSecondaryColor3b -#undef glSecondaryColor3bEXT -#undef glSecondaryColor3bv -#undef glSecondaryColor3bvEXT -#undef glSecondaryColor3d -#undef glSecondaryColor3dEXT -#undef glSecondaryColor3dv -#undef glSecondaryColor3dvEXT -#undef glSecondaryColor3f -#undef glSecondaryColor3fEXT -#undef glSecondaryColor3fv -#undef glSecondaryColor3fvEXT -#undef glSecondaryColor3hNV -#undef glSecondaryColor3hvNV -#undef glSecondaryColor3i -#undef glSecondaryColor3iEXT -#undef glSecondaryColor3iv -#undef glSecondaryColor3ivEXT -#undef glSecondaryColor3s -#undef glSecondaryColor3sEXT -#undef glSecondaryColor3sv -#undef glSecondaryColor3svEXT -#undef glSecondaryColor3ub -#undef glSecondaryColor3ubEXT -#undef glSecondaryColor3ubv -#undef glSecondaryColor3ubvEXT -#undef glSecondaryColor3ui -#undef glSecondaryColor3uiEXT -#undef glSecondaryColor3uiv -#undef glSecondaryColor3uivEXT -#undef glSecondaryColor3us -#undef glSecondaryColor3usEXT -#undef glSecondaryColor3usv -#undef glSecondaryColor3usvEXT -#undef glSecondaryColorPointer -#undef glSecondaryColorPointerEXT -#undef glSecondaryColorPointerListIBM -#undef glSelectBuffer -#undef glSeparableFilter2D -#undef glSeparableFilter2DEXT -#undef glSetFenceAPPLE -#undef glSetFenceNV -#undef glSetFragmentShaderConstantATI -#undef glSetInvariantEXT -#undef glSetLocalConstantEXT -#undef glShadeModel -#undef glShaderOp1EXT -#undef glShaderOp2EXT -#undef glShaderOp3EXT -#undef glShaderSource -#undef glShaderSourceARB -#undef glSharpenTexFuncSGIS -#undef glSpriteParameterfSGIX -#undef glSpriteParameterfvSGIX -#undef glSpriteParameteriSGIX -#undef glSpriteParameterivSGIX -#undef glStencilFunc -#undef glStencilFuncSeparate -#undef glStencilFuncSeparateATI -#undef glStencilMask -#undef glStencilMaskSeparate -#undef glStencilOp -#undef glStencilOpSeparate -#undef glStencilOpSeparateATI -#undef glStringMarkerGREMEDY -#undef glSwizzleEXT -#undef glTagSampleBufferSGIX -#undef glTangentPointerEXT -#undef glTbufferMask3DFX -#undef glTestFenceAPPLE -#undef glTestFenceNV -#undef glTestObjectAPPLE -#undef glTexBufferEXT -#undef glTexBumpParameterfvATI -#undef glTexBumpParameterivATI -#undef glTexCoord1d -#undef glTexCoord1dv -#undef glTexCoord1f -#undef glTexCoord1fv -#undef glTexCoord1hNV -#undef glTexCoord1hvNV -#undef glTexCoord1i -#undef glTexCoord1iv -#undef glTexCoord1s -#undef glTexCoord1sv -#undef glTexCoord2d -#undef glTexCoord2dv -#undef glTexCoord2f -#undef glTexCoord2fColor3fVertex3fSUN -#undef glTexCoord2fColor3fVertex3fvSUN -#undef glTexCoord2fColor4fNormal3fVertex3fSUN -#undef glTexCoord2fColor4fNormal3fVertex3fvSUN -#undef glTexCoord2fColor4ubVertex3fSUN -#undef glTexCoord2fColor4ubVertex3fvSUN -#undef glTexCoord2fNormal3fVertex3fSUN -#undef glTexCoord2fNormal3fVertex3fvSUN -#undef glTexCoord2fVertex3fSUN -#undef glTexCoord2fVertex3fvSUN -#undef glTexCoord2fv -#undef glTexCoord2hNV -#undef glTexCoord2hvNV -#undef glTexCoord2i -#undef glTexCoord2iv -#undef glTexCoord2s -#undef glTexCoord2sv -#undef glTexCoord3d -#undef glTexCoord3dv -#undef glTexCoord3f -#undef glTexCoord3fv -#undef glTexCoord3hNV -#undef glTexCoord3hvNV -#undef glTexCoord3i -#undef glTexCoord3iv -#undef glTexCoord3s -#undef glTexCoord3sv -#undef glTexCoord4d -#undef glTexCoord4dv -#undef glTexCoord4f -#undef glTexCoord4fColor4fNormal3fVertex4fSUN -#undef glTexCoord4fColor4fNormal3fVertex4fvSUN -#undef glTexCoord4fVertex4fSUN -#undef glTexCoord4fVertex4fvSUN -#undef glTexCoord4fv -#undef glTexCoord4hNV -#undef glTexCoord4hvNV -#undef glTexCoord4i -#undef glTexCoord4iv -#undef glTexCoord4s -#undef glTexCoord4sv -#undef glTexCoordPointer -#undef glTexCoordPointerEXT -#undef glTexCoordPointerListIBM -#undef glTexCoordPointervINTEL -#undef glTexEnvf -#undef glTexEnvfv -#undef glTexEnvi -#undef glTexEnviv -#undef glTexFilterFuncSGIS -#undef glTexGend -#undef glTexGendv -#undef glTexGenf -#undef glTexGenfv -#undef glTexGeni -#undef glTexGeniv -#undef glTexImage1D -#undef glTexImage2D -#undef glTexImage3D -#undef glTexImage3DEXT -#undef glTexImage4DSGIS -#undef glTexParameterIivEXT -#undef glTexParameterIuivEXT -#undef glTexParameterf -#undef glTexParameterfv -#undef glTexParameteri -#undef glTexParameteriv -#undef glTexScissorFuncINTEL -#undef glTexScissorINTEL -#undef glTexSubImage1D -#undef glTexSubImage1DEXT -#undef glTexSubImage2D -#undef glTexSubImage2DEXT -#undef glTexSubImage3D -#undef glTexSubImage3DEXT -#undef glTexSubImage4DSGIS -#undef glTextureFogSGIX -#undef glTextureLightEXT -#undef glTextureMaterialEXT -#undef glTextureNormalEXT -#undef glTextureRangeAPPLE -#undef glTrackMatrixNV -#undef glTransformFeedbackAttribsNV -#undef glTransformFeedbackVaryingsNV -#undef glTranslated -#undef glTranslatef -#undef glUniform1f -#undef glUniform1fARB -#undef glUniform1fv -#undef glUniform1fvARB -#undef glUniform1i -#undef glUniform1iARB -#undef glUniform1iv -#undef glUniform1ivARB -#undef glUniform1uiEXT -#undef glUniform1uiv -#undef glUniform1uivEXT -#undef glUniform2f -#undef glUniform2fARB -#undef glUniform2fv -#undef glUniform2fvARB -#undef glUniform2i -#undef glUniform2iARB -#undef glUniform2iv -#undef glUniform2ivARB -#undef glUniform2uiEXT -#undef glUniform2uiv -#undef glUniform2uivEXT -#undef glUniform3f -#undef glUniform3fARB -#undef glUniform3fv -#undef glUniform3fvARB -#undef glUniform3i -#undef glUniform3iARB -#undef glUniform3iv -#undef glUniform3ivARB -#undef glUniform3uiEXT -#undef glUniform3uiv -#undef glUniform3uivEXT -#undef glUniform4f -#undef glUniform4fARB -#undef glUniform4fv -#undef glUniform4fvARB -#undef glUniform4i -#undef glUniform4iARB -#undef glUniform4iv -#undef glUniform4ivARB -#undef glUniform4uiEXT -#undef glUniform4uiv -#undef glUniform4uivEXT -#undef glUniformBufferEXT -#undef glUniformMatrix2fv -#undef glUniformMatrix2fvARB -#undef glUniformMatrix2x3fv -#undef glUniformMatrix2x4fv -#undef glUniformMatrix3fv -#undef glUniformMatrix3fvARB -#undef glUniformMatrix3x2fv -#undef glUniformMatrix3x4fv -#undef glUniformMatrix4fv -#undef glUniformMatrix4fvARB -#undef glUniformMatrix4x2fv -#undef glUniformMatrix4x3fv -#undef glUnlockArraysEXT -#undef glUnmapBuffer -#undef glUnmapBufferARB -#undef glUnmapObjectBufferATI -#undef glUpdateObjectBufferATI -#undef glUseProgram -#undef glUseProgramObjectARB -#undef glValidateProgram -#undef glValidateProgramARB -#undef glVariantArrayObjectATI -#undef glVariantPointerEXT -#undef glVariantbvEXT -#undef glVariantdvEXT -#undef glVariantfvEXT -#undef glVariantivEXT -#undef glVariantsvEXT -#undef glVariantubvEXT -#undef glVariantuivEXT -#undef glVariantusvEXT -#undef glVertex2d -#undef glVertex2dv -#undef glVertex2f -#undef glVertex2fv -#undef glVertex2hNV -#undef glVertex2hvNV -#undef glVertex2i -#undef glVertex2iv -#undef glVertex2s -#undef glVertex2sv -#undef glVertex3d -#undef glVertex3dv -#undef glVertex3f -#undef glVertex3fv -#undef glVertex3hNV -#undef glVertex3hvNV -#undef glVertex3i -#undef glVertex3iv -#undef glVertex3s -#undef glVertex3sv -#undef glVertex4d -#undef glVertex4dv -#undef glVertex4f -#undef glVertex4fv -#undef glVertex4hNV -#undef glVertex4hvNV -#undef glVertex4i -#undef glVertex4iv -#undef glVertex4s -#undef glVertex4sv -#undef glVertexArrayParameteriAPPLE -#undef glVertexArrayRangeAPPLE -#undef glVertexArrayRangeNV -#undef glVertexAttrib1d -#undef glVertexAttrib1dARB -#undef glVertexAttrib1dNV -#undef glVertexAttrib1dv -#undef glVertexAttrib1dvARB -#undef glVertexAttrib1dvNV -#undef glVertexAttrib1f -#undef glVertexAttrib1fARB -#undef glVertexAttrib1fNV -#undef glVertexAttrib1fv -#undef glVertexAttrib1fvARB -#undef glVertexAttrib1fvNV -#undef glVertexAttrib1hNV -#undef glVertexAttrib1hvNV -#undef glVertexAttrib1s -#undef glVertexAttrib1sARB -#undef glVertexAttrib1sNV -#undef glVertexAttrib1sv -#undef glVertexAttrib1svARB -#undef glVertexAttrib1svNV -#undef glVertexAttrib2d -#undef glVertexAttrib2dARB -#undef glVertexAttrib2dNV -#undef glVertexAttrib2dv -#undef glVertexAttrib2dvARB -#undef glVertexAttrib2dvNV -#undef glVertexAttrib2f -#undef glVertexAttrib2fARB -#undef glVertexAttrib2fNV -#undef glVertexAttrib2fv -#undef glVertexAttrib2fvARB -#undef glVertexAttrib2fvNV -#undef glVertexAttrib2hNV -#undef glVertexAttrib2hvNV -#undef glVertexAttrib2s -#undef glVertexAttrib2sARB -#undef glVertexAttrib2sNV -#undef glVertexAttrib2sv -#undef glVertexAttrib2svARB -#undef glVertexAttrib2svNV -#undef glVertexAttrib3d -#undef glVertexAttrib3dARB -#undef glVertexAttrib3dNV -#undef glVertexAttrib3dv -#undef glVertexAttrib3dvARB -#undef glVertexAttrib3dvNV -#undef glVertexAttrib3f -#undef glVertexAttrib3fARB -#undef glVertexAttrib3fNV -#undef glVertexAttrib3fv -#undef glVertexAttrib3fvARB -#undef glVertexAttrib3fvNV -#undef glVertexAttrib3hNV -#undef glVertexAttrib3hvNV -#undef glVertexAttrib3s -#undef glVertexAttrib3sARB -#undef glVertexAttrib3sNV -#undef glVertexAttrib3sv -#undef glVertexAttrib3svARB -#undef glVertexAttrib3svNV -#undef glVertexAttrib4Nbv -#undef glVertexAttrib4NbvARB -#undef glVertexAttrib4Niv -#undef glVertexAttrib4NivARB -#undef glVertexAttrib4Nsv -#undef glVertexAttrib4NsvARB -#undef glVertexAttrib4Nub -#undef glVertexAttrib4NubARB -#undef glVertexAttrib4Nubv -#undef glVertexAttrib4NubvARB -#undef glVertexAttrib4Nuiv -#undef glVertexAttrib4NuivARB -#undef glVertexAttrib4Nusv -#undef glVertexAttrib4NusvARB -#undef glVertexAttrib4bv -#undef glVertexAttrib4bvARB -#undef glVertexAttrib4d -#undef glVertexAttrib4dARB -#undef glVertexAttrib4dNV -#undef glVertexAttrib4dv -#undef glVertexAttrib4dvARB -#undef glVertexAttrib4dvNV -#undef glVertexAttrib4f -#undef glVertexAttrib4fARB -#undef glVertexAttrib4fNV -#undef glVertexAttrib4fv -#undef glVertexAttrib4fvARB -#undef glVertexAttrib4fvNV -#undef glVertexAttrib4hNV -#undef glVertexAttrib4hvNV -#undef glVertexAttrib4iv -#undef glVertexAttrib4ivARB -#undef glVertexAttrib4s -#undef glVertexAttrib4sARB -#undef glVertexAttrib4sNV -#undef glVertexAttrib4sv -#undef glVertexAttrib4svARB -#undef glVertexAttrib4svNV -#undef glVertexAttrib4ubNV -#undef glVertexAttrib4ubv -#undef glVertexAttrib4ubvARB -#undef glVertexAttrib4ubvNV -#undef glVertexAttrib4uiv -#undef glVertexAttrib4uivARB -#undef glVertexAttrib4usv -#undef glVertexAttrib4usvARB -#undef glVertexAttribArrayObjectATI -#undef glVertexAttribI1iEXT -#undef glVertexAttribI1ivEXT -#undef glVertexAttribI1uiEXT -#undef glVertexAttribI1uivEXT -#undef glVertexAttribI2iEXT -#undef glVertexAttribI2ivEXT -#undef glVertexAttribI2uiEXT -#undef glVertexAttribI2uivEXT -#undef glVertexAttribI3iEXT -#undef glVertexAttribI3ivEXT -#undef glVertexAttribI3uiEXT -#undef glVertexAttribI3uivEXT -#undef glVertexAttribI4bvEXT -#undef glVertexAttribI4iEXT -#undef glVertexAttribI4ivEXT -#undef glVertexAttribI4svEXT -#undef glVertexAttribI4ubvEXT -#undef glVertexAttribI4uiEXT -#undef glVertexAttribI4uivEXT -#undef glVertexAttribI4usvEXT -#undef glVertexAttribIPointerEXT -#undef glVertexAttribPointer -#undef glVertexAttribPointerARB -#undef glVertexAttribPointerNV -#undef glVertexAttribs1dvNV -#undef glVertexAttribs1fvNV -#undef glVertexAttribs1hvNV -#undef glVertexAttribs1svNV -#undef glVertexAttribs2dvNV -#undef glVertexAttribs2fvNV -#undef glVertexAttribs2hvNV -#undef glVertexAttribs2svNV -#undef glVertexAttribs3dvNV -#undef glVertexAttribs3fvNV -#undef glVertexAttribs3hvNV -#undef glVertexAttribs3svNV -#undef glVertexAttribs4dvNV -#undef glVertexAttribs4fvNV -#undef glVertexAttribs4hvNV -#undef glVertexAttribs4svNV -#undef glVertexAttribs4ubvNV -#undef glVertexBlendARB -#undef glVertexBlendEnvfATI -#undef glVertexBlendEnviATI -#undef glVertexPointer -#undef glVertexPointerEXT -#undef glVertexPointerListIBM -#undef glVertexPointervINTEL -#undef glVertexStream2dATI -#undef glVertexStream2dvATI -#undef glVertexStream2fATI -#undef glVertexStream2fvATI -#undef glVertexStream2iATI -#undef glVertexStream2ivATI -#undef glVertexStream2sATI -#undef glVertexStream2svATI -#undef glVertexStream3dATI -#undef glVertexStream3dvATI -#undef glVertexStream3fATI -#undef glVertexStream3fvATI -#undef glVertexStream3iATI -#undef glVertexStream3ivATI -#undef glVertexStream3sATI -#undef glVertexStream3svATI -#undef glVertexStream4dATI -#undef glVertexStream4dvATI -#undef glVertexStream4fATI -#undef glVertexStream4fvATI -#undef glVertexStream4iATI -#undef glVertexStream4ivATI -#undef glVertexStream4sATI -#undef glVertexStream4svATI -#undef glVertexWeightPointerEXT -#undef glVertexWeightfEXT -#undef glVertexWeightfvEXT -#undef glVertexWeighthNV -#undef glVertexWeighthvNV -#undef glViewport -#undef glWeightPointerARB -#undef glWeightbvARB -#undef glWeightdvARB -#undef glWeightfvARB -#undef glWeightivARB -#undef glWeightsvARB -#undef glWeightubvARB -#undef glWeightuivARB -#undef glWeightusvARB -#undef glWindowPos2d -#undef glWindowPos2dARB -#undef glWindowPos2dMESA -#undef glWindowPos2dv -#undef glWindowPos2dvARB -#undef glWindowPos2dvMESA -#undef glWindowPos2f -#undef glWindowPos2fARB -#undef glWindowPos2fMESA -#undef glWindowPos2fv -#undef glWindowPos2fvARB -#undef glWindowPos2fvMESA -#undef glWindowPos2i -#undef glWindowPos2iARB -#undef glWindowPos2iMESA -#undef glWindowPos2iv -#undef glWindowPos2ivARB -#undef glWindowPos2ivMESA -#undef glWindowPos2s -#undef glWindowPos2sARB -#undef glWindowPos2sMESA -#undef glWindowPos2sv -#undef glWindowPos2svARB -#undef glWindowPos2svMESA -#undef glWindowPos3d -#undef glWindowPos3dARB -#undef glWindowPos3dMESA -#undef glWindowPos3dv -#undef glWindowPos3dvARB -#undef glWindowPos3dvMESA -#undef glWindowPos3f -#undef glWindowPos3fARB -#undef glWindowPos3fMESA -#undef glWindowPos3fv -#undef glWindowPos3fvARB -#undef glWindowPos3fvMESA -#undef glWindowPos3i -#undef glWindowPos3iARB -#undef glWindowPos3iMESA -#undef glWindowPos3iv -#undef glWindowPos3ivARB -#undef glWindowPos3ivMESA -#undef glWindowPos3s -#undef glWindowPos3sARB -#undef glWindowPos3sMESA -#undef glWindowPos3sv -#undef glWindowPos3svARB -#undef glWindowPos3svMESA -#undef glWindowPos4dMESA -#undef glWindowPos4dvMESA -#undef glWindowPos4fMESA -#undef glWindowPos4fvMESA -#undef glWindowPos4iMESA -#undef glWindowPos4ivMESA -#undef glWindowPos4sMESA -#undef glWindowPos4svMESA -#undef glWriteMaskEXT - -#undef gluBeginCurve -#undef gluBeginPolygon -#undef gluBeginSurface -#undef gluBeginTrim -#undef gluBuild1DMipmaps -#undef gluBuild2DMipmaps -#undef gluCylinder -#undef gluDeleteNurbsRenderer -#undef gluDeleteQuadric -#undef gluDeleteTess -#undef gluDisk -#undef gluEndCurve -#undef gluEndPolygon -#undef gluEndSurface -#undef gluEndTrim -#undef gluErrorString -#undef gluErrorStringWIN -#undef gluErrorUnicodeStringEXT -#undef gluGetNurbsProperty -#undef gluGetString -#undef gluGetTessProperty -#undef gluLoadSamplingMatrices -#undef gluLookAt -#undef gluNewNurbsRenderer -#undef gluNewQuadric -#undef gluNewTess -#undef gluNextContour -#undef gluNurbsCallback -#undef gluNurbsCurve -#undef gluNurbsProperty -#undef gluNurbsSurface -#undef gluOrtho2D -#undef gluPartialDisk -#undef gluPerspective -#undef gluPickMatrix -#undef gluProject -#undef gluPwlCurve -#undef gluQuadricCallback -#undef gluQuadricDrawStyle -#undef gluQuadricNormals -#undef gluQuadricOrientation -#undef gluQuadricTexture -#undef gluScaleImage -#undef gluSphere -#undef gluTessBeginContour -#undef gluTessBeginPolygon -#undef gluTessCallback -#undef gluTessEndContour -#undef gluTessEndPolygon -#undef gluTessNormal -#undef gluTessProperty -#undef gluTessVertex -#undef gluUnProject - - -/////////////////////////////////////////////////////////////////////////////////////// -// Definitions below -/////////////////////////////////////////////////////////////////////////////////////// - - -#define glAccum GML_FUNCTION_NOT_IMPLEMENTED -#define glActiveStencilFaceEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glActiveTexture GML_FUNCTION_NOT_IMPLEMENTED -#define glActiveTextureARB GML_FUNCTION_NOT_IMPLEMENTED -#define glActiveVaryingNV GML_FUNCTION_NOT_IMPLEMENTED -#define glAddSwapHintRectWIN GML_FUNCTION_NOT_IMPLEMENTED -#define glAlphaFragmentOp1ATI GML_FUNCTION_NOT_IMPLEMENTED -#define glAlphaFragmentOp2ATI GML_FUNCTION_NOT_IMPLEMENTED -#define glAlphaFragmentOp3ATI GML_FUNCTION_NOT_IMPLEMENTED -#define glAlphaFunc GML_FUNCTION_NOT_IMPLEMENTED -#define glApplyTextureEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glAreProgramsResidentNV GML_FUNCTION_NOT_IMPLEMENTED -#define glAreTexturesResident GML_FUNCTION_NOT_IMPLEMENTED -#define glAreTexturesResidentEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glArrayElement GML_FUNCTION_NOT_IMPLEMENTED -#define glArrayElementEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glArrayObjectATI GML_FUNCTION_NOT_IMPLEMENTED -#define glAsyncMarkerSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glAttachObjectARB GML_FUNCTION_NOT_IMPLEMENTED -#define glAttachShader GML_FUNCTION_NOT_IMPLEMENTED -#define glBegin GML_FUNCTION_NOT_IMPLEMENTED -#define glBeginFragmentShaderATI GML_FUNCTION_NOT_IMPLEMENTED -#define glBeginOcclusionQueryNV GML_FUNCTION_NOT_IMPLEMENTED -#define glBeginQuery GML_FUNCTION_NOT_IMPLEMENTED -#define glBeginQueryARB GML_FUNCTION_NOT_IMPLEMENTED -#define glBeginSceneEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glBeginTransformFeedbackNV GML_FUNCTION_NOT_IMPLEMENTED -#define glBeginVertexShaderEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glBindAttribLocation GML_FUNCTION_NOT_IMPLEMENTED -#define glBindAttribLocationARB GML_FUNCTION_NOT_IMPLEMENTED -#define glBindBuffer GML_FUNCTION_NOT_IMPLEMENTED -#define glBindBufferARB GML_FUNCTION_NOT_IMPLEMENTED -#define glBindBufferBaseNV GML_FUNCTION_NOT_IMPLEMENTED -#define glBindBufferOffsetNV GML_FUNCTION_NOT_IMPLEMENTED -#define glBindBufferRangeNV GML_FUNCTION_NOT_IMPLEMENTED -#define glBindFragDataLocationEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glBindFragmentShaderATI GML_FUNCTION_NOT_IMPLEMENTED -#define glBindFramebufferEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glBindLightParameterEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glBindMaterialParameterEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glBindParameterEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glBindProgramARB GML_FUNCTION_NOT_IMPLEMENTED -#define glBindProgramNV GML_FUNCTION_NOT_IMPLEMENTED -#define glBindRenderbufferEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glBindTexGenParameterEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glBindTexture GML_FUNCTION_NOT_IMPLEMENTED -#define glBindTextureEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glBindTextureUnitParameterEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glBindVertexArrayAPPLE GML_FUNCTION_NOT_IMPLEMENTED -#define glBindVertexShaderEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glBinormalPointerEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glBitmap GML_FUNCTION_NOT_IMPLEMENTED -#define glBlendColor GML_FUNCTION_NOT_IMPLEMENTED -#define glBlendColorEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glBlendEquation GML_FUNCTION_NOT_IMPLEMENTED -#define glBlendEquationEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glBlendEquationSeparate GML_FUNCTION_NOT_IMPLEMENTED -#define glBlendEquationSeparateEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glBlendFunc GML_FUNCTION_NOT_IMPLEMENTED -#define glBlendFuncSeparate GML_FUNCTION_NOT_IMPLEMENTED -#define glBlendFuncSeparateEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glBlitFramebufferEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glBufferData GML_FUNCTION_NOT_IMPLEMENTED -#define glBufferDataARB GML_FUNCTION_NOT_IMPLEMENTED -#define glBufferRegionEnabledEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glBufferSubData GML_FUNCTION_NOT_IMPLEMENTED -#define glBufferSubDataARB GML_FUNCTION_NOT_IMPLEMENTED -#define glCallList GML_FUNCTION_NOT_IMPLEMENTED -#define glCallLists GML_FUNCTION_NOT_IMPLEMENTED -#define glCheckFramebufferStatusEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glClampColorARB GML_FUNCTION_NOT_IMPLEMENTED -#define glClear GML_FUNCTION_NOT_IMPLEMENTED -#define glClearAccum GML_FUNCTION_NOT_IMPLEMENTED -#define glClearColor GML_FUNCTION_NOT_IMPLEMENTED -#define glClearColorIiEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glClearColorIuiEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glClearDepth GML_FUNCTION_NOT_IMPLEMENTED -#define glClearDepthdNV GML_FUNCTION_NOT_IMPLEMENTED -#define glClearDepthfOES GML_FUNCTION_NOT_IMPLEMENTED -#define glClearIndex GML_FUNCTION_NOT_IMPLEMENTED -#define glClearStencil GML_FUNCTION_NOT_IMPLEMENTED -#define glClientActiveTexture GML_FUNCTION_NOT_IMPLEMENTED -#define glClientActiveTextureARB GML_FUNCTION_NOT_IMPLEMENTED -#define glClientActiveVertexStreamATI GML_FUNCTION_NOT_IMPLEMENTED -#define glClipPlane GML_FUNCTION_NOT_IMPLEMENTED -#define glClipPlanefOES GML_FUNCTION_NOT_IMPLEMENTED -#define glColor3b GML_FUNCTION_NOT_IMPLEMENTED -#define glColor3bv GML_FUNCTION_NOT_IMPLEMENTED -#define glColor3d GML_FUNCTION_NOT_IMPLEMENTED -#define glColor3dv GML_FUNCTION_NOT_IMPLEMENTED -#define glColor3f GML_FUNCTION_NOT_IMPLEMENTED -#define glColor3fVertex3fSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glColor3fVertex3fvSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glColor3fv GML_FUNCTION_NOT_IMPLEMENTED -#define glColor3hNV GML_FUNCTION_NOT_IMPLEMENTED -#define glColor3hvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glColor3i GML_FUNCTION_NOT_IMPLEMENTED -#define glColor3iv GML_FUNCTION_NOT_IMPLEMENTED -#define glColor3s GML_FUNCTION_NOT_IMPLEMENTED -#define glColor3sv GML_FUNCTION_NOT_IMPLEMENTED -#define glColor3ub GML_FUNCTION_NOT_IMPLEMENTED -#define glColor3ubv GML_FUNCTION_NOT_IMPLEMENTED -#define glColor3ui GML_FUNCTION_NOT_IMPLEMENTED -#define glColor3uiv GML_FUNCTION_NOT_IMPLEMENTED -#define glColor3us GML_FUNCTION_NOT_IMPLEMENTED -#define glColor3usv GML_FUNCTION_NOT_IMPLEMENTED -#define glColor4b GML_FUNCTION_NOT_IMPLEMENTED -#define glColor4bv GML_FUNCTION_NOT_IMPLEMENTED -#define glColor4d GML_FUNCTION_NOT_IMPLEMENTED -#define glColor4dv GML_FUNCTION_NOT_IMPLEMENTED -#define glColor4f GML_FUNCTION_NOT_IMPLEMENTED -#define glColor4fNormal3fVertex3fSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glColor4fNormal3fVertex3fvSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glColor4fv GML_FUNCTION_NOT_IMPLEMENTED -#define glColor4hNV GML_FUNCTION_NOT_IMPLEMENTED -#define glColor4hvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glColor4i GML_FUNCTION_NOT_IMPLEMENTED -#define glColor4iv GML_FUNCTION_NOT_IMPLEMENTED -#define glColor4s GML_FUNCTION_NOT_IMPLEMENTED -#define glColor4sv GML_FUNCTION_NOT_IMPLEMENTED -#define glColor4ub GML_FUNCTION_NOT_IMPLEMENTED -#define glColor4ubVertex2fSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glColor4ubVertex2fvSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glColor4ubVertex3fSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glColor4ubVertex3fvSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glColor4ubv GML_FUNCTION_NOT_IMPLEMENTED -#define glColor4ui GML_FUNCTION_NOT_IMPLEMENTED -#define glColor4uiv GML_FUNCTION_NOT_IMPLEMENTED -#define glColor4us GML_FUNCTION_NOT_IMPLEMENTED -#define glColor4usv GML_FUNCTION_NOT_IMPLEMENTED -#define glColorFragmentOp1ATI GML_FUNCTION_NOT_IMPLEMENTED -#define glColorFragmentOp2ATI GML_FUNCTION_NOT_IMPLEMENTED -#define glColorFragmentOp3ATI GML_FUNCTION_NOT_IMPLEMENTED -#define glColorMask GML_FUNCTION_NOT_IMPLEMENTED -#define glColorMaskIndexedEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glColorMaterial GML_FUNCTION_NOT_IMPLEMENTED -#define glColorPointer GML_FUNCTION_NOT_IMPLEMENTED -#define glColorPointerEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glColorPointerListIBM GML_FUNCTION_NOT_IMPLEMENTED -#define glColorPointervINTEL GML_FUNCTION_NOT_IMPLEMENTED -#define glColorSubTable GML_FUNCTION_NOT_IMPLEMENTED -#define glColorSubTableEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glColorTable GML_FUNCTION_NOT_IMPLEMENTED -#define glColorTableEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glColorTableParameterfv GML_FUNCTION_NOT_IMPLEMENTED -#define glColorTableParameterfvSGI GML_FUNCTION_NOT_IMPLEMENTED -#define glColorTableParameteriv GML_FUNCTION_NOT_IMPLEMENTED -#define glColorTableParameterivSGI GML_FUNCTION_NOT_IMPLEMENTED -#define glColorTableSGI GML_FUNCTION_NOT_IMPLEMENTED -#define glCombinerInputNV GML_FUNCTION_NOT_IMPLEMENTED -#define glCombinerOutputNV GML_FUNCTION_NOT_IMPLEMENTED -#define glCombinerParameterfNV GML_FUNCTION_NOT_IMPLEMENTED -#define glCombinerParameterfvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glCombinerParameteriNV GML_FUNCTION_NOT_IMPLEMENTED -#define glCombinerParameterivNV GML_FUNCTION_NOT_IMPLEMENTED -#define glCombinerStageParameterfvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glCompileShader GML_FUNCTION_NOT_IMPLEMENTED -#define glCompileShaderARB GML_FUNCTION_NOT_IMPLEMENTED -#define glCompressedTexImage1D GML_FUNCTION_NOT_IMPLEMENTED -#define glCompressedTexImage1DARB GML_FUNCTION_NOT_IMPLEMENTED -#define glCompressedTexImage2D GML_FUNCTION_NOT_IMPLEMENTED -#define glCompressedTexImage2DARB GML_FUNCTION_NOT_IMPLEMENTED -#define glCompressedTexImage3D GML_FUNCTION_NOT_IMPLEMENTED -#define glCompressedTexImage3DARB GML_FUNCTION_NOT_IMPLEMENTED -#define glCompressedTexSubImage1D GML_FUNCTION_NOT_IMPLEMENTED -#define glCompressedTexSubImage1DARB GML_FUNCTION_NOT_IMPLEMENTED -#define glCompressedTexSubImage2D GML_FUNCTION_NOT_IMPLEMENTED -#define glCompressedTexSubImage2DARB GML_FUNCTION_NOT_IMPLEMENTED -#define glCompressedTexSubImage3D GML_FUNCTION_NOT_IMPLEMENTED -#define glCompressedTexSubImage3DARB GML_FUNCTION_NOT_IMPLEMENTED -#define glConvolutionFilter1D GML_FUNCTION_NOT_IMPLEMENTED -#define glConvolutionFilter1DEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glConvolutionFilter2D GML_FUNCTION_NOT_IMPLEMENTED -#define glConvolutionFilter2DEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glConvolutionParameterf GML_FUNCTION_NOT_IMPLEMENTED -#define glConvolutionParameterfEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glConvolutionParameterfv GML_FUNCTION_NOT_IMPLEMENTED -#define glConvolutionParameterfvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glConvolutionParameteri GML_FUNCTION_NOT_IMPLEMENTED -#define glConvolutionParameteriEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glConvolutionParameteriv GML_FUNCTION_NOT_IMPLEMENTED -#define glConvolutionParameterivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glCopyColorSubTable GML_FUNCTION_NOT_IMPLEMENTED -#define glCopyColorSubTableEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glCopyColorTable GML_FUNCTION_NOT_IMPLEMENTED -#define glCopyColorTableSGI GML_FUNCTION_NOT_IMPLEMENTED -#define glCopyConvolutionFilter1D GML_FUNCTION_NOT_IMPLEMENTED -#define glCopyConvolutionFilter1DEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glCopyConvolutionFilter2D GML_FUNCTION_NOT_IMPLEMENTED -#define glCopyConvolutionFilter2DEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glCopyPixels GML_FUNCTION_NOT_IMPLEMENTED -#define glCopyTexImage1D GML_FUNCTION_NOT_IMPLEMENTED -#define glCopyTexImage1DEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glCopyTexImage2D GML_FUNCTION_NOT_IMPLEMENTED -#define glCopyTexImage2DEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glCopyTexSubImage1D GML_FUNCTION_NOT_IMPLEMENTED -#define glCopyTexSubImage1DEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glCopyTexSubImage2D GML_FUNCTION_NOT_IMPLEMENTED -#define glCopyTexSubImage2DEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glCopyTexSubImage3D GML_FUNCTION_NOT_IMPLEMENTED -#define glCopyTexSubImage3DEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glCreateProgram GML_FUNCTION_NOT_IMPLEMENTED -#define glCreateProgramObjectARB GML_FUNCTION_NOT_IMPLEMENTED -#define glCreateShader GML_FUNCTION_NOT_IMPLEMENTED -#define glCreateShaderObjectARB GML_FUNCTION_NOT_IMPLEMENTED -#define glCullFace GML_FUNCTION_NOT_IMPLEMENTED -#define glCullParameterdvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glCullParameterfvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glCurrentPaletteMatrixARB GML_FUNCTION_NOT_IMPLEMENTED -#define glDeleteAsyncMarkersSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glDeleteBufferRegionEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glDeleteBuffers GML_FUNCTION_NOT_IMPLEMENTED -#define glDeleteBuffersARB GML_FUNCTION_NOT_IMPLEMENTED -#define glDeleteFencesAPPLE GML_FUNCTION_NOT_IMPLEMENTED -#define glDeleteFencesNV GML_FUNCTION_NOT_IMPLEMENTED -#define glDeleteFragmentShaderATI GML_FUNCTION_NOT_IMPLEMENTED -#define glDeleteFramebuffersEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glDeleteLists GML_FUNCTION_NOT_IMPLEMENTED -#define glDeleteObjectARB GML_FUNCTION_NOT_IMPLEMENTED -#define glDeleteOcclusionQueriesNV GML_FUNCTION_NOT_IMPLEMENTED -#define glDeleteProgram GML_FUNCTION_NOT_IMPLEMENTED -#define glDeleteProgramsARB GML_FUNCTION_NOT_IMPLEMENTED -#define glDeleteProgramsNV GML_FUNCTION_NOT_IMPLEMENTED -#define glDeleteQueries GML_FUNCTION_NOT_IMPLEMENTED -#define glDeleteQueriesARB GML_FUNCTION_NOT_IMPLEMENTED -#define glDeleteRenderbuffersEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glDeleteShader GML_FUNCTION_NOT_IMPLEMENTED -#define glDeleteTextures GML_FUNCTION_NOT_IMPLEMENTED -#define glDeleteTexturesEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glDeleteVertexArraysAPPLE GML_FUNCTION_NOT_IMPLEMENTED -#define glDeleteVertexShaderEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glDepthBoundsEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glDepthBoundsdNV GML_FUNCTION_NOT_IMPLEMENTED -#define glDepthFunc GML_FUNCTION_NOT_IMPLEMENTED -#define glDepthMask GML_FUNCTION_NOT_IMPLEMENTED -#define glDepthRange GML_FUNCTION_NOT_IMPLEMENTED -#define glDepthRangedNV GML_FUNCTION_NOT_IMPLEMENTED -#define glDepthRangefOES GML_FUNCTION_NOT_IMPLEMENTED -#define glDetachObjectARB GML_FUNCTION_NOT_IMPLEMENTED -#define glDetachShader GML_FUNCTION_NOT_IMPLEMENTED -#define glDetailTexFuncSGIS GML_FUNCTION_NOT_IMPLEMENTED -#define glDisable GML_FUNCTION_NOT_IMPLEMENTED -#define glDisableClientState GML_FUNCTION_NOT_IMPLEMENTED -#define glDisableIndexedEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glDisableVariantClientStateEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glDisableVertexAttribArray GML_FUNCTION_NOT_IMPLEMENTED -#define glDisableVertexAttribArrayARB GML_FUNCTION_NOT_IMPLEMENTED -#define glDrawArrays GML_FUNCTION_NOT_IMPLEMENTED -#define glDrawArraysEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glDrawArraysInstancedEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glDrawBuffer GML_FUNCTION_NOT_IMPLEMENTED -#define glDrawBufferRegionEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glDrawBuffers GML_FUNCTION_NOT_IMPLEMENTED -#define glDrawBuffersARB GML_FUNCTION_NOT_IMPLEMENTED -#define glDrawBuffersATI GML_FUNCTION_NOT_IMPLEMENTED -#define glDrawElementArrayAPPLE GML_FUNCTION_NOT_IMPLEMENTED -#define glDrawElementArrayATI GML_FUNCTION_NOT_IMPLEMENTED -#define glDrawElements GML_FUNCTION_NOT_IMPLEMENTED -#define glDrawElementsInstancedEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glDrawPixels GML_FUNCTION_NOT_IMPLEMENTED -#define glDrawRangeElementArrayAPPLE GML_FUNCTION_NOT_IMPLEMENTED -#define glDrawRangeElementArrayATI GML_FUNCTION_NOT_IMPLEMENTED -#define glDrawRangeElements GML_FUNCTION_NOT_IMPLEMENTED -#define glDrawRangeElementsEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glEdgeFlag GML_FUNCTION_NOT_IMPLEMENTED -#define glEdgeFlagPointer GML_FUNCTION_NOT_IMPLEMENTED -#define glEdgeFlagPointerEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glEdgeFlagPointerListIBM GML_FUNCTION_NOT_IMPLEMENTED -#define glEdgeFlagv GML_FUNCTION_NOT_IMPLEMENTED -#define glElementPointerAPPLE GML_FUNCTION_NOT_IMPLEMENTED -#define glElementPointerATI GML_FUNCTION_NOT_IMPLEMENTED -#define glEnable GML_FUNCTION_NOT_IMPLEMENTED -#define glEnableClientState GML_FUNCTION_NOT_IMPLEMENTED -#define glEnableIndexedEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glEnableVariantClientStateEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glEnableVertexAttribArray GML_FUNCTION_NOT_IMPLEMENTED -#define glEnableVertexAttribArrayARB GML_FUNCTION_NOT_IMPLEMENTED -#define glEnd GML_FUNCTION_NOT_IMPLEMENTED -#define glEndFragmentShaderATI GML_FUNCTION_NOT_IMPLEMENTED -#define glEndList GML_FUNCTION_NOT_IMPLEMENTED -#define glEndOcclusionQueryNV GML_FUNCTION_NOT_IMPLEMENTED -#define glEndQuery GML_FUNCTION_NOT_IMPLEMENTED -#define glEndQueryARB GML_FUNCTION_NOT_IMPLEMENTED -#define glEndSceneEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glEndTransformFeedbackNV GML_FUNCTION_NOT_IMPLEMENTED -#define glEndVertexShaderEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glEvalCoord1d GML_FUNCTION_NOT_IMPLEMENTED -#define glEvalCoord1dv GML_FUNCTION_NOT_IMPLEMENTED -#define glEvalCoord1f GML_FUNCTION_NOT_IMPLEMENTED -#define glEvalCoord1fv GML_FUNCTION_NOT_IMPLEMENTED -#define glEvalCoord2d GML_FUNCTION_NOT_IMPLEMENTED -#define glEvalCoord2dv GML_FUNCTION_NOT_IMPLEMENTED -#define glEvalCoord2f GML_FUNCTION_NOT_IMPLEMENTED -#define glEvalCoord2fv GML_FUNCTION_NOT_IMPLEMENTED -#define glEvalMapsNV GML_FUNCTION_NOT_IMPLEMENTED -#define glEvalMesh1 GML_FUNCTION_NOT_IMPLEMENTED -#define glEvalMesh2 GML_FUNCTION_NOT_IMPLEMENTED -#define glEvalPoint1 GML_FUNCTION_NOT_IMPLEMENTED -#define glEvalPoint2 GML_FUNCTION_NOT_IMPLEMENTED -#define glExecuteProgramNV GML_FUNCTION_NOT_IMPLEMENTED -#define glExtractComponentEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFeedbackBuffer GML_FUNCTION_NOT_IMPLEMENTED -#define glFinalCombinerInputNV GML_FUNCTION_NOT_IMPLEMENTED -#define glFinish GML_FUNCTION_NOT_IMPLEMENTED -#define glFinishAsyncSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glFinishFenceAPPLE GML_FUNCTION_NOT_IMPLEMENTED -#define glFinishFenceNV GML_FUNCTION_NOT_IMPLEMENTED -#define glFinishObjectAPPLE GML_FUNCTION_NOT_IMPLEMENTED -#define glFinishTextureSUNX GML_FUNCTION_NOT_IMPLEMENTED -#define glFlush GML_FUNCTION_NOT_IMPLEMENTED -#define glFlushPixelDataRangeNV GML_FUNCTION_NOT_IMPLEMENTED -#define glFlushRasterSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glFlushVertexArrayRangeAPPLE GML_FUNCTION_NOT_IMPLEMENTED -#define glFlushVertexArrayRangeNV GML_FUNCTION_NOT_IMPLEMENTED -#define glFogCoordPointer GML_FUNCTION_NOT_IMPLEMENTED -#define glFogCoordPointerEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFogCoordPointerListIBM GML_FUNCTION_NOT_IMPLEMENTED -#define glFogCoordd GML_FUNCTION_NOT_IMPLEMENTED -#define glFogCoorddEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFogCoorddv GML_FUNCTION_NOT_IMPLEMENTED -#define glFogCoorddvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFogCoordf GML_FUNCTION_NOT_IMPLEMENTED -#define glFogCoordfEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFogCoordfv GML_FUNCTION_NOT_IMPLEMENTED -#define glFogCoordfvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFogCoordhNV GML_FUNCTION_NOT_IMPLEMENTED -#define glFogCoordhvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glFogFuncSGIS GML_FUNCTION_NOT_IMPLEMENTED -#define glFogf GML_FUNCTION_NOT_IMPLEMENTED -#define glFogfv GML_FUNCTION_NOT_IMPLEMENTED -#define glFogi GML_FUNCTION_NOT_IMPLEMENTED -#define glFogiv GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentColorMaterialEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentColorMaterialSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentLightModelfEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentLightModelfSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentLightModelfvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentLightModelfvSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentLightModeliEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentLightModeliSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentLightModelivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentLightModelivSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentLightfEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentLightfSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentLightfvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentLightfvSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentLightiEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentLightiSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentLightivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentLightivSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentMaterialfEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentMaterialfSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentMaterialfvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentMaterialfvSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentMaterialiEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentMaterialiSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentMaterialivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFragmentMaterialivSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glFrameZoomSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glFramebufferRenderbufferEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFramebufferTexture1DEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFramebufferTexture2DEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFramebufferTexture3DEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFramebufferTextureEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFramebufferTextureFaceEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFramebufferTextureLayerEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glFreeObjectBufferATI GML_FUNCTION_NOT_IMPLEMENTED -#define glFrontFace GML_FUNCTION_NOT_IMPLEMENTED -#define glFrustum GML_FUNCTION_NOT_IMPLEMENTED -#define glFrustumfOES GML_FUNCTION_NOT_IMPLEMENTED -#define glGenAsyncMarkersSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glGenBuffers GML_FUNCTION_NOT_IMPLEMENTED -#define glGenBuffersARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGenFencesAPPLE GML_FUNCTION_NOT_IMPLEMENTED -#define glGenFencesNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGenFragmentShadersATI GML_FUNCTION_NOT_IMPLEMENTED -#define glGenFramebuffersEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGenLists GML_FUNCTION_NOT_IMPLEMENTED -#define glGenOcclusionQueriesNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGenProgramsARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGenProgramsNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGenQueries GML_FUNCTION_NOT_IMPLEMENTED -#define glGenQueriesARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGenRenderbuffersEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGenSymbolsEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGenTextures GML_FUNCTION_NOT_IMPLEMENTED -#define glGenTexturesEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGenVertexArraysAPPLE GML_FUNCTION_NOT_IMPLEMENTED -#define glGenVertexShadersEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGenerateMipmap GML_FUNCTION_NOT_IMPLEMENTED -#define glGenerateMipmapEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetActiveAttrib GML_FUNCTION_NOT_IMPLEMENTED -#define glGetActiveAttribARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetActiveUniform GML_FUNCTION_NOT_IMPLEMENTED -#define glGetActiveUniformARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetActiveVaryingNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetArrayObjectfvATI GML_FUNCTION_NOT_IMPLEMENTED -#define glGetArrayObjectivATI GML_FUNCTION_NOT_IMPLEMENTED -#define glGetAttachedObjectsARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetAttachedShaders GML_FUNCTION_NOT_IMPLEMENTED -#define glGetAttribLocation GML_FUNCTION_NOT_IMPLEMENTED -#define glGetAttribLocationARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetBooleanIndexedvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetBooleanv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetBufferParameteriv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetBufferParameterivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetBufferPointerv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetBufferPointervARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetBufferSubData GML_FUNCTION_NOT_IMPLEMENTED -#define glGetBufferSubDataARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetClipPlane GML_FUNCTION_NOT_IMPLEMENTED -#define glGetClipPlanefOES GML_FUNCTION_NOT_IMPLEMENTED -#define glGetColorTable GML_FUNCTION_NOT_IMPLEMENTED -#define glGetColorTableEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetColorTableParameterfv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetColorTableParameterfvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetColorTableParameterfvSGI GML_FUNCTION_NOT_IMPLEMENTED -#define glGetColorTableParameteriv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetColorTableParameterivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetColorTableParameterivSGI GML_FUNCTION_NOT_IMPLEMENTED -#define glGetColorTableSGI GML_FUNCTION_NOT_IMPLEMENTED -#define glGetCombinerInputParameterfvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetCombinerInputParameterivNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetCombinerOutputParameterfvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetCombinerOutputParameterivNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetCombinerStageParameterfvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetCompressedTexImage GML_FUNCTION_NOT_IMPLEMENTED -#define glGetCompressedTexImageARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetConvolutionFilter GML_FUNCTION_NOT_IMPLEMENTED -#define glGetConvolutionFilterEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetConvolutionParameterfv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetConvolutionParameterfvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetConvolutionParameteriv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetConvolutionParameterivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetDetailTexFuncSGIS GML_FUNCTION_NOT_IMPLEMENTED -#define glGetDoublev GML_FUNCTION_NOT_IMPLEMENTED -#define glGetError GML_FUNCTION_NOT_IMPLEMENTED -#define glGetFenceivNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetFinalCombinerInputParameterfvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetFinalCombinerInputParameterivNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetFloatv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetFogFuncSGIS GML_FUNCTION_NOT_IMPLEMENTED -#define glGetFragDataLocationEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetFragmentLightfvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetFragmentLightfvSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glGetFragmentLightivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetFragmentLightivSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glGetFragmentMaterialfvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetFragmentMaterialfvSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glGetFragmentMaterialivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetFragmentMaterialivSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glGetFramebufferAttachmentParameterivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetHandleARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetHistogram GML_FUNCTION_NOT_IMPLEMENTED -#define glGetHistogramEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetHistogramParameterfv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetHistogramParameterfvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetHistogramParameteriv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetHistogramParameterivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetImageTransformParameterfvHP GML_FUNCTION_NOT_IMPLEMENTED -#define glGetImageTransformParameterivHP GML_FUNCTION_NOT_IMPLEMENTED -#define glGetInfoLogARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetIntegerIndexedvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetIntegerv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetInvariantBooleanvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetInvariantFloatvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetInvariantIntegervEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetLightfv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetLightiv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetLocalConstantBooleanvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetLocalConstantFloatvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetLocalConstantIntegervEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetMapAttribParameterfvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetMapAttribParameterivNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetMapControlPointsNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetMapParameterfvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetMapParameterivNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetMapdv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetMapfv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetMapiv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetMaterialfv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetMaterialiv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetMinmax GML_FUNCTION_NOT_IMPLEMENTED -#define glGetMinmaxEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetMinmaxParameterfv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetMinmaxParameterfvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetMinmaxParameteriv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetMinmaxParameterivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetObjectBufferfvATI GML_FUNCTION_NOT_IMPLEMENTED -#define glGetObjectBufferivATI GML_FUNCTION_NOT_IMPLEMENTED -#define glGetObjectParameterfvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetObjectParameterivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetOcclusionQueryivNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetOcclusionQueryuivNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetPixelMapfv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetPixelMapuiv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetPixelMapusv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetPixelTransformParameterfvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetPixelTransformParameterivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetPointerv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetPointervEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetPolygonStipple GML_FUNCTION_NOT_IMPLEMENTED -#define glGetProgramEnvParameterdvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetProgramEnvParameterfvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetProgramInfoLog GML_FUNCTION_NOT_IMPLEMENTED -#define glGetProgramLocalParameterdvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetProgramLocalParameterfvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetProgramNamedParameterdvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetProgramNamedParameterfvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetProgramParameterdvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetProgramParameterfvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetProgramStringARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetProgramStringNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetProgramiv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetProgramivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetProgramivNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetQueryObjecti64vEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetQueryObjectiv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetQueryObjectivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetQueryObjectui64vEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetQueryObjectuiv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetQueryObjectuivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetQueryiv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetQueryivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetRenderbufferParameterivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetSeparableFilter GML_FUNCTION_NOT_IMPLEMENTED -#define glGetSeparableFilterEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetShaderInfoLog GML_FUNCTION_NOT_IMPLEMENTED -#define glGetShaderSource GML_FUNCTION_NOT_IMPLEMENTED -#define glGetShaderSourceARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetShaderiv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetSharpenTexFuncSGIS GML_FUNCTION_NOT_IMPLEMENTED -#define glGetString GML_FUNCTION_NOT_IMPLEMENTED -#define glGetTexBumpParameterfvATI GML_FUNCTION_NOT_IMPLEMENTED -#define glGetTexBumpParameterivATI GML_FUNCTION_NOT_IMPLEMENTED -#define glGetTexEnvfv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetTexEnviv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetTexFilterFuncSGIS GML_FUNCTION_NOT_IMPLEMENTED -#define glGetTexGendv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetTexGenfv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetTexGeniv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetTexImage GML_FUNCTION_NOT_IMPLEMENTED -#define glGetTexLevelParameterfv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetTexLevelParameteriv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetTexParameterIivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetTexParameterIuivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetTexParameterPointervAPPLE GML_FUNCTION_NOT_IMPLEMENTED -#define glGetTexParameterfv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetTexParameteriv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetTrackMatrixivNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetTransformFeedbackVaryingNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetUniformBufferSizeEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetUniformLocation GML_FUNCTION_NOT_IMPLEMENTED -#define glGetUniformLocationARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetUniformOffsetEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetUniformfvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetUniformfv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetUniformiv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetUniformivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetUniformuiv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetUniformuivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetVariantArrayObjectfvATI GML_FUNCTION_NOT_IMPLEMENTED -#define glGetVariantArrayObjectivATI GML_FUNCTION_NOT_IMPLEMENTED -#define glGetVariantBooleanvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetVariantFloatvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetVariantIntegervEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetVariantPointervEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetVaryingLocationNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetVertexAttribArrayObjectfvATI GML_FUNCTION_NOT_IMPLEMENTED -#define glGetVertexAttribArrayObjectivATI GML_FUNCTION_NOT_IMPLEMENTED -#define glGetVertexAttribIivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetVertexAttribIuivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glGetVertexAttribPointerv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetVertexAttribPointervARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetVertexAttribPointervNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetVertexAttribdv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetVertexAttribdvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetVertexAttribdvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetVertexAttribfv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetVertexAttribfvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetVertexAttribfvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGetVertexAttribiv GML_FUNCTION_NOT_IMPLEMENTED -#define glGetVertexAttribivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glGetVertexAttribivNV GML_FUNCTION_NOT_IMPLEMENTED -#define glGlobalAlphaFactorbSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glGlobalAlphaFactordSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glGlobalAlphaFactorfSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glGlobalAlphaFactoriSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glGlobalAlphaFactorsSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glGlobalAlphaFactorubSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glGlobalAlphaFactoruiSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glGlobalAlphaFactorusSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glHint GML_FUNCTION_NOT_IMPLEMENTED -#define glHistogram GML_FUNCTION_NOT_IMPLEMENTED -#define glHistogramEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glImageTransformParameterfHP GML_FUNCTION_NOT_IMPLEMENTED -#define glImageTransformParameterfvHP GML_FUNCTION_NOT_IMPLEMENTED -#define glImageTransformParameteriHP GML_FUNCTION_NOT_IMPLEMENTED -#define glImageTransformParameterivHP GML_FUNCTION_NOT_IMPLEMENTED -#define glIndexFuncEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glIndexMask GML_FUNCTION_NOT_IMPLEMENTED -#define glIndexMaterialEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glIndexPointer GML_FUNCTION_NOT_IMPLEMENTED -#define glIndexPointerEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glIndexPointerListIBM GML_FUNCTION_NOT_IMPLEMENTED -#define glIndexd GML_FUNCTION_NOT_IMPLEMENTED -#define glIndexdv GML_FUNCTION_NOT_IMPLEMENTED -#define glIndexf GML_FUNCTION_NOT_IMPLEMENTED -#define glIndexfv GML_FUNCTION_NOT_IMPLEMENTED -#define glIndexi GML_FUNCTION_NOT_IMPLEMENTED -#define glIndexiv GML_FUNCTION_NOT_IMPLEMENTED -#define glIndexs GML_FUNCTION_NOT_IMPLEMENTED -#define glIndexsv GML_FUNCTION_NOT_IMPLEMENTED -#define glIndexub GML_FUNCTION_NOT_IMPLEMENTED -#define glIndexubv GML_FUNCTION_NOT_IMPLEMENTED -#define glInitNames GML_FUNCTION_NOT_IMPLEMENTED -#define glInsertComponentEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glInterleavedArrays GML_FUNCTION_NOT_IMPLEMENTED -#define glIsAsyncMarkerSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glIsBuffer GML_FUNCTION_NOT_IMPLEMENTED -#define glIsBufferARB GML_FUNCTION_NOT_IMPLEMENTED -#define glIsEnabled GML_FUNCTION_NOT_IMPLEMENTED -#define glIsEnabledIndexedEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glIsFenceAPPLE GML_FUNCTION_NOT_IMPLEMENTED -#define glIsFenceNV GML_FUNCTION_NOT_IMPLEMENTED -#define glIsFramebufferEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glIsList GML_FUNCTION_NOT_IMPLEMENTED -#define glIsObjectBufferATI GML_FUNCTION_NOT_IMPLEMENTED -#define glIsOcclusionQueryNV GML_FUNCTION_NOT_IMPLEMENTED -#define glIsProgram GML_FUNCTION_NOT_IMPLEMENTED -#define glIsProgramARB GML_FUNCTION_NOT_IMPLEMENTED -#define glIsProgramNV GML_FUNCTION_NOT_IMPLEMENTED -#define glIsQuery GML_FUNCTION_NOT_IMPLEMENTED -#define glIsQueryARB GML_FUNCTION_NOT_IMPLEMENTED -#define glIsRenderbufferEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glIsShader GML_FUNCTION_NOT_IMPLEMENTED -#define glIsTexture GML_FUNCTION_NOT_IMPLEMENTED -#define glIsTextureEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glIsVariantEnabledEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glIsVertexArrayAPPLE GML_FUNCTION_NOT_IMPLEMENTED -#define glLightEnviEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glLightModelf GML_FUNCTION_NOT_IMPLEMENTED -#define glLightModelfv GML_FUNCTION_NOT_IMPLEMENTED -#define glLightModeli GML_FUNCTION_NOT_IMPLEMENTED -#define glLightModeliv GML_FUNCTION_NOT_IMPLEMENTED -#define glLightf GML_FUNCTION_NOT_IMPLEMENTED -#define glLightfv GML_FUNCTION_NOT_IMPLEMENTED -#define glLighti GML_FUNCTION_NOT_IMPLEMENTED -#define glLightiv GML_FUNCTION_NOT_IMPLEMENTED -#define glLineStipple GML_FUNCTION_NOT_IMPLEMENTED -#define glLineWidth GML_FUNCTION_NOT_IMPLEMENTED -#define glLinkProgram GML_FUNCTION_NOT_IMPLEMENTED -#define glLinkProgramARB GML_FUNCTION_NOT_IMPLEMENTED -#define glListBase GML_FUNCTION_NOT_IMPLEMENTED -#define glLoadIdentity GML_FUNCTION_NOT_IMPLEMENTED -#define glLoadMatrixd GML_FUNCTION_NOT_IMPLEMENTED -#define glLoadMatrixf GML_FUNCTION_NOT_IMPLEMENTED -#define glLoadName GML_FUNCTION_NOT_IMPLEMENTED -#define glLoadProgramNV GML_FUNCTION_NOT_IMPLEMENTED -#define glLoadTransposeMatrixd GML_FUNCTION_NOT_IMPLEMENTED -#define glLoadTransposeMatrixdARB GML_FUNCTION_NOT_IMPLEMENTED -#define glLoadTransposeMatrixf GML_FUNCTION_NOT_IMPLEMENTED -#define glLoadTransposeMatrixfARB GML_FUNCTION_NOT_IMPLEMENTED -#define glLockArraysEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glLogicOp GML_FUNCTION_NOT_IMPLEMENTED -#define glMap1d GML_FUNCTION_NOT_IMPLEMENTED -#define glMap1f GML_FUNCTION_NOT_IMPLEMENTED -#define glMap2d GML_FUNCTION_NOT_IMPLEMENTED -#define glMap2f GML_FUNCTION_NOT_IMPLEMENTED -#define glMapBuffer GML_FUNCTION_NOT_IMPLEMENTED -#define glMapBufferARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMapBufferRange GML_FUNCTION_NOT_IMPLEMENTED -#define glMapControlPointsNV GML_FUNCTION_NOT_IMPLEMENTED -#define glMapGrid1d GML_FUNCTION_NOT_IMPLEMENTED -#define glMapGrid1f GML_FUNCTION_NOT_IMPLEMENTED -#define glMapGrid2d GML_FUNCTION_NOT_IMPLEMENTED -#define glMapGrid2f GML_FUNCTION_NOT_IMPLEMENTED -#define glMapObjectBufferATI GML_FUNCTION_NOT_IMPLEMENTED -#define glMapParameterfvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glMapParameterivNV GML_FUNCTION_NOT_IMPLEMENTED -#define glMaterialf GML_FUNCTION_NOT_IMPLEMENTED -#define glMaterialfv GML_FUNCTION_NOT_IMPLEMENTED -#define glMateriali GML_FUNCTION_NOT_IMPLEMENTED -#define glMaterialiv GML_FUNCTION_NOT_IMPLEMENTED -#define glMatrixIndexPointerARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMatrixIndexubvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMatrixIndexuivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMatrixIndexusvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMatrixMode GML_FUNCTION_NOT_IMPLEMENTED -#define glMinmax GML_FUNCTION_NOT_IMPLEMENTED -#define glMinmaxEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glMultMatrixd GML_FUNCTION_NOT_IMPLEMENTED -#define glMultMatrixf GML_FUNCTION_NOT_IMPLEMENTED -#define glMultTransposeMatrixd GML_FUNCTION_NOT_IMPLEMENTED -#define glMultTransposeMatrixdARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultTransposeMatrixf GML_FUNCTION_NOT_IMPLEMENTED -#define glMultTransposeMatrixfARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiDrawArrays GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiDrawArraysEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiDrawElementArrayAPPLE GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiDrawElements GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiDrawElementsEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiDrawRangeElementArrayAPPLE GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiModeDrawArraysIBM GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiModeDrawElementsIBM GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord1d GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord1dARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord1dv GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord1dvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord1f GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord1fARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord1fv GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord1fvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord1hNV GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord1hvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord1i GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord1iARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord1iv GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord1ivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord1s GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord1sARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord1sv GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord1svARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord2d GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord2dARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord2dv GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord2dvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord2f GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord2fARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord2fv GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord2fvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord2hNV GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord2hvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord2i GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord2iARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord2iv GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord2ivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord2s GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord2sARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord2sv GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord2svARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord3d GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord3dARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord3dv GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord3dvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord3f GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord3fARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord3fv GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord3fvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord3hNV GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord3hvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord3i GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord3iARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord3iv GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord3ivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord3s GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord3sARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord3sv GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord3svARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord4d GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord4dARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord4dv GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord4dvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord4f GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord4fARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord4fv GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord4fvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord4hNV GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord4hvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord4i GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord4iARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord4iv GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord4ivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord4s GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord4sARB GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord4sv GML_FUNCTION_NOT_IMPLEMENTED -#define glMultiTexCoord4svARB GML_FUNCTION_NOT_IMPLEMENTED -#define glNewBufferRegionEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glNewList GML_FUNCTION_NOT_IMPLEMENTED -#define glNewObjectBufferATI GML_FUNCTION_NOT_IMPLEMENTED -#define glNormal3b GML_FUNCTION_NOT_IMPLEMENTED -#define glNormal3bv GML_FUNCTION_NOT_IMPLEMENTED -#define glNormal3d GML_FUNCTION_NOT_IMPLEMENTED -#define glNormal3dv GML_FUNCTION_NOT_IMPLEMENTED -#define glNormal3f GML_FUNCTION_NOT_IMPLEMENTED -#define glNormal3fVertex3fSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glNormal3fVertex3fvSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glNormal3fv GML_FUNCTION_NOT_IMPLEMENTED -#define glNormal3hNV GML_FUNCTION_NOT_IMPLEMENTED -#define glNormal3hvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glNormal3i GML_FUNCTION_NOT_IMPLEMENTED -#define glNormal3iv GML_FUNCTION_NOT_IMPLEMENTED -#define glNormal3s GML_FUNCTION_NOT_IMPLEMENTED -#define glNormal3sv GML_FUNCTION_NOT_IMPLEMENTED -#define glNormalPointer GML_FUNCTION_NOT_IMPLEMENTED -#define glNormalPointerEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glNormalPointerListIBM GML_FUNCTION_NOT_IMPLEMENTED -#define glNormalPointervINTEL GML_FUNCTION_NOT_IMPLEMENTED -#define glNormalStream3bATI GML_FUNCTION_NOT_IMPLEMENTED -#define glNormalStream3bvATI GML_FUNCTION_NOT_IMPLEMENTED -#define glNormalStream3dATI GML_FUNCTION_NOT_IMPLEMENTED -#define glNormalStream3dvATI GML_FUNCTION_NOT_IMPLEMENTED -#define glNormalStream3fATI GML_FUNCTION_NOT_IMPLEMENTED -#define glNormalStream3fvATI GML_FUNCTION_NOT_IMPLEMENTED -#define glNormalStream3iATI GML_FUNCTION_NOT_IMPLEMENTED -#define glNormalStream3ivATI GML_FUNCTION_NOT_IMPLEMENTED -#define glNormalStream3sATI GML_FUNCTION_NOT_IMPLEMENTED -#define glNormalStream3svATI GML_FUNCTION_NOT_IMPLEMENTED -#define glOrtho GML_FUNCTION_NOT_IMPLEMENTED -#define glOrthofOES GML_FUNCTION_NOT_IMPLEMENTED -#define glPNTrianglesfATI GML_FUNCTION_NOT_IMPLEMENTED -#define glPNTrianglesiATI GML_FUNCTION_NOT_IMPLEMENTED -#define glPassTexCoordATI GML_FUNCTION_NOT_IMPLEMENTED -#define glPassThrough GML_FUNCTION_NOT_IMPLEMENTED -#define glPixelDataRangeNV GML_FUNCTION_NOT_IMPLEMENTED -#define glPixelMapfv GML_FUNCTION_NOT_IMPLEMENTED -#define glPixelMapuiv GML_FUNCTION_NOT_IMPLEMENTED -#define glPixelMapusv GML_FUNCTION_NOT_IMPLEMENTED -#define glPixelStoref GML_FUNCTION_NOT_IMPLEMENTED -#define glPixelStorei GML_FUNCTION_NOT_IMPLEMENTED -#define glPixelTexGenSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glPixelTransferf GML_FUNCTION_NOT_IMPLEMENTED -#define glPixelTransferi GML_FUNCTION_NOT_IMPLEMENTED -#define glPixelTransformParameterfEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glPixelTransformParameterfvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glPixelTransformParameteriEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glPixelTransformParameterivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glPixelZoom GML_FUNCTION_NOT_IMPLEMENTED -#define glPointParameterf GML_FUNCTION_NOT_IMPLEMENTED -#define glPointParameterfARB GML_FUNCTION_NOT_IMPLEMENTED -#define glPointParameterfEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glPointParameterfv GML_FUNCTION_NOT_IMPLEMENTED -#define glPointParameterfvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glPointParameterfvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glPointParameteriNV GML_FUNCTION_NOT_IMPLEMENTED -#define glPointParameterivNV GML_FUNCTION_NOT_IMPLEMENTED -#define glPointSize GML_FUNCTION_NOT_IMPLEMENTED -#define glPollAsyncSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glPolygonMode GML_FUNCTION_NOT_IMPLEMENTED -#define glPolygonOffset GML_FUNCTION_NOT_IMPLEMENTED -#define glPolygonOffsetEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glPolygonStipple GML_FUNCTION_NOT_IMPLEMENTED -#define glPopAttrib GML_FUNCTION_NOT_IMPLEMENTED -#define glPopClientAttrib GML_FUNCTION_NOT_IMPLEMENTED -#define glPopMatrix GML_FUNCTION_NOT_IMPLEMENTED -#define glPopName GML_FUNCTION_NOT_IMPLEMENTED -#define glPrimitiveRestartIndexNV GML_FUNCTION_NOT_IMPLEMENTED -#define glPrimitiveRestartNV GML_FUNCTION_NOT_IMPLEMENTED -#define glPrioritizeTextures GML_FUNCTION_NOT_IMPLEMENTED -#define glPrioritizeTexturesEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramBufferParametersIivNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramBufferParametersIuivNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramBufferParametersfvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramEnvParameter4dARB GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramEnvParameter4dvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramEnvParameter4fARB GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramEnvParameter4fvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramEnvParameterI4iNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramEnvParameterI4ivNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramEnvParameterI4uiNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramEnvParameterI4uivNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramEnvParameters4fvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramEnvParametersI4ivNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramEnvParametersI4uivNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramLocalParameter4dARB GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramLocalParameter4dvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramLocalParameter4fARB GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramLocalParameter4fvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramLocalParameterI4iNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramLocalParameterI4ivNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramLocalParameterI4uiNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramLocalParameterI4uivNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramLocalParameters4fvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramLocalParametersI4ivNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramLocalParametersI4uivNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramNamedParameter4dNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramNamedParameter4dvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramNamedParameter4fNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramNamedParameter4fvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramParameter4dNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramParameter4dvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramParameter4fNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramParameter4fvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramParameteriEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramParameters4dvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramParameters4fvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramStringARB GML_FUNCTION_NOT_IMPLEMENTED -#define glProgramVertexLimitNV GML_FUNCTION_NOT_IMPLEMENTED -#define glPushAttrib GML_FUNCTION_NOT_IMPLEMENTED -#define glPushClientAttrib GML_FUNCTION_NOT_IMPLEMENTED -#define glPushMatrix GML_FUNCTION_NOT_IMPLEMENTED -#define glPushName GML_FUNCTION_NOT_IMPLEMENTED -#define glRasterPos2d GML_FUNCTION_NOT_IMPLEMENTED -#define glRasterPos2dv GML_FUNCTION_NOT_IMPLEMENTED -#define glRasterPos2f GML_FUNCTION_NOT_IMPLEMENTED -#define glRasterPos2fv GML_FUNCTION_NOT_IMPLEMENTED -#define glRasterPos2i GML_FUNCTION_NOT_IMPLEMENTED -#define glRasterPos2iv GML_FUNCTION_NOT_IMPLEMENTED -#define glRasterPos2s GML_FUNCTION_NOT_IMPLEMENTED -#define glRasterPos2sv GML_FUNCTION_NOT_IMPLEMENTED -#define glRasterPos3d GML_FUNCTION_NOT_IMPLEMENTED -#define glRasterPos3dv GML_FUNCTION_NOT_IMPLEMENTED -#define glRasterPos3f GML_FUNCTION_NOT_IMPLEMENTED -#define glRasterPos3fv GML_FUNCTION_NOT_IMPLEMENTED -#define glRasterPos3i GML_FUNCTION_NOT_IMPLEMENTED -#define glRasterPos3iv GML_FUNCTION_NOT_IMPLEMENTED -#define glRasterPos3s GML_FUNCTION_NOT_IMPLEMENTED -#define glRasterPos3sv GML_FUNCTION_NOT_IMPLEMENTED -#define glRasterPos4d GML_FUNCTION_NOT_IMPLEMENTED -#define glRasterPos4dv GML_FUNCTION_NOT_IMPLEMENTED -#define glRasterPos4f GML_FUNCTION_NOT_IMPLEMENTED -#define glRasterPos4fv GML_FUNCTION_NOT_IMPLEMENTED -#define glRasterPos4i GML_FUNCTION_NOT_IMPLEMENTED -#define glRasterPos4iv GML_FUNCTION_NOT_IMPLEMENTED -#define glRasterPos4s GML_FUNCTION_NOT_IMPLEMENTED -#define glRasterPos4sv GML_FUNCTION_NOT_IMPLEMENTED -#define glReadBuffer GML_FUNCTION_NOT_IMPLEMENTED -#define glReadBufferRegionEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glReadPixels GML_FUNCTION_NOT_IMPLEMENTED -#define glReadVideoPixelsSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glRectd GML_FUNCTION_NOT_IMPLEMENTED -#define glRectdv GML_FUNCTION_NOT_IMPLEMENTED -#define glRectf GML_FUNCTION_NOT_IMPLEMENTED -#define glRectfv GML_FUNCTION_NOT_IMPLEMENTED -#define glRecti GML_FUNCTION_NOT_IMPLEMENTED -#define glRectiv GML_FUNCTION_NOT_IMPLEMENTED -#define glRects GML_FUNCTION_NOT_IMPLEMENTED -#define glRectsv GML_FUNCTION_NOT_IMPLEMENTED -#define glReferencePlaneSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glRenderMode GML_FUNCTION_NOT_IMPLEMENTED -#define glRenderbufferStorageEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glRenderbufferStorageMultisampleCoverageNV GML_FUNCTION_NOT_IMPLEMENTED -#define glRenderbufferStorageMultisampleEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glReplacementCodePointerSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glReplacementCodeubSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glReplacementCodeubvSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glReplacementCodeuiColor3fVertex3fSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glReplacementCodeuiColor3fVertex3fvSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glReplacementCodeuiColor4fNormal3fVertex3fSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glReplacementCodeuiColor4fNormal3fVertex3fvSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glReplacementCodeuiColor4ubVertex3fSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glReplacementCodeuiColor4ubVertex3fvSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glReplacementCodeuiNormal3fVertex3fSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glReplacementCodeuiNormal3fVertex3fvSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glReplacementCodeuiSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glReplacementCodeuiTexCoord2fVertex3fSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glReplacementCodeuiTexCoord2fVertex3fvSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glReplacementCodeuiVertex3fSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glReplacementCodeuiVertex3fvSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glReplacementCodeuivSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glReplacementCodeusSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glReplacementCodeusvSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glRequestResidentProgramsNV GML_FUNCTION_NOT_IMPLEMENTED -#define glResetHistogram GML_FUNCTION_NOT_IMPLEMENTED -#define glResetHistogramEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glResetMinmax GML_FUNCTION_NOT_IMPLEMENTED -#define glResetMinmaxEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glResizeBuffersMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glRotated GML_FUNCTION_NOT_IMPLEMENTED -#define glRotatef GML_FUNCTION_NOT_IMPLEMENTED -#define glSampleCoverage GML_FUNCTION_NOT_IMPLEMENTED -#define glSampleCoverageARB GML_FUNCTION_NOT_IMPLEMENTED -#define glSampleMapATI GML_FUNCTION_NOT_IMPLEMENTED -#define glSampleMaskEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glSampleMaskSGIS GML_FUNCTION_NOT_IMPLEMENTED -#define glSamplePatternEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glSamplePatternSGIS GML_FUNCTION_NOT_IMPLEMENTED -#define glScaled GML_FUNCTION_NOT_IMPLEMENTED -#define glScalef GML_FUNCTION_NOT_IMPLEMENTED -#define glScissor GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3b GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3bEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3bv GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3bvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3d GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3dEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3dv GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3dvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3f GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3fEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3fv GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3fvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3hNV GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3hvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3i GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3iEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3iv GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3ivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3s GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3sEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3sv GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3svEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3ub GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3ubEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3ubv GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3ubvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3ui GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3uiEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3uiv GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3uivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3us GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3usEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3usv GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColor3usvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColorPointer GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColorPointerEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glSecondaryColorPointerListIBM GML_FUNCTION_NOT_IMPLEMENTED -#define glSelectBuffer GML_FUNCTION_NOT_IMPLEMENTED -#define glSeparableFilter2D GML_FUNCTION_NOT_IMPLEMENTED -#define glSeparableFilter2DEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glSetFenceAPPLE GML_FUNCTION_NOT_IMPLEMENTED -#define glSetFenceNV GML_FUNCTION_NOT_IMPLEMENTED -#define glSetFragmentShaderConstantATI GML_FUNCTION_NOT_IMPLEMENTED -#define glSetInvariantEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glSetLocalConstantEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glShadeModel GML_FUNCTION_NOT_IMPLEMENTED -#define glShaderOp1EXT GML_FUNCTION_NOT_IMPLEMENTED -#define glShaderOp2EXT GML_FUNCTION_NOT_IMPLEMENTED -#define glShaderOp3EXT GML_FUNCTION_NOT_IMPLEMENTED -#define glShaderSource GML_FUNCTION_NOT_IMPLEMENTED -#define glShaderSourceARB GML_FUNCTION_NOT_IMPLEMENTED -#define glSharpenTexFuncSGIS GML_FUNCTION_NOT_IMPLEMENTED -#define glSpriteParameterfSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glSpriteParameterfvSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glSpriteParameteriSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glSpriteParameterivSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glStencilFunc GML_FUNCTION_NOT_IMPLEMENTED -#define glStencilFuncSeparate GML_FUNCTION_NOT_IMPLEMENTED -#define glStencilFuncSeparateATI GML_FUNCTION_NOT_IMPLEMENTED -#define glStencilMask GML_FUNCTION_NOT_IMPLEMENTED -#define glStencilMaskSeparate GML_FUNCTION_NOT_IMPLEMENTED -#define glStencilOp GML_FUNCTION_NOT_IMPLEMENTED -#define glStencilOpSeparate GML_FUNCTION_NOT_IMPLEMENTED -#define glStencilOpSeparateATI GML_FUNCTION_NOT_IMPLEMENTED -#define glStringMarkerGREMEDY GML_FUNCTION_NOT_IMPLEMENTED -#define glSwizzleEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glTagSampleBufferSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glTangentPointerEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glTbufferMask3DFX GML_FUNCTION_NOT_IMPLEMENTED -#define glTestFenceAPPLE GML_FUNCTION_NOT_IMPLEMENTED -#define glTestFenceNV GML_FUNCTION_NOT_IMPLEMENTED -#define glTestObjectAPPLE GML_FUNCTION_NOT_IMPLEMENTED -#define glTexBufferEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glTexBumpParameterfvATI GML_FUNCTION_NOT_IMPLEMENTED -#define glTexBumpParameterivATI GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord1d GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord1dv GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord1f GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord1fv GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord1hNV GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord1hvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord1i GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord1iv GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord1s GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord1sv GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord2d GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord2dv GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord2f GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord2fColor3fVertex3fSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord2fColor3fVertex3fvSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord2fColor4fNormal3fVertex3fSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord2fColor4fNormal3fVertex3fvSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord2fColor4ubVertex3fSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord2fColor4ubVertex3fvSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord2fNormal3fVertex3fSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord2fNormal3fVertex3fvSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord2fVertex3fSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord2fVertex3fvSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord2fv GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord2hNV GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord2hvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord2i GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord2iv GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord2s GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord2sv GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord3d GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord3dv GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord3f GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord3fv GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord3hNV GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord3hvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord3i GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord3iv GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord3s GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord3sv GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord4d GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord4dv GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord4f GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord4fColor4fNormal3fVertex4fSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord4fColor4fNormal3fVertex4fvSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord4fVertex4fSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord4fVertex4fvSUN GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord4fv GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord4hNV GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord4hvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord4i GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord4iv GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord4s GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoord4sv GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoordPointer GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoordPointerEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoordPointerListIBM GML_FUNCTION_NOT_IMPLEMENTED -#define glTexCoordPointervINTEL GML_FUNCTION_NOT_IMPLEMENTED -#define glTexEnvf GML_FUNCTION_NOT_IMPLEMENTED -#define glTexEnvfv GML_FUNCTION_NOT_IMPLEMENTED -#define glTexEnvi GML_FUNCTION_NOT_IMPLEMENTED -#define glTexEnviv GML_FUNCTION_NOT_IMPLEMENTED -#define glTexFilterFuncSGIS GML_FUNCTION_NOT_IMPLEMENTED -#define glTexGend GML_FUNCTION_NOT_IMPLEMENTED -#define glTexGendv GML_FUNCTION_NOT_IMPLEMENTED -#define glTexGenf GML_FUNCTION_NOT_IMPLEMENTED -#define glTexGenfv GML_FUNCTION_NOT_IMPLEMENTED -#define glTexGeni GML_FUNCTION_NOT_IMPLEMENTED -#define glTexGeniv GML_FUNCTION_NOT_IMPLEMENTED -#define glTexImage1D GML_FUNCTION_NOT_IMPLEMENTED -#define glTexImage2D GML_FUNCTION_NOT_IMPLEMENTED -#define glTexImage3D GML_FUNCTION_NOT_IMPLEMENTED -#define glTexImage3DEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glTexImage4DSGIS GML_FUNCTION_NOT_IMPLEMENTED -#define glTexParameterIivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glTexParameterIuivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glTexParameterf GML_FUNCTION_NOT_IMPLEMENTED -#define glTexParameterfv GML_FUNCTION_NOT_IMPLEMENTED -#define glTexParameteri GML_FUNCTION_NOT_IMPLEMENTED -#define glTexParameteriv GML_FUNCTION_NOT_IMPLEMENTED -#define glTexScissorFuncINTEL GML_FUNCTION_NOT_IMPLEMENTED -#define glTexScissorINTEL GML_FUNCTION_NOT_IMPLEMENTED -#define glTexSubImage1D GML_FUNCTION_NOT_IMPLEMENTED -#define glTexSubImage1DEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glTexSubImage2D GML_FUNCTION_NOT_IMPLEMENTED -#define glTexSubImage2DEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glTexSubImage3D GML_FUNCTION_NOT_IMPLEMENTED -#define glTexSubImage3DEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glTexSubImage4DSGIS GML_FUNCTION_NOT_IMPLEMENTED -#define glTextureFogSGIX GML_FUNCTION_NOT_IMPLEMENTED -#define glTextureLightEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glTextureMaterialEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glTextureNormalEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glTextureRangeAPPLE GML_FUNCTION_NOT_IMPLEMENTED -#define glTrackMatrixNV GML_FUNCTION_NOT_IMPLEMENTED -#define glTransformFeedbackAttribsNV GML_FUNCTION_NOT_IMPLEMENTED -#define glTransformFeedbackVaryingsNV GML_FUNCTION_NOT_IMPLEMENTED -#define glTranslated GML_FUNCTION_NOT_IMPLEMENTED -#define glTranslatef GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform1f GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform1fARB GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform1fv GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform1fvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform1i GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform1iARB GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform1iv GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform1ivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform1uiEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform1uiv GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform1uivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform2f GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform2fARB GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform2fv GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform2fvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform2i GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform2iARB GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform2iv GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform2ivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform2uiEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform2uiv GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform2uivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform3f GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform3fARB GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform3fv GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform3fvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform3i GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform3iARB GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform3iv GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform3ivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform3uiEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform3uiv GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform3uivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform4f GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform4fARB GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform4fv GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform4fvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform4i GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform4iARB GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform4iv GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform4ivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform4uiEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform4uiv GML_FUNCTION_NOT_IMPLEMENTED -#define glUniform4uivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glUniformBufferEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glUniformMatrix2fv GML_FUNCTION_NOT_IMPLEMENTED -#define glUniformMatrix2fvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glUniformMatrix2x3fv GML_FUNCTION_NOT_IMPLEMENTED -#define glUniformMatrix2x4fv GML_FUNCTION_NOT_IMPLEMENTED -#define glUniformMatrix3fv GML_FUNCTION_NOT_IMPLEMENTED -#define glUniformMatrix3fvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glUniformMatrix3x2fv GML_FUNCTION_NOT_IMPLEMENTED -#define glUniformMatrix3x4fv GML_FUNCTION_NOT_IMPLEMENTED -#define glUniformMatrix4fv GML_FUNCTION_NOT_IMPLEMENTED -#define glUniformMatrix4fvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glUniformMatrix4x2fv GML_FUNCTION_NOT_IMPLEMENTED -#define glUniformMatrix4x3fv GML_FUNCTION_NOT_IMPLEMENTED -#define glUnlockArraysEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glUnmapBuffer GML_FUNCTION_NOT_IMPLEMENTED -#define glUnmapBufferARB GML_FUNCTION_NOT_IMPLEMENTED -#define glUnmapObjectBufferATI GML_FUNCTION_NOT_IMPLEMENTED -#define glUpdateObjectBufferATI GML_FUNCTION_NOT_IMPLEMENTED -#define glUseProgram GML_FUNCTION_NOT_IMPLEMENTED -#define glUseProgramObjectARB GML_FUNCTION_NOT_IMPLEMENTED -#define glValidateProgram GML_FUNCTION_NOT_IMPLEMENTED -#define glValidateProgramARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVariantArrayObjectATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVariantPointerEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVariantbvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVariantdvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVariantfvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVariantivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVariantsvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVariantubvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVariantuivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVariantusvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex2d GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex2dv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex2f GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex2fv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex2hNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex2hvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex2i GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex2iv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex2s GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex2sv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex3d GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex3dv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex3f GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex3fv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex3hNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex3hvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex3i GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex3iv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex3s GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex3sv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex4d GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex4dv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex4f GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex4fv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex4hNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex4hvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex4i GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex4iv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex4s GML_FUNCTION_NOT_IMPLEMENTED -#define glVertex4sv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexArrayParameteriAPPLE GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexArrayRangeAPPLE GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexArrayRangeNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib1d GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib1dARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib1dNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib1dv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib1dvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib1dvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib1f GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib1fARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib1fNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib1fv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib1fvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib1fvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib1hNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib1hvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib1s GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib1sARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib1sNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib1sv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib1svARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib1svNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib2d GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib2dARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib2dNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib2dv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib2dvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib2dvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib2f GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib2fARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib2fNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib2fv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib2fvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib2fvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib2hNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib2hvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib2s GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib2sARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib2sNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib2sv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib2svARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib2svNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib3d GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib3dARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib3dNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib3dv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib3dvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib3dvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib3f GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib3fARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib3fNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib3fv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib3fvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib3fvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib3hNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib3hvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib3s GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib3sARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib3sNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib3sv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib3svARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib3svNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4Nbv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4NbvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4Niv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4NivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4Nsv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4NsvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4Nub GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4NubARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4Nubv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4NubvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4Nuiv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4NuivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4Nusv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4NusvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4bv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4bvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4d GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4dARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4dNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4dv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4dvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4dvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4f GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4fARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4fNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4fv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4fvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4fvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4hNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4hvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4iv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4ivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4s GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4sARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4sNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4sv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4svARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4svNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4ubNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4ubv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4ubvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4ubvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4uiv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4uivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4usv GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttrib4usvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribArrayObjectATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribI1iEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribI1ivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribI1uiEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribI1uivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribI2iEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribI2ivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribI2uiEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribI2uivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribI3iEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribI3ivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribI3uiEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribI3uivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribI4bvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribI4iEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribI4ivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribI4svEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribI4ubvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribI4uiEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribI4uivEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribI4usvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribIPointerEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribPointer GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribPointerARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribPointerNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribs1dvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribs1fvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribs1hvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribs1svNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribs2dvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribs2fvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribs2hvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribs2svNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribs3dvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribs3fvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribs3hvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribs3svNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribs4dvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribs4fvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribs4hvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribs4svNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexAttribs4ubvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexBlendARB GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexBlendEnvfATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexBlendEnviATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexPointer GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexPointerEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexPointerListIBM GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexPointervINTEL GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexStream2dATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexStream2dvATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexStream2fATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexStream2fvATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexStream2iATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexStream2ivATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexStream2sATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexStream2svATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexStream3dATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexStream3dvATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexStream3fATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexStream3fvATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexStream3iATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexStream3ivATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexStream3sATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexStream3svATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexStream4dATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexStream4dvATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexStream4fATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexStream4fvATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexStream4iATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexStream4ivATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexStream4sATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexStream4svATI GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexWeightPointerEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexWeightfEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexWeightfvEXT GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexWeighthNV GML_FUNCTION_NOT_IMPLEMENTED -#define glVertexWeighthvNV GML_FUNCTION_NOT_IMPLEMENTED -#define glViewport GML_FUNCTION_NOT_IMPLEMENTED -#define glWeightPointerARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWeightbvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWeightdvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWeightfvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWeightivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWeightsvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWeightubvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWeightuivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWeightusvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos2d GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos2dARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos2dMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos2dv GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos2dvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos2dvMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos2f GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos2fARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos2fMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos2fv GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos2fvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos2fvMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos2i GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos2iARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos2iMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos2iv GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos2ivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos2ivMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos2s GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos2sARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos2sMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos2sv GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos2svARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos2svMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos3d GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos3dARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos3dMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos3dv GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos3dvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos3dvMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos3f GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos3fARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos3fMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos3fv GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos3fvARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos3fvMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos3i GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos3iARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos3iMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos3iv GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos3ivARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos3ivMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos3s GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos3sARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos3sMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos3sv GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos3svARB GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos3svMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos4dMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos4dvMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos4fMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos4fvMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos4iMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos4ivMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos4sMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glWindowPos4svMESA GML_FUNCTION_NOT_IMPLEMENTED -#define glWriteMaskEXT GML_FUNCTION_NOT_IMPLEMENTED - -#define gluBeginCurve GML_FUNCTION_NOT_IMPLEMENTED -#define gluBeginPolygon GML_FUNCTION_NOT_IMPLEMENTED -#define gluBeginSurface GML_FUNCTION_NOT_IMPLEMENTED -#define gluBeginTrim GML_FUNCTION_NOT_IMPLEMENTED -#define gluBuild1DMipmaps GML_FUNCTION_NOT_IMPLEMENTED -#define gluBuild2DMipmaps GML_FUNCTION_NOT_IMPLEMENTED -#define gluCylinder GML_FUNCTION_NOT_IMPLEMENTED -#define gluDeleteNurbsRenderer GML_FUNCTION_NOT_IMPLEMENTED -#define gluDeleteQuadric GML_FUNCTION_NOT_IMPLEMENTED -#define gluDeleteTess GML_FUNCTION_NOT_IMPLEMENTED -#define gluDisk GML_FUNCTION_NOT_IMPLEMENTED -#define gluEndCurve GML_FUNCTION_NOT_IMPLEMENTED -#define gluEndPolygon GML_FUNCTION_NOT_IMPLEMENTED -#define gluEndSurface GML_FUNCTION_NOT_IMPLEMENTED -#define gluEndTrim GML_FUNCTION_NOT_IMPLEMENTED -#define gluErrorString GML_FUNCTION_NOT_IMPLEMENTED -#define gluErrorStringWIN GML_FUNCTION_NOT_IMPLEMENTED -#define gluErrorUnicodeStringEXT GML_FUNCTION_NOT_IMPLEMENTED -#define gluGetNurbsProperty GML_FUNCTION_NOT_IMPLEMENTED -#define gluGetString GML_FUNCTION_NOT_IMPLEMENTED -#define gluGetTessProperty GML_FUNCTION_NOT_IMPLEMENTED -#define gluLoadSamplingMatrices GML_FUNCTION_NOT_IMPLEMENTED -#define gluLookAt GML_FUNCTION_NOT_IMPLEMENTED -#define gluNewNurbsRenderer GML_FUNCTION_NOT_IMPLEMENTED -#define gluNewQuadric GML_FUNCTION_NOT_IMPLEMENTED -#define gluNewTess GML_FUNCTION_NOT_IMPLEMENTED -#define gluNextContour GML_FUNCTION_NOT_IMPLEMENTED -#define gluNurbsCallback GML_FUNCTION_NOT_IMPLEMENTED -#define gluNurbsCurve GML_FUNCTION_NOT_IMPLEMENTED -#define gluNurbsProperty GML_FUNCTION_NOT_IMPLEMENTED -#define gluNurbsSurface GML_FUNCTION_NOT_IMPLEMENTED -#define gluOrtho2D GML_FUNCTION_NOT_IMPLEMENTED -#define gluPartialDisk GML_FUNCTION_NOT_IMPLEMENTED -#define gluPerspective GML_FUNCTION_NOT_IMPLEMENTED -#define gluPickMatrix GML_FUNCTION_NOT_IMPLEMENTED -#define gluProject GML_FUNCTION_NOT_IMPLEMENTED -#define gluPwlCurve GML_FUNCTION_NOT_IMPLEMENTED -#define gluQuadricCallback GML_FUNCTION_NOT_IMPLEMENTED -#define gluQuadricDrawStyle GML_FUNCTION_NOT_IMPLEMENTED -#define gluQuadricNormals GML_FUNCTION_NOT_IMPLEMENTED -#define gluQuadricOrientation GML_FUNCTION_NOT_IMPLEMENTED -#define gluQuadricTexture GML_FUNCTION_NOT_IMPLEMENTED -#define gluScaleImage GML_FUNCTION_NOT_IMPLEMENTED -#define gluSphere GML_FUNCTION_NOT_IMPLEMENTED -#define gluTessBeginContour GML_FUNCTION_NOT_IMPLEMENTED -#define gluTessBeginPolygon GML_FUNCTION_NOT_IMPLEMENTED -#define gluTessCallback GML_FUNCTION_NOT_IMPLEMENTED -#define gluTessEndContour GML_FUNCTION_NOT_IMPLEMENTED -#define gluTessEndPolygon GML_FUNCTION_NOT_IMPLEMENTED -#define gluTessNormal GML_FUNCTION_NOT_IMPLEMENTED -#define gluTessProperty GML_FUNCTION_NOT_IMPLEMENTED -#define gluTessVertex GML_FUNCTION_NOT_IMPLEMENTED -#define gluUnProject GML_FUNCTION_NOT_IMPLEMENTED diff -Nru spring-96.0~14.04~ppa4/rts/lib/gml/gmlmut.h spring-98.0~14.04~ppa6/rts/lib/gml/gmlmut.h --- spring-96.0~14.04~ppa4/rts/lib/gml/gmlmut.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/gml/gmlmut.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,199 +0,0 @@ -// GML - OpenGL Multithreading Library -// for Spring http://springrts.com -// Author: Mattias "zerver" Radeskog -// (C) Ware Zerver Tech. http://zerver.net -// Ware Zerver Tech. licenses this library -// to be used, distributed and modified -// freely for any purpose, as long as -// this notice remains unchanged - -// MUTEX TYPES: -// xxx below refers to a mutex named named xxxmutex, declared in gml.cpp and also below as extern -// If you want to protect a newly introduced shared resource, you may need to declare a new mutex -// To protect access to an existing shared resource, check if an existing named mutex is used to protect it in other locations, and use that same one -// -// Basic mutex lock types -// GML_STDMUTEX_LOCK(xxx) - scope locks the specified standard (non recursive, boost::mutex) mutex -// GML_RECMUTEX_LOCK(xxx) - scope locks the specified recursive (boost::recursive_mutex) mutex -// -// Specialized mutex lock types - they are rarely needed -// GML_MSTMUTEX_LOCK(xxx) - scope locks the specified manually lockable/unlockable (gmlMutex) mutex -// GML_MSTMUTEX_DOLOCK(xxx) - locks the specified manually lockable/unlockable (gmlMutex) mutex -// GML_MSTMUTEX_DOUNLOCK(xxx) - unlocks the specified manually lockable/unlockable (gmlMutex) mutex -// GML_THRMUTEX_LOCK(xxx,thr) - scope locks the specified recursive (boost::recursive_mutex) mutex depending on if the current thread matches thr = GML_SIM, GML_DRAW or GML_SIM|GML_DRAW -// GML_OBJMUTEX_LOCK(xxx,thr,arg) - scope locks the specified recursive (boost::recursive_mutex) mutex depending on if the current thread matches thr = GML_SIM, GML_DRAW or GML_SIM|GML_DRAW, arg will be prefixed to xxx -// GML_LODMUTEX_LOCK(xxx) - shorthand for GML_OBJMUTEX_LOCK(lod, GML_DRAW|GML_SIM, xxx->), i.e. will lock xxx->lodmutex for sim/draw threads -// GML_DRCMUTEX_LOCK(xxx) - shorthand for GML_MEASURE_LOCK_TIME(GML_OBJMUTEX_LOCK(xxx, GML_DRAW|GML_SIM, *L->)), i.e. will lock *L->xxxmutex for sim/draw threads and measure the locking overhead -// GML_LINEMUTEX_LOCK(...) - special mutex lock replacement for profiling only -// GML_PROFMUTEX_LOCK(...) - special mutex lock replacement for profiling only - -#ifndef GMLMUTEX_H -#define GMLMUTEX_H - -#define GML_DRAW 1 -#define GML_SIM 2 - -#ifdef USE_GML - -#include "gmlcnf.h" - -#if GML_ENABLE_SIM -#include -extern boost::mutex caimutex; -extern boost::mutex decalmutex; -extern boost::mutex treemutex; -extern boost::mutex mapmutex; -extern boost::mutex inmapmutex; -extern boost::mutex tempmutex; -extern boost::mutex posmutex; -extern boost::mutex runitmutex; -extern boost::mutex netmutex; -extern boost::mutex histmutex; -extern boost::mutex timemutex; -extern boost::mutex watermutex; -extern boost::mutex dquemutex; -extern boost::mutex scarmutex; -extern boost::mutex trackmutex; -extern boost::mutex rprojmutex; -extern boost::mutex rflashmutex; -extern boost::mutex rpiecemutex; -extern boost::mutex rfeatmutex; -extern boost::mutex drawmutex; -extern boost::mutex scallmutex; -extern boost::mutex ulbatchmutex; -extern boost::mutex flbatchmutex; -extern boost::mutex olbatchmutex; -extern boost::mutex plbatchmutex; -extern boost::mutex glbatchmutex; -extern boost::mutex mlbatchmutex; -extern boost::mutex llbatchmutex; -extern boost::mutex cmdmutex; -extern boost::mutex xcallmutex; -extern boost::mutex blockmutex; -extern boost::mutex tnummutex; -extern boost::mutex ntexmutex; -extern boost::mutex catmutex; -extern boost::mutex grpchgmutex; -extern boost::mutex laycmdmutex; - -#include -extern boost::recursive_mutex unitmutex; -extern boost::recursive_mutex quadmutex; -extern boost::recursive_mutex selmutex; -extern boost::recursive_mutex featmutex; -extern boost::recursive_mutex grassmutex; -extern boost::recursive_mutex &guimutex; -extern boost::recursive_mutex filemutex; -extern boost::recursive_mutex &qnummutex; -extern boost::recursive_mutex &groupmutex; -extern boost::recursive_mutex &grpselmutex; -extern boost::recursive_mutex projmutex; -extern boost::recursive_mutex objmutex; -extern boost::recursive_mutex modelmutex; -extern boost::recursive_mutex cammutex; - -#include "gmlcls.h" - -extern gmlMutex simmutex; - -#if GML_MUTEX_PROFILER -# include "System/TimeProfiler.h" -#define GML_MUTEX_TYPE(name, type) boost::type::scoped_lock name##lock(name##mutex) -# if GML_MUTEX_PROFILE -# ifdef _DEBUG -# define GML_MTXCMP(a,b) !strcmp(a,b) // comparison of static strings using addresses may not work in debug mode -# else -# define GML_MTXCMP(a,b) (a==b) -# endif -# define GML_LINEMUTEX_LOCK(name, type, line)\ - char st##name[sizeof(ScopedTimer)];\ - int stc##name=GML_MTXCMP(GML_QUOTE(name),gmlProfMutex);\ - if(stc##name)\ - new (st##name) ScopedTimer(" " GML_QUOTE(name ## line ## Mutex));\ - type;\ - if(stc##name)\ - ((ScopedTimer *)st##name)->~ScopedTimer() -# define GML_PROFMUTEX_LOCK(name, type, line) GML_LINEMUTEX_LOCK(name, type, line) -# define GML_STDMUTEX_LOCK(name) GML_PROFMUTEX_LOCK(name, GML_MUTEX_TYPE(name, mutex), __LINE__) -# define GML_RECMUTEX_LOCK(name) GML_PROFMUTEX_LOCK(name, GML_MUTEX_TYPE(name, recursive_mutex), __LINE__) -# define GML_THRMUTEX_LOCK(name,thr) GML_PROFMUTEX_LOCK(name, gmlRecursiveScopedLock name##lock(name##mutex, (((thr)&GML_DRAW) && ((thr)&GML_SIM)) || (((thr)&GML_DRAW) && !Threading::IsSimThread()) || (((thr)&GML_SIM) && Threading::IsSimThread())), __LINE__) -# define GML_OBJMUTEX_LOCK(name,thr,...) GML_PROFMUTEX_LOCK(name, gmlRecursiveScopedLock name##lock(__VA_ARGS__ name##mutex, (((thr)&GML_DRAW) && ((thr)&GML_SIM)) || (((thr)&GML_DRAW) && !Threading::IsSimThread()) || (((thr)&GML_SIM) && Threading::IsSimThread())), __LINE__) -# else -# define GML_PROFMUTEX_LOCK(name, type)\ - char st##name[sizeof(ScopedTimer)];\ - new (st##name) ScopedTimer(" " GML_QUOTE(name##Mutex));\ - type;\ - ((ScopedTimer *)st##name)->~ScopedTimer() -# define GML_STDMUTEX_LOCK(name) GML_PROFMUTEX_LOCK(name, GML_MUTEX_TYPE(name, mutex)) -# define GML_RECMUTEX_LOCK(name) GML_PROFMUTEX_LOCK(name, GML_MUTEX_TYPE(name, recursive_mutex)) -# define GML_THRMUTEX_LOCK(name,thr) GML_PROFMUTEX_LOCK(name, gmlRecursiveScopedLock name##lock(name##mutex, (((thr)&GML_DRAW) && ((thr)&GML_SIM)) || (((thr)&GML_DRAW) && !Threading::IsSimThread()) || (((thr)&GML_SIM) && Threading::IsSimThread()))) -# define GML_OBJMUTEX_LOCK(name,thr,...) GML_PROFMUTEX_LOCK(name, gmlRecursiveScopedLock name##lock(__VA_ARGS__ name##mutex, (((thr)&GML_DRAW) && ((thr)&GML_SIM)) || (((thr)&GML_DRAW) && !Threading::IsSimThread()) || (((thr)&GML_SIM) && Threading::IsSimThread()))) -# endif -#else -# define GML_STDMUTEX_LOCK(name) gmlMutexScopedLock name##lock(name##mutex) -#if GML_DEBUG_MUTEX -extern std::map lockmaps[GML_MAX_NUM_THREADS]; -extern std::map lockmmaps[GML_MAX_NUM_THREADS]; -extern boost::mutex lmmutex; -class gmlRecursiveMutexLockDebug:public gmlRecursiveMutexScopedLock { -public: - std::string s1; - gmlRecursiveMutexLockDebug(boost::recursive_mutex &m, std::string s) : s1(s), gmlRecursiveMutexScopedLock(m) { - GML_STDMUTEX_LOCK(lm); - std::map &lockmap = lockmaps[gmlThreadNumber]; - std::map::iterator locki = lockmap.find(s); - if(locki == lockmap.end()) - lockmap[s1] = 1; - else - lockmap[s1] = (*locki).second + 1; - } - virtual ~gmlRecursiveMutexLockDebug() { - GML_STDMUTEX_LOCK(lm); - std::map &lockmap = lockmaps[gmlThreadNumber]; - lockmap[s1] = (*lockmap.find(s1)).second - 1; - } -}; -# define GML_RECMUTEX_LOCK(name) gmlRecursiveMutexLockDebug name##lock(name##mutex, #name) -# define GML_THRMUTEX_LOCK(name,thr) gmlRecursiveScopedLock name##lock(name##mutex, (((thr)&GML_DRAW) && ((thr)&GML_SIM)) || (((thr)&GML_DRAW) && !Threading::IsSimThread()) || (((thr)&GML_SIM) && Threading::IsSimThread())) // TODO -# define GML_OBJMUTEX_LOCK(name,thr,...) gmlRecursiveScopedLock name##lock(__VA_ARGS__ name##mutex, (((thr)&GML_DRAW) && ((thr)&GML_SIM)) || (((thr)&GML_DRAW) && !Threading::IsSimThread()) || (((thr)&GML_SIM) && Threading::IsSimThread())) // TODO - -#else -# define GML_RECMUTEX_LOCK(name) gmlRecursiveMutexScopedLock name##lock(name##mutex) -# define GML_THRMUTEX_LOCK(name,thr) gmlRecursiveScopedLock name##lock(name##mutex, (((thr)&GML_DRAW) && ((thr)&GML_SIM)) || (((thr)&GML_DRAW) && !Threading::IsSimThread()) || (((thr)&GML_SIM) && Threading::IsSimThread())) -# define GML_OBJMUTEX_LOCK(name,thr,...) gmlRecursiveScopedLock name##lock(__VA_ARGS__ name##mutex, (((thr)&GML_DRAW) && ((thr)&GML_SIM)) || (((thr)&GML_DRAW) && !Threading::IsSimThread()) || (((thr)&GML_SIM) && Threading::IsSimThread())) -#endif -#endif -class gmlMutexLock { - gmlMutex &mtx; -public: - gmlMutexLock(gmlMutex &m, int wait = 0) : mtx(m) { - mtx.Lock(wait); - } - virtual ~gmlMutexLock() { mtx.Unlock(); } -}; -#define GML_MSTMUTEX_LOCK(name, ...) gmlMutexLock name##mutexlock(name##mutex, __VA_ARGS__) -#define GML_MSTMUTEX_DOLOCK(name) name##mutex.Lock() -#define GML_MSTMUTEX_DOUNLOCK(name) name##mutex.Unlock() -#define GML_STDMUTEX_LOCK_NOPROF(name) gmlMutexScopedLock name##lock(name##mutex) - -#endif - -#endif - -#if !defined(USE_GML) || !GML_ENABLE_SIM - -#define GML_STDMUTEX_LOCK(name) -#define GML_RECMUTEX_LOCK(name) -#define GML_THRMUTEX_LOCK(name,thr) -#define GML_OBJMUTEX_LOCK(name,thr,...) -#define GML_STDMUTEX_LOCK_NOPROF(name) -#define GML_MSTMUTEX_LOCK(name, ...) -#define GML_MSTMUTEX_DOLOCK(name) -#define GML_MSTMUTEX_DOUNLOCK(name) - -#endif - -#define GML_LODMUTEX_LOCK(unit) GML_OBJMUTEX_LOCK(lod, GML_DRAW|GML_SIM, unit->) - -#endif - diff -Nru spring-96.0~14.04~ppa4/rts/lib/gml/gmlque.h spring-98.0~14.04~ppa6/rts/lib/gml/gmlque.h --- spring-96.0~14.04~ppa4/rts/lib/gml/gmlque.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/gml/gmlque.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,112 +0,0 @@ -// GML - OpenGL Multithreading Library -// for Spring http://springrts.com -// Author: Mattias "zerver" Radeskog -// (C) Ware Zerver Tech. http://zerver.net -// Ware Zerver Tech. licenses this library -// to be used, distributed and modified -// freely for any purpose, as long as -// this notice remains unchanged - -#ifndef GMLQUEUE_H -#define GMLQUEUE_H - -struct VAdata { - GLint size; - GLenum type; - GLboolean normalized; - GLsizei stride; - const GLvoid *pointer; - GLuint buffer; - VAdata(): size(0), type(0), normalized(true),stride(0), pointer(NULL), buffer(0) {} - VAdata(GLint si, GLenum ty, GLboolean no, GLsizei st, const GLvoid *po, GLuint buf): - size(si),type(ty),normalized(no),stride(st),pointer(po),buffer(buf) {} -}; - -struct VAstruct { - GLuint target; - GLint size; - GLenum type; - GLboolean normalized; - GLvoid * pointer; - GLuint buffer; - int totalsize; -}; - - -struct gmlQueue { - std::map VAmap; - std::set VAset; - - BYTE *ReadPos; - BYTE *WritePos; - BYTE *Pos1; - BYTE *Pos2; - - BYTE *WriteSize; - BYTE *Size1; - BYTE *Size2; - - BYTE *Read; - BYTE *Write; - BYTE *Queue1; - BYTE *Queue2; - - gmlLock Locks1; - gmlLock Locks2; - volatile BOOL_ Locked1; - volatile BOOL_ Locked2; - - volatile BOOL_ Reloc; - BYTE * volatile Sync; - BOOL_ WasSynced; - - GLenum ClientState; - // VertexPointer - GLint VPsize; - GLenum VPtype; - GLsizei VPstride; - const GLvoid *VPpointer; - // ColorPointer - GLint CPsize; - GLenum CPtype; - GLsizei CPstride; - const GLvoid *CPpointer; - // EdgeFlagPointer - GLsizei EFPstride; - const GLboolean *EFPpointer; - // IndexPointer - GLenum IPtype; - GLsizei IPstride; - const GLvoid *IPpointer; - // NormalPointer - GLenum NPtype; - GLsizei NPstride; - const GLvoid *NPpointer; - // TexCoordPointer - GLint TCPsize; - GLenum TCPtype; - GLsizei TCPstride; - const GLvoid *TCPpointer; - - GLuint ArrayBuffer; - GLuint ElementArrayBuffer; - GLuint PixelPackBuffer; - GLuint PixelUnpackBuffer; - - gmlQueue(); - virtual ~gmlQueue(); - - BYTE *Realloc(BYTE **e=NULL); - BYTE *WaitRealloc(BYTE **e=NULL); - void ReleaseWrite(BOOL_ final=TRUE); - BOOL_ GetWrite(BOOL_ critical); - void ReleaseRead(); - BOOL_ GetRead(BOOL_ critical=FALSE); - void SyncRequest(); - void Execute(); - void ExecuteSynced(void (gmlQueue::*execfun)() =&gmlQueue::Execute); - void ExecuteDebug(); - inline bool Empty(int q = 3) { return (!(q & 1) || *(BYTE * volatile *)&Pos1 == Queue1) && (!(q & 2) || *(BYTE * volatile *)&Pos2 == Queue2); } -}; - -#endif diff -Nru spring-96.0~14.04~ppa4/rts/lib/gml/gmlsrv.h spring-98.0~14.04~ppa6/rts/lib/gml/gmlsrv.h --- spring-96.0~14.04~ppa4/rts/lib/gml/gmlsrv.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/gml/gmlsrv.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,476 +0,0 @@ -// GML - OpenGL Multithreading Library -// for Spring http://springrts.com -// Author: Mattias "zerver" Radeskog -// (C) Ware Zerver Tech. http://zerver.net -// Ware Zerver Tech. licenses this library -// to be used, distributed and modified -// freely for any purpose, as long as -// this notice remains unchanged - -#ifndef GMLSRV_H -#define GMLSRV_H - -#ifdef USE_GML -#include "System/OffscreenGLContext.h" -#include -#include -#include -#include "System/Platform/errorhandler.h" -#include "System/Platform/Watchdog.h" -#include "lib/streflop/streflop_cond.h" -#if !defined(_MSC_VER) && defined(_WIN32) -# include "System/Platform/Win/win32.h" -#endif - -extern COffscreenGLContext* ogc[GML_MAX_NUM_THREADS]; - -EXTERN inline void gmlUpdateServers() { - gmlItemsConsumed=0; - gmlProgramServer.GenerateItems(); - gmlProgramObjectARBServer.GenerateItems(); - gmlShaderServer_VERTEX.GenerateItems(); - gmlShaderServer_FRAGMENT.GenerateItems(); - gmlShaderServer_GEOMETRY_EXT.GenerateItems(); - gmlShaderObjectARBServer_VERTEX.GenerateItems(); - gmlShaderObjectARBServer_FRAGMENT.GenerateItems(); - gmlShaderObjectARBServer_GEOMETRY_EXT.GenerateItems(); - gmlQuadricServer.GenerateItems(); - - gmlTextureServer.GenerateItems(); - gmlBufferARBServer.GenerateItems(); - gmlFencesNVServer.GenerateItems(); - gmlProgramsARBServer.GenerateItems(); - gmlRenderbuffersEXTServer.GenerateItems(); - gmlFramebuffersEXTServer.GenerateItems(); - gmlQueryServer.GenerateItems(); - gmlBufferServer.GenerateItems(); - - gmlListServer.GenerateItems(); -} - -#define GML_MAX_EXEC_DEPTH 4 - -template -struct gmlExecState { - R (*worker)(void *); - R (*workerarg)(void *,A); - R (*workeriter)(void *,U); - void* workerclass; - int maxthreads; - BOOL_ syncmode; - int num_units; - const GML_TYPENAME std::set *iter; - int limit1; - int limit2; - BOOL_ serverwork; - void (*serverfun)(void *); - - gmlCount UnitCounter; - gmlExecState(R (*wrk)(void *)=NULL,R (*wrka)(void *,A)=NULL,R (*wrki)(void *,U)=NULL, - void* cls=NULL,int mt=0,BOOL_ sm=FALSE,int nu=0,const GML_TYPENAME std::set *it=NULL,int l1=1,int l2=1,BOOL_ sw=FALSE,void (*swf)(void *)=NULL): - worker(wrk),workerarg(wrka),workeriter(wrki),workerclass(cls),maxthreads(mt), - syncmode(sm),num_units(nu),iter(it),limit1(l1),limit2(l2),serverwork(sw),serverfun(swf),UnitCounter(-1) { - } - - void ExecServerFun() { - if(serverfun) - (*serverfun)(workerclass); - } - - void ExecAll(int &pos, typename std::set::const_iterator &it) { - int i=UnitCounter; - if(i>=num_units) - return; - if(workeriter) { - while(++i::const_iterator &it) { - int i=++UnitCounter; - if(i>=num_units) - return FALSE; - if(workeriter) { - while(pos -class gmlClientServer { -public: - int ExecDepth; - GML_TYPENAME gmlExecState ExecState[GML_MAX_EXEC_DEPTH]; - boost::barrier Barrier; - boost::thread *threads[GML_MAX_NUM_THREADS]; - volatile BOOL_ dorun; - BOOL_ inited; - gmlCount threadcnt; - gmlCount ClientsReady; - BOOL_ newwork; - - BOOL_ auxinited; - R (*auxworker)(void *); - void* auxworkerclass; - boost::barrier AuxBarrier; - gmlCount AuxClientsReady; - - - gmlClientServer() - : ExecDepth(0) - , Barrier(GML_CPU_COUNT) - , dorun(TRUE) - , inited(FALSE) - , threadcnt(0) - , ClientsReady(0) - , newwork(FALSE) - , auxinited(FALSE) - , auxworker(NULL) - , auxworkerclass(NULL) - , AuxBarrier(2) - , AuxClientsReady(0) { - } - - ~gmlClientServer() { - if(inited) { - GML_TYPENAME gmlExecState *ex=ExecState+ExecDepth; - BOOL_ dowait=TRUE; - for(int i=3; i<=gmlThreadCount+1; ++i) { - if(!threads[i]->joinable() || threads[i]->timed_join(boost::posix_time::milliseconds(10))) - dowait=FALSE; - } - ex->maxthreads=0; - dorun=FALSE; - if(dowait) - Barrier.wait(); - for(int i=3; i<=gmlThreadCount+1; ++i) { - if(threads[i]->joinable()) { - if(dowait) - threads[i]->join(); - else if(!threads[i]->timed_join(boost::posix_time::milliseconds(100))) - threads[i]->interrupt(); - } - delete threads[i]; - } - } - if(auxinited) { - boost::thread *simthread = threads[GML_SIM_THREAD_NUM]; - BOOL_ dowait=simthread->joinable() && !simthread->timed_join(boost::posix_time::milliseconds(10)); - auxworker=NULL; - dorun=FALSE; - if(dowait) - AuxBarrier.wait(); - if(simthread->joinable()) { - if(dowait) - simthread->join(); - else if(!simthread->timed_join(boost::posix_time::milliseconds(100))) - simthread->interrupt(); - } - delete simthread; - } - } - - void gmlServer() { - - do { - ClientsReady%=0; - if(newwork>0) - ++ExecDepth; - GML_TYPENAME gmlExecState *ex=ExecState+ExecDepth; - if(newwork==0) - ex->UnitCounter%=-1; - BOOL_ execswf=newwork>=0; - newwork=0; - - Barrier.wait(); - - if(execswf) - ex->ExecServerFun(); - - typename std::set::const_iterator it; - if(ex->workeriter) - it=ex->iter->begin(); - int pos=0; -// int nproc=0; - int updsrv=0; - if(ex->maxthreads>1) { - while(ClientsReady < gmlThreadCount - 1) { - if(!gmlShareLists && ((updsrv++%GML_UPDSRV_INTERVAL)==0 || *(volatile int *)&gmlItemsConsumed>=GML_UPDSRV_INTERVAL)) - gmlUpdateServers(); - BOOL_ processed=FALSE; - - for(int i=3; i<=gmlThreadCount+1; ++i) { - gmlQueue *qd=&gmlQueues[i]; - if(qd->Reloc) - qd->Realloc(); - if(qd->GetRead()) { - qd->Execute(); - qd->ReleaseRead(); - processed=TRUE; - } - if(qd->Sync) { - qd->ExecuteSynced(); - processed=TRUE; - } - } - if(GML_SERVER_GLCALL && ex->serverwork && !processed) { - if(ex->Exec(pos,it)) { - // ++nproc; - } - } - } - } - else { - ex->ExecAll(pos,it); - } - -// GML_DEBUG("server ",nproc, 3) - if(ExecDepth>0 && !*(volatile int *)&newwork) { - --ExecDepth; - newwork=-1; - } - - } while(*(volatile int *)&newwork); - } - - void WorkInit() { -// set_threadnum(0); - gmlInit(); - - for(int i=3; i<=gmlThreadCount+1; ++i) - threads[i]=new boost::thread(boost::bind(&gmlClientServer::gmlClient, this)); -#if GML_ENABLE_TLS_CHECK - for(int i=0; i *it,int nu,int l1,int l2,BOOL_ sw,void (*swf)(void *)=NULL) { - if(!inited) - WorkInit(); - if(auxworker) - --mt; - if(gmlThreadNumber != GML_DRAW_THREAD_NUM) { - NewWork(wrk,wrka,wrkit,cls,mt,sm,it,nu,l1,l2,sw,swf); - return; - } - GML_TYPENAME gmlExecState *ex=ExecState; - new (ex) GML_TYPENAME gmlExecState(wrk,wrka,wrkit,cls,mt,sm,nu,it,l1,l2,sw,swf); - gmlServerActive = true; - gmlServer(); - gmlServerActive = false; - } - - void NewWork(R (*wrk)(void *),R (*wrka)(void *,A), R (*wrkit)(void *,U),void *cls,int mt,BOOL_ sm, const GML_TYPENAME std::set *it,int nu,int l1,int l2,BOOL_ sw,void (*swf)(void *)=NULL) { - gmlQueue *qd=&gmlQueues[gmlThreadNumber]; - qd->ReleaseWrite(); - - GML_TYPENAME gmlExecState *ex=ExecState+ExecDepth; - new (ex+1) GML_TYPENAME gmlExecState(wrk,wrka,wrkit,cls,mt,sm,nu,it,l1,l2,sw,swf); - newwork=TRUE; - - while(!qd->Empty()) - boost::thread::yield(); - ++ClientsReady; - gmlClientSub(); - - Barrier.wait(); - - qd->GetWrite(TRUE); - if(ex->syncmode) - qd->SyncRequest(); - - } - - void gmlClientSub() { - Barrier.wait(); - - GML_TYPENAME gmlExecState *ex=ExecState+ExecDepth; - - int thread=gmlThreadNumber; - if(thread>=ex->maxthreads+2) { - ++ClientsReady; - return; - } - - typename std::set::iterator it; - if(ex->workeriter) - it=((GML_TYPENAME std::set *)*(GML_TYPENAME std::set * volatile *)&ex->iter)->begin(); - int pos=0; - - int processed=0; - gmlQueue *qd=&gmlQueues[thread]; - - qd->GetWrite(TRUE); - - if(ex->syncmode) - qd->SyncRequest(); - - while(ex->Exec(pos,it)) { - ++processed; - -// int exproc=processed; -#if GML_ALTERNATE_SYNCMODE - if(qd->WasSynced && qd->GetWrite(ex->syncmode?TRUE:2)) -#else - if(qd->WasSynced && qd->GetWrite(TRUE)) -#endif - processed=0; - if(processed>=ex->limit1 && qd->GetWrite(processed>=ex->limit2)) - processed=0; -// if(exproc!=processed) { -// GML_DEBUG("client ",exproc, 3) -// } - } - qd->ReleaseWrite(); - while(!qd->Empty()) - boost::thread::yield(); - ++ClientsReady; - } - - __FORCE_ALIGN_STACK__ - void gmlClient() { - long thr = ++threadcnt; - set_threadnum(thr + 2); - if (gmlShareLists) { - ogc[thr]->WorkerThreadPost(); - } - streflop::streflop_init(); - while(dorun) { - gmlClientSub(); - } - if (gmlShareLists) { - ogc[thr]->WorkerThreadFree(); - } - } - - void GetQueue() { - gmlQueue *qd=&gmlQueues[GML_SIM_THREAD_NUM]; - - if(!qd->WasSynced && qd->Write==qd->WritePos) - return; - - BOOL_ isq1=qd->Write==qd->Queue1; - - qd->GetWrite(qd->WasSynced?2:TRUE); - - if(isq1) { - while(!qd->Locked1 && !qd->Empty(1)) - boost::thread::yield(); - } - else { - while(!qd->Locked2 && !qd->Empty(2)) - boost::thread::yield(); - } - } - - BOOL_ PumpAux() { - if(!threads[GML_SIM_THREAD_NUM]->joinable()) - return TRUE; - static int updsrvaux=0; - if(!gmlShareLists && ((updsrvaux++%GML_UPDSRV_INTERVAL)==0 || *(volatile int *)&gmlItemsConsumed>=GML_UPDSRV_INTERVAL)) - gmlUpdateServers(); - - while(AuxClientsReady<=3) { - gmlQueue *qd=&gmlQueues[GML_SIM_THREAD_NUM]; - if(qd->Reloc) - qd->Realloc(); - if(qd->GetRead()) { - qd->ExecuteDebug(); - qd->ReleaseRead(); - } - if(qd->Sync) { - qd->ExecuteSynced(&gmlQueue::ExecuteDebug); - } - if(AuxClientsReady==0) - return FALSE; - else - ++AuxClientsReady; - } - return TRUE; - } - - void AuxWork(R (*wrk)(void *),void *cls) { - auxworker=wrk; - auxworkerclass=cls; - AuxClientsReady%=0; - if(!auxinited) { - if(!inited) - WorkInit(); - threads[GML_SIM_THREAD_NUM]=new boost::thread(boost::bind(&gmlClientServer::gmlClientAux, this)); - auxinited=TRUE; - } - AuxBarrier.wait(); - } - - - void gmlClientAuxSub() { - AuxBarrier.wait(); - - if(!auxworker) - return; - - gmlQueue *qd=&gmlQueues[GML_SIM_THREAD_NUM]; - - qd->GetWrite(TRUE); - - (*auxworker)(auxworkerclass); - - qd->ReleaseWrite(); - - ++AuxClientsReady; - auxworker=NULL; - } - - __FORCE_ALIGN_STACK__ - void gmlClientAux() { - Threading::SetThreadName("sim"); - Watchdog::RegisterThread(WDT_SIM, true); - set_threadnum(GML_SIM_THREAD_NUM); - streflop::streflop_init(); - while(dorun) { - gmlClientAuxSub(); - } - } - - void ExpandAuxQueue() { - gmlQueue *qd=&gmlQueues[gmlThreadNumber]; - while(qd->WriteSizeWrite+GML_AUX_PREALLOC) - qd->WaitRealloc(); - } - -}; - -#endif // USE_GML - -#endif diff -Nru spring-96.0~14.04~ppa4/rts/lib/gml/speedy-tls.cpp spring-98.0~14.04~ppa6/rts/lib/gml/speedy-tls.cpp --- spring-96.0~14.04~ppa4/rts/lib/gml/speedy-tls.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/gml/speedy-tls.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,438 +0,0 @@ -//Copyright (C) 2008 Kevin Hoffman. See LICENSE for use and warranty disclaimer. -//Speedy TLS 1.0. Latest version at http://www.kevinjhoffman.com/ -//Contains macros that can be used to very quickly (one instruction) access thread-local memory. - -#ifdef USE_GML -#ifndef _WIN32 - -#include "speedy-tls.h" -#include -#include -#include -#include -#include -#include -#include -#include - -//============================================================================================================== INTEL ===================== -#ifdef __intel__ - -//Useful reading: -// http://pdos.csail.mit.edu/6.828/2005/readings/i386/s05_01.htm -// http://www.intel.com/products/processor/manuals/ (especially volume 3A) -// Descriptor/Selector format for i386 -// -// http://en.wikipedia.org/wiki/X86_assembly_language#Segmented_addressing -// More info on segmented addressing. -// -// http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html#s7 -// http://asm.sourceforge.net/articles/rmiyagi-inline-asm.txt -// Intros to inline assembly in GCC -// -// http://www.microsoft.com/msj/archive/S2CE.aspx -// http://en.wikipedia.org/wiki/Win32_Thread_Information_Block -// http://younsi.blogspot.com/2007/05/show-tib-under-hood-from-matt-pietrek.html -// -// Might be able to port this to Windows or maybe use compiler TLS storage class and it does it for us (__declspec(thread)). - -//NOTE: I don't use arch_prctl(ARCH_SET_GS, base) and instead use 32-bit segment selector because -//if you set a 64-bit segment selector it makes context switches more expensive! - -//Generic representation of an x86 segment descriptor (32-bit mode and 64-bit mode w/ 32-bit syscall) -struct i386_descriptor { - unsigned int limit_0_15:16; - unsigned int base_0_15:16; - unsigned int base_16_23:8; - unsigned int accessed:1; - unsigned int contents:3; - unsigned int is_normal:1; - unsigned int protection:2; - unsigned int present:1; - unsigned int limit_16_19:4; - unsigned int avl:1; - unsigned int unknown_o:1; - unsigned int seg_32bit:1; - unsigned int limit_in_pages:1; - unsigned int base_24_31:8; -}; - -#ifdef __linux__ - -#include -#include -#include -#include -#include - -int modify_ldt(int func, void *ptr, unsigned long bytecount) { - return syscall(__NR_modify_ldt, func, ptr, bytecount); -} - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 66) -#define modify_ldt_ldt_s user_desc -#endif - -//Define the modify_ldt function that will call this particular syscall. -//_syscall3(int, modify_ldt, int, func, void *, ptr, unsigned long, bytecount); - -#ifdef __x86_64__ -#include -#include -extern "C" { -extern int arch_prctl(int code, unsigned long addr); -}; -#endif - -#else - -#include -#include - -//We still use this structure. -typedef struct modify_ldt_ldt_s { - unsigned int entry_number; - unsigned long base_addr; - unsigned int limit; - unsigned int seg_32bit:1; - unsigned int contents:2; - unsigned int read_exec_only:1; - unsigned int limit_in_pages:1; - unsigned int seg_not_present:1; - unsigned int useable:1; -} modify_ldt_t; - -#define MODIFY_LDT_CONTENTS_DATA 0 -#define MODIFY_LDT_CONTENTS_STACK 1 -#define MODIFY_LDT_CONTENTS_CODE 2 - -#define LDT_ENTRIES 8192 -#define LDT_ENTRY_SIZE 8 - -//Fake the Linux syscall by implementing use BSD-syscall -int modify_ldt(int func, void *ptr, unsigned long bytecount) -{ - if (0 == func){ - //reading LDT - int ret = i386_get_ldt(0, (union ldt_entry*)ptr, bytecount / LDT_ENTRY_SIZE); - if (ret < 0){ return -1; } - int realRet = (bytecount/LDT_ENTRY_SIZE)*LDT_ENTRY_SIZE; - if (ret*LDT_ENTRY_SIZE < realRet){ realRet = ret*LDT_ENTRY_SIZE; } - return realRet; - } else { - //writing one LDT - //have to form actual binary representation of LDT - modify_ldt_ldt_s* pLDT = (modify_ldt_ldt_s*)ptr; - union ldt_entry newLDT; - memset(&newLDT, 0, sizeof(newLDT)); - - int ret=0; - if (pLDT->seg_not_present){ - //Must use this other syntax to free the LDT entry. - ret = i386_set_ldt(pLDT->entry_number, NULL, 1); - } else { - newLDT.data.limit00 = pLDT->limit & 0xFFFF; - newLDT.data.base00 = pLDT->base_addr & 0xFFFF; - newLDT.data.base16 = (pLDT->base_addr & 0xFF0000) >> 16; - newLDT.data.type = (pLDT->read_exec_only ? DESC_DATA_RONLY : DESC_DATA_WRITE); - newLDT.data.dpl = 0x3; - newLDT.data.present = (pLDT->seg_not_present ? 0 : 1); - newLDT.data.limit16 = (pLDT->limit & 0x0F0000) >> 16; - newLDT.data.stksz = (pLDT->seg_32bit ? DESC_DATA_32B : DESC_DATA_16B); - newLDT.data.granular= (pLDT->limit_in_pages ? 1 : 0); - newLDT.data.base24 = (pLDT->base_addr & 0xFF000000) >> 24; - //now do syscall - ret = i386_set_ldt(pLDT->entry_number, &newLDT, 1); - } - if (ret < 0){ return -1; } - if (pLDT->entry_number == LDT_AUTO_ALLOC){ - pLDT->entry_number = ret; - } - //printf("ALLOCATED LDT NUMBER %d\n", pLDT->entry_number); - return 0; - } -} - -#endif //linux - -#ifndef MAP_ANON -#define MAP_ANON MAP_ANONYMOUS -#endif //MAP_ANON - -//------------------------------------------------------------------------------- - -//Worker function to search for the next available ldt -int speedy_tls_get_next_avail_ldt(){ -#ifdef __linux__ - char temp[LDT_ENTRIES*LDT_ENTRY_SIZE]; - int ret = modify_ldt(0, temp, sizeof(temp)); - if (ret < 0){ - perror("failed to read ldt to find next free spot"); - exit(-1); - } - int num=1; - struct i386_descriptor* entries = (struct i386_descriptor*)temp; - for (; entries[num].present; num++){} - return num; -#else - //Let the kernel choose the next free spot (may be more efficient) - return LDT_AUTO_ALLOC; -#endif -} - -//Determine how many LDT entries are still free. -int speedy_tls_get_number_ldt_entries(){ - char temp[LDT_ENTRIES*LDT_ENTRY_SIZE]; - int ret = modify_ldt(0, temp, sizeof(temp)); - if (ret < 0){ - perror("failed to read ldt to get # of entries"); - exit(-1); - } - int maxToScan=ret / LDT_ENTRY_SIZE; - int num=0; - struct i386_descriptor* entries = (struct i386_descriptor*)temp; - for (int i=0; i (void*)0xFFFFFFFF){ - #ifdef __linux__ - int ret = arch_prctl(ARCH_SET_GS, (unsigned long)addr); - if (0 != ret){ - perror("speedy_tls_init_foraddr: failed to set 64-bit base address in GS register!"); - return -1; - } - pthread_setspecific(__speedy_tls_threadhook.m_ldt, speedy_tls_int32_to_ptr(-1)); - pthread_setspecific(__speedy_tls_threadhook.m_tlsbase, addr); - pthread_setspecific(__speedy_tls_threadhook.m_tlslength, speedy_tls_int32_to_ptr(numBytes)); - return 0; - #else - printf("speedy_tls_init_foraddr: base address is 64-bit. Non-Linux OSes do not support this. Out of 32-bit TLS memory. Must fail!!!\n"); - errno = EFAULT; - return -1; - #endif - } -#endif - - pthread_mutex_lock(&__speedy_tls_threadhook.m_lock); - - int newEntryNumber = speedy_tls_get_next_avail_ldt(); - newLDT.entry_number=newEntryNumber; - newLDT.base_addr = (speedy_tls_ptr_to_int32(base) + (getpagesize()-1)) & (~(getpagesize()-1)); - newLDT.limit = numBytes / getpagesize(); - newLDT.seg_32bit = 1; - newLDT.contents = MODIFY_LDT_CONTENTS_DATA; - newLDT.read_exec_only=0; - newLDT.limit_in_pages=1; - newLDT.seg_not_present=0; - newLDT.useable = 1; - int ret = modify_ldt(1, &newLDT, sizeof(newLDT)); - pthread_mutex_unlock(&__speedy_tls_threadhook.m_lock); - if (ret < 0){ - perror("speedy_tls_init_foraddr failed to set ldt"); - return -1; - } - - __asm__ __volatile__ - ( - "movl %0,%%eax\n\t" - "movw %%ax, " __speedy_tls_reg__ "\n\t" - : : "r"((newLDT.entry_number<<3) | (1 << 2) | 0x3) : "%eax" - ); - - //Make sure that we will deallocate this LDT when the thread ends - pthread_setspecific(__speedy_tls_threadhook.m_ldt, speedy_tls_int32_to_ptr(newLDT.entry_number)); - //Remember the base address for our private TLS for this thread. - pthread_setspecific(__speedy_tls_threadhook.m_tlsbase, speedy_tls_int32_to_ptr(newLDT.base_addr)); - pthread_setspecific(__speedy_tls_threadhook.m_tlslength, speedy_tls_int32_to_ptr(numBytes)); - - return 0; -} - -//Returns the base address of the thread-local storage area or NULL if not initialized. -void* speedy_tls_get_base() -{ - void* baseAddr=NULL; - baseAddr = pthread_getspecific(__speedy_tls_threadhook.m_tlsbase); - return baseAddr; -/**************************************** the old way was to get the selector, but doesn't work if we have a 64-bit base. - //Get the current selector. - unsigned int curSelector=0; - __asm__ __volatile__ - ( - "xor %%eax,%%eax\n\t" - "movw " __speedy_tls_reg__ ", %%ax\n\t" - "movl %%eax, %0\n\t" - : "=r"(curSelector) : : "%eax" - ); - //Make sure it's not into the GDT instead of the LDT. - //(if it is, that means we didn't set it, so don't use it) - if (!(curSelector & (1<<2))){ - return NULL; - } - //Get the index into the LDT. - int idx = (curSelector >> 3); - if (idx < 0 || idx >= LDT_ENTRIES){ return NULL; } - - char temp[LDT_ENTRIES*LDT_ENTRY_SIZE]; - int ret = modify_ldt(0, temp, sizeof(temp)); - if (ret < 0){ - perror("speedy_tls_get_base: failed to read ldt"); - return NULL; - } - struct i386_descriptor* entries = (struct i386_descriptor*)temp; - if (!entries[idx].present){ return NULL; } - unsigned int realBase = entries[idx].base_0_15 | (entries[idx].base_16_23 << 16) | (entries[idx].base_24_31 << 24); - return (void*)realBase; -*****************************************/ -} - -#else //__intel__ - -#error Implementation is not defined for non-Intel architecture right now. - -#endif - -#endif -#endif diff -Nru spring-96.0~14.04~ppa4/rts/lib/gml/speedy-tls.h spring-98.0~14.04~ppa6/rts/lib/gml/speedy-tls.h --- spring-96.0~14.04~ppa4/rts/lib/gml/speedy-tls.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/gml/speedy-tls.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,151 +0,0 @@ -//Copyright (C) 2008 Kevin Hoffman. See LICENSE for use and warranty disclaimer. -//Speedy TLS 1.0. Latest version at http://www.kevinjhoffman.com/ -//Contains macros that can be used to very quickly (one instruction) access thread-local memory. - -#ifndef __SPEEDY_TLS_H__ -#define __SPEEDY_TLS_H__ - -//Allocates specified amount of memory (rounded up to nearest page). -//Results are undefined if you call this more than once on a thread. -//Returns system error or 0 on success. -int speedy_tls_init(int numBytes); - -//Initializes the thread-local storage area to the memory region indicated. Size must be a multiple of the page size. -//Results are undefined if you call this more than once on a thread. -//Returns system error or 0 on success. -int speedy_tls_init_foraddr(void* addr, int numBytes); - -//Returns the base address of the thread-local storage area or NULL if not initialized. -void* speedy_tls_get_base(); - -#if defined(__i386__) - -#define __intel__ -#define __speedy_tls_reg__ "%%fs" - -#define speedy_tls_ptr_to_int32(x) ((int)(x)) -#define speedy_tls_int32_to_ptr(x) ((void*)(x)) - -#elif defined(__x86_64__) - -#define __intel__ -#define __speedy_tls_reg__ "%%gs" - -#define speedy_tls_ptr_to_int32(x) ((int)(long long int)(x)) -#define speedy_tls_int32_to_ptr(x) ((void*)(long long int)(x)) - -#else -#error Fast TLS operations have not yet been implemented for this architecture. Please contribute. -#endif - -//We can have a common assembly implementation for x86 architecture (uses fs on x86 and gs on x64). -#ifdef __intel__ - -//Use for information only on Intel only. -int speedy_tls_get_number_ldt_entries(); - -//------------------------------------------------------------------------------------------------------------------------------------- -//MACROS TO GET AND SET TLS VALUES (SAFE FOR SMP) -//------------------------------------------------------------------------------------------------------------------------------------- - -#define speedy_tls_get_int8(base, index, scale, output) \ - __asm__ __volatile__ ( "movb " __speedy_tls_reg__ ":(%1,%2," #scale "), %0" : "=r"(output) : "r"(base), "r"(index) ); -#define speedy_tls_get_int16(base, index, scale, output) \ - __asm__ __volatile__ ( "movw " __speedy_tls_reg__ ":(%1,%2," #scale "), %0" : "=r"(output) : "r"(base), "r"(index) ); -#define speedy_tls_get_int32(base, index, scale, output) \ - __asm__ __volatile__ ( "movl " __speedy_tls_reg__ ":(%1,%2," #scale "), %0" : "=r"(output) : "r"(base), "r"(index) ); - -#define speedy_tls_put_int8(base, index, scale, input) \ - __asm__ __volatile__ ( "movb %0, " __speedy_tls_reg__ ":(%1,%2," #scale ")" : : "r"(input), "r"(base), "r"(index) ); -#define speedy_tls_put_int16(base, index, scale, input) \ - __asm__ __volatile__ ( "movw %0, " __speedy_tls_reg__ ":(%1,%2," #scale ")" : : "r"(input), "r"(base), "r"(index) ); -#define speedy_tls_put_int32(base, index, scale, input) \ - __asm__ __volatile__ ( "movl %0, " __speedy_tls_reg__ ":(%1,%2," #scale ")" : : "r"(input), "r"(base), "r"(index) ); - -//------------------------------------------------------------------------------------------------------------------------------------- -//MACROS THAT USE TLS VALUES (NOT SAFE FOR SMP) -//------------------------------------------------------------------------------------------------------------------------------------- - -#define speedy_tls_add_int8(base, index, scale, input) \ - __asm__ __volatile__ ( "addb %0, " __speedy_tls_reg__ ":(%1,%2," #scale ")" : : "r"(input), "r"(base), "r"(index) ); -#define speedy_tls_add_int16(base, index, scale, input) \ - __asm__ __volatile__ ( "addw %0, " __speedy_tls_reg__ ":(%1,%2," #scale ")" : : "r"(input), "r"(base), "r"(index) ); -#define speedy_tls_add_int32(base, index, scale, input) \ - __asm__ __volatile__ ( "addl %0, " __speedy_tls_reg__ ":(%1,%2," #scale ")" : : "r"(input), "r"(base), "r"(index) ); - -#define speedy_tls_inc_int8(base, index, scale) \ - __asm__ __volatile__ ( "incb " __speedy_tls_reg__ ":(%0,%1," #scale ")" : : "r"(base), "r"(index) ); -#define speedy_tls_inc_int16(base, index, scale) \ - __asm__ __volatile__ ( "incw " __speedy_tls_reg__ ":(%0,%1," #scale ")" : : "r"(base), "r"(index) ); -#define speedy_tls_inc_int32(base, index, scale) \ - __asm__ __volatile__ ( "incl " __speedy_tls_reg__ ":(%0,%1," #scale ")" : : "r"(base), "r"(index) ); - -#define speedy_tls_dec_int8(base, index, scale) \ - __asm__ __volatile__ ( "decb " __speedy_tls_reg__ ":(%0,%1," #scale ")" : : "r"(base), "r"(index) ); -#define speedy_tls_dec_int16(base, index, scale) \ - __asm__ __volatile__ ( "decw " __speedy_tls_reg__ ":(%0,%1," #scale ")" : : "r"(base), "r"(index) ); -#define speedy_tls_dec_int32(base, index, scale) \ - __asm__ __volatile__ ( "decl " __speedy_tls_reg__ ":(%0,%1," #scale ")" : : "r"(base), "r"(index) ); - -//------------------------------------------------------------------------------------------------------------------------------------- -//MACROS THAT USE TLS VALUES (SAFE FOR SMP) -//------------------------------------------------------------------------------------------------------------------------------------- - -#define speedy_tls_atomic_add_int8(base, index, scale, input) \ - __asm__ __volatile__ ( "lock; addb %0, " __speedy_tls_reg__ ":(%1,%2," #scale ")" : : "r"(input), "r"(base), "r"(index) ); -#define speedy_tls_atomic_add_int16(base, index, scale, input) \ - __asm__ __volatile__ ( "lock; addw %0, " __speedy_tls_reg__ ":(%1,%2," #scale ")" : : "r"(input), "r"(base), "r"(index) ); -#define speedy_tls_atomic_add_int32(base, index, scale, input) \ - __asm__ __volatile__ ( "lock; addl %0, " __speedy_tls_reg__ ":(%1,%2," #scale ")" : : "r"(input), "r"(base), "r"(index) ); - -#define speedy_tls_atomic_inc_int8(base, index, scale) \ - __asm__ __volatile__ ( "lock; incb " __speedy_tls_reg__ ":(%0,%1," #scale ")" : : "r"(base), "r"(index) ); -#define speedy_tls_atomic_inc_int16(base, index, scale) \ - __asm__ __volatile__ ( "lock; incw " __speedy_tls_reg__ ":(%0,%1," #scale ")" : : "r"(base), "r"(index) ); -#define speedy_tls_atomic_inc_int32(base, index, scale) \ - __asm__ __volatile__ ( "lock; incl " __speedy_tls_reg__ ":(%0,%1," #scale ")" : : "r"(base), "r"(index) ); - -#define speedy_tls_atomic_dec_int8(base, index, scale) \ - __asm__ __volatile__ ( "lock; decb " __speedy_tls_reg__ ":(%0,%1," #scale ")" : : "r"(base), "r"(index) ); -#define speedy_tls_atomic_dec_int16(base, index, scale) \ - __asm__ __volatile__ ( "lock; decw " __speedy_tls_reg__ ":(%0,%1," #scale ")" : : "r"(base), "r"(index) ); -#define speedy_tls_atomic_dec_int32(base, index, scale) \ - __asm__ __volatile__ ( "lock; decl " __speedy_tls_reg__ ":(%0,%1," #scale ")" : : "r"(base), "r"(index) ); - -//Gets value of TLS integer and saves in original_value, and then adds input to the TLS integer. -#define speedy_tls_atomic_get_and_add_int8(base, index, scale, input, original_value) \ - __asm__ __volatile__ ( "lock; xaddb %0, " __speedy_tls_reg__ ":(%2,%3," #scale ")" : "=r"(original_value) : "0"(input), "r"(base), "r"(index) ); -#define speedy_tls_atomic_get_and_add_int16(base, index, scale, input, original_value) \ - __asm__ __volatile__ ( "lock; xaddw %0, " __speedy_tls_reg__ ":(%2,%3," #scale ")" : "=r"(original_value) : "0"(input), "r"(base), "r"(index) ); -#define speedy_tls_atomic_get_and_add_int32(base, index, scale, input, original_value) \ - __asm__ __volatile__ ( "lock; xaddl %0, " __speedy_tls_reg__ ":(%2,%3," #scale ")" : "=r"(original_value) : "0"(input), "r"(base), "r"(index) ); - -//------------------------------------------------------------------------------------------------------------------------------------- -//MACROS THAT USE LOCAL VARIABLES INSTEAD OF TLS (NOT SMP SAFE) -//------------------------------------------------------------------------------------------------------------------------------------- - -//Saves value of var in original_value and then adds num to var and saves in var. -#define speedy_local_get_and_add_int8(var, num, original_value) \ - __asm__ __volatile__ ( "xaddb %0,%1" : "=r" (original_value), "+m" (var) : "0" (num) : "memory" ); -#define speedy_local_get_and_add_int16(var, num, original_value) \ - __asm__ __volatile__ ( "xaddw %0,%1" : "=r" (original_value), "+m" (var) : "0" (num) : "memory" ); -#define speedy_local_get_and_add_int32(var, num, original_value) \ - __asm__ __volatile__ ( "xaddl %0,%1" : "=r" (original_value), "+m" (var) : "0" (num) : "memory" ); - -//------------------------------------------------------------------------------------------------------------------------------------- -//MACROS THAT USE LOCAL VARIABLES INSTEAD OF TLS (SMP SAFE) -//------------------------------------------------------------------------------------------------------------------------------------- - -//Saves value of var in original_value and then adds num to var and saves in var. -#define speedy_local_atomic_get_and_add_int8(var, num, original_value) \ - __asm__ __volatile__ ( "lock; xaddb %0,%1" : "=r" (original_value), "+m" (var) : "0" (num) : "memory" ); -#define speedy_local_atomic_get_and_add_int16(var, num, original_value) \ - __asm__ __volatile__ ( "lock; xaddw %0,%1" : "=r" (original_value), "+m" (var) : "0" (num) : "memory" ); -#define speedy_local_atomic_get_and_add_int32(var, num, original_value) \ - __asm__ __volatile__ ( "lock; xaddl %0,%1" : "=r" (original_value), "+m" (var) : "0" (num) : "memory" ); - - -#endif //__intel__ - -#endif //__SPEEDY_TLS_H__ - diff -Nru spring-96.0~14.04~ppa4/rts/lib/gml/ThreadSafeContainers.cpp spring-98.0~14.04~ppa6/rts/lib/gml/ThreadSafeContainers.cpp --- spring-96.0~14.04~ppa4/rts/lib/gml/ThreadSafeContainers.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/gml/ThreadSafeContainers.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -#include "ThreadSafeContainers.h" - -#ifndef USE_GML - -/*CR_BIND_TEMPLATE(ThreadListSimRender, ) -CR_REG_METADATA(ThreadListSimRender,( - CR_MEMBER(cont) -));*/ - -#else - -/*CR_BIND_TEMPLATE(ThreadListSimRender, ) -CR_REG_METADATA(ThreadListSimRender,( - CR_MEMBER(cont), - CR_POSTLOAD(PostLoad) -));*/ - -#endif diff -Nru spring-96.0~14.04~ppa4/rts/lib/gml/ThreadSafeContainers.h spring-98.0~14.04~ppa6/rts/lib/gml/ThreadSafeContainers.h --- spring-96.0~14.04~ppa4/rts/lib/gml/ThreadSafeContainers.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/gml/ThreadSafeContainers.h 2014-10-07 20:09:52.000000000 +0000 @@ -15,7 +15,6 @@ #include #include "System/creg/creg_cond.h" -#include "gmlcnf.h" #include #include @@ -28,8 +27,6 @@ ///////////////////////////////////////////////////////// -#if !defined(USE_GML) || !GML_ENABLE_SIM - template class ThreadListSimRender { private: @@ -38,7 +35,7 @@ typedef typename std::vector::const_iterator VecIT; public: - CR_DECLARE_STRUCT(ThreadListSimRender); + CR_DECLARE_STRUCT(ThreadListSimRender) void PostLoad() {}; @@ -181,7 +178,7 @@ typedef typename std::vector::const_iterator VecIT; public: - CR_DECLARE_STRUCT(ThreadListRender); + CR_DECLARE_STRUCT(ThreadListRender) ~ThreadListRender() { clear(); @@ -275,7 +272,7 @@ typedef std::map TMapC; public: - CR_DECLARE_STRUCT(ThreadMapRender); + CR_DECLARE_STRUCT(ThreadMapRender) ~ThreadMapRender() { clear(); @@ -316,655 +313,6 @@ TMapC contRender; }; - -template -class ThreadVectorSimRender { -private: - typedef typename std::vector::iterator VectorIT; - typedef typename std::vector::const_iterator constIT; - -public: - CR_DECLARE_STRUCT(ThreadVectorSimRender); - - void PostLoad() {}; - - //! SIMULATION/SYNCED METHODS - void push(const T& x) { - cont.push_back(x); - } - - VectorIT insert(VectorIT& it, const T& x) { - if (it != cont.end()) { - //! fast insert - cont.push_back(*it); - *it = x; - return it; - } - return cont.insert(it, x); - } - - VectorIT erase(VectorIT& it) { - VectorIT ito = it++; - if (it == cont.end()) { - cont.pop_back(); - return cont.end(); - } - *ito = cont.back(); - cont.pop_back(); - return ito; - } - - void resize(const size_t& s) { - cont.resize(s); - } - - size_t size() const { - return cont.size(); - } - - bool empty() const { - return cont.empty(); - } - - VectorIT begin() { - return cont.begin(); - } - - VectorIT end() { - return cont.end(); - } - -public: - //! RENDER/UNSYNCED METHODS - inline void update() const { - } - - size_t render_size() const { - return cont.size(); - } - - bool render_empty() const { - return cont.empty(); - } - - constIT render_begin() const { - return cont.begin(); - } - - constIT render_end() const { - return cont.end(); - } - -public: - typedef VectorIT iterator; - typedef constIT render_iterator; - -//private: -public: - std::vector cont; -}; - -#else - -template -class ThreadListSimRender { -private: - typedef typename C::iterator SimIT; - typedef typename R::const_iterator RenderIT; - typedef typename std::set::const_iterator constSetIT; - typedef typename std::set::iterator SetIT; - typedef typename std::vector::const_iterator VecIT; - -public: - CR_DECLARE_STRUCT(ThreadListSimRender); - - ~ThreadListSimRender() { - clear(); - } - - void clear() { - for(SimIT it = cont.begin(); it != cont.end(); ++it) - delete *it; - for (VecIT it = delRender.begin(); it != delRender.end(); ++it) - delete *it; - for (SetIT it = postDelRender.begin(); it != postDelRender.end(); ++it) - delete *it; - } - - void PostLoad() { - for (SimIT it = cont.begin(); it != cont.end(); ++it) { - preAddRender.insert(*it); - } - } - - //! SIMULATION/SYNCED METHODS - void push(const T& x) { - preAddRender.insert(x); - cont.push_back(x); - } - void insert(const T& x) { - preAddRender.insert(x); - cont.insert(x); - } - - SimIT insert(SimIT& it, const T& x) { - preAddRender.insert(x); - return cont.insert(it, x); - } - - // keep same deletion order in MT and non-MT version to reduce risk for desync - SimIT erase_delete_synced(SimIT& it) { - delRender.push_back(*it); - return cont.erase(it); - } - - SimIT erase_delete_set_synced(SimIT& it) { - delRender.push_back(*it); - return set_erase(cont, it); - } - - bool can_delete_synced() { - return !delRender.empty(); - } - - void delete_erased_synced() { - for (VecIT it = delRender.begin(); it != delRender.end(); ++it) { - T s = *it; - if(!contRender.erase(s) && !addRender.erase(s) && !preAddRender.erase(s)) - assert(false); - delete s; - } - delRender.clear(); - } - - void resize(const size_t& s) { - cont.resize(s); - } - - size_t size() const { - return cont.size(); - } - - bool empty() const { - return cont.empty(); - } - - SimIT begin() { - return cont.begin(); - } - - SimIT end() { - return cont.end(); - } - -public: - //! RENDER/UNSYNCED METHODS - void delay_add() { - for (constSetIT it = preAddRender.begin(); it != preAddRender.end(); ++it) { - addRender.insert(*it); - } - preAddRender.clear(); - } - - void add_delayed() { - for (constSetIT it = addRender.begin(); it != addRender.end(); ++it) { - contRender.insert(*it); - } - addRender.clear(); - } - - bool can_delay_add() { - return !preAddRender.empty(); - } - - SimIT erase_delete(SimIT& it) { - delRender.push_back(*it); - return cont.erase(it); - } - - SimIT erase_delete_set(SimIT& it) { - delRender.push_back(*it); - return set_erase(cont, it); - } - - bool can_delete() { - return !delRender.empty(); - } - - void delete_erased() { - for (VecIT it = delRender.begin(); it != delRender.end(); ++it) { - T s = *it; - if(!contRender.erase(s) && !addRender.erase(s) && !preAddRender.erase(s)) - assert(false); - delete s; - } - delRender.clear(); - } - - void delay_delete() { - for (VecIT it = delRender.begin(); it != delRender.end(); ++it) { - postDelRender.insert(*it); - } - delRender.clear(); - } - - void delete_delayed() { - for (SetIT it = postDelRender.begin(); it != postDelRender.end();) { - T s = *it; - if(contRender.erase(s) || addRender.erase(s)) { - it = set_erase(postDelRender, it); - delete s; - } - else - ++it; - } - } - - size_t render_size() const { - return contRender.size(); - } - - bool render_empty() const { - return contRender.empty(); - } - - RenderIT render_begin() const { - return contRender.begin(); - } - - RenderIT render_end() const { - return contRender.end(); - } - -public: - typedef SimIT iterator; - typedef RenderIT render_iterator; - -public: //!needed by CREG - C cont; - -private: - std::set preAddRender; - std::set addRender; - R contRender; - std::vector delRender; - std::set postDelRender; -}; - - -template -class ThreadVectorSimRender { -private: - typedef typename std::vector::iterator SimIT; - typedef typename std::set::const_iterator RenderIT; - typedef typename std::set::const_iterator constSetIT; - -public: - CR_DECLARE_STRUCT(ThreadVectorSimRender); - - void PostLoad() { - for (SimIT it = cont.begin(); it != cont.end(); ++it) { - addRender.insert(*it); - } - } - - //! SIMULATION/SYNCED METHODS - void push(const T& x) { - cont.push_back(x); - addRender.insert(x); - } - - SimIT insert(SimIT& it, const T& x) { - addRender.insert(x); - if (it != cont.end()) { - //! fast insert - cont.push_back(*it); - *it = x; - return it; - } - return cont.insert(it, x); - } - - SimIT erase(SimIT& it) { - delRender.insert(*it); - - SimIT ito = it++; - if (it == cont.end()) { - cont.pop_back(); - return cont.end(); - } - *ito = cont.back(); - cont.pop_back(); - return ito; - } - - void resize(const size_t& s) { - cont.resize(s); - } - - size_t size() const { - return cont.size(); - } - - bool empty() const { - return cont.empty(); - } - - SimIT begin() { - return cont.begin(); - } - - SimIT end() { - return cont.end(); - } - -public: - //! RENDER/UNSYNCED METHODS - inline void update() { - for (constSetIT it = addRender.begin(); it != addRender.end(); ++it) - { - contRender.insert(*it); - } - addRender.clear(); - for (constSetIT it = delRender.begin(); it != delRender.end(); ++it) - { - contRender.erase(*it); - } - delRender.clear(); - } - - size_t render_size() const { - return contRender.size(); - } - - bool render_empty() const { - return contRender.empty(); - } - - RenderIT render_begin() const { - return contRender.begin(); - } - - RenderIT render_end() const { - return contRender.end(); - } - -public: - typedef SimIT iterator; - typedef RenderIT render_iterator; - -public: //!needed by CREG - std::vector cont; - -private: - std::set contRender; - std::set addRender; - std::set delRender; -}; - - - - - - - - -template -class ThreadListRender { -private: - typedef typename std::set::const_iterator constSetIT; - typedef typename std::set::iterator SetIT; - typedef typename std::vector::const_iterator VecIT; - typedef typename std::vector::const_iterator VecITC; - typedef typename std::vector::iterator VecITT; - -public: - CR_DECLARE_STRUCT(ThreadListRender); - - ~ThreadListRender() { - clear(); - } - - void clear() { - delay_delete(); - for(typename R::iterator it = contRender.begin(); it!=contRender.end(); ++it) - addRender.insert(*it); - contRender.clear(); - delete_delayed(); - } - - void PostLoad() { - } - - //! SIMULATION/SYNCED METHODS - void push(const T& x) { - preAddRender.insert(x); - } - void insert(const T& x) { - preAddRender.insert(x); - } - - void erase_remove_synced(const T& x) { - removeRender.push_back(x); - } - - void remove_erased_synced() { - for (VecIT it = removeRender.begin(); it != removeRender.end(); ++it) { - T s = *it; - size_t d; - if(!(d = contRender.erase(s)) && !addRender.erase(s) && !preAddRender.erase(s)) - assert(false); - if(d) - D::Remove(s); - } - removeRender.clear(); - } - -public: - //! RENDER/UNSYNCED METHODS - void delay_add() { - for (constSetIT it = preAddRender.begin(); it != preAddRender.end(); ++it) { - addRender.insert(*it); - } - preAddRender.clear(); - } - - void add_delayed() { - for (constSetIT it = addRender.begin(); it != addRender.end(); ++it) { - D::Add(*it); - contRender.insert(*it); - } - addRender.clear(); - } - - void erase_delete(const T& x) { - delRender.push_back(x); - } - - void delay_delete() { - for (VecIT it = delRender.begin(); it != delRender.end(); ++it) { - postDelRender.insert(*it); - } - delRender.clear(); - } - - void delete_delayed() { - for (SetIT it = postDelRender.begin(); it != postDelRender.end();) { - T s = *it; - size_t d; - if((d = contRender.erase(s)) || addRender.erase(s)) { - it = set_erase(postDelRender, it); - if(d) - D::Remove(s); - D::Delete(s); - } - else - ++it; - } - } - - void enqueue(const T& x) { - simQueue.push_back(x); - } - - void delay() { - for (VecIT it = simQueue.begin(); it != simQueue.end(); ++it) { - sharedQueue.push_back(*it); - } - simQueue.clear(); - } - - void execute() { - for (VecIT it = sharedQueue.begin(); it != sharedQueue.end(); ++it) { - D::Add(*it); - } - sharedQueue.clear(); - } - - void clean() { - clean(&simDelQueue); - } - - void clean(std::vector *delQueue) { - delay(); - for (VecITT it = sharedQueue.begin(); it != sharedQueue.end(); ) { - bool found = false; - for (VecITC it2 = delQueue->begin(); it2 != delQueue->end(); ++it2) { - if(*it == *it2) { - found = true; - break; - } - } - if(found) - it = sharedQueue.erase(it); - else - ++it; - } - } - - std::vector *to_destroy() { - return &simDelQueue; - } - - void dequeue(const C& x) { - simDelQueue.push_back(x); - } - - void dequeue_synced(const C& x) { - simDelQueue.push_back(x); - } - - void destroy() { - for (VecITC it = simDelQueue.begin(); it != simDelQueue.end(); ++it) { - D::Remove(*it); - } - simDelQueue.clear(); - } - - void destroy_synced() { - for (VecITC it = simDelQueue.begin(); it != simDelQueue.end(); ++it) { - D::Remove(*it); - } - simDelQueue.clear(); - } - -private: - std::vector simQueue; - std::vector sharedQueue; - std::vector simDelQueue; - - std::set preAddRender; - std::set addRender; - R contRender; - std::vector delRender; - std::set postDelRender; - std::vector removeRender; -}; - - - -template -class ThreadMapRender { -private: - typedef std::map TMapC; - typedef std::map TMap; - typedef std::set TSet; - typedef typename TMap::const_iterator constMapIT; - typedef typename TMap::iterator MapIT; - typedef typename TSet::const_iterator constSetIT; - typedef typename TSet::iterator SetIT; - -public: - CR_DECLARE_STRUCT(ThreadMapRender); - - ~ThreadMapRender() { - clear(); - } - - const TMapC& get_render_map() const { return contRender; } - - void clear() { - } - - void PostLoad() { - } - - //! SIMULATION/SYNCED METHODS - void push(const C& x, const V& y) { - preAddRender[x] = y; - } - -public: - //! RENDER/UNSYNCED METHODS - void delay_add() { - for (constMapIT it = preAddRender.begin(); it != preAddRender.end(); ++it) { - addRender[it->first] = it->second; - } - preAddRender.clear(); - } - - void add_delayed() { - for (constMapIT it = addRender.begin(); it != addRender.end(); ++it) { - contRender[I::Index(it->first)] = it->second; - } - addRender.clear(); - } - - void erase_delete(const C& x) { - delRender.insert(x); - } - - void delay_delete() { - for (constSetIT it = delRender.begin(); it != delRender.end(); ++it) { - postDelRender.insert(*it); - } - delRender.clear(); - } - - void delete_delayed() { - for (SetIT it = postDelRender.begin(); it != postDelRender.end();) { - C s = *it; - if((contRender.erase(I::Index(s))) || addRender.erase(s)) { - it = set_erase(postDelRender, it); - } - else { - ++it; - } - } - } - -private: - TMap preAddRender; - TMap addRender; - TMapC contRender; - TSet delRender; - TSet postDelRender; -}; - -#endif - - - template class ThreadListSim { private: @@ -974,7 +322,7 @@ typedef typename std::vector::const_iterator VecIT; public: - CR_DECLARE_STRUCT(ThreadListSim); + CR_DECLARE_STRUCT(ThreadListSim) ~ThreadListSim() { clear(); @@ -1030,9 +378,7 @@ void detach_erased_synced() { for (VecIT it = del.begin(); it != del.end(); ++it) { D::Detach(*it); -#if !defined(USE_GML) || !GML_ENABLE_SIM delete *it; -#endif } del.clear(); } @@ -1058,18 +404,12 @@ } SimIT erase_delete(SimIT& it) { -#if !defined(USE_GML) || !GML_ENABLE_SIM delete *it; -#endif return cont.erase(it); } SimIT erase_detach(SimIT& it) { -#if !defined(USE_GML) || !GML_ENABLE_SIM delete *it; -#else - D::Detach(*it); -#endif return cont.erase(it); } diff -Nru spring-96.0~14.04~ppa4/rts/lib/headlessStubs/CMakeLists.txt spring-98.0~14.04~ppa6/rts/lib/headlessStubs/CMakeLists.txt --- spring-96.0~14.04~ppa4/rts/lib/headlessStubs/CMakeLists.txt 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/headlessStubs/CMakeLists.txt 2014-10-07 20:09:52.000000000 +0000 @@ -10,13 +10,13 @@ # We still need these header files, # even if we are not going to link with SDL. # We have them available anyway (mingwlibs). - FIND_PACKAGE(SDL REQUIRED) - INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR}) + FIND_PACKAGE(SDL2 REQUIRED) + INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR}) ELSE (WIN32) # Use a direct copy of the GL and SDL headers, # as these may not be available on headless systems. INCLUDE_DIRECTORIES(BEFORE ${CMAKE_SOURCE_DIR}/include) - INCLUDE_DIRECTORIES(BEFORE ${CMAKE_SOURCE_DIR}/include/SDL) + INCLUDE_DIRECTORIES(BEFORE ${CMAKE_SOURCE_DIR}/include/SDL2) ENDIF (WIN32) ADD_LIBRARY(headlessStubs STATIC EXCLUDE_FROM_ALL ${headlessStubsSources}) diff -Nru spring-96.0~14.04~ppa4/rts/lib/headlessStubs/sdlstub.c spring-98.0~14.04~ppa6/rts/lib/headlessStubs/sdlstub.c --- spring-96.0~14.04~ppa4/rts/lib/headlessStubs/sdlstub.c 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/headlessStubs/sdlstub.c 2014-10-07 20:09:52.000000000 +0000 @@ -5,7 +5,7 @@ * http://www.libsdl.org/docs/html/ */ -#include "SDL.h" +#include #ifdef __cplusplus @@ -22,17 +22,19 @@ static struct SDL_RWops stubRWops; static Uint8 stubKeyState[0]; static SDL_version stubVersion; -static SDL_VideoInfo stubVideo; static Uint32 stubSubSystemsInit = 0; + +extern DECLSPEC void SDLCALL SDL_free(void* p) { + return; +} + extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags) { startSystemMilliSeconds = stub_sdl_getSystemMilliSeconds(); stubSurface.w = 512; stubSurface.h = 512; - stubVideo.current_w = 512; - stubVideo.current_h = 512; stubSubSystemsInit = SDL_INIT_EVERYTHING; return 0; @@ -46,7 +48,7 @@ return 0; } -extern DECLSPEC char* SDLCALL SDL_GetError() { +extern DECLSPEC const char* SDLCALL SDL_GetError() { return "using the SDL stub library"; } @@ -54,12 +56,9 @@ return 0; } -extern DECLSPEC SDL_Surface* SDLCALL SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) { - return &stubSurface; -} - -extern DECLSPEC const SDL_VideoInfo* SDLCALL SDL_GetVideoInfo(void) { - return &stubVideo; +extern DECLSPEC SDL_Window* SDLCALL SDL_CreateWindow(const char* title, int x, int y, int w, int h, Uint32 flags) { + static int foo; + return (SDL_Window*)(&foo); } extern DECLSPEC struct SDL_RWops* SDLCALL SDL_RWFromFile(const char* file, const char* mode) { @@ -84,7 +83,7 @@ extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface* surface) { } -extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers() { +extern DECLSPEC void SDLCALL SDL_GL_SwapWindow(SDL_Window* window) { } extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms) { @@ -95,22 +94,28 @@ return stub_sdl_getSystemMilliSeconds() - startSystemMilliSeconds; } -extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y) { +extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window* window, int x, int y) { } extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow() { return 0; } -extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int i) { +extern DECLSPEC void SDLCALL SDL_HideWindow(SDL_Window* window) { +} + +extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window* window, Uint32 flags) { return 0; } +extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window* window, SDL_bool bordered) { +} + extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int i, int j) { return 0; } -extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod i) { +extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate) { } extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event* event) { @@ -124,10 +129,13 @@ extern DECLSPEC void SDLCALL SDL_PumpEvents() { } -extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface* icon, Uint8* mask) { +extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window* window, const char* title) { +} + +extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window* window, SDL_Surface* icon) { } -extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char* title, const char* icon) { +extern DECLSPEC void SDLCALL SDL_SetWindowMinimumSize(SDL_Window* window, int min_w, int min_h) { } extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int* value) { @@ -135,24 +143,44 @@ return 0; } -extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode) { - return 0; +extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window* window) { + static int foo; + return &foo; } -extern DECLSPEC int SDLCALL SDL_GetWMInfo(void* infostruct) { - // TODO: probably needs to populate infostruct with something reasonable... +extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window* window, SDL_bool grabbed) { +} - // I _think_ this triggers SpringApp.cpp to just use the screen geometry +extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowGrab(SDL_Window* window) { return 0; } -extern DECLSPEC Uint8* SDLCALL SDL_GetKeyState(int* numkeys) { +extern DECLSPEC void SDLCALL SDL_DisableScreenSaver() { +} + +extern DECLSPEC char* SDLCALL SDL_GetClipboardText() { + return ""; +} + +extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char* text) { + return -1; +} + +extern DECLSPEC const Uint8 *SDLCALL SDL_GetKeyboardState(int* numkeys) { *numkeys = 0; return stubKeyState; } -extern DECLSPEC SDLMod SDLCALL SDL_GetModState() { +extern DECLSPEC SDL_Keymod SDLCALL SDL_GetModState() { + return 0; +} + +extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode) { + return 0; +} + +extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key) { return 0; } @@ -160,15 +188,15 @@ return &stubVersion; } -extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle) { - return 0; +extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version* ver) { + *ver = stubVersion; } -extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int* x, int* y) { +extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle) { return 0; } -extern DECLSPEC int SDLCALL SDL_SetGamma(float red, float green, float blue) { +extern DECLSPEC Uint32 SDLCALL SDL_GetMouseState(int* x, int* y) { return 0; } @@ -176,7 +204,7 @@ return 0; } -extern DECLSPEC const char* SDLCALL SDL_JoystickName(int device_index) { +extern DECLSPEC const char* SDLCALL SDL_JoystickName(SDL_Joystick* device_index) { return ""; } @@ -187,11 +215,29 @@ extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick* joystick) { } -extern DECLSPEC SDL_Rect** SDLCALL SDL_ListModes(SDL_PixelFormat* format, Uint32 flags) { - return NULL; +extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(int displayIndex) { + return 0; +} + +extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode* mode) { + mode->format = SDL_PIXELFORMAT_RGB24; + mode->w = 640; + mode->h = 480; + mode->refresh_rate = 100; + mode->driverdata = NULL; + return 0; +} + +extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window* window, SDL_DisplayMode* mode) { + return SDL_GetDesktopDisplayMode(0, mode); +} + +extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex, SDL_DisplayMode* mode) { + return SDL_GetDesktopDisplayMode(0, mode); } -extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event* events, int numevents, SDL_eventaction action, Uint32 mask) { + +extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event* events, int numevents, SDL_eventaction action, Uint32 minType, Uint32 maxType) { return 0; } @@ -199,6 +245,22 @@ return 0; } +extern DECLSPEC int SDL_GetNumVideoDisplays(void) { + return 0; +} +extern DECLSPEC int SDL_GetDisplayBounds(int displayIndex, SDL_Rect* rect) { + if (rect == 0) return -1; + rect->w = 640; + rect->h = 480; + rect->x = 0; + rect->y = 0; + return 0; +} + +extern DECLSPEC int SDL_GL_GetSwapInterval() { + return 0; +} + #ifdef __cplusplus } // extern "C" #endif diff -Nru spring-96.0~14.04~ppa4/rts/lib/lua/include/luaconf.h spring-98.0~14.04~ppa6/rts/lib/lua/include/luaconf.h --- spring-96.0~14.04~ppa4/rts/lib/lua/include/luaconf.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/lua/include/luaconf.h 2014-10-07 20:09:52.000000000 +0000 @@ -744,8 +744,8 @@ // But not a group of them, so it's possible that multiple threads modify the stack of a single lua_State and breaking each other. // Solution might be to use coroutines for each c++ thread, cause they got their own stacks and so cannot break each other. //#define luai_userstateyield(L,n) LuaMutexYield(L) - //#define lua_lock(L) LuaMutexLock(L) - //#define lua_unlock(L) LuaMutexUnlock(L) + #define lua_lock(L) LuaMutexLock(L) + #define lua_unlock(L) LuaMutexUnlock(L) #else #define luai_userstateopen(L) ((void)L) #define luai_userstateclose(L) ((void)L) diff -Nru spring-96.0~14.04~ppa4/rts/lib/lua/include/LuaInclude.h spring-98.0~14.04~ppa6/rts/lib/lua/include/LuaInclude.h --- spring-96.0~14.04~ppa4/rts/lib/lua/include/LuaInclude.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/lua/include/LuaInclude.h 2014-10-07 20:09:52.000000000 +0000 @@ -4,32 +4,47 @@ #define SPRING_LUA_INCLUDE #include +#include // strlen +#include +#include "LuaUser.h" #include "lua.h" -#include "lib/lua/src/lstate.h" #include "lualib.h" #include "lauxlib.h" +#include "lib/lua/src/lstate.h" #include "lib/streflop/streflop_cond.h" -#include "LuaUser.h" +#include "System/Log/ILog.h" + +/////////////////////////////////////////////////////////////////////////// +// A few missing lua_to..., lua_check..., lua_opt... +// + static inline void lua_pushsstring(lua_State* L, const std::string& str) { lua_pushlstring(L, str.data(), str.size()); } +static inline std::string luaL_tosstring(lua_State* L, int index) +{ + size_t len = 0; + const char* s = lua_tolstring(L, index, &len); + return std::string(s, len); +} + + static inline std::string luaL_checksstring(lua_State* L, int index) { - return std::string(luaL_checkstring(L, index), lua_strlen(L, index)); + size_t len = 0; + const char* s = luaL_checklstring(L, index, &len); + return std::string(s, len); } static inline std::string luaL_optsstring(lua_State* L, int index, const std::string& def) { - if (lua_isstring(L, index)) { - return std::string(lua_tostring(L, index), lua_strlen(L, index)); - } - return def; + return luaL_opt(L, luaL_checksstring, index, def); } @@ -66,9 +81,10 @@ { const float n = lua_tonumber(L, idx); #ifdef DEBUG + // Note: + // luaL_argerror must be called from inside of lua, else it calls exit() + // so it can't be used in LuaParser::Get...() and similar if (math::isinf(n) || math::isnan(n)) luaL_argerror(L, idx, "number expected, got NAN (check your code for div0)"); - //assert(!math::isinf(d)); - //assert(!math::isnan(d)); #endif return n; } @@ -86,21 +102,120 @@ } +static inline bool luaL_checkboolean(lua_State* L, int idx) +{ + luaL_checktype(L, idx, LUA_TBOOLEAN); + return lua_toboolean(L, idx); +} + + static inline bool luaL_optboolean(lua_State* L, int idx, bool def) { - return lua_isboolean(L, idx) ? lua_toboolean(L, idx) : def; + return luaL_opt(L, luaL_checkboolean, idx, def); } -static inline bool luaL_checkboolean(lua_State* L, int idx) + +/////////////////////////////////////////////////////////////////////////// +// A few custom safety wrappers +// + +#undef lua_pop +static inline void lua_pop(lua_State* L, const int args) { - if (!lua_isboolean(L, idx)) { - luaL_checktype(L, idx, LUA_TBOOLEAN); + assert(args > 0); // prevent lua_pop(L, -1) which is wrong, args is _count_ and not index (use lua_remove for that) + lua_settop(L, -(args)-1); // from lua.h! +} + + +static inline int luaS_absIndex(lua_State* L, const int i) +{ + if (i <= 0 && i > LUA_REGISTRYINDEX) + return lua_gettop(L) + (i) + 1; + + return i; +} + + +template +static inline T luaL_SpringOpt(lua_State* L, int idx, const T def, T(*lua_optFoo)(lua_State*, int, const T), T(*lua_toFoo)(lua_State*, int), int typeFoo, const char* caller) +{ + if (L->errorJmp) { + return (*lua_optFoo)(L, idx, def); } - return lua_toboolean(L, idx); + + T ret = (*lua_toFoo)(L, idx); + if (ret || (lua_type(L, idx) == typeFoo)) { + return ret; + } + + if (!lua_isnoneornil(L, idx)) { + LOG_L(L_WARNING, "Got wrong type for return argument #%d in \"%s::%s\" (%s expected, got %s)", luaS_absIndex(L, idx), spring_lua_getName(L), caller, lua_typename(L, typeFoo), luaL_typename(L, idx)); + } + return def; +} + + +static inline std::string luaL_SpringOptString(lua_State* L, int idx, const std::string& def, std::string(*lua_optFoo)(lua_State*, int, const std::string&), std::string(*lua_toFoo)(lua_State*, int), int typeFoo, const char* caller) +{ + if (L->errorJmp) { + return (*lua_optFoo)(L, idx, def); + } + + std::string ret = (*lua_toFoo)(L, idx); + if (!ret.empty() || (lua_type(L, idx) == typeFoo)) { + return ret; + } + + if (!lua_isnoneornil(L, idx)) { + LOG_L(L_WARNING, "Got wrong type for return argument #%d in \"%s::%s\" (%s expected, got %s)", luaS_absIndex(L, idx), spring_lua_getName(L), caller, lua_typename(L, typeFoo), luaL_typename(L, idx)); + } + return def; } +static inline const char* luaL_SpringOptCString(lua_State* L, int idx, const char* def, size_t* len, const char*(*lua_optFoo)(lua_State*, int, const char*, size_t*), const char*(*lua_toFoo)(lua_State*, int, size_t*), int typeFoo, const char* caller) +{ + if (L->errorJmp) { + return (*lua_optFoo)(L, idx, def, len); + } + + const char* ret = (*lua_toFoo)(L, idx, len); + if (ret || (lua_type(L, idx) == typeFoo)) { + return ret; + } + + if (!lua_isnoneornil(L, idx)) { + LOG_L(L_WARNING, "Got wrong type for return argument #%d in \"%s::%s\" (%s expected, got %s)", luaS_absIndex(L, idx), spring_lua_getName(L), caller, lua_typename(L, typeFoo), luaL_typename(L, idx)); + } + if (len != NULL) *len = strlen(def); + return def; +} + + +#define luaL_optboolean(L,idx,def) (luaL_SpringOpt(L,idx,def,::luaL_optboolean,lua_toboolean,LUA_TBOOLEAN,__FUNCTION__)) +#define luaL_optfloat(L,idx,def) ((float)luaL_SpringOpt(L,idx,def,::luaL_optfloat,lua_tofloat,LUA_TNUMBER,__FUNCTION__)) +#define luaL_optinteger(L,idx,def) (luaL_SpringOpt(L,idx,def,::luaL_optinteger,lua_tointeger,LUA_TNUMBER,__FUNCTION__)) +#define luaL_optlstring(L,idx,def,len) (luaL_SpringOptCString(L,idx,def,len,::luaL_optlstring,lua_tolstring,LUA_TSTRING,__FUNCTION__)) +#define luaL_optnumber(L,idx,def) (luaL_SpringOpt(L,idx,def,::luaL_optnumber,lua_tonumber,LUA_TNUMBER,__FUNCTION__)) + +#define luaL_optsstring(L,idx,def) (luaL_SpringOptString(L,idx,def,::luaL_optsstring,luaL_tosstring,LUA_TSTRING,__FUNCTION__)) + +#ifdef luaL_optint + #undef luaL_optint + #define luaL_optint(L,idx,def) ((int)luaL_SpringOpt(L,idx,def,::luaL_optinteger,lua_tointeger,LUA_TNUMBER,__FUNCTION__)) +#endif +#ifdef luaL_optstring + #undef luaL_optstring + #define luaL_optstring(L,idx,def) (luaL_SpringOptCString(L,idx,def,NULL,::luaL_optlstring,lua_tolstring,LUA_TSTRING,__FUNCTION__)) +#endif + + + +/////////////////////////////////////////////////////////////////////////// +// State creation & destruction +// + struct luaContextData; static inline luaContextData* GetLuaContextData(const lua_State* L) diff -Nru spring-96.0~14.04~ppa4/rts/lib/lua/include/LuaUser.cpp spring-98.0~14.04~ppa6/rts/lib/lua/include/LuaUser.cpp --- spring-96.0~14.04~ppa4/rts/lib/lua/include/LuaUser.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/lua/include/LuaUser.cpp 2014-10-07 20:09:52.000000000 +0000 @@ -2,52 +2,38 @@ #include #include +#include -#include "lua.h" #include "LuaInclude.h" #include "Lua/LuaHandle.h" #include "System/Platform/Threading.h" #include "System/Log/ILog.h" +#if (!defined(DEDICATED) && !defined(UNITSYNC) && !defined(BUILDING_AI)) + #include "System/Misc/SpringTime.h" +#endif + /////////////////////////////////////////////////////////////////////////// // Custom Lua Mutexes -static boost::recursive_mutex luaprimmutex, luasecmutex; static std::map mutexes; static std::map coroutines; -//static luaContextData baseLuaContextData; -static boost::recursive_mutex* GetLuaMutex(bool userMode, bool primary) +static boost::recursive_mutex* GetLuaMutex(lua_State* L) { -#if (LUA_MT_OPT & LUA_MUTEX) - if (userMode) - return new boost::recursive_mutex(); - else // LuaGaia & LuaRules will share mutexes to avoid deadlocks during XCalls etc. - return primary ? &luaprimmutex : &luasecmutex; -#else - return &luaprimmutex; //FIXME all luaStates share the same mutex??? -#endif + assert(!mutexes[L]); + return new boost::recursive_mutex(); } void LuaCreateMutex(lua_State* L) { - if (!GetLuaContextData(L)) - return; - luaContextData* lcd = GetLuaContextData(L); + if (!lcd) return; // CLuaParser + assert(lcd); - //FIXME when using Lua's lua_lock system it might be a bit inefficient to do a null check each call, - // so better link to a dummy one instead. - // Problem is that luaContextData links a lot rendering related files (LuaTextures, LuaFBOs, ...) - // which aren't linked in unitsync. - /*if (!lcd) { - G(L)->ud = &baseLuaContextData; - lcd = &baseLuaContextData; - }*/ - - boost::recursive_mutex* mutex = GetLuaMutex((lcd->owner == NULL) ? true : lcd->owner->GetUserMode(), lcd->primary); + boost::recursive_mutex* mutex = GetLuaMutex(L); lcd->luamutex = mutex; mutexes[L] = mutex; } @@ -55,21 +41,18 @@ void LuaDestroyMutex(lua_State* L) { - if (!GetLuaContextData(L)) - return; - - if (!L) - return; + if (!GetLuaContextData(L)) return; // CLuaParser + assert(GetLuaContextData(L)); if (coroutines.find(L) != coroutines.end()) { mutexes.erase(L); coroutines.erase(L); } else { - assert(coroutines.find(L) == coroutines.end()); + lua_unlock(L); assert(mutexes.find(L) != mutexes.end()); boost::recursive_mutex* mutex = GetLuaContextData(L)->luamutex; - if ((mutex != &luaprimmutex) && (mutex != &luasecmutex)) - delete mutex; + assert(mutex); + delete mutex; mutexes.erase(L); //TODO erase all related coroutines too? } @@ -78,18 +61,22 @@ void LuaLinkMutex(lua_State* L_parent, lua_State* L_child) { - if (!GetLuaContextData(L_parent)) - return; + luaContextData* plcd = GetLuaContextData(L_parent); + assert(plcd); + + luaContextData* clcd = GetLuaContextData(L_child); + assert(clcd); + + assert(plcd == clcd); coroutines[L_child] = true; - mutexes[L_child] = mutexes[L_parent]; + mutexes[L_child] = plcd->luamutex; } void LuaMutexLock(lua_State* L) { - if (!GetLuaContextData(L)) - return; + if (!GetLuaContextData(L)) return; // CLuaParser boost::recursive_mutex* mutex = GetLuaContextData(L)->luamutex; @@ -104,8 +91,7 @@ void LuaMutexUnlock(lua_State* L) { - if (!GetLuaContextData(L)) - return; + if (!GetLuaContextData(L)) return; // CLuaParser boost::recursive_mutex* mutex = GetLuaContextData(L)->luamutex; mutex->unlock(); @@ -114,8 +100,7 @@ void LuaMutexYield(lua_State* L) { - if (!GetLuaContextData(L)) - return; + assert(GetLuaContextData(L)); /*mutexes[L]->unlock(); if (!mutexes[L]->try_lock()) { // only yield if another thread is waiting for the mutex @@ -124,17 +109,27 @@ }*/ static int count = 0; - bool yield = false; + bool y = false; + if (count-- <= 0) { y = true; count = 30; } + LuaMutexUnlock(L); - if ((yield = ((count--) <= 0))) - count = 30; + if (y) boost::this_thread::yield(); + LuaMutexLock(L); +} - LuaMutexUnlock(L); - if (yield) - boost::this_thread::yield(); +/////////////////////////////////////////////////////////////////////////// +// - LuaMutexLock(L); +const char* spring_lua_getName(lua_State* L) +{ + auto ld = GetLuaContextData(L); + if (ld) { + return ld->owner->GetName().c_str(); + } + + static const char* c = ""; + return c; } @@ -146,19 +141,9 @@ static Threading::AtomicCounterInt64 totalNumLuaAllocs = 0; static Threading::AtomicCounterInt64 totalLuaAllocTime = 0; -// 64-bit systems are less constrained -static const unsigned int maxAllocedBytes = 768u * 1024u*1024u * (1u + (sizeof(void*) == 8)); +static const unsigned int maxAllocedBytes = 768u * 1024u*1024u; static const char* maxAllocFmtStr = "%s: cannot allocate more memory! (%u bytes already used, %u bytes maximum)"; -size_t spring_lua_states() { return (mutexes.size() - coroutines.size()); } - -void spring_lua_update_context(luaContextData* lcd, size_t osize, size_t nsize) { - if (lcd == NULL) - return; - - lcd->maxAllocedBytes = maxAllocedBytes / std::max(size_t(1), spring_lua_states()); - lcd->curAllocedBytes += (nsize - osize); -} void* spring_lua_alloc(void* ud, void* ptr, size_t osize, size_t nsize) { @@ -166,31 +151,18 @@ if (nsize == 0) { totalBytesAlloced -= osize; - - spring_lua_update_context(lcd, osize, 0); free(ptr); return NULL; } - if (lcd != NULL) { - if ((nsize > osize) && (lcd->curAllocedBytes > lcd->maxAllocedBytes)) { - LOG_L(L_FATAL, maxAllocFmtStr, (lcd->owner->GetName()).c_str(), lcd->curAllocedBytes, lcd->maxAllocedBytes); - - // better kill Lua than whole engine - return NULL; - } - - // allow larger allocation limit per state if fewer states - // but do not allow one single state to soak up all memory - // TODO: non-uniform distribution of limits per state - spring_lua_update_context(lcd, osize, nsize); + if ((nsize > osize) && (totalBytesAlloced > maxAllocedBytes)) { + // better kill Lua than whole engine + // NOTE: this will trigger luaD_throw --> exit(EXIT_FAILURE) + LOG_L(L_FATAL, maxAllocFmtStr, (lcd->owner->GetName()).c_str(), totalBytesAlloced, maxAllocedBytes); + return NULL; } - #if (!defined(HEADLESS) && !defined(DEDICATED) && !defined(UNITSYNC) && !defined(BUILDING_AI)) - // FIXME: - // the Lua lib is compiled with its own makefile and does not inherit these definitions, yet - // somehow unitsync compiles (despite not linking against GlobalSynced) but dedserv does not - // if gs is referenced + #if (!defined(DEDICATED) && !defined(UNITSYNC) && !defined(BUILDING_AI)) const spring_time t0 = spring_gettime(); void* mem = realloc(ptr, nsize); const spring_time t1 = spring_gettime(); diff -Nru spring-96.0~14.04~ppa4/rts/lib/lua/include/LuaUser.h spring-98.0~14.04~ppa6/rts/lib/lua/include/LuaUser.h --- spring-96.0~14.04~ppa4/rts/lib/lua/include/LuaUser.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/lua/include/LuaUser.h 2014-10-07 20:09:52.000000000 +0000 @@ -3,6 +3,8 @@ #ifndef SPRING_LUA_USER_H #define SPRING_LUA_USER_H +#include "lua.h" + extern void LuaCreateMutex(lua_State* L); extern void LuaDestroyMutex(lua_State* L); extern void LuaLinkMutex(lua_State* L_parent, lua_State* L_child); @@ -10,6 +12,7 @@ extern void LuaMutexUnlock(lua_State* L); extern void LuaMutexYield(lua_State* L); +extern const char* spring_lua_getName(lua_State* L); struct SLuaInfo { unsigned int allocedBytes; diff -Nru spring-96.0~14.04~ppa4/rts/lib/lua/src/lmathlib.cpp spring-98.0~14.04~ppa6/rts/lib/lua/src/lmathlib.cpp --- spring-96.0~14.04~ppa4/rts/lib/lua/src/lmathlib.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/lua/src/lmathlib.cpp 2014-10-07 20:09:52.000000000 +0000 @@ -192,25 +192,11 @@ } -static int lua_streflop_random_seed = 0; static int math_random (lua_State *L) { /* the `%' avoids the (rare) case of r==1, and is needed also because on some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */ - -//SPRING -// respect the original lua code that uses rand, -// and rand is auto-seeded always with the same value -#ifdef STREFLOP_H - if (lua_streflop_random_seed == 0) { - lua_streflop_random_seed = 1; - math::RandomInit(1); // streflop - } - - lua_Number r = math::Random(lua_Number(0.0), lua_Number(1.0)); // streflop -#else - lua_Number r = 0.0f; -#endif + lua_Number r = (lua_Number)(rand()%RAND_MAX) / (lua_Number)RAND_MAX; switch (lua_gettop(L)) { /* check number of arguments */ case 0: { /* no arguments */ lua_pushnumber(L, r); /* Number between 0 and 1 */ @@ -235,11 +221,7 @@ } static int math_randomseed (lua_State *L) { -//SPRING srand(luaL_checkint(L, 1)); -#ifdef STREFLOP_H - math::RandomInit(luaL_checkint(L, 1)); // streflop -#endif - + srand(luaL_checkint(L, 1)); return 0; } diff -Nru spring-96.0~14.04~ppa4/rts/lib/luasocket/src/inet.cpp spring-98.0~14.04~ppa6/rts/lib/luasocket/src/inet.cpp --- spring-96.0~14.04~ppa4/rts/lib/luasocket/src/inet.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/luasocket/src/inet.cpp 2014-10-07 20:09:52.000000000 +0000 @@ -282,11 +282,8 @@ \*-------------------------------------------------------------------------*/ const char *inet_trybind(p_socket ps, const char *address, unsigned short port) { - /* - // bind is always allowed if (!isAllowed(ps, address, port, false)) return "bind denied"; - */ struct sockaddr_in local; int err; diff -Nru spring-96.0~14.04~ppa4/rts/lib/luasocket/src/restrictions.cpp spring-98.0~14.04~ppa6/rts/lib/luasocket/src/restrictions.cpp --- spring-96.0~14.04~ppa4/rts/lib/luasocket/src/restrictions.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/luasocket/src/restrictions.cpp 2014-10-07 20:09:52.000000000 +0000 @@ -8,6 +8,9 @@ #include "System/Log/ILog.h" #include "System/Config/ConfigHandler.h" +#define WILDCARD_HOST "*" +#define WILDCARD_PORT -1 + #ifndef TEST #define LOG_SECTION_LUASOCKET "LuaSocket" LOG_REGISTER_SECTION_GLOBAL(LOG_SECTION_LUASOCKET) @@ -16,10 +19,10 @@ #endif #define LOG_SECTION_CURRENT LOG_SECTION_LUASOCKET -CONFIG(std::string, TCPAllowConnect).defaultValue("").readOnly(true); -CONFIG(std::string, TCPAllowListen).defaultValue("").readOnly(true); +CONFIG(std::string, TCPAllowConnect).defaultValue(WILDCARD_HOST).readOnly(true); +CONFIG(std::string, TCPAllowListen).defaultValue(WILDCARD_HOST).readOnly(true); CONFIG(std::string, UDPAllowConnect).defaultValue("").readOnly(true); -CONFIG(std::string, UDPAllowListen).defaultValue("").readOnly(true); +CONFIG(std::string, UDPAllowListen).defaultValue(WILDCARD_HOST).readOnly(true); #endif CLuaSocketRestrictions* luaSocketRestrictions=0; @@ -28,23 +31,24 @@ { #ifndef TEST addRules(TCP_CONNECT, configHandler->GetString("TCPAllowConnect")); -// addRules(TCP_LISTEN, configHandler->GetString("TCPAllowListen")); + addRules(TCP_LISTEN, configHandler->GetString("TCPAllowListen")); addRules(UDP_CONNECT, configHandler->GetString("UDPAllowConnect")); -// addRules(UDP_LISTEN, configHandler->GetString("UDPAllowListen")); + addRules(UDP_LISTEN, configHandler->GetString("UDPAllowListen")); #endif } void CLuaSocketRestrictions::addRule(RestrictType type, const std::string& hostname, int port, bool allowed) { - if ((port<=0) || (port>65535)){ + if ((port != WILDCARD_PORT) && ((port<=0) || (port>65535))){ LOG_L(L_ERROR, "Invalid port specified: %d", port); return; } - if (getRule(type, hostname.c_str(), port)!=NULL) { + const TSocketRule* rule = getRule(type, hostname.c_str(), port); + if ((rule != NULL) && (rule->allowed == allowed)) { LOG_L(L_ERROR, "Rule already exists: %s %d", hostname.c_str(), port); return; } - LOG("Adding rule %d %s:%d",type, hostname.c_str(), port); + if (!allowed) { //add deny rules to the front of the list restrictions[type].push_front(TSocketRule(hostname, port, allowed)); } else { @@ -54,6 +58,11 @@ void CLuaSocketRestrictions::addRule(RestrictType type, const std::string& rule) { + if (rule == WILDCARD_HOST) { //allow everything + restrictions[type].push_back(TSocketRule(WILDCARD_HOST, WILDCARD_PORT, true)); + return; + } + size_t delimpos = rule.find(":"); if (delimpos==std::string::npos) { LOG_L(L_ERROR, "Invalid %d rule: %s, rule has to be hostname:port", type, rule.c_str()); @@ -66,11 +75,10 @@ void CLuaSocketRestrictions::addRules(RestrictType type, const std::string& configstr) { - int i=0; - char ch; std::string rule; - while((ch=configstr[i++])) { + for(int i=0; i < configstr.length(); i++) { + const char ch = configstr[i]; if ((isspace(ch)) && (!rule.empty())) { addRule(type, rule); rule = ""; @@ -111,13 +119,11 @@ end = ALL_RULES; } for (int i=start; i::iterator it; for(it = restrictions[i].begin(); it != restrictions[i].end(); ++it) { - TSocketRule &rule = *it; - if (hostname == rule.hostname) { - if ((rule.port==-1) || (port == -1)) { // port ignored - return &rule; - } else if (rule.port==port) { + const TSocketRule& rule = *it; + if ((hostname == rule.hostname) || (rule.hostname == WILDCARD_HOST)) { + if ((rule.port == WILDCARD_PORT) || (rule.port == port)) { return &rule; } } @@ -130,7 +136,7 @@ void CLuaSocketRestrictions::addIP(const char* hostname, const char* ip) { for(int i=0; i::iterator it; for(it = restrictions[i].begin(); it != restrictions[i].end(); ++it) { const TSocketRule &rule = *it; if ((rule.hostname == hostname) && (getRule((RestrictType)i, ip, rule.port) == NULL)) { //add rule with ip, when not exisitng @@ -159,7 +165,7 @@ { LOG("Dumping luasocket rules:"); for(int i=0; i::iterator it; for(it = restrictions[i].begin(); it != restrictions[i].end(); ++it) { TSocketRule &rule = *it; LOG("%s %s %s %d", ruleToStr((RestrictType)i), rule.allowed ? "ALLOW" : "DENY ", rule.hostname.c_str(), rule.port); diff -Nru spring-96.0~14.04~ppa4/rts/lib/luasocket/src/restrictions.h spring-98.0~14.04~ppa6/rts/lib/luasocket/src/restrictions.h --- spring-96.0~14.04~ppa4/rts/lib/luasocket/src/restrictions.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/lib/luasocket/src/restrictions.h 2014-10-07 20:09:52.000000000 +0000 @@ -17,10 +17,9 @@ } }; -typedef std::list TStrIntMap; - class CLuaSocketRestrictions { public: + enum RestrictType{ TCP_CONNECT=0, TCP_LISTEN, @@ -69,7 +68,7 @@ */ const char* ruleToStr(RestrictType type); - TStrIntMap restrictions[ALL_RULES]; + std::list restrictions[ALL_RULES]; }; diff -Nru spring-96.0~14.04~ppa4/rts/Lua/CMakeLists.txt spring-98.0~14.04~ppa6/rts/Lua/CMakeLists.txt --- spring-96.0~14.04~ppa4/rts/Lua/CMakeLists.txt 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -2,8 +2,8 @@ # This list was created using this *nix shell command: # > find . -name "*.cpp"" | sort SET(sources_engine_Lua + "${CMAKE_CURRENT_SOURCE_DIR}/LuaArchive.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/LuaBitOps.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/LuaCallInCheck.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/LuaConstCMD.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/LuaConstCMDTYPE.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/LuaConstCOB.cpp" @@ -17,6 +17,7 @@ "${CMAKE_CURRENT_SOURCE_DIR}/LuaHandleSynced.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/LuaIO.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/LuaInputReceiver.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/LuaInterCall.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/LuaIntro.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/LuaMaterial.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/LuaMathExtra.cpp" @@ -30,7 +31,6 @@ "${CMAKE_CURRENT_SOURCE_DIR}/LuaRulesParams.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/LuaScream.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/LuaShaders.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/LuaSyncedCall.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/LuaSyncedCtrl.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/LuaSyncedMoveCtrl.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/LuaSyncedRead.cpp" @@ -39,13 +39,12 @@ "${CMAKE_CURRENT_SOURCE_DIR}/LuaUI.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/LuaUnitDefs.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/LuaUnitRendering.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/LuaUnsyncedCall.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/LuaUnsyncedCtrl.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/LuaUnsyncedRead.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/LuaUtils.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/LuaVFS.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/LuaWeaponDefs.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/LuaZip.cpp" + PARENT_SCOPE ) -MakeGlobal(sources_engine_Lua) diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaArchive.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaArchive.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaArchive.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaArchive.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,193 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include "LuaArchive.h" + +#include "LuaInclude.h" +#include "LuaHandle.h" +#include "LuaHashString.h" +#include "LuaUtils.h" + +#include "System/FileSystem/ArchiveScanner.h" +#include "System/Util.h" + + +/******************************************************************************/ +/******************************************************************************/ + +bool LuaArchive::PushEntries(lua_State* L) +{ +#define REGISTER_LUA_CFUNC(x) \ + lua_pushstring(L, #x); \ + lua_pushcfunction(L, x); \ + lua_rawset(L, -3) + +#define REGISTER_NAMED_LUA_CFUNC(x,name) \ + lua_pushstring(L, #name); \ + lua_pushcfunction(L, x); \ + lua_rawset(L, -3) + + REGISTER_LUA_CFUNC(GetMaps); + REGISTER_LUA_CFUNC(GetGames); + REGISTER_LUA_CFUNC(GetAllArchives); + REGISTER_LUA_CFUNC(HasArchive); + + REGISTER_LUA_CFUNC(GetArchiveInfo); + REGISTER_LUA_CFUNC(GetArchiveDependencies); + REGISTER_LUA_CFUNC(GetArchiveReplaces); + + REGISTER_LUA_CFUNC(GetArchiveChecksum); + + return true; +} + + + +/******************************************************************************/ +/******************************************************************************/ + +int LuaArchive::GetMaps(lua_State* L) +{ + const auto& list = archiveScanner->GetMaps(); + lua_createtable(L, list.size(), 0); + + unsigned int count = 0; + for (const std::string& mapName: list) { + lua_pushsstring(L, mapName); + lua_rawseti(L, -2, ++count); + } + return 1; +} + + +int LuaArchive::GetGames(lua_State* L) +{ + const auto& list = archiveScanner->GetPrimaryMods(); + lua_createtable(L, list.size(), 0); + + unsigned int count = 0; + for (const CArchiveScanner::ArchiveData& gameArchData: list) { + lua_pushsstring(L, gameArchData.GetNameVersioned()); + lua_rawseti(L, -2, ++count); + } + return 1; +} + + +int LuaArchive::GetAllArchives(lua_State* L) +{ + const auto& list = archiveScanner->GetAllArchives(); + lua_createtable(L, list.size(), 0); + + unsigned int count = 0; + for (const CArchiveScanner::ArchiveData& archName: list) { + lua_pushsstring(L, archName.GetNameVersioned()); + lua_rawseti(L, -2, ++count); + } + return 1; +} + +/******************************************************************************/ +/******************************************************************************/ + +int LuaArchive::HasArchive(lua_State* L) +{ + const std::string archiveName = luaL_checksstring(L, 1); + CArchiveScanner::ArchiveData archiveData = archiveScanner->GetArchiveData(archiveName); + lua_pushboolean(L, !archiveData.IsEmpty()); + return 1; +} + +/******************************************************************************/ +/******************************************************************************/ + +int LuaArchive::GetArchiveInfo(lua_State* L) +{ + const std::string archiveName = luaL_checksstring(L, 1); + CArchiveScanner::ArchiveData archiveData = archiveScanner->GetArchiveData(archiveName); + if (archiveData.IsEmpty()) { + return 0; + } + + lua_createtable(L, 0, archiveData.GetInfo().size()); + + for (const auto& pair: archiveData.GetInfo()) { + const std::string& itemName = pair.first; + const InfoItem& itemData = pair.second; + + lua_pushsstring(L, itemName); + switch (itemData.valueType) { + case INFO_VALUE_TYPE_STRING: { + lua_pushsstring(L, itemData.valueTypeString); + } break; + case INFO_VALUE_TYPE_INTEGER: { + lua_pushinteger(L, itemData.value.typeInteger); + } break; + case INFO_VALUE_TYPE_FLOAT: { + lua_pushnumber(L, itemData.value.typeFloat); + } break; + case INFO_VALUE_TYPE_BOOL: { + lua_pushboolean(L, itemData.value.typeBool); + } break; + default: assert(false); + } + lua_rawset(L, -3); + } + + return 1; +} + + +int LuaArchive::GetArchiveDependencies(lua_State* L) +{ + const std::string archiveName = luaL_checksstring(L, 1); + CArchiveScanner::ArchiveData archiveData = archiveScanner->GetArchiveData(archiveName); + if (archiveData.IsEmpty()) { + return 0; + } + + const std::vector& dependencies = archiveData.GetDependencies(); + + unsigned int count = 0; + lua_createtable(L, dependencies.size(), 0); + + for (const std::string& dependency: dependencies) { + lua_pushsstring(L, dependency); + lua_rawseti(L, -2, ++count); + } + return 1; +} + + +int LuaArchive::GetArchiveReplaces(lua_State* L) +{ + const std::string archiveName = luaL_checksstring(L, 1); + CArchiveScanner::ArchiveData archiveData = archiveScanner->GetArchiveData(archiveName); + if (archiveData.IsEmpty()) { + return 0; + } + + const std::vector& replaces = archiveData.GetReplaces(); + + unsigned int count = 0; + lua_createtable(L, replaces.size(), 0); + + for (const std::string& replace: replaces) { + lua_pushsstring(L, replace); + lua_rawseti(L, -2, ++count); + } + return 1; +} + + +/******************************************************************************/ +/******************************************************************************/ + +int LuaArchive::GetArchiveChecksum(lua_State* L) +{ + const std::string archiveName = luaL_checksstring(L, 1); + const unsigned int checksumSingl = archiveScanner->GetSingleArchiveChecksum(archiveName); + const unsigned int checksumAccum = archiveScanner->GetArchiveCompleteChecksum(archiveName); + lua_pushsstring(L, IntToString(checksumSingl, "%X")); + lua_pushsstring(L, IntToString(checksumAccum, "%X")); + return 2; +} diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaArchive.h spring-98.0~14.04~ppa6/rts/Lua/LuaArchive.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaArchive.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaArchive.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,31 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef LUA_ARCHIVE_H +#define LUA_ARCHIVE_H + +#include + +struct lua_State; + + +class LuaArchive { + friend class CLuaIntro; + + public: + static bool PushEntries(lua_State* L); + + private: + static int GetMaps(lua_State* L); + static int GetGames(lua_State* L); + static int GetAllArchives(lua_State* L); + static int HasArchive(lua_State* L); + + static int GetArchiveInfo(lua_State* L); + static int GetArchiveDependencies(lua_State* L); + static int GetArchiveReplaces(lua_State* L); + + static int GetArchiveChecksum(lua_State* L); +}; + + +#endif /* LUA_ARCHIVE_H */ diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaCallInCheck.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaCallInCheck.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaCallInCheck.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaCallInCheck.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - - -#include "LuaCallInCheck.h" -#include "LuaInclude.h" -#include "System/Log/ILog.h" - - -/******************************************************************************/ -/******************************************************************************/ - -LuaCallInCheck::LuaCallInCheck(lua_State* _L, const char* name) -{ - L = _L; - startTop = lua_gettop(L); - funcName = name; -} - - -LuaCallInCheck::~LuaCallInCheck() -{ - const int endTop = lua_gettop(L); - if (startTop != endTop) { - LOG_L(L_WARNING, - "LuaCallInCheck mismatch for %s(): start = %i, end = %i", - funcName, startTop, endTop); - } -} - - -/******************************************************************************/ -/******************************************************************************/ - diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaCallInCheck.h spring-98.0~14.04~ppa6/rts/Lua/LuaCallInCheck.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaCallInCheck.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaCallInCheck.h 2014-10-07 20:09:51.000000000 +0000 @@ -3,41 +3,13 @@ #ifndef LUA_CALL_IN_CHECK_H #define LUA_CALL_IN_CHECK_H -#include "LuaEventBatch.h" #include "System/TimeProfiler.h" - -struct lua_State; - - -class LuaCallInCheck { - public: - LuaCallInCheck(lua_State* L, const char* funcName); - ~LuaCallInCheck(); - - private: - lua_State* L; - int startTop; - const char* funcName; -}; - +#include "LuaUtils.h" #if DEBUG_LUA -# define LUA_CALL_IN_CHECK(L, ...) SELECT_LUA_STATE(); LuaCallInCheck ciCheck((L), __FUNCTION__) +# define LUA_CALL_IN_CHECK(L, ...) LuaUtils::ScopedStackChecker ciCheck((L)); SCOPED_TIMER("Lua"); #else -# define LUA_CALL_IN_CHECK(L, ...) SCOPED_TIMER("Lua"); SELECT_LUA_STATE() -#endif - -#ifdef USE_GML // hack to add some degree of thread safety to LUA -# include "lib/gml/gml.h" -# include "lib/gml/gmlsrv.h" -# if GML_ENABLE_SIM -# undef LUA_CALL_IN_CHECK -# if DEBUG_LUA -# define LUA_CALL_IN_CHECK(L, ...) SELECT_LUA_STATE(); GML_CHECK_CALL_CHAIN(L, __VA_ARGS__); GML_DRCMUTEX_LOCK(lua); GML_CALL_DEBUGGER(); LuaCallInCheck ciCheck((L), __FUNCTION__); -# else -# define LUA_CALL_IN_CHECK(L, ...) SELECT_LUA_STATE(); GML_CHECK_CALL_CHAIN(L, __VA_ARGS__); GML_DRCMUTEX_LOCK(lua); GML_CALL_DEBUGGER(); -# endif -# endif +# define LUA_CALL_IN_CHECK(L, ...) SCOPED_TIMER("Lua"); #endif #endif /* LUA_CALL_IN_CHECK_H */ diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaConfig.h spring-98.0~14.04~ppa6/rts/Lua/LuaConfig.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaConfig.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaConfig.h 2014-10-07 20:09:51.000000000 +0000 @@ -3,45 +3,8 @@ #ifndef LUA_CONFIG_H #define LUA_CONFIG_H -#include "lib/gml/gmlcnf.h" - // set to 0 to switch to 0-based weapon // indices in LuaSynced** API functions #define LUA_WEAPON_BASE_INDEX 1 -#define LUA_MUTEX 1 -#define LUA_BATCH 2 -#define LUA_STATE 4 - -#if (defined(USE_GML) && GML_ENABLE_SIM) -#define LUA_MT_OPT ( LUA_MUTEX | LUA_BATCH | LUA_STATE ) // optimizations for faster parallel execution of separate lua_States -#elif defined(USE_LUA_MT) -#define LUA_MT_OPT ( LUA_BATCH | LUA_STATE ) -#else -#define LUA_MT_OPT 0 -#endif - -enum { - MT_LUA_FIRST = 0, - MT_LUA_DEFAULT = 0, - MT_LUA_NONE = 0, - MT_LUA_FIRSTACTIVE = 1, - MT_LUA_SINGLE = 1, - MT_LUA_SINGLE_BATCH, - MT_LUA_DUAL_EXPORT, - MT_LUA_DUAL, - MT_LUA_DUAL_ALL, - MT_LUA_DUAL_UNMANAGED, - MT_LUA_SIZE, - MT_LUA_LAST = MT_LUA_SIZE - 1 -}; -// MT_LUA_DEFAULT: Use 'luaThreadingModel' setting from modInfo (default) -// MT_LUA_NONE: N/A (single threaded) -// MT_LUA_SINGLE: Single state -// MT_LUA_SINGLE_BATCH: Single state, batching of unsynced events -// MT_LUA_DUAL_EXPORT: Dual states for synced, batching of unsynced events, synced/unsynced communication via EXPORT table and SendToUnsynced -// MT_LUA_DUAL: Dual states for synced, batching of unsynced events, synced/unsynced communication via SendToUnsynced only -// MT_LUA_DUAL_ALL: Dual states for all, all synced/unsynced communication (widgets included) via SendToUnsynced only -// MT_LUA_DUAL_UNMANAGED: Dual states for all, all synced/unsynced communication (widgets included) is unmanaged and via SendToUnsynced only - #endif // LUA_CONFIG_H diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaConstCMD.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaConstCMD.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaConstCMD.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaConstCMD.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -70,7 +70,7 @@ PUSH_CMD(RESURRECT); PUSH_CMD(CAPTURE); PUSH_CMD(AUTOREPAIRLEVEL); - PUSH_CMD(LOOPBACKATTACK); + LuaInsertDualMapPair(L, "LOOPBACKATTACK", CMD_ATTACK); // backward compability (TODO: find a way to print a warning when used!) PUSH_CMD(IDLEMODE); return true; diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaContextData.h spring-98.0~14.04~ppa6/rts/Lua/LuaContextData.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaContextData.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaContextData.h 2014-10-07 20:09:51.000000000 +0000 @@ -4,12 +4,12 @@ #define LUA_CONTEXT_DATA_H #include +#include #include "LuaShaders.h" #include "LuaTextures.h" #include "LuaFBOs.h" #include "LuaRBOs.h" -//FIXME#include "LuaVBOs.h" #include "LuaDisplayLists.h" #include "System/EventClient.h" #include "System/Log/ILog.h" @@ -162,8 +162,8 @@ : owner(NULL) , luamutex(NULL) - , primary(true) , synced(false) + , allowChanges(false) , drawingEnabled(false) , running(0) @@ -181,8 +181,8 @@ CLuaHandle* owner; boost::recursive_mutex* luamutex; - bool primary; //GML crap bool synced; + bool allowChanges; bool drawingEnabled; int running; //< is currently running? (0: not running; >0: is running) @@ -199,10 +199,8 @@ int readAllyTeam; int selectTeam; - //FIXME LuaArrays arrays; LuaShaders shaders; LuaTextures textures; - //FIXME LuaVBOs vbos; LuaFBOs fbos; LuaRBOs rbos; CLuaDisplayLists displayLists; diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaDefs.h spring-98.0~14.04~ppa6/rts/Lua/LuaDefs.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaDefs.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaDefs.h 2014-10-07 20:09:51.000000000 +0000 @@ -46,12 +46,12 @@ assert(valid_type); return ERROR_TYPE; } - DataType GetDataType(unsigned) { return INT_TYPE; } - DataType GetDataType(int) { return INT_TYPE; } - DataType GetDataType(bool) { return BOOL_TYPE; } - DataType GetDataType(float) { return FLOAT_TYPE; } - DataType GetDataType(const std::string&) { return STRING_TYPE; } -}; + template<> DataType GetDataType(unsigned) { return INT_TYPE; } + template<> DataType GetDataType(int) { return INT_TYPE; } + template<> DataType GetDataType(bool) { return BOOL_TYPE; } + template<> DataType GetDataType(float) { return FLOAT_TYPE; } + template<> DataType GetDataType(std::string) { return STRING_TYPE; } +} #define ADDRESS(name) ((const char *)&name) diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaDisplayLists.h spring-98.0~14.04~ppa6/rts/Lua/LuaDisplayLists.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaDisplayLists.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaDisplayLists.h 2014-10-07 20:09:51.000000000 +0000 @@ -4,7 +4,7 @@ #define LUA_DISPLAY_LISTS_H #include -using std::vector; +#include #include "Rendering/GL/myGL.h" @@ -82,8 +82,8 @@ GLuint id; MatrixStateData matData; }; - vector active; - vector unused; // references slots in active + std::vector active; + std::vector unused; // references slots in active }; diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaEventBatch.h spring-98.0~14.04~ppa6/rts/Lua/LuaEventBatch.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaEventBatch.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaEventBatch.h 2014-10-07 20:09:51.000000000 +0000 @@ -3,380 +3,8 @@ #ifndef LUA_EVENT_BATCH_H #define LUA_EVENT_BATCH_H -#include "lib/gml/gmlcnf.h" -#include "Sim/Units/CommandAI/Command.h" -#include "Sim/Units/Unit.h" -#include "Sim/Features/Feature.h" -#include "Sim/Projectiles/Projectile.h" +#include "System/Misc/SpringTime.h" #include "LuaConfig.h" -enum UnitEvent { - UNIT_FINISHED, - UNIT_CREATED, - UNIT_FROM_FACTORY, - UNIT_DESTROYED, - UNIT_TAKEN, - UNIT_GIVEN, - UNIT_IDLE, - UNIT_COMMAND, - UNIT_CMD_DONE, - UNIT_DAMAGED, - UNIT_EXPERIENCE, - UNIT_SEISMIC_PING, - UNIT_ENTERED_RADAR, - UNIT_ENTERED_LOS, - UNIT_LEFT_RADAR, - UNIT_LEFT_LOS, - UNIT_LOADED, - UNIT_UNLOADED, - UNIT_ENTERED_WATER, - UNIT_ENTERED_AIR, - UNIT_LEFT_WATER, - UNIT_LEFT_AIR, - UNIT_CLOAKED, - UNIT_DECLOAKED, - UNIT_MOVE_FAILED, - UNIT_EXPLOSION, - UNIT_UNIT_COLLISION, - UNIT_FEAT_COLLISION, - UNIT_STOCKPILE_CHANGED -}; - -enum FeatEvent { - FEAT_CREATED, - FEAT_DESTROYED, - FEAT_DAMAGED -}; - -enum ProjEvent { - PROJ_CREATED, - PROJ_DESTROYED -}; - -enum LogEvent { - LOG_CONSOLE_LINE -}; - -enum UIEvent { - SHOCK_FRONT -}; - - -struct LuaUnitEventBase { -public: - LuaUnitEventBase(UnitEvent eventID): id(eventID) {} - UnitEvent GetID() const { return id; } -protected: - UnitEvent id; -}; - -// TODO: FINISH ME -struct LuaUnitCreatedEvent: public LuaUnitEventBase { LuaUnitCreatedEvent(): LuaUnitEventBase(UNIT_CREATED) {} }; -struct LuaUnitFinishedEvent: public LuaUnitEventBase { LuaUnitFinishedEvent(): LuaUnitEventBase(UNIT_FINISHED) {} }; -struct LuaUnitFromFactoryEvent: public LuaUnitEventBase { LuaUnitFromFactoryEvent(): LuaUnitEventBase(UNIT_FROM_FACTORY) {} }; -struct LuaUnitDestroyedEvent: public LuaUnitEventBase { LuaUnitDestroyedEvent(): LuaUnitEventBase(UNIT_DESTROYED) {} }; -struct LuaUnitTakenEvent: public LuaUnitEventBase { LuaUnitTakenEvent(): LuaUnitEventBase(UNIT_TAKEN) {} }; -struct LuaUnitGivenEvent: public LuaUnitEventBase { LuaUnitGivenEvent(): LuaUnitEventBase(UNIT_GIVEN) {} }; -struct LuaUnitIdleEvent: public LuaUnitEventBase { LuaUnitIdleEvent(): LuaUnitEventBase(UNIT_IDLE) {} }; -struct LuaUnitCommandEvent: public LuaUnitEventBase { LuaUnitCommandEvent(): LuaUnitEventBase(UNIT_COMMAND) {} }; -struct LuaUnitCommandDoneEvent: public LuaUnitEventBase { LuaUnitCommandDoneEvent(): LuaUnitEventBase(UNIT_CMD_DONE) {} }; -struct LuaUnitDamagedEvent: public LuaUnitEventBase { LuaUnitDamagedEvent(): LuaUnitEventBase(UNIT_DAMAGED) {} }; -struct LuaUnitExperienceEvent: public LuaUnitEventBase { LuaUnitExperienceEvent(): LuaUnitEventBase(UNIT_EXPERIENCE) {} }; -struct LuaUnitSeismicPingEvent: public LuaUnitEventBase { LuaUnitSeismicPingEvent(): LuaUnitEventBase(UNIT_SEISMIC_PING) {} }; -struct LuaUnitEnteredRadarEvent: public LuaUnitEventBase { LuaUnitEnteredRadarEvent(): LuaUnitEventBase(UNIT_ENTERED_RADAR) {} }; -struct LuaUnitEnteredLosEvent: public LuaUnitEventBase { LuaUnitEnteredLosEvent(): LuaUnitEventBase(UNIT_ENTERED_LOS) {} }; -struct LuaUnitLeftRadarEvent: public LuaUnitEventBase { LuaUnitLeftRadarEvent(): LuaUnitEventBase(UNIT_LEFT_RADAR) {} }; -struct LuaUnitLeftLosEvent: public LuaUnitEventBase { LuaUnitLeftLosEvent(): LuaUnitEventBase(UNIT_LEFT_LOS) {} }; -struct LuaUnitLoadedEvent: public LuaUnitEventBase { LuaUnitLoadedEvent(): LuaUnitEventBase(UNIT_LOADED) {} }; -struct LuaUnitUnloadedEvent: public LuaUnitEventBase { LuaUnitUnloadedEvent(): LuaUnitEventBase(UNIT_UNLOADED) {} }; -struct LuaUnitEnteredWaterEvent: public LuaUnitEventBase { LuaUnitEnteredWaterEvent(): LuaUnitEventBase(UNIT_ENTERED_WATER) {} }; -struct LuaUnitEnteredAirEvent: public LuaUnitEventBase { LuaUnitEnteredAirEvent(): LuaUnitEventBase(UNIT_ENTERED_AIR) {} }; -struct LuaUnitLeftWaterEvent: public LuaUnitEventBase { LuaUnitLeftWaterEvent(): LuaUnitEventBase(UNIT_LEFT_WATER) {} }; -struct LuaUnitLeftAirEvent: public LuaUnitEventBase { LuaUnitLeftAirEvent(): LuaUnitEventBase(UNIT_LEFT_AIR) {} }; -struct LuaUnitCloakedEvent: public LuaUnitEventBase { LuaUnitCloakedEvent(): LuaUnitEventBase(UNIT_CLOAKED) {} }; -struct LuaUnitDecloakedEvent: public LuaUnitEventBase { LuaUnitDecloakedEvent(): LuaUnitEventBase(UNIT_DECLOAKED) {} }; -struct LuaUnitUnitCollisionEvent: public LuaUnitEventBase { LuaUnitUnitCollisionEvent(): LuaUnitEventBase(UNIT_UNIT_COLLISION) {} }; -struct LuaUnitFeatureCollisionEvent: public LuaUnitEventBase { LuaUnitFeatureCollisionEvent(): LuaUnitEventBase(UNIT_FEAT_COLLISION) {} }; -struct LuaUnitMoveFailedEvent: public LuaUnitEventBase { LuaUnitMoveFailedEvent(): LuaUnitEventBase(UNIT_MOVE_FAILED) {} }; -struct LuaUnitExplosionEvent: public LuaUnitEventBase { LuaUnitExplosionEvent(): LuaUnitEventBase(UNIT_EXPLOSION) {} }; // ? -struct LuaUnitStockpileChangedEvent: public LuaUnitEventBase { LuaUnitStockpileChangedEvent(): LuaUnitEventBase(UNIT_STOCKPILE_CHANGED) {} }; - - - -struct LuaFeatEventBase { -public: - LuaFeatEventBase(FeatEvent eventID): id(eventID) {} - FeatEvent GetID() const { return id; } -protected: - FeatEvent id; -}; - -struct LuaFeatureCreatedEvent: public LuaFeatEventBase { -public: - LuaFeatureCreatedEvent(const CFeature* f): LuaFeatEventBase(FEAT_CREATED) { - feature = f; - } - const CFeature* GetFeature() const { return feature; } -private: - const CFeature* feature; -}; - -struct LuaFeatureDestroyedEvent: public LuaFeatEventBase { -public: - LuaFeatureDestroyedEvent(const CFeature* f): LuaFeatEventBase(FEAT_DESTROYED) { - feature = f; - } - const CFeature* GetFeature() const { return feature; } -private: - const CFeature* feature; -}; - -struct LuaFeatureDamagedEvent: public LuaFeatEventBase { -public: - LuaFeatureDamagedEvent(const CFeature* f, const CUnit* a, float d, int wdID, int pID): LuaFeatEventBase(FEAT_DAMAGED) { - feature = f; - attacker = a; - damage = d; - weaponDefID = wdID; - projectileID = pID; - } - - const CFeature* GetFeature() const { return feature; } - const CUnit* GetAttacker() const { return attacker; } - float GetDamage() const { return damage; } - int GetWeaponDefID() const { return weaponDefID; } - int GetProjectileID() const { return projectileID; } -private: - const CFeature* feature; - const CUnit* attacker; - float damage; - int weaponDefID; - int projectileID; -}; - - - -struct LuaProjEventBase { -public: - LuaProjEventBase(ProjEvent eventID): id(eventID) {} - ProjEvent GetID() const { return id; } -protected: - ProjEvent id; -}; - -struct LuaProjCreatedEvent: public LuaProjEventBase { -public: - LuaProjCreatedEvent(const CProjectile* p): LuaProjEventBase(PROJ_CREATED) { - projectile = p; - } - const CProjectile* GetProjectile() const { return projectile; } -private: - const CProjectile* projectile; -}; - -struct LuaProjDestroyedEvent: public LuaProjEventBase { -public: - LuaProjDestroyedEvent(const CProjectile* p): LuaProjEventBase(PROJ_DESTROYED) { - projectile = p; - } - const CProjectile* GetProjectile() const { return projectile; } -private: - const CProjectile* projectile; -}; - - - -struct LuaLogEventBase { -public: - LuaLogEventBase(LogEvent eventID): id(eventID) {} - LogEvent GetID() const { return id; } -protected: - LogEvent id; -}; - -struct LuaAddConsoleLineEvent: public LuaLogEventBase { -public: - LuaAddConsoleLineEvent(const std::string& msg, const std::string& sec, int lvl): - LuaLogEventBase(LOG_CONSOLE_LINE), - message(msg), - section(sec), - level(lvl) - { - } - const std::string& GetMessage() const { return message; } - const std::string& GetSection() const { return section; } - int GetLevel() const { return level; } -private: - std::string message; - std::string section; - int level; -}; - - - -struct UIEventBase { -public: - UIEventBase(UIEvent eventID): id(eventID) {} - UIEvent GetID() const { return id; } -protected: UIEvent id; -}; - -struct UIShockFrontEvent: public UIEventBase { -public: - UIShockFrontEvent(const float3& p, float pwr, float r, float d): UIEventBase(SHOCK_FRONT) { - pos = p; - power = pwr; - aoe = r; - dist = d; - } - const float3& GetPos() const { return pos; } - float GetPower() const { return power; } - float GetAreaOfEffect() const { return aoe; } - const float* GetDistMod() const { return &dist; } -private: - float3 pos; - float power; - float aoe; - float dist; -}; - - - - - - -// FIXME: -// THIS A FUCKING RETARDED WAY OF DOING IT, UNMAINTAINABLE AND UNEXTENDIBLE -// CREATE SIMPLE DEDICATED EVENT STRUCTURES OR THROW BATCHING THE FUCK OUT -/* -struct LuaUnitEvent { - LuaUnitEvent(UnitEvent i, const CUnit* u1, const Command& c1) - : id(i) - , unit1(u1) - , bool1(false) - , int1(0) - , float1(0.0f) - , unit2(NULL) - { cmd1.reset(new Command(c1)); } - LuaUnitEvent(UnitEvent i, const CUnit* u1, int i1, const float3& p1, float f1) - : id(i) - , unit1(u1) - , bool1(false) - , int1(i1) - , float1(f1) - , unit2(NULL) - { cmd1.reset(new Command(p1)); } // store the vector as a command to save some memory - LuaUnitEvent(UnitEvent i, int i1, const float3& p1, const CUnit* u1) - : id(i) - , unit1(u1) - , bool1(false) - , int1(i1) - , float1(0.0f) - , unit2(NULL) - { cmd1.reset(new Command(p1)); } // store the vector as a command to save some memory - - UnitEvent id; - const CUnit* unit1; - bool bool1; - int int1; - float float1; - union { - const CUnit* unit2; - int int2; - const CWeapon* weapon2; - }; - boost::shared_ptr cmd1; // using a shared pointer instead of an actual object saves some memory -}; -*/ - -#define LUA_EVENT_CAST(type, event) const type& ee = static_cast(event) - -#if (LUA_MT_OPT & LUA_BATCH) - #define LUA_UNIT_BATCH_PUSH(r, unitEvent) \ - if (UseEventBatch() && Threading::IsLuaBatchThread()) { \ - GML_STDMUTEX_LOCK(ulbatch); \ - luaUnitEventBatch.push_back(unitEvent); \ - return r; \ - } - #define LUA_FEAT_BATCH_PUSH(r, featEvent) \ - if (UseEventBatch() && Threading::IsLuaBatchThread()) { \ - GML_STDMUTEX_LOCK(flbatch); \ - luaFeatEventBatch.push_back(featEvent); \ - return r; \ - } - #define LUA_PROJ_BATCH_PUSH(r, projEvent) \ - if (UseEventBatch() && Threading::IsLuaBatchThread()) { \ - GML_STDMUTEX_LOCK(plbatch); \ - luaProjEventBatch.push_back(projEvent); \ - return r; \ - } - #define LUA_FRAME_BATCH_PUSH(r, frameEvent) \ - if (UseEventBatch() && Threading::IsLuaBatchThread()) { \ - GML_STDMUTEX_LOCK(glbatch); \ - luaFrameEventBatch.push_back(frameEvent); \ - return r; \ - } - #define LUA_LOG_BATCH_PUSH(r, logEvent) \ - if (UseEventBatch() && Threading::IsLuaBatchThread()) { \ - GML_STDMUTEX_LOCK(mlbatch); \ - luaLogEventBatch.push_back(logEvent); \ - return r; \ - } - #define LUA_UI_BATCH_PUSH(r, uiEvent) \ - if (UseEventBatch() && Threading::IsLuaBatchThread()) { \ - GML_STDMUTEX_LOCK(llbatch); \ - luaUIEventBatch.push_back(uiEvent); \ - return r; \ - } -#else - #define LUA_UNIT_BATCH_PUSH(r, unitEvent) - #define LUA_FEAT_BATCH_PUSH(r, featEvent) - #define LUA_PROJ_BATCH_PUSH(r, projEvent) - #define LUA_FRAME_BATCH_PUSH(r, frameEvent) - #define LUA_LOG_BATCH_PUSH(r, logEvent) - #define LUA_UI_BATCH_PUSH(r, uiEvent) -#endif - -#if defined(USE_GML) && GML_ENABLE_SIM && GML_CALL_DEBUG - #define GML_MEASURE_LOCK_TIME(lock) spring_time luatime = spring_gettime(); lock; luatime = spring_gettime() - luatime; gmlLockTime += luatime.toMilliSecsf() -#else - #define GML_MEASURE_LOCK_TIME(lock) lock -#endif - - -#if (LUA_MT_OPT & LUA_STATE) - #define BEGIN_ITERATE_LUA_STATES() lua_State* L_Cur = L_Sim; do { lua_State * const L = L_Cur - #define END_ITERATE_LUA_STATES() if(SingleState() || L_Cur == L_Draw) break; L_Cur = L_Draw; } while(true) - #ifndef LUA_SYNCED_ONLY - #define SELECT_LUA_STATE() lua_State * const L = (SingleState() || Threading::IsSimThread()) ? L_Sim : L_Draw - #define SELECT_UNSYNCED_LUA_STATE() lua_State * const L = SingleState() ? L_Sim : L_Draw - #else - #define SELECT_LUA_STATE() - #define SELECT_UNSYNCED_LUA_STATE() - #endif - #if defined(USE_GML) && GML_ENABLE_SIM - #define GML_DRCMUTEX_LOCK(name) GML_MEASURE_LOCK_TIME(GML_OBJMUTEX_LOCK(name, GML_DRAW|GML_SIM, *GetLuaContextData(L)->)) - #else - #define GML_DRCMUTEX_LOCK(name) - #endif -#else - #define BEGIN_ITERATE_LUA_STATES() lua_State * const L = L_Sim - #define END_ITERATE_LUA_STATES() - #ifndef LUA_SYNCED_ONLY - #define SELECT_LUA_STATE() lua_State * const L = L_Sim - #define SELECT_UNSYNCED_LUA_STATE() lua_State * const L = L_Sim - #else - #define SELECT_LUA_STATE() - #define SELECT_UNSYNCED_LUA_STATE() - #endif - #define GML_DRCMUTEX_LOCK(name) GML_MEASURE_LOCK_TIME(GML_OBJMUTEX_LOCK(name, GML_DRAW|GML_SIM, *GetLuaContextData(L)->)) -#endif - -#if defined(USE_GML) && GML_ENABLE_SIM - #define GML_SELECT_LUA_STATE() SELECT_LUA_STATE() -#else - #define GML_SELECT_LUA_STATE() -#endif - #endif // LUA_EVENT_BATCH_H diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaFBOs.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaFBOs.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaFBOs.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaFBOs.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -16,7 +16,6 @@ #include "System/Log/ILog.h" #include -using std::map; /******************************************************************************/ @@ -29,9 +28,7 @@ LuaFBOs::~LuaFBOs() { - set::const_iterator it; - for (it = fbos.begin(); it != fbos.end(); ++it) { - const FBO* fbo = *it; + for (FBO* fbo: fbos) { glDeleteFramebuffersEXT(1, &fbo->id); } } @@ -155,7 +152,7 @@ } if (lua_israwstring(L, 2)) { - const string key = lua_tostring(L, 2); + const std::string key = lua_tostring(L, 2); const GLenum type = ParseAttachment(key); if (type != 0) { GLint currentFBO; @@ -215,9 +212,9 @@ /******************************************************************************/ /******************************************************************************/ -GLenum LuaFBOs::ParseAttachment(const string& name) +GLenum LuaFBOs::ParseAttachment(const std::string& name) { - static map attachMap; + static std::map attachMap; if (attachMap.empty()) { attachMap["depth"] = GL_DEPTH_ATTACHMENT_EXT; attachMap["stencil"] = GL_STENCIL_ATTACHMENT_EXT; @@ -238,7 +235,7 @@ attachMap["color14"] = GL_COLOR_ATTACHMENT14_EXT; attachMap["color15"] = GL_COLOR_ATTACHMENT15_EXT; } - map::const_iterator it = attachMap.find(name); + std::map::const_iterator it = attachMap.find(name); if (it != attachMap.end()) { return it->second; } @@ -410,7 +407,7 @@ if (lua_istable(L, table)) { for (lua_pushnil(L); lua_next(L, table) != 0; lua_pop(L, 1)) { if (lua_israwstring(L, -2)) { - const string key = lua_tostring(L, -2); + const std::string key = lua_tostring(L, -2); const GLenum type = ParseAttachment(key); if (type != 0) { ApplyAttachment(L, -1, fboPtr, type); diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaFBOs.h spring-98.0~14.04~ppa6/rts/Lua/LuaFBOs.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaFBOs.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaFBOs.h 2014-10-07 20:09:51.000000000 +0000 @@ -5,8 +5,6 @@ #include #include -using std::set; -using std::string; #include "Rendering/GL/myGL.h" @@ -24,7 +22,7 @@ public: static bool PushEntries(lua_State* L); - static GLenum ParseAttachment(const string& name); + static GLenum ParseAttachment(const std::string& name); public: struct FBO { @@ -39,7 +37,7 @@ }; private: - set fbos; + std::set fbos; private: // helpers static bool CreateMetatable(lua_State* L); diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaFeatureDefs.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaFeatureDefs.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaFeatureDefs.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaFeatureDefs.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -20,6 +20,7 @@ #include "Rendering/Models/IModelParser.h" #include "Sim/Features/Feature.h" #include "Sim/Features/FeatureHandler.h" +#include "Sim/Misc/CollisionVolume.h" #include "System/Log/ILog.h" @@ -169,26 +170,26 @@ const void* userData = lua_touserdata(L, lua_upvalueindex(1)); const FeatureDef* fd = static_cast(userData); const DataElement& elem = it->second; - const char* p = ((const char*)fd) + elem.offset; + const void* p = ((const char*)fd) + elem.offset; switch (elem.type) { case READONLY_TYPE: { lua_rawget(L, 1); return 1; } case INT_TYPE: { - lua_pushnumber(L, *((int*)p)); + lua_pushnumber(L, *reinterpret_cast(p)); return 1; } case BOOL_TYPE: { - lua_pushboolean(L, *((bool*)p)); + lua_pushboolean(L, *reinterpret_cast(p)); return 1; } case FLOAT_TYPE: { - lua_pushnumber(L, *((float*)p)); + lua_pushnumber(L, *reinterpret_cast(p)); return 1; } case STRING_TYPE: { - lua_pushsstring(L, *((string*)p)); + lua_pushsstring(L, *reinterpret_cast(p)); return 1; } case FUNCTION_TYPE: { @@ -233,7 +234,7 @@ // Definition editing const DataElement& elem = it->second; - const char* p = ((const char*)fd) + elem.offset; + const void* p = ((const char*)fd) + elem.offset; switch (elem.type) { case FUNCTION_TYPE: @@ -399,6 +400,37 @@ } +static int ColVolTable(lua_State* L, const void* data) { + auto cv = static_cast(data); + assert(cv != NULL); + + lua_newtable(L); + switch (cv->GetVolumeType()) { + case CollisionVolume::COLVOL_TYPE_ELLIPSOID: + HSTR_PUSH_STRING(L, "type", "ellipsoid"); + break; + case CollisionVolume::COLVOL_TYPE_CYLINDER: + HSTR_PUSH_STRING(L, "type", "cylinder"); + break; + case CollisionVolume::COLVOL_TYPE_BOX: + HSTR_PUSH_STRING(L, "type", "box"); + break; + } + + LuaPushNamedNumber(L, "scaleX", cv->GetScales().x); + LuaPushNamedNumber(L, "scaleY", cv->GetScales().y); + LuaPushNamedNumber(L, "scaleZ", cv->GetScales().z); + LuaPushNamedNumber(L, "offsetX", cv->GetOffsets().x); + LuaPushNamedNumber(L, "offsetY", cv->GetOffsets().y); + LuaPushNamedNumber(L, "offsetZ", cv->GetOffsets().z); + LuaPushNamedNumber(L, "boundingRadius", cv->GetBoundingRadius()); + LuaPushNamedBool(L, "defaultToSphere", cv->DefaultToSphere()); + LuaPushNamedBool(L, "defaultToFootPrint", cv->DefaultToFootPrint()); + LuaPushNamedBool(L, "defaultToPieceTree", cv->DefaultToPieceTree()); + return 1; +} + + #define TYPE_MODEL_FUNC(name, param) \ static int Model ## name(lua_State* L, const void* data) \ { \ @@ -413,15 +445,15 @@ //TYPE_MODEL_FUNC(Height, height); // ::ModelHeight() //TYPE_MODEL_FUNC(Radius, radius); // ::ModelRadius() -TYPE_MODEL_FUNC(Minx, mins.x); -TYPE_MODEL_FUNC(Midx, relMidPos.x); -TYPE_MODEL_FUNC(Maxx, maxs.x); -TYPE_MODEL_FUNC(Miny, mins.y); -TYPE_MODEL_FUNC(Midy, relMidPos.y); -TYPE_MODEL_FUNC(Maxy, maxs.y); -TYPE_MODEL_FUNC(Minz, mins.z); -TYPE_MODEL_FUNC(Midz, relMidPos.z); -TYPE_MODEL_FUNC(Maxz, maxs.z); +TYPE_MODEL_FUNC(Minx, mins.x) +TYPE_MODEL_FUNC(Midx, relMidPos.x) +TYPE_MODEL_FUNC(Maxx, maxs.x) +TYPE_MODEL_FUNC(Miny, mins.y) +TYPE_MODEL_FUNC(Midy, relMidPos.y) +TYPE_MODEL_FUNC(Maxy, maxs.y) +TYPE_MODEL_FUNC(Minz, mins.z) +TYPE_MODEL_FUNC(Midz, relMidPos.z) +TYPE_MODEL_FUNC(Maxz, maxs.z) /******************************************************************************/ @@ -436,6 +468,8 @@ const FeatureDef fd; const char* start = ADDRESS(fd); + ADD_FUNCTION("collisionVolume", fd.collisionVolume, ColVolTable); + ADD_FUNCTION("drawTypeString", fd.drawType, DrawTypeString); ADD_FUNCTION("customParams", fd.customParams, CustomParamsTable); diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaFonts.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaFonts.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaFonts.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaFonts.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -12,7 +12,7 @@ #include "LuaOpenGL.h" #include "Rendering/GL/myGL.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "System/Exceptions.h" @@ -179,10 +179,10 @@ lua_pushsstring(L, style); return 1; } else if (key == "texturewidth") { - lua_pushnumber(L, font->GetTexWidth()); + lua_pushnumber(L, font->GetTextureWidth()); return 1; } else if (key == "textureheight") { - lua_pushnumber(L, font->GetTexHeight()); + lua_pushnumber(L, font->GetTextureHeight()); return 1; } } diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaFonts.h spring-98.0~14.04~ppa6/rts/Lua/LuaFonts.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaFonts.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaFonts.h 2014-10-07 20:09:51.000000000 +0000 @@ -3,7 +3,7 @@ #ifndef LUA_FONTS_H #define LUA_FONTS_H -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" struct lua_State; diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaGaia.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaGaia.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaGaia.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaGaia.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,8 +2,8 @@ #include -#include - +#include +#include #include "LuaGaia.h" @@ -36,16 +36,18 @@ /******************************************************************************/ /******************************************************************************/ +static boost::mutex m_singleton; + + void CLuaGaia::LoadHandler() { - //FIXME GML: this needs a mutex!!! + { + std::lock_guard lk(m_singleton); + if (luaGaia) return; - if (luaGaia != NULL) { - return; + luaGaia = new CLuaGaia(); } - luaGaia = new CLuaGaia(); - if (!luaGaia->IsValid()) { FreeHandler(); } @@ -54,10 +56,14 @@ void CLuaGaia::FreeHandler() { - //FIXME GML: this needs a mutex!!! - delete luaGaia; luaGaia = NULL; -} + std::lock_guard lk(m_singleton); + if (!luaGaia) return; + auto* inst = luaGaia; + luaGaia = NULL; + inst->KillLua(); + delete inst; +} /******************************************************************************/ /******************************************************************************/ @@ -69,14 +75,12 @@ return; } - teamsLocked = true; - - SetFullCtrl(true, true); - SetFullRead(true, true); - SetCtrlTeam(AllAccessTeam, true); //teamHandler->GaiaTeamID(); - SetReadTeam(AllAccessTeam, true); - SetReadAllyTeam(AllAccessTeam, true); - SetSelectTeam(teamHandler->GaiaTeamID(), true); + SetFullCtrl(true); + SetFullRead(true); + SetCtrlTeam(CEventClient::AllAccessTeam); + SetReadTeam(CEventClient::AllAccessTeam); + SetReadAllyTeam(CEventClient::AllAccessTeam); + SetSelectTeam(teamHandler->GaiaTeamID()); Init(LuaGaiaSyncedFilename, LuaGaiaUnsyncedFilename, SPRING_VFS_MAP); } @@ -84,17 +88,7 @@ CLuaGaia::~CLuaGaia() { - if (L_Sim != NULL || L_Draw != NULL) { - Shutdown(); - KillLua(); - } - - assert(this == luaGaia); - assert(!IsValid()); - - if (killMe) { - luaGaia = NULL; - } + luaGaia = NULL; } @@ -106,9 +100,6 @@ bool CLuaGaia::AddUnsyncedCode(lua_State *L) { - /*lua_pushliteral(L, "UNSYNCED"); - lua_gettable(L, LUA_REGISTRYINDEX);*/ - return true; } diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaGaia.h spring-98.0~14.04~ppa6/rts/Lua/LuaGaia.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaGaia.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaGaia.h 2014-10-07 20:09:51.000000000 +0000 @@ -21,7 +21,7 @@ private: CLuaGaia(); - ~CLuaGaia(); + virtual ~CLuaGaia(); }; diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaHandle.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaHandle.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaHandle.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaHandle.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,6 +7,7 @@ #include "LuaUI.h" #include "LuaCallInCheck.h" +#include "LuaEventBatch.h" #include "LuaHashString.h" #include "LuaOpenGL.h" #include "LuaBitOps.h" @@ -16,7 +17,7 @@ #include "Game/GlobalUnsynced.h" #include "Game/Players/Player.h" #include "Game/Players/PlayerHandler.h" -#include "Net/Protocol/BaseNetProtocol.h" // FIXME: for MAPDRAW_* +#include "Net/Protocol/BaseNetProtocol.h" #include "Game/UI/KeyCodes.h" #include "Game/UI/KeySet.h" #include "Game/UI/KeyBindings.h" @@ -33,29 +34,32 @@ #include "Sim/Weapons/WeaponDef.h" #include "System/Config/ConfigHandler.h" #include "System/EventHandler.h" +#include "System/Exceptions.h" #include "System/GlobalConfig.h" #include "System/Rectangle.h" #include "System/ScopedFPUSettings.h" #include "System/Log/ILog.h" #include "System/Input/KeyInput.h" #include "System/FileSystem/FileHandler.h" +#include "System/Platform/SDL1_keysym.h" #include "LuaInclude.h" -#include +#include +#include #include + #include bool CLuaHandle::devMode = false; bool CLuaHandle::modUICtrl = true; -bool CLuaHandle::useDualStates = false; /******************************************************************************/ /******************************************************************************/ -static void PushTracebackFuncToRegistry(lua_State* L) +void CLuaHandle::PushTracebackFuncToRegistry(lua_State* L) { LUA_OPEN_LIB(L, luaopen_debug); HSTR_PUSH(L, "traceback"); @@ -67,25 +71,33 @@ } -CLuaHandle::CLuaHandle(const string& _name, int _order, bool _userMode) - : CEventClient(_name, _order, false) // FIXME + +static int handlepanic(lua_State *L) +{ + std::string err = luaL_optsstring(L, 1, "lua paniced"); + throw content_error(err); +} + + + +CLuaHandle::CLuaHandle(const string& _name, int _order, bool _userMode, bool _synced) + : CEventClient(_name, _order, _synced) , userMode (_userMode) , killMe (false) , callinErrors(0) { - UpdateThreading(); + D.owner = this; + D.synced = _synced; + L = LUA_OPEN(&D); - SetSynced(false, true); - D_Sim.owner = this; - D_Sim.primary = true; //GML crap - L_Sim = LUA_OPEN(&D_Sim); - D_Draw.owner = this; - D_Draw.primary = false; //GML crap - L_Draw = LUA_OPEN(&D_Draw); + L_GC = lua_newthread(L); + luaL_ref(L,LUA_REGISTRYINDEX); // needed for engine traceback - PushTracebackFuncToRegistry(L_Sim); - PushTracebackFuncToRegistry(L_Draw); + PushTracebackFuncToRegistry(L); + + // prevent lua from calling c's exit() + lua_atpanic(L, handlepanic); } @@ -93,50 +105,26 @@ { eventHandler.RemoveClient(this); - // free the lua state - KillLua(); - - for (int i = 0; i < delayedCallsFromSynced.size(); ++i) { - DelayDataDump& ddp = delayedCallsFromSynced[i]; - for (int d = 0; d < ddp.data.size(); ++d) { - LuaUtils::ShallowDataDump& sdd = ddp.data[d]; - if (sdd.type == LUA_TSTRING) - delete sdd.data.str; - } - } - delayedCallsFromSynced.clear(); -} - - -void CLuaHandle::UpdateThreading() { - int mtl = globalConfig->GetMultiThreadLua(); - useDualStates = (mtl == MT_LUA_DUAL_EXPORT || mtl == MT_LUA_DUAL || mtl == MT_LUA_DUAL_ALL || mtl == MT_LUA_DUAL_UNMANAGED); - singleState = (mtl != MT_LUA_DUAL_ALL && mtl != MT_LUA_DUAL_UNMANAGED); - copyExportTable = false; - useEventBatch = singleState && (mtl != MT_LUA_NONE && mtl != MT_LUA_SINGLE); - purgeCallsFromSyncedBatch = useDualStates && (mtl != MT_LUA_DUAL_UNMANAGED); + // KillLua() must be called before dtor!!! + assert(!IsValid()); } void CLuaHandle::KillLua() { - if (L_Draw != NULL) { - lua_State* L_Old = L_Sim; - L_Sim = L_Draw; - SetRunning(L_Draw, true); - LUA_CLOSE(L_Draw); - //SetRunning(L_Draw, false); --nope, the state is deleted - L_Draw = NULL; - L_Sim = L_Old; - } - if (L_Sim != NULL) { - lua_State* L_Old = L_Draw; - L_Draw = L_Sim; - SetRunning(L_Sim, true); - LUA_CLOSE(L_Sim); - //SetRunning(L_Sim, false); --nope, the state is deleted - L_Sim = NULL; - L_Draw = L_Old; + if (IsValid()) { + // 1. unlink from eventHandler, so no new events are getting triggered + eventHandler.RemoveClient(this); + //FIXME when multithreaded lua is enabled, wait for all running events to finish (possible via a mutex?) + + // 2. shutdown + Shutdown(); + + // 3. delete the lua_State + SetHandleRunning(L, true); + LUA_CLOSE(L); + //SetHandleRunning(L, false); --nope, the state is deleted + L = NULL; } } @@ -144,6 +132,7 @@ /******************************************************************************/ /******************************************************************************/ + int CLuaHandle::KillActiveHandle(lua_State* L) { CLuaHandle* ah = GetHandle(L); @@ -152,8 +141,12 @@ if ((args >= 1) && lua_isstring(L, 1)) { ah->killMsg = lua_tostring(L, 1); } + // get rid of us next GameFrame call ah->killMe = true; + + // don't process any further events + eventHandler.RemoveClient(ah); } return 0; } @@ -188,54 +181,13 @@ } -bool CLuaHandle::LoadCode(lua_State *L, const string& code, const string& debug) -{ - GML_DRCMUTEX_LOCK(lua); // LoadCode - - lua_settop(L, 0); - - // do not signal floating point exceptions in user Lua code - ScopedDisableFpuExceptions fe; - - int loadError = 0; - int callError = 0; - bool ret = true; - - if ((loadError = luaL_loadbuffer(L, code.c_str(), code.size(), debug.c_str())) == 0) { - SetRunning(L, true); - - if ((callError = lua_pcall(L, 0, 0, 0)) != 0) { - LOG_L(L_ERROR, "Lua LoadCode pcall error = %i, %s, %s", loadError, debug.c_str(), lua_tostring(L, -1)); - lua_pop(L, 1); - ret = false; - } - - SetRunning(L, false); - } else { - LOG_L(L_ERROR, "Lua LoadCode loadbuffer error = %i, %s, %s", callError, debug.c_str(), lua_tostring(L, -1)); - lua_pop(L, 1); - ret = false; - } - - return ret; -} - /******************************************************************************/ /******************************************************************************/ void CLuaHandle::CheckStack() { - // although Execute* have nothing to do with the stack, this happens to be a good place for it, - // and these calls must be located before the actual stack check to avoid a deadlock - ExecuteCallsFromSynced(false); - ExecuteUnitEventBatch(); - ExecuteFeatEventBatch(); - ExecuteProjEventBatch(); - ExecuteFrameEventBatch(); - ExecuteLogEventBatch(); - - SELECT_LUA_STATE(); - GML_DRCMUTEX_LOCK(lua); // CheckStack + if (!IsValid()) + return; const int top = lua_gettop(L); if (top != 0) { @@ -245,163 +197,53 @@ } -void CLuaHandle::RecvFromSynced(lua_State *srcState, int args) { - SELECT_UNSYNCED_LUA_STATE(); - -#if ((LUA_MT_OPT & LUA_STATE) && (LUA_MT_OPT & LUA_MUTEX)) - if (/*GML::Enabled() &&*/ !SingleState() && srcState != L) { // Sim thread sends to unsynced --> delay it - DelayRecvFromSynced(srcState, args); - return; - } - // Draw thread, delayed already, execute it -#endif - - static const LuaHashString cmdStr("RecvFromSynced"); - //LUA_CALL_IN_CHECK(L); -- not valid here - - if (!cmdStr.GetGlobalFunc(L)) - return; // the call is not defined - lua_insert(L, 1); // place the function - - // call the routine - lua_State* L_Prev = ForceUnsyncedState(); - RunCallIn(cmdStr, args, 0); - RestoreState(L_Prev); -} - - -void CLuaHandle::DelayRecvFromSynced(lua_State* srcState, int args) { - DelayDataDump ddmp; - - if (CopyExportTable()) { - HSTR_PUSH(srcState, "EXPORT"); - lua_rawget(srcState, LUA_GLOBALSINDEX); - - if (lua_istable(srcState, -1)) - LuaUtils::Backup(ddmp.dump, srcState, 1); - lua_pop(srcState, 1); - } - - LuaUtils::ShallowBackup(ddmp.data, srcState, args); - - GML_STDMUTEX_LOCK(scall); - - delayedCallsFromSynced.push_back(DelayDataDump()); - - DelayDataDump& ddb = delayedCallsFromSynced.back(); - ddb.data.swap(ddmp.data); - ddb.dump.swap(ddmp.dump); - ddb.xcall = false; -} - - -int CLuaHandle::SendToUnsynced(lua_State* L) +int CLuaHandle::XCall(lua_State* srcState, const string& funcName) { - const int args = lua_gettop(L); - if (args <= 0) { - luaL_error(L, "Incorrect arguments to SendToUnsynced()"); - } - - static const int supportedTypes = - (1 << LUA_TNIL) - | (1 << LUA_TBOOLEAN) - | (1 << LUA_TNUMBER) - | (1 << LUA_TSTRING) - ; + const int top = lua_gettop(L); - for (int i = 1; i <= args; i++) { - const int t = (1 << lua_type(L, i)); - if (!(t & supportedTypes)) { - luaL_error(L, "Incorrect data type for SendToUnsynced(), arg %d", i); - } + // push the function + const LuaHashString funcHash(funcName); + if (!funcHash.GetGlobalFunc(L)) { + LOG_L(L_WARNING, "Tried to call non-linked Script.%s.%s()", GetName().c_str(), funcName.c_str()); + return 0; } - CLuaHandle* lh = GetHandle(L); - lh->RecvFromSynced(L, args); - return 0; -} + int retCount; + if (srcState == L) { + lua_insert(L, 1); // move the function to the beginning -bool CLuaHandle::ExecuteCallsFromSynced(bool forced) { -#if (LUA_MT_OPT & LUA_MUTEX) - if (!GML::Enabled() || (SingleState() && (this != luaUI)) || (forced && !PurgeCallsFromSyncedBatch())) -#endif - return false; - - GML_THRMUTEX_LOCK(obj, GML_DRAW); // ExecuteCallsFromSynced - - std::vector drfs; - { - GML_STDMUTEX_LOCK(scall); // ExecuteCallsFromSynced - - if (delayedCallsFromSynced.empty()) - return false; + // call the function + if (!RunCallIn(L, funcHash, top, LUA_MULTRET)) { + return 0; + } + retCount = lua_gettop(L); + } else { + const int srcCount = lua_gettop(srcState); - delayedCallsFromSynced.swap(drfs); - } + LuaUtils::CopyData(L, srcState, srcCount); - GML_THRMUTEX_LOCK(unit, GML_DRAW); // ExecuteCallsFromSynced - GML_THRMUTEX_LOCK(feat, GML_DRAW); // ExecuteCallsFromSynced -// GML_THRMUTEX_LOCK(proj, GML_DRAW); // ExecuteCallsFromSynced + const bool origDrawingState = LuaOpenGL::IsDrawingEnabled(L); + LuaOpenGL::SetDrawingEnabled(L, LuaOpenGL::IsDrawingEnabled(srcState)); - SELECT_UNSYNCED_LUA_STATE(); // ExecuteCallsFromSynced - GML_DRCMUTEX_LOCK(lua); + // call the function + const bool failed = !RunCallIn(L, funcHash, srcCount, LUA_MULTRET); - for (int i = 0; i < drfs.size(); ++i) { - DelayDataDump &ddp = drfs[i]; + LuaOpenGL::SetDrawingEnabled(L, origDrawingState); -#if (LUA_MT_OPT & LUA_STATE) - if (!ddp.xcall) { - if (CopyExportTable() && ddp.dump.size() > 0) { - HSTR_PUSH(L, "UNSYNCED"); - lua_rawget(L, LUA_REGISTRYINDEX); + if (failed) + return 0; - HSTR_PUSH(L, "SYNCED"); - lua_rawget(L, -2); - if (lua_getmetatable(L, -1)) { - HSTR_PUSH(L, "realTable"); - lua_rawget(L, -2); - if (lua_istable(L, -1)) { - HSTR_PUSH(L, "EXPORT"); - LuaUtils::Restore(ddp.dump, L); - lua_rawset(L, -3); - } - lua_pop(L, 2); - } - lua_pop(L, 2); - } + retCount = lua_gettop(L) - top; - int ddsize = ddp.data.size(); - if (ddsize > 0) { - LuaUtils::ShallowRestore(ddp.data, L); - luaL_checkstack(L, 2, __FUNCTION__); - RecvFromSynced(L, ddsize); - } - } - else -#endif // (LUA_MT_OPT & LUA_STATE) - { - if (ddp.data.size() == 1) { - LuaUtils::ShallowDataDump sdd = ddp.data[0]; - if (sdd.type == LUA_TSTRING) { - const LuaHashString funcHash(*sdd.data.str); - delete sdd.data.str; - if (funcHash.GetGlobalFunc(L)) { - const int top = lua_gettop(L) - 1; - - LuaUtils::Restore(ddp.dump, L); - - lua_State* L_Prev = ForceUnsyncedState(); - RunCallIn(funcHash, ddp.dump.size(), LUA_MULTRET); - RestoreState(L_Prev); - - lua_settop(L, top); - } - } - } + lua_settop(srcState, 0); // pop all passed arguments on caller stack + if (retCount > 0) { + LuaUtils::CopyData(srcState, L, retCount); // push the new returned arguments on caller stack } + lua_settop(L, top); // revert the callee stack } - return true; + + return retCount; } @@ -409,6 +251,7 @@ /******************************************************************************/ int CLuaHandle::RunCallInTraceback( + lua_State* L, const LuaHashString* hs, int inArgs, int outArgs, @@ -419,8 +262,6 @@ // do not signal floating point exceptions in user Lua code ScopedDisableFpuExceptions fe; - SELECT_LUA_STATE(); - struct ScopedLuaCall { public: ScopedLuaCall( @@ -440,7 +281,7 @@ , errFuncIdx(_errFuncIdx) , popErrFunc(_popErrFunc) { - handle->SetRunning(state, true); + handle->SetHandleRunning(state, true); GLMatrixStateTracker& matTracker = GetLuaContextData(state)->glMatrixTracker; MatrixStateData prevMatState = matTracker.PushMatrixState(); @@ -451,13 +292,13 @@ // note2: we collect garbage now in its own callin "CollectGarbage" // lua_gc(L, LUA_GCRESTART, 0); error = lua_pcall(state, nInArgs, nOutArgs, errFuncIdx); - // only run GC inside of "SetRunning(L, true) ... SetRunning(L, false)"! + // only run GC inside of "SetHandleRunning(L, true) ... SetHandleRunning(L, false)"! lua_gc(state, LUA_GCSTOP, 0); LuaOpenGL::CheckMatrixState(state, func, error); matTracker.PopMatrixState(prevMatState); - handle->SetRunning(state, false); + handle->SetHandleRunning(state, false); } ~ScopedLuaCall() { @@ -469,30 +310,34 @@ void CheckFixStack(std::string& trace) { // note: assumes error-handler has not been popped yet (!) + const int outArgs = (lua_gettop(luaState) - (GetTop() - 1)) + nInArgs; + if (GetError() == 0) { if (nOutArgs != LUA_MULTRET) { - const int retdiff = (lua_gettop(luaState) - (GetTop() - 1)) - (nOutArgs - nInArgs); - - if (retdiff != 0) { - LOG_L(L_ERROR, "Internal Lua error: %d return values, %d expected", nOutArgs + retdiff, nOutArgs); - lua_pop(luaState, retdiff); + if (outArgs != nOutArgs) { + LOG_L(L_ERROR, "Internal Lua error: %d return values, %d expected", outArgs, nOutArgs); + if (outArgs > nOutArgs) + lua_pop(luaState, outArgs - nOutArgs); } } else { - const int retdiff = (lua_gettop(luaState) - (GetTop() - 1)) + nInArgs; - - if (retdiff < 0) { - LOG_L(L_ERROR, "Internal Lua error: %d return values", retdiff); - lua_pop(luaState, retdiff); + if (outArgs < 0) { + LOG_L(L_ERROR, "Internal Lua error: stack corrupted"); } } } else { - const int retdiff = (lua_gettop(luaState) - (GetTop() - 1)) - (1 - nInArgs); + const int dbgOutArgs = 1; // the traceback string + + if (outArgs > dbgOutArgs) { + LOG_L(L_ERROR, "Internal Lua error: %i too many elements on the stack", outArgs - dbgOutArgs); + lua_pop(luaState, outArgs - dbgOutArgs); // only leave traceback str on the stack + } else if (outArgs < dbgOutArgs) { + LOG_L(L_ERROR, "Internal Lua error: stack corrupted"); + lua_pushnil(luaState); // to make the code below valid + } - // BUG? only the traceback shall be returned, but occasionally something goes wrong - lua_pop(luaState, retdiff); - trace += std::string((retdiff != 0)? "[Internal Lua error: Traceback failure] " : ""); - trace += (lua_isstring(luaState, -1) ? lua_tostring(luaState, -1) : "[No traceback returned]"); - lua_pop(luaState, 1); + trace += "[Internal Lua error: Call failure] "; + trace += luaL_optstring(luaState, -1, "[No traceback returned]"); + lua_pop(luaState, 1); // pop traceback string // log only errors that lead to a crash luaHandle->callinErrors += (GetError() == LUA_ERRRUN); @@ -523,26 +368,57 @@ } -bool CLuaHandle::RunCallInTraceback(const LuaHashString& hs, int inArgs, int outArgs, int errFuncIndex, bool popErrFunc) +bool CLuaHandle::RunCallInTraceback(lua_State* L, const LuaHashString& hs, int inArgs, int outArgs, int errFuncIndex, bool popErrFunc) { std::string traceback; - const int error = RunCallInTraceback(&hs, inArgs, outArgs, errFuncIndex, traceback, popErrFunc); + const int error = RunCallInTraceback(L, &hs, inArgs, outArgs, errFuncIndex, traceback, popErrFunc); if (error != 0) { LOG_L(L_ERROR, "%s::RunCallIn: error = %i, %s, %s", GetName().c_str(), error, hs.GetString().c_str(), traceback.c_str()); + + if (error == LUA_ERRMEM) { + // try to free some memory so other lua states can alloc again + for (int i=0; i<20; ++i) { + CollectGarbage(); + } + + // Kill + KillActiveHandle(L); + } return false; } return true; } +/******************************************************************************/ +/******************************************************************************/ -bool CLuaHandle::RunCallIn(int inArgs, int outArgs, std::string& errorMsg) +bool CLuaHandle::LoadCode(lua_State *L, const string& code, const string& debug) { - return RunCallInTraceback(NULL, inArgs, outArgs, 0, errorMsg, false); + lua_settop(L, 0); + + const LuaUtils::ScopedDebugTraceBack traceBack(L); + + const int loadError = luaL_loadbuffer(L, code.c_str(), code.size(), debug.c_str()); + bool ret = true; + + if (loadError == 0) { + static const LuaHashString cmdStr("Initialize"); + + // call the routine + ret = RunCallInTraceback(L, cmdStr, 0, 0, traceBack.GetErrFuncIdx(), false); + } else { + LOG_L(L_ERROR, "Lua LoadCode loadbuffer error = %i, %s, %s", loadError, debug.c_str(), lua_tostring(L, -1)); + lua_pop(L, 1); + ret = false; + } + + return ret; } /******************************************************************************/ +/******************************************************************************/ void CLuaHandle::Shutdown() { @@ -557,9 +433,35 @@ } // call the routine - RunCallInTraceback(cmdStr, 0, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 0, 0, traceBack.GetErrFuncIdx(), false); +} + + +bool CLuaHandle::GotChatMsg(const string& msg, int playerID) +{ + LUA_CALL_IN_CHECK(L, true); + luaL_checkstack(L, 4, __FUNCTION__); + static const LuaHashString cmdStr("GotChatMsg"); + + bool processed = false; + if (cmdStr.GetGlobalFunc(L)) { + lua_pushsstring(L, msg); + lua_pushnumber(L, playerID); + + // call the routine + if (RunCallIn(L, cmdStr, 2, 1)) { + processed = luaL_optboolean(L, -1, false); + lua_pop(L, 1); + } + } + + if (!processed && (this == luaUI)) { + processed = luaUI->ConfigCommand(msg); //FIXME deprecated + } + return processed; } + void CLuaHandle::Load(IArchive* archive) { LUA_CALL_IN_CHECK(L); @@ -576,9 +478,44 @@ LuaZipFileReader::PushNew(L, "", archive); // call the routine - RunCallInTraceback(cmdStr, 1, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 1, 0, traceBack.GetErrFuncIdx(), false); +} + + +bool CLuaHandle::HasCallIn(lua_State* L, const string& name) +{ + if (!IsValid()) + return false; + + if (name == "CollectGarbage") + return true; + + //FIXME should be equal to below, but somehow it isn't and doesn't work as expected!? +// lua_getglobal(L, name.c_str()); +// const bool found = !lua_isfunction(L, -1); +// lua_pop(L, 1); + + lua_pushvalue(L, LUA_GLOBALSINDEX); + lua_pushsstring(L, name); // push the function name + lua_rawget(L, -2); // get the function + const bool found = lua_isfunction(L, -1); + lua_pop(L, 2); + + return found; } + +bool CLuaHandle::UpdateCallIn(lua_State* L, const string& name) +{ + if (HasCallIn(L, name)) { + eventHandler.InsertEvent(this, name); + } else { + eventHandler.RemoveEvent(this, name); + } + return true; +} + + void CLuaHandle::GamePreload() { LUA_CALL_IN_CHECK(L); @@ -592,7 +529,7 @@ } // call the routine - RunCallInTraceback(cmdStr, 0, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 0, 0, traceBack.GetErrFuncIdx(), false); } void CLuaHandle::GameStart() @@ -608,7 +545,7 @@ } // call the routine - RunCallInTraceback(cmdStr, 0, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 0, 0, traceBack.GetErrFuncIdx(), false); } void CLuaHandle::GameOver(const std::vector& winningAllyTeams) @@ -630,7 +567,7 @@ } // call the routine - RunCallInTraceback(cmdStr, 1, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 1, 0, traceBack.GetErrFuncIdx(), false); } @@ -650,7 +587,7 @@ lua_pushboolean(L, paused); // call the routine - RunCallInTraceback(cmdStr, 2, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 2, 0, traceBack.GetErrFuncIdx(), false); } @@ -666,10 +603,7 @@ return; } - LUA_FRAME_BATCH_PUSH(, frameNum); LUA_CALL_IN_CHECK(L); - if (CopyExportTable()) - DelayRecvFromSynced(L, 0); // Copy _G.EXPORT --> SYNCED.EXPORT once a game frame luaL_checkstack(L, 4, __FUNCTION__); const LuaUtils::ScopedDebugTraceBack traceBack(L); @@ -682,7 +616,7 @@ lua_pushnumber(L, frameNum); // call the routine - RunCallInTraceback(cmdStr, 1, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 1, 0, traceBack.GetErrFuncIdx(), false); } @@ -690,17 +624,16 @@ { LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 4, __FUNCTION__); - - const LuaHashString cmdStr("GameID"); const LuaUtils::ScopedDebugTraceBack traceBack(L); + const LuaHashString cmdStr("GameID"); if (!cmdStr.GetGlobalFunc(L)) { return; } lua_pushlstring(L, reinterpret_cast(gameID), numBytes); - RunCallInTraceback(cmdStr, 1, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 1, 0, traceBack.GetErrFuncIdx(), false); } @@ -719,7 +652,7 @@ lua_pushnumber(L, teamID); // call the routine - RunCallInTraceback(cmdStr, 1, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 1, 0, traceBack.GetErrFuncIdx(), false); } @@ -738,7 +671,7 @@ lua_pushnumber(L, teamID); // call the routine - RunCallInTraceback(cmdStr, 1, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 1, 0, traceBack.GetErrFuncIdx(), false); } @@ -757,7 +690,7 @@ lua_pushnumber(L, playerID); // call the routine - RunCallInTraceback(cmdStr, 1, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 1, 0, traceBack.GetErrFuncIdx(), false); } @@ -776,7 +709,7 @@ lua_pushnumber(L, playerID); // call the routine - RunCallInTraceback(cmdStr, 1, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 1, 0, traceBack.GetErrFuncIdx(), false); } @@ -796,7 +729,7 @@ lua_pushnumber(L, reason); // call the routine - RunCallInTraceback(cmdStr, 2, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 2, 0, traceBack.GetErrFuncIdx(), false); } @@ -817,13 +750,12 @@ lua_pushnumber(L, unit->team); // call the routine - RunCallInTraceback(hs, 3, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, hs, 3, 0, traceBack.GetErrFuncIdx(), false); } void CLuaHandle::UnitCreated(const CUnit* unit, const CUnit* builder) { - LUA_UNIT_BATCH_PUSH(, LuaUnitCreatedEvent(unit, builder)); LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 7, __FUNCTION__); @@ -843,13 +775,12 @@ int args = (builder != NULL) ? 4 : 3; // call the routine - RunCallInTraceback(cmdStr, args, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, args, 0, traceBack.GetErrFuncIdx(), false); } void CLuaHandle::UnitFinished(const CUnit* unit) { - LUA_UNIT_BATCH_PUSH(, LuaUnitFinishedEvent(unit)); static const LuaHashString cmdStr("UnitFinished"); UnitCallIn(cmdStr, unit); } @@ -858,7 +789,6 @@ void CLuaHandle::UnitFromFactory(const CUnit* unit, const CUnit* factory, bool userOrders) { - LUA_UNIT_BATCH_PUSH(, LuaUnitFromFactoryEvent(unit, factory, userOrders)) LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 9, __FUNCTION__); @@ -877,13 +807,12 @@ lua_pushboolean(L, userOrders); // call the routine - RunCallInTraceback(cmdStr, 6, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 6, 0, traceBack.GetErrFuncIdx(), false); } void CLuaHandle::UnitDestroyed(const CUnit* unit, const CUnit* attacker) { - LUA_UNIT_BATCH_PUSH(, LuaUnitDestroyedEvent(unit, attacker)) LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 9, __FUNCTION__); @@ -906,13 +835,12 @@ } // call the routine - RunCallInTraceback(cmdStr, argCount, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, argCount, 0, traceBack.GetErrFuncIdx(), false); } void CLuaHandle::UnitTaken(const CUnit* unit, int oldTeam, int newTeam) { - LUA_UNIT_BATCH_PUSH(, LuaUnitTakenEvent(unit, oldTeam, newTeam)) LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 7, __FUNCTION__); const LuaUtils::ScopedDebugTraceBack traceBack(L); @@ -928,13 +856,12 @@ lua_pushnumber(L, newTeam); // call the routine - RunCallInTraceback(cmdStr, 4, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 4, 0, traceBack.GetErrFuncIdx(), false); } void CLuaHandle::UnitGiven(const CUnit* unit, int oldTeam, int newTeam) { - LUA_UNIT_BATCH_PUSH(, LuaUnitGivenEvent(unit, oldTeam, newTeam)) LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 7, __FUNCTION__); const LuaUtils::ScopedDebugTraceBack traceBack(L); @@ -950,13 +877,12 @@ lua_pushnumber(L, oldTeam); // call the routine - RunCallInTraceback(cmdStr, 4, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 4, 0, traceBack.GetErrFuncIdx(), false); } void CLuaHandle::UnitIdle(const CUnit* unit) { - LUA_UNIT_BATCH_PUSH(, LuaUnitIdleEvent(unit)) static const LuaHashString cmdStr("UnitIdle"); UnitCallIn(cmdStr, unit); } @@ -964,7 +890,6 @@ void CLuaHandle::UnitCommand(const CUnit* unit, const Command& command) { - LUA_UNIT_BATCH_PUSH(, LuaUnitCommandEvent(unit, command)) LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 11, __FUNCTION__); @@ -990,13 +915,12 @@ lua_pushnumber(L, command.tag); // call the routine - RunCallInTraceback(cmdStr, 7, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 7, 0, traceBack.GetErrFuncIdx(), false); } void CLuaHandle::UnitCmdDone(const CUnit* unit, const Command& command) { - LUA_UNIT_BATCH_PUSH(, LuaUnitCommandDoneEvent(unit, command)) LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 8, __FUNCTION__); @@ -1018,7 +942,7 @@ LuaUtils::PushCommandOptionsTable(L, command, false); // call the routine - RunCallInTraceback(cmdStr, 7, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 7, 0, traceBack.GetErrFuncIdx(), false); } @@ -1030,7 +954,6 @@ int projectileID, bool paralyzer) { - LUA_UNIT_BATCH_PUSH(, LuaUnitDamagedEvent(unit, attacker, damage, weaponDefID, projectileID, paralyzer)) LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 11, __FUNCTION__); @@ -1062,13 +985,12 @@ } // call the routine - RunCallInTraceback(cmdStr, argCount, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, argCount, 0, traceBack.GetErrFuncIdx(), false); } void CLuaHandle::UnitExperience(const CUnit* unit, float oldExperience) { - LUA_UNIT_BATCH_PUSH(, LuaUnitExperienceEvent(unit, oldExperience)) LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 8, __FUNCTION__); @@ -1086,7 +1008,14 @@ lua_pushnumber(L, oldExperience); // call the routine - RunCallInTraceback(cmdStr, 5, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 5, 0, traceBack.GetErrFuncIdx(), false); +} + + +void CLuaHandle::UnitHarvestStorageFull(const CUnit* unit) +{ + static const LuaHashString cmdStr("UnitHarvestStorageFull"); + UnitCallIn(cmdStr, unit); } @@ -1095,7 +1024,6 @@ void CLuaHandle::UnitSeismicPing(const CUnit* unit, int allyTeam, const float3& pos, float strength) { - LUA_UNIT_BATCH_PUSH(, LuaUnitSeismicPingEvent(unit, allyTeam, pos, strength)) LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 9, __FUNCTION__); int readAllyTeam = GetHandleReadAllyTeam(L); @@ -1118,7 +1046,7 @@ } // call the routine - RunCallIn(cmdStr, GetHandleFullRead(L) ? 7 : 4, 0); + RunCallIn(L, cmdStr, GetHandleFullRead(L) ? 7 : 4, 0); } @@ -1140,13 +1068,12 @@ } // call the routine - RunCallIn(hs, GetHandleFullRead(L) ? 4 : 2, 0); + RunCallIn(L, hs, GetHandleFullRead(L) ? 4 : 2, 0); } void CLuaHandle::UnitEnteredRadar(const CUnit* unit, int allyTeam) { - LUA_UNIT_BATCH_PUSH(, LuaUnitEnteredRadarEvent(unit, allyTeam)) static const LuaHashString hs("UnitEnteredRadar"); LosCallIn(hs, unit, allyTeam); } @@ -1154,7 +1081,6 @@ void CLuaHandle::UnitEnteredLos(const CUnit* unit, int allyTeam) { - LUA_UNIT_BATCH_PUSH(, LuaUnitEnteredLosEvent(unit, allyTeam)) static const LuaHashString hs("UnitEnteredLos"); LosCallIn(hs, unit, allyTeam); } @@ -1162,7 +1088,6 @@ void CLuaHandle::UnitLeftRadar(const CUnit* unit, int allyTeam) { - LUA_UNIT_BATCH_PUSH(, LuaUnitLeftRadarEvent(unit, allyTeam)) static const LuaHashString hs("UnitLeftRadar"); LosCallIn(hs, unit, allyTeam); } @@ -1170,7 +1095,6 @@ void CLuaHandle::UnitLeftLos(const CUnit* unit, int allyTeam) { - LUA_UNIT_BATCH_PUSH(, LuaUnitLeftLosEvent(unit, allyTeam)) static const LuaHashString hs("UnitLeftLos"); LosCallIn(hs, unit, allyTeam); } @@ -1180,7 +1104,6 @@ void CLuaHandle::UnitLoaded(const CUnit* unit, const CUnit* transport) { - LUA_UNIT_BATCH_PUSH(, LuaUnitLoadedEvent(unit, transport)) LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 8, __FUNCTION__); @@ -1198,13 +1121,12 @@ lua_pushnumber(L, transport->team); // call the routine - RunCallInTraceback(cmdStr, 5, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 5, 0, traceBack.GetErrFuncIdx(), false); } void CLuaHandle::UnitUnloaded(const CUnit* unit, const CUnit* transport) { - LUA_UNIT_BATCH_PUSH(, LuaUnitUnloadedEvent(unit, transport)) LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 8, __FUNCTION__); @@ -1222,7 +1144,7 @@ lua_pushnumber(L, transport->team); // call the routine - RunCallInTraceback(cmdStr, 5, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 5, 0, traceBack.GetErrFuncIdx(), false); } @@ -1230,7 +1152,6 @@ void CLuaHandle::UnitEnteredWater(const CUnit* unit) { - LUA_UNIT_BATCH_PUSH(, LuaUnitEnteredWaterEvent(unit)) static const LuaHashString cmdStr("UnitEnteredWater"); UnitCallIn(cmdStr, unit); } @@ -1238,7 +1159,6 @@ void CLuaHandle::UnitEnteredAir(const CUnit* unit) { - LUA_UNIT_BATCH_PUSH(, LuaUnitEnteredAirEvent(unit)) static const LuaHashString cmdStr("UnitEnteredAir"); UnitCallIn(cmdStr, unit); } @@ -1246,7 +1166,6 @@ void CLuaHandle::UnitLeftWater(const CUnit* unit) { - LUA_UNIT_BATCH_PUSH(, LuaUnitLeftWaterEvent(unit)) static const LuaHashString cmdStr("UnitLeftWater"); UnitCallIn(cmdStr, unit); } @@ -1254,7 +1173,6 @@ void CLuaHandle::UnitLeftAir(const CUnit* unit) { - LUA_UNIT_BATCH_PUSH(, LuaUnitLeftAirEvent(unit)) static const LuaHashString cmdStr("UnitLeftAir"); UnitCallIn(cmdStr, unit); } @@ -1264,7 +1182,6 @@ void CLuaHandle::UnitCloaked(const CUnit* unit) { - LUA_UNIT_BATCH_PUSH(, LuaUnitCloakedEvent(unit)) static const LuaHashString cmdStr("UnitCloaked"); UnitCallIn(cmdStr, unit); } @@ -1272,7 +1189,6 @@ void CLuaHandle::UnitDecloaked(const CUnit* unit) { - LUA_UNIT_BATCH_PUSH(, LuaUnitDecloakedEvent(unit)) static const LuaHashString cmdStr("UnitDecloaked"); UnitCallIn(cmdStr, unit); } @@ -1286,7 +1202,6 @@ if (!watchUnitDefs[collider->unitDef->id]) return; if (!watchUnitDefs[collidee->unitDef->id]) return; - LUA_UNIT_BATCH_PUSH(, LuaUnitUnitCollisionEvent(collider, collidee)) LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 5, __FUNCTION__); @@ -1301,7 +1216,7 @@ lua_pushnumber(L, collidee->id); lua_pushboolean(L, false); - RunCallInTraceback(cmdStr, 3, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 3, 0, traceBack.GetErrFuncIdx(), false); } void CLuaHandle::UnitFeatureCollision(const CUnit* collider, const CFeature* collidee) @@ -1312,7 +1227,6 @@ if (!watchUnitDefs[collider->unitDef->id]) return; if (!watchFeatureDefs[collidee->def->id]) return; - LUA_UNIT_BATCH_PUSH(, LuaUnitFeatureCollisionEvent(collider, collidee)) LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 5, __FUNCTION__); @@ -1327,7 +1241,7 @@ lua_pushnumber(L, collidee->id); lua_pushboolean(L, false); - RunCallInTraceback(cmdStr, 3, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 3, 0, traceBack.GetErrFuncIdx(), false); } void CLuaHandle::UnitMoveFailed(const CUnit* unit) @@ -1336,7 +1250,6 @@ if (watchUnitDefs.empty()) return; if (!watchUnitDefs[unit->unitDef->id]) return; - LUA_UNIT_BATCH_PUSH(, LuaUnitMoveFailedEvent(unit)) static const LuaHashString cmdStr("UnitMoveFailed"); UnitCallIn(cmdStr, unit); } @@ -1346,7 +1259,6 @@ void CLuaHandle::FeatureCreated(const CFeature* feature) { - LUA_FEAT_BATCH_PUSH(, LuaFeatureCreatedEvent(feature)) LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 5, __FUNCTION__); @@ -1361,12 +1273,11 @@ lua_pushnumber(L, feature->allyteam); // call the routine - RunCallInTraceback(cmdStr, 2, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 2, 0, traceBack.GetErrFuncIdx(), false); } void CLuaHandle::FeatureDestroyed(const CFeature* feature) { - LUA_FEAT_BATCH_PUSH(, LuaFeatureDestroyedEvent(feature)) LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 5, __FUNCTION__); @@ -1381,7 +1292,7 @@ lua_pushnumber(L, feature->allyteam); // call the routine - RunCallInTraceback(cmdStr, 2, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, 2, 0, traceBack.GetErrFuncIdx(), false); } void CLuaHandle::FeatureDamaged( @@ -1391,13 +1302,11 @@ int weaponDefID, int projectileID) { - LUA_FEAT_BATCH_PUSH(, LuaFeatureDamagedEvent(feature, attacker, damage, weaponDefID, projectileID)) LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 11, __FUNCTION__); - - static const LuaHashString cmdStr(__FUNCTION__); const LuaUtils::ScopedDebugTraceBack traceBack(L); + static const LuaHashString cmdStr(__FUNCTION__); if (!cmdStr.GetGlobalFunc(L)) return; @@ -1421,7 +1330,7 @@ } // call the routine - RunCallInTraceback(cmdStr, argCount, 0, traceBack.GetErrFuncIdx(), false); + RunCallInTraceback(L, cmdStr, argCount, 0, traceBack.GetErrFuncIdx(), false); } @@ -1443,7 +1352,6 @@ if (p->weapon && (wd == NULL || !watchWeaponDefs[wd->id])) return; - LUA_PROJ_BATCH_PUSH(, LuaProjCreatedEvent(p)) LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 5, __FUNCTION__); @@ -1457,7 +1365,7 @@ lua_pushnumber(L, ((wd != NULL)? wd->id: -1)); // call the routine - RunCallIn(cmdStr, 3, 0); + RunCallIn(L, cmdStr, 3, 0); } @@ -1476,7 +1384,6 @@ if (wd == NULL || !watchWeaponDefs[wd->id]) return; } - LUA_PROJ_BATCH_PUSH(, LuaProjDestroyedEvent(p)) LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 4, __FUNCTION__); @@ -1488,7 +1395,7 @@ lua_pushnumber(L, p->id); // call the routine - RunCallIn(cmdStr, 1, 0); + RunCallIn(L, cmdStr, 1, 0); } /******************************************************************************/ @@ -1503,9 +1410,9 @@ if (watchWeaponDefs.empty()) return false; if (!watchWeaponDefs[weaponDefID]) return false; - LUA_UNIT_BATCH_PUSH(false, LuaUnitExplosionEvent(weaponDefID, projectileID, pos, owner)) LUA_CALL_IN_CHECK(L, false); luaL_checkstack(L, 7, __FUNCTION__); + static const LuaHashString cmdStr("Explosion"); if (!cmdStr.GetGlobalFunc(L)) return false; // the call is not defined @@ -1519,17 +1426,11 @@ } // call the routine - if (!RunCallIn(cmdStr, (owner == NULL) ? 4 : 5, 1)) + if (!RunCallIn(L, cmdStr, (owner == NULL) ? 4 : 5, 1)) return false; // get the results - if (!lua_isboolean(L, -1)) { - LOG_L(L_WARNING, "%s() bad return value", cmdStr.GetString().c_str()); - lua_pop(L, 1); - return false; - } - - const bool retval = !!lua_toboolean(L, -1); + const bool retval = luaL_optboolean(L, -1, false); lua_pop(L, 1); return retval; } @@ -1538,9 +1439,9 @@ void CLuaHandle::StockpileChanged(const CUnit* unit, const CWeapon* weapon, int oldCount) { - LUA_UNIT_BATCH_PUSH(, LuaUnitStockpileChangedEvent(unit, weapon, oldCount)) LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 8, __FUNCTION__); + static const LuaHashString cmdStr("StockpileChanged"); if (!cmdStr.GetGlobalFunc(L)) return; @@ -1553,327 +1454,28 @@ lua_pushnumber(L, weapon->numStockpiled); // call the routine - RunCallIn(cmdStr, 6, 0); + RunCallIn(L, cmdStr, 6, 0); } -void CLuaHandle::ExecuteUnitEventBatch() { - if (!UseEventBatch()) - return; - - GML_THRMUTEX_LOCK(obj, GML_DRAW); // ExecuteUnitEventBatch - - std::vector lueb; - { - GML_STDMUTEX_LOCK(ulbatch); - - if (luaUnitEventBatch.empty()) - return; - - luaUnitEventBatch.swap(lueb); - } - - GML_THRMUTEX_LOCK(unit, GML_DRAW); // ExecuteUnitEventBatch - GML_THRMUTEX_LOCK(feat, GML_DRAW); // ExecuteUnitEventBatch -// GML_THRMUTEX_LOCK(proj, GML_DRAW); // ExecuteUnitEventBatch - - GML_SELECT_LUA_STATE(); - GML_DRCMUTEX_LOCK(lua); // ExecuteUnitEventBatch - - if (Threading::IsSimThread()) - Threading::SetLuaBatchThread(false); - - for (std::vector::iterator i = lueb.begin(); i != lueb.end(); ++i) { - #if 0 - // TODO: FINISH ME - const LuaUnitEventBase& e = *i; - switch (e.GetID()) { - case UNIT_FINISHED: { - LUA_EVENT_CAST(LuaUnitFinishedEvent, e); UnitFinished(ee.GetUnit()); - } break; - case UNIT_CREATED: { - LUA_EVENT_CAST(LuaUnitCreatedEvent, e); UnitCreated(ee.GetUnit(), ee.GetBuilder()); - } break; - case UNIT_FROM_FACTORY: { - LUA_EVENT_CAST(LuaUnitFromFactoryEvent, e); UnitFromFactory(ee.GetUnit(), ee.GetFactory(), ee.GetUserOrders()); - } break; - case UNIT_DESTROYED: { - LUA_EVENT_CAST(LuaUnitDestroyedEvent, e); UnitDestroyed(ee.GetUnit(), ee.GetAttacker()); - } break; - case UNIT_TAKEN: { - LUA_EVENT_CAST(LuaUnitTakenEvent, e); UnitTaken(ee.GetUnit(), ee.GetOldTeam(), ee.GetNewTeam()); - } break; - case UNIT_GIVEN: { - LUA_EVENT_CAST(LuaUnitGivenEvent, e); UnitGiven(ee.GetUnit(), ee.GetOldTeam(), ee.GetNewTeam()); - } break; - case UNIT_IDLE: { - LUA_EVENT_CAST(LuaUnitIdleEvent, e); UnitIdle(ee.GetUnit()); - } break; - case UNIT_COMMAND: { - LUA_EVENT_CAST(LuaUnitCommandEvent, e); UnitCommand(ee.GetUnit(), *ee.GetCommand()); - } break; - case UNIT_CMD_DONE: { - LUA_EVENT_CAST(LuaUnitCommandDoneEvent, e); UnitCmdDone(ee.GetUnit(), ee.GetCommandID(), ee.GetCommandTag()); - } break; - case UNIT_DAMAGED: { - LUA_EVENT_CAST(LuaUnitDamagedEvent, e); UnitDamaged(ee.GetUnit(), ee.GetAttacker(), ee.GetDamage(), ee.GetWeaponDefID(), ee.GetProjectileDefID(), ee.GetParalyzer()); - } break; - case UNIT_EXPERIENCE: { - LUA_EVENT_CAST(LuaUnitExperienceEvent, e); UnitExperience(ee.GetUnit(), ee.GetOldExperience()); - } break; - case UNIT_SEISMIC_PING: { - LUA_EVENT_CAST(LuaUnitSeismicPingEvent, e); UnitSeismicPing(ee.GetUnit(), ee.GetAllyTeam(), ee.GetPos() /*ee.cmd1->GetPos(0)*/, ee.GetStrength()); - } break; - case UNIT_ENTERED_RADAR: { - LUA_EVENT_CAST(LuaUnitEnteredRadarEvent, e); UnitEnteredRadar(ee.GetUnit(), ee.GetAllyTeam()); - } break; - case UNIT_ENTERED_LOS: { - LUA_EVENT_CAST(LuaUnitEnteredLosEvent, e); UnitEnteredLos(ee.GetUnit(), ee.GetAllyTeam()); - } break; - case UNIT_LEFT_RADAR: { - LUA_EVENT_CAST(LuaUnitLeftRadarEvent, e); UnitLeftRadar(ee.GetUnit(), ee.GetAllyTeam()); - } break; - case UNIT_LEFT_LOS: { - LUA_EVENT_CAST(LuaUnitLeftLosEvent, e); UnitLeftLos(ee.GetUnit(), ee.GetAllyTeam()); - } break; - case UNIT_LOADED: { - LUA_EVENT_CAST(LuaUnitLoadedEvent, e); UnitLoaded(ee.GetUnit(), ee.GetTransporter()); - } break; - case UNIT_UNLOADED: { - LUA_EVENT_CAST(LuaUnitUnloadedEvent, e); UnitUnloaded(ee.GetUnit(), ee.GetTransporter()); - } break; - case UNIT_ENTERED_WATER: { - LUA_EVENT_CAST(LuaUnitEnteredWaterEvent, e); UnitEnteredWater(ee.GetUnit()); - } break; - case UNIT_ENTERED_AIR: { - LUA_EVENT_CAST(LuaUnitEnteredAirEvent, e); UnitEnteredAir(ee.GetUnit()); - } break; - case UNIT_LEFT_WATER: { - LUA_EVENT_CAST(LuaUnitLeftWaterEvent, e); UnitLeftWater(ee.GetUnit()); - } break; - case UNIT_LEFT_AIR: { - LUA_EVENT_CAST(LuaUnitLeftAirEvent, e); UnitLeftAir(ee.GetUnit()); - } break; - case UNIT_CLOAKED: { - LUA_EVENT_CAST(LuaUnitCloakedEvent, e); UnitCloaked(ee.GetUnit()); - } break; - case UNIT_DECLOAKED: { - LUA_EVENT_CAST(LuaUnitDecloakedEvent, e); UnitDecloaked(ee.GetUnit()); - } break; - case UNIT_MOVE_FAILED: { - LUA_EVENT_CAST(LuaUnitMoveFailedEvent, e); UnitMoveFailed(ee.GetUnit()); - } break; - case UNIT_EXPLOSION: { - LUA_EVENT_CAST(LuaUnitExplosionEvent, e); Explosion(ee.GetWeaponDefID(), ee.GetProjectileID(), ee.GetPos() /*ee.cmd1->GetPos(0)*/, ee.GetOwner()); - } break; - case UNIT_UNIT_COLLISION: { - LUA_EVENT_CAST(LuaUnitUnitCollisionEvent, e); UnitUnitCollision(ee.GetCollider(), ee.GetCollidee()); - } break; - case UNIT_FEAT_COLLISION: { - LUA_EVENT_CAST(LuaUnitFeatureCollisionEvent, e); UnitFeatureCollision(ee.GetCollider(), ee.GetCollidee()); - } break; - case UNIT_STOCKPILE_CHANGED: { - LUA_EVENT_CAST(LuaUnitStockpileChangedEvent, e); StockpileChanged(ee.GetUnit(), ee.GetWeapon(), ee.GetOldCount()); - } break; - default: { - LOG_L(L_ERROR, "%s: Invalid Event %d", __FUNCTION__, e.GetID()); - } break; - } - #endif - } - - if (Threading::IsSimThread()) - Threading::SetLuaBatchThread(true); -} - - -void CLuaHandle::ExecuteFeatEventBatch() { - if (!UseEventBatch()) - return; - - GML_THRMUTEX_LOCK(obj, GML_DRAW); // ExecuteFeatEventBatch - - std::vector lfeb; - { - GML_STDMUTEX_LOCK(flbatch); - - if (luaFeatEventBatch.empty()) - return; - - luaFeatEventBatch.swap(lfeb); - } - - GML_THRMUTEX_LOCK(unit, GML_DRAW); // ExecuteFeatEventBatch - GML_THRMUTEX_LOCK(feat, GML_DRAW); // ExecuteFeatEventBatch -// GML_THRMUTEX_LOCK(proj, GML_DRAW); // ExecuteFeatEventBatch - - GML_SELECT_LUA_STATE(); - GML_DRCMUTEX_LOCK(lua); // ExecuteFeatEventBatch - - if (Threading::IsSimThread()) - Threading::SetLuaBatchThread(false); - - for (std::vector::iterator i = lfeb.begin(); i != lfeb.end(); ++i) { - const LuaFeatEventBase& e = *i; - switch (e.GetID()) { - case FEAT_CREATED: { - LUA_EVENT_CAST(LuaFeatureCreatedEvent, e); FeatureCreated(ee.GetFeature()); - } break; - case FEAT_DESTROYED: { - LUA_EVENT_CAST(LuaFeatureDestroyedEvent, e); FeatureDestroyed(ee.GetFeature()); - } break; - case FEAT_DAMAGED: { - LUA_EVENT_CAST(LuaFeatureDamagedEvent, e); FeatureDamaged(ee.GetFeature(), ee.GetAttacker(), ee.GetDamage(), ee.GetWeaponDefID(), ee.GetProjectileID()); - } break; - default: { - LOG_L(L_ERROR, "%s: Invalid Event %d", __FUNCTION__, e.GetID()); - } break; - } - } - - if (Threading::IsSimThread()) - Threading::SetLuaBatchThread(true); -} - - -void CLuaHandle::ExecuteProjEventBatch() { - if (!UseEventBatch()) - return; - -// GML_THRMUTEX_LOCK(unit, GML_DRAW); // ExecuteProjEventBatch -// GML_THRMUTEX_LOCK(feat, GML_DRAW); // ExecuteProjEventBatch - GML_THRMUTEX_LOCK(proj, GML_DRAW); // ExecuteProjEventBatch - - std::vector lpeb; - { - GML_STDMUTEX_LOCK(plbatch); - - if (luaProjEventBatch.empty()) - return; - - luaProjEventBatch.swap(lpeb); - } - - GML_SELECT_LUA_STATE(); - GML_DRCMUTEX_LOCK(lua); // ExecuteProjEventBatch - - if (Threading::IsSimThread()) - Threading::SetLuaBatchThread(false); - - for (std::vector::iterator i = lpeb.begin(); i != lpeb.end(); ++i) { - const LuaProjEventBase& e = *i; - switch (e.GetID()) { - case PROJ_CREATED: { - LUA_EVENT_CAST(LuaProjCreatedEvent, e); ProjectileCreated(ee.GetProjectile()); - } break; - case PROJ_DESTROYED: { - LUA_EVENT_CAST(LuaProjDestroyedEvent, e); ProjectileDestroyed(ee.GetProjectile()); - } break; - default: { - LOG_L(L_ERROR, "%s: Invalid Event %d", __FUNCTION__, e.GetID()); - } break; - } - } - - if (Threading::IsSimThread()) - Threading::SetLuaBatchThread(true); -} - - -void CLuaHandle::ExecuteFrameEventBatch() { - if (!UseEventBatch()) - return; - - std::vector lgeb; - { - GML_STDMUTEX_LOCK(glbatch); - - if (luaFrameEventBatch.empty()) - return; - - luaFrameEventBatch.swap(lgeb); - } - - GML_THRMUTEX_LOCK(unit, GML_DRAW); // ExecuteFrameEventBatch - GML_THRMUTEX_LOCK(feat, GML_DRAW); // ExecuteFrameEventBatch -// GML_THRMUTEX_LOCK(proj, GML_DRAW); // ExecuteFrameEventBatch - - GML_SELECT_LUA_STATE(); - GML_DRCMUTEX_LOCK(lua); // ExecuteFrameEventBatch - - if (Threading::IsSimThread()) - Threading::SetLuaBatchThread(false); - - for (std::vector::iterator i = lgeb.begin(); i != lgeb.end(); ++i) { - GameFrame(*i); - } - - if (Threading::IsSimThread()) - Threading::SetLuaBatchThread(true); -} - - -void CLuaHandle::ExecuteLogEventBatch() { - if (!UseEventBatch()) - return; - - std::vector lmeb; - { - GML_STDMUTEX_LOCK(mlbatch); - - if (luaLogEventBatch.empty()) - return; - - luaLogEventBatch.swap(lmeb); - } - - GML_THRMUTEX_LOCK(unit, GML_DRAW); // ExecuteLogEventBatch - GML_THRMUTEX_LOCK(feat, GML_DRAW); // ExecuteLogEventBatch -// GML_THRMUTEX_LOCK(proj, GML_DRAW); // ExecuteLogEventBatch - - GML_SELECT_LUA_STATE(); - GML_DRCMUTEX_LOCK(lua); // ExecuteLogEventBatch - - if (Threading::IsSimThread()) - Threading::SetLuaBatchThread(false); - - for (std::vector::iterator i = lmeb.begin(); i != lmeb.end(); ++i) { - const LuaLogEventBase& e = *i; - switch (e.GetID()) { - case LOG_CONSOLE_LINE: { - LUA_EVENT_CAST(LuaAddConsoleLineEvent, e); AddConsoleLine(ee.GetMessage(), ee.GetSection(), ee.GetLevel()); - } break; - default: { - LOG_L(L_ERROR, "%s: Invalid Event %d", __FUNCTION__, e.GetID()); - } break; - } - } - - if (Threading::IsSimThread()) - Threading::SetLuaBatchThread(true); -} - bool CLuaHandle::RecvLuaMsg(const string& msg, int playerID) { LUA_CALL_IN_CHECK(L, false); luaL_checkstack(L, 8, __FUNCTION__); + static const LuaHashString cmdStr("RecvLuaMsg"); if (!cmdStr.GetGlobalFunc(L)) return false; - lua_pushsstring(L, msg); // allow embedded 0's + lua_pushsstring(L, msg); // allows embedded 0's lua_pushnumber(L, playerID); // call the routine - if (!RunCallIn(cmdStr, 2, 1)) + if (!RunCallIn(L, cmdStr, 2, 1)) return false; - if (!lua_isboolean(L, -1)) { - lua_pop(L, 1); - return false; - } - const bool retval = !!lua_toboolean(L, -1); + const bool retval = luaL_optboolean(L, -1, false); lua_pop(L, 1); return retval; } @@ -1930,17 +1532,6 @@ /******************************************************************************/ -inline bool CLuaHandle::PushUnsyncedCallIn(lua_State *L, const LuaHashString& hs) -{ - // LuaUI keeps these call-ins in the Global table, - // the synced handles keep them in the Registry table - if (GetUserMode()) { - return hs.GetGlobalFunc(L); - } else { - return hs.GetRegistryFunc(L); - } -} - void CLuaHandle::Save(zipFile archive) { @@ -1952,7 +1543,7 @@ LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 3, __FUNCTION__); static const LuaHashString cmdStr("Save"); - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!cmdStr.GetGlobalFunc(L)) { return; } @@ -1960,7 +1551,7 @@ LuaZipFileWriter::PushNew(L, "", archive); // call the routine - RunCallInUnsynced(cmdStr, 1, 0); + RunCallIn(L, cmdStr, 1, 0); } @@ -1969,7 +1560,7 @@ LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 6, __FUNCTION__); static const LuaHashString cmdStr("UnsyncedHeightMapUpdate"); - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!cmdStr.GetGlobalFunc(L)) { return; } @@ -1979,7 +1570,7 @@ lua_pushnumber(L, rect.z2); // call the routine - RunCallInUnsynced(cmdStr, 4, 0); + RunCallIn(L, cmdStr, 4, 0); } @@ -1988,12 +1579,12 @@ LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 2, __FUNCTION__); static const LuaHashString cmdStr("Update"); - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!cmdStr.GetGlobalFunc(L)) { return; } // call the routine - RunCallInUnsynced(cmdStr, 0, 0); + RunCallIn(L, cmdStr, 0, 0); } @@ -2002,7 +1593,7 @@ LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 5, __FUNCTION__); static const LuaHashString cmdStr("ViewResize"); - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!cmdStr.GetGlobalFunc(L)) { return; } @@ -2023,7 +1614,7 @@ LuaPushNamedNumber(L, "viewPosY", globalRendering->viewPosY); // call the routine - RunCallInUnsynced(cmdStr, 1, 0); + RunCallIn(L, cmdStr, 1, 0); } @@ -2033,7 +1624,7 @@ LUA_CALL_IN_CHECK(L, false); luaL_checkstack(L, 4, __FUNCTION__); static const LuaHashString cmdStr("DefaultCommand"); - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!cmdStr.GetGlobalFunc(L)) { return false; } @@ -2063,7 +1654,7 @@ */ // call the routine - if (!RunCallInUnsynced(cmdStr, args, 1)) + if (!RunCallIn(L, cmdStr, args, 1)) return false; if (!lua_isnumber(L, 1)) { @@ -2077,113 +1668,62 @@ } - - -void CLuaHandle::DrawGenesis() +void CLuaHandle::RunDrawCallIn(const LuaHashString& hs) { LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 2, __FUNCTION__); - static const LuaHashString cmdStr("DrawGenesis"); - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!hs.GetGlobalFunc(L)) { return; } LuaOpenGL::SetDrawingEnabled(L, true); // call the routine - RunCallInUnsynced(cmdStr, 0, 0); + RunCallIn(L, hs, 0, 0); LuaOpenGL::SetDrawingEnabled(L, false); } -void CLuaHandle::DrawWorld() +void CLuaHandle::DrawGenesis() { - LUA_CALL_IN_CHECK(L); - luaL_checkstack(L, 2, __FUNCTION__); - static const LuaHashString cmdStr("DrawWorld"); - if (!PushUnsyncedCallIn(L, cmdStr)) { - return; - } - - LuaOpenGL::SetDrawingEnabled(L, true); + static const LuaHashString cmdStr("DrawGenesis"); + RunDrawCallIn(cmdStr); +} - // call the routine - RunCallInUnsynced(cmdStr, 0, 0); - LuaOpenGL::SetDrawingEnabled(L, false); +void CLuaHandle::DrawWorld() +{ + static const LuaHashString cmdStr("DrawWorld"); + RunDrawCallIn(cmdStr); } void CLuaHandle::DrawWorldPreUnit() { - LUA_CALL_IN_CHECK(L); - luaL_checkstack(L, 2, __FUNCTION__); static const LuaHashString cmdStr("DrawWorldPreUnit"); - if (!PushUnsyncedCallIn(L, cmdStr)) { - return; - } - - LuaOpenGL::SetDrawingEnabled(L, true); - - // call the routine - RunCallInUnsynced(cmdStr, 0, 0); - - LuaOpenGL::SetDrawingEnabled(L, false); + RunDrawCallIn(cmdStr); } void CLuaHandle::DrawWorldShadow() { - LUA_CALL_IN_CHECK(L); - luaL_checkstack(L, 2, __FUNCTION__); static const LuaHashString cmdStr("DrawWorldShadow"); - if (!PushUnsyncedCallIn(L, cmdStr)) { - return; - } - - LuaOpenGL::SetDrawingEnabled(L, true); - - // call the routine - RunCallInUnsynced(cmdStr, 0, 0); - - LuaOpenGL::SetDrawingEnabled(L, false); + RunDrawCallIn(cmdStr); } void CLuaHandle::DrawWorldReflection() { - LUA_CALL_IN_CHECK(L); - luaL_checkstack(L, 2, __FUNCTION__); static const LuaHashString cmdStr("DrawWorldReflection"); - if (!PushUnsyncedCallIn(L, cmdStr)) { - return; - } - - LuaOpenGL::SetDrawingEnabled(L, true); - - // call the routine - RunCallInUnsynced(cmdStr, 0, 0); - - LuaOpenGL::SetDrawingEnabled(L, false); + RunDrawCallIn(cmdStr); } void CLuaHandle::DrawWorldRefraction() { - LUA_CALL_IN_CHECK(L); - luaL_checkstack(L, 2, __FUNCTION__); static const LuaHashString cmdStr("DrawWorldRefraction"); - if (!PushUnsyncedCallIn(L, cmdStr)) { - return; - } - - LuaOpenGL::SetDrawingEnabled(L, true); - - // call the routine - RunCallInUnsynced(cmdStr, 0, 0); - - LuaOpenGL::SetDrawingEnabled(L, false); + RunDrawCallIn(cmdStr); } @@ -2192,7 +1732,7 @@ LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 4, __FUNCTION__); static const LuaHashString cmdStr("DrawScreen"); - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!cmdStr.GetGlobalFunc(L)) { return; } @@ -2202,7 +1742,7 @@ LuaOpenGL::SetDrawingEnabled(L, true); // call the routine - RunCallInUnsynced(cmdStr, 2, 0); + RunCallIn(L, cmdStr, 2, 0); LuaOpenGL::SetDrawingEnabled(L, false); } @@ -2213,7 +1753,7 @@ LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 4, __FUNCTION__); static const LuaHashString cmdStr("DrawScreenEffects"); - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!cmdStr.GetGlobalFunc(L)) { return; } @@ -2223,7 +1763,7 @@ LuaOpenGL::SetDrawingEnabled(L, true); // call the routine - RunCallInUnsynced(cmdStr, 2, 0); + RunCallIn(L, cmdStr, 2, 0); LuaOpenGL::SetDrawingEnabled(L, false); } @@ -2234,26 +1774,40 @@ LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 4, __FUNCTION__); static const LuaHashString cmdStr("DrawInMiniMap"); - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!cmdStr.GetGlobalFunc(L)) { return; } - const int xSize = minimap->GetSizeX(); - const int ySize = minimap->GetSizeY(); + lua_pushnumber(L, minimap->GetSizeX()); + lua_pushnumber(L, minimap->GetSizeY()); - if ((xSize < 1) || (ySize < 1)) { - lua_pop(L, 1); + const bool origDrawingState = LuaOpenGL::IsDrawingEnabled(L); + LuaOpenGL::SetDrawingEnabled(L, true); + + // call the routine + RunCallIn(L, cmdStr, 2, 0); + + LuaOpenGL::SetDrawingEnabled(L, origDrawingState); +} + + +void CLuaHandle::DrawInMiniMapBackground() +{ + LUA_CALL_IN_CHECK(L); + luaL_checkstack(L, 4, __FUNCTION__); + static const LuaHashString cmdStr("DrawInMiniMapBackground"); + if (!cmdStr.GetGlobalFunc(L)) { return; } - lua_pushnumber(L, xSize); - lua_pushnumber(L, ySize); + lua_pushnumber(L, minimap->GetSizeX()); + lua_pushnumber(L, minimap->GetSizeY()); const bool origDrawingState = LuaOpenGL::IsDrawingEnabled(L); LuaOpenGL::SetDrawingEnabled(L, true); // call the routine - RunCallInUnsynced(cmdStr, 2, 0); + RunCallIn(L, cmdStr, 2, 0); LuaOpenGL::SetDrawingEnabled(L, origDrawingState); } @@ -2264,22 +1818,21 @@ LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 3, __FUNCTION__); static const LuaHashString cmdStr("GameProgress"); - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!cmdStr.GetGlobalFunc(L)) { return; } lua_pushnumber(L, frameNum); // call the routine - RunCallInUnsynced(cmdStr, 1, 0); + RunCallIn(L, cmdStr, 1, 0); } /******************************************************************************/ /******************************************************************************/ - -bool CLuaHandle::KeyPress(unsigned short key, bool isRepeat) +bool CLuaHandle::KeyPress(int key, bool isRepeat) { if (!CheckModUICtrl()) { return false; @@ -2287,40 +1840,36 @@ LUA_CALL_IN_CHECK(L, false); luaL_checkstack(L, 6, __FUNCTION__); static const LuaHashString cmdStr("KeyPress"); - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!cmdStr.GetGlobalFunc(L)) { return false; // the call is not defined, do not take the event } - lua_pushnumber(L, key); + //FIXME we should never had started using directly SDL consts, somaeday we should weakly force lua-devs to fix their code + lua_pushinteger(L, SDL21_keysyms(key)); lua_createtable(L, 0, 4); - HSTR_PUSH_BOOL(L, "alt", !!keyInput->GetKeyState(SDLK_LALT)); - HSTR_PUSH_BOOL(L, "ctrl", !!keyInput->GetKeyState(SDLK_LCTRL)); - HSTR_PUSH_BOOL(L, "meta", !!keyInput->GetKeyState(SDLK_LMETA)); - HSTR_PUSH_BOOL(L, "shift", !!keyInput->GetKeyState(SDLK_LSHIFT)); + HSTR_PUSH_BOOL(L, "alt", !!KeyInput::GetKeyModState(KMOD_ALT)); + HSTR_PUSH_BOOL(L, "ctrl", !!KeyInput::GetKeyModState(KMOD_CTRL)); + HSTR_PUSH_BOOL(L, "meta", !!KeyInput::GetKeyModState(KMOD_GUI)); + HSTR_PUSH_BOOL(L, "shift", !!KeyInput::GetKeyModState(KMOD_SHIFT)); lua_pushboolean(L, isRepeat); CKeySet ks(key, false); lua_pushsstring(L, ks.GetString(true)); - - lua_pushnumber(L, keyInput->GetCurrentKeyUnicodeChar()); + lua_pushinteger(L, 0); //FIXME remove, was deprecated utf32 char (now uses TextInput for that) // call the function - if (!RunCallInUnsynced(cmdStr, 5, 1)) + if (!RunCallIn(L, cmdStr, 5, 1)) return false; - if (!lua_isboolean(L, -1)) { - lua_pop(L, 1); - return false; - } - const bool retval = !!lua_toboolean(L, -1); + const bool retval = luaL_optboolean(L, -1, false); lua_pop(L, 1); return retval; } -bool CLuaHandle::KeyRelease(unsigned short key) +bool CLuaHandle::KeyRelease(int key) { if (!CheckModUICtrl()) { return false; @@ -2328,32 +1877,52 @@ LUA_CALL_IN_CHECK(L, false); luaL_checkstack(L, 5, __FUNCTION__); static const LuaHashString cmdStr("KeyRelease"); - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!cmdStr.GetGlobalFunc(L)) { return false; // the call is not defined, do not take the event } - lua_pushnumber(L, key); + lua_pushinteger(L, SDL21_keysyms(key)); lua_createtable(L, 0, 4); - HSTR_PUSH_BOOL(L, "alt", !!keyInput->GetKeyState(SDLK_LALT)); - HSTR_PUSH_BOOL(L, "ctrl", !!keyInput->GetKeyState(SDLK_LCTRL)); - HSTR_PUSH_BOOL(L, "meta", !!keyInput->GetKeyState(SDLK_LMETA)); - HSTR_PUSH_BOOL(L, "shift", !!keyInput->GetKeyState(SDLK_LSHIFT)); + HSTR_PUSH_BOOL(L, "alt", !!KeyInput::GetKeyModState(KMOD_ALT)); + HSTR_PUSH_BOOL(L, "ctrl", !!KeyInput::GetKeyModState(KMOD_CTRL)); + HSTR_PUSH_BOOL(L, "meta", !!KeyInput::GetKeyModState(KMOD_GUI)); + HSTR_PUSH_BOOL(L, "shift", !!KeyInput::GetKeyModState(KMOD_SHIFT)); CKeySet ks(key, false); lua_pushsstring(L, ks.GetString(true)); - - lua_pushnumber(L, keyInput->GetCurrentKeyUnicodeChar()); + lua_pushinteger(L, 0); //FIXME remove, was deprecated utf32 char (now uses TextInput for that) // call the function - if (!RunCallInUnsynced(cmdStr, 4, 1)) + if (!RunCallIn(L, cmdStr, 4, 1)) return false; - if (!lua_isboolean(L, -1)) { - lua_pop(L, 1); + const bool retval = luaL_optboolean(L, -1, false); + lua_pop(L, 1); + return retval; +} + + +bool CLuaHandle::TextInput(const std::string& utf8) +{ + if (!CheckModUICtrl()) { return false; } - const bool retval = !!lua_toboolean(L, -1); + LUA_CALL_IN_CHECK(L, false); + luaL_checkstack(L, 3, __FUNCTION__); + static const LuaHashString cmdStr("TextInput"); + if (!cmdStr.GetGlobalFunc(L)) { + return false; // the call is not defined, do not take the event + } + + lua_pushsstring(L, utf8); + //lua_pushnumber(L, UTF8toUTF32(utf8)); + + // call the function + if (!RunCallIn(L, cmdStr, 1, 1)) + return false; + + const bool retval = luaL_optboolean(L, -1, false); lua_pop(L, 1); return retval; } @@ -2367,7 +1936,7 @@ LUA_CALL_IN_CHECK(L, false); luaL_checkstack(L, 5, __FUNCTION__); static const LuaHashString cmdStr("MousePress"); - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!cmdStr.GetGlobalFunc(L)) { return false; // the call is not defined, do not take the event } @@ -2376,29 +1945,25 @@ lua_pushnumber(L, button); // call the function - if (!RunCallInUnsynced(cmdStr, 3, 1)) + if (!RunCallIn(L, cmdStr, 3, 1)) return false; - if (!lua_isboolean(L, -1)) { - lua_pop(L, 1); - return false; - } - const bool retval = !!lua_toboolean(L, -1); + const bool retval = luaL_optboolean(L, -1, false); lua_pop(L, 1); return retval; } -int CLuaHandle::MouseRelease(int x, int y, int button) +void CLuaHandle::MouseRelease(int x, int y, int button) { if (!CheckModUICtrl()) { - return false; + return; } LUA_CALL_IN_CHECK(L, false); luaL_checkstack(L, 5, __FUNCTION__); static const LuaHashString cmdStr("MouseRelease"); - if (!PushUnsyncedCallIn(L, cmdStr)) { - return false; // the call is not defined, do not take the event + if (!cmdStr.GetGlobalFunc(L)) { + return; // the call is not defined, do not take the event } lua_pushnumber(L, x - globalRendering->viewPosX); @@ -2406,16 +1971,7 @@ lua_pushnumber(L, button); // call the function - if (!RunCallInUnsynced(cmdStr, 3, 1)) - return false; - - if (!lua_isnumber(L, -1)) { - lua_pop(L, 1); - return -1; - } - const int retval = lua_toint(L, -1) - 1; - lua_pop(L, 1); - return retval; + RunCallIn(L, cmdStr, 3, 0); } @@ -2427,7 +1983,7 @@ LUA_CALL_IN_CHECK(L, false); luaL_checkstack(L, 7, __FUNCTION__); static const LuaHashString cmdStr("MouseMove"); - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!cmdStr.GetGlobalFunc(L)) { return false; // the call is not defined, do not take the event } @@ -2438,14 +1994,10 @@ lua_pushnumber(L, button); // call the function - if (!RunCallInUnsynced(cmdStr, 5, 1)) + if (!RunCallIn(L, cmdStr, 5, 1)) return false; - if (!lua_isboolean(L, -1)) { - lua_pop(L, 1); - return false; - } - const bool retval = !!lua_toboolean(L, -1); + const bool retval = luaL_optboolean(L, -1, false); lua_pop(L, 1); return retval; } @@ -2459,7 +2011,7 @@ LUA_CALL_IN_CHECK(L, false); luaL_checkstack(L, 4, __FUNCTION__); static const LuaHashString cmdStr("MouseWheel"); - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!cmdStr.GetGlobalFunc(L)) { return false; // the call is not defined, do not take the event } @@ -2467,14 +2019,10 @@ lua_pushnumber(L, value); // call the function - if (!RunCallInUnsynced(cmdStr, 2, 1)) + if (!RunCallIn(L, cmdStr, 2, 1)) return false; - if (!lua_isboolean(L, -1)) { - lua_pop(L, 1); - return false; - } - const bool retval = !!lua_toboolean(L, -1); + const bool retval = luaL_optboolean(L, -1, false); lua_pop(L, 1); return retval; } @@ -2487,7 +2035,7 @@ LUA_CALL_IN_CHECK(L, false); luaL_checkstack(L, 4, __FUNCTION__); const LuaHashString cmdStr(event); - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!cmdStr.GetGlobalFunc(L)) { return false; // the call is not defined, do not take the event } @@ -2495,14 +2043,10 @@ lua_pushnumber(L, val2); // call the function - if (!RunCallInUnsynced(cmdStr, 2, 1)) + if (!RunCallIn(L, cmdStr, 2, 1)) return false; - if (!lua_isboolean(L, -1)) { - lua_pop(L, 1); - return false; - } - const bool retval = !!lua_toboolean(L, -1); + const bool retval = luaL_optboolean(L, -1, false); lua_pop(L, 1); return retval; } @@ -2515,7 +2059,7 @@ LUA_CALL_IN_CHECK(L, false); luaL_checkstack(L, 4, __FUNCTION__); static const LuaHashString cmdStr("IsAbove"); - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!cmdStr.GetGlobalFunc(L)) { return false; // the call is not defined } @@ -2523,14 +2067,10 @@ lua_pushnumber(L, globalRendering->viewSizeY - y - 1); // call the function - if (!RunCallInUnsynced(cmdStr, 2, 1)) + if (!RunCallIn(L, cmdStr, 2, 1)) return false; - if (!lua_isboolean(L, -1)) { - lua_pop(L, 1); - return false; - } - const bool retval = !!lua_toboolean(L, -1); + const bool retval = luaL_optboolean(L, -1, false); lua_pop(L, 1); return retval; } @@ -2544,7 +2084,7 @@ LUA_CALL_IN_CHECK(L, ""); luaL_checkstack(L, 4, __FUNCTION__); static const LuaHashString cmdStr("GetTooltip"); - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!cmdStr.GetGlobalFunc(L)) { return ""; // the call is not defined } @@ -2552,41 +2092,15 @@ lua_pushnumber(L, globalRendering->viewSizeY - y - 1); // call the function - if (!RunCallInUnsynced(cmdStr, 2, 1)) + if (!RunCallIn(L, cmdStr, 2, 1)) return ""; - if (!lua_isstring(L, -1)) { - lua_pop(L, 1); - return ""; - } - const string retval = lua_tostring(L, -1); + const string retval = luaL_optsstring(L, -1, ""); lua_pop(L, 1); return retval; } -bool CLuaHandle::ConfigCommand(const string& command) -{ - if (!CheckModUICtrl()) { - return true; // FIXME ? - } - LUA_CALL_IN_CHECK(L, true); - luaL_checkstack(L, 2, __FUNCTION__); - static const LuaHashString cmdStr("ConfigureLayout"); - if (!PushUnsyncedCallIn(L, cmdStr)) { - return true; // the call is not defined - } - - lua_pushsstring(L, command); - - // call the routine - if (!RunCallInUnsynced(cmdStr, 1, 0)) - return false; - - return true; -} - - bool CLuaHandle::CommandNotify(const Command& cmd) { if (!CheckModUICtrl()) { @@ -2595,7 +2109,7 @@ LUA_CALL_IN_CHECK(L, false); luaL_checkstack(L, 5, __FUNCTION__); static const LuaHashString cmdStr("CommandNotify"); - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!cmdStr.GetGlobalFunc(L)) { return false; // the call is not defined } @@ -2608,17 +2122,11 @@ LuaUtils::PushCommandOptionsTable(L, cmd, false); // call the function - if (!RunCallInUnsynced(cmdStr, 3, 1)) + if (!RunCallIn(L, cmdStr, 3, 1)) return false; // get the results - if (!lua_isboolean(L, -1)) { - LOG_L(L_WARNING, "%s() bad return value", cmdStr.GetString().c_str()); - lua_pop(L, 1); - return false; - } - - const bool retval = !!lua_toboolean(L, -1); + const bool retval = luaL_optboolean(L, -1, false); lua_pop(L, 1); return retval; } @@ -2629,20 +2137,19 @@ if (!CheckModUICtrl()) { return true; // FIXME? } - LUA_LOG_BATCH_PUSH(true, LuaAddConsoleLineEvent(msg, section, level)) + LUA_CALL_IN_CHECK(L, true); luaL_checkstack(L, 4, __FUNCTION__); static const LuaHashString cmdStr("AddConsoleLine"); - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!cmdStr.GetGlobalFunc(L)) { return true; // the call is not defined } lua_pushsstring(L, msg); - // FIXME: makes no sense now, but *gets might expect this - lua_pushnumber(L, 0); // priority XXX replace 0 with level? + lua_pushnumber(L, level); // call the function - if (!RunCallIn(cmdStr, 2, 0)) + if (!RunCallIn(L, cmdStr, 2, 0)) return false; return true; @@ -2658,14 +2165,14 @@ LUA_CALL_IN_CHECK(L, false); luaL_checkstack(L, 3, __FUNCTION__); static const LuaHashString cmdStr("GroupChanged"); - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!cmdStr.GetGlobalFunc(L)) { return false; // the call is not defined } lua_pushnumber(L, groupID); // call the routine - if (!RunCallInUnsynced(cmdStr, 1, 0)) + if (!RunCallIn(L, cmdStr, 1, 0)) return false; return true; @@ -2683,7 +2190,7 @@ LUA_CALL_IN_CHECK(L, ""); luaL_checkstack(L, 6, __FUNCTION__); static const LuaHashString cmdStr("WorldTooltip"); - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!cmdStr.GetGlobalFunc(L)) { return ""; // the call is not defined } @@ -2711,14 +2218,10 @@ } // call the routine - if (!RunCallInUnsynced(cmdStr, args, 1)) + if (!RunCallIn(L, cmdStr, args, 1)) return ""; - if (!lua_isstring(L, -1)) { - lua_pop(L, 1); - return ""; - } - const string retval = lua_tostring(L, -1); + const string retval = luaL_optstring(L, -1, ""); lua_pop(L, 1); return retval; } @@ -2735,7 +2238,7 @@ LUA_CALL_IN_CHECK(L, false); luaL_checkstack(L, 9, __FUNCTION__); static const LuaHashString cmdStr("MapDrawCmd"); - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!cmdStr.GetGlobalFunc(L)) { return false; // the call is not defined } @@ -2776,15 +2279,11 @@ } // call the routine - if (!RunCallInUnsynced(cmdStr, args, 1)) + if (!RunCallIn(L, cmdStr, args, 1)) return false; // take the event? - if (!lua_isboolean(L, -1)) { - lua_pop(L, 1); - return false; - } - const bool retval = lua_toboolean(L, -1); + const bool retval = luaL_optboolean(L, -1, false); lua_pop(L, 1); return retval; } @@ -2799,7 +2298,7 @@ LUA_CALL_IN_CHECK(L, false); luaL_checkstack(L, 5, __FUNCTION__); static const LuaHashString cmdStr("GameSetup"); - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!cmdStr.GetGlobalFunc(L)) { return false; } @@ -2815,11 +2314,12 @@ } // call the routine - if (!RunCallInUnsynced(cmdStr, 3, 2)) + if (!RunCallIn(L, cmdStr, 3, 2)) return false; if (lua_isboolean(L, -2)) { if (lua_toboolean(L, -2)) { + // only allow ready-state change if Lua takes the event if (lua_isboolean(L, -1)) { ready = lua_toboolean(L, -1); } @@ -2842,7 +2342,7 @@ // is either CLuaRules* or CLuaUI*, // but the AI call-in is always unsynced! - if (!PushUnsyncedCallIn(L, cmdStr)) { + if (!cmdStr.GetGlobalFunc(L)) { return NULL; } @@ -2859,7 +2359,7 @@ argCount = 2; } - if (!RunCallIn(cmdStr, argCount, 1)) + if (!RunCallIn(L, cmdStr, argCount, 1)) return NULL; if (lua_isstring(L, -1)) @@ -2872,49 +2372,59 @@ /******************************************************************************/ /******************************************************************************/ -CONFIG(float, MaxLuaGarbageCollectionTime ).defaultValue(1000.0f / GAME_SPEED).minimumValue(1.0f); // ms -CONFIG( int, MaxLuaGarbageCollectionSteps).defaultValue(10000 ).minimumValue(1 ); -CONFIG( int, MaxLuaGarbageMemoryFootPrint).defaultValue(64 ).minimumValue( 32); // MB +CONFIG(float, MaxLuaGarbageCollectionTime ).defaultValue(5.f).minimumValue(1.0f).description("in MilliSecs"); + void CLuaHandle::CollectGarbage() { - SELECT_LUA_STATE(); - lua_gc(L, LUA_GCSTOP, 0); // don't collect garbage outside of this function + lua_lock(L_GC); + //SCOPED_MT_TIMER("CollectGarbage"); // this func doesn't run in parallel yet, cause of problems with IsHandleRunning() - static const float maxLuaGarbageCollectTime = configHandler->GetFloat("MaxLuaGarbageCollectionTime" ); - static const int maxLuaGarbageCollectSteps = configHandler->GetInt ("MaxLuaGarbageCollectionSteps"); - static const int maxLuaGarbageMemFootPrint = configHandler->GetInt ("MaxLuaGarbageMemoryFootPrint"); + // note: total footprint INCLUDING garbage + int luaMemFootPrintKB = lua_gc(L_GC, LUA_GCCOUNT, 0); - // kilobytes --> megabytes (note: total footprint INCLUDING garbage) - const int luaMemFootPrint = lua_gc(L, LUA_GCCOUNT, 0) / 1024; + // 30x per second !!! + static const float maxLuaGarbageCollectTime = configHandler->GetFloat("MaxLuaGarbageCollectionTime"); + float maxRunTime = smoothstep(10, 100, luaMemFootPrintKB / 1024) * maxLuaGarbageCollectTime; + + const spring_time startTime = spring_gettime(); + const spring_time endTime = startTime + spring_msecs(maxRunTime); + static int gcsteps = 10; + int numLuaGarbageCollectIters = 0; + + SetHandleRunning(L_GC, true); + + // collect garbage until time runs out + while (spring_gettime() < endTime) { + numLuaGarbageCollectIters++; + if (!lua_gc(L_GC, LUA_GCSTEP, gcsteps)) + continue; + + // garbage-collection cycle finished + const int luaMemFootPrintNow = lua_gc(L_GC, LUA_GCCOUNT, 0); + const int luaMemFootPrintChange = luaMemFootPrintNow - luaMemFootPrintKB; + luaMemFootPrintKB = luaMemFootPrintNow; - // 25MB --> 20usecs, 100MB --> 100usecs (30x per second) - const float rawRunTime = luaMemFootPrint * (0.02f + 0.08f * smoothstep(25, 100, luaMemFootPrint)); - const float maxRunTime = std::min(rawRunTime, maxLuaGarbageCollectTime); + // cycle didn't freed any memory early-exit + if (luaMemFootPrintChange == 0) + break; + } - const spring_time endTime = spring_gettime() + spring_msecs(maxRunTime); + lua_gc(L_GC, LUA_GCSTOP, 0); // don't collect garbage outside of this function + SetHandleRunning(L_GC, false); + lua_unlock(L_GC); - // collect garbage until time runs out or the maximum - // number of steps is exceeded, whichever comes first - SetRunning(L, true); + const spring_time finishTime = spring_gettime(); - for (int n = 0; (n < maxLuaGarbageCollectSteps) && (spring_gettime() < endTime); n++) { - if (lua_gc(L, LUA_GCSTEP, 10)) { - // garbage-collection finished - break; - } - } + if (gcsteps > 1 && numLuaGarbageCollectIters > 0) { + // runtime optimize number of steps to process in a batch + const float avgTimePerLoopIter = (finishTime - startTime).toMilliSecsf() / numLuaGarbageCollectIters; - // limit the size of the garbage pile even if time is already up - // lapi.cpp::lua_gc should return (g->totalbytes - g->estimate) if - // what == LUA_GCCOUNT and data != 0 for this to work without risk - // of infinite loop, but Lua VM hacks should be avoided - #if 0 - while ((lua_gc(L, LUA_GCCOUNT, 0) / 1024) >= maxLuaGarbageMemFootPrint) - lua_gc(L, LUA_GCSTEP, 2); - #endif + if (avgTimePerLoopIter > (maxLuaGarbageCollectTime * 0.150f)) gcsteps--; + if (avgTimePerLoopIter < (maxLuaGarbageCollectTime * 0.075f)) gcsteps++; + } - SetRunning(L, false); + eventHandler.DbgTimingInfo(TIMING_GC, startTime, finishTime); } /******************************************************************************/ @@ -2925,6 +2435,7 @@ HSTR_PUSH(L, "Script"); lua_newtable(L); { HSTR_PUSH_CFUNC(L, "Kill", KillActiveHandle); + HSTR_PUSH_CFUNC(L, "UpdateCallIn", CallOutUpdateCallIn); HSTR_PUSH_CFUNC(L, "GetName", CallOutGetName); HSTR_PUSH_CFUNC(L, "GetSynced", CallOutGetSynced); HSTR_PUSH_CFUNC(L, "GetFullCtrl", CallOutGetFullCtrl); @@ -2936,10 +2447,10 @@ HSTR_PUSH_CFUNC(L, "GetGlobal", CallOutGetGlobal); HSTR_PUSH_CFUNC(L, "GetRegistry", CallOutGetRegistry); HSTR_PUSH_CFUNC(L, "GetCallInList", CallOutGetCallInList); + HSTR_PUSH_CFUNC(L, "IsEngineMinVersion", CallOutIsEngineMinVersion); // special team constants HSTR_PUSH_NUMBER(L, "NO_ACCESS_TEAM", CEventClient::NoAccessTeam); HSTR_PUSH_NUMBER(L, "ALL_ACCESS_TEAM", CEventClient::AllAccessTeam); -//FIXME LuaArrays::PushEntries(L); } lua_rawset(L, -3); @@ -3029,6 +2540,36 @@ } +int CLuaHandle::CallOutIsEngineMinVersion(lua_State* L) +{ + const int minMajorVer = luaL_checkint(L, 1); + const int minMinorVer = luaL_optinteger(L, 2, 0); + const int minCommits = luaL_optinteger(L, 3, 0); + + if (StringToInt(SpringVersion::GetMajor()) < minMajorVer) { + lua_pushboolean(L, false); + return 1; + } + + if (StringToInt(SpringVersion::GetMajor()) == minMajorVer) { + if (StringToInt(SpringVersion::GetMinor()) < minMinorVer) { + if (GetHandleSynced(L)) { // minor is only allowed to contain unsynced changes! + lua_pushboolean(L, false); + return 1; + } + } + + if (StringToInt(SpringVersion::GetCommits()) < minCommits) { + lua_pushboolean(L, false); + return 1; + } + } + + lua_pushboolean(L, true); + return 1; +} + + int CLuaHandle::CallOutGetCallInList(lua_State* L) { vector list; @@ -3050,30 +2591,12 @@ } -int CLuaHandle::CallOutSyncedUpdateCallIn(lua_State* L) -{ - if (!Threading::IsGameLoadThread() && !Threading::IsSimThread()) { - // FIXME: - // if this can be called from a non-sim context, this code is insufficient - // --> no shit, did *someone* perhaps forget to consider the LoadingMT case? - return 0; - } - - CLuaHandle* lh = GetHandle(L); - lh->SyncedUpdateCallIn(lh->GetActiveState(), luaL_checkstring(L, 1)); - return 0; -} - - -int CLuaHandle::CallOutUnsyncedUpdateCallIn(lua_State* L) +int CLuaHandle::CallOutUpdateCallIn(lua_State* L) { - if (!Threading::IsGameLoadThread() && Threading::IsSimThread()) { - // FIXME: see CallOutSyncedUpdateCallIn - return 0; - } + const string name = luaL_checkstring(L, 1); CLuaHandle* lh = GetHandle(L); - lh->UnsyncedUpdateCallIn(lh->GetActiveState(), luaL_checkstring(L, 1)); + lh->UpdateCallIn(L, name); return 0; } diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaHandle.h spring-98.0~14.04~ppa6/rts/Lua/LuaHandle.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaHandle.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaHandle.h 2014-10-07 20:09:51.000000000 +0000 @@ -6,10 +6,9 @@ #include "System/EventClient.h" //FIXME#include "LuaArrays.h" -#include "LuaCallInCheck.h" #include "LuaContextData.h" -#include "LuaUtils.h" -#include "System/Platform/Threading.h" +#include "LuaHashString.h" +#include "lib/lua/include/LuaInclude.h" //FIXME needed for GetLuaContextData #include #include @@ -42,6 +41,7 @@ class LuaTextures; class LuaShaders; class CLuaDisplayLists; +class CLuaRules; class CLuaHandle : public CEventClient @@ -52,86 +52,55 @@ void ResetCallinErrors() { callinErrors = 0; } public: -#define GET_CONTEXT_DATA(v) (GetLuaContextData(L ? L : GetActiveState())->v) -#define GET_ACTIVE_CONTEXT_DATA(v) (GetLuaContextData(GetActiveState())->v) -#define GET_HANDLE_CONTEXT_DATA(v) (GetLuaContextData(L)->v) -#define SET_ACTIVE_CONTEXT_DATA(v) if(all) { D_Sim.v = _##v; D_Draw.v = _##v; } else GET_ACTIVE_CONTEXT_DATA(v) = _##v -#define SET_HANDLE_CONTEXT_DATA(v) GET_HANDLE_CONTEXT_DATA(v) = _##v - - void SetFullRead(bool _fullRead, bool all = false) { SET_ACTIVE_CONTEXT_DATA(fullRead); } - bool GetFullRead() const { return GET_ACTIVE_CONTEXT_DATA(fullRead); } // virtual function in CEventClient - static void SetHandleFullRead(const lua_State* L, bool _fullRead) { SET_HANDLE_CONTEXT_DATA(fullRead); } - static bool GetHandleFullRead(const lua_State* L) { return GET_HANDLE_CONTEXT_DATA(fullRead); } - - void SetFullCtrl(bool _fullCtrl, bool all = false) { SET_ACTIVE_CONTEXT_DATA(fullCtrl); } - bool GetFullCtrl() const { return GET_ACTIVE_CONTEXT_DATA(fullCtrl); } - static void SetHandleFullCtrl(const lua_State* L, bool _fullCtrl) { SET_HANDLE_CONTEXT_DATA(fullCtrl); } - static bool GetHandleFullCtrl(const lua_State* L) { return GET_HANDLE_CONTEXT_DATA(fullCtrl); } - - void SetCtrlTeam(int _ctrlTeam, bool all = false) { SET_ACTIVE_CONTEXT_DATA(ctrlTeam); } - int GetCtrlTeam() const { return GET_ACTIVE_CONTEXT_DATA(ctrlTeam); } - static void SetHandleCtrlTeam(const lua_State* L, int _ctrlTeam) { SET_HANDLE_CONTEXT_DATA(ctrlTeam); } - static int GetHandleCtrlTeam(const lua_State* L) { return GET_HANDLE_CONTEXT_DATA(ctrlTeam); } - - void SetReadTeam(int _readTeam, bool all = false) { SET_ACTIVE_CONTEXT_DATA(readTeam); } - int GetReadTeam() const { return GET_ACTIVE_CONTEXT_DATA(readTeam); } - static void SetHandleReadTeam(const lua_State* L, int _readTeam) { SET_HANDLE_CONTEXT_DATA(readTeam); } - static int GetHandleReadTeam(const lua_State* L) { return GET_HANDLE_CONTEXT_DATA(readTeam); } - - void SetReadAllyTeam(int _readAllyTeam, bool all = false) { SET_ACTIVE_CONTEXT_DATA(readAllyTeam); } - int GetReadAllyTeam() const { return GET_ACTIVE_CONTEXT_DATA(readAllyTeam); } // virtual function in CEventClient - static void SetHandleReadAllyTeam(const lua_State* L, int _readAllyTeam) { SET_HANDLE_CONTEXT_DATA(readAllyTeam); } - static int GetHandleReadAllyTeam(const lua_State* L) { return GET_HANDLE_CONTEXT_DATA(readAllyTeam); } - - void SetSelectTeam(int _selectTeam, bool all = false) { SET_ACTIVE_CONTEXT_DATA(selectTeam); } - int GetSelectTeam() const { return GET_ACTIVE_CONTEXT_DATA(selectTeam); } - static void SetHandleSelectTeam(const lua_State* L, int _selectTeam) { SET_HANDLE_CONTEXT_DATA(selectTeam); } - static int GetHandleSelectTeam(const lua_State* L) { return GET_HANDLE_CONTEXT_DATA(selectTeam); } - - void SetSynced(bool _synced, bool all = false) { SET_ACTIVE_CONTEXT_DATA(synced); } - bool GetSynced() const { return GET_ACTIVE_CONTEXT_DATA(synced); } - static void SetHandleSynced(const lua_State* L, bool _synced) { SET_HANDLE_CONTEXT_DATA(synced); } - static bool GetHandleSynced(const lua_State* L) { return GET_HANDLE_CONTEXT_DATA(synced); } + #define PERMISSIONS_FUNCS(Name, type, dataArg) \ + void Set ## Name(type _ ## dataArg) { GetLuaContextData(L)->dataArg = _ ## dataArg; } \ + type Get ## Name() const { return GetLuaContextData(L)->dataArg; } \ + static void SetHandle ## Name(const lua_State* L, type _ ## dataArg) { GetLuaContextData(L)->dataArg = _ ## dataArg;; } \ + static type GetHandle ## Name(const lua_State* L) { return GetLuaContextData(L)->dataArg; } + + PERMISSIONS_FUNCS(FullRead, bool, fullRead); // virtual function in CEventClient + PERMISSIONS_FUNCS(FullCtrl, bool, fullCtrl); + PERMISSIONS_FUNCS(CtrlTeam, int, ctrlTeam); + PERMISSIONS_FUNCS(ReadTeam, int, readTeam); + PERMISSIONS_FUNCS(ReadAllyTeam, int, readAllyTeam); // virtual function in CEventClient + PERMISSIONS_FUNCS(SelectTeam, int, selectTeam); - static CLuaHandle* GetHandle(lua_State* L) { return GET_HANDLE_CONTEXT_DATA(owner); } + #undef PERMISSIONS_FUNCS + + static bool GetHandleSynced(const lua_State* L) { return GetLuaContextData(L)->synced; } - static bool GetHandleUserMode(const lua_State* L) { return GET_HANDLE_CONTEXT_DATA(owner->GetUserMode()); } bool GetUserMode() const { return userMode; } + static bool GetHandleUserMode(const lua_State* L) { return GetLuaContextData(L)->owner->GetUserMode(); } - static bool CheckModUICtrl(lua_State* L) { return GetModUICtrl() || GetHandleUserMode(L); } bool CheckModUICtrl() const { return GetModUICtrl() || GetUserMode(); } + static bool CheckModUICtrl(lua_State* L) { return GetModUICtrl() || GetHandleUserMode(L); } - void SetRunning(lua_State* L, const bool _running) { GET_HANDLE_CONTEXT_DATA(running) += (_running) ? +1 : -1; assert( GET_HANDLE_CONTEXT_DATA(running) >= 0); } - bool IsRunning() const { return (GET_ACTIVE_CONTEXT_DATA(running) > 0); } + static int GetHandleAllowChanges(const lua_State* L) { return GetLuaContextData(L)->allowChanges; } -//FIXME LuaArrays& GetArrays(const lua_State* L = NULL) { return GET_CONTEXT_DATA(arrays); } - LuaShaders& GetShaders(const lua_State* L = NULL) { return GET_CONTEXT_DATA(shaders); } - LuaTextures& GetTextures(const lua_State* L = NULL) { return GET_CONTEXT_DATA(textures); } -//FIXME LuaVBOs& GetVBOs(const lua_State* L = NULL) { return GET_CONTEXT_DATA(vbos); } - LuaFBOs& GetFBOs(const lua_State* L = NULL) { return GET_CONTEXT_DATA(fbos); } - LuaRBOs& GetRBOs(const lua_State* L = NULL) { return GET_CONTEXT_DATA(rbos); } - CLuaDisplayLists& GetDisplayLists(const lua_State* L = NULL) { return GET_CONTEXT_DATA(displayLists); } + static CLuaHandle* GetHandle(lua_State* L) { return GetLuaContextData(L)->owner; } - public: // call-ins - bool WantsEvent(const string& name) { - BEGIN_ITERATE_LUA_STATES(); - { - GML_DRCMUTEX_LOCK(lua); // WantsEvent - - // ask our derived instance - if (HasCallIn(L, name)) - return true; - } - END_ITERATE_LUA_STATES(); - return false; + static void SetHandleRunning(lua_State* L, const bool _running) { + GetLuaContextData(L)->running += (_running) ? +1 : -1; + assert( GetLuaContextData(L)->running >= 0); } + static bool IsHandleRunning(lua_State* L) { return (GetLuaContextData(L)->running > 0); } + bool IsRunning() const { return IsHandleRunning(L); } - // HasCallIn is only implemented by LuaHandleSynced/LuaIntro/LuaUI - virtual bool HasCallIn(lua_State* L, const string& name) { return false; } // FIXME - virtual bool SyncedUpdateCallIn(lua_State* L, const string& name) { return false; } - virtual bool UnsyncedUpdateCallIn(lua_State* L, const string& name) { return false; } + bool IsValid() const { return (L != NULL); } - void Shutdown(); + //FIXME needed by LuaSyncedTable (can be solved cleaner?) + lua_State* GetLuaState() const { return L; } + + LuaShaders& GetShaders(const lua_State* L = NULL) { return GetLuaContextData(L)->shaders; } + LuaTextures& GetTextures(const lua_State* L = NULL) { return GetLuaContextData(L)->textures; } + LuaFBOs& GetFBOs(const lua_State* L = NULL) { return GetLuaContextData(L)->fbos; } + LuaRBOs& GetRBOs(const lua_State* L = NULL) { return GetLuaContextData(L)->rbos; } + CLuaDisplayLists& GetDisplayLists(const lua_State* L = NULL) { return GetLuaContextData(L)->displayLists; } + + public: // call-ins + bool WantsEvent(const string& name) { return HasCallIn(L, name); } + virtual bool HasCallIn(lua_State* L, const string& name); + virtual bool UpdateCallIn(lua_State* L, const string& name); void Load(IArchive* archive); @@ -167,6 +136,7 @@ int projectileID, bool paralyzer); void UnitExperience(const CUnit* unit, float oldExperience); + void UnitHarvestStorageFull(const CUnit* unit); void UnitSeismicPing(const CUnit* unit, int allyTeam, const float3& pos, float strength); @@ -207,19 +177,17 @@ void StockpileChanged(const CUnit* owner, const CWeapon* weapon, int oldCount); - // LuaHandleSynced wraps this to set allowChanges - virtual bool RecvLuaMsg(const string& msg, int playerID); - void Save(zipFile archive); void UnsyncedHeightMapUpdate(const SRectangle& rect); void Update(); - bool KeyPress(unsigned short key, bool isRepeat); - bool KeyRelease(unsigned short key); + bool KeyPress(int key, bool isRepeat); + bool KeyRelease(int key); + bool TextInput(const std::string& utf8); bool MouseMove(int x, int y, int dx, int dy, int button); bool MousePress(int x, int y, int button); - int MouseRelease(int x, int y, int button); // return a cmd index, or -1 + void MouseRelease(int x, int y, int button); bool MouseWheel(bool up, float value); bool JoystickEvent(const std::string& event, int val1, int val2); bool IsAbove(int x, int y); @@ -227,8 +195,6 @@ bool DefaultCommand(const CUnit* unit, const CFeature* feature, int& cmd); - bool ConfigCommand(const string& command); - bool CommandNotify(const Command& cmd); bool AddConsoleLine(const string& msg, const string& section, int level); @@ -260,96 +226,54 @@ void DrawScreenEffects(); void DrawScreen(); void DrawInMiniMap(); + void DrawInMiniMapBackground(); void GameProgress(int frameNum); void CollectGarbage(); - public: // custom call-in (inter-script calls) - virtual bool HasSyncedXCall(const string& funcName) { return false; } - virtual bool HasUnsyncedXCall(lua_State* srcState, const string& funcName) { return false; } - virtual int SyncedXCall(lua_State* srcState, const string& funcName) { - return 0; - } - virtual int UnsyncedXCall(lua_State* srcState, const string& funcName) { - return 0; - } - - struct DelayDataDump { - std::vector data; - std::vector dump; - bool xcall; - }; - - /// @return true if any calls were processed, false otherwise - bool ExecuteCallsFromSynced(bool forced = true); - virtual void RecvFromSynced(lua_State* srcState, int args); - void RecvFromSim(int args); - void DelayRecvFromSynced(lua_State* srcState, int args); - std::vector delayedCallsFromSynced; - static int SendToUnsynced(lua_State* L); + public: // Non-eventhandler call-ins + void Shutdown(); + bool GotChatMsg(const string& msg, int playerID); + bool RecvLuaMsg(const string& msg, int playerID); - void UpdateThreading(); + public: // custom call-in (inter-script calls) + bool HasXCall(const string& funcName) { return HasCallIn(L, funcName); } + int XCall(lua_State* srcState, const string& funcName); protected: - CLuaHandle(const string& name, int order, bool userMode); + CLuaHandle(const string& name, int order, bool userMode, bool synced); virtual ~CLuaHandle(); void KillLua(); + static void PushTracebackFuncToRegistry(lua_State* L); + bool AddBasicCalls(lua_State* L); bool LoadCode(lua_State* L, const string& code, const string& debug); - bool AddEntriesToTable(lua_State* L, const char* name, bool (*entriesFunc)(lua_State*)); + static bool AddEntriesToTable(lua_State* L, const char* name, bool (*entriesFunc)(lua_State*)); /// returns error code and sets traceback on error - int RunCallInTraceback(const LuaHashString* hs, int inArgs, int outArgs, int errFuncIndex, std::string& tracebackMsg, bool popErrFunc); + int RunCallInTraceback(lua_State* L, const LuaHashString* hs, int inArgs, int outArgs, int errFuncIndex, std::string& tracebackMsg, bool popErrFunc); /// returns false and prints message to log on error - bool RunCallInTraceback(const LuaHashString& hs, int inArgs, int outArgs, int errFuncIndex, bool popErrFunc = true); + bool RunCallInTraceback(lua_State* L, const LuaHashString& hs, int inArgs, int outArgs, int errFuncIndex, bool popErrFunc = true); /// returns false and and sets errormessage on error - bool RunCallIn(int inArgs, int outArgs, std::string& errormessage); + bool RunCallIn(lua_State* L, int inArgs, int outArgs, std::string& errormessage); /// returns false and prints message to log on error - bool RunCallIn(const LuaHashString& hs, int inArgs, int outArgs); - bool RunCallInUnsynced(const LuaHashString& hs, int inArgs, int outArgs); + bool RunCallIn(lua_State* L, const LuaHashString& hs, int inArgs, int outArgs); void LosCallIn(const LuaHashString& hs, const CUnit* unit, int allyTeam); void UnitCallIn(const LuaHashString& hs, const CUnit* unit); - bool PushUnsyncedCallIn(lua_State* L, const LuaHashString& hs); - - protected: - // MT stuff - bool singleState; - // LUA_MT_OPT inserted below mainly so that compiler can optimize code - bool SingleState() const { return !(LUA_MT_OPT & LUA_STATE) || singleState; } // Is this handle using a single Lua state? - bool copyExportTable; - bool CopyExportTable() const { return (LUA_MT_OPT & LUA_STATE) && copyExportTable; } // Copy the table _G.EXPORT --> SYNCED.EXPORT between dual states? - static bool useDualStates; - static bool UseDualStates() { return (LUA_MT_OPT & LUA_STATE) && useDualStates; } // Is Lua handle splitting enabled (globally)? - bool useEventBatch; - bool UseEventBatch() const { return (LUA_MT_OPT & LUA_BATCH) && useEventBatch; } // Use event batch to forward "synced" luaui events into draw thread? - bool purgeCallsFromSyncedBatch; - bool PurgeCallsFromSyncedBatch() const { return (LUA_MT_OPT & LUA_STATE) && purgeCallsFromSyncedBatch; } // Automatically clean deleted objects/IDs from the SendToUnsynced/XCall batch - - lua_State* ForceUnsyncedState() { lua_State* L_Prev = L_Sim; if (!SingleState() && Threading::IsSimThread()) L_Sim = L_Draw; return L_Prev; } - void RestoreState(lua_State* L_Prev) { if (!SingleState() && Threading::IsSimThread()) L_Sim = L_Prev; } - - lua_State* GetActiveState() { - return (SingleState() || Threading::IsSimThread()) ? L_Sim : L_Draw; - } - const lua_State* GetActiveState() const { - return (SingleState() || Threading::IsSimThread()) ? L_Sim : L_Draw; - } - - bool IsValid() const { return (L_Sim != NULL) && (L_Draw != NULL); } + void RunDrawCallIn(const LuaHashString& hs); protected: bool userMode; - lua_State* L_Sim; - lua_State* L_Draw; + lua_State* L; + luaContextData D; - luaContextData D_Sim; - luaContextData D_Draw; + lua_State* L_GC; bool killMe; string killMsg; @@ -360,21 +284,7 @@ int callinErrors; - public: // EventBatch - void ExecuteUnitEventBatch(); - void ExecuteFeatEventBatch(); - void ExecuteProjEventBatch(); - void ExecuteFrameEventBatch(); - void ExecuteLogEventBatch(); - - protected: - std::vector luaUnitEventBatch; - std::vector luaFeatEventBatch; - std::vector luaProjEventBatch; - std::vector luaLogEventBatch; - std::vector luaFrameEventBatch; - - protected: // call-outs + private: // call-outs static int KillActiveHandle(lua_State* L); static int CallOutGetName(lua_State* L); static int CallOutGetSynced(lua_State* L); @@ -387,17 +297,15 @@ static int CallOutGetGlobal(lua_State* L); static int CallOutGetRegistry(lua_State* L); static int CallOutGetCallInList(lua_State* L); - static int CallOutSyncedUpdateCallIn(lua_State* L); - static int CallOutUnsyncedUpdateCallIn(lua_State* L); + static int CallOutUpdateCallIn(lua_State* L); + static int CallOutIsEngineMinVersion(lua_State* L); public: // static -//FIXME static LuaArrays& GetActiveArrays(lua_State* L) { return GET_HANDLE_CONTEXT_DATA(arrays); } - static inline LuaShaders& GetActiveShaders(lua_State* L) { return GET_HANDLE_CONTEXT_DATA(shaders); } - static inline LuaTextures& GetActiveTextures(lua_State* L) { return GET_HANDLE_CONTEXT_DATA(textures); } -//FIXME static LuaVBOs& GetActiveVBOs(lua_State* L) { return GET_HANDLE_CONTEXT_DATA(vbos); } - static inline LuaFBOs& GetActiveFBOs(lua_State* L) { return GET_HANDLE_CONTEXT_DATA(fbos); } - static inline LuaRBOs& GetActiveRBOs(lua_State* L) { return GET_HANDLE_CONTEXT_DATA(rbos); } - static inline CLuaDisplayLists& GetActiveDisplayLists(lua_State* L) { return GET_HANDLE_CONTEXT_DATA(displayLists); } + static inline LuaShaders& GetActiveShaders(lua_State* L) { return GetLuaContextData(L)->shaders; } + static inline LuaTextures& GetActiveTextures(lua_State* L) { return GetLuaContextData(L)->textures; } + static inline LuaFBOs& GetActiveFBOs(lua_State* L) { return GetLuaContextData(L)->fbos; } + static inline LuaRBOs& GetActiveRBOs(lua_State* L) { return GetLuaContextData(L)->rbos; } + static inline CLuaDisplayLists& GetActiveDisplayLists(lua_State* L) { return GetLuaContextData(L)->displayLists; } static void SetDevMode(bool value) { devMode = value; } static bool GetDevMode() { return devMode; } @@ -407,9 +315,6 @@ static void HandleLuaMsg(int playerID, int script, int mode, const std::vector& msg); - static bool IsDrawCallIn() { - return (LUA_MT_OPT & LUA_MUTEX) && !Threading::IsSimThread(); - } protected: // static static bool devMode; // allows real file access @@ -417,25 +322,24 @@ // FIXME: because CLuaUnitScript needs to access RunCallIn friend class CLuaUnitScript; + + // FIXME needs access to L & RunCallIn + friend class CLuaRules; }; -inline bool CLuaHandle::RunCallIn(const LuaHashString& hs, int inArgs, int outArgs) +inline bool CLuaHandle::RunCallIn(lua_State* L, const LuaHashString& hs, int inArgs, int outArgs) { - return RunCallInTraceback(hs, inArgs, outArgs, 0, false); + return RunCallInTraceback(L, hs, inArgs, outArgs, 0, false); } -inline bool CLuaHandle::RunCallInUnsynced(const LuaHashString& hs, int inArgs, int outArgs) +inline bool CLuaHandle::RunCallIn(lua_State* L, int inArgs, int outArgs, std::string& errorMsg) { - SetSynced(false); - const bool retval = RunCallIn(hs, inArgs, outArgs); - SetSynced(!userMode); - return retval; + return RunCallInTraceback(L, NULL, inArgs, outArgs, 0, errorMsg, false); } - /******************************************************************************/ /******************************************************************************/ diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaHandleSynced.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaHandleSynced.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaHandleSynced.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaHandleSynced.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,26 +1,21 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#include -#include - - #include "LuaHandleSynced.h" #include "LuaInclude.h" -#include "LuaCallInCheck.h" #include "LuaUtils.h" +#include "LuaArchive.h" +#include "LuaCallInCheck.h" #include "LuaConstGL.h" #include "LuaConstCMD.h" #include "LuaConstCMDTYPE.h" #include "LuaConstCOB.h" #include "LuaConstGame.h" -#include "LuaSyncedCall.h" +#include "LuaInterCall.h" #include "LuaSyncedCtrl.h" #include "LuaSyncedRead.h" #include "LuaSyncedTable.h" -#include "LuaUnsyncedCall.h" #include "LuaUnsyncedCtrl.h" #include "LuaUnsyncedRead.h" #include "LuaFeatureDefs.h" @@ -31,27 +26,21 @@ #include "LuaVFS.h" #include "LuaZip.h" -#include "System/Config/ConfigHandler.h" +#include "Game/Game.h" #include "Game/WordCompletion.h" -#include "Sim/Misc/GlobalSynced.h" #include "Sim/Misc/TeamHandler.h" #include "Sim/Features/FeatureHandler.h" -#include "Sim/Units/Unit.h" -#include "Sim/Units/UnitDef.h" +#include "Sim/Units/BuildInfo.h" #include "Sim/Units/UnitDefHandler.h" -#include "Sim/Units/CommandAI/Command.h" #include "Sim/Units/Scripts/CobInstance.h" #include "Sim/Units/Scripts/LuaUnitScript.h" +#include "Sim/Weapons/Weapon.h" #include "Sim/Weapons/WeaponDefHandler.h" #include "System/EventHandler.h" -#include "System/GlobalConfig.h" -#include "System/ScopedFPUSettings.h" #include "System/Log/ILog.h" #include "System/FileSystem/FileHandler.h" -#include "System/FileSystem/FileSystem.h" -static const LuaHashString unsyncedStr("UNSYNCED"); LuaRulesParams::Params CLuaHandleSynced::gameParams; LuaRulesParams::HashMap CLuaHandleSynced::gameParamsMap; @@ -60,62 +49,33 @@ /******************************************************************************/ /******************************************************************************/ +// ## ## ## ## ###### ## ## ## ## ###### ######## ######## +// ## ## ### ## ## ## ## ## ### ## ## ## ## ## ## +// ## ## #### ## ## #### #### ## ## ## ## ## +// ## ## ## ## ## ###### ## ## ## ## ## ###### ## ## +// ## ## ## #### ## ## ## #### ## ## ## ## +// ## ## ## ### ## ## ## ## ### ## ## ## ## ## +// ####### ## ## ###### ## ## ## ###### ######## ######## -CLuaHandleSynced::CLuaHandleSynced(const string& _name, int _order) -: CLuaHandle(_name, _order, false), - teamsLocked(false) +CUnsyncedLuaHandle::CUnsyncedLuaHandle(CLuaHandleSynced* _base, const string& _name, int _order) + : CLuaHandle(_name, _order, false, false) + , base(*_base) { - UpdateThreading(); - SetAllowChanges(false, true); + D.allowChanges = false; } -CLuaHandleSynced::~CLuaHandleSynced() +CUnsyncedLuaHandle::~CUnsyncedLuaHandle() { - // kill all unitscripts running in this handle - CLuaUnitScript::HandleFreed(this); - - watchUnitDefs.clear(); - watchFeatureDefs.clear(); - watchWeaponDefs.clear(); -} - - -/******************************************************************************/ - - -void CLuaHandleSynced::UpdateThreading() { - int mtl = globalConfig->GetMultiThreadLua(); - useDualStates = (mtl == MT_LUA_DUAL_EXPORT || mtl == MT_LUA_DUAL || mtl == MT_LUA_DUAL_ALL || mtl == MT_LUA_DUAL_UNMANAGED); - singleState = (mtl == MT_LUA_NONE || mtl == MT_LUA_SINGLE || mtl == MT_LUA_SINGLE_BATCH); - copyExportTable = (mtl == MT_LUA_DUAL_EXPORT); - useEventBatch = false; - purgeCallsFromSyncedBatch = !singleState && (mtl != MT_LUA_DUAL_UNMANAGED); } -void CLuaHandleSynced::Init(const string& syncedFile, - const string& unsyncedFile, - const string& modes) +bool CUnsyncedLuaHandle::Init(const string& code, const string& file) { - if (!IsValid()) - return; - - if (GetFullCtrl()) { - watchUnitDefs.resize(unitDefHandler->unitDefs.size() + 1, false); - watchFeatureDefs.resize(featureHandler->GetFeatureDefs().size(), false); - watchWeaponDefs.resize(weaponDefHandler->weaponDefs.size(), false); - } - - const string syncedCode = LoadFile(syncedFile, modes); - const string unsyncedCode = LoadFile(unsyncedFile, modes); - if (syncedCode.empty() && unsyncedCode.empty()) { - KillLua(); - return; + if (!IsValid()) { + return false; } - BEGIN_ITERATE_LUA_STATES(); - // load the standard libraries LUA_OPEN_LIB(L, luaopen_base); LUA_OPEN_LIB(L, luaopen_math); @@ -132,196 +92,30 @@ lua_pushnil(L); lua_setglobal(L, "loadlib"); lua_pushnil(L); lua_setglobal(L, "loadstring"); // replaced lua_pushnil(L); lua_setglobal(L, "require"); - lua_pushnil(L); lua_setglobal(L, "rawequal"); - lua_pushnil(L); lua_setglobal(L, "rawget"); - lua_pushnil(L); lua_setglobal(L, "rawset"); -// lua_pushnil(L); lua_setglobal(L, "getfenv"); -// lua_pushnil(L); lua_setglobal(L, "setfenv"); - lua_pushnil(L); lua_setglobal(L, "newproxy"); - lua_pushnil(L); lua_setglobal(L, "gcinfo"); - lua_pushnil(L); lua_setglobal(L, "collectgarbage"); - - // use gs->randFloat() for the synchronized code, and disable randomseed() - // (this first copies the original functions to the registry for unsynced) - if (!SyncifyRandomFuncs(L)) { - KillLua(); - return; - } - - // 1. setup functions/environment - SetSynced(true, true); - SetAllowChanges(true, true); - const bool haveSynced = (SingleState() || L == L_Sim) && SetupSynced(L); - SetSynced(false, true); - SetAllowChanges(false, true); - const bool haveUnsynced = (SingleState() || L == L_Draw) && SetupUnsynced(L); - - // 2. load code (main.lua & draw.lua) - if (SingleState() || L == L_Sim) { - lua_settop(L, 0); - SetSynced(true, true); - SetAllowChanges(true, true); - if (!LoadCode(L, syncedCode, syncedFile)) { - KillLua(); - return; - } - } - if (SingleState() || L == L_Draw) { - lua_settop(L, 0); - SetSynced(false, true); - SetAllowChanges(false, true); - if (!LoadUnsyncedCode(L, unsyncedCode, unsyncedFile)) { - KillLua(); - return; - } - - lua_settop(L, 0); - - // NOTE: - // what makes these so special that failing - // to set them up forces Lua to be killed?? - if ( - !SetupUnsyncedFunction(L, "RecvFromSynced") || - !SetupUnsyncedFunction(L, "Update") || - !SetupUnsyncedFunction(L, "DrawGenesis") || - !SetupUnsyncedFunction(L, "DrawWorld") || - !SetupUnsyncedFunction(L, "DrawWorldPreUnit") || - !SetupUnsyncedFunction(L, "DrawWorldShadow") || - !SetupUnsyncedFunction(L, "DrawWorldReflection") || - !SetupUnsyncedFunction(L, "DrawWorldRefraction") || - !SetupUnsyncedFunction(L, "DrawScreenEffects") || - !SetupUnsyncedFunction(L, "DrawScreen") || - !SetupUnsyncedFunction(L, "DrawInMiniMap") - ) { - KillLua(); - return; - } - lua_settop(L, 0); - } - - SetSynced(true, true); - SetAllowChanges(true, true); - - if (!IsValid() || (!haveSynced && !haveUnsynced)) { - KillLua(); - return; - } - - // register for call-ins - eventHandler.AddClient(this); - - END_ITERATE_LUA_STATES(); -} - - -bool CLuaHandleSynced::SetupSynced(lua_State* L) -{ - if (!IsValid()) { - return false; - } lua_pushvalue(L, LUA_GLOBALSINDEX); - HSTR_PUSH(L, "EXPORT"); - lua_newtable(L); - lua_rawset(L, -3); - - AddBasicCalls(L); // into Global - - lua_pushliteral(L, "Script"); - lua_rawget(L, -2); - LuaPushNamedCFunc(L, "AddActionFallback", AddSyncedActionFallback); - LuaPushNamedCFunc(L, "RemoveActionFallback", RemoveSyncedActionFallback); - LuaPushNamedCFunc(L, "UpdateCallIn", CallOutSyncedUpdateCallIn); - LuaPushNamedCFunc(L, "GetWatchUnit", GetWatchUnitDef); - LuaPushNamedCFunc(L, "SetWatchUnit", SetWatchUnitDef); - LuaPushNamedCFunc(L, "GetWatchFeature", GetWatchFeatureDef); - LuaPushNamedCFunc(L, "SetWatchFeature", SetWatchFeatureDef); - LuaPushNamedCFunc(L, "GetWatchWeapon", GetWatchWeaponDef); - LuaPushNamedCFunc(L, "SetWatchWeapon", SetWatchWeaponDef); - lua_pop(L, 1); - - // add the custom file loader - LuaPushNamedCFunc(L, "SendToUnsynced", SendToUnsynced); - - LuaPushNamedCFunc(L, "loadstring", LoadStringData); - LuaPushNamedCFunc(L, "CallAsTeam", CallAsTeam); - - LuaPushNamedNumber(L, "COBSCALE", COBSCALE); - - // load our libraries (LuaSyncedCtrl overrides some LuaUnsyncedCtrl entries) - if (!AddEntriesToTable(L, "VFS", LuaVFS::PushSynced) || - !AddEntriesToTable(L, "VFS", LuaZipFileReader::PushSynced) || - !AddEntriesToTable(L, "VFS", LuaZipFileWriter::PushSynced) || - !AddEntriesToTable(L, "UnitDefs", LuaUnitDefs::PushEntries) || - !AddEntriesToTable(L, "WeaponDefs", LuaWeaponDefs::PushEntries) || - !AddEntriesToTable(L, "FeatureDefs", LuaFeatureDefs::PushEntries) || - !AddEntriesToTable(L, "Script", LuaSyncedCall::PushEntries) || - !AddEntriesToTable(L, "Spring", LuaUnsyncedCtrl::PushEntries) || - !AddEntriesToTable(L, "Spring", LuaSyncedCtrl::PushEntries) || - !AddEntriesToTable(L, "Spring", LuaSyncedRead::PushEntries) || - !AddEntriesToTable(L, "Game", LuaConstGame::PushEntries) || - !AddEntriesToTable(L, "CMD", LuaConstCMD::PushEntries) || - !AddEntriesToTable(L, "CMDTYPE", LuaConstCMDTYPE::PushEntries) || - !AddEntriesToTable(L, "COB", LuaConstCOB::PushEntries) || - !AddEntriesToTable(L, "SFX", LuaConstSFX::PushEntries) || - !AddEntriesToTable(L, "LOG", LuaUtils::PushLogEntries) - ) { - KillLua(); - return false; - } - - // add code from the sub-class - if (!AddSyncedCode(L)) { - KillLua(); - return false; - } - - lua_settop(L, 0); - return true; -} - - -bool CLuaHandleSynced::SetupUnsynced(lua_State* L) -{ - if (!IsValid()) { - return false; - } - - // make the UNSYNCED table - unsyncedStr.Push(L); - lua_newtable(L); - lua_rawset(L, LUA_REGISTRYINDEX); - - unsyncedStr.GetRegistry(L); - - AddBasicCalls(L); // into UNSYNCED + AddBasicCalls(L); // remove Script.Kill() - lua_pushliteral(L, "Script"); - lua_rawget(L, -2); - lua_pushliteral(L, "Kill"); - lua_pushnil(L); - lua_rawset(L, -3); - LuaPushNamedCFunc(L, "UpdateCallIn", CallOutUnsyncedUpdateCallIn); + lua_getglobal(L, "Script"); + LuaPushNamedNil(L, "Kill"); lua_pop(L, 1); - lua_pushliteral(L, "_G"); - unsyncedStr.GetRegistry(L); - lua_rawset(L, -3); - - LuaPushNamedCFunc(L, "loadstring", LoadStringData); - LuaPushNamedCFunc(L, "CallAsTeam", CallAsTeam); + LuaPushNamedCFunc(L, "loadstring", CLuaHandleSynced::LoadStringData); + LuaPushNamedCFunc(L, "CallAsTeam", CLuaHandleSynced::CallAsTeam); + LuaPushNamedNumber(L, "COBSCALE", COBSCALE); // load our libraries if (!LuaSyncedTable::PushEntries(L) || !AddEntriesToTable(L, "VFS", LuaVFS::PushUnsynced) || - !AddEntriesToTable(L, "VFS", LuaZipFileReader::PushUnsynced) || - !AddEntriesToTable(L, "VFS", LuaZipFileWriter::PushUnsynced) || + !AddEntriesToTable(L, "VFS", LuaZipFileReader::PushUnsynced) || + !AddEntriesToTable(L, "VFS", LuaZipFileWriter::PushUnsynced) || + !AddEntriesToTable(L, "VFS", LuaArchive::PushEntries) || !AddEntriesToTable(L, "UnitDefs", LuaUnitDefs::PushEntries) || !AddEntriesToTable(L, "WeaponDefs", LuaWeaponDefs::PushEntries) || !AddEntriesToTable(L, "FeatureDefs", LuaFeatureDefs::PushEntries) || - !AddEntriesToTable(L, "Script", LuaUnsyncedCall::PushEntries) || + !AddEntriesToTable(L, "Script", LuaInterCall::PushEntriesUnsynced) || !AddEntriesToTable(L, "Script", LuaScream::PushEntries) || !AddEntriesToTable(L, "Spring", LuaSyncedRead::PushEntries) || !AddEntriesToTable(L, "Spring", LuaUnsyncedCtrl::PushEntries) || @@ -337,563 +131,1000 @@ return false; } - lua_pushliteral(L, "math"); lua_newtable(L); - lua_getglobal(L, "math"); LightCopyTable(L, -2, -1); lua_pop(L, 1); - lua_rawset(L, -3); - - lua_pushliteral(L, "table"); lua_newtable(L); - lua_getglobal(L, "table"); LightCopyTable(L, -2, -1); lua_pop(L, 1); - lua_rawset(L, -3); - - lua_pushliteral(L, "string"); lua_newtable(L); - lua_getglobal(L, "string"); LightCopyTable(L, -2, -1); lua_pop(L, 1); - lua_rawset(L, -3); - - lua_pushliteral(L, "coroutine"); lua_newtable(L); - lua_getglobal(L, "coroutine"); LightCopyTable(L, -2, -1); lua_pop(L, 1); - lua_rawset(L, -3); + lua_settop(L, 0); - if (!CopyRealRandomFuncs(L)) { + // add code from the sub-class + if (!base.AddUnsyncedCode(L)) { KillLua(); return false; } lua_settop(L, 0); - - // note the absence of loadstring() -- global access - const char* labels[] = { - "assert", "error", - "print", - "next", "pairs", "ipairs", - "tonumber", "tostring", "type", - "collectgarbage", "gcinfo", - "unpack", "select", - "getmetatable", "setmetatable", - "rawequal", "rawget", "rawset", - "getfenv", "setfenv", - "pcall", "xpcall", - "_VERSION", - NULL - }; - for (const char** l = labels; *l != NULL; l++) { - CopyGlobalToUnsynced(L, *l); - } - - // add code from the sub-class - unsyncedStr.GetRegistry(L); - if (!AddUnsyncedCode(L)) { + if (!LoadCode(L, code, file)) { KillLua(); return false; } + lua_settop(L, 0); + eventHandler.AddClient(this); return true; } -bool CLuaHandleSynced::SyncifyRandomFuncs(lua_State* L) -{ - // adjust the math.random() and math.randomseed() calls - lua_getglobal(L, "math"); - if (!lua_istable(L, -1)) { - LOG_L(L_WARNING, "lua.math does not exist"); - return false; - } - - // copy the original random() into the registry - lua_pushliteral(L, "random"); - lua_pushliteral(L, "random"); - lua_rawget(L, -3); // math table - lua_rawset(L, LUA_REGISTRYINDEX); - - // copy the original randomseed() into the registry - lua_pushliteral(L, "randomseed"); - lua_pushliteral(L, "randomseed"); - lua_rawget(L, -3); // math table - lua_rawset(L, LUA_REGISTRYINDEX); - - // install our custom random() - lua_pushliteral(L, "random"); - lua_pushcfunction(L, SyncedRandom); - lua_rawset(L, -3); - - // remove randomseed() - lua_pushliteral(L, "randomseed"); - lua_pushnil(L); - lua_rawset(L, -3); - - lua_pop(L, 1); // pop the global math table +// +// Call-Ins +// - return true; -} +void CUnsyncedLuaHandle::RecvFromSynced(lua_State* srcState, int args) +{ + if (!IsValid()) + return; -bool CLuaHandleSynced::CopyRealRandomFuncs(lua_State* L) -{ - lua_pushliteral(L, "math"); - lua_rawget(L, -2); + LUA_CALL_IN_CHECK(L); + luaL_checkstack(L, 2 + args, __FUNCTION__); - lua_pushliteral(L, "random"); - lua_pushliteral(L, "random"); - lua_rawget(L, LUA_REGISTRYINDEX); - lua_rawset(L, -3); - - lua_pushliteral(L, "randomseed"); - lua_pushliteral(L, "randomseed"); - lua_rawget(L, LUA_REGISTRYINDEX); - lua_rawset(L, -3); + static const LuaHashString cmdStr("RecvFromSynced"); + if (!cmdStr.GetGlobalFunc(L)) + return; // the call is not defined - lua_pop(L, 1); // remove 'math' + LuaUtils::CopyData(L, srcState, args); - return true; + // call the routine + RunCallIn(L, cmdStr, args, 0); } -bool CLuaHandleSynced::SetupUnsyncedFunction(lua_State* L, const char* funcName) +bool CUnsyncedLuaHandle::DrawUnit(const CUnit* unit) { - // copy the function from UNSYNCED into - // the registry, and setfenv() it to UNSYNCED - lua_settop(L, 0); - unsyncedStr.GetRegistry(L); - if (!lua_istable(L, -1)) { - lua_settop(L, 0); -// FIXME LOG_L(L_ERROR, "missing UNSYNCED table for %s", name.c_str()); + LUA_CALL_IN_CHECK(L, false); + luaL_checkstack(L, 4, __FUNCTION__); + + static const LuaHashString cmdStr(__FUNCTION__); + if (!cmdStr.GetGlobalFunc(L)) return false; - } - const int unsynced = lua_gettop(L); - lua_pushstring(L, funcName); + const bool oldDrawState = LuaOpenGL::IsDrawingEnabled(L); + LuaOpenGL::SetDrawingEnabled(L, true); - lua_pushstring(L, funcName); - lua_gettable(L, unsynced); - if (lua_isnil(L, -1)) { - lua_rawset(L, LUA_REGISTRYINDEX); - lua_settop(L, 0); - return true; - } - else if (!lua_isfunction(L, -1)) { - lua_settop(L, 0); - LOG_L(L_WARNING, "%s in %s is not a function", - funcName, GetName().c_str()); - return false; - } - lua_pushvalue(L, unsynced); - lua_setfenv(L, -2); + lua_pushnumber(L, unit->id); + lua_pushnumber(L, game->GetDrawMode()); - lua_rawset(L, LUA_REGISTRYINDEX); + const bool success = RunCallIn(L, cmdStr, 2, 1); + LuaOpenGL::SetDrawingEnabled(L, oldDrawState); - lua_settop(L, 0); - return true; + if (!success) + return false; + + const bool retval = luaL_optboolean(L, -1, false); + lua_pop(L, 1); + return retval; } -bool CLuaHandleSynced::CopyGlobalToUnsynced(lua_State* L, const char* name) +bool CUnsyncedLuaHandle::DrawFeature(const CFeature* feature) { - lua_settop(L, 0); - unsyncedStr.GetRegistry(L); - const int unsynced = lua_gettop(L); + LUA_CALL_IN_CHECK(L, false); + luaL_checkstack(L, 4, __FUNCTION__); - lua_pushstring(L, name); - lua_getglobal(L, name); - lua_rawset(L, unsynced); + static const LuaHashString cmdStr(__FUNCTION__); + if (!cmdStr.GetGlobalFunc(L)) + return false; - lua_settop(L, 0); - return true; -} + const bool oldDrawState = LuaOpenGL::IsDrawingEnabled(L); + LuaOpenGL::SetDrawingEnabled(L, true); + lua_pushnumber(L, feature->id); + lua_pushnumber(L, game->GetDrawMode()); -bool CLuaHandleSynced::LightCopyTable(lua_State* L, int dstIndex, int srcIndex) -{ - // use positive indices - if (dstIndex < 0) { dstIndex = lua_gettop(L) + dstIndex + 1; } - if (srcIndex < 0) { srcIndex = lua_gettop(L) + srcIndex + 1; } + const bool success = RunCallIn(L, cmdStr, 2, 1); + LuaOpenGL::SetDrawingEnabled(L, oldDrawState); - if (!lua_istable(L, dstIndex) || !lua_istable(L, srcIndex)) { + if (!success) return false; - } - - for (lua_pushnil(L); lua_next(L, srcIndex) != 0; lua_pop(L, 1)) { - if (!lua_israwstring(L, -2)) { // key must be a string - continue; - } - if (lua_isstring(L, -1) || - lua_isnumber(L, -1) || - lua_isboolean(L, -1) || - lua_isfunction(L, -1)) { - lua_pushvalue(L, -2); // copy the key - lua_pushvalue(L, -2); // copy the value - lua_rawset(L, dstIndex); - } - } - return true; + const bool retval = luaL_optboolean(L, -1, false); + lua_pop(L, 1); + return retval; } -bool CLuaHandleSynced::LoadUnsyncedCode(lua_State* L, const string& code, const string& debug) +bool CUnsyncedLuaHandle::DrawShield(const CUnit* unit, const CWeapon* weapon) { - // do not signal floating point exceptions in user Lua code - ScopedDisableFpuExceptions fe; - - lua_settop(L, 0); + LUA_CALL_IN_CHECK(L, false); + luaL_checkstack(L, 5, __FUNCTION__); - int error; - error = luaL_loadbuffer(L, code.c_str(), code.size(), debug.c_str()); - if (error != 0) { - LOG_L(L_ERROR, "error = %i, %s, %s", - error, debug.c_str(), lua_tostring(L, -1)); - lua_settop(L, 0); - return false; - } + static const LuaHashString cmdStr(__FUNCTION__); - unsyncedStr.GetRegistry(L); - if (!lua_istable(L, -1)) { - lua_settop(L, 0); + if (!cmdStr.GetGlobalFunc(L)) return false; - } - lua_setfenv(L, -2); - - SetRunning(L, true); - error = lua_pcall(L, 0, 0, 0); - SetRunning(L, false); - if (error != 0) { - LOG_L(L_ERROR, "error = %i, %s, %s", - error, debug.c_str(), lua_tostring(L, -1)); - lua_settop(L, 0); - return false; - } + const bool oldDrawState = LuaOpenGL::IsDrawingEnabled(L); + LuaOpenGL::SetDrawingEnabled(L, true); - return true; -} + lua_pushnumber(L, unit->id); + lua_pushnumber(L, weapon->weaponNum); + lua_pushnumber(L, game->GetDrawMode()); + const bool success = RunCallIn(L, cmdStr, 3, 1); + LuaOpenGL::SetDrawingEnabled(L, oldDrawState); -/******************************************************************************/ + if (!success) + return false; -string CLuaHandleSynced::LoadFile(const string& filename, - const string& modes) const -{ - string vfsModes; - if (devMode) { - vfsModes = SPRING_VFS_RAW; - } - vfsModes += modes; - CFileHandler f(filename, vfsModes); - string code; - if (!f.LoadStringData(code)) { - code.clear(); - } - return code; + const bool retval = luaL_optboolean(L, -1, false); + lua_pop(L, 1); + return retval; } -bool CLuaHandleSynced::HasCallIn(lua_State* L, const string& name) +bool CUnsyncedLuaHandle::DrawProjectile(const CProjectile* projectile) { - if (!IsValid()) { + if (!(projectile->weapon || projectile->piece)) return false; - } - - if (name == "CollectGarbage") - return true; - // NOTE: - // these are the only strictly unsynced LuaRULES callins - // they are SetupUnsyncedFunction()'ed by CLuaRules ctor - static const std::string unsyncedNames[] = { - "DrawUnit", - "DrawFeature", - "DrawShield", - "DrawProjectile", - "RecvSkirmishAIMessage", - "RecvFromSynced", - }; - - // unsynced call-ins in REGISTRY - int tableIndex = LUA_REGISTRYINDEX; - bool unsynced = false; - - for (unsigned int n = 0; n < (sizeof(unsyncedNames) / sizeof(std::string)); n++) { - if (name == unsyncedNames[n]) { - unsynced = true; break; - } - } + LUA_CALL_IN_CHECK(L, false); + luaL_checkstack(L, 5, __FUNCTION__); - // synced call-ins in GLOBAL - if (!unsynced && !eventHandler.IsUnsynced(name)) - tableIndex = LUA_GLOBALSINDEX; + static const LuaHashString cmdStr(__FUNCTION__); + if (!cmdStr.GetGlobalFunc(L)) + return false; - bool haveFunc = true; - lua_settop(L, 0); - lua_pushsstring(L, name); - lua_gettable(L, tableIndex); - if (!lua_isfunction(L, -1)) { - haveFunc = false; - } - lua_settop(L, 0); + const bool oldDrawState = LuaOpenGL::IsDrawingEnabled(L); + LuaOpenGL::SetDrawingEnabled(L, true); - return haveFunc; -} + lua_pushnumber(L, projectile->id); + lua_pushnumber(L, game->GetDrawMode()); + const bool success = RunCallIn(L, cmdStr, 2, 1); + LuaOpenGL::SetDrawingEnabled(L, oldDrawState); -bool CLuaHandleSynced::SyncedUpdateCallIn(lua_State* L, const string& name) -{ - if ((name == "RecvFromSynced") || - eventHandler.IsUnsynced(name)) { + if (!success) return false; - } - if (HasCallIn(L, name)) { - eventHandler.InsertEvent(this, name); - } else { - eventHandler.RemoveEvent(this, name); - } - return true; -} - - -bool CLuaHandleSynced::UnsyncedUpdateCallIn(lua_State* L, const string& name) -{ - if (name != "RecvFromSynced") { - if (!eventHandler.IsUnsynced(name)) - return false; - - if (HasCallIn(L, name)) { - eventHandler.InsertEvent(this, name); - } else { - eventHandler.RemoveEvent(this, name); - } - } - SetupUnsyncedFunction(L, name.c_str()); - return true; + const bool retval = luaL_optboolean(L, -1, false); + lua_pop(L, 1); + return retval; } -/******************************************************************************/ -/******************************************************************************/ // -// Call-ins (first two are unused) +// Call-Outs // -bool CLuaHandleSynced::SyncedActionFallback(const string& msg, int playerID) +/******************************************************************************/ +/******************************************************************************/ +// ###### ## ## ## ## ###### ######## ######## +// ## ## ## ## ### ## ## ## ## ## ## +// ## #### #### ## ## ## ## ## +// ###### ## ## ## ## ## ###### ## ## +// ## ## ## #### ## ## ## ## +// ## ## ## ## ### ## ## ## ## ## +// ###### ## ## ## ###### ######## ######## + +CSyncedLuaHandle::CSyncedLuaHandle(CLuaHandleSynced* _base, const string& _name, int _order) + : CLuaHandle(_name, _order, false, true) + , base(*_base) + , origNextRef(-1) { - string cmd = msg; - const string::size_type pos = cmd.find_first_of(" \t"); - if (pos != string::npos) { - cmd.resize(pos); - } - if (textCommands.find(cmd) == textCommands.end()) { - return false; - } - GotChatMsg(msg.substr(1), playerID); // strip the '.' - return true; + D.allowChanges = true; } -bool CLuaHandleSynced::GotChatMsg(const string& msg, int playerID) +CSyncedLuaHandle::~CSyncedLuaHandle() { - LUA_CALL_IN_CHECK(L, true); - luaL_checkstack(L, 4, __FUNCTION__); - static const LuaHashString cmdStr("GotChatMsg"); - if (!cmdStr.GetGlobalFunc(L)) { - return true; // the call is not defined - } - - lua_pushsstring(L, msg); - lua_pushnumber(L, playerID); - - // call the routine - RunCallIn(cmdStr, 2, 0); - - return true; + // kill all unitscripts running in this handle + CLuaUnitScript::HandleFreed(this); } -/******************************************************************************/ - - - -void CLuaHandleSynced::RecvFromSynced(lua_State *srcState, int args) +bool CSyncedLuaHandle::Init(const string& code, const string& file) { - SELECT_UNSYNCED_LUA_STATE(); - -#if ((LUA_MT_OPT & LUA_STATE) && (LUA_MT_OPT & LUA_MUTEX)) - if (/*GML::Enabled() &&*/ !SingleState() && srcState != L) { // Sim thread sends to unsynced --> delay it - DelayRecvFromSynced(srcState, args); - return; - } - // Draw thread, delayed already, execute it -#endif + if (!IsValid()) + return false; - static const LuaHashString cmdStr("RecvFromSynced"); - //LUA_CALL_IN_CHECK(L); -- not valid here + watchUnitDefs.resize(unitDefHandler->unitDefs.size() + 1, false); + watchFeatureDefs.resize(featureHandler->GetFeatureDefs().size(), false); + watchWeaponDefs.resize(weaponDefHandler->weaponDefs.size(), false); - if (!cmdStr.GetRegistryFunc(L)) - return; // the call is not defined - lua_insert(L, 1); // place the function + // load the standard libraries + LUA_OPEN_LIB(L, luaopen_base); + LUA_OPEN_LIB(L, luaopen_math); + LUA_OPEN_LIB(L, luaopen_table); + LUA_OPEN_LIB(L, luaopen_string); + //LUA_OPEN_LIB(L, luaopen_io); + //LUA_OPEN_LIB(L, luaopen_os); + //LUA_OPEN_LIB(L, luaopen_package); + //LUA_OPEN_LIB(L, luaopen_debug); - // call the routine - SetAllowChanges(false); - SetHandleSynced(L, false); + lua_getglobal(L, "next"); + origNextRef = luaL_ref(L, LUA_REGISTRYINDEX); + + // delete/replace some dangerous functions + lua_pushnil(L); lua_setglobal(L, "dofile"); + lua_pushnil(L); lua_setglobal(L, "loadfile"); + lua_pushnil(L); lua_setglobal(L, "loadlib"); + lua_pushnil(L); lua_setglobal(L, "require"); + lua_pushnil(L); lua_setglobal(L, "rawequal"); //FIXME not unsafe anymore since split? + lua_pushnil(L); lua_setglobal(L, "rawget"); //FIXME not unsafe anymore since split? + lua_pushnil(L); lua_setglobal(L, "rawset"); //FIXME not unsafe anymore since split? +// lua_pushnil(L); lua_setglobal(L, "getfenv"); +// lua_pushnil(L); lua_setglobal(L, "setfenv"); + lua_pushnil(L); lua_setglobal(L, "newproxy"); // sync unsafe cause of __gc + lua_pushnil(L); lua_setglobal(L, "gcinfo"); + lua_pushnil(L); lua_setglobal(L, "collectgarbage"); + + lua_pushvalue(L, LUA_GLOBALSINDEX); + LuaPushNamedCFunc(L, "loadstring", CLuaHandleSynced::LoadStringData); + LuaPushNamedCFunc(L, "pairs", SyncedPairs); + LuaPushNamedCFunc(L, "next", SyncedNext); + lua_pop(L, 1); + + lua_pushvalue(L, LUA_GLOBALSINDEX); + + AddBasicCalls(L); // into Global + + // adjust the math.random() and math.randomseed() calls + lua_getglobal(L, "math"); + LuaPushNamedCFunc(L, "random", SyncedRandom); + LuaPushNamedCFunc(L, "randomseed", SyncedRandomSeed); + lua_pop(L, 1); // pop the global math table + + lua_getglobal(L, "Script"); + LuaPushNamedCFunc(L, "AddActionFallback", AddSyncedActionFallback); + LuaPushNamedCFunc(L, "RemoveActionFallback", RemoveSyncedActionFallback); + LuaPushNamedCFunc(L, "GetWatchUnit", GetWatchUnitDef); + LuaPushNamedCFunc(L, "SetWatchUnit", SetWatchUnitDef); + LuaPushNamedCFunc(L, "GetWatchFeature", GetWatchFeatureDef); + LuaPushNamedCFunc(L, "SetWatchFeature", SetWatchFeatureDef); + LuaPushNamedCFunc(L, "GetWatchWeapon", GetWatchWeaponDef); + LuaPushNamedCFunc(L, "SetWatchWeapon", SetWatchWeaponDef); + lua_pop(L, 1); + + // add the custom file loader + LuaPushNamedCFunc(L, "SendToUnsynced", SendToUnsynced); + LuaPushNamedCFunc(L, "CallAsTeam", CLuaHandleSynced::CallAsTeam); + LuaPushNamedNumber(L, "COBSCALE", COBSCALE); + + // load our libraries (LuaSyncedCtrl overrides some LuaUnsyncedCtrl entries) + if ( + !AddEntriesToTable(L, "VFS", LuaVFS::PushSynced) || + !AddEntriesToTable(L, "VFS", LuaZipFileReader::PushSynced) || + !AddEntriesToTable(L, "VFS", LuaZipFileWriter::PushSynced) || + !AddEntriesToTable(L, "UnitDefs", LuaUnitDefs::PushEntries) || + !AddEntriesToTable(L, "WeaponDefs", LuaWeaponDefs::PushEntries) || + !AddEntriesToTable(L, "FeatureDefs", LuaFeatureDefs::PushEntries) || + !AddEntriesToTable(L, "Script", LuaInterCall::PushEntriesSynced) || + !AddEntriesToTable(L, "Spring", LuaUnsyncedCtrl::PushEntries) || + !AddEntriesToTable(L, "Spring", LuaSyncedCtrl::PushEntries) || + !AddEntriesToTable(L, "Spring", LuaSyncedRead::PushEntries) || + !AddEntriesToTable(L, "Game", LuaConstGame::PushEntries) || + !AddEntriesToTable(L, "CMD", LuaConstCMD::PushEntries) || + !AddEntriesToTable(L, "CMDTYPE", LuaConstCMDTYPE::PushEntries) || + !AddEntriesToTable(L, "COB", LuaConstCOB::PushEntries) || + !AddEntriesToTable(L, "SFX", LuaConstSFX::PushEntries) || + !AddEntriesToTable(L, "LOG", LuaUtils::PushLogEntries) + ) { + KillLua(); + return false; + } + + // add code from the sub-class + if (!base.AddSyncedCode(L)) { + KillLua(); + return false; + } + + lua_settop(L, 0); + if (!LoadCode(L, code, file)) { + KillLua(); + return false; + } + + lua_settop(L, 0); + eventHandler.AddClient(this); + return true; +} + + +// +// Call-Ins +// + +bool CSyncedLuaHandle::SyncedActionFallback(const string& msg, int playerID) +{ + string cmd = msg; + const string::size_type pos = cmd.find_first_of(" \t"); + if (pos != string::npos) { + cmd.resize(pos); + } + if (textCommands.find(cmd) == textCommands.end()) { + return false; + } + string msg_ = msg.substr(1); // strip the '/' + return GotChatMsg(msg_, playerID); +} + + +/// pushes 7 items on the stack +static void PushUnitAndCommand(lua_State* L, const CUnit* unit, const Command& cmd) +{ + // push the unit info + lua_pushnumber(L, unit->id); + lua_pushnumber(L, unit->unitDef->id); + lua_pushnumber(L, unit->team); + + // push the command id + lua_pushnumber(L, cmd.GetID()); + + // push the params list + lua_newtable(L); + for (int p = 0; p < (int)cmd.params.size(); p++) { + lua_pushnumber(L, cmd.params[p]); + lua_rawseti(L, -2, p + 1); + } + + // push the options table + lua_newtable(L); + HSTR_PUSH_NUMBER(L, "coded", cmd.options); + HSTR_PUSH_BOOL(L, "alt", !!(cmd.options & ALT_KEY)); + HSTR_PUSH_BOOL(L, "ctrl", !!(cmd.options & CONTROL_KEY)); + HSTR_PUSH_BOOL(L, "shift", !!(cmd.options & SHIFT_KEY)); + HSTR_PUSH_BOOL(L, "right", !!(cmd.options & RIGHT_MOUSE_KEY)); + HSTR_PUSH_BOOL(L, "meta", !!(cmd.options & META_KEY)); + + // push the command tag + lua_pushnumber(L, cmd.tag); +} + +bool CSyncedLuaHandle::CommandFallback(const CUnit* unit, const Command& cmd) +{ + LUA_CALL_IN_CHECK(L, true); + luaL_checkstack(L, 9, __FUNCTION__); + + static const LuaHashString cmdStr(__FUNCTION__); + if (!cmdStr.GetGlobalFunc(L)) + return true; // the call is not defined + + PushUnitAndCommand(L, unit, cmd); + + // call the function + if (!RunCallIn(L, cmdStr, 7, 1)) + return true; + + const bool retval = luaL_optboolean(L, -1, true); + lua_pop(L, 1); + return retval; // return 'true' to remove the command +} + + +bool CSyncedLuaHandle::AllowCommand(const CUnit* unit, const Command& cmd, bool fromSynced) +{ + LUA_CALL_IN_CHECK(L, true); + luaL_checkstack(L, 10, __FUNCTION__); + + static const LuaHashString cmdStr(__FUNCTION__); + if (!cmdStr.GetGlobalFunc(L)) + return true; // the call is not defined + + PushUnitAndCommand(L, unit, cmd); + + lua_pushboolean(L, fromSynced); + + // call the function + if (!RunCallIn(L, cmdStr, 8, 1)) + return true; + + // get the results + const bool retval = luaL_optboolean(L, -1, true); + lua_pop(L, 1); + return retval; +} + + +bool CSyncedLuaHandle::AllowUnitCreation(const UnitDef* unitDef, + const CUnit* builder, const BuildInfo* buildInfo) +{ + LUA_CALL_IN_CHECK(L, true); + luaL_checkstack(L, 9, __FUNCTION__); + + static const LuaHashString cmdStr(__FUNCTION__); + if (!cmdStr.GetGlobalFunc(L)) + return true; // the call is not defined + + lua_pushnumber(L, unitDef->id); + lua_pushnumber(L, builder->id); + lua_pushnumber(L, builder->team); + + if (buildInfo != NULL) { + lua_pushnumber(L, buildInfo->pos.x); + lua_pushnumber(L, buildInfo->pos.y); + lua_pushnumber(L, buildInfo->pos.z); + lua_pushnumber(L, buildInfo->buildFacing); + } + + // call the function + if (!RunCallIn(L, cmdStr, (buildInfo != NULL)? 7 : 3, 1)) + return true; + + // get the results + const bool retval = luaL_optboolean(L, -1, true); + lua_pop(L, 1); + return retval; +} + + + +bool CSyncedLuaHandle::AllowUnitTransfer(const CUnit* unit, int newTeam, bool capture) +{ + LUA_CALL_IN_CHECK(L, true); + luaL_checkstack(L, 7, __FUNCTION__); + + static const LuaHashString cmdStr(__FUNCTION__); + if (!cmdStr.GetGlobalFunc(L)) + return true; // the call is not defined + + lua_pushnumber(L, unit->id); + lua_pushnumber(L, unit->unitDef->id); + lua_pushnumber(L, unit->team); + lua_pushnumber(L, newTeam); + lua_pushboolean(L, capture); + + // call the function + if (!RunCallIn(L, cmdStr, 5, 1)) + return true; + + // get the results + const bool retval = luaL_optboolean(L, -1, true); + lua_pop(L, 1); + return retval; +} + + +bool CSyncedLuaHandle::AllowUnitBuildStep(const CUnit* builder, + const CUnit* unit, float part) +{ + LUA_CALL_IN_CHECK(L, true); + luaL_checkstack(L, 7, __FUNCTION__); + + static const LuaHashString cmdStr(__FUNCTION__); + if (!cmdStr.GetGlobalFunc(L)) + return true; // the call is not defined + + lua_pushnumber(L, builder->id); + lua_pushnumber(L, builder->team); + lua_pushnumber(L, unit->id); + lua_pushnumber(L, unit->unitDef->id); + lua_pushnumber(L, part); - lua_State* L_Prev = ForceUnsyncedState(); - RunCallIn(cmdStr, args, 0); - RestoreState(L_Prev); + // call the function + if (!RunCallIn(L, cmdStr, 5, 1)) + return true; + + // get the results + const bool retval = luaL_optboolean(L, -1, true); + lua_pop(L, 1); + return retval; +} + + +bool CSyncedLuaHandle::AllowFeatureCreation(const FeatureDef* featureDef, + int teamID, const float3& pos) +{ + LUA_CALL_IN_CHECK(L, true); + luaL_checkstack(L, 7, __FUNCTION__); + + static const LuaHashString cmdStr(__FUNCTION__); + if (!cmdStr.GetGlobalFunc(L)) + return true; // the call is not defined + + lua_pushnumber(L, featureDef->id); + lua_pushnumber(L, teamID); + lua_pushnumber(L, pos.x); + lua_pushnumber(L, pos.y); + lua_pushnumber(L, pos.z); + + // call the function + if (!RunCallIn(L, cmdStr, 5, 1)) + return true; + + // get the results + const bool retval = luaL_optboolean(L, -1, true); + lua_pop(L, 1); + return retval; +} + + +bool CSyncedLuaHandle::AllowFeatureBuildStep(const CUnit* builder, + const CFeature* feature, float part) +{ + LUA_CALL_IN_CHECK(L, true); + luaL_checkstack(L, 7, __FUNCTION__); - SetHandleSynced(L, true); - SetAllowChanges(true); + static const LuaHashString cmdStr(__FUNCTION__); + if (!cmdStr.GetGlobalFunc(L)) + return true; // the call is not defined + + lua_pushnumber(L, builder->id); + lua_pushnumber(L, builder->team); + lua_pushnumber(L, feature->id); + lua_pushnumber(L, feature->def->id); + lua_pushnumber(L, part); + + // call the function + if (!RunCallIn(L, cmdStr, 5, 1)) + return true; + + // get the results + const bool retval = luaL_optboolean(L, -1, true); + lua_pop(L, 1); + return retval; } -bool CLuaHandleSynced::RecvLuaMsg(const string& msg, int playerID) +bool CSyncedLuaHandle::AllowResourceLevel(int teamID, const string& type, float level) { - //FIXME: is there a reason to disallow gamestate changes in RecvLuaMsg? - const bool prevAllowChanges = GetAllowChanges(); - SetAllowChanges(false); + LUA_CALL_IN_CHECK(L, true); + luaL_checkstack(L, 5, __FUNCTION__); - const bool retval = CLuaHandle::RecvLuaMsg(msg, playerID); + static const LuaHashString cmdStr(__FUNCTION__); + if (!cmdStr.GetGlobalFunc(L)) + return true; // the call is not defined - SetAllowChanges(prevAllowChanges); + lua_pushnumber(L, teamID); + lua_pushsstring(L, type); + lua_pushnumber(L, level); + // call the function + if (!RunCallIn(L, cmdStr, 3, 1)) + return true; + + // get the results + const bool retval = luaL_optboolean(L, -1, true); + lua_pop(L, 1); return retval; } -/******************************************************************************/ -/******************************************************************************/ -// -// Custom Call-in -// +bool CSyncedLuaHandle::AllowResourceTransfer(int oldTeam, int newTeam, + const string& type, float amount) +{ + LUA_CALL_IN_CHECK(L, true); + luaL_checkstack(L, 6, __FUNCTION__); + + static const LuaHashString cmdStr(__FUNCTION__); + if (!cmdStr.GetGlobalFunc(L)) + return true; // the call is not defined + + lua_pushnumber(L, oldTeam); + lua_pushnumber(L, newTeam); + lua_pushsstring(L, type); + lua_pushnumber(L, amount); + + // call the function + if (!RunCallIn(L, cmdStr, 4, 1)) + return true; + + // get the results + const bool retval = luaL_optboolean(L, -1, true); + lua_pop(L, 1); + return retval; +} + + +bool CSyncedLuaHandle::AllowDirectUnitControl(int playerID, const CUnit* unit) +{ + LUA_CALL_IN_CHECK(L, true); + luaL_checkstack(L, 6, __FUNCTION__); + + static const LuaHashString cmdStr(__FUNCTION__); + if (!cmdStr.GetGlobalFunc(L)) + return true; // the call is not defined + + lua_pushnumber(L, unit->id); + lua_pushnumber(L, unit->unitDef->id); + lua_pushnumber(L, unit->team); + lua_pushnumber(L, playerID); + + // call the function + if (!RunCallIn(L, cmdStr, 4, 1)) + return true; + + // get the results + const bool retval = luaL_optboolean(L, -1, true); + lua_pop(L, 1); + return retval; +} + + +bool CSyncedLuaHandle::AllowBuilderHoldFire(const CUnit* unit, int action) +{ + LUA_CALL_IN_CHECK(L, true); + luaL_checkstack(L, 2 + 3 + 1, __FUNCTION__); + + static const LuaHashString cmdStr(__FUNCTION__); + if (!cmdStr.GetGlobalFunc(L)) + return true; // the call is not defined + + lua_pushnumber(L, unit->id); + lua_pushnumber(L, unit->unitDef->id); + lua_pushnumber(L, action); + + // call the function + if (!RunCallIn(L, cmdStr, 3, 1)) + return true; + + // get the results + const bool retval = luaL_optboolean(L, -1, true); + lua_pop(L, 1); + return retval; +} + + +bool CSyncedLuaHandle::AllowStartPosition(int playerID, unsigned char readyState, const float3& clampedPos, const float3& rawPickPos) +{ + LUA_CALL_IN_CHECK(L, true); + luaL_checkstack(L, 13, __FUNCTION__); + + static const LuaHashString cmdStr(__FUNCTION__); + if (!cmdStr.GetGlobalFunc(L)) + return true; // the call is not defined + + // push the start position and playerID + lua_pushnumber(L, clampedPos.x); + lua_pushnumber(L, clampedPos.y); + lua_pushnumber(L, clampedPos.z); + lua_pushnumber(L, playerID); + lua_pushnumber(L, readyState); + lua_pushnumber(L, rawPickPos.x); + lua_pushnumber(L, rawPickPos.y); + lua_pushnumber(L, rawPickPos.z); + + // call the function + if (!RunCallIn(L, cmdStr, 8, 1)) + return true; + + // get the results + const bool retval = luaL_optboolean(L, -1, true); + lua_pop(L, 1); + return retval; +} + + +bool CSyncedLuaHandle::MoveCtrlNotify(const CUnit* unit, int data) +{ + LUA_CALL_IN_CHECK(L, false); + luaL_checkstack(L, 6, __FUNCTION__); + + static const LuaHashString cmdStr(__FUNCTION__); + if (!cmdStr.GetGlobalFunc(L)) + return false; // the call is not defined + + // push the unit info + lua_pushnumber(L, unit->id); + lua_pushnumber(L, unit->unitDef->id); + lua_pushnumber(L, unit->team); + lua_pushnumber(L, data); + + // call the function + if (!RunCallIn(L, cmdStr, 4, 1)) + return false; + + // get the results + const bool retval = luaL_optboolean(L, -1, false); + lua_pop(L, 1); + return retval; +} + + +bool CSyncedLuaHandle::TerraformComplete(const CUnit* unit, const CUnit* build) +{ + LUA_CALL_IN_CHECK(L, false); + luaL_checkstack(L, 8, __FUNCTION__); + const LuaUtils::ScopedDebugTraceBack traceBack(L); + + + + static const LuaHashString cmdStr(__FUNCTION__); + if (!cmdStr.GetGlobalFunc(L)) + return false; // the call is not defined + + // push the unit info + lua_pushnumber(L, unit->id); + lua_pushnumber(L, unit->unitDef->id); + lua_pushnumber(L, unit->team); + + // push the construction info + lua_pushnumber(L, build->id); + lua_pushnumber(L, build->unitDef->id); + lua_pushnumber(L, build->team); + + // call the function + if (!RunCallInTraceback(L, cmdStr, 6, 1, traceBack.GetErrFuncIdx(), false)) + return false; + + // get the results + const bool retval = luaL_optboolean(L, -1, false); + lua_pop(L, 1); + return retval; +} + + + +/** + * called after every damage modification (even HitByWeaponId) + * but before the damage is applied + * + * expects two numbers returned by lua code: + * 1st is stored under *newDamage if newDamage != NULL + * 2nd is stored under *impulseMult if impulseMult != NULL + */ +bool CSyncedLuaHandle::UnitPreDamaged( + const CUnit* unit, + const CUnit* attacker, + float damage, + int weaponDefID, + int projectileID, + bool paralyzer, + float* newDamage, + float* impulseMult) +{ + LUA_CALL_IN_CHECK(L, false); + luaL_checkstack(L, 2 + 2 + 10, __FUNCTION__); + const LuaUtils::ScopedDebugTraceBack traceBack(L); + + static const LuaHashString cmdStr(__FUNCTION__); + if (!cmdStr.GetGlobalFunc(L)) + return false; + + int inArgCount = 5; + int outArgCount = 2; + + lua_pushnumber(L, unit->id); + lua_pushnumber(L, unit->unitDef->id); + lua_pushnumber(L, unit->team); + lua_pushnumber(L, damage); + lua_pushboolean(L, paralyzer); + //FIXME pass impulse too? + + if (GetHandleFullRead(L)) { + lua_pushnumber(L, weaponDefID); inArgCount += 1; + lua_pushnumber(L, projectileID); inArgCount += 1; + + if (attacker != NULL) { + lua_pushnumber(L, attacker->id); + lua_pushnumber(L, attacker->unitDef->id); + lua_pushnumber(L, attacker->team); + inArgCount += 3; + } + } + + // call the routine + // NOTE: + // RunCallInTraceback removes the error-handler by default + // this has to be disabled when using ScopedDebugTraceBack + // or it would mess up the stack + if (!RunCallInTraceback(L, cmdStr, inArgCount, outArgCount, traceBack.GetErrFuncIdx(), false)) + return false; + + if (newDamage && lua_isnumber(L, -2)) { + *newDamage = lua_tonumber(L, -2); + } else if (!lua_isnumber(L, -2) || lua_isnil(L, -2)) { + // first value is obligatory, so may not be nil + LOG_L(L_WARNING, "%s(): 1st return-value should be a number (newDamage)", (cmdStr.GetString()).c_str()); + } + + if (impulseMult && lua_isnumber(L, -1)) { + *impulseMult = lua_tonumber(L, -1); + } else if (!lua_isnumber(L, -1) && !lua_isnil(L, -1)) { + // second value is optional, so nils are OK + LOG_L(L_WARNING, "%s(): 2nd return-value should be a number (impulseMult)", (cmdStr.GetString()).c_str()); + } + + lua_pop(L, outArgCount); + return (*newDamage == 0.f && *impulseMult == 0.f); // returns true to disable engine dmg handling +} + +bool CSyncedLuaHandle::FeaturePreDamaged( + const CFeature* feature, + const CUnit* attacker, + float damage, + int weaponDefID, + int projectileID, + float* newDamage, + float* impulseMult) +{ + LUA_CALL_IN_CHECK(L, false); + luaL_checkstack(L, 2 + 9 + 2, __FUNCTION__); + + static const LuaHashString cmdStr(__FUNCTION__); + const LuaUtils::ScopedDebugTraceBack traceBack(L); + + if (!cmdStr.GetGlobalFunc(L)) + return false; + + int inArgCount = 4; + int outArgCount = 2; + + lua_pushnumber(L, feature->id); + lua_pushnumber(L, feature->def->id); + lua_pushnumber(L, feature->team); + lua_pushnumber(L, damage); + + if (GetHandleFullRead(L)) { + lua_pushnumber(L, weaponDefID); inArgCount += 1; + lua_pushnumber(L, projectileID); inArgCount += 1; + + if (attacker != NULL) { + lua_pushnumber(L, attacker->id); + lua_pushnumber(L, attacker->unitDef->id); + lua_pushnumber(L, attacker->team); + inArgCount += 3; + } + } + + // call the routine + if (!RunCallInTraceback(L, cmdStr, inArgCount, outArgCount, traceBack.GetErrFuncIdx(), false)) + return false; -bool CLuaHandleSynced::HasSyncedXCall(const string& funcName) -{ - SELECT_LUA_STATE(); + if (newDamage && lua_isnumber(L, -2)) { + *newDamage = lua_tonumber(L, -2); + } else if (!lua_isnumber(L, -2) || lua_isnil(L, -2)) { + // first value is obligatory, so may not be nil + LOG_L(L_WARNING, "%s(): 1st value returned should be a number (newDamage)", (cmdStr.GetString()).c_str()); + } + + if (impulseMult && lua_isnumber(L, -1)) { + *impulseMult = lua_tonumber(L, -1); + } else if (!lua_isnumber(L, -1) && !lua_isnil(L, -1)) { + // second value is optional, so nils are OK + LOG_L(L_WARNING, "%s(): 2nd value returned should be a number (impulseMult)", (cmdStr.GetString()).c_str()); + } + + lua_pop(L, outArgCount); + return (*newDamage == 0.f && *impulseMult == 0.f); // returns true to disable engine dmg handling +} + +bool CSyncedLuaHandle::ShieldPreDamaged( + const CProjectile* projectile, + const CWeapon* shieldEmitter, + const CUnit* shieldCarrier, + bool bounceProjectile +) { + LUA_CALL_IN_CHECK(L, false); + luaL_checkstack(L, 2 + 5 + 1, __FUNCTION__); + const LuaUtils::ScopedDebugTraceBack traceBack(L); - if (L != L_Sim) + static const LuaHashString cmdStr(__FUNCTION__); + if (!cmdStr.GetGlobalFunc(L)) return false; - GML_DRCMUTEX_LOCK(lua); // HasSyncedXCall + // push the call-in arguments + lua_pushnumber(L, projectile->id); + lua_pushnumber(L, projectile->GetOwnerID()); + lua_pushnumber(L, shieldEmitter->weaponNum); + lua_pushnumber(L, shieldCarrier->id); + lua_pushboolean(L, bounceProjectile); - lua_pushvalue(L, LUA_GLOBALSINDEX); - if (!lua_istable(L, -1)) { - lua_pop(L, 1); + // call the routine + if (!RunCallInTraceback(L, cmdStr, 5, 1, traceBack.GetErrFuncIdx(), false)) return false; - } - lua_pushsstring(L, funcName); // push the function name - lua_rawget(L, -2); // get the function - const bool haveFunc = lua_isfunction(L, -1); - lua_pop(L, 2); - return haveFunc; + + // pop the return-value; must be true or false + const bool ret = luaL_optboolean(L, -1, false); + lua_pop(L, 1); + return ret; } -bool CLuaHandleSynced::HasUnsyncedXCall(lua_State* srcState, const string& funcName) +int CSyncedLuaHandle::AllowWeaponTargetCheck(unsigned int attackerID, unsigned int attackerWeaponNum, unsigned int attackerWeaponDefID) { - SELECT_UNSYNCED_LUA_STATE(); + int ret = -1; - GML_DRCMUTEX_LOCK(lua); // HasUnsyncedXCall + if (!watchWeaponDefs[attackerWeaponDefID]) + return ret; - unsyncedStr.GetRegistry(L); // push the UNSYNCED table - if (!lua_istable(L, -1)) { - lua_pop(L, 1); - return false; - } - lua_pushsstring(L, funcName); // push the function name - lua_rawget(L, -2); // get the function - const bool haveFunc = lua_isfunction(L, -1); - lua_pop(L, 2); - return haveFunc; + LUA_CALL_IN_CHECK(L, -1); + luaL_checkstack(L, 2 + 3 + 1, __FUNCTION__); + const LuaUtils::ScopedDebugTraceBack traceBack(L); + + static const LuaHashString cmdStr(__FUNCTION__); + if (!cmdStr.GetGlobalFunc(L)) + return ret; + + lua_pushnumber(L, attackerID); + lua_pushnumber(L, attackerWeaponNum); + lua_pushnumber(L, attackerWeaponDefID); + + if (!RunCallInTraceback(L, cmdStr, 3, 1, traceBack.GetErrFuncIdx(), false)) + return ret; + + ret = int(luaL_optboolean(L, -1, false)); //FIXME int???? + lua_pop(L, 1); + return ret; } -int CLuaHandleSynced::XCall(lua_State* L, lua_State* srcState, const string& funcName) +bool CSyncedLuaHandle::AllowWeaponTarget( + unsigned int attackerID, + unsigned int targetID, + unsigned int attackerWeaponNum, + unsigned int attackerWeaponDefID, + float* targetPriority) { - // expecting an environment table - if (!lua_istable(L, -1)) { - lua_pop(L, 1); - return 0; - } - - // push the function - const LuaHashString funcHash(funcName); - funcHash.Push(L); // push the function name - lua_rawget(L, -2); // get the function - if (!lua_isfunction(L, -1)) { - lua_pop(L, 2); - return 0; - } - lua_remove(L, -2); + assert(targetPriority != NULL); - const int top = lua_gettop(L) - 1; // do not count the function + bool ret = true; - const bool diffStates = (srcState != L); + if (!watchWeaponDefs[attackerWeaponDefID]) + return ret; - int retCount; + LUA_CALL_IN_CHECK(L, true); + luaL_checkstack(L, 2 + 5 + 2, __FUNCTION__); + const LuaUtils::ScopedDebugTraceBack traceBack(L); - if (!diffStates) { - lua_insert(L, 1); // move the function to the beginning - // call the function - if (!RunCallIn(funcHash, top, LUA_MULTRET)) { - return 0; - } - retCount = lua_gettop(L); - } - else { - const int srcCount = lua_gettop(srcState); + static const LuaHashString cmdStr(__FUNCTION__); + if (!cmdStr.GetGlobalFunc(L)) + return ret; + + lua_pushnumber(L, attackerID); + lua_pushnumber(L, targetID); + lua_pushnumber(L, attackerWeaponNum); + lua_pushnumber(L, attackerWeaponDefID); + lua_pushnumber(L, *targetPriority); - LuaUtils::CopyData(L, srcState, srcCount); + if (!RunCallInTraceback(L, cmdStr, 5, 2, traceBack.GetErrFuncIdx(), false)) + return ret; - // call the function - if (!RunCallIn(funcHash, srcCount, LUA_MULTRET)) { - return 0; - } - retCount = lua_gettop(L) - top; + ret = luaL_optboolean(L, -2, false); - lua_settop(srcState, 0); - if (retCount > 0) { - LuaUtils::CopyData(srcState, L, retCount); - } - lua_settop(L, top); + if (lua_isnumber(L, -1)) { + *targetPriority = lua_tonumber(L, -1); } - return retCount; -} + lua_pop(L, 2); + return ret; +} -int CLuaHandleSynced::SyncedXCall(lua_State* srcState, const string& funcName) -{ - SELECT_LUA_STATE(); - if (L != L_Sim) - return 0; +bool CSyncedLuaHandle::AllowWeaponInterceptTarget( + const CUnit* interceptorUnit, + const CWeapon* interceptorWeapon, + const CProjectile* interceptorTarget +) { + bool ret = true; - GML_DRCMUTEX_LOCK(lua); // SyncedXCall + if (!watchWeaponDefs[interceptorWeapon->weaponDef->id]) + return ret; - lua_pushvalue(L, LUA_GLOBALSINDEX); - const int retval = XCall(L, srcState, funcName); - ASSERT_SYNCED(retval); - return retval; -} + LUA_CALL_IN_CHECK(L, true); + luaL_checkstack(L, 2 + 3 + 1, __FUNCTION__); + const LuaUtils::ScopedDebugTraceBack traceBack(L); + static const LuaHashString cmdStr(__FUNCTION__); + if (!cmdStr.GetGlobalFunc(L)) + return ret; -int CLuaHandleSynced::UnsyncedXCall(lua_State* srcState, const string& funcName) -{ - SELECT_UNSYNCED_LUA_STATE(); + lua_pushnumber(L, interceptorUnit->id); + lua_pushnumber(L, interceptorWeapon->weaponNum); + lua_pushnumber(L, interceptorTarget->id); - GML_DRCMUTEX_LOCK(lua); // UnsyncedXCall + if (!RunCallInTraceback(L, cmdStr, 3, 1, traceBack.GetErrFuncIdx(), false)) + return ret; - const bool prevSynced = GetHandleSynced(L); - SetHandleSynced(L, false); - unsyncedStr.GetRegistry(L); // push the UNSYNCED table - const int retval = XCall(L, srcState, funcName); - SetHandleSynced(L, prevSynced); - return retval; + ret = luaL_optboolean(L, -1, false); + lua_pop(L, 1); + return ret; } -/******************************************************************************/ -/******************************************************************************/ +// +// Call-Outs +// -int CLuaHandleSynced::SyncedRandom(lua_State* L) +int CSyncedLuaHandle::SyncedRandom(lua_State* L) { const int args = lua_gettop(L); if (args == 0) { @@ -925,120 +1156,93 @@ } -int CLuaHandleSynced::LoadStringData(lua_State* L) +int CSyncedLuaHandle::SyncedRandomSeed(lua_State* L) { - size_t len; - const char *str = luaL_checklstring(L, 1, &len); - const char *chunkname = luaL_optstring(L, 2, str); - int status = luaL_loadbuffer(L, str, len, chunkname); - if (status != 0) { - lua_pushnil(L); - lua_insert(L, -2); - return 2; // nil, then the error message - } - // set the chunk's fenv to the current fenv - if (lua_istable(L, 3)) { - lua_pushvalue(L, 3); - } else { - LuaUtils::PushCurrentFuncEnv(L, __FUNCTION__); - } - if (lua_setfenv(L, -2) == 0) { - luaL_error(L, "loadstring(): error with setfenv"); - } - return 1; + const int newseed = luaL_checkint(L, -1); + gs->SetRandSeed(newseed); + return 0; } -int CLuaHandleSynced::CallAsTeam(lua_State* L) +int CSyncedLuaHandle::SyncedNext(lua_State* L) { - CLuaHandleSynced* lhs = GetSyncedHandle(L); - if (lhs->teamsLocked) { - luaL_error(L, "CallAsTeam() called when teams are locked"); - } - const int args = lua_gettop(L); - if ((args < 2) || !lua_isfunction(L, 2)) { - luaL_error(L, "Incorrect arguments to CallAsTeam()"); - } + auto* slh = GetSyncedHandle(L); + assert(slh->origNextRef > 0); - // save the current access - const bool prevFullCtrl = GetHandleFullCtrl(L); - const bool prevFullRead = GetHandleFullRead(L); - const int prevCtrlTeam = GetHandleCtrlTeam(L); - const int prevReadTeam = GetHandleReadTeam(L); - const int prevReadAllyTeam = GetHandleReadAllyTeam(L); - const int prevSelectTeam = GetHandleSelectTeam(L); + const std::set whiteList = { + LUA_TSTRING, + LUA_TNUMBER, + LUA_TBOOLEAN, + LUA_TNIL, + LUA_TTHREAD //FIXME LUA_TTHREAD is normally _not_ synced safe but LUS handler needs it atm (and uses it in a safe way) + }; - // parse the new access - if (lua_isnumber(L, 1)) { - const int teamID = lua_toint(L, 1); - if ((teamID < MinSpecialTeam) || (teamID >= teamHandler->ActiveTeams())) { - luaL_error(L, "Bad teamID in SetCtrlTeam"); - } - // ctrl - SetHandleCtrlTeam(L, teamID); - SetHandleFullCtrl(L, GetHandleCtrlTeam(L) == CEventClient::AllAccessTeam); - // read - SetHandleReadTeam(L, teamID); - SetHandleReadAllyTeam(L, (teamID < 0) ? teamID : teamHandler->AllyTeam(teamID)); - SetHandleFullRead(L, GetHandleReadAllyTeam(L) == CEventClient::AllAccessTeam); - // select - SetHandleSelectTeam(L, teamID); - } - else if (lua_istable(L, 1)) { - const int table = 1; - for (lua_pushnil(L); lua_next(L, table) != 0; lua_pop(L, 1)) { - if (!lua_israwstring(L, -2) || !lua_isnumber(L, -1)) { - continue; - } - const string key = lua_tostring(L, -2); - const int teamID = lua_toint(L, -1); - if ((teamID < MinSpecialTeam) || (teamID >= teamHandler->ActiveTeams())) { - luaL_error(L, "Bad teamID in SetCtrlTeam"); - } + const int oldTop = lua_gettop(L); - if (key == "ctrl") { - SetHandleCtrlTeam(L, teamID); - SetHandleFullCtrl(L, GetHandleCtrlTeam(L) == CEventClient::AllAccessTeam); - } - else if (key == "read") { - SetHandleReadTeam(L, teamID); - SetHandleReadAllyTeam(L, (teamID < 0) ? teamID : teamHandler->AllyTeam(teamID)); - SetHandleFullRead(L, GetHandleReadAllyTeam(L) == CEventClient::AllAccessTeam); - } - else if (key == "select") { - SetHandleSelectTeam(L, teamID); + lua_rawgeti(L, LUA_REGISTRYINDEX, slh->origNextRef); + lua_pushvalue(L, 1); + if (oldTop >= 2) { lua_pushvalue(L, 2); } else { lua_pushnil(L); } + lua_call(L, 2, LUA_MULTRET); + const int retCount = lua_gettop(L) - oldTop; + assert(retCount == 1 || retCount == 2); + + if (retCount >= 2) { + const int keyType = lua_type(L, -2); + if (whiteList.find(keyType) == whiteList.end()) { + if (LuaUtils::PushDebugTraceback(L) > 0) { + lua_pushfstring(L, "Iterating a table with keys of type \"%s\" in synced context!", lua_typename(L, keyType)); + lua_call(L, 1, 1); + + const auto* errMsg = lua_tostring(L, -1); + LOG_L(L_WARNING, "%s", errMsg); } + lua_pop(L, 1); // either nil or the errMsg } } - else { - luaL_error(L, "Incorrect arguments to CallAsTeam()"); - } - // call the function - const int funcArgs = lua_gettop(L) - 2; + return retCount; +} - // protected call so that the permissions are always reverted - const int error = lua_pcall(L, funcArgs, LUA_MULTRET, 0); - // revert the permissions - SetHandleFullCtrl(L, prevFullCtrl); - SetHandleFullRead(L, prevFullRead); - SetHandleCtrlTeam(L, prevCtrlTeam); - SetHandleReadTeam(L, prevReadTeam); - SetHandleReadAllyTeam(L, prevReadAllyTeam); - SetHandleSelectTeam(L, prevSelectTeam); +int CSyncedLuaHandle::SyncedPairs(lua_State* L) +{ + /* copied from lbaselib.cpp */ + luaL_checktype(L, 1, LUA_TTABLE); + lua_pushcfunction(L, SyncedNext); /* return generator, */ + lua_pushvalue(L, 1); /* state, */ + lua_pushnil(L); /* and initial value */ + return 3; +} - if (error != 0) { - LOG_L(L_ERROR, "error = %i, %s, %s", - error, "CallAsTeam", lua_tostring(L, -1)); - lua_error(L); + +int CSyncedLuaHandle::SendToUnsynced(lua_State* L) +{ + const int args = lua_gettop(L); + if (args <= 0) { + luaL_error(L, "Incorrect arguments to SendToUnsynced()"); } - return lua_gettop(L) - 1; // the teamID/table is still on the stack + static const int supportedTypes = + (1 << LUA_TNIL) + | (1 << LUA_TBOOLEAN) + | (1 << LUA_TNUMBER) + | (1 << LUA_TSTRING) + ; + + for (int i = 1; i <= args; i++) { + const int t = (1 << lua_type(L, i)); + if (!(t & supportedTypes)) { + luaL_error(L, "Incorrect data type for SendToUnsynced(), arg %d", i); + } + } + + CUnsyncedLuaHandle* ulh = CLuaHandleSynced::GetUnsyncedHandle(L); + ulh->RecvFromSynced(L, args); + return 0; } -int CLuaHandleSynced::AddSyncedActionFallback(lua_State* L) +int CSyncedLuaHandle::AddSyncedActionFallback(lua_State* L) { string cmdRaw = luaL_checkstring(L, 1); cmdRaw = "/" + cmdRaw; @@ -1054,7 +1258,7 @@ return 1; } - CLuaHandleSynced* lhs = GetSyncedHandle(L); + auto lhs = GetSyncedHandle(L); lhs->textCommands[cmd] = luaL_checkstring(L, 2); wordCompletion->AddWord(cmdRaw, true, false, false); lua_pushboolean(L, true); @@ -1062,8 +1266,9 @@ } -int CLuaHandleSynced::RemoveSyncedActionFallback(lua_State* L) +int CSyncedLuaHandle::RemoveSyncedActionFallback(lua_State* L) { + //TODO move to LuaHandle string cmdRaw = luaL_checkstring(L, 1); cmdRaw = "/" + cmdRaw; @@ -1078,8 +1283,7 @@ return 1; } - CLuaHandleSynced* lhs = GetSyncedHandle(L); - + auto lhs = GetSyncedHandle(L); map::iterator it = lhs->textCommands.find(cmd); if (it != lhs->textCommands.end()) { lhs->textCommands.erase(it); @@ -1092,11 +1296,9 @@ } -/******************************************************************************/ - #define GetWatchDef(DefType) \ - int CLuaHandleSynced::GetWatch ## DefType ## Def(lua_State* L) { \ - CLuaHandleSynced* lhs = GetSyncedHandle(L); \ + int CSyncedLuaHandle::GetWatch ## DefType ## Def(lua_State* L) { \ + CSyncedLuaHandle* lhs = GetSyncedHandle(L); \ const unsigned int defID = luaL_checkint(L, 1); \ if (defID >= lhs->watch ## DefType ## Defs.size()) { \ return 0; \ @@ -1106,8 +1308,8 @@ } #define SetWatchDef(DefType) \ - int CLuaHandleSynced::SetWatch ## DefType ## Def(lua_State* L) { \ - CLuaHandleSynced* lhs = GetSyncedHandle(L); \ + int CSyncedLuaHandle::SetWatch ## DefType ## Def(lua_State* L) { \ + CSyncedLuaHandle* lhs = GetSyncedHandle(L); \ const unsigned int defID = luaL_checkint(L, 1); \ if (defID >= lhs->watch ## DefType ## Defs.size()) { \ return 0; \ @@ -1127,5 +1329,183 @@ #undef GetWatchDef #undef SetWatchDef + +/******************************************************************************/ +/******************************************************************************/ +// ###### ## ## ### ######## ######## ######## +// ## ## ## ## ## ## ## ## ## ## ## +// ## ## ## ## ## ## ## ## ## ## +// ###### ######### ## ## ######## ###### ## ## +// ## ## ## ######### ## ## ## ## ## +// ## ## ## ## ## ## ## ## ## ## ## +// ###### ## ## ## ## ## ## ######## ######## + +CLuaHandleSynced::CLuaHandleSynced(const string& _name, int _order) + : syncedLuaHandle(this, _name, _order) + , unsyncedLuaHandle(this, _name, _order + 1) +{ +} + + +CLuaHandleSynced::~CLuaHandleSynced() +{ + // must be called before their dtors!!! + syncedLuaHandle.KillLua(); + unsyncedLuaHandle.KillLua(); +} + + +void CLuaHandleSynced::Init(const string& syncedFile, const string& unsyncedFile, const string& modes) +{ + if (!IsValid()) + return; + + const string syncedCode = LoadFile(syncedFile, modes); + const string unsyncedCode = LoadFile(unsyncedFile, modes); + if (syncedCode.empty() && unsyncedCode.empty()) { + KillLua(); + return; + } + + const bool haveSynced = syncedLuaHandle.Init(syncedCode, syncedFile); + const bool haveUnsynced = unsyncedLuaHandle.Init(unsyncedCode, unsyncedFile); + + if (!IsValid() || (!haveSynced && !haveUnsynced)) { + KillLua(); + return; + } + + CheckStack(); +} + + +string CLuaHandleSynced::LoadFile(const string& filename, const string& modes) const +{ + string vfsModes(modes); + if (CSyncedLuaHandle::devMode) { + vfsModes = SPRING_VFS_RAW + vfsModes; + } + CFileHandler f(filename, vfsModes); + string code; + if (!f.LoadStringData(code)) { + code.clear(); + } + return code; +} + +// +// Call-Outs +// + +int CLuaHandleSynced::LoadStringData(lua_State* L) +{ + size_t len; + const char *str = luaL_checklstring(L, 1, &len); + const char *chunkname = luaL_optstring(L, 2, str); + int status = luaL_loadbuffer(L, str, len, chunkname); + if (status != 0) { + lua_pushnil(L); + lua_insert(L, -2); + return 2; // nil, then the error message + } + // set the chunk's fenv to the current fenv + if (lua_istable(L, 3)) { + lua_pushvalue(L, 3); + } else { + LuaUtils::PushCurrentFuncEnv(L, __FUNCTION__); + } + if (lua_setfenv(L, -2) == 0) { + luaL_error(L, "loadstring(): error with setfenv"); + } + return 1; +} + + +int CLuaHandleSynced::CallAsTeam(lua_State* L) +{ + const int args = lua_gettop(L); + if ((args < 2) || !lua_isfunction(L, 2)) { + luaL_error(L, "Incorrect arguments to CallAsTeam()"); + } + + // save the current access + const bool prevFullCtrl = CLuaHandle::GetHandleFullCtrl(L); + const bool prevFullRead = CLuaHandle::GetHandleFullRead(L); + const int prevCtrlTeam = CLuaHandle::GetHandleCtrlTeam(L); + const int prevReadTeam = CLuaHandle::GetHandleReadTeam(L); + const int prevReadAllyTeam = CLuaHandle::GetHandleReadAllyTeam(L); + const int prevSelectTeam = CLuaHandle::GetHandleSelectTeam(L); + + // parse the new access + if (lua_isnumber(L, 1)) { + const int teamID = lua_toint(L, 1); + if ((teamID < CEventClient::MinSpecialTeam) || (teamID >= teamHandler->ActiveTeams())) { + luaL_error(L, "Bad teamID in SetCtrlTeam"); + } + // ctrl + CLuaHandle::SetHandleCtrlTeam(L, teamID); + CLuaHandle::SetHandleFullCtrl(L, prevCtrlTeam == CEventClient::AllAccessTeam); + // read + CLuaHandle::SetHandleReadTeam(L, teamID); + CLuaHandle::SetHandleReadAllyTeam(L, (teamID < 0) ? teamID : teamHandler->AllyTeam(teamID)); + CLuaHandle::SetHandleFullRead(L, prevReadAllyTeam == CEventClient::AllAccessTeam); + // select + CLuaHandle::SetHandleSelectTeam(L, teamID); + } + else if (lua_istable(L, 1)) { + const int table = 1; + for (lua_pushnil(L); lua_next(L, table) != 0; lua_pop(L, 1)) { + if (!lua_israwstring(L, -2) || !lua_isnumber(L, -1)) { + continue; + } + const string key = lua_tostring(L, -2); + const int teamID = lua_toint(L, -1); + if ((teamID < CEventClient::MinSpecialTeam) || (teamID >= teamHandler->ActiveTeams())) { + luaL_error(L, "Bad teamID in SetCtrlTeam"); + } + + if (key == "ctrl") { + CLuaHandle::SetHandleCtrlTeam(L, teamID); + CLuaHandle::SetHandleFullCtrl(L, prevCtrlTeam == CEventClient::AllAccessTeam); + } + else if (key == "read") { + CLuaHandle::SetHandleReadTeam(L, teamID); + CLuaHandle::SetHandleReadAllyTeam(L, (teamID < 0) ? teamID : teamHandler->AllyTeam(teamID)); + CLuaHandle::SetHandleFullRead(L, prevReadAllyTeam == CEventClient::AllAccessTeam); + } + else if (key == "select") { + CLuaHandle::SetHandleSelectTeam(L, teamID); + } + } + } + else { + luaL_error(L, "Incorrect arguments to CallAsTeam()"); + } + + // call the function + const int funcArgs = lua_gettop(L) - 2; + + // protected call so that the permissions are always reverted + const int error = lua_pcall(L, funcArgs, LUA_MULTRET, 0); + + // revert the permissions + CLuaHandle::SetHandleFullCtrl(L, prevFullCtrl); + CLuaHandle::SetHandleFullRead(L, prevFullRead); + CLuaHandle::SetHandleCtrlTeam(L, prevCtrlTeam); + CLuaHandle::SetHandleReadTeam(L, prevReadTeam); + CLuaHandle::SetHandleReadAllyTeam(L, prevReadAllyTeam); + CLuaHandle::SetHandleSelectTeam(L, prevSelectTeam); + + if (error != 0) { + LOG_L(L_ERROR, "error = %i, %s, %s", + error, "CallAsTeam", lua_tostring(L, -1)); + lua_error(L); + } + + return lua_gettop(L) - 1; // the teamID/table is still on the stack +} + + + /******************************************************************************/ /******************************************************************************/ diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaHandleSynced.h spring-98.0~14.04~ppa6/rts/Lua/LuaHandleSynced.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaHandleSynced.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaHandleSynced.h 2014-10-07 20:09:51.000000000 +0000 @@ -13,83 +13,122 @@ struct lua_State; class LuaSyncedCtrl; +class CLuaHandleSynced; +struct BuildInfo; -class CLuaHandleSynced : public CLuaHandle -{ - public: - static const LuaRulesParams::Params& GetGameParams() {return gameParams;}; - static const LuaRulesParams::HashMap& GetGameParamsMap() {return gameParamsMap;}; - public: - bool Initialize(const string& syncData); - string GetSyncData(); +class CUnsyncedLuaHandle : public CLuaHandle +{ + friend class CLuaHandleSynced; - void UpdateThreading(); + public: // call-ins + bool DrawUnit(const CUnit* unit); + bool DrawFeature(const CFeature* feature); + bool DrawShield(const CUnit* unit, const CWeapon* weapon); + bool DrawProjectile(const CProjectile* projectile); - inline bool GetAllowChanges() const { return IsDrawCallIn() ? allowChangesDraw : allowChanges; } - inline void SetAllowChanges(bool ac, bool all = false) { if (all) allowChangesDraw = allowChanges = ac; else if (IsDrawCallIn()) allowChangesDraw = ac; else allowChanges = ac; } + public: // all non-eventhandler callins + void RecvFromSynced(lua_State* srcState, int args); // not an engine call-in - public: // call-ins - bool HasCallIn(lua_State* L, const string& name); - virtual bool SyncedUpdateCallIn(lua_State* L, const string& name); - virtual bool UnsyncedUpdateCallIn(lua_State* L, const string& name); - - bool GotChatMsg(const string& msg, int playerID); - bool RecvLuaMsg(const string& msg, int playerID); - virtual void RecvFromSynced(lua_State* srcState, int args); // not an engine call-in + protected: + CUnsyncedLuaHandle(CLuaHandleSynced* base, const string& name, int order); + virtual ~CUnsyncedLuaHandle(); - bool SyncedActionFallback(const string& line, int playerID); + bool Init(const string& code, const string& file); - public: // custom call-in - bool HasSyncedXCall(const string& funcName); - bool HasUnsyncedXCall(lua_State* srcState, const string& funcName); - int XCall(lua_State* L, lua_State* srcState, const string& funcName); - int SyncedXCall(lua_State* srcState, const string& funcName); - int UnsyncedXCall(lua_State* srcState, const string& funcName); + static CUnsyncedLuaHandle* GetUnsyncedHandle(lua_State* L) { + assert(dynamic_cast(CLuaHandle::GetHandle(L))); + return static_cast(CLuaHandle::GetHandle(L)); + } protected: - CLuaHandleSynced(const string& name, int order); - virtual ~CLuaHandleSynced(); - void Init(const string& syncedFile, - const string& unsyncedFile, - const string& modes); - bool SetupSynced(lua_State* L); - bool SetupUnsynced(lua_State* L); + CLuaHandleSynced& base; +}; - // hooks to add code during initialization - virtual bool AddSyncedCode(lua_State* L) = 0; - virtual bool AddUnsyncedCode(lua_State* L) = 0; - string LoadFile(const string& filename, const string& modes) const; - bool CopyGlobalToUnsynced(lua_State* L, const char* name); - bool SetupUnsyncedFunction(lua_State* L, const char* funcName); - bool LoadUnsyncedCode(lua_State* L, const string& code, const string& debug); - bool SyncifyRandomFuncs(lua_State* L); - bool CopyRealRandomFuncs(lua_State* L); - bool LightCopyTable(lua_State* L, int dstIndex, int srcIndex); +class CSyncedLuaHandle : public CLuaHandle +{ + friend class CLuaHandleSynced; + + public: // call-ins + bool CommandFallback(const CUnit* unit, const Command& cmd); + bool AllowCommand(const CUnit* unit, const Command& cmd, bool fromSynced); + + bool AllowUnitCreation(const UnitDef* unitDef, const CUnit* builder, const BuildInfo* buildInfo); + bool AllowUnitTransfer(const CUnit* unit, int newTeam, bool capture); + bool AllowUnitBuildStep(const CUnit* builder, const CUnit* unit, float part); + bool AllowFeatureCreation(const FeatureDef* featureDef, int allyTeamID, const float3& pos); + bool AllowFeatureBuildStep(const CUnit* builder, const CFeature* feature, float part); + bool AllowResourceLevel(int teamID, const string& type, float level); + bool AllowResourceTransfer(int oldTeam, int newTeam, const string& type, float amount); + bool AllowDirectUnitControl(int playerID, const CUnit* unit); + bool AllowBuilderHoldFire(const CUnit* unit, int action); + bool AllowStartPosition(int playerID, unsigned char readyState, const float3& clampedPos, const float3& rawPickPos); + + bool TerraformComplete(const CUnit* unit, const CUnit* build); + bool MoveCtrlNotify(const CUnit* unit, int data); + + int AllowWeaponTargetCheck(unsigned int attackerID, unsigned int attackerWeaponNum, unsigned int attackerWeaponDefID); + bool AllowWeaponTarget( + unsigned int attackerID, + unsigned int targetID, + unsigned int attackerWeaponNum, + unsigned int attackerWeaponDefID, + float* targetPriority + ); + bool AllowWeaponInterceptTarget(const CUnit* interceptorUnit, const CWeapon* interceptorWeapon, const CProjectile* interceptorTarget); + + bool UnitPreDamaged( + const CUnit* unit, + const CUnit* attacker, + float damage, + int weaponDefID, + int projectileID, + bool paralyzer, + float* newDamage, + float* impulseMult); + + bool FeaturePreDamaged( + const CFeature* feature, + const CUnit* attacker, + float damage, + int weaponDefID, + int projectileID, + float* newDamage, + float* impulseMult); + + bool ShieldPreDamaged(const CProjectile*, const CWeapon*, const CUnit*, bool); + + bool SyncedActionFallback(const string& line, int playerID); protected: - static CLuaHandleSynced* GetSyncedHandle(lua_State* L) { - assert(dynamic_cast(CLuaHandle::GetHandle(L))); - return static_cast(CLuaHandle::GetHandle(L)); + CSyncedLuaHandle(CLuaHandleSynced* base, const string& name, int order); + virtual ~CSyncedLuaHandle(); + + bool Init(const string& code, const string& file); + + static CSyncedLuaHandle* GetSyncedHandle(lua_State* L) { + assert(dynamic_cast(CLuaHandle::GetHandle(L))); + return static_cast(CLuaHandle::GetHandle(L)); } - private: - bool allowChanges; // sim thread - bool allowChangesDraw; // other threads (a non sim thread may load gadgets) protected: - bool teamsLocked; // disables CallAsTeam() + CLuaHandleSynced& base; + map textCommands; // name, help + private: + int origNextRef; + private: // call-outs static int SyncedRandom(lua_State* L); + static int SyncedRandomSeed(lua_State* L); - static int LoadStringData(lua_State* L); - - static int CallAsTeam(lua_State* L); + static int SyncedNext(lua_State* L); + static int SyncedPairs(lua_State* L); - static int AllowUnsafeChanges(lua_State* L); + static int SendToUnsynced(lua_State* L); static int AddSyncedActionFallback(lua_State* L); static int RemoveSyncedActionFallback(lua_State* L); @@ -100,6 +139,94 @@ static int SetWatchFeatureDef(lua_State* L); static int GetWatchWeaponDef(lua_State* L); static int SetWatchWeaponDef(lua_State* L); +}; + + +class CLuaHandleSynced +{ + public: // Non-eventhandler call-ins + bool GotChatMsg(const string& msg, int playerID) { + return syncedLuaHandle.GotChatMsg(msg, playerID) || + unsyncedLuaHandle.GotChatMsg(msg, playerID); + } + + bool RecvLuaMsg(const string& msg, int playerID) { + return syncedLuaHandle.RecvLuaMsg(msg, playerID); + } + + public: + void CheckStack() { + syncedLuaHandle.CheckStack(); + unsyncedLuaHandle.CheckStack(); + } + + static CUnsyncedLuaHandle* GetUnsyncedHandle(lua_State* L) { + if (CLuaHandle::GetHandleSynced(L)) { + auto slh = CSyncedLuaHandle::GetSyncedHandle(L); + return &slh->base.unsyncedLuaHandle; + } else { + return CUnsyncedLuaHandle::GetUnsyncedHandle(L); + } + } + + static CSyncedLuaHandle* GetSyncedHandle(lua_State* L) { + if (CLuaHandle::GetHandleSynced(L)) { + return CSyncedLuaHandle::GetSyncedHandle(L); + } else { + auto ulh = CUnsyncedLuaHandle::GetUnsyncedHandle(L); + return &ulh->base.syncedLuaHandle; + } + } + + protected: + CLuaHandleSynced(const string& name, int order); + virtual ~CLuaHandleSynced(); + + string LoadFile(const string& filename, const string& modes) const; + void Init(const string& syncedFile, const string& unsyncedFile, const string& modes); + + bool IsValid() const { + return syncedLuaHandle.IsValid() && unsyncedLuaHandle.IsValid(); + } + void KillLua() { + syncedLuaHandle.KillLua(); + unsyncedLuaHandle.KillLua(); + } + + #define SET_PERMISSION(name, type) \ + void Set ## name(const type arg) { \ + syncedLuaHandle.Set ## name(arg); \ + unsyncedLuaHandle.Set ## name(arg); \ + } + + SET_PERMISSION(FullCtrl, bool); + SET_PERMISSION(FullRead, bool); + SET_PERMISSION(CtrlTeam, int); + SET_PERMISSION(ReadTeam, int); + SET_PERMISSION(ReadAllyTeam, int); + SET_PERMISSION(SelectTeam, int); + + #undef SET_PERMISSION + + protected: + friend class CUnsyncedLuaHandle; + friend class CSyncedLuaHandle; + + // hooks to add code during initialization + virtual bool AddSyncedCode(lua_State* L) = 0; + virtual bool AddUnsyncedCode(lua_State* L) = 0; + + // call-outs + static int LoadStringData(lua_State* L); + static int CallAsTeam(lua_State* L); + + public: + CSyncedLuaHandle syncedLuaHandle; + CUnsyncedLuaHandle unsyncedLuaHandle; + + public: + static const LuaRulesParams::Params& GetGameParams() { return gameParams; } + static const LuaRulesParams::HashMap& GetGameParamsMap() { return gameParamsMap; } private: //FIXME: add to CREG? diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaHelper.h spring-98.0~14.04~ppa6/rts/Lua/LuaHelper.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaHelper.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaHelper.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#ifndef LUA_HELPER_H -#define LUA_HELPER_H - -#include "Sim/Misc/TeamHandler.h" -#include "System/EventClient.h" -#include "LuaHandle.h" - -class CFeature; - -/******************************************************************************/ -/******************************************************************************/ -// -// Access helpers -// - -static inline bool FullCtrl(const lua_State *L) -{ - return CLuaHandle::GetHandleFullCtrl(L); -} - - -static inline int CtrlTeam(const lua_State *L) -{ - return CLuaHandle::GetHandleCtrlTeam(L); -} - - -static inline int CtrlAllyTeam(const lua_State *L) -{ - const int ctrlTeam = CtrlTeam(L); - if (ctrlTeam < 0) { - return ctrlTeam; - } - return teamHandler->AllyTeam(ctrlTeam); -} - - -static inline bool CanControlTeam(const lua_State *L, int teamID) -{ - const int ctrlTeam = CtrlTeam(L); - if (ctrlTeam < 0) { - return (ctrlTeam == CEventClient::AllAccessTeam) ? true : false; - } - return (ctrlTeam == teamID); -} - - -static inline bool CanControlAllyTeam(const lua_State *L, int allyTeamID) -{ - const int ctrlTeam = CtrlTeam(L); - if (ctrlTeam < 0) { - return (ctrlTeam == CEventClient::AllAccessTeam) ? true : false; - } - return (teamHandler->AllyTeam(ctrlTeam) == allyTeamID); -} - - -static inline bool CanControlUnit(const lua_State *L, const CUnit* unit) -{ - const int ctrlTeam = CtrlTeam(L); - if (ctrlTeam < 0) { - return (ctrlTeam == CEventClient::AllAccessTeam) ? true : false; - } - return (ctrlTeam == unit->team); -} - - -static inline bool CanControlFeatureAllyTeam(const lua_State *L, int allyTeamID) -{ - const int ctrlTeam = CtrlTeam(L); - if (ctrlTeam < 0) { - return (ctrlTeam == CEventClient::AllAccessTeam) ? true : false; - } - if (allyTeamID < 0) { - return (ctrlTeam == teamHandler->GaiaTeamID()); - } - return (teamHandler->AllyTeam(ctrlTeam) == allyTeamID); -} - - -static inline bool CanControlFeature(const lua_State *L, const CFeature* feature) -{ - return CanControlFeatureAllyTeam(L, feature->allyteam); -} - - -static inline bool CanControlProjectileAllyTeam(const lua_State *L, int allyTeamID) -{ - const int ctrlTeam = CtrlTeam(L); - if (ctrlTeam < 0) { - return (ctrlTeam == CEventClient::AllAccessTeam) ? true : false; - } - if (allyTeamID < 0) { - return false; - } - return (teamHandler->AllyTeam(ctrlTeam) == allyTeamID); -} - -#endif // LUA_HELPER_H diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaInputReceiver.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaInputReceiver.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaInputReceiver.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaInputReceiver.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -21,13 +21,13 @@ } -bool LuaInputReceiver::KeyPressed(unsigned short key, bool isRepeat) +bool LuaInputReceiver::KeyPressed(int key, bool isRepeat) { return eventHandler.KeyPress(key, isRepeat); } -bool LuaInputReceiver::KeyReleased(unsigned short key) +bool LuaInputReceiver::KeyReleased(int key) { return eventHandler.KeyRelease(key); } diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaInputReceiver.h spring-98.0~14.04~ppa6/rts/Lua/LuaInputReceiver.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaInputReceiver.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaInputReceiver.h 2014-10-07 20:09:51.000000000 +0000 @@ -14,8 +14,8 @@ LuaInputReceiver(); ~LuaInputReceiver(); - bool KeyPressed(unsigned short key, bool isRepeat); - bool KeyReleased(unsigned short key); + bool KeyPressed(int key, bool isRepeat); + bool KeyReleased(int key); bool MousePress(int x, int y, int button); void MouseMove(int x, int y, int dx, int dy, int button); diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaInterCall.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaInterCall.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaInterCall.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaInterCall.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,143 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + + +#include "LuaInterCall.h" + +#include "LuaInclude.h" + +#include "LuaHandle.h" +#include "LuaGaia.h" +#include "LuaRules.h" +#include "LuaUI.h" + + +enum { + LUA_UI, + LUA_RULES, + LUA_GAIA +}; + + +static CLuaHandle* GetLuaHandle(lua_State* L, int index) +{ + int* addr = (int*) lua_touserdata(L, index); + if (addr == NULL) { + luaL_error(L, "Bad XCall target"); + return NULL; + } + + const bool isSrcSynced = CLuaHandle::GetHandleSynced(L); + switch (*addr) { + case LUA_UI: + if (!luaUI) return NULL; // handle is not currently active + return luaUI; + case LUA_RULES: + if (!luaRules) return NULL; // handle is not currently active + return (isSrcSynced) ? static_cast(&luaRules->syncedLuaHandle) : static_cast(&luaRules->unsyncedLuaHandle); + case LUA_GAIA: + if (!luaGaia) return NULL; // handle is not currently active + return (isSrcSynced) ? static_cast(&luaGaia->syncedLuaHandle) : static_cast(&luaGaia->unsyncedLuaHandle); + default: + luaL_error(L, "Bad XCall target"); + return NULL; + }; +} + + +/******************************************************************************/ +/******************************************************************************/ + + +static int HandleXCall(lua_State* L) +{ + const int addrIndex = lua_upvalueindex(1); + const int nameIndex = lua_upvalueindex(2); + + CLuaHandle* lh = GetLuaHandle(L, addrIndex); + const std::string funcName = luaL_checksstring(L, nameIndex); + + if (lh == NULL) return 0; + return lh->XCall(L, funcName); +} + + +static int IndexHook(lua_State* L) +{ + if (!lua_israwstring(L, -1)) { + return luaL_error(L, "Script.XYZ: only strings allowed got ", lua_typename(L, -1)); + } + + lua_pushvalue(L, lua_upvalueindex(1)); + lua_pushvalue(L, -2); + lua_pushcclosure(L, HandleXCall, 2); + return 1; +} + + +static int CallHook(lua_State* L) +{ + const int addrIndex = lua_upvalueindex(1); + CLuaHandle* lh = GetLuaHandle(L, addrIndex); + if (lh == NULL) return 0; + + const int args = lua_gettop(L); // arg 1 is the table + if (args <= 1) { + // is the handle currently active? + lua_pushboolean(L, (lh != NULL)); + return 1; + } + else if (args >= 2) { + // see if the specified function exists + const string funcName = luaL_checksstring(L, 2); + lua_pushboolean(L, lh->HasXCall(funcName)); + return 1; + } + return 0; +} + + +static int PushCallHandler(lua_State* L, int luaInstance, const string& name) +{ + lua_pushsstring(L, name); + int* ptr = (int*) lua_newuserdata(L, sizeof(int)); + *ptr = luaInstance; + { // create metatable of the userdata + lua_newtable(L); { + lua_pushliteral(L, "__index"); + lua_pushvalue(L, -3); //userdata + lua_pushcclosure(L, IndexHook, 1); + lua_rawset(L, -3); + lua_pushliteral(L, "__call"); + lua_pushvalue(L, -3); //userdata + lua_pushcclosure(L, CallHook, 1); + lua_rawset(L, -3); + lua_pushliteral(L, "__metatable"); + lua_pushliteral(L, "can't touch this"); + lua_rawset(L, -3); + } + lua_setmetatable(L, -2); // set the userdata's metatable + } + lua_rawset(L, -3); + return 0; +} + + +bool LuaInterCall::PushEntriesSynced(lua_State* L) +{ + PushCallHandler(L, LUA_GAIA, "LuaGaia"); + PushCallHandler(L, LUA_RULES, "LuaRules"); + return true; +} + + +bool LuaInterCall::PushEntriesUnsynced(lua_State* L) +{ + PushCallHandler(L, LUA_GAIA, "LuaGaia"); + PushCallHandler(L, LUA_RULES, "LuaRules"); + PushCallHandler(L, LUA_UI, "LuaUI"); + return true; +} + + +/******************************************************************************/ +/******************************************************************************/ diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaInterCall.h spring-98.0~14.04~ppa6/rts/Lua/LuaInterCall.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaInterCall.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaInterCall.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,15 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef LUA_INTER_CALL_H +#define LUA_INTER_CALL_H + +struct lua_State; + + +class LuaInterCall { + public: + static bool PushEntriesSynced(lua_State* L); + static bool PushEntriesUnsynced(lua_State* L); +}; + +#endif /* LUA_INTER_CALL_H */ diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaIntro.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaIntro.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaIntro.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaIntro.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,16 +1,19 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ +#include +#include #include "LuaIntro.h" #include "LuaInclude.h" +#include "LuaArchive.h" #include "LuaUnsyncedCtrl.h" #include "LuaCallInCheck.h" #include "LuaConstGL.h" #include "LuaConstCMD.h" #include "LuaConstCMDTYPE.h" #include "LuaConstGame.h" -#include "LuaUnsyncedCall.h" +#include "LuaInterCall.h" #include "LuaUnsyncedRead.h" #include "LuaScream.h" #include "LuaSyncedRead.h" @@ -34,36 +37,40 @@ /******************************************************************************/ /******************************************************************************/ +static boost::mutex m_singleton; + void CLuaIntro::LoadHandler() { - if (LuaIntro) { - return; - } + { + std::lock_guard lk(m_singleton); + if (LuaIntro) return; - new CLuaIntro(); + LuaIntro = new CLuaIntro(); + } if (!LuaIntro->IsValid()) { - delete LuaIntro; + FreeHandler(); } } void CLuaIntro::FreeHandler() { - static bool inFree = false; - if (!inFree) { - inFree = true; - delete LuaIntro; - inFree = false; - } + std::lock_guard lk(m_singleton); + if (!LuaIntro) return; + + auto* inst = LuaIntro; + LuaIntro = NULL; + inst->KillLua(); + delete inst; } /******************************************************************************/ CLuaIntro::CLuaIntro() -: CLuaHandle("LuaIntro", LUA_HANDLE_ORDER_INTRO, true) +: CLuaHandle("LuaIntro", LUA_HANDLE_ORDER_INTRO, true, false) { LuaIntro = this; @@ -79,8 +86,6 @@ return; } - lua_State* L = L_Sim; - // load the standard libraries LUA_OPEN_LIB(L, luaopen_base); LUA_OPEN_LIB(L, luaopen_io); @@ -116,11 +121,6 @@ AddBasicCalls(L); // into Global - lua_pushstring(L, "Script"); - lua_rawget(L, -2); - LuaPushNamedCFunc(L, "UpdateCallIn", CallOutUnsyncedUpdateCallIn); - lua_pop(L, 1); - // load the spring libraries if ( !AddEntriesToTable(L, "Spring", LoadUnsyncedCtrlFunctions) || @@ -130,7 +130,9 @@ !AddEntriesToTable(L, "VFS", LuaVFS::PushUnsynced) || !AddEntriesToTable(L, "VFS", LuaZipFileReader::PushUnsynced) || !AddEntriesToTable(L, "VFS", LuaZipFileWriter::PushUnsynced) || + !AddEntriesToTable(L, "VFS", LuaArchive::PushEntries) || !AddEntriesToTable(L, "Script", LuaScream::PushEntries) || + //!AddEntriesToTable(L, "Script", LuaInterCall::PushEntriesUnsynced) || //!AddEntriesToTable(L, "Script", LuaLobby::PushEntries) || !AddEntriesToTable(L, "gl", LuaOpenGL::PushEntries) || !AddEntriesToTable(L, "GL", LuaConstGL::PushEntries) || @@ -160,10 +162,6 @@ CLuaIntro::~CLuaIntro() { - if (L_Sim != NULL || L_Draw != NULL) { - Shutdown(); - KillLua(); - } LuaIntro = NULL; } @@ -288,9 +286,6 @@ REGISTER_LUA_CFUNC(GetKeyBindings); REGISTER_LUA_CFUNC(GetActionHotKeys); - REGISTER_LUA_CFUNC(GetMyAllyTeamID); - REGISTER_LUA_CFUNC(GetMyTeamID); - REGISTER_LUA_CFUNC(GetLogSections); #undef REGISTER_LUA_CFUNC @@ -355,65 +350,9 @@ } -bool CLuaIntro::HasCallIn(lua_State *L, const string& name) -{ - if (!IsValid()) { - return false; - } - - // never allow these calls - if (name == "Explosion") { - return false; - } - - if (name == "CollectGarbage") { - return false; - } - - lua_getglobal(L, name.c_str()); - if (!lua_isfunction(L, -1)) { - lua_pop(L, 1); - return false; - } - lua_pop(L, 1); - return true; -} - - -bool CLuaIntro::UnsyncedUpdateCallIn(lua_State *L, const string& name) -{ - // never allow this call-in - if (name == "Explosion") { - return false; - } - - if (HasCallIn(L, name)) { - eventHandler.InsertEvent(this, name); - } else { - eventHandler.RemoveEvent(this, name); - } - - return true; -} - - /******************************************************************************/ /******************************************************************************/ -void CLuaIntro::Shutdown() -{ - LUA_CALL_IN_CHECK(L); - luaL_checkstack(L, 2, __FUNCTION__); - static const LuaHashString cmdStr("Shutdown"); - if (!cmdStr.GetGlobalFunc(L)) { - return; - } - - // call the routine - RunCallIn(cmdStr, 0, 0); -} - - void CLuaIntro::DrawLoadScreen() { LUA_CALL_IN_CHECK(L); @@ -428,7 +367,7 @@ LuaOpenGL::EnableCommon(LuaOpenGL::DRAW_SCREEN); // call the routine - RunCallIn(cmdStr, 0, 0); + RunCallIn(L, cmdStr, 0, 0); LuaOpenGL::DisableCommon(LuaOpenGL::DRAW_SCREEN); LuaOpenGL::SetDrawingEnabled(L, false); @@ -448,7 +387,7 @@ lua_pushboolean(L, replace_lastline); // call the routine - RunCallIn(cmdStr, 2, 0); + RunCallIn(L, cmdStr, 2, 0); } /******************************************************************************/ diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaIntro.h spring-98.0~14.04~ppa6/rts/Lua/LuaIntro.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaIntro.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaIntro.h 2014-10-07 20:09:51.000000000 +0000 @@ -16,10 +16,6 @@ static void FreeHandler(); public: // call-ins - bool HasCallIn(lua_State *L, const std::string& name); - bool UnsyncedUpdateCallIn(lua_State *L, const std::string& name); - - void Shutdown(); void DrawLoadScreen(); void LoadProgress(const std::string& msg, const bool replace_lastline); diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaMaterial.h spring-98.0~14.04~ppa6/rts/Lua/LuaMaterial.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaMaterial.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaMaterial.h 2014-10-07 20:09:51.000000000 +0000 @@ -12,7 +12,6 @@ #include "LuaOpenGLUtils.h" #include "LuaUnitMaterial.h" // for LuaMatRef -#include "LuaUniqueBin.h" #include "Rendering/GL/myGL.h" #include "Rendering/ShadowHandler.h" @@ -141,7 +140,7 @@ public: void Clear() { units.clear(); } - const GML_VECTOR& GetUnits() const { return units; } + const std::vector& GetUnits() const { return units; } void Ref(); void UnRef(); @@ -157,7 +156,7 @@ private: int refCount; - GML_VECTOR units; + std::vector units; }; diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaMathExtra.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaMathExtra.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaMathExtra.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaMathExtra.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -20,6 +20,7 @@ LuaPushNamedCFunc(L, "mix", mix); LuaPushNamedCFunc(L, "round", round); LuaPushNamedCFunc(L, "erf", erf); + LuaPushNamedCFunc(L, "smoothstep", smoothstep); return true; } @@ -69,7 +70,7 @@ const lua_Number y = luaL_checknumber_noassert(L, 2); const lua_Number a = luaL_checknumber_noassert(L, 3); - lua_pushnumber(L, Blend(x, y, a)); + lua_pushnumber(L, ::mix(x, y, a)); return 1; } @@ -99,6 +100,11 @@ return 1; } +int LuaMathExtra::smoothstep(lua_State* L) { + lua_pushnumber(L, ::smoothstep(luaL_checkfloat(L, 1), luaL_checkfloat(L, 2), luaL_checkfloat(L, 3))); + return 1; +} + /******************************************************************************/ /******************************************************************************/ diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaMathExtra.h spring-98.0~14.04~ppa6/rts/Lua/LuaMathExtra.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaMathExtra.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaMathExtra.h 2014-10-07 20:09:51.000000000 +0000 @@ -17,6 +17,7 @@ static int mix(lua_State* L); static int round(lua_State* L); static int erf(lua_State* L); + static int smoothstep(lua_State* L); }; #endif /* LUA_MATH_EXTRA_H */ diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaOpenGL.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaOpenGL.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaOpenGL.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaOpenGL.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -12,9 +12,6 @@ #include #include #include -#include -#include - #include "LuaOpenGL.h" #include "LuaInclude.h" @@ -33,12 +30,11 @@ #include "Game/Camera.h" #include "Game/UI/CommandColors.h" #include "Game/UI/MiniMap.h" -#include "lib/gml/gmlmut.h" #include "Map/BaseGroundDrawer.h" #include "Map/HeightMapTexture.h" #include "Map/MapInfo.h" #include "Map/ReadMap.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Rendering/GlobalRendering.h" #include "Rendering/IconHandler.h" #include "Rendering/LineDrawer.h" @@ -119,11 +115,11 @@ { glDeleteLists(resetStateList, 1); - if (globalRendering->haveGLSL) { - set::const_iterator it; - for (it = occlusionQueries.begin(); it != occlusionQueries.end(); ++it) { - glDeleteQueries(1, &(*it)); - } + if (!globalRendering->haveGLSL) + return; + + for (auto it = occlusionQueries.begin(); it != occlusionQueries.end(); ++it) { + glDeleteQueries(1, &(*it)); } } @@ -725,6 +721,16 @@ void LuaOpenGL::EnableDrawInMiniMap() { + glMatrixMode(GL_TEXTURE); { + glPushMatrix(); + } + glMatrixMode(GL_PROJECTION); { + glPushMatrix(); + } + glMatrixMode(GL_MODELVIEW); { + glPushMatrix(); + } + if (drawMode == DRAW_SCREEN) { prevDrawMode = DRAW_SCREEN; drawMode = DRAW_NONE; @@ -739,16 +745,6 @@ { if (prevDrawMode != DRAW_SCREEN) { DisableCommon(DRAW_MINIMAP); - - glMatrixMode(GL_TEXTURE); { - glLoadIdentity(); - } - glMatrixMode(GL_PROJECTION); { - glLoadIdentity(); - } - glMatrixMode(GL_MODELVIEW); { - glLoadIdentity(); - } } else { if (safeMode) { @@ -761,6 +757,16 @@ prevDrawMode = DRAW_NONE; drawMode = DRAW_SCREEN; } + + glMatrixMode(GL_TEXTURE); { + glPopMatrix(); + } + glMatrixMode(GL_PROJECTION); { + glPopMatrix(); + } + glMatrixMode(GL_MODELVIEW); { + glPopMatrix(); + } } @@ -774,6 +780,71 @@ /******************************************************************************/ +// +// MiniMap BG +// + +void LuaOpenGL::EnableDrawInMiniMapBackground() +{ + glMatrixMode(GL_TEXTURE); { + glPushMatrix(); + } + glMatrixMode(GL_PROJECTION); { + glPushMatrix(); + } + glMatrixMode(GL_MODELVIEW); { + glPushMatrix(); + } + + if (drawMode == DRAW_SCREEN) { + prevDrawMode = DRAW_SCREEN; + drawMode = DRAW_NONE; + } + EnableCommon(DRAW_MINIMAP_BACKGROUND); + resetMatrixFunc = ResetMiniMapMatrices; + ResetMiniMapMatrices(); +} + + +void LuaOpenGL::DisableDrawInMiniMapBackground() +{ + if (prevDrawMode != DRAW_SCREEN) { + DisableCommon(DRAW_MINIMAP_BACKGROUND); + } + else { + if (safeMode) { + glPopAttrib(); + } else { + glCallList(resetStateList); + } + resetMatrixFunc = ResetScreenMatrices; + ResetScreenMatrices(); + prevDrawMode = DRAW_NONE; + drawMode = DRAW_SCREEN; + } + + glMatrixMode(GL_TEXTURE); { + glPopMatrix(); + } + glMatrixMode(GL_PROJECTION); { + glPopMatrix(); + } + glMatrixMode(GL_MODELVIEW); { + glPopMatrix(); + } +} + + +void LuaOpenGL::ResetDrawInMiniMapBackground() +{ + if (safeMode) { + ResetMiniMapMatrices(); + glCallList(resetStateList); + } +} + + +/******************************************************************************/ /******************************************************************************/ void LuaOpenGL::SetupWorldLighting() @@ -1267,8 +1338,6 @@ const bool rawDraw = luaL_optboolean(L, 2, false); - GML_LODMUTEX_LOCK(unit); // Unit - bool useLOD = true; if (unit->lodCount <= 0) { useLOD = false; @@ -1330,8 +1399,6 @@ const bool rawDraw = luaL_optboolean(L, 2, false); - GML_LODMUTEX_LOCK(unit); // UnitRaw - bool useLOD = true; if (unit->lodCount <= 0) { useLOD = false; @@ -2477,6 +2544,8 @@ const GLint y = (GLint)luaL_checkint(L, 2); const GLsizei w = (GLsizei)luaL_checkint(L, 3); const GLsizei h = (GLsizei)luaL_checkint(L, 4); + if (w < 0) luaL_argerror(L, 3, " must be greater than or equal zero!"); + if (h < 0) luaL_argerror(L, 4, " must be greater than or equal zero!"); glScissor(x + globalRendering->viewPosX, y + globalRendering->viewPosY, w, h); } else { @@ -2492,12 +2561,13 @@ CheckDrawingEnabled(L, __FUNCTION__); const int x = luaL_checkint(L, 1); - const int y = luaL_checkint(L, 1); - const int w = luaL_checkint(L, 1); - const int h = luaL_checkint(L, 1); + const int y = luaL_checkint(L, 2); + const int w = luaL_checkint(L, 3); + const int h = luaL_checkint(L, 4); + if (w < 0) luaL_argerror(L, 3, " must be greater than or equal zero!"); + if (h < 0) luaL_argerror(L, 4, " must be greater than or equal zero!"); glViewport(x, y, w, h); - return 0; } @@ -2977,14 +3047,18 @@ int LuaOpenGL::LineWidth(lua_State* L) { - glLineWidth(luaL_checkfloat(L, 1)); + const float width = luaL_checkfloat(L, 1); + if (width <= 0.0f) luaL_argerror(L, 1, "Incorrect Width (must be greater zero)"); + glLineWidth(width); return 0; } int LuaOpenGL::PointSize(lua_State* L) { - glPointSize(luaL_checkfloat(L, 1)); + const float size = luaL_checkfloat(L, 1); + if (size <= 0.0f) luaL_argerror(L, 1, "Incorrect Size (must be greater zero)"); + glPointSize(size); return 0; } @@ -3122,6 +3196,8 @@ LuaTextures::Texture tex; tex.xsize = (GLsizei)luaL_checknumber(L, 1); tex.ysize = (GLsizei)luaL_checknumber(L, 2); + if (tex.xsize <= 0) luaL_argerror(L, 1, "Texture Size must be greater than zero!"); + if (tex.ysize <= 0) luaL_argerror(L, 2, "Texture Size must be greater than zero!"); if (lua_istable(L, 3)) { const int table = 3; @@ -4256,28 +4332,36 @@ { GLuint q; glGenQueries(1, &q); - if (q == 0) { + + if (q == 0) return 0; - } - occlusionQueries.insert(q); - lua_pushlightuserdata(L, (void*) &(*occlusionQueries.find(q))); + + // store a raw pointer to the inserted query value as userdata + const auto pair = occlusionQueries.insert(q); + const auto iter = pair.first; + const void* addr = &(*iter); + + lua_pushlightuserdata(L, const_cast(addr)); return 1; } int LuaOpenGL::DeleteQuery(lua_State* L) { - if (lua_isnil(L, 1)) { + if (lua_isnil(L, 1)) return 0; - } - if (!lua_islightuserdata(L, 1)) { + + if (!lua_islightuserdata(L, 1)) luaL_error(L, "invalid argument"); + + const GLuint* ptr = reinterpret_cast(lua_topointer(L, 1)); + const GLuint qry = *ptr; + + if (occlusionQueries.find(qry) != occlusionQueries.end()) { + occlusionQueries.erase(qry); + glDeleteQueries(1, &qry); } - GLuint q = (unsigned long int)lua_topointer(L, 1); - if (occlusionQueries.find(q) != occlusionQueries.end()) { - occlusionQueries.erase(q); - glDeleteQueries(1, &q); - } + return 0; } @@ -4286,23 +4370,25 @@ { static bool running = false; - if (running) { + if (running) luaL_error(L, "not re-entrant"); - } - if (!lua_islightuserdata(L, 1)) { + + if (!lua_islightuserdata(L, 1)) luaL_error(L, "expecting a query"); - } - GLuint q = (unsigned long int)lua_topointer(L, 1); - if (occlusionQueries.find(q) == occlusionQueries.end()) { + + const GLuint* ptr = reinterpret_cast(lua_topointer(L, 1)); + const GLuint qry = *ptr; + + if (occlusionQueries.find(qry) == occlusionQueries.end()) return 0; - } - if (!lua_isfunction(L, 2)) { + + if (!lua_isfunction(L, 2)) luaL_error(L, "expecting a function"); - } + const int args = lua_gettop(L); // number of arguments running = true; - glBeginQuery(GL_SAMPLES_PASSED, q); + glBeginQuery(GL_SAMPLES_PASSED, qry); const int error = lua_pcall(L, (args - 2), 0, 0); glEndQuery(GL_SAMPLES_PASSED); running = false; @@ -4319,19 +4405,19 @@ int LuaOpenGL::GetQuery(lua_State* L) { - if (!lua_islightuserdata(L, 1)) { + if (!lua_islightuserdata(L, 1)) luaL_error(L, "invalid argument"); - } - GLuint q = (unsigned long int)lua_topointer(L, 1); - if (occlusionQueries.find(q) == occlusionQueries.end()) { + + const GLuint* ptr = reinterpret_cast(lua_topointer(L, 1)); + const GLuint qry = *ptr; + + if (occlusionQueries.find(qry) == occlusionQueries.end()) return 0; - } GLuint count; - glGetQueryObjectuiv(q, GL_QUERY_RESULT, &count); + glGetQueryObjectuiv(qry, GL_QUERY_RESULT, &count); lua_pushnumber(L, count); - return 1; } diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaOpenGL.h spring-98.0~14.04~ppa6/rts/Lua/LuaOpenGL.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaOpenGL.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaOpenGL.h 2014-10-07 20:09:51.000000000 +0000 @@ -22,7 +22,8 @@ DRAW_WORLD_REFRACTION = 5, DRAW_SCREEN = 6, DRAW_MINIMAP = 7, - DRAW_LAST_MODE = DRAW_MINIMAP + DRAW_MINIMAP_BACKGROUND = 8, + DRAW_LAST_MODE = DRAW_MINIMAP_BACKGROUND }; public: @@ -31,8 +32,8 @@ static bool PushEntries(lua_State* L); - static bool IsDrawingEnabled(lua_State* L) { return GET_HANDLE_CONTEXT_DATA(drawingEnabled); } - static void SetDrawingEnabled(lua_State* L, bool value) { GET_HANDLE_CONTEXT_DATA(drawingEnabled) = value; } + static bool IsDrawingEnabled(lua_State* L) { return GetLuaContextData(L)->drawingEnabled; } + static void SetDrawingEnabled(lua_State* L, bool value) { GetLuaContextData(L)->drawingEnabled = value; } static bool CanUseShaders() { return canUseShaders; } @@ -79,6 +80,10 @@ static void ResetDrawInMiniMap(); static void DisableDrawInMiniMap(); + static void EnableDrawInMiniMapBackground(); + static void ResetDrawInMiniMapBackground(); + static void DisableDrawInMiniMapBackground(); + inline static void InitMatrixState(lua_State* L, const LuaHashString* hs); inline static void CheckMatrixState(lua_State* L, const LuaHashString* hs, int error); diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaOpenGLUtils.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaOpenGLUtils.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaOpenGLUtils.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaOpenGLUtils.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -11,7 +11,7 @@ #include "Map/BaseGroundDrawer.h" #include "Map/HeightMapTexture.h" #include "Map/ReadMap.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Rendering/GlobalRendering.h" #include "Rendering/IconHandler.h" #include "Rendering/ShadowHandler.h" @@ -577,11 +577,11 @@ case LUATEX_GRASS: return int2(1024, 1024); case LUATEX_FONT: - return int2(font->GetTexWidth(), font->GetTexHeight()); + return int2(font->GetTextureWidth(), font->GetTextureHeight()); case LUATEX_FONTSMALL: - return int2(smallFont->GetTexWidth(), smallFont->GetTexHeight()); + return int2(smallFont->GetTextureWidth(), smallFont->GetTextureHeight()); case LUATEX_MINIMAP: - if (readMap != NULL) { + if (readMap != NULL) { return readMap->GetMiniMapTextureSize(); } break; @@ -591,7 +591,7 @@ case LUATEX_INFOTEX_MTLMAP: case LUATEX_INFOTEX_HGTMAP: case LUATEX_INFOTEX_BLKMAP: { - if (readMap != NULL) { + if (readMap != NULL) { return (readMap->GetGroundDrawer()->GetInfoTexSize()); } } @@ -602,7 +602,7 @@ case LUATEX_MAP_GBUFFER_EMITTEX: case LUATEX_MAP_GBUFFER_MISCTEX: case LUATEX_MAP_GBUFFER_ZVALTEX: { - if (readMap != NULL) { + if (readMap != NULL) { return (readMap->GetGroundDrawer()->GetGeometryBuffer()->GetWantedSize(readMap->GetGroundDrawer()->DrawDeferred())); } } diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaParser.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaParser.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaParser.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaParser.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -21,7 +21,6 @@ #include "System/FileSystem/FileHandler.h" #include "System/FileSystem/VFSHandler.h" #include "System/FileSystem/FileSystem.h" -#include "System/BranchPrediction.h" #include "System/Misc/SpringTime.h" #include "System/ScopedFPUSettings.h" #include "System/Util.h" @@ -112,8 +111,10 @@ lua_pushnil(L); lua_setglobal(L, "require"); lua_pushnil(L); lua_setglobal(L, "gcinfo"); lua_pushnil(L); lua_setglobal(L, "collectgarbage"); + lua_pushnil(L); lua_setglobal(L, "newproxy"); // not sync-safe cause of __gc - // FIXME: replace "random" as in LuaHandleSynced (can write your own for now) + // FIXME: replace "random" _as in_ LuaHandleSynced (can write your own for now), we cannot use the LHS one cause gs-> is not valid in LuaParser + // using streflop's RNG is possible lua_getglobal(L, "math"); lua_pushliteral(L, "random"); lua_pushnil(L); lua_rawset(L, -3); lua_pushliteral(L, "randomseed"); lua_pushnil(L); lua_rawset(L, -3); @@ -195,12 +196,9 @@ currentParser = this; - { - // do not signal floating point exceptions in user Lua code - ScopedDisableFpuExceptions fe; - - error = lua_pcall(L, 0, 1, 0); - } + // do not signal floating point exceptions in user Lua code + ScopedDisableFpuExceptions fe; + error = lua_pcall(L, 0, 1, 0); currentParser = NULL; @@ -225,12 +223,11 @@ LuaUtils::LowerKeys(L, 1); } - rootRef = luaL_ref(L, LUA_REGISTRYINDEX); + LuaUtils::CheckTableForNaNs(L, 1, fileName); + rootRef = luaL_ref(L, LUA_REGISTRYINDEX); lua_settop(L, 0); - valid = true; - return true; } @@ -1113,7 +1110,7 @@ for (lua_pushnil(L); lua_next(L, table) != 0; lua_pop(L, 1)) { if (lua_israwnumber(L, -2) && lua_isnumber(L, -1)) { const int key = lua_toint(L, -2); - const float value = lua_tofloat(L, -1); + const float value = lua_tonumber(L, -1); data[key] = value; } } @@ -1153,7 +1150,7 @@ for (lua_pushnil(L); lua_next(L, table) != 0; lua_pop(L, 1)) { if (lua_israwstring(L, -2) && lua_isnumber(L, -1)) { const string key = lua_tostring(L, -2); - const float value = lua_tofloat(L, -1); + const float value = lua_tonumber(L, -1); data[key] = value; } } @@ -1169,7 +1166,7 @@ const int table = lua_gettop(L); for (lua_pushnil(L); lua_next(L, table) != 0; lua_pop(L, 1)) { if (lua_israwstring(L, -2)) { - if (lua_isstring(L, -1)) { + if (lua_isstring(L, -1)) { // includes numbers const string key = lua_tostring(L, -2); const string value = lua_tostring(L, -1); data[key] = value; @@ -1195,7 +1192,7 @@ { lua_pushnumber(L, index); lua_gettable(L, tableIndex); - value = lua_tofloat(L, -1); + value = lua_tonumber(L, -1); if (unlikely(value == 0) && !lua_isnumber(L, -1) && !lua_isstring(L, -1)) { lua_pop(L, 1); return false; @@ -1256,7 +1253,7 @@ return true; } else if (lua_isnumber(L, index)) { - value = (lua_tofloat(L, index) != 0.0f); + value = (lua_tonumber(L, index) != 0.0f); return true; } else if (lua_isstring(L, index)) { @@ -1315,7 +1312,7 @@ if (!PushValue(key)) { return def; } - const float value = lua_tofloat(L, -1); + const float value = lua_tonumber(L, -1); if (unlikely(value == 0.f) && !lua_isnumber(L, -1) && !lua_isstring(L, -1)) { lua_pop(L, 1); return def; @@ -1412,7 +1409,7 @@ if (!PushValue(key)) { return def; } - const float value = lua_tofloat(L, -1); + const float value = lua_tonumber(L, -1); if (unlikely(value == 0) && !lua_isnumber(L, -1) && !lua_isstring(L, -1)) { lua_pop(L, 1); return def; diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaRules.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaRules.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaRules.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaRules.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,40 +1,23 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#include -#include - - #include "LuaRules.h" #include "LuaInclude.h" -#include "LuaCallInCheck.h" #include "LuaUtils.h" -#include "LuaMaterial.h" -#include "LuaSyncedCtrl.h" -#include "LuaSyncedRead.h" #include "LuaUnitRendering.h" -#include "LuaUnitDefs.h" -#include "LuaWeaponDefs.h" -#include "LuaOpenGL.h" - -#include "Game/Game.h" -#include "Sim/Units/CommandAI/Command.h" -#include "Sim/Features/Feature.h" -#include "Sim/Features/FeatureDef.h" +#include "LuaCallInCheck.h" + #include "Sim/Misc/GlobalSynced.h" -#include "Sim/Projectiles/Projectile.h" -#include "Sim/Units/BuildInfo.h" #include "Sim/Units/Unit.h" #include "Sim/Units/UnitDef.h" #include "Sim/Units/Scripts/CobInstance.h" // for UNPACK{X,Z} -#include "Sim/Weapons/Weapon.h" -#include "Sim/Weapons/WeaponDef.h" #include "System/Log/ILog.h" #include "System/FileSystem/VFSModes.h" // for SPRING_VFS_* #include +#include +#include CLuaRules* luaRules = NULL; @@ -47,14 +30,17 @@ /******************************************************************************/ /******************************************************************************/ +static boost::mutex m_singleton; + + void CLuaRules::LoadHandler() { - //FIXME GML: this needs a mutex!!! - if (luaRules != NULL) { - return; - } + { + std::lock_guard lk(m_singleton); + if (luaRules) return; - luaRules = new CLuaRules(); + luaRules = new CLuaRules(); + } if (!luaRules->IsValid()) { FreeHandler(); @@ -64,8 +50,13 @@ void CLuaRules::FreeHandler() { - //FIXME GML: this needs a mutex!!! - delete luaRules; luaRules = NULL; + std::lock_guard lk(m_singleton); + if (!luaRules) return; + + auto* inst = luaRules; + luaRules = NULL; + inst->KillLua(); + delete inst; } @@ -79,75 +70,23 @@ return; } - SetFullCtrl(true, true); - SetFullRead(true, true); - SetCtrlTeam(AllAccessTeam, true); - SetReadTeam(AllAccessTeam, true); - SetReadAllyTeam(AllAccessTeam, true); - SetSelectTeam(AllAccessTeam, true); + SetFullCtrl(true); + SetFullRead(true); + SetCtrlTeam(CEventClient::AllAccessTeam); + SetReadTeam(CEventClient::AllAccessTeam); + SetReadAllyTeam(CEventClient::AllAccessTeam); + SetSelectTeam(CEventClient::AllAccessTeam); Init(LuaRulesSyncedFilename, LuaRulesUnsyncedFilename, SPRING_VFS_MOD); if (!IsValid()) { return; } - - BEGIN_ITERATE_LUA_STATES(); - - if (SingleState() || L == L_Sim) { - haveCommandFallback = HasCallIn(L, "CommandFallback"); - haveAllowCommand = HasCallIn(L, "AllowCommand"); - haveAllowUnitCreation = HasCallIn(L, "AllowUnitCreation"); - haveAllowUnitTransfer = HasCallIn(L, "AllowUnitTransfer"); - haveAllowUnitBuildStep = HasCallIn(L, "AllowUnitBuildStep"); - haveAllowFeatureCreation = HasCallIn(L, "AllowFeatureCreation"); - haveAllowFeatureBuildStep = HasCallIn(L, "AllowFeatureBuildStep"); - haveAllowResourceLevel = HasCallIn(L, "AllowResourceLevel"); - haveAllowResourceTransfer = HasCallIn(L, "AllowResourceTransfer"); - haveAllowDirectUnitControl = HasCallIn(L, "AllowDirectUnitControl"); - haveAllowStartPosition = HasCallIn(L, "AllowStartPosition"); - - haveMoveCtrlNotify = HasCallIn(L, "MoveCtrlNotify"); - haveTerraformComplete = HasCallIn(L, "TerraformComplete"); - haveAllowWeaponTargetCheck = HasCallIn(L, "AllowWeaponTargetCheck"); - haveAllowWeaponTarget = HasCallIn(L, "AllowWeaponTarget"); - haveAllowWeaponInterceptTarget = HasCallIn(L, "AllowWeaponInterceptTarget"); - haveUnitPreDamaged = HasCallIn(L, "UnitPreDamaged"); - haveFeaturePreDamaged = HasCallIn(L, "FeaturePreDamaged"); - haveShieldPreDamaged = HasCallIn(L, "ShieldPreDamaged"); - } - if (SingleState() || L == L_Draw) { - haveDrawUnit = HasCallIn(L, "DrawUnit" ); - haveDrawFeature = HasCallIn(L, "DrawFeature" ); - haveDrawShield = HasCallIn(L, "DrawShield" ); - haveDrawProjectile = HasCallIn(L, "DrawProjectile"); - - SetupUnsyncedFunction(L, "DrawUnit"); - SetupUnsyncedFunction(L, "DrawFeature"); - SetupUnsyncedFunction(L, "DrawShield"); - SetupUnsyncedFunction(L, "DrawProjectile"); - SetupUnsyncedFunction(L, "RecvSkirmishAIMessage"); - } - - END_ITERATE_LUA_STATES(); } CLuaRules::~CLuaRules() { - if (L_Sim != NULL || L_Draw != NULL) { - Shutdown(); - KillLua(); - } - - assert(this == luaRules); - assert(!IsValid()); - - // make sure to really get rid of the LuaRules environment if we were - // called from outside FreeHandler (see LuaHandle::KillActiveHandle()) - // note that ctor is only ever reached from LoadHandler - if (killMe) { - luaRules = NULL; - } + luaRules = NULL; } @@ -164,988 +103,19 @@ bool CLuaRules::AddUnsyncedCode(lua_State *L) { - lua_pushliteral(L, "UNSYNCED"); - lua_gettable(L, LUA_REGISTRYINDEX); - - lua_pushliteral(L, "Spring"); - lua_rawget(L, -2); + lua_getglobal(L, "Spring"); lua_pushliteral(L, "UnitRendering"); lua_newtable(L); LuaUnitRendering::PushEntries(L); lua_rawset(L, -3); lua_pop(L, 1); // Spring - lua_pop(L, 1); // UNSYNCED - return true; } /******************************************************************************/ /******************************************************************************/ -// -// LuaRules Call-Ins -// - -bool CLuaRules::SyncedUpdateCallIn(lua_State *L, const string& name) -{ - #define UPDATE_HAVE_CALLIN(callinName) \ - have ## callinName = HasCallIn( L, #callinName ); - - if (name == "CommandFallback" ) { UPDATE_HAVE_CALLIN(CommandFallback); } - else if (name == "AllowCommand" ) { UPDATE_HAVE_CALLIN(AllowCommand); } - else if (name == "AllowUnitCreation" ) { UPDATE_HAVE_CALLIN(AllowUnitCreation); } - else if (name == "AllowUnitTransfer" ) { UPDATE_HAVE_CALLIN(AllowUnitTransfer); } - else if (name == "AllowUnitBuildStep" ) { UPDATE_HAVE_CALLIN(AllowUnitBuildStep); } - else if (name == "AllowFeatureCreation" ) { UPDATE_HAVE_CALLIN(AllowFeatureCreation); } - else if (name == "AllowFeatureBuildStep" ) { UPDATE_HAVE_CALLIN(AllowFeatureBuildStep); } - else if (name == "AllowResourceLevel" ) { UPDATE_HAVE_CALLIN(AllowResourceLevel); } - else if (name == "AllowResourceTransfer" ) { UPDATE_HAVE_CALLIN(AllowResourceTransfer); } - else if (name == "AllowDirectUnitControl") { UPDATE_HAVE_CALLIN(AllowDirectUnitControl); } - else if (name == "AllowStartPosition" ) { UPDATE_HAVE_CALLIN(AllowStartPosition); } - else if (name == "MoveCtrlNotify" ) { UPDATE_HAVE_CALLIN(MoveCtrlNotify); } - else if (name == "TerraformComplete" ) { UPDATE_HAVE_CALLIN(TerraformComplete); } - else if (name == "UnitPreDamaged" ) { UPDATE_HAVE_CALLIN(UnitPreDamaged); } - else if (name == "FeaturePreDamaged" ) { UPDATE_HAVE_CALLIN(FeaturePreDamaged); } - else if (name == "ShieldPreDamaged" ) { UPDATE_HAVE_CALLIN(ShieldPreDamaged); } - else if (name == "AllowWeaponTargetCheck") { UPDATE_HAVE_CALLIN(AllowWeaponTargetCheck); } - else if (name == "AllowWeaponTarget" ) { UPDATE_HAVE_CALLIN(AllowWeaponTarget); } - else { - return CLuaHandleSynced::SyncedUpdateCallIn(L, name); - } - - #undef UPDATE_HAVE_CALLIN - return true; -} - - -bool CLuaRules::UnsyncedUpdateCallIn(lua_State *L, const string& name) -{ - if (name == "DrawUnit" ) { haveDrawUnit = HasCallIn(L, "DrawUnit" ); } - else if (name == "DrawFeature" ) { haveDrawFeature = HasCallIn(L, "DrawFeature" ); } - else if (name == "DrawShield" ) { haveDrawShield = HasCallIn(L, "DrawShield" ); } - else if (name == "DrawProjectile") { haveDrawProjectile = HasCallIn(L, "DrawProjectile"); } - - return CLuaHandleSynced::UnsyncedUpdateCallIn(L, name); -} - -/// pushes 7 items on the stack -static void PushUnitAndCommand(lua_State* L, const CUnit* unit, const Command& cmd) -{ - // push the unit info - lua_pushnumber(L, unit->id); - lua_pushnumber(L, unit->unitDef->id); - lua_pushnumber(L, unit->team); - - // push the command id - lua_pushnumber(L, cmd.GetID()); - - // push the params list - LuaUtils::PushCommandParamsTable(L, cmd, false); - // push the options table - LuaUtils::PushCommandOptionsTable(L, cmd, false); - - // push the command tag - lua_pushnumber(L, cmd.tag); -} - -bool CLuaRules::CommandFallback(const CUnit* unit, const Command& cmd) -{ - if (!haveCommandFallback) - return true; // the call is not defined - - LUA_CALL_IN_CHECK(L, true); - luaL_checkstack(L, 9, __FUNCTION__); - static const LuaHashString cmdStr(__FUNCTION__); - if (!cmdStr.GetGlobalFunc(L)) - return true; // the call is not defined - - PushUnitAndCommand(L, unit, cmd); - - // call the function - if (!RunCallIn(cmdStr, 7, 1)) - return true; - - // get the results - if (!lua_isboolean(L, -1)) { - LOG_L(L_WARNING, "%s() bad return value", cmdStr.GetString().c_str()); - lua_pop(L, 1); - return true; - } - - const bool retval = !!lua_toboolean(L, -1); - lua_pop(L, 1); - - // return 'true' to remove the command - return retval; -} - - -bool CLuaRules::AllowCommand(const CUnit* unit, const Command& cmd, bool fromSynced) -{ - if (!haveAllowCommand) - return true; // the call is not defined - - LUA_CALL_IN_CHECK(L, true); - luaL_checkstack(L, 10, __FUNCTION__); - static const LuaHashString cmdStr(__FUNCTION__); - if (!cmdStr.GetGlobalFunc(L)) - return true; // the call is not defined - - PushUnitAndCommand(L, unit, cmd); - - lua_pushboolean(L, fromSynced); - - // call the function - if (!RunCallIn(cmdStr, 8, 1)) - return true; - - // get the results - if (!lua_isboolean(L, -1)) { - LOG_L(L_WARNING, "%s() bad return value", cmdStr.GetString().c_str()); - lua_pop(L, 1); - return true; - } - const bool retval = !!lua_toboolean(L, -1); - lua_pop(L, 1); - return retval; -} - - -bool CLuaRules::AllowUnitCreation(const UnitDef* unitDef, - const CUnit* builder, const BuildInfo* buildInfo) -{ - if (!haveAllowUnitCreation) - return true; // the call is not defined - - LUA_CALL_IN_CHECK(L, true); - luaL_checkstack(L, 9, __FUNCTION__); - static const LuaHashString cmdStr(__FUNCTION__); - if (!cmdStr.GetGlobalFunc(L)) - return true; // the call is not defined - - lua_pushnumber(L, unitDef->id); - lua_pushnumber(L, builder->id); - lua_pushnumber(L, builder->team); - - if (buildInfo != NULL) { - lua_pushnumber(L, buildInfo->pos.x); - lua_pushnumber(L, buildInfo->pos.y); - lua_pushnumber(L, buildInfo->pos.z); - lua_pushnumber(L, buildInfo->buildFacing); - } - - // call the function - if (!RunCallIn(cmdStr, (buildInfo != NULL)? 7 : 3, 1)) - return true; - - // get the results - if (!lua_isboolean(L, -1)) { - LOG_L(L_WARNING, "%s() bad return value", cmdStr.GetString().c_str()); - lua_pop(L, 1); - return true; - } - const bool retval = !!lua_toboolean(L, -1); - lua_pop(L, 1); - return retval; -} - - - -bool CLuaRules::AllowUnitTransfer(const CUnit* unit, int newTeam, bool capture) -{ - if (!haveAllowUnitTransfer) - return true; // the call is not defined - - LUA_CALL_IN_CHECK(L, true); - luaL_checkstack(L, 7, __FUNCTION__); - static const LuaHashString cmdStr(__FUNCTION__); - if (!cmdStr.GetGlobalFunc(L)) - return true; // the call is not defined - - lua_pushnumber(L, unit->id); - lua_pushnumber(L, unit->unitDef->id); - lua_pushnumber(L, unit->team); - lua_pushnumber(L, newTeam); - lua_pushboolean(L, capture); - - // call the function - if (!RunCallIn(cmdStr, 5, 1)) - return true; - - // get the results - if (!lua_isboolean(L, -1)) { - LOG_L(L_WARNING, "%s() bad return value", cmdStr.GetString().c_str()); - lua_pop(L, 1); - return true; - } - - const bool retval = !!lua_toboolean(L, -1); - lua_pop(L, 1); - return retval; -} - - -bool CLuaRules::AllowUnitBuildStep(const CUnit* builder, - const CUnit* unit, float part) -{ - if (!haveAllowUnitBuildStep) - return true; // the call is not defined - - LUA_CALL_IN_CHECK(L, true); - luaL_checkstack(L, 7, __FUNCTION__); - static const LuaHashString cmdStr(__FUNCTION__); - if (!cmdStr.GetGlobalFunc(L)) - return true; // the call is not defined - - lua_pushnumber(L, builder->id); - lua_pushnumber(L, builder->team); - lua_pushnumber(L, unit->id); - lua_pushnumber(L, unit->unitDef->id); - lua_pushnumber(L, part); - - // call the function - if (!RunCallIn(cmdStr, 5, 1)) - return true; - - // get the results - if (!lua_isboolean(L, -1)) { - LOG_L(L_WARNING, "%s() bad return value", cmdStr.GetString().c_str()); - lua_pop(L, 1); - return true; - } - - const bool retval = !!lua_toboolean(L, -1); - lua_pop(L, 1); - return retval; -} - - -bool CLuaRules::AllowFeatureCreation(const FeatureDef* featureDef, - int teamID, const float3& pos) -{ - if (!haveAllowFeatureCreation) - return true; // the call is not defined - - LUA_CALL_IN_CHECK(L, true); - luaL_checkstack(L, 7, __FUNCTION__); - static const LuaHashString cmdStr(__FUNCTION__); - if (!cmdStr.GetGlobalFunc(L)) - return true; // the call is not defined - - lua_pushnumber(L, featureDef->id); - lua_pushnumber(L, teamID); - lua_pushnumber(L, pos.x); - lua_pushnumber(L, pos.y); - lua_pushnumber(L, pos.z); - - // call the function - if (!RunCallIn(cmdStr, 5, 1)) - return true; - - // get the results - if (!lua_isboolean(L, -1)) { - LOG_L(L_WARNING, "%s() bad return value", cmdStr.GetString().c_str()); - lua_pop(L, 1); - return true; - } - - const bool retval = !!lua_toboolean(L, -1); - lua_pop(L, 1); - return retval; -} - - -bool CLuaRules::AllowFeatureBuildStep(const CUnit* builder, - const CFeature* feature, float part) -{ - if (!haveAllowFeatureBuildStep) - return true; // the call is not defined - - LUA_CALL_IN_CHECK(L, true); - luaL_checkstack(L, 7, __FUNCTION__); - static const LuaHashString cmdStr(__FUNCTION__); - if (!cmdStr.GetGlobalFunc(L)) - return true; // the call is not defined - - lua_pushnumber(L, builder->id); - lua_pushnumber(L, builder->team); - lua_pushnumber(L, feature->id); - lua_pushnumber(L, feature->def->id); - lua_pushnumber(L, part); - - // call the function - if (!RunCallIn(cmdStr, 5, 1)) - return true; - - // get the results - if (!lua_isboolean(L, -1)) { - LOG_L(L_WARNING, "%s() bad return value", cmdStr.GetString().c_str()); - lua_pop(L, 1); - return true; - } - - const bool retval = !!lua_toboolean(L, -1); - lua_pop(L, 1); - return retval; -} - - -bool CLuaRules::AllowResourceLevel(int teamID, const string& type, float level) -{ - if (!haveAllowResourceLevel) - return true; // the call is not defined - - LUA_CALL_IN_CHECK(L, true); - luaL_checkstack(L, 5, __FUNCTION__); - static const LuaHashString cmdStr(__FUNCTION__); - if (!cmdStr.GetGlobalFunc(L)) - return true; // the call is not defined - - lua_pushnumber(L, teamID); - lua_pushsstring(L, type); - lua_pushnumber(L, level); - - // call the function - if (!RunCallIn(cmdStr, 3, 1)) - return true; - - // get the results - if (!lua_isboolean(L, -1)) { - LOG_L(L_WARNING, "%s() bad return value", cmdStr.GetString().c_str()); - lua_pop(L, 1); - return true; - } - - const bool retval = !!lua_toboolean(L, -1); - lua_pop(L, 1); - return retval; -} - - -bool CLuaRules::AllowResourceTransfer(int oldTeam, int newTeam, - const string& type, float amount) -{ - if (!haveAllowResourceTransfer) - return true; // the call is not defined - - LUA_CALL_IN_CHECK(L, true); - luaL_checkstack(L, 6, __FUNCTION__); - static const LuaHashString cmdStr(__FUNCTION__); - if (!cmdStr.GetGlobalFunc(L)) - return true; // the call is not defined - - lua_pushnumber(L, oldTeam); - lua_pushnumber(L, newTeam); - lua_pushsstring(L, type); - lua_pushnumber(L, amount); - - // call the function - if (!RunCallIn(cmdStr, 4, 1)) - return true; - - // get the results - if (!lua_isboolean(L, -1)) { - LOG_L(L_WARNING, "%s() bad return value", cmdStr.GetString().c_str()); - lua_pop(L, 1); - return true; - } - - const bool retval = !!lua_toboolean(L, -1); - lua_pop(L, 1); - return retval; -} - - -bool CLuaRules::AllowDirectUnitControl(int playerID, const CUnit* unit) -{ - if (!haveAllowDirectUnitControl) - return true; // the call is not defined - - LUA_CALL_IN_CHECK(L, true); - luaL_checkstack(L, 6, __FUNCTION__); - static const LuaHashString cmdStr(__FUNCTION__); - if (!cmdStr.GetGlobalFunc(L)) - return true; // the call is not defined - - lua_pushnumber(L, unit->id); - lua_pushnumber(L, unit->unitDef->id); - lua_pushnumber(L, unit->team); - lua_pushnumber(L, playerID); - - // call the function - if (!RunCallIn(cmdStr, 4, 1)) - return true; - - // get the results - if (!lua_isboolean(L, -1)) { - LOG_L(L_WARNING, "%s() bad return value", cmdStr.GetString().c_str()); - lua_pop(L, 1); - return true; - } - - const bool retval = !!lua_toboolean(L, -1); - lua_pop(L, 1); - return retval; -} - - -bool CLuaRules::AllowStartPosition(int playerID, unsigned char readyState, const float3& clampedPos, const float3& rawPickPos) -{ - if (!haveAllowStartPosition) - return true; // the call is not defined - - LUA_CALL_IN_CHECK(L, true); - luaL_checkstack(L, 13, __FUNCTION__); - - static const LuaHashString cmdStr(__FUNCTION__); - - if (!cmdStr.GetGlobalFunc(L)) - return true; // the call is not defined - - // push the start position and playerID - lua_pushnumber(L, clampedPos.x); - lua_pushnumber(L, clampedPos.y); - lua_pushnumber(L, clampedPos.z); - lua_pushnumber(L, playerID); - lua_pushnumber(L, readyState); - lua_pushnumber(L, rawPickPos.x); - lua_pushnumber(L, rawPickPos.y); - lua_pushnumber(L, rawPickPos.z); - - // call the function - if (!RunCallIn(cmdStr, 8, 1)) - return true; - - // get the results - if (!lua_isboolean(L, -1)) { - LOG_L(L_WARNING, "%s() bad return value", cmdStr.GetString().c_str()); - lua_pop(L, 1); - return true; - } - const bool retval = !!lua_toboolean(L, -1); - lua_pop(L, 1); - return retval; -} - - -bool CLuaRules::MoveCtrlNotify(const CUnit* unit, int data) -{ - if (!haveMoveCtrlNotify) - return false; // the call is not defined - - LUA_CALL_IN_CHECK(L, false); - luaL_checkstack(L, 6, __FUNCTION__); - static const LuaHashString cmdStr(__FUNCTION__); - if (!cmdStr.GetGlobalFunc(L)) - return false; // the call is not defined - - // push the unit info - lua_pushnumber(L, unit->id); - lua_pushnumber(L, unit->unitDef->id); - lua_pushnumber(L, unit->team); - lua_pushnumber(L, data); - - // call the function - if (!RunCallIn(cmdStr, 4, 1)) - return false; - - // get the results - if (!lua_isboolean(L, -1)) { - LOG_L(L_WARNING, "%s() bad return value", cmdStr.GetString().c_str()); - lua_pop(L, 1); - return false; - } - - const bool retval = !!lua_toboolean(L, -1); - lua_pop(L, 1); - - return retval; -} - - -bool CLuaRules::TerraformComplete(const CUnit* unit, const CUnit* build) -{ - if (!haveTerraformComplete) - return false; // the call is not defined - - LUA_CALL_IN_CHECK(L, false); - luaL_checkstack(L, 8, __FUNCTION__); - static const LuaHashString cmdStr(__FUNCTION__); - if (!cmdStr.GetGlobalFunc(L)) - return false; // the call is not defined - - // push the unit info - lua_pushnumber(L, unit->id); - lua_pushnumber(L, unit->unitDef->id); - lua_pushnumber(L, unit->team); - - // push the construction info - lua_pushnumber(L, build->id); - lua_pushnumber(L, build->unitDef->id); - lua_pushnumber(L, build->team); - - // call the function - if (!RunCallIn(cmdStr, 6, 1)) - return false; - - // get the results - if (!lua_isboolean(L, -1)) { - LOG_L(L_WARNING, "%s() bad return value", cmdStr.GetString().c_str()); - lua_pop(L, 1); - return false; - } - - const bool retval = !!lua_toboolean(L, -1); - lua_pop(L, 1); - - // return 'true' to remove the command - return retval; -} - - -/** - * called after every damage modification (even HitByWeaponId) - * but before the damage is applied - * - * expects two numbers returned by lua code: - * 1st is stored under *newDamage if newDamage != NULL - * 2nd is stored under *impulseMult if impulseMult != NULL - */ -bool CLuaRules::UnitPreDamaged( - const CUnit* unit, - const CUnit* attacker, - float damage, - int weaponDefID, - int projectileID, - bool paralyzer, - float* newDamage, - float* impulseMult) -{ - if (!haveUnitPreDamaged) - return false; - - LUA_CALL_IN_CHECK(L, false); - luaL_checkstack(L, 2 + 2 + 10, __FUNCTION__); - - static const LuaHashString cmdStr(__FUNCTION__); - const LuaUtils::ScopedDebugTraceBack traceBack(L); - - if (!cmdStr.GetGlobalFunc(L)) - return false; - - int inArgCount = 5; - int outArgCount = 2; - - lua_pushnumber(L, unit->id); - lua_pushnumber(L, unit->unitDef->id); - lua_pushnumber(L, unit->team); - lua_pushnumber(L, damage); - lua_pushboolean(L, paralyzer); - //FIXME pass impulse too? - - if (GetHandleFullRead(L)) { - lua_pushnumber(L, weaponDefID); inArgCount += 1; - lua_pushnumber(L, projectileID); inArgCount += 1; - - if (attacker != NULL) { - lua_pushnumber(L, attacker->id); - lua_pushnumber(L, attacker->unitDef->id); - lua_pushnumber(L, attacker->team); - inArgCount += 3; - } - } - - // call the routine - // NOTE: - // RunCallInTraceback removes the error-handler by default - // this has to be disabled when using ScopedDebugTraceBack - // or it would mess up the stack - if (!RunCallInTraceback(cmdStr, inArgCount, outArgCount, traceBack.GetErrFuncIdx(), false)) - return false; - - if (newDamage && lua_isnumber(L, -2)) { - *newDamage = lua_tonumber(L, -2); - } else if (!lua_isnumber(L, -2) || lua_isnil(L, -2)) { - // first value is obligatory, so may not be nil - LOG_L(L_WARNING, "%s(): 1st return-value should be a number (newDamage)", (cmdStr.GetString()).c_str()); - } - - if (impulseMult && lua_isnumber(L, -1)) { - *impulseMult = lua_tonumber(L, -1); - } else if (!lua_isnumber(L, -1) && !lua_isnil(L, -1)) { - // second value is optional, so nils are OK - LOG_L(L_WARNING, "%s(): 2nd return-value should be a number (impulseMult)", (cmdStr.GetString()).c_str()); - } - - lua_pop(L, outArgCount); - return true; -} - -bool CLuaRules::FeaturePreDamaged( - const CFeature* feature, - const CUnit* attacker, - float damage, - int weaponDefID, - int projectileID, - float* newDamage, - float* impulseMult) -{ - if (!haveFeaturePreDamaged) - return false; - - LUA_CALL_IN_CHECK(L, false); - luaL_checkstack(L, 2 + 9 + 2, __FUNCTION__); - - static const LuaHashString cmdStr(__FUNCTION__); - const LuaUtils::ScopedDebugTraceBack traceBack(L); - - if (!cmdStr.GetGlobalFunc(L)) - return false; - - int inArgCount = 4; - int outArgCount = 2; - - lua_pushnumber(L, feature->id); - lua_pushnumber(L, feature->def->id); - lua_pushnumber(L, feature->team); - lua_pushnumber(L, damage); - - if (GetHandleFullRead(L)) { - lua_pushnumber(L, weaponDefID); inArgCount += 1; - lua_pushnumber(L, projectileID); inArgCount += 1; - - if (attacker != NULL) { - lua_pushnumber(L, attacker->id); - lua_pushnumber(L, attacker->unitDef->id); - lua_pushnumber(L, attacker->team); - inArgCount += 3; - } - } - - // call the routine - if (!RunCallInTraceback(cmdStr, inArgCount, outArgCount, traceBack.GetErrFuncIdx(), false)) - return false; - - if (newDamage && lua_isnumber(L, -2)) { - *newDamage = lua_tonumber(L, -2); - } else if (!lua_isnumber(L, -2) || lua_isnil(L, -2)) { - // first value is obligatory, so may not be nil - LOG_L(L_WARNING, "%s(): 1st value returned should be a number (newDamage)", (cmdStr.GetString()).c_str()); - } - - if (impulseMult && lua_isnumber(L, -1)) { - *impulseMult = lua_tonumber(L, -1); - } else if (!lua_isnumber(L, -1) && !lua_isnil(L, -1)) { - // second value is optional, so nils are OK - LOG_L(L_WARNING, "%s(): 2nd value returned should be a number (impulseMult)", (cmdStr.GetString()).c_str()); - } - - lua_pop(L, outArgCount); - return true; -} - -bool CLuaRules::ShieldPreDamaged( - const CProjectile* projectile, - const CWeapon* shieldEmitter, - const CUnit* shieldCarrier, - bool bounceProjectile -) { - if (!haveShieldPreDamaged) - return false; - - LUA_CALL_IN_CHECK(L, false); - luaL_checkstack(L, 2 + 5 + 1, __FUNCTION__); - - static const LuaHashString cmdStr(__FUNCTION__); - const LuaUtils::ScopedDebugTraceBack traceBack(L); - - if (!cmdStr.GetGlobalFunc(L)) - return false; - - // push the call-in arguments - lua_pushnumber(L, projectile->id); - lua_pushnumber(L, projectile->GetOwnerID()); - lua_pushnumber(L, shieldEmitter->weaponNum); - lua_pushnumber(L, shieldCarrier->id); - lua_pushboolean(L, bounceProjectile); - - // call the routine - if (!RunCallInTraceback(cmdStr, 5, 1, traceBack.GetErrFuncIdx(), false)) - return false; - - // pop the return-value; must be true or false - const bool ret = (lua_isboolean(L, -1) && lua_toboolean(L, -1)); - lua_pop(L, 1); - return ret; -} - - - -/******************************************************************************/ - -int CLuaRules::AllowWeaponTargetCheck(unsigned int attackerID, unsigned int attackerWeaponNum, unsigned int attackerWeaponDefID) -{ - if (!haveAllowWeaponTargetCheck) - return -1; - if (!watchWeaponDefs[attackerWeaponDefID]) - return -1; - - LUA_CALL_IN_CHECK(L, -1); - luaL_checkstack(L, 2 + 3 + 1, __FUNCTION__); - - static const LuaHashString cmdStr(__FUNCTION__); - const LuaUtils::ScopedDebugTraceBack traceBack(L); - - int ret = -1; - - if (cmdStr.GetGlobalFunc(L)) { - lua_pushnumber(L, attackerID); - lua_pushnumber(L, attackerWeaponNum); - lua_pushnumber(L, attackerWeaponDefID); - - if (!RunCallInTraceback(cmdStr, 3, 1, traceBack.GetErrFuncIdx(), false)) - return ret; - - ret = int(lua_isboolean(L, -1) && lua_toboolean(L, -1)); - lua_pop(L, 1); - } - - return ret; -} - -bool CLuaRules::AllowWeaponTarget( - unsigned int attackerID, - unsigned int targetID, - unsigned int attackerWeaponNum, - unsigned int attackerWeaponDefID, - float* targetPriority) -{ - assert(targetPriority != NULL); - - bool ret = true; - - if (!haveAllowWeaponTarget) - return ret; - if (!watchWeaponDefs[attackerWeaponDefID]) - return ret; - - LUA_CALL_IN_CHECK(L, true); - luaL_checkstack(L, 2 + 5 + 2, __FUNCTION__); - - static const LuaHashString cmdStr(__FUNCTION__); - const LuaUtils::ScopedDebugTraceBack traceBack(L); - - if (cmdStr.GetGlobalFunc(L)) { - lua_pushnumber(L, attackerID); - lua_pushnumber(L, targetID); - lua_pushnumber(L, attackerWeaponNum); - lua_pushnumber(L, attackerWeaponDefID); - lua_pushnumber(L, *targetPriority); - - if (!RunCallInTraceback(cmdStr, 5, 2, traceBack.GetErrFuncIdx(), false)) - return ret; - - ret = (lua_isboolean(L, -2) && lua_toboolean(L, -2)); - - if (lua_isnumber(L, -1)) { - *targetPriority = lua_tonumber(L, -1); - } - - lua_pop(L, 2); - } - - return ret; -} - -bool CLuaRules::AllowWeaponInterceptTarget( - const CUnit* interceptorUnit, - const CWeapon* interceptorWeapon, - const CProjectile* interceptorTarget -) { - bool ret = true; - - if (!haveAllowWeaponInterceptTarget) - return ret; - if (!watchWeaponDefs[interceptorWeapon->weaponDef->id]) - return ret; - - LUA_CALL_IN_CHECK(L, true); - luaL_checkstack(L, 2 + 3 + 1, __FUNCTION__); - - static const LuaHashString cmdStr(__FUNCTION__); - const LuaUtils::ScopedDebugTraceBack traceBack(L); - - if (cmdStr.GetGlobalFunc(L)) { - lua_pushnumber(L, interceptorUnit->id); - lua_pushnumber(L, interceptorWeapon->weaponNum); - lua_pushnumber(L, interceptorTarget->id); - - if (!RunCallInTraceback(cmdStr, 3, 1, traceBack.GetErrFuncIdx(), false)) - return ret; - - ret = (lua_isboolean(L, -1) && lua_toboolean(L, -1)); - lua_pop(L, 1); - } - - return ret; -} - -/******************************************************************************/ - - - -bool CLuaRules::DrawUnit(const CUnit* unit) -{ - if (!haveDrawUnit) - return false; - - LUA_CALL_IN_CHECK(L, false); - luaL_checkstack(L, 4, __FUNCTION__); - - static const LuaHashString cmdStr(__FUNCTION__); - - if (!cmdStr.GetRegistryFunc(L)) - return false; - - const bool oldDrawState = LuaOpenGL::IsDrawingEnabled(L); - LuaOpenGL::SetDrawingEnabled(L, true); - - lua_pushnumber(L, unit->id); - lua_pushnumber(L, game->GetDrawMode()); - - const bool success = RunCallIn(cmdStr, 2, 1); - LuaOpenGL::SetDrawingEnabled(L, oldDrawState); - - if (!success) - return false; - if (!lua_isboolean(L, -1)) { - LOG_L(L_WARNING, "%s() bad return-type (bool expected, got %s)", __FUNCTION__, lua_typename(L, lua_type(L, -1))); - lua_pop(L, 1); - return false; - } - - const bool retval = !!lua_toboolean(L, -1); - - lua_pop(L, 1); - return retval; -} - -bool CLuaRules::DrawFeature(const CFeature* feature) -{ - if (!haveDrawFeature) - return false; - - LUA_CALL_IN_CHECK(L, false); - luaL_checkstack(L, 4, __FUNCTION__); - - static const LuaHashString cmdStr(__FUNCTION__); - - if (!cmdStr.GetRegistryFunc(L)) - return false; - - const bool oldDrawState = LuaOpenGL::IsDrawingEnabled(L); - LuaOpenGL::SetDrawingEnabled(L, true); - - lua_pushnumber(L, feature->id); - lua_pushnumber(L, game->GetDrawMode()); - - const bool success = RunCallIn(cmdStr, 2, 1); - LuaOpenGL::SetDrawingEnabled(L, oldDrawState); - - if (!success) - return false; - if (!lua_isboolean(L, -1)) { - LOG_L(L_WARNING, "%s() bad return-type (bool expected, got %s)", __FUNCTION__, lua_typename(L, lua_type(L, -1))); - lua_pop(L, 1); - return false; - } - - const bool retval = !!lua_toboolean(L, -1); - - lua_pop(L, 1); - return retval; -} - -bool CLuaRules::DrawShield(const CUnit* unit, const CWeapon* weapon) -{ - if (!haveDrawShield) - return false; - - LUA_CALL_IN_CHECK(L, false); - luaL_checkstack(L, 5, __FUNCTION__); - - static const LuaHashString cmdStr(__FUNCTION__); - - if (!cmdStr.GetRegistryFunc(L)) - return false; - - const bool oldDrawState = LuaOpenGL::IsDrawingEnabled(L); - LuaOpenGL::SetDrawingEnabled(L, true); - - lua_pushnumber(L, unit->id); - lua_pushnumber(L, weapon->weaponNum); - lua_pushnumber(L, game->GetDrawMode()); - - const bool success = RunCallIn(cmdStr, 3, 1); - LuaOpenGL::SetDrawingEnabled(L, oldDrawState); - - if (!success) - return false; - if (!lua_isboolean(L, -1)) { - LOG_L(L_WARNING, "%s() bad return-type (bool expected, got %s)", __FUNCTION__, lua_typename(L, lua_type(L, -1))); - lua_pop(L, 1); - return false; - } - - const bool retval = !!lua_toboolean(L, -1); - - lua_pop(L, 1); - return retval; -} - -bool CLuaRules::DrawProjectile(const CProjectile* projectile) -{ - if (!haveDrawProjectile) - return false; - if (!(projectile->weapon || projectile->piece)) - return false; - - LUA_CALL_IN_CHECK(L, false); - luaL_checkstack(L, 5, __FUNCTION__); - - static const LuaHashString cmdStr(__FUNCTION__); - - if (!cmdStr.GetRegistryFunc(L)) - return false; - - const bool oldDrawState = LuaOpenGL::IsDrawingEnabled(L); - LuaOpenGL::SetDrawingEnabled(L, true); - - lua_pushnumber(L, projectile->id); - lua_pushnumber(L, game->GetDrawMode()); - - const bool success = RunCallIn(cmdStr, 2, 1); - LuaOpenGL::SetDrawingEnabled(L, oldDrawState); - - if (!success) - return false; - if (!lua_isboolean(L, -1)) { - LOG_L(L_WARNING, "%s() bad return-type (bool expected, got %s)", __FUNCTION__, lua_typename(L, lua_type(L, -1))); - lua_pop(L, 1); - return false; - } - - const bool retval = !!lua_toboolean(L, -1); - - lua_pop(L, 1); - return retval; -} - - - -/******************************************************************************/ -/******************************************************************************/ int CLuaRules::UnpackCobArg(lua_State* L) { @@ -1174,6 +144,8 @@ return; } + auto L = syncedLuaHandle.L; + LUA_CALL_IN_CHECK(L); const int top = lua_gettop(L); @@ -1206,7 +178,7 @@ const int* oldArgs = currentCobArgs; currentCobArgs = args; - const bool error = !RunCallIn(name, 3 + argsCount, LUA_MULTRET); + const bool error = !syncedLuaHandle.RunCallIn(L, name, 3 + argsCount, LUA_MULTRET); currentCobArgs = oldArgs; callDepth--; diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaRules.h spring-98.0~14.04~ppa6/rts/Lua/LuaRules.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaRules.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaRules.h 2014-10-07 20:09:51.000000000 +0000 @@ -33,80 +33,16 @@ static void FreeHandler(); public: // call-ins - bool SyncedUpdateCallIn(lua_State *L, const string& name); - bool UnsyncedUpdateCallIn(lua_State *L, const string& name); - - bool CommandFallback(const CUnit* unit, const Command& cmd); - bool AllowCommand(const CUnit* unit, const Command& cmd, bool fromSynced); - bool AllowUnitCreation(const UnitDef* unitDef, - const CUnit* builder, const BuildInfo* buildInfo); - bool AllowUnitTransfer(const CUnit* unit, int newTeam, bool capture); - bool AllowUnitBuildStep(const CUnit* builder, const CUnit* unit, float part); - bool AllowFeatureCreation(const FeatureDef* featureDef, int allyTeamID, - const float3& pos); - bool AllowFeatureBuildStep(const CUnit* builder, const CFeature* feature, - float part); - bool AllowResourceLevel(int teamID, const string& type, float level); - bool AllowResourceTransfer(int oldTeam, int newTeam, - const string& type, float amount); - bool AllowDirectUnitControl(int playerID, const CUnit* unit); - bool AllowStartPosition(int playerID, unsigned char readyState, const float3& clampedPos, const float3& rawPickPos); - - bool TerraformComplete(const CUnit* unit, const CUnit* build); - - bool MoveCtrlNotify(const CUnit* unit, int data); - void Cob2Lua(const LuaHashString& funcName, const CUnit* unit, int& argsCount, int args[MAX_LUA_COB_ARGS]); - int AllowWeaponTargetCheck( - unsigned int attackerID, - unsigned int attackerWeaponNum, - unsigned int attackerWeaponDefID - ); - bool AllowWeaponTarget( - unsigned int attackerID, - unsigned int targetID, - unsigned int attackerWeaponNum, - unsigned int attackerWeaponDefID, - float* targetPriority - ); - bool AllowWeaponInterceptTarget( - const CUnit* interceptorUnit, - const CWeapon* interceptorWeapon, - const CProjectile* interceptorTarget - ); - - bool UnitPreDamaged( - const CUnit* unit, - const CUnit* attacker, - float damage, - int weaponDefID, - int projectileID, - bool paralyzer, - float* newDamage, - float* impulseMult); - - bool FeaturePreDamaged( - const CFeature* feature, - const CUnit* attacker, - float damage, - int weaponDefID, - int projectileID, - float* newDamage, - float* impulseMult); - - bool ShieldPreDamaged(const CProjectile*, const CWeapon*, const CUnit*, bool); - - // unsynced - bool DrawUnit(const CUnit* unit); - bool DrawFeature(const CFeature* feature); - bool DrawShield(const CUnit* unit, const CWeapon* weapon); - bool DrawProjectile(const CProjectile* projectile); + const char* RecvSkirmishAIMessage(int aiID, const char* data, int inSize) { + return syncedLuaHandle.RecvSkirmishAIMessage(aiID, data, inSize); + } private: CLuaRules(); - ~CLuaRules(); + virtual ~CLuaRules(); protected: bool AddSyncedCode(lua_State *L); @@ -118,32 +54,6 @@ static int PermitHelperAIs(lua_State* L); private: - bool haveCommandFallback; - bool haveAllowCommand; - bool haveAllowUnitCreation; - bool haveAllowUnitTransfer; - bool haveAllowUnitBuildStep; - bool haveAllowFeatureCreation; - bool haveAllowFeatureBuildStep; - bool haveAllowResourceLevel; - bool haveAllowResourceTransfer; - bool haveAllowDirectUnitControl; - bool haveAllowStartPosition; - bool haveMoveCtrlNotify; - bool haveTerraformComplete; - bool haveUnitPreDamaged; - bool haveFeaturePreDamaged; - bool haveShieldPreDamaged; - bool haveAllowWeaponTargetCheck; - bool haveAllowWeaponTarget; - bool haveAllowWeaponInterceptTarget; - - bool haveDrawUnit; - bool haveDrawFeature; - bool haveDrawShield; - bool haveDrawProjectile; - - private: static const int* currentCobArgs; }; diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaRulesParams.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaRulesParams.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaRulesParams.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaRulesParams.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -4,9 +4,9 @@ using namespace LuaRulesParams; -CR_BIND(Param,); +CR_BIND(Param,) CR_REG_METADATA(Param, ( CR_MEMBER(los), CR_MEMBER(valueInt), CR_MEMBER(valueString) -)); +)) diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaRulesParams.h spring-98.0~14.04~ppa6/rts/Lua/LuaRulesParams.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaRulesParams.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaRulesParams.h 2014-10-07 20:09:51.000000000 +0000 @@ -26,7 +26,7 @@ }; struct Param { - CR_DECLARE_STRUCT(Param); + CR_DECLARE_STRUCT(Param) Param() : los(RULESPARAMLOS_PRIVATE),valueInt(0.0f) {}; diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaShaders.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaShaders.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaShaders.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaShaders.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -9,6 +9,7 @@ #include "LuaHandle.h" #include "LuaOpenGL.h" #include "LuaOpenGLUtils.h" +#include "LuaUtils.h" #include "Game/Camera.h" #include "Rendering/ShadowHandler.h" diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaSyncedCall.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaSyncedCall.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaSyncedCall.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaSyncedCall.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - - -#include "LuaSyncedCall.h" - -#include "LuaInclude.h" - -#include "LuaHandle.h" -#include "LuaGaia.h" -#include "LuaRules.h" -#include "LuaHashString.h" -#include "LuaUI.h" -#include "LuaUtils.h" - -#include -#include -#include - - -/******************************************************************************/ -/******************************************************************************/ - -static int HandleXCall(lua_State* L) -{ - const int addrIndex = lua_upvalueindex(1); - const int nameIndex = lua_upvalueindex(2); - - if (!lua_isuserdata(L, addrIndex) || !lua_israwstring(L, nameIndex)) { - luaL_error(L, "Bad function name type"); - } - - CLuaHandle** addr = (CLuaHandle**) lua_touserdata(L, addrIndex); - if (*addr == NULL) { - return 0; // handle is not currently active - } - CLuaHandle* lh = *addr; - - const char* funcName = lua_tostring(L, nameIndex); - - return lh->SyncedXCall(L, funcName); -} - - -static int IndexHook(lua_State* L) -{ - CLuaHandle** addr = (CLuaHandle**) lua_touserdata(L, lua_upvalueindex(1)); - if (!lua_israwstring(L, 2)) { - return 0; // missing string name for function - } - lua_pushlightuserdata(L, addr); - lua_pushstring(L, lua_tostring(L, 2)); - lua_pushcclosure(L, HandleXCall, 2); - return 1; -} - - -static int CallHook(lua_State* L) -{ - CLuaHandle** addr = (CLuaHandle**) lua_touserdata(L, lua_upvalueindex(1)); - const int args = lua_gettop(L); // arg 1 is the table - if (args <= 1) { - // is the handle currently active? - lua_pushboolean(L, (*addr != NULL)); - return 1; - } - else if ((args >= 2) && lua_israwstring(L, 2)) { - // see if the specified function exists - const string funcName = lua_tostring(L, 2); - CLuaHandle* lh = *addr; - if (lh == NULL) { - return 0; // not running - } - lua_pushboolean(L, lh->HasSyncedXCall(funcName)); - return 1; - } - return 0; -} - - -static int PushCallHandler(lua_State* L, CLuaHandle** addr, const string& name) -{ - lua_pushsstring(L, name); - CLuaHandle*** ptr = (CLuaHandle***) lua_newuserdata(L, sizeof(CLuaHandle**)); - *ptr = addr; - lua_newtable(L); { - lua_pushliteral(L, "__index"); - lua_pushlightuserdata(L, addr); - lua_pushcclosure(L, IndexHook, 1); - lua_rawset(L, -3); - lua_pushliteral(L, "__call"); - lua_pushlightuserdata(L, addr); - lua_pushcclosure(L, CallHook, 1); - lua_rawset(L, -3); - lua_pushliteral(L, "__metatable"); - lua_pushliteral(L, "can't touch this"); - lua_rawset(L, -3); - } - lua_setmetatable(L, -2); // set the userdata's metatable - lua_rawset(L, -3); - return 0; -} - - -bool LuaSyncedCall::PushEntries(lua_State* L) -{ - PushCallHandler(L, (CLuaHandle**) &luaGaia, "LuaGaia"); - PushCallHandler(L, (CLuaHandle**) &luaRules, "LuaRules"); - return true; -} - - -/******************************************************************************/ -/******************************************************************************/ diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaSyncedCall.h spring-98.0~14.04~ppa6/rts/Lua/LuaSyncedCall.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaSyncedCall.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaSyncedCall.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#ifndef LUA_SYNCED_CALL_H -#define LUA_SYNCED_CALL_H - -struct lua_State; - - -class LuaSyncedCall { - public: - static bool PushEntries(lua_State* L); -}; - - -#endif /* LUA_SYNCED_CALL_H */ diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaSyncedCtrl.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaSyncedCtrl.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaSyncedCtrl.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaSyncedCtrl.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -9,6 +9,7 @@ #include "LuaInclude.h" +#include "LuaConfig.h" #include "LuaRules.h" // for MAX_LUA_COB_ARGS #include "LuaHandleSynced.h" #include "LuaHashString.h" @@ -20,11 +21,13 @@ #include "Game/GameHelper.h" #include "Game/SelectedUnitsHandler.h" #include "Game/Players/PlayerHandler.h" +#include "Game/Players/Player.h" #include "Net/GameServer.h" #include "Map/Ground.h" #include "Map/MapDamage.h" #include "Map/MapInfo.h" #include "Map/ReadMap.h" +#include "Rendering/Env/GrassDrawer.h" #include "Rendering/Env/IGroundDecalDrawer.h" #include "Rendering/Env/ITreeDrawer.h" #include "Rendering/Models/IModelParser.h" @@ -33,6 +36,7 @@ #include "Sim/Misc/CollisionVolume.h" #include "Sim/Misc/DamageArray.h" #include "Sim/Misc/LosHandler.h" +#include "Sim/Misc/ModInfo.h" #include "Sim/Misc/SmoothHeightMesh.h" #include "Sim/Misc/Team.h" #include "Sim/Misc/TeamHandler.h" @@ -62,11 +66,11 @@ #include "Sim/Weapons/PlasmaRepulser.h" #include "Sim/Weapons/Weapon.h" #include "Sim/Weapons/WeaponDefHandler.h" +#include "System/EventHandler.h" #include "System/myMath.h" #include "System/ObjectDependenceTypes.h" #include "System/Log/ILog.h" #include "System/Sync/HsiehHash.h" -#include "LuaHelper.h" using std::max; using std::min; @@ -97,12 +101,7 @@ inline void LuaSyncedCtrl::CheckAllowGameChanges(lua_State* L) { - const CLuaHandleSynced* lhs = CLuaHandleSynced::GetSyncedHandle(L); - - if (lhs == NULL) { - luaL_error(L, "Internal lua error, unsynced script using synced calls"); - } - if (!lhs->GetAllowChanges()) { + if (!CLuaHandle::GetHandleAllowChanges(L)) { luaL_error(L, "Unsafe attempt to change game state"); } } @@ -118,7 +117,9 @@ lua_pushcfunction(L, x); \ lua_rawset(L, -3) + REGISTER_LUA_CFUNC(SetAlly); REGISTER_LUA_CFUNC(KillTeam); + REGISTER_LUA_CFUNC(AssignPlayerToTeam); REGISTER_LUA_CFUNC(GameOver); REGISTER_LUA_CFUNC(AddTeamResource); @@ -155,6 +156,7 @@ REGISTER_LUA_CFUNC(SetUnitSonarStealth); REGISTER_LUA_CFUNC(SetUnitAlwaysVisible); REGISTER_LUA_CFUNC(SetUnitMetalExtraction); + REGISTER_LUA_CFUNC(SetUnitHarvestStorage); REGISTER_LUA_CFUNC(SetUnitBuildSpeed); REGISTER_LUA_CFUNC(SetUnitNanoPieces); REGISTER_LUA_CFUNC(SetUnitBlocking); @@ -498,11 +500,7 @@ if (o == NULL) return 0; - float3 dir(luaL_checkfloat(L, 2), - luaL_checkfloat(L, 3), - luaL_checkfloat(L, 4)); - - o->ForcedSpin(dir.Normalize()); + o->ForcedSpin((float3(luaL_checkfloat(L, 2), luaL_checkfloat(L, 3), luaL_checkfloat(L, 4))).SafeNormalize()); return 0; } @@ -555,6 +553,7 @@ o->SetDirVectors(matrix); o->UpdateMidAndAimPos(); o->SetHeadingFromDirection(); + // do not need ForcedSpin, above three calls cover it o->ForcedMove(pos); o->SetVelocityAndSpeed(speed); return 0; @@ -574,26 +573,55 @@ // The call-outs // +int LuaSyncedCtrl::SetAlly(lua_State* L) +{ + const int firstAllyTeamID = luaL_checkint(L, 1); + const int secondAllyTeamID = luaL_checkint(L, 2); + + if (!teamHandler->IsValidAllyTeam(firstAllyTeamID)) + return 0; + if (!teamHandler->IsValidAllyTeam(secondAllyTeamID)) + return 0; + + teamHandler->SetAlly(firstAllyTeamID, secondAllyTeamID, luaL_checkboolean(L, 3)); + return 0; +} int LuaSyncedCtrl::KillTeam(lua_State* L) { const int teamID = luaL_checkint(L, 1); - if (!teamHandler->IsValidTeam(teamID)) { + + if (!teamHandler->IsValidTeam(teamID)) return 0; - } - if (teamID == teamHandler->GaiaTeamID()) { - //FIXME either we disallow it here or it needs modifications in GameServer.cpp (it creates a `teams` vector w/o gaia) - // possible fix would be to always create the Gaia team (currently it's conditional on gs->useLuaGaia) + + //FIXME either we disallow it here or it needs modifications in GameServer.cpp (it creates a `teams` vector w/o gaia) + // possible fix would be to always create the Gaia team (currently it's conditional on gs->useLuaGaia) + if (teamID == teamHandler->GaiaTeamID()) return 0; - } + CTeam* team = teamHandler->Team(teamID); - if (team == NULL) { + + if (team == NULL) return 0; - } + team->Died(); return 0; } +int LuaSyncedCtrl::AssignPlayerToTeam(lua_State* L) +{ + const int playerID = luaL_checkint(L, 1); + const int teamID = luaL_checkint(L, 2); + + if (!playerHandler->IsValidPlayer(playerID)) + return 0; + if (!teamHandler->IsValidTeam(teamID)) + return 0; + + teamHandler->Team(teamID)->AddPlayer(playerID); + return 0; +} + int LuaSyncedCtrl::GameOver(lua_State* L) { @@ -810,7 +838,7 @@ if (type == "metal") { amount = std::min(amount, (float)team1->metal); - if (!luaRules || luaRules->AllowResourceTransfer(teamID1, teamID2, "m", amount)) { + if (eventHandler.AllowResourceTransfer(teamID1, teamID2, "m", amount)) { //FIXME can cause an endless loop team1->metal -= amount; team1->metalSent += amount; team1->currentStats->metalSent += amount; @@ -820,7 +848,7 @@ } } else if (type == "energy") { amount = std::min(amount, (float)team1->energy); - if (!luaRules || luaRules->AllowResourceTransfer(teamID1, teamID2, "e", amount)) { + if (eventHandler.AllowResourceTransfer(teamID1, teamID2, "e", amount)) { //FIXME can cause an endless loop team1->energy -= amount; team1->energySent += amount; team1->currentStats->energySent += amount; @@ -1431,7 +1459,7 @@ weapon->reloadTime = (int)(value * GAME_SPEED); } else if (key == "accuracy") { - weapon->accuracy = value; + weapon->accuracyError = value; } else if (key == "sprayAngle") { weapon->sprayAngle = value; @@ -1681,6 +1709,16 @@ } +int LuaSyncedCtrl::SetUnitHarvestStorage(lua_State* L) +{ + CUnit* unit = ParseUnit(L, __FUNCTION__, 1); + if (unit == NULL) { + return 0; + } + unit->harvestStorage = luaL_checkfloat(L, 2); + return 0; +} + int LuaSyncedCtrl::SetUnitBuildSpeed(lua_State* L) { CUnit* unit = ParseUnit(L, __FUNCTION__, 1); @@ -2109,19 +2147,22 @@ { CheckAllowGameChanges(L); CUnit* unit = ParseUnit(L, __FUNCTION__, 1); - if (unit == NULL) { + + if (unit == NULL) return 0; - } - if (unit->moveType == NULL) { + if (unit->moveType == NULL) return 0; - } - const float3 pos(luaL_checkfloat(L, 2), - luaL_checkfloat(L, 3), - luaL_checkfloat(L, 4)); + + const float3 pos(luaL_checkfloat(L, 2), luaL_checkfloat(L, 3), luaL_checkfloat(L, 4)); + const float radius = luaL_optfloat(L, 5, 0.0f); const float speed = luaL_optfloat(L, 6, unit->moveType->GetMaxSpeed()); - unit->moveType->StartMoving(pos, radius, speed); + if (luaL_optboolean(L, 7, false)) { + unit->moveType->StartMovingRaw(pos, radius); + } else { + unit->moveType->StartMoving(pos, radius, speed); + } return 0; } @@ -2135,9 +2176,9 @@ int LuaSyncedCtrl::SetUnitPosition(lua_State* L) { CUnit* unit = ParseUnit(L, __FUNCTION__, 1); - if (unit == NULL) { + + if (unit == NULL) return 0; - } float3 pos; @@ -2152,9 +2193,9 @@ pos.z = luaL_checkfloat(L, 3); if (luaL_optboolean(L, 4, false)) { - pos.y = ground->GetHeightAboveWater(pos.x, pos.z); + pos.y = CGround::GetHeightAboveWater(pos.x, pos.z); } else { - pos.y = ground->GetHeightReal(pos.x, pos.z); + pos.y = CGround::GetHeightReal(pos.x, pos.z); } } @@ -2177,10 +2218,10 @@ assert(matrix.IsOrthoNormal() == 0); + // do not need ForcedSpin, below three calls cover it unit->SetDirVectors(matrix); unit->UpdateMidAndAimPos(); unit->SetHeadingFromDirection(); - unit->ForcedMove(unit->pos); return 0; } @@ -2357,7 +2398,7 @@ float3 pos(luaL_checkfloat(L, 1), 0.0f, luaL_checkfloat(L, 2)); pos.ClampInBounds(); - treeDrawer->AddGrass(pos); + grassDrawer->AddGrass(pos); return 0; } @@ -2367,7 +2408,7 @@ float3 pos(luaL_checkfloat(L, 1), 0.0f, luaL_checkfloat(L, 2)); pos.ClampInBounds(); - treeDrawer->RemoveGrass((int)pos.x,(int)pos.z); + grassDrawer->RemoveGrass(pos); return 0; } @@ -2806,26 +2847,33 @@ return 0; } - +// +// TODO: move this and SpawnCEG to LuaUnsyncedCtrl +// int LuaSyncedCtrl::SetProjectileCEG(lua_State* L) { CProjectile* proj = ParseProjectile(L, __FUNCTION__, 1); if (proj == NULL) return 0; + if (!proj->weapon && !proj->piece) + return 0; - assert(proj->weapon || proj->piece); + unsigned int cegID = CExplosionGeneratorHandler::EXPGEN_ID_INVALID; - if (proj->weapon) { - CWeaponProjectile* wproj = static_cast(proj); - wproj->SetCustomExplosionGeneratorID(explGenHandler->LoadGeneratorID(luaL_checkstring(L, 2))); - } - if (proj->piece) { - CPieceProjectile* pproj = static_cast(proj); - pproj->SetCustomExplosionGeneratorID(explGenHandler->LoadGeneratorID(luaL_checkstring(L, 2))); + if (lua_isstring(L, 2)) { + cegID = explGenHandler->LoadGeneratorID(std::string(CEG_PREFIX_STRING) + lua_tostring(L, 2)); + } else { + cegID = luaL_checknumber(L, 2); } - return 0; + // if cegID is EXPGEN_ID_INVALID, this also returns NULL + if (explGenHandler->GetGenerator(cegID) != NULL) { + proj->SetCustomExplosionGeneratorID(cegID); + } + + lua_pushnumber(L, cegID); + return 1; } diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaSyncedCtrl.h spring-98.0~14.04~ppa6/rts/Lua/LuaSyncedCtrl.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaSyncedCtrl.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaSyncedCtrl.h 2014-10-07 20:09:51.000000000 +0000 @@ -23,7 +23,9 @@ private: // all LuaHandleSynced + static int SetAlly(lua_State* L); static int KillTeam(lua_State* L); + static int AssignPlayerToTeam(lua_State* L); static int GameOver(lua_State* L); static int AddTeamResource(lua_State* L); @@ -54,7 +56,6 @@ static int TransferFeature(lua_State* L); static int SetUnitCosts(lua_State* L); - static int SetUnitResourcing(lua_State* L); static int SetUnitTooltip(lua_State* L); static int SetUnitHealth(lua_State* L); static int SetUnitMaxHealth(lua_State* L); @@ -68,7 +69,9 @@ static int SetUnitStealth(lua_State* L); static int SetUnitSonarStealth(lua_State* L); static int SetUnitAlwaysVisible(lua_State* L); + static int SetUnitResourcing(lua_State* L); static int SetUnitMetalExtraction(lua_State* L); + static int SetUnitHarvestStorage(lua_State* L); static int SetUnitBuildSpeed(lua_State* L); static int SetUnitNanoPieces(lua_State* L); static int SetUnitBlocking(lua_State* L); diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaSyncedMoveCtrl.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaSyncedMoveCtrl.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaSyncedMoveCtrl.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaSyncedMoveCtrl.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,6 @@ #include "LuaHandle.h" #include "LuaHashString.h" -#include "LuaHelper.h" #include "LuaUtils.h" #include "Sim/MoveTypes/MoveDefHandler.h" #include "Sim/MoveTypes/ScriptMoveType.h" @@ -19,6 +18,7 @@ #include "Sim/Units/UnitHandler.h" #include "System/myMath.h" #include "System/Log/ILog.h" +#include "System/Sync/HsiehHash.h" #include @@ -88,23 +88,19 @@ static inline CUnit* ParseUnit(lua_State* L, const char* caller, int index) { - const int unitID = luaL_checkint(L, index); - if ((unitID < 0) || (static_cast(unitID) >= unitHandler->MaxUnits())) { - luaL_error(L, "%s(): Bad unitID: %d\n", caller, unitID); - } - CUnit* unit = unitHandler->units[unitID]; - if (unit == NULL) { + // handles negative and out-of-bound ID's + CUnit* unit = unitHandler->GetUnit(luaL_checkint(L, index)); + + if (unit == NULL) return NULL; - } - if (!CanControlUnit(L, unit)) { + if (!CanControlUnit(L, unit)) return NULL; - } + return unit; } -static inline CScriptMoveType* ParseMoveType(lua_State* L, - const char* caller, int index) +static inline CScriptMoveType* ParseScriptMoveType(lua_State* L, const char* caller, int index) { CUnit* unit = ParseUnit(L, caller, index); @@ -113,21 +109,18 @@ if (!unit->UsingScriptMoveType()) return NULL; - return static_cast(unit->moveType); + return (static_cast(unit->moveType)); } - -template -static inline MoveType* ParseMoveType(lua_State* L, - const char* caller, int index) +template +static inline DerivedMoveType* ParseDerivedMoveType(lua_State* L, const char* caller, int index) { CUnit* unit = ParseUnit(L, caller, index); - if (unit == NULL) { + + if (unit == NULL) return NULL; - } - MoveType* mt = dynamic_cast(unit->moveType); - return mt; + return (dynamic_cast(unit->moveType)); } @@ -175,10 +168,11 @@ int LuaSyncedMoveCtrl::SetTag(lua_State* L) { - CScriptMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); - if (moveType == NULL) { + CScriptMoveType* moveType = ParseScriptMoveType(L, __FUNCTION__, 1); + + if (moveType == NULL) return 0; - } + moveType->tag = luaL_checkint(L, 2); return 0; } @@ -186,10 +180,11 @@ int LuaSyncedMoveCtrl::GetTag(lua_State* L) { - CScriptMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); - if (moveType == NULL) { + CScriptMoveType* moveType = ParseScriptMoveType(L, __FUNCTION__, 1); + + if (moveType == NULL) return 0; - } + lua_pushnumber(L, moveType->tag); return 1; } @@ -200,10 +195,11 @@ int LuaSyncedMoveCtrl::SetProgressState(lua_State* L) { - CScriptMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); - if (moveType == NULL) { + CScriptMoveType* moveType = ParseScriptMoveType(L, __FUNCTION__, 1); + + if (moveType == NULL) return 0; - } + const int args = lua_gettop(L); // number of arguments if (args < 2) { luaL_error(L, "Incorrect arguments to SetProgressState()"); @@ -239,10 +235,11 @@ int LuaSyncedMoveCtrl::SetExtrapolate(lua_State* L) { - CScriptMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); - if (moveType == NULL) { + CScriptMoveType* moveType = ParseScriptMoveType(L, __FUNCTION__, 1); + + if (moveType == NULL) return 0; - } + moveType->extrapolate = luaL_checkboolean(L, 2); return 0; } @@ -252,10 +249,11 @@ int LuaSyncedMoveCtrl::SetPhysics(lua_State* L) { - CScriptMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); - if (moveType == NULL) { + CScriptMoveType* moveType = ParseScriptMoveType(L, __FUNCTION__, 1); + + if (moveType == NULL) return 0; - } + const float3 pos(luaL_checkfloat(L, 2), luaL_checkfloat(L, 3), luaL_checkfloat(L, 4)); @@ -275,10 +273,11 @@ int LuaSyncedMoveCtrl::SetPosition(lua_State* L) { - CScriptMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); - if (moveType == NULL) { + CScriptMoveType* moveType = ParseScriptMoveType(L, __FUNCTION__, 1); + + if (moveType == NULL) return 0; - } + const float3 pos(luaL_checkfloat(L, 2), luaL_checkfloat(L, 3), luaL_checkfloat(L, 4)); @@ -290,10 +289,11 @@ int LuaSyncedMoveCtrl::SetVelocity(lua_State* L) { - CScriptMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); - if (moveType == NULL) { + CScriptMoveType* moveType = ParseScriptMoveType(L, __FUNCTION__, 1); + + if (moveType == NULL) return 0; - } + const float3 vel(luaL_checkfloat(L, 2), luaL_checkfloat(L, 3), luaL_checkfloat(L, 4)); @@ -305,10 +305,11 @@ int LuaSyncedMoveCtrl::SetRelativeVelocity(lua_State* L) { - CScriptMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); - if (moveType == NULL) { + CScriptMoveType* moveType = ParseScriptMoveType(L, __FUNCTION__, 1); + + if (moveType == NULL) return 0; - } + const float3 relVel(luaL_checkfloat(L, 2), luaL_checkfloat(L, 3), luaL_checkfloat(L, 4)); @@ -320,10 +321,11 @@ int LuaSyncedMoveCtrl::SetRotation(lua_State* L) { - CScriptMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); - if (moveType == NULL) { + CScriptMoveType* moveType = ParseScriptMoveType(L, __FUNCTION__, 1); + + if (moveType == NULL) return 0; - } + const float3 rot(luaL_checkfloat(L, 2), luaL_checkfloat(L, 3), luaL_checkfloat(L, 4)); @@ -342,10 +344,11 @@ int LuaSyncedMoveCtrl::SetRotationVelocity(lua_State* L) { - CScriptMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); - if (moveType == NULL) { + CScriptMoveType* moveType = ParseScriptMoveType(L, __FUNCTION__, 1); + + if (moveType == NULL) return 0; - } + const float3 rotVel(luaL_checkfloat(L, 2), luaL_checkfloat(L, 3), luaL_checkfloat(L, 4)); @@ -357,10 +360,11 @@ int LuaSyncedMoveCtrl::SetHeading(lua_State* L) { - CScriptMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); - if (moveType == NULL) { + CScriptMoveType* moveType = ParseScriptMoveType(L, __FUNCTION__, 1); + + if (moveType == NULL) return 0; - } + const short heading = (short)luaL_checknumber(L, 2); ASSERT_SYNCED((short)heading); moveType->SetHeading(heading); @@ -372,10 +376,11 @@ int LuaSyncedMoveCtrl::SetTrackSlope(lua_State* L) { - CScriptMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); - if (moveType == NULL) { + CScriptMoveType* moveType = ParseScriptMoveType(L, __FUNCTION__, 1); + + if (moveType == NULL) return 0; - } + moveType->trackSlope = luaL_checkboolean(L, 2); return 0; } @@ -383,10 +388,11 @@ int LuaSyncedMoveCtrl::SetTrackGround(lua_State* L) { - CScriptMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); - if (moveType == NULL) { + CScriptMoveType* moveType = ParseScriptMoveType(L, __FUNCTION__, 1); + + if (moveType == NULL) return 0; - } + moveType->trackGround = luaL_checkboolean(L, 2); return 0; } @@ -394,10 +400,11 @@ int LuaSyncedMoveCtrl::SetGroundOffset(lua_State* L) { - CScriptMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); - if (moveType == NULL) { + CScriptMoveType* moveType = ParseScriptMoveType(L, __FUNCTION__, 1); + + if (moveType == NULL) return 0; - } + moveType->groundOffset = luaL_checkfloat(L, 2); return 0; } @@ -405,10 +412,11 @@ int LuaSyncedMoveCtrl::SetGravity(lua_State* L) { - CScriptMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); - if (moveType == NULL) { + CScriptMoveType* moveType = ParseScriptMoveType(L, __FUNCTION__, 1); + + if (moveType == NULL) return 0; - } + moveType->gravityFactor = luaL_checkfloat(L, 2); return 0; } @@ -416,10 +424,11 @@ int LuaSyncedMoveCtrl::SetDrag(lua_State* L) { - CScriptMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); - if (moveType == NULL) { + CScriptMoveType* moveType = ParseScriptMoveType(L, __FUNCTION__, 1); + + if (moveType == NULL) return 0; - } + moveType->drag = luaL_checkfloat(L, 2); return 0; } @@ -427,10 +436,11 @@ int LuaSyncedMoveCtrl::SetWindFactor(lua_State* L) { - CScriptMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); - if (moveType == NULL) { + CScriptMoveType* moveType = ParseScriptMoveType(L, __FUNCTION__, 1); + + if (moveType == NULL) return 0; - } + moveType->windFactor = luaL_checkfloat(L, 2); return 0; } @@ -438,10 +448,11 @@ int LuaSyncedMoveCtrl::SetLimits(lua_State* L) { - CScriptMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); - if (moveType == NULL) { + CScriptMoveType* moveType = ParseScriptMoveType(L, __FUNCTION__, 1); + + if (moveType == NULL) return 0; - } + const float3 mins(luaL_checkfloat(L, 2), luaL_checkfloat(L, 3), luaL_checkfloat(L, 4)); @@ -458,10 +469,10 @@ int LuaSyncedMoveCtrl::SetNoBlocking(lua_State* L) { - CScriptMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); - if (moveType == NULL) { + CScriptMoveType* moveType = ParseScriptMoveType(L, __FUNCTION__, 1); + + if (moveType == NULL) return 0; - } // marks or unmarks the unit on the blocking-map, but // does not change its blocking (collidable) state @@ -472,10 +483,11 @@ int LuaSyncedMoveCtrl::SetShotStop(lua_State* L) { - CScriptMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); - if (moveType == NULL) { + CScriptMoveType* moveType = ParseScriptMoveType(L, __FUNCTION__, 1); + + if (moveType == NULL) return 0; - } + moveType->shotStop = luaL_checkboolean(L, 2); return 0; } @@ -483,10 +495,11 @@ int LuaSyncedMoveCtrl::SetSlopeStop(lua_State* L) { - CScriptMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); - if (moveType == NULL) { + CScriptMoveType* moveType = ParseScriptMoveType(L, __FUNCTION__, 1); + + if (moveType == NULL) return 0; - } + moveType->slopeStop = luaL_checkboolean(L, 2); return 0; } @@ -494,286 +507,95 @@ int LuaSyncedMoveCtrl::SetCollideStop(lua_State* L) { - CScriptMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); - if (moveType == NULL) { + CScriptMoveType* moveType = ParseScriptMoveType(L, __FUNCTION__, 1); + + if (moveType == NULL) return 0; - } + moveType->gndStop = luaL_checkboolean(L, 2); // FIXME moveType->collideStop = lua_toboolean(L, 2); return 0; } -/******************************************************************************/ -/******************************************************************************/ -/* MoveType-specific methods */ - -static inline bool SetGenericMoveTypeValue(AMoveType* mt, const string& key, float value) -{ - // can't set goal here, need a different function that calls mt->SetGoal - // FIXME should use setter methods in all Set*MoveTypeValue functions, but they mostly don't exist - if (key == "maxSpeed") { - mt->SetMaxSpeed(value / GAME_SPEED); return true; - } else if (key == "repairBelowHealth") { - mt->SetRepairBelowHealth(value); return true; - } - return false; -} - -static inline bool SetGenericMoveTypeValue(AMoveType* mt, const string& key, bool value) -{ - return false; -} /******************************************************************************/ -/* CStrafeAirMoveType handling */ - -static inline bool SetAirMoveTypeValue(CStrafeAirMoveType* mt, const string& key, float value) -{ - if (SetGenericMoveTypeValue(mt, key, value)) - return true; - if (key == "wantedHeight") { - mt->wantedHeight = value; return true; - } else if (key == "myGravity") { - mt->myGravity = value; return true; - } else if (key == "maxBank") { - mt->maxBank = value; return true; - } else if (key == "maxPitch") { - mt->maxPitch = value; return true; - } else if (key == "turnRadius") { - mt->turnRadius = value; return true; - } else if (key == "maxAcc") { - mt->accRate = value; return true; - } else if (key == "maxAileron") { - mt->maxAileron = value; return true; - } else if (key == "maxElevator") { - mt->maxElevator = value; return true; - } else if (key == "maxRudder") { - mt->maxRudder = value; return true; - } - - return false; -} +/* MoveType member-value handling */ -static inline bool SetAirMoveTypeValue(CStrafeAirMoveType* mt, const string& key, bool value) +template +static bool SetMoveTypeValue(AMoveType* mt, const string& key, value_type value) { - if (SetGenericMoveTypeValue(mt, key, value)) - return true; - if (key == "collide") { - mt->collide = value; return true; - } else if (key == "useSmoothMesh") { - mt->useSmoothMesh = value; return true; - } - return false; + return (mt->SetMemberValue(HsiehHash(key.c_str(), key.size(), 0), &value)); } - -static inline void SetSingleAirMoveTypeValue(lua_State* L, int keyidx, int validx, CStrafeAirMoveType* moveType) -{ - const string key = lua_tostring(L, keyidx); - bool assigned = true; - - if (lua_isnumber(L, validx)) { - assigned = SetAirMoveTypeValue(moveType, key, lua_tofloat(L, validx)); - } else if (lua_isboolean(L, validx)) { - assigned = SetAirMoveTypeValue(moveType, key, lua_toboolean(L, validx)); - } - - if (!assigned) { - LOG_L(L_WARNING, "Can not assign key \"%s\" to AirMoveType", key.c_str()); - } -} - -int LuaSyncedMoveCtrl::SetAirMoveTypeData(lua_State* L) -{ - CStrafeAirMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); - if (moveType == NULL) { - luaL_error(L, "Unit does not have a compatible MoveType"); - } - - const int args = lua_gettop(L); // number of arguments - - if (args == 3 && lua_isstring(L, 2)) { - // a single value - SetSingleAirMoveTypeValue(L, 2, 3, moveType); - } else if (args == 2 && lua_istable(L, 2)) { - // a table of values - const int table = 2; - for (lua_pushnil(L); lua_next(L, table) != 0; lua_pop(L, 1)) { - if (lua_israwstring(L, -2)) { - SetSingleAirMoveTypeValue(L, -2, -1, moveType); - } - } - } - - return 0; -} - - -/******************************************************************************/ -/* CGroundMoveType handling */ - -static inline bool SetGroundMoveTypeValue(CGroundMoveType* mt, const string& key, float value) +static inline bool SetMoveTypeValue(lua_State* L, AMoveType* moveType, int keyIdx, int valIdx) { - if (SetGenericMoveTypeValue(mt, key, value)) - return true; + if (lua_isnumber(L, valIdx)) + return (SetMoveTypeValue(moveType, lua_tostring(L, keyIdx), lua_tofloat(L, valIdx))); - if (key == "turnRate") { - mt->turnRate = value; return true; - } else if (key == "accRate") { - mt->accRate = value; return true; - } else if (key == "decRate") { - mt->decRate = value; return true; - } else if (key == "maxReverseSpeed") { - // use setter? - mt->maxReverseSpeed = value / GAME_SPEED; - return true; - } + if (lua_isboolean(L, valIdx)) + return (SetMoveTypeValue(moveType, lua_tostring(L, keyIdx), lua_toboolean(L, valIdx))); return false; } -static inline bool SetGroundMoveTypeValue(CGroundMoveType* mt, const string& key, bool value) -{ - if (SetGenericMoveTypeValue(mt, key, value)) - return true; - - return false; -} -static inline void SetSingleGroundMoveTypeValue(lua_State* L, int keyidx, int validx, CGroundMoveType* moveType) +static int SetMoveTypeData(lua_State* L, AMoveType* moveType, const char* caller) { - const string key = lua_tostring(L, keyidx); - bool assigned = true; - - if (lua_isnumber(L, validx)) { - assigned = SetGroundMoveTypeValue(moveType, key, lua_tofloat(L, validx)); - } else if (lua_isboolean(L, validx)) { - assigned = SetGroundMoveTypeValue(moveType, key, lua_toboolean(L, validx)); - } - - if (!assigned) { - LOG_L(L_WARNING, "Can not assign key \"%s\" to GroundMoveType", key.c_str()); - } -} + int numAssignedValues = 0; -int LuaSyncedMoveCtrl::SetGroundMoveTypeData(lua_State *L) -{ - CGroundMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); if (moveType == NULL) { - luaL_error(L, "Unit does not have a compatible MoveType"); + luaL_error(L, "[%s] unit %d has incompatible movetype for %s", __FUNCTION__, caller, lua_tonumber(L, 1)); + return numAssignedValues; } - const int args = lua_gettop(L); // number of arguments + switch (lua_gettop(L)) { + case 2: { + // two args (unitID, {"key1" = (number | bool) value1, ...}) + const int tableIdx = 2; - if (args == 3 && lua_isstring(L, 2)) { - // a single value - SetSingleGroundMoveTypeValue(L, 2, 3, moveType); - } else if (args == 2 && lua_istable(L, 2)) { - // a table of values - const int table = 2; - for (lua_pushnil(L); lua_next(L, table) != 0; lua_pop(L, 1)) { - if (lua_israwstring(L, -2)) { - SetSingleGroundMoveTypeValue(L, -2, -1, moveType); + if (lua_istable(L, tableIdx)) { + for (lua_pushnil(L); lua_next(L, tableIdx) != 0; lua_pop(L, 1)) { + if (lua_israwstring(L, -2) && SetMoveTypeValue(L, moveType, -2, -1)) { + numAssignedValues++; + } else { + LOG_L(L_WARNING, "[%s] incompatible movetype key for %s", __FUNCTION__, caller); + } + } } - } + } break; + + case 3: { + // three args (unitID, "key", (number | bool) value) + if (lua_isstring(L, 2) && SetMoveTypeValue(L, moveType, 2, 3)) { + numAssignedValues++; + } else { + LOG_L(L_WARNING, "[%s] incompatible movetype key for %s", __FUNCTION__, caller); + } + } break; } - return 0; + lua_pushnumber(L, numAssignedValues); + return 1; } - -/******************************************************************************/ -/* CHoverAirMoveType handling */ - -static inline bool SetHoverAirMoveTypeValue(CHoverAirMoveType* mt, const string& key, float value) +int LuaSyncedMoveCtrl::SetGunshipMoveTypeData(lua_State* L) { - if (SetGenericMoveTypeValue(mt, key, value)) { - return true; - } - - if (key == "wantedHeight") { - mt->SetDefaultAltitude(value); return true; - } else if (key == "turnRate") { - mt->turnRate = value; return true; - } else if (key == "accRate") { - mt->accRate = value; return true; - } else if (key == "decRate") { - mt->decRate = value; return true; - } else if (key == "altitudeRate") { - mt->altitudeRate = value; return true; - } else if (key == "currentBank") { - mt->currentBank = value; return true; - } else if (key == "currentPitch") { - mt->currentPitch = value; return true; - } else if (key == "maxDrift") { - mt->maxDrift = value; return true; - } - - return false; + return (SetMoveTypeData(L, ParseDerivedMoveType(L, __FUNCTION__, 1), __FUNCTION__)); } -static inline bool SetHoverAirMoveTypeValue(CHoverAirMoveType* mt, const string& key, bool value) +int LuaSyncedMoveCtrl::SetAirMoveTypeData(lua_State* L) { - if (SetGenericMoveTypeValue(mt, key, value)) - return true; - - if (key == "collide") { - mt->collide = value; return true; - } else if (key == "useSmoothMesh") { - mt->useSmoothMesh = value; return true; - } else if (key == "bankingAllowed") { - mt->bankingAllowed = value; return true; - } else if (key == "airStrafe") { - mt->airStrafe = value; return true; - } else if (key == "dontLand") { - mt->SetAllowLanding(!value); return true; - } - - return false; + return (SetMoveTypeData(L, ParseDerivedMoveType(L, __FUNCTION__, 1), __FUNCTION__)); } -static inline void SetSingleHoverAirMoveTypeValue(lua_State* L, int keyIdx, int valIdx, CHoverAirMoveType* moveType) +int LuaSyncedMoveCtrl::SetGroundMoveTypeData(lua_State* L) { - const string key = lua_tostring(L, keyIdx); - bool assigned = true; - - if (lua_isnumber(L, valIdx)) { - assigned = SetHoverAirMoveTypeValue(moveType, key, lua_tofloat(L, valIdx)); - } else if (lua_isboolean(L, valIdx)) { - assigned = SetHoverAirMoveTypeValue(moveType, key, lua_toboolean(L, valIdx)); - } - - if (!assigned) { - LOG_L(L_WARNING, "Can not assign key \"%s\" to GunshipMoveType", key.c_str()); - } + return (SetMoveTypeData(L, ParseDerivedMoveType(L, __FUNCTION__, 1), __FUNCTION__)); } -int LuaSyncedMoveCtrl::SetGunshipMoveTypeData(lua_State *L) -{ - CHoverAirMoveType* moveType = ParseMoveType(L, __FUNCTION__, 1); - if (moveType == NULL) { - luaL_error(L, "Unit does not have a compatible MoveType"); - } - const int args = lua_gettop(L); // number of arguments - - if (args == 3 && lua_isstring(L, 2)) { - // a single value - SetSingleHoverAirMoveTypeValue(L, 2, 3, moveType); - } else if (args == 2 && lua_istable(L, 2)) { - // a table of values - const int table = 2; - for (lua_pushnil(L); lua_next(L, table) != 0; lua_pop(L, 1)) { - if (lua_israwstring(L, -2)) { - SetSingleHoverAirMoveTypeValue(L, -2, -1, moveType); - } - } - } - - return 0; -} /******************************************************************************/ /******************************************************************************/ @@ -807,7 +629,7 @@ } if (moveDef->udRefCount == 0) { - // pathfinder contains optimizations that + // pathfinders contain optimizations that // make unreferenced movedef's non-usable lua_pushboolean(L, false); return 1; diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaSyncedRead.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaSyncedRead.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaSyncedRead.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaSyncedRead.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -4,6 +4,7 @@ #include "LuaInclude.h" +#include "LuaConfig.h" #include "LuaHandle.h" #include "LuaHashString.h" #include "LuaMetalMap.h" @@ -118,7 +119,6 @@ REGISTER_LUA_CFUNC(GetGaiaTeamID); - REGISTER_LUA_CFUNC(GetGameSpeed); REGISTER_LUA_CFUNC(GetGameFrame); REGISTER_LUA_CFUNC(GetGameSeconds); @@ -215,6 +215,7 @@ REGISTER_LUA_CFUNC(GetUnitBuildFacing); REGISTER_LUA_CFUNC(GetUnitIsBuilding); REGISTER_LUA_CFUNC(GetUnitCurrentBuildPower); + REGISTER_LUA_CFUNC(GetUnitHarvestStorage); REGISTER_LUA_CFUNC(GetUnitNanoPieces); REGISTER_LUA_CFUNC(GetUnitTransporter); REGISTER_LUA_CFUNC(GetUnitIsTransporting); @@ -273,6 +274,7 @@ REGISTER_LUA_CFUNC(GetFeatureCollisionVolumeData); REGISTER_LUA_CFUNC(GetProjectilePosition); + REGISTER_LUA_CFUNC(GetProjectileDirection); REGISTER_LUA_CFUNC(GetProjectileVelocity); REGISTER_LUA_CFUNC(GetProjectileGravity); REGISTER_LUA_CFUNC(GetProjectileSpinAngle); @@ -495,6 +497,50 @@ return 4; } +static int GetSolidObjectPosition(lua_State* L, const CSolidObject* o, bool isFeature) +{ + if (o == NULL) + return 0; + + // no error for features + float3 errorVec; + + if (isFeature) { + if (!IsFeatureVisible(L, static_cast(o))) { + return 0; + } + } else { + if (!IsAllyUnit(L, static_cast(o))) { + errorVec += static_cast(o)->GetErrorPos(CLuaHandle::GetHandleReadAllyTeam(L)); + errorVec -= o->midPos; + } + } + + // NOTE: + // must be called before any pushing to the stack, + // else in case of noneornil it will read the pushed items. + const bool returnMidPos = luaL_optboolean(L, 2, false); + const bool returnAimPos = luaL_optboolean(L, 3, false); + + // base-position + lua_pushnumber(L, o->pos.x + errorVec.x); + lua_pushnumber(L, o->pos.y + errorVec.y); + lua_pushnumber(L, o->pos.z + errorVec.z); + + if (returnMidPos) { + lua_pushnumber(L, o->midPos.x + errorVec.x); + lua_pushnumber(L, o->midPos.y + errorVec.y); + lua_pushnumber(L, o->midPos.z + errorVec.z); + } + if (returnAimPos) { + lua_pushnumber(L, o->aimPos.x + errorVec.x); + lua_pushnumber(L, o->aimPos.y + errorVec.y); + lua_pushnumber(L, o->aimPos.z + errorVec.z); + } + + return (3 + (3 * returnMidPos) + (3 * returnAimPos)); +} + static int GetSolidObjectBlocking(lua_State* L, const CSolidObject* o) { if (o == NULL) @@ -649,15 +695,6 @@ } -static inline void CheckNoArgs(lua_State* L, const char* funcName) -{ - const int args = lua_gettop(L); // number of arguments - if (args != 0) { - luaL_error(L, "%s() takes no arguments", funcName); - } -} - - /******************************************************************************/ static int PushRulesParams(lua_State* L, const char* caller, @@ -747,7 +784,6 @@ int LuaSyncedRead::IsCheatingEnabled(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushboolean(L, gs->cheatEnabled); return 1; } @@ -755,7 +791,6 @@ int LuaSyncedRead::IsGodModeEnabled(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushboolean(L, gs->godMode); return 1; } @@ -763,7 +798,6 @@ int LuaSyncedRead::IsDevLuaEnabled(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushboolean(L, CLuaHandle::GetDevMode()); return 1; } @@ -771,7 +805,6 @@ int LuaSyncedRead::IsEditDefsEnabled(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushboolean(L, gs->editDefsEnabled); return 1; } @@ -779,7 +812,6 @@ int LuaSyncedRead::AreHelperAIsEnabled(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); if (!game) { return 0; } @@ -790,7 +822,6 @@ int LuaSyncedRead::FixedAllies(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); if (!game) { return 0; } @@ -801,7 +832,6 @@ int LuaSyncedRead::IsGameOver(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushboolean(L, game->IsGameOver()); return 1; } @@ -809,7 +839,6 @@ int LuaSyncedRead::GetGaiaTeamID(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); if (!gs->useLuaGaia) { return 0; } @@ -818,19 +847,8 @@ } -int LuaSyncedRead::GetGameSpeed(lua_State* L) -{ - CheckNoArgs(L, __FUNCTION__); - lua_pushnumber(L, gs->wantedSpeedFactor); - lua_pushnumber(L, gs->speedFactor); - lua_pushboolean(L, gs->paused); - return 3; -} - - int LuaSyncedRead::GetGameFrame(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); const int dayFrames = GAME_SPEED * (24 * 60 * 60); lua_pushnumber(L, gs->frameNum % dayFrames); lua_pushnumber(L, gs->frameNum / dayFrames); @@ -840,7 +858,6 @@ int LuaSyncedRead::GetGameSeconds(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); const float seconds = gs->frameNum / (float)GAME_SPEED; lua_pushnumber(L, seconds); return 1; @@ -849,7 +866,6 @@ int LuaSyncedRead::GetWind(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushnumber(L, wind.GetCurrentWind().x); lua_pushnumber(L, wind.GetCurrentWind().y); lua_pushnumber(L, wind.GetCurrentWind().z); @@ -1031,7 +1047,6 @@ int LuaSyncedRead::GetAllyTeamList(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_newtable(L); int count = 1; for (int at = 0; at < teamHandler->ActiveAllyTeams(); at++) { @@ -1569,7 +1584,6 @@ int LuaSyncedRead::GetAllUnits(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); int count = 1; std::list::const_iterator uit; if (CLuaHandle::GetHandleFullRead(L)) { @@ -1931,19 +1945,17 @@ int LuaSyncedRead::GetTeamUnitCount(lua_State* L) { - if (CLuaHandle::GetHandleReadAllyTeam(L) == CEventClient::NoAccessTeam) { + if (CLuaHandle::GetHandleReadAllyTeam(L) == CEventClient::NoAccessTeam) return 0; - } // parse the team const CTeam* team = ParseTeam(L, __FUNCTION__, 1); - if (team == NULL) { + + if (team == NULL) return 0; - } - const int teamID = team->teamNum; // use the raw team count for allies - if (IsAlliedTeam(L, teamID)) { + if (IsAlliedTeam(L, team->teamNum)) { lua_pushnumber(L, team->units.size()); return 1; } @@ -1951,13 +1963,11 @@ // loop through the units for enemies int count = 0; const CUnitSet& units = team->units; - CUnitSet::const_iterator uit; - for (uit = units.begin(); uit != units.end(); ++uit) { - const CUnit* unit = *uit; - if (IsUnitVisible(L, unit)) { - count++; - } + + for (auto uit = units.begin(); uit != units.end(); ++uit) { + count += int(IsUnitVisible(L, *uit)); } + lua_pushnumber(L, count); return 1; } @@ -1970,16 +1980,25 @@ // // Macro Requirements: -// L, it, units, and count +// L, units -#define LOOP_UNIT_CONTAINER(ALLEGIANCE_TEST, CUSTOM_TEST) \ - for (it = units.begin(); it != units.end(); ++it) { \ - const CUnit* unit = *it; \ - ALLEGIANCE_TEST; \ - CUSTOM_TEST; \ - count++; \ - lua_pushnumber(L, unit->id); \ - lua_rawseti(L, -2, count); \ +#define LOOP_UNIT_CONTAINER(ALLEGIANCE_TEST, CUSTOM_TEST, NEWTABLE) \ + { \ + unsigned int count = 0; \ + \ + if (NEWTABLE) { \ + lua_createtable(L, units.size(), 0); \ + } \ + \ + for (auto it = units.begin(); it != units.end(); ++it) { \ + const CUnit* unit = *it; \ + \ + ALLEGIANCE_TEST; \ + CUSTOM_TEST; \ + \ + lua_pushnumber(L, unit->id); \ + lua_rawseti(L, -2, ++count); \ + } \ } // Macro Requirements: @@ -1990,24 +2009,24 @@ #define NULL_TEST ; // always passes #define VISIBLE_TEST \ - if (!IsUnitVisible(L, unit)) { continue; } + if (!IsUnitVisible(L, unit)) { continue; } #define SIMPLE_TEAM_TEST \ if (unit->team != allegiance) { continue; } #define VISIBLE_TEAM_TEST \ if (unit->team != allegiance) { continue; } \ - if (!IsUnitVisible(L, unit)) { continue; } + if (!IsUnitVisible(L, unit)) { continue; } #define MY_UNIT_TEST \ - if (unit->team != readTeam) { continue; } + if (unit->team != readTeam) { continue; } #define ALLY_UNIT_TEST \ if (unit->allyteam != CLuaHandle::GetHandleReadAllyTeam(L)) { continue; } #define ENEMY_UNIT_TEST \ if (unit->allyteam == CLuaHandle::GetHandleReadAllyTeam(L)) { continue; } \ - if (!IsUnitVisible(L, unit)) { continue; } + if (!IsUnitVisible(L, unit)) { continue; } static int ParseAllegiance(lua_State* L, const char* caller, int index) @@ -2043,31 +2062,27 @@ #define RECTANGLE_TEST ; // no test, GetUnitsExact is sufficient - vector::const_iterator it; - const vector &units = quadField->GetUnitsExact(mins, maxs); - - lua_newtable(L); - int count = 0; + const vector& units = quadField->GetUnitsExact(mins, maxs); if (allegiance >= 0) { if (IsAlliedTeam(L, allegiance)) { - LOOP_UNIT_CONTAINER(SIMPLE_TEAM_TEST, RECTANGLE_TEST); + LOOP_UNIT_CONTAINER(SIMPLE_TEAM_TEST, RECTANGLE_TEST, true); } else { - LOOP_UNIT_CONTAINER(VISIBLE_TEAM_TEST, RECTANGLE_TEST); + LOOP_UNIT_CONTAINER(VISIBLE_TEAM_TEST, RECTANGLE_TEST, true); } } else if (allegiance == MyUnits) { const int readTeam = CLuaHandle::GetHandleReadTeam(L); - LOOP_UNIT_CONTAINER(MY_UNIT_TEST, RECTANGLE_TEST); + LOOP_UNIT_CONTAINER(MY_UNIT_TEST, RECTANGLE_TEST, true); } else if (allegiance == AllyUnits) { - LOOP_UNIT_CONTAINER(ALLY_UNIT_TEST, RECTANGLE_TEST); + LOOP_UNIT_CONTAINER(ALLY_UNIT_TEST, RECTANGLE_TEST, true); } else if (allegiance == EnemyUnits) { - LOOP_UNIT_CONTAINER(ENEMY_UNIT_TEST, RECTANGLE_TEST); + LOOP_UNIT_CONTAINER(ENEMY_UNIT_TEST, RECTANGLE_TEST, true); } else { // AllUnits - LOOP_UNIT_CONTAINER(VISIBLE_TEST, RECTANGLE_TEST); + LOOP_UNIT_CONTAINER(VISIBLE_TEST, RECTANGLE_TEST, true); } return 1; @@ -2094,31 +2109,27 @@ continue; \ } - vector::const_iterator it; - const vector &units = quadField->GetUnitsExact(mins, maxs); - - lua_newtable(L); - int count = 0; + const vector& units = quadField->GetUnitsExact(mins, maxs); if (allegiance >= 0) { if (IsAlliedTeam(L, allegiance)) { - LOOP_UNIT_CONTAINER(SIMPLE_TEAM_TEST, BOX_TEST); + LOOP_UNIT_CONTAINER(SIMPLE_TEAM_TEST, BOX_TEST, true); } else { - LOOP_UNIT_CONTAINER(VISIBLE_TEAM_TEST, BOX_TEST); + LOOP_UNIT_CONTAINER(VISIBLE_TEAM_TEST, BOX_TEST, true); } } else if (allegiance == MyUnits) { const int readTeam = CLuaHandle::GetHandleReadTeam(L); - LOOP_UNIT_CONTAINER(MY_UNIT_TEST, BOX_TEST); + LOOP_UNIT_CONTAINER(MY_UNIT_TEST, BOX_TEST, true); } else if (allegiance == AllyUnits) { - LOOP_UNIT_CONTAINER(ALLY_UNIT_TEST, BOX_TEST); + LOOP_UNIT_CONTAINER(ALLY_UNIT_TEST, BOX_TEST, true); } else if (allegiance == EnemyUnits) { - LOOP_UNIT_CONTAINER(ENEMY_UNIT_TEST, BOX_TEST); + LOOP_UNIT_CONTAINER(ENEMY_UNIT_TEST, BOX_TEST, true); } else { // AllUnits - LOOP_UNIT_CONTAINER(VISIBLE_TEST, BOX_TEST); + LOOP_UNIT_CONTAINER(VISIBLE_TEST, BOX_TEST, true); } return 1; @@ -2146,31 +2157,27 @@ continue; \ } \ - vector::const_iterator it; - const vector &units = quadField->GetUnitsExact(mins, maxs); - - lua_newtable(L); - int count = 0; + const vector& units = quadField->GetUnitsExact(mins, maxs); if (allegiance >= 0) { if (IsAlliedTeam(L, allegiance)) { - LOOP_UNIT_CONTAINER(SIMPLE_TEAM_TEST, CYLINDER_TEST); + LOOP_UNIT_CONTAINER(SIMPLE_TEAM_TEST, CYLINDER_TEST, true); } else { - LOOP_UNIT_CONTAINER(VISIBLE_TEAM_TEST, CYLINDER_TEST); + LOOP_UNIT_CONTAINER(VISIBLE_TEAM_TEST, CYLINDER_TEST, true); } } else if (allegiance == MyUnits) { const int readTeam = CLuaHandle::GetHandleReadTeam(L); - LOOP_UNIT_CONTAINER(MY_UNIT_TEST, CYLINDER_TEST); + LOOP_UNIT_CONTAINER(MY_UNIT_TEST, CYLINDER_TEST, true); } else if (allegiance == AllyUnits) { - LOOP_UNIT_CONTAINER(ALLY_UNIT_TEST, CYLINDER_TEST); + LOOP_UNIT_CONTAINER(ALLY_UNIT_TEST, CYLINDER_TEST, true); } else if (allegiance == EnemyUnits) { - LOOP_UNIT_CONTAINER(ENEMY_UNIT_TEST, CYLINDER_TEST); + LOOP_UNIT_CONTAINER(ENEMY_UNIT_TEST, CYLINDER_TEST, true); } else { // AllUnits - LOOP_UNIT_CONTAINER(VISIBLE_TEST, CYLINDER_TEST); + LOOP_UNIT_CONTAINER(VISIBLE_TEST, CYLINDER_TEST, true); } return 1; @@ -2202,31 +2209,27 @@ continue; \ } \ - vector::const_iterator it; - const vector &units = quadField->GetUnitsExact(mins, maxs); - - lua_newtable(L); - int count = 0; + const vector& units = quadField->GetUnitsExact(mins, maxs); if (allegiance >= 0) { if (IsAlliedTeam(L, allegiance)) { - LOOP_UNIT_CONTAINER(SIMPLE_TEAM_TEST, SPHERE_TEST); + LOOP_UNIT_CONTAINER(SIMPLE_TEAM_TEST, SPHERE_TEST, true); } else { - LOOP_UNIT_CONTAINER(VISIBLE_TEAM_TEST, SPHERE_TEST); + LOOP_UNIT_CONTAINER(VISIBLE_TEAM_TEST, SPHERE_TEST, true); } } else if (allegiance == MyUnits) { const int readTeam = CLuaHandle::GetHandleReadTeam(L); - LOOP_UNIT_CONTAINER(MY_UNIT_TEST, SPHERE_TEST); + LOOP_UNIT_CONTAINER(MY_UNIT_TEST, SPHERE_TEST, true); } else if (allegiance == AllyUnits) { - LOOP_UNIT_CONTAINER(ALLY_UNIT_TEST, SPHERE_TEST); + LOOP_UNIT_CONTAINER(ALLY_UNIT_TEST, SPHERE_TEST, true); } else if (allegiance == EnemyUnits) { - LOOP_UNIT_CONTAINER(ENEMY_UNIT_TEST, SPHERE_TEST); + LOOP_UNIT_CONTAINER(ENEMY_UNIT_TEST, SPHERE_TEST, true); } else { // AllUnits - LOOP_UNIT_CONTAINER(VISIBLE_TEST, SPHERE_TEST); + LOOP_UNIT_CONTAINER(VISIBLE_TEST, SPHERE_TEST, true); } return 1; @@ -2289,49 +2292,47 @@ endTeam = teamHandler->ActiveTeams() - 1; } -#define PLANES_TEST \ +#define PLANES_TEST \ if (!UnitInPlanes(unit, planes)) { \ - continue; \ + continue; \ } - lua_newtable(L); - int count = 0; - const int readTeam = CLuaHandle::GetHandleReadTeam(L); + lua_newtable(L); + for (int team = startTeam; team <= endTeam; team++) { const CUnitSet& units = teamHandler->Team(team)->units; - CUnitSet::const_iterator it; if (allegiance >= 0) { if (allegiance == team) { if (IsAlliedTeam(L, allegiance)) { - LOOP_UNIT_CONTAINER(NULL_TEST, PLANES_TEST); + LOOP_UNIT_CONTAINER(NULL_TEST, PLANES_TEST, false); } else { - LOOP_UNIT_CONTAINER(VISIBLE_TEST, PLANES_TEST); + LOOP_UNIT_CONTAINER(VISIBLE_TEST, PLANES_TEST, false); } } } else if (allegiance == MyUnits) { if (readTeam == team) { - LOOP_UNIT_CONTAINER(NULL_TEST, PLANES_TEST); + LOOP_UNIT_CONTAINER(NULL_TEST, PLANES_TEST, false); } } else if (allegiance == AllyUnits) { if (CLuaHandle::GetHandleReadAllyTeam(L) == teamHandler->AllyTeam(team)) { - LOOP_UNIT_CONTAINER(NULL_TEST, PLANES_TEST); + LOOP_UNIT_CONTAINER(NULL_TEST, PLANES_TEST, false); } } else if (allegiance == EnemyUnits) { if (CLuaHandle::GetHandleReadAllyTeam(L) != teamHandler->AllyTeam(team)) { - LOOP_UNIT_CONTAINER(VISIBLE_TEST, PLANES_TEST); + LOOP_UNIT_CONTAINER(VISIBLE_TEST, PLANES_TEST, false); } } else { // AllUnits if (IsAlliedTeam(L, team)) { - LOOP_UNIT_CONTAINER(NULL_TEST, PLANES_TEST); + LOOP_UNIT_CONTAINER(NULL_TEST, PLANES_TEST, false); } else { - LOOP_UNIT_CONTAINER(VISIBLE_TEST, PLANES_TEST); + LOOP_UNIT_CONTAINER(VISIBLE_TEST, PLANES_TEST, false); } } } @@ -2897,40 +2898,7 @@ int LuaSyncedRead::GetUnitPosition(lua_State* L) { - int argc = 0; - CUnit* unit = ParseUnit(L, __FUNCTION__, 1); - - if (unit == NULL) { - return argc; - } - - float3 err = ZeroVector; - - if (!IsAllyUnit(L, unit)) { - err += unit->GetErrorPos(CLuaHandle::GetHandleReadAllyTeam(L)); - err -= unit->midPos; - } - - // base-position - lua_pushnumber(L, unit->pos.x + err.x); - lua_pushnumber(L, unit->pos.y + err.y); - lua_pushnumber(L, unit->pos.z + err.z); - argc += 3; - - if (luaL_optboolean(L, 2, false)) { - lua_pushnumber(L, unit->midPos.x + err.x); - lua_pushnumber(L, unit->midPos.y + err.y); - lua_pushnumber(L, unit->midPos.z + err.z); - argc += 3; - } - if (luaL_optboolean(L, 3, false)) { - lua_pushnumber(L, unit->aimPos.x + err.x); - lua_pushnumber(L, unit->aimPos.y + err.y); - lua_pushnumber(L, unit->aimPos.z + err.z); - argc += 3; - } - - return argc; + return (GetSolidObjectPosition(L, ParseUnit(L, __FUNCTION__, 1), false)); } @@ -3078,6 +3046,18 @@ } +int LuaSyncedRead::GetUnitHarvestStorage(lua_State* L) +{ + CUnit* unit = ParseAllyUnit(L, __FUNCTION__, 1); + if (unit == NULL) { + return 0; + } + + lua_pushnumber(L, unit->harvestStorage); + return 1; +} + + int LuaSyncedRead::GetUnitNanoPieces(lua_State* L) { const CUnit* unit = ParseAllyUnit(L, __FUNCTION__, 1); @@ -3580,7 +3560,7 @@ return 0; } - return (LuaPathFinder::PushPathNodes(L, gmt->pathId)); + return (LuaPathFinder::PushPathNodes(L, gmt->GetPathID())); } @@ -3601,17 +3581,21 @@ int LuaSyncedRead::GetUnitLastAttackedPiece(lua_State* L) { const CUnit* unit = ParseAllyUnit(L, __FUNCTION__, 1); // ? - if (unit == NULL) { + + if (unit == NULL) return 0; - } - if (unit->lastAttackedPiece == NULL) { + if (unit->lastAttackedPiece == NULL) return 0; - } const LocalModelPiece* lmp = unit->lastAttackedPiece; const S3DModelPiece* omp = lmp->original; - lua_pushsstring(L, omp->name); + if (lua_isboolean(L, 1) && lua_toboolean(L, 1)) { + lua_pushnumber(L, lmp->GetLModelPieceIndex() + 1); + } else { + lua_pushsstring(L, omp->name); + } + lua_pushnumber(L, unit->lastAttackedPieceFrame); return 2; } @@ -3691,34 +3675,30 @@ int LuaSyncedRead::GetUnitSeparation(lua_State* L) { CUnit* unit1 = ParseUnit(L, __FUNCTION__, 1); - if (unit1 == NULL) { - return 0; - } CUnit* unit2 = ParseUnit(L, __FUNCTION__, 2); - if (unit2 == NULL) { + if (unit1 == NULL || unit2 == NULL) { return 0; } - float3 pos1; - if (IsAllyUnit(L, unit1)) { - pos1 = unit1->midPos; - } else { + float3 pos1 = unit1->midPos; + float3 pos2 = unit2->midPos; + + if (!IsAllyUnit(L, unit1)) { pos1 = unit1->GetErrorPos(CLuaHandle::GetHandleReadAllyTeam(L)); } - float3 pos2; - if (IsAllyUnit(L, unit1)) { - pos2 = unit2->midPos; - } else { + if (!IsAllyUnit(L, unit2)) { pos2 = unit2->GetErrorPos(CLuaHandle::GetHandleReadAllyTeam(L)); } float dist; - //const int args = lua_gettop(L); // number of arguments if (luaL_optboolean(L, 3, false)) { dist = pos1.distance2D(pos2); } else { dist = pos1.distance(pos2); } + if (luaL_optboolean(L, 4, false)) { + dist = std::max(0.0f, dist - unit1->radius - unit2->radius); + } lua_pushnumber(L, dist); return 1; @@ -3781,22 +3761,22 @@ if (groundmt != NULL) { HSTR_PUSH_STRING(L, "name", "ground"); - HSTR_PUSH_NUMBER(L, "turnRate", groundmt->turnRate); - HSTR_PUSH_NUMBER(L, "accRate", groundmt->accRate); - HSTR_PUSH_NUMBER(L, "decRate", groundmt->decRate); - - HSTR_PUSH_NUMBER(L, "maxReverseSpeed", groundmt->maxReverseSpeed * GAME_SPEED); - HSTR_PUSH_NUMBER(L, "wantedSpeed", groundmt->wantedSpeed * GAME_SPEED); - HSTR_PUSH_NUMBER(L, "currentSpeed", groundmt->currentSpeed * GAME_SPEED); - - HSTR_PUSH_NUMBER(L, "goalRadius", groundmt->goalRadius); - - HSTR_PUSH_NUMBER(L, "currwaypointx", groundmt->currWayPoint.x); - HSTR_PUSH_NUMBER(L, "currwaypointy", groundmt->currWayPoint.y); - HSTR_PUSH_NUMBER(L, "currwaypointz", groundmt->currWayPoint.z); - HSTR_PUSH_NUMBER(L, "nextwaypointx", groundmt->nextWayPoint.x); - HSTR_PUSH_NUMBER(L, "nextwaypointy", groundmt->nextWayPoint.y); - HSTR_PUSH_NUMBER(L, "nextwaypointz", groundmt->nextWayPoint.z); + HSTR_PUSH_NUMBER(L, "turnRate", groundmt->GetTurnRate()); + HSTR_PUSH_NUMBER(L, "accRate", groundmt->GetAccRate()); + HSTR_PUSH_NUMBER(L, "decRate", groundmt->GetDecRate()); + + HSTR_PUSH_NUMBER(L, "maxReverseSpeed", groundmt->GetMaxReverseSpeed() * GAME_SPEED); + HSTR_PUSH_NUMBER(L, "wantedSpeed", groundmt->GetWantedSpeed() * GAME_SPEED); + HSTR_PUSH_NUMBER(L, "currentSpeed", groundmt->GetCurrentSpeed() * GAME_SPEED); + + HSTR_PUSH_NUMBER(L, "goalRadius", groundmt->GetGoalRadius()); + + HSTR_PUSH_NUMBER(L, "currwaypointx", (groundmt->GetCurrWayPoint()).x); + HSTR_PUSH_NUMBER(L, "currwaypointy", (groundmt->GetCurrWayPoint()).y); + HSTR_PUSH_NUMBER(L, "currwaypointz", (groundmt->GetCurrWayPoint()).z); + HSTR_PUSH_NUMBER(L, "nextwaypointx", (groundmt->GetNextWayPoint()).x); + HSTR_PUSH_NUMBER(L, "nextwaypointy", (groundmt->GetNextWayPoint()).y); + HSTR_PUSH_NUMBER(L, "nextwaypointz", (groundmt->GetNextWayPoint()).z); HSTR_PUSH_NUMBER(L, "requestedSpeed", 0.0f); @@ -3984,26 +3964,37 @@ if (unit == NULL) return 0; - GML_STDMUTEX_LOCK(cai); // GetUnitCommands - const CCommandAI* commandAI = unit->commandAI; if (commandAI == NULL) return 0; // send the new unit commands for factories, otherwise the normal commands - const CCommandQueue* queue = NULL; const CFactoryCAI* factoryCAI = dynamic_cast(commandAI); + const CCommandQueue* queue = (factoryCAI == NULL) ? &commandAI->commandQue : &factoryCAI->newUnitCommands; - if (factoryCAI == NULL) { - queue = &commandAI->commandQue; - } else { - queue = &factoryCAI->newUnitCommands; + // performance relevant `debug` message + if (lua_isnoneornil(L, 2)) { + static int calls = 0; + static spring_time nextWarning = spring_gettime(); + calls++; + if (spring_gettime() >= nextWarning) { + nextWarning = spring_gettime() + spring_secs(5); + if (calls > 1000) { + luaL_error(L, + "[%s] called too often without a 2nd argument to define maxNumCmds returned in the table, please check your code!\n" + "Especially when you only read the first cmd or want to check if the queue is non-empty, this can be a huge performance leak!\n", __FUNCTION__); + } + calls = 0; + } } - if (luaL_optboolean(L, 3, true)) { + const int numCmds = luaL_optint(L, 2, -1); + const bool cmdsTable = luaL_optboolean(L, 3, true); // deprecated, prefer to set 2nd arg to 0 + + if (cmdsTable && (numCmds != 0)) { // *get wants the actual commands - PackCommandQueue(L, *queue, luaL_optint(L, 2, -1)); + PackCommandQueue(L, *queue, numCmds); } else { // *get just wants the queue's size lua_pushnumber(L, queue->size()); @@ -4019,8 +4010,6 @@ if (unit == NULL) return 0; - GML_STDMUTEX_LOCK(cai); // GetFactoryCommands - const CCommandAI* commandAI = unit->commandAI; const CFactoryCAI* factoryCAI = dynamic_cast(commandAI); @@ -4030,8 +4019,11 @@ const CCommandQueue& commandQue = factoryCAI->commandQue; - if (luaL_optboolean(L, 3, true)) { - PackCommandQueue(L, commandQue, luaL_optint(L, 2, -1)); + const int numCmds = luaL_optint(L, 2, -1); + const bool cmdsTable = luaL_optboolean(L, 3, true); // deprecated, prefer to set 2nd arg to 0 + + if (cmdsTable && (numCmds != 0)) { + PackCommandQueue(L, commandQue, numCmds); } else { lua_pushnumber(L, commandQue.size()); } @@ -4099,8 +4091,6 @@ return 0; } - GML_STDMUTEX_LOCK(cai); // GetFactoryCounts - const CCommandAI* commandAI = unit->commandAI; const CFactoryCAI* factoryCAI = dynamic_cast(commandAI); if (!factoryCAI) { @@ -4203,16 +4193,12 @@ int LuaSyncedRead::GetFullBuildQueue(lua_State* L) { - GML_STDMUTEX_LOCK(cai); // GetFullBuildQueue - return PackBuildQueue(L, false, __FUNCTION__); } int LuaSyncedRead::GetRealBuildQueue(lua_State* L) { - GML_STDMUTEX_LOCK(cai); // GetRealBuildQueue - return PackBuildQueue(L, true, __FUNCTION__); } @@ -4350,7 +4336,6 @@ int LuaSyncedRead::GetAllFeatures(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); int count = 0; const CFeatureSet& activeFeatures = featureHandler->GetActiveFeatures(); CFeatureSet::const_iterator fit; @@ -4448,35 +4433,9 @@ int LuaSyncedRead::GetFeaturePosition(lua_State* L) { - int argc = 0; - CFeature* feature = ParseFeature(L, __FUNCTION__, 1); - - if (feature == NULL || !IsFeatureVisible(L, feature)) { - return argc; - } - - lua_pushnumber(L, feature->pos.x); - lua_pushnumber(L, feature->pos.y); - lua_pushnumber(L, feature->pos.z); - argc += 3; - - if (luaL_optboolean(L, 2, false)) { - lua_pushnumber(L, feature->midPos.x); - lua_pushnumber(L, feature->midPos.y); - lua_pushnumber(L, feature->midPos.z); - argc += 3; - } - if (luaL_optboolean(L, 3, false)) { - lua_pushnumber(L, feature->aimPos.x); - lua_pushnumber(L, feature->aimPos.y); - lua_pushnumber(L, feature->aimPos.z); - argc += 3; - } - - return argc; + return (GetSolidObjectPosition(L, ParseFeature(L, __FUNCTION__, 1), true)); } - int LuaSyncedRead::GetFeatureDirection(lua_State* L) { CFeature* feature = ParseFeature(L, __FUNCTION__, 1); @@ -4754,7 +4713,7 @@ { const float x = luaL_checkfloat(L, 1); const float z = luaL_checkfloat(L, 2); - lua_pushnumber(L, ground->GetHeightReal(x, z, CLuaHandle::GetHandleSynced(L))); + lua_pushnumber(L, CGround::GetHeightReal(x, z, CLuaHandle::GetHandleSynced(L))); return 1; } @@ -4763,7 +4722,7 @@ { const float x = luaL_checkfloat(L, 1); const float z = luaL_checkfloat(L, 2); - lua_pushnumber(L, ground->GetOrigHeight(x, z)); + lua_pushnumber(L, CGround::GetOrigHeight(x, z)); return 1; } @@ -4772,7 +4731,7 @@ { const float x = luaL_checkfloat(L, 1); const float z = luaL_checkfloat(L, 2); - const float3 normal = ground->GetSmoothNormal(x, z, CLuaHandle::GetHandleSynced(L)); + const float3 normal = CGround::GetSmoothNormal(x, z, CLuaHandle::GetHandleSynced(L)); lua_pushnumber(L, normal.x); lua_pushnumber(L, normal.y); lua_pushnumber(L, normal.z); @@ -4876,7 +4835,6 @@ int LuaSyncedRead::GetGroundExtremes(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushnumber(L, readMap->GetInitMinHeight()); lua_pushnumber(L, readMap->GetInitMaxHeight()); return 2; @@ -5182,12 +5140,16 @@ int LuaSyncedRead::GetUnitPieceMap(lua_State* L) { - CUnit* unit = ParseTypedUnit(L, __FUNCTION__, 1); - if (unit == NULL) { + const CUnit* unit = ParseTypedUnit(L, __FUNCTION__, 1); + + if (unit == NULL) return 0; - } + const LocalModel* localModel = unit->localModel; - lua_newtable(L); + + lua_createtable(L, 0, localModel->pieces.size()); + + // {"piece" = 123, ...} for (size_t i = 0; i < localModel->pieces.size(); i++) { const LocalModelPiece& lp = *localModel->pieces[i]; lua_pushsstring(L, lp.original->name); @@ -5200,12 +5162,16 @@ int LuaSyncedRead::GetUnitPieceList(lua_State* L) { - CUnit* unit = ParseTypedUnit(L, __FUNCTION__, 1); - if (unit == NULL) { + const CUnit* unit = ParseTypedUnit(L, __FUNCTION__, 1); + + if (unit == NULL) return 0; - } + const LocalModel* localModel = unit->localModel; - lua_newtable(L); + + lua_createtable(L, localModel->pieces.size(), 0); + + // {[1] = "piece", ...} for (size_t i = 0; i < localModel->pieces.size(); i++) { const LocalModelPiece& lp = *localModel->pieces[i]; lua_pushsstring(L, lp.original->name); diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaSyncedRead.h spring-98.0~14.04~ppa6/rts/Lua/LuaSyncedRead.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaSyncedRead.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaSyncedRead.h 2014-10-07 20:09:51.000000000 +0000 @@ -30,7 +30,6 @@ static int GetGaiaTeamID(lua_State* L); - static int GetGameSpeed(lua_State* L); static int GetGameFrame(lua_State* L); static int GetGameSeconds(lua_State* L); @@ -122,6 +121,7 @@ static int GetUnitBuildFacing(lua_State* L); static int GetUnitIsBuilding(lua_State* L); static int GetUnitCurrentBuildPower(lua_State* L); + static int GetUnitHarvestStorage(lua_State* L); static int GetUnitNanoPieces(lua_State* L); static int GetUnitTransporter(lua_State* L); static int GetUnitIsTransporting(lua_State* L); @@ -228,10 +228,10 @@ static int GetRadarErrorParams(lua_State* L); - static int TraceRay(lua_State* L); // not implemented - static int TraceRayUnits(lua_State* L); // not implemented - static int TraceRayFeatures(lua_State* L); // not implemented - static int TraceRayGround(lua_State* L); // not implemented + static int TraceRay(lua_State* L); //TODO: not implemented + static int TraceRayUnits(lua_State* L); //TODO: not implemented + static int TraceRayFeatures(lua_State* L); //TODO: not implemented + static int TraceRayGround(lua_State* L); //TODO: not implemented static int GetCOBUnitVar(lua_State* L); static int GetCOBTeamVar(lua_State* L); diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaSyncedTable.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaSyncedTable.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaSyncedTable.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaSyncedTable.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,29 +1,14 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -// FIXME: it'd probably be faster overall to have a Script.NewSyncTable() -// available to the synced side, that checks data assignments in a -// __newindex call. This could be used in conjunction with the -// current setup to avoid table creation in WrapTable(). - - #include "LuaSyncedTable.h" #include "LuaInclude.h" +#include "LuaHandleSynced.h" #include "LuaHashString.h" #include "LuaUtils.h" -// replace a normal table with a read-only proxy -static bool WrapTable(lua_State* L); - -// iteration routines -static int Next(lua_State* L); -static int Pairs(lua_State* L); -static int IPairs(lua_State* L); - -// meta-table calls static int SyncTableIndex(lua_State* L); static int SyncTableNewIndex(lua_State* L); static int SyncTableMetatable(lua_State* L); @@ -32,53 +17,20 @@ /******************************************************************************/ /******************************************************************************/ - -bool LuaSyncedTable::PushEntries(lua_State* L) +static bool PushSyncedTable(lua_State* L) { HSTR_PUSH(L, "SYNCED"); - lua_pushvalue(L, LUA_GLOBALSINDEX); - - WrapTable(L); // replace the GLOBAL table with a proxy - lua_rawset(L, -3); - - LuaPushNamedCFunc(L, "snext", Next); - LuaPushNamedCFunc(L, "spairs", Pairs); - LuaPushNamedCFunc(L, "sipairs", IPairs); - - return true; -} - - -static bool WrapTable(lua_State* L) -{ - const int realTable = lua_gettop(L); - lua_newtable(L); { // the proxy table lua_newtable(L); { // the metatable - - HSTR_PUSH(L, "__index"); - lua_pushvalue(L, realTable); - lua_pushcclosure(L, SyncTableIndex, 1); - lua_rawset(L, -3); // closure - - HSTR_PUSH(L, "__newindex"); - lua_pushcfunction(L, SyncTableNewIndex); - lua_rawset(L, -3); - - HSTR_PUSH(L, "__metatable"); - lua_pushcfunction(L, SyncTableMetatable); - lua_rawset(L, -3); - - HSTR_PUSH(L, "realTable"); - lua_pushvalue(L, realTable); - lua_rawset(L, -3); + LuaPushNamedCFunc(L, "__index", SyncTableIndex); + LuaPushNamedCFunc(L, "__newindex", SyncTableNewIndex); + LuaPushNamedCFunc(L, "__metatable", SyncTableMetatable); } lua_setmetatable(L, -2); } - - lua_remove(L, realTable); + lua_rawset(L, -3); return true; } @@ -86,39 +38,41 @@ /******************************************************************************/ -inline static bool SafeType(lua_State* L, const int index) -{ - const int t = lua_type(L, index); - - return ( - (t == LUA_TSTRING) - || (t == LUA_TNUMBER) - || (t == LUA_TBOOLEAN) - || (t == LUA_TTABLE) - ); -} - -/******************************************************************************/ - -static int SyncTableIndex(lua_State* L) +static int SyncTableIndex(lua_State* dstL) { - lua_gettable(L, lua_upvalueindex(1)); + if (lua_isnoneornil(dstL, -1)) + return 0; - if (lua_isstring(L, -1) || - lua_isnumber(L, -1) || - lua_isboolean(L, -1)) { - return 1; - } - - if (lua_istable(L, -1)) { - if (WrapTable(L)) { - return 1; - } else { - return 0; + auto slh = CLuaHandleSynced::GetSyncedHandle(dstL); + if (!slh->IsValid()) + return 0; + auto srcL = slh->GetLuaState(); + + const int srcTop = lua_gettop(srcL); + const int dstTop = lua_gettop(dstL); + + // copy the index & get value + lua_pushvalue(srcL, LUA_GLOBALSINDEX); + const int keyCopied = LuaUtils::CopyData(srcL, dstL, 1); + assert(keyCopied > 0); + lua_rawget(srcL, -2); + + // copy to destination + const int valueCopied = LuaUtils::CopyData(dstL, srcL, 1); + if (lua_istable(dstL, -1)) { + // disallow writing in SYNCED[...] + lua_newtable(dstL); { // the metatable + LuaPushNamedCFunc(dstL, "__newindex", SyncTableNewIndex); + LuaPushNamedCFunc(dstL, "__metatable", SyncTableMetatable); } + lua_setmetatable(dstL, -2); } - - return 0; // functions, userdata, etc... + + assert(valueCopied == 1); + assert(dstTop + 1 == lua_gettop(dstL)); + + lua_settop(srcL, srcTop); + return valueCopied; } @@ -137,93 +91,24 @@ /******************************************************************************/ +/******************************************************************************/ -static inline void PushRealTable(lua_State* L, int index, const char* name) -{ - if (lua_getmetatable(L, 1) == 0) { - luaL_error(L, "Error: using %s() with an invalid table", name); - } - HSTR_PUSH(L, "realTable"); - lua_rawget(L, -2); - if (!lua_istable(L, -1)) { - luaL_error(L, "Error: using %s() with an invalid table", name); - } - return; -} - - -static int Next(lua_State* L) -{ - luaL_checktype(L, 1, LUA_TTABLE); - lua_settop(L, 2); // create a 2nd argument if there isn't one - - PushRealTable(L, 1, "snext"); - const int realTable = lua_gettop(L); - - lua_pushvalue(L, 2); // push the key to the top - lua_pushnil(L); // gets removed by lua_pop beneath! - do { - lua_pop(L, 1); // remove the value - if (!lua_next(L, realTable)) { - lua_pushnil(L); - return 1; - } - } while (lua_istable(L, -2) || !SafeType(L, -1)); - - if (lua_istable(L, -1)) { - WrapTable(L); - } - - return 2; -} - - -static int Pairs(lua_State* L) +bool LuaSyncedTable::PushEntries(lua_State* L) { - luaL_checktype(L, 1, LUA_TTABLE); - lua_pushcfunction(L, Next); // iterator - lua_pushvalue(L, 1); // state (table) - lua_pushnil(L); // initial value - return 3; -} + PushSyncedTable(L); + // backward compability + lua_pushliteral(L, "snext"); + lua_getglobal(L, "next"); + lua_rawset(L, -3); + lua_pushliteral(L, "spairs"); + lua_getglobal(L, "pairs"); + lua_rawset(L, -3); + lua_pushliteral(L, "sipairs"); + lua_getglobal(L, "ipairs"); + lua_rawset(L, -3); -static int IPairs(lua_State* L) -{ - lua_Number i = lua_tonumber(L, 2); - luaL_checktype(L, 1, LUA_TTABLE); - - // initializing - if ((i == 0) && lua_isnone(L, 2)) { - PushRealTable(L, 1, "sipairs"); - lua_pushcclosure(L, IPairs, 1); // iterator - lua_pushvalue(L, 1); // state (table) - lua_pushnumber(L, 0); // initial value - return 3; - } - - lua_pushnil(L); - lua_pushnil(L); // gets removed by lua_pop beneath! - do { - lua_pop(L, 2); // remove old i,v pair - - // incrementing - i++; - lua_pushnumber(L, i); // key (i) - lua_rawgeti(L, lua_upvalueindex(1), (int)i); // value (v) - - // no more elements left in the table - if (lua_isnil(L, -1)) { - return 1; - } - } while (!SafeType(L, -1)); - - // wrap tables - if (lua_istable(L, -1)) { - WrapTable(L); - } - - return 2; + return true; } diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaUI.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaUI.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaUI.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaUI.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,20 +1,18 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ -#include "lib/gml/gmlcnf.h" - - #include "LuaUI.h" #include "LuaInclude.h" #include "LuaUnsyncedCtrl.h" +#include "LuaArchive.h" #include "LuaCallInCheck.h" #include "LuaConstGL.h" #include "LuaConstCMD.h" #include "LuaConstCMDTYPE.h" #include "LuaConstGame.h" #include "LuaSyncedRead.h" -#include "LuaUnsyncedCall.h" +#include "LuaInterCall.h" #include "LuaUnsyncedRead.h" #include "LuaFeatureDefs.h" #include "LuaUnitDefs.h" @@ -51,11 +49,11 @@ #include "System/Util.h" #include "lib/luasocket/src/luasocket.h" +#include +#include #include #include #include -#include -#include CONFIG(bool, LuaSocketEnabled) .defaultValue(true) @@ -88,42 +86,43 @@ /******************************************************************************/ /******************************************************************************/ +static boost::mutex m_singleton; + void CLuaUI::LoadHandler() { - if (luaUI) { - return; - } + { + std::lock_guard lk(m_singleton); + if (luaUI) return; - new CLuaUI(); + luaUI = new CLuaUI(); + } if (!luaUI->IsValid()) { - delete luaUI; + FreeHandler(); } } void CLuaUI::FreeHandler() { - static bool inFree = false; - if (!inFree) { - inFree = true; - delete luaUI; - inFree = false; - } + std::lock_guard lk(m_singleton); + if (!luaUI) return; + + auto* inst = luaUI; + luaUI = NULL; + inst->KillLua(); + delete inst; } /******************************************************************************/ CLuaUI::CLuaUI() -: CLuaHandle("LuaUI", LUA_HANDLE_ORDER_UI, true) +: CLuaHandle("LuaUI", LUA_HANDLE_ORDER_UI, true, false) { - GML::SetLuaUIState(L_Sim); luaUI = this; - BEGIN_ITERATE_LUA_STATES(); - if (!IsValid()) { return; } @@ -187,20 +186,16 @@ AddBasicCalls(L); // into Global - lua_pushstring(L, "Script"); - lua_rawget(L, -2); - LuaPushNamedCFunc(L, "UpdateCallIn", CallOutUnsyncedUpdateCallIn); - lua_pop(L, 1); - // load the spring libraries if (!LoadCFunctions(L) || !AddEntriesToTable(L, "VFS", LuaVFS::PushUnsynced) || !AddEntriesToTable(L, "VFS", LuaZipFileReader::PushUnsynced) || !AddEntriesToTable(L, "VFS", LuaZipFileWriter::PushUnsynced) || + !AddEntriesToTable(L, "VFS", LuaArchive::PushEntries) || !AddEntriesToTable(L, "UnitDefs", LuaUnitDefs::PushEntries) || !AddEntriesToTable(L, "WeaponDefs", LuaWeaponDefs::PushEntries) || !AddEntriesToTable(L, "FeatureDefs", LuaFeatureDefs::PushEntries) || - !AddEntriesToTable(L, "Script", LuaUnsyncedCall::PushEntries) || + !AddEntriesToTable(L, "Script", LuaInterCall::PushEntriesUnsynced) || !AddEntriesToTable(L, "Script", LuaScream::PushEntries) || !AddEntriesToTable(L, "Spring", LuaSyncedRead::PushEntries) || !AddEntriesToTable(L, "Spring", LuaUnsyncedCtrl::PushEntries) || @@ -226,25 +221,17 @@ eventHandler.AddClient(this); // update extra call-ins - UnsyncedUpdateCallIn(L, "WorldTooltip"); - UnsyncedUpdateCallIn(L, "MapDrawCmd"); - - UpdateUnsyncedXCalls(L); + UpdateCallIn(L, "WorldTooltip"); + UpdateCallIn(L, "MapDrawCmd"); lua_settop(L, 0); - - END_ITERATE_LUA_STATES(); } CLuaUI::~CLuaUI() { - if (L_Sim != NULL || L_Draw != NULL) { - Shutdown(); - KillLua(); - } luaUI = NULL; - GML::SetLuaUIState(NULL); + if (guihandler) guihandler->LoadConfig("ctrlpanel.txt"); } void CLuaUI::InitLuaSocket(lua_State* L) { @@ -255,7 +242,7 @@ LUA_OPEN_LIB(L,luaopen_socket_core); if (f.LoadStringData(code)){ - LoadCode(L, code.c_str(), filename.c_str()); + LoadCode(L, code, filename); } else { LOG_L(L_ERROR, "Error loading %s", filename.c_str()); } @@ -274,59 +261,38 @@ } -bool CLuaUI::HasCallIn(lua_State *L, const string& name) +static bool IsDisallowedCallIn(const string& name) { - if (!IsValid()) { - return false; - } - - // never allow these calls - if (name == "Explosion") { - return false; - } - - if (name == "CollectGarbage") - return true; - - lua_getglobal(L, name.c_str()); - if (!lua_isfunction(L, -1)) { - lua_pop(L, 1); - return false; - } - lua_pop(L, 1); - return true; + return + (name == "Explosion") + || (name == "DrawUnit") + || (name == "DrawFeature") + || (name == "DrawShield") + || (name == "DrawProjectile") + ; } -bool CLuaUI::UnsyncedUpdateCallIn(lua_State *L, const string& name) +bool CLuaUI::HasCallIn(lua_State* L, const string& name) { - // never allow this call-in - if (name == "Explosion") { + // never allow these calls + if (IsDisallowedCallIn(name)) return false; - } - if (HasCallIn(L, name)) { - eventHandler.InsertEvent(this, name); - } else { - eventHandler.RemoveEvent(this, name); - } - - UpdateUnsyncedXCalls(L); - - return true; + return CLuaHandle::HasCallIn(L, name); } void CLuaUI::UpdateTeams() { if (luaUI) { - luaUI->SetFullCtrl(gs->godMode, true); + luaUI->SetFullCtrl(gs->godMode); luaUI->SetCtrlTeam(gs->godMode ? AllAccessTeam : - (gu->spectating ? NoAccessTeam : gu->myTeam), true); - luaUI->SetFullRead(gu->spectatingFullView, true); - luaUI->SetReadTeam(luaUI->GetFullRead() ? AllAccessTeam : gu->myTeam, true); - luaUI->SetReadAllyTeam(luaUI->GetFullRead() ? AllAccessTeam : gu->myAllyTeam, true); - luaUI->SetSelectTeam(gu->spectatingFullSelect ? AllAccessTeam : gu->myTeam, true); + (gu->spectating ? NoAccessTeam : gu->myTeam)); + luaUI->SetFullRead(gu->spectatingFullView); + luaUI->SetReadTeam(luaUI->GetFullRead() ? AllAccessTeam : gu->myTeam); + luaUI->SetReadAllyTeam(luaUI->GetFullRead() ? AllAccessTeam : gu->myAllyTeam); + luaUI->SetSelectTeam(gu->spectatingFullSelect ? AllAccessTeam : gu->myTeam); } } @@ -344,10 +310,8 @@ lua_rawset(L, -3) REGISTER_LUA_CFUNC(SetShockFrontFactors); - REGISTER_LUA_CFUNC(SendToUnsynced); lua_setglobal(L, "Spring"); - return true; } @@ -355,37 +319,22 @@ /******************************************************************************/ /******************************************************************************/ -void CLuaUI::Shutdown() -{ - LUA_CALL_IN_CHECK(L); - luaL_checkstack(L, 2, __FUNCTION__); - static const LuaHashString cmdStr("Shutdown"); - if (!cmdStr.GetGlobalFunc(L)) { - return; - } - - // call the routine - RunCallIn(cmdStr, 0, 0); - - return; -} - - -bool CLuaUI::ConfigCommand(const string& command) +bool CLuaUI::ConfigCommand(const string& command) //FIXME rename to fit event name { LUA_CALL_IN_CHECK(L, true); luaL_checkstack(L, 2, __FUNCTION__); static const LuaHashString cmdStr("ConfigureLayout"); if (!cmdStr.GetGlobalFunc(L)) { - return true; // the call is not defined + return false; // the call is not defined } - lua_pushstring(L, command.c_str()); + lua_pushsstring(L, command); // call the routine - if (!RunCallIn(cmdStr, 1, 0)) { + if (!RunCallIn(L, cmdStr, 1, 0)) { return false; } + return true; } @@ -406,25 +355,19 @@ float3 gap = (camera->GetPos() - pos); -#if defined(USE_GML) && GML_ENABLE_SIM - // WTF? - const float shockFrontDistMod = (GML::Enabled() && distMod != NULL)? *distMod : this->shockFrontDistAdj; -#else const float shockFrontDistMod = this->shockFrontDistAdj; -#endif float dist = gap.Length() + shockFrontDistMod; if ((power /= (dist * dist)) < shockFrontMinPower && distMod == NULL) return; - LUA_UI_BATCH_PUSH(, UIShockFrontEvent(pos, power, areaOfEffect, shockFrontDistMod)) LUA_CALL_IN_CHECK(L); luaL_checkstack(L, 6, __FUNCTION__); static const LuaHashString cmdStr("ShockFront"); if (!cmdStr.GetGlobalFunc(L)) { - haveShockFront = false; + haveShockFront = false; //FIXME improve in GameHelper.cpp and pipe instead through eventHandler? return; // the call is not defined } @@ -442,7 +385,7 @@ lua_pushnumber(L, dir.z); // call the routine - if (!RunCallIn(cmdStr, 4, 0)) { + if (!RunCallIn(L, cmdStr, 4, 0)) { return; } @@ -450,60 +393,8 @@ } -void CLuaUI::ExecuteUIEventBatch() { - if (!UseEventBatch()) - return; - - std::vector lleb; - { - GML_STDMUTEX_LOCK(llbatch); // ExecuteUIEventBatch - - if (luaUIEventBatch.empty()) - return; - - luaUIEventBatch.swap(lleb); - } - - GML_SELECT_LUA_STATE(); - GML_DRCMUTEX_LOCK(lua); // ExecuteUIEventBatch - - if (Threading::IsSimThread()) - Threading::SetLuaBatchThread(false); - - for (std::vector::iterator i = lleb.begin(); i != lleb.end(); ++i) { - const UIEventBase& e = *i; - switch (e.GetID()) { - case SHOCK_FRONT: { - LUA_EVENT_CAST(UIShockFrontEvent, e); ShockFront(ee.GetPos(), ee.GetPower(), ee.GetAreaOfEffect(), ee.GetDistMod()); - } break; - default: { - LOG_L(L_ERROR, "%s: Invalid Event %d", __FUNCTION__, e.GetID()); - } break; - } - } - - if (Threading::IsSimThread()) - Threading::SetLuaBatchThread(true); -} - /******************************************************************************/ -bool CLuaUI::HasLayoutButtons() -{ - SELECT_LUA_STATE(); - GML_DRCMUTEX_LOCK(lua); // HasLayoutButtons - - luaL_checkstack(L, 2, __FUNCTION__); - - static const LuaHashString cmdStr("LayoutButtons"); - if (!cmdStr.GetGlobalFunc(L)) { - return false; // the call is not defined - } - lua_pop(L, 1); - return true; -} - - bool CLuaUI::LayoutButtons(int& xButtons, int& yButtons, const vector& cmds, vector& removeCmds, @@ -525,10 +416,6 @@ buttonList.clear(); menuName = ""; - GML_THRMUTEX_LOCK(unit, GML_DRAW); // LayoutButtons - GML_THRMUTEX_LOCK(feat, GML_DRAW); // LayoutButtons -// GML_THRMUTEX_LOCK(proj, GML_DRAW); // LayoutButtons - LUA_CALL_IN_CHECK(L, false); luaL_checkstack(L, 6, __FUNCTION__); const int top = lua_gettop(L); @@ -548,7 +435,7 @@ } // call the function - if (!RunCallIn(cmdStr, 4, LUA_MULTRET)) { + if (!RunCallIn(L, cmdStr, 4, LUA_MULTRET)) { lua_settop(L, top); return false; } @@ -829,109 +716,6 @@ /******************************************************************************/ /******************************************************************************/ // -// Custom Call-in -// - -bool CLuaUI::HasUnsyncedXCall(lua_State* srcState, const string& funcName) -{ - SELECT_LUA_STATE(); -#if (LUA_MT_OPT & LUA_MUTEX) - if (GML::Enabled() && srcState != L && SingleState()) { - GML_STDMUTEX_LOCK(xcall); // HasUnsyncedXCall - - return unsyncedXCalls.find(funcName) != unsyncedXCalls.end(); - } -#endif - - lua_getglobal(L, funcName.c_str()); - const bool haveFunc = lua_isfunction(L, -1); - lua_pop(L, 1); - return haveFunc; -} - - -int CLuaUI::UnsyncedXCall(lua_State* srcState, const string& funcName) -{ -#if (LUA_MT_OPT & LUA_MUTEX) - if (GML::Enabled()) { - SELECT_UNSYNCED_LUA_STATE(); - if (srcState != L) { - DelayDataDump ddmp; - - LuaUtils::ShallowDataDump sdd; - sdd.type = LUA_TSTRING; - sdd.data.str = new std::string; - *sdd.data.str = funcName; - - ddmp.data.push_back(sdd); - - LuaUtils::Backup(ddmp.dump, srcState, lua_gettop(srcState)); - - lua_settop(srcState, 0); - - GML_STDMUTEX_LOCK(scall); // UnsyncedXCall - - delayedCallsFromSynced.push_back(DelayDataDump()); - - DelayDataDump &ddb = delayedCallsFromSynced.back(); - ddb.data.swap(ddmp.data); - ddb.dump.swap(ddmp.dump); - ddb.xcall = true; - - return 0; - } - } -#endif - - LUA_CALL_IN_CHECK(L, 0); - const LuaHashString funcHash(funcName); - if (!funcHash.GetGlobalFunc(L)) { - return 0; - } - - const int top = lua_gettop(L) - 1; // do not count the function - - const bool diffStates = (srcState != L); - - int retCount; - - if (!diffStates) { - lua_insert(L, 1); // move the function to the beginning - // call the function - if (!RunCallIn(funcHash, top, LUA_MULTRET)) { - return 0; - } - retCount = lua_gettop(L); - } - else { - const int srcCount = lua_gettop(srcState); - - LuaUtils::CopyData(L, srcState, srcCount); - const bool origDrawingState = LuaOpenGL::IsDrawingEnabled(L); - LuaOpenGL::SetDrawingEnabled(L, LuaOpenGL::IsDrawingEnabled(srcState)); - - // call the function - if (!RunCallIn(funcHash, srcCount, LUA_MULTRET)) { - LuaOpenGL::SetDrawingEnabled(L, origDrawingState); - return 0; - } - LuaOpenGL::SetDrawingEnabled(L, origDrawingState); - retCount = lua_gettop(L) - top; - - lua_settop(srcState, 0); - if (retCount > 0) { - LuaUtils::CopyData(srcState, L, retCount); - } - lua_settop(L, top); - } - - return retCount; -} - - -/******************************************************************************/ -/******************************************************************************/ -// // Lua Callbacks // @@ -953,34 +737,5 @@ return 0; } -int CLuaUI::UpdateUnsyncedXCalls(lua_State* L) -{ -#if (LUA_MT_OPT & LUA_MUTEX) - if (!GML::Enabled() || !SingleState() || L != L_Sim) -#endif - return 0; - - GML_STDMUTEX_LOCK(xcall); // UpdateUnsyncedXCalls - - unsyncedXCalls.clear(); - - for (lua_pushnil(L); lua_next(L, LUA_GLOBALSINDEX) != 0; lua_pop(L, 1)) { - const int ktype = lua_type(L, -2); - const int vtype = lua_type(L, -1); - if (ktype == LUA_TSTRING && vtype == LUA_TFUNCTION) { - size_t len = 0; - const char* data = lua_tolstring(L, -2, &len); - if (len > 0) { - std::string name; - name.resize(len); - memcpy(&name[0], data, len); - unsyncedXCalls.insert(name); - } - } - } - - return 0; -} - /******************************************************************************/ /******************************************************************************/ diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaUI.h spring-98.0~14.04~ppa6/rts/Lua/LuaUI.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaUI.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaUI.h 2014-10-07 20:09:51.000000000 +0000 @@ -43,11 +43,6 @@ public: // call-ins bool HasCallIn(lua_State* L, const string& name); - bool UnsyncedUpdateCallIn(lua_State* L, const string& name); - - void Shutdown(); - - bool HasLayoutButtons(); bool LayoutButtons(int& xButtons, int& yButtons, const vector& cmds, @@ -65,34 +60,21 @@ void ShockFront(const float3& pos, float power, float areaOfEffect, const float* distMod = NULL); - public: // custom call-in - bool HasUnsyncedXCall(lua_State* srcState, const string& funcName); - int UnsyncedXCall(lua_State* srcState, const string& funcName); - void ExecuteUIEventBatch(); - protected: CLuaUI(); - ~CLuaUI(); + virtual ~CLuaUI(); string LoadFile(const string& filename) const; bool LoadCFunctions(lua_State* L); + void InitLuaSocket(lua_State* L); - bool BuildCmdDescTable(lua_State* L, - const vector& cmds); - + bool BuildCmdDescTable(lua_State* L, const vector& cmds); bool GetLuaIntMap(lua_State* L, int index, map& intList); - bool GetLuaIntList(lua_State* L, int index, vector& intList); - - bool GetLuaReStringList(lua_State* L, int index, - vector& reStringCmds); - - bool GetLuaReParamsList(lua_State* L, int index, - vector& reParamsCmds); - - bool GetLuaCmdDescList(lua_State* L, int index, - vector& customCmds); + bool GetLuaReStringList(lua_State* L, int index, vector& reStringCmds); + bool GetLuaReParamsList(lua_State* L, int index, vector& reParamsCmds); + bool GetLuaCmdDescList(lua_State* L, int index, vector& customCmds); protected: bool haveShockFront; @@ -102,15 +84,6 @@ private: // call-outs static int SetShockFrontFactors(lua_State* L); - - int UpdateUnsyncedXCalls(lua_State* L); - /** - * initialize luasocket - */ - void InitLuaSocket(lua_State* L); - - std::set unsyncedXCalls; - std::vector luaUIEventBatch; }; diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaUniqueBin.h spring-98.0~14.04~ppa6/rts/Lua/LuaUniqueBin.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaUniqueBin.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaUniqueBin.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,224 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#ifndef LUA_UNIQUE_BIN_H -#define LUA_UNIQUE_BIN_H - -// -// A container that holds unique copies of a data type (with smart references). -// -// Accessing the data for any reference is always valid. -// -// Data Types that use this template must have the following properties: -// -// 1. the 'bool operator<(const T&) const' member function -// -// 2. the 'static T def' static variable that holds default values -// - -#include - - -/******************************************************************************/ -/******************************************************************************/ -// -// UniqueBin -// - -template -class UniqueBin -{ - private: - class Data; - struct SortObj; - - public: - - class Ref; - - typedef std::set DataSet; - typedef typename DataSet::const_iterator const_iterator; - - const_iterator begin() const { - return dataSet.begin(); - } - - const_iterator end() const { - return dataSet.end(); - } - - unsigned int size() const { - return dataSet.size(); - } - - bool empty() const { - return dataSet.empty(); - } - - Ref GetRef(const T& t) { - Data* cmpPtr = (Data*) &t; // note the cast - const_iterator it = dataSet.find(cmpPtr); - if (it != dataSet.end()) { - return Ref(*it); // already in the set - } - Data* data = new Data(t); - dataSet.insert(data); - return Ref(data); - } - - bool Exists(const T& t) const { - Data* cmpPtr = (Data*) &t; // note the cast - const_iterator it = dataSet.find(cmpPtr); - if (it != dataSet.end()) { - return true; - } - return false; - } - - static UniqueBin handler; - - private: - struct SortObj - { - bool operator()(const Data* a, const Data* b) { - return (*a < *b); - } - }; - - private: - typedef typename DataSet::iterator iterator; - - private: - UniqueBin() { - defData = new Data(T::def); - defData->Ref(); // make it permanent - dataSet.insert(defData); - } - - ~UniqueBin() { - defData->UnRef(); - for (iterator it = dataSet.begin(); it != dataSet.end(); ++it) { - delete *it; - } - } - - void EraseData(Data* data) { - dataSet.erase(data); - delete data; - } - - private: - Data* defData; - DataSet dataSet; - -/******************************************************************************/ -// -// Ref -// - - public: - class Ref { - - friend Ref UniqueBin::GetRef(const T& t); // for Ref(Data*) access - - public: - Ref() { - dataPtr = UniqueBin::handler.defData; - } - - const T& operator*() const { - return (**dataPtr); - } - - const T* operator->() const { - return &(**dataPtr); - } - - bool operator==(const Ref& r) const { - return dataPtr == r.dataPtr; - } - - bool operator!=(const Ref& r) const { - return dataPtr != r.dataPtr; - } - - void Reset() { - dataPtr->UnRef(); - dataPtr = UniqueBin::handler->defData; - dataPtr->Ref(); - } - - ~Ref() { - dataPtr->UnRef(); - }; - - Ref(const Ref& r) { - dataPtr = r.dataPtr; - dataPtr->Ref(); - } - - Ref& operator=(const Ref& r) { - if (dataPtr != r.dataPtr) { - dataPtr->UnRef(); - dataPtr = r.dataPtr; - dataPtr->Ref(); - } - return *this; - } - - private: - Ref(Data* dp) { - dataPtr = dp; - dataPtr->Ref(); - } - - private: - Data* dataPtr; - }; - -/******************************************************************************/ -// -// Data -// - - private: - class Data { - public: - bool operator<(const Data& d) const { - return (data < d.data); - } - - const T& operator*() const { - return data; - } - - void Ref() { - refCount++; - } - - void UnRef() { - refCount--; - if (refCount <= 0) { - UniqueBin::handler.EraseData(this); - } - } - - Data(const T& t) - : data(t), refCount(0) {} - - private: - T data; // NOTE: must come first - unsigned int refCount; - }; -}; - -/******************************************************************************/ -/******************************************************************************/ - - -template UniqueBin UniqueBin::handler; - - -/******************************************************************************/ -/******************************************************************************/ - -#endif // LUA_UNIQUE_BIN_H diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaUnitDefs.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaUnitDefs.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaUnitDefs.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaUnitDefs.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -13,6 +13,7 @@ #include "LuaInclude.h" +#include "LuaConfig.h" #include "LuaDefs.h" #include "LuaHandle.h" #include "LuaUtils.h" @@ -27,6 +28,7 @@ #include "Sim/Features/Feature.h" #include "Sim/Features/FeatureHandler.h" #include "Sim/Misc/CategoryHandler.h" +#include "Sim/Misc/CollisionVolume.h" #include "Sim/Misc/LosHandler.h" #include "Sim/Misc/QuadField.h" #include "Sim/Misc/Wind.h" @@ -160,26 +162,26 @@ const void* userData = lua_touserdata(L, lua_upvalueindex(1)); const UnitDef* ud = static_cast(userData); const DataElement& elem = it->second; - const char* p = ((const char*)ud) + elem.offset; + const void* p = ((const char*)ud) + elem.offset; switch (elem.type) { case READONLY_TYPE: { lua_rawget(L, 1); return 1; } case INT_TYPE: { - lua_pushnumber(L, *((int*)p)); + lua_pushnumber(L, *reinterpret_cast(p)); return 1; } case BOOL_TYPE: { - lua_pushboolean(L, *((bool*)p)); + lua_pushboolean(L, *reinterpret_cast(p)); return 1; } case FLOAT_TYPE: { - lua_pushnumber(L, *((float*)p)); + lua_pushnumber(L, *reinterpret_cast(p)); return 1; } case STRING_TYPE: { - lua_pushsstring(L, *((string*)p)); + lua_pushsstring(L, *reinterpret_cast(p)); return 1; } case FUNCTION_TYPE: { @@ -224,7 +226,7 @@ // Definition editing const DataElement& elem = it->second; - const char* p = ((const char*)ud) + elem.offset; + const void* p = ((const char*)ud) + elem.offset; switch (elem.type) { case FUNCTION_TYPE: @@ -551,6 +553,38 @@ return 1; } + +static int ColVolTable(lua_State* L, const void* data) { + auto cv = static_cast(data); + assert(cv != NULL); + + lua_newtable(L); + switch (cv->GetVolumeType()) { + case CollisionVolume::COLVOL_TYPE_ELLIPSOID: + HSTR_PUSH_STRING(L, "type", "ellipsoid"); + break; + case CollisionVolume::COLVOL_TYPE_CYLINDER: + HSTR_PUSH_STRING(L, "type", "cylinder"); + break; + case CollisionVolume::COLVOL_TYPE_BOX: + HSTR_PUSH_STRING(L, "type", "box"); + break; + } + + LuaPushNamedNumber(L, "scaleX", cv->GetScales().x); + LuaPushNamedNumber(L, "scaleY", cv->GetScales().y); + LuaPushNamedNumber(L, "scaleZ", cv->GetScales().z); + LuaPushNamedNumber(L, "offsetX", cv->GetOffsets().x); + LuaPushNamedNumber(L, "offsetY", cv->GetOffsets().y); + LuaPushNamedNumber(L, "offsetZ", cv->GetOffsets().z); + LuaPushNamedNumber(L, "boundingRadius", cv->GetBoundingRadius()); + LuaPushNamedBool(L, "defaultToSphere", cv->DefaultToSphere()); + LuaPushNamedBool(L, "defaultToFootPrint", cv->DefaultToFootPrint()); + LuaPushNamedBool(L, "defaultToPieceTree", cv->DefaultToPieceTree()); + return 1; +} + + #define TYPE_FUNC(FuncName, LuaType) \ static int FuncName(lua_State* L, const void* data) \ { \ @@ -568,32 +602,32 @@ return 1; \ } -TYPE_FUNC(IsTransportUnit, boolean); -TYPE_FUNC(IsImmobileUnit, boolean); -TYPE_FUNC(IsBuildingUnit, boolean); -TYPE_FUNC(IsBuilderUnit, boolean); -TYPE_FUNC(IsMobileBuilderUnit, boolean); -TYPE_FUNC(IsStaticBuilderUnit, boolean); -TYPE_FUNC(IsFactoryUnit, boolean); -TYPE_FUNC(IsExtractorUnit, boolean); -TYPE_FUNC(IsGroundUnit, boolean); -TYPE_FUNC(IsAirUnit, boolean); -TYPE_FUNC(IsStrafingAirUnit, boolean); -TYPE_FUNC(IsHoveringAirUnit, boolean); -TYPE_FUNC(IsFighterAirUnit, boolean); -TYPE_FUNC(IsBomberAirUnit, boolean); - -TYPE_MODEL_FUNC(ModelHeight, height); -TYPE_MODEL_FUNC(ModelRadius, radius); -TYPE_MODEL_FUNC(ModelMinx, mins.x); -TYPE_MODEL_FUNC(ModelMidx, relMidPos.x); -TYPE_MODEL_FUNC(ModelMaxx, maxs.x); -TYPE_MODEL_FUNC(ModelMiny, mins.y); -TYPE_MODEL_FUNC(ModelMidy, relMidPos.y); -TYPE_MODEL_FUNC(ModelMaxy, maxs.y); -TYPE_MODEL_FUNC(ModelMinz, mins.z); -TYPE_MODEL_FUNC(ModelMidz, relMidPos.z); -TYPE_MODEL_FUNC(ModelMaxz, maxs.z); +TYPE_FUNC(IsTransportUnit, boolean) +TYPE_FUNC(IsImmobileUnit, boolean) +TYPE_FUNC(IsBuildingUnit, boolean) +TYPE_FUNC(IsBuilderUnit, boolean) +TYPE_FUNC(IsMobileBuilderUnit, boolean) +TYPE_FUNC(IsStaticBuilderUnit, boolean) +TYPE_FUNC(IsFactoryUnit, boolean) +TYPE_FUNC(IsExtractorUnit, boolean) +TYPE_FUNC(IsGroundUnit, boolean) +TYPE_FUNC(IsAirUnit, boolean) +TYPE_FUNC(IsStrafingAirUnit, boolean) +TYPE_FUNC(IsHoveringAirUnit, boolean) +TYPE_FUNC(IsFighterAirUnit, boolean) +TYPE_FUNC(IsBomberAirUnit, boolean) + +TYPE_MODEL_FUNC(ModelHeight, height) +TYPE_MODEL_FUNC(ModelRadius, radius) +TYPE_MODEL_FUNC(ModelMinx, mins.x) +TYPE_MODEL_FUNC(ModelMidx, relMidPos.x) +TYPE_MODEL_FUNC(ModelMaxx, maxs.x) +TYPE_MODEL_FUNC(ModelMiny, mins.y) +TYPE_MODEL_FUNC(ModelMidy, relMidPos.y) +TYPE_MODEL_FUNC(ModelMaxy, maxs.y) +TYPE_MODEL_FUNC(ModelMinz, mins.z) +TYPE_MODEL_FUNC(ModelMidz, relMidPos.z) +TYPE_MODEL_FUNC(ModelMaxz, maxs.z) @@ -667,6 +701,7 @@ ADD_FUNCTION("shieldWeaponDef", ud.shieldWeaponDef, WeaponDefToID); ADD_FUNCTION("stockpileWeaponDef", ud.stockpileWeaponDef, WeaponDefToID); ADD_FUNCTION("iconType", ud.iconType, SafeIconType); + ADD_FUNCTION("collisionVolume", ud.collisionVolume, ColVolTable); ADD_FUNCTION("isTransport", ud, IsTransportUnit); ADD_FUNCTION("isImmobile", ud, IsImmobileUnit); @@ -695,6 +730,8 @@ ADD_FUNCTION("midz", ud, ModelMidz); ADD_FUNCTION("maxz", ud, ModelMaxz); + + ADD_INT("id", ud.id); ADD_INT("cobID", ud.cobID); diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaUnitRendering.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaUnitRendering.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaUnitRendering.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaUnitRendering.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -10,8 +10,6 @@ #include "LuaHashString.h" #include "LuaUtils.h" -#include "lib/gml/gmlmut.h" - #include "Rendering/UnitDrawer.h" #include "Rendering/Textures/3DOTextureHandler.h" #include "Rendering/Textures/S3OTextureHandler.h" @@ -120,8 +118,6 @@ if (unit == NULL) { return 0; } - GML_LODMUTEX_LOCK(unit); // SetLODLength - const unsigned int lod = (unsigned int)luaL_checknumber(L, 2) - 1; if (lod >= unit->lodCount) { return 0; @@ -137,9 +133,6 @@ if (unit == NULL) { return 0; } - - GML_LODMUTEX_LOCK(unit); // SetLODDistance - const unsigned int lod = (unsigned int)luaL_checknumber(L, 2) - 1; if (lod >= unit->lodCount) { return 0; @@ -161,8 +154,6 @@ return 0; } - GML_LODMUTEX_LOCK(unit); // SetPieceList - const LocalModel* localModel = unit->localModel; const unsigned int lod = (unsigned int)luaL_checknumber(L, 2) - 1; @@ -555,8 +546,6 @@ return 0; } - GML_LODMUTEX_LOCK(unit); // SetMaterial - const unsigned int lod = (unsigned int)luaL_checknumber(L, 2) - 1; const string matName = luaL_checkstring(L, 3); const LuaMatType matType = ParseMaterialType(matName); @@ -587,8 +576,6 @@ return 0; } - GML_LODMUTEX_LOCK(unit); // SetMaterialLastLod - const string matName = luaL_checkstring(L, 2); LuaUnitMaterial* unitMat = GetUnitMaterial(unit, matName); if (unitMat == NULL) { @@ -607,8 +594,6 @@ return 0; } - GML_LODMUTEX_LOCK(unit); // SetMaterialDisplayLists - const unsigned int lod = (unsigned int)luaL_checknumber(L, 2) - 1; const string matName = luaL_checkstring(L, 3); LuaUnitMaterial* unitMat = GetUnitMaterial(unit, matName); @@ -633,8 +618,6 @@ return 0; } - GML_LODMUTEX_LOCK(unit); // SetUnitUniform - const string matName = luaL_checkstring(L, 2); LuaUnitMaterial* unitMat = GetUnitMaterial(unit, matName); if (unitMat == NULL) { @@ -696,8 +679,6 @@ static void PrintUnitLOD(CUnit* unit, int lod) { - GML_LODMUTEX_LOCK(unit); // PrintUnitLOD - LOG(" LOD %i:", lod); LOG(" LodLength = %f", unit->lodLengths[lod]); for (int type = 0; type < LUAMAT_TYPE_COUNT; type++) { @@ -723,8 +704,6 @@ return 0; } - GML_LODMUTEX_LOCK(unit); // Debug - LOG_L(L_DEBUG, "%s", ""); LOG_L(L_DEBUG, "UnitID = %i", unit->id); LOG_L(L_DEBUG, "UnitDefID = %i", unit->unitDef->id); diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaUnsyncedCall.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaUnsyncedCall.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaUnsyncedCall.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaUnsyncedCall.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,114 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - - -#include "LuaUnsyncedCall.h" - -#include "LuaInclude.h" - -#include "LuaHandle.h" -#include "LuaGaia.h" -#include "LuaRules.h" -#include "LuaHashString.h" -#include "LuaUI.h" -#include "LuaUtils.h" - -#include -#include -#include - - -/******************************************************************************/ -/******************************************************************************/ - -static int HandleXCall(lua_State* L) -{ - const int addrIndex = lua_upvalueindex(1); - const int nameIndex = lua_upvalueindex(2); - - if (!lua_isuserdata(L, addrIndex) || !lua_israwstring(L, nameIndex)) { - luaL_error(L, "Bad function name type"); - } - - CLuaHandle** addr = (CLuaHandle**) lua_touserdata(L, addrIndex); - if (*addr == NULL) { - return 0; // handle is not currently active - } - CLuaHandle* lh = *addr; - - const char* funcName = lua_tostring(L, nameIndex); - - return lh->UnsyncedXCall(L, funcName); -} - - -static int IndexHook(lua_State* L) -{ - CLuaHandle** addr = (CLuaHandle**) lua_touserdata(L, lua_upvalueindex(1)); - if (!lua_israwstring(L, 2)) { - return 0; // missing string name for function - } - lua_pushlightuserdata(L, addr); - lua_pushstring(L, lua_tostring(L, 2)); - lua_pushcclosure(L, HandleXCall, 2); - return 1; -} - - -static int CallHook(lua_State* L) -{ - CLuaHandle** addr = (CLuaHandle**) lua_touserdata(L, lua_upvalueindex(1)); - const int args = lua_gettop(L); // arg 1 is the table - if (args <= 1) { - // is the handle currently active? - lua_pushboolean(L, (*addr != NULL)); - return 1; - } - else if ((args >= 2) && lua_israwstring(L, 2)) { - // see if the specified function exists - const string funcName = lua_tostring(L, 2); - CLuaHandle* lh = *addr; - if (lh == NULL) { - return 0; // not running - } - lua_pushboolean(L, lh->HasUnsyncedXCall(L, funcName)); - return 1; - } - return 0; -} - - -static int PushCallHandler(lua_State* L, CLuaHandle** addr, const string& name) -{ - lua_pushsstring(L, name); - CLuaHandle*** ptr = (CLuaHandle***) lua_newuserdata(L, sizeof(CLuaHandle**)); - *ptr = addr; - lua_newtable(L); { - lua_pushliteral(L, "__index"); - lua_pushlightuserdata(L, addr); - lua_pushcclosure(L, IndexHook, 1); - lua_rawset(L, -3); - lua_pushliteral(L, "__call"); - lua_pushlightuserdata(L, addr); - lua_pushcclosure(L, CallHook, 1); - lua_rawset(L, -3); - lua_pushliteral(L, "__metatable"); - lua_pushliteral(L, "can't touch this"); - lua_rawset(L, -3); - } - lua_setmetatable(L, -2); // set the userdata's metatable - lua_rawset(L, -3); - return 0; -} - - -bool LuaUnsyncedCall::PushEntries(lua_State* L) -{ - PushCallHandler(L, (CLuaHandle**) &luaGaia, "LuaGaia"); - PushCallHandler(L, (CLuaHandle**) &luaRules, "LuaRules"); - PushCallHandler(L, (CLuaHandle**) &luaUI, "LuaUI"); - return true; -} - - -/******************************************************************************/ -/******************************************************************************/ diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaUnsyncedCall.h spring-98.0~14.04~ppa6/rts/Lua/LuaUnsyncedCall.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaUnsyncedCall.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaUnsyncedCall.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#ifndef LUA_UNSYNCED_CALL_H -#define LUA_UNSYNCED_CALL_H - -struct lua_State; - -class LuaUnsyncedCall { - public: - static bool PushEntries(lua_State* L); -}; - - -#endif /* LUA_UNSYNCED_CALL_H */ diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaUnsyncedCtrl.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaUnsyncedCtrl.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaUnsyncedCtrl.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaUnsyncedCtrl.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -59,7 +59,7 @@ #include "System/Net/PackPacket.h" #include "System/Util.h" #include "System/Sound/ISound.h" -#include "System/Sound/SoundChannels.h" +#include "System/Sound/ISoundChannels.h" #include "System/FileSystem/FileHandler.h" #include "System/FileSystem/DataDirLocater.h" #include "System/FileSystem/FileSystem.h" @@ -68,12 +68,9 @@ #include #include "System/Platform/Misc.h" -#include "LuaHelper.h" -#if !defined(HEADLESS) && !defined(NO_SOUND) - #include "System/Sound/EFX.h" - #include "System/Sound/EFXPresets.h" -#endif +#include "System/Sound/OpenAL/EFX.h" +#include "System/Sound/OpenAL/EFXPresets.h" #include #include @@ -82,7 +79,7 @@ #include -#include +#include #include using std::min; @@ -204,6 +201,8 @@ REGISTER_LUA_CFUNC(SetMouseCursor); REGISTER_LUA_CFUNC(WarpMouse); + REGISTER_LUA_CFUNC(SetClipboard); + REGISTER_LUA_CFUNC(SetCameraOffset); REGISTER_LUA_CFUNC(UpdateInfoTexture); @@ -357,11 +356,6 @@ glLineWidth(cmdColors.QueuedLineWidth()); - GML_RECMUTEX_LOCK(unit); // DrawUnitCommandQueues - GML_RECMUTEX_LOCK(feat); // DrawUnitCommandQueues - GML_STDMUTEX_LOCK(cai); // DrawUnitCommandQueues - GML_STDMUTEX_LOCK(dque); // DrawUnitCommandQueues - std::set::const_iterator ui; for (ui = drawCmdQueueUnits.begin(); ui != drawCmdQueueUnits.end(); ++ui) { @@ -381,8 +375,6 @@ void LuaUnsyncedCtrl::ClearUnitCommandQueues() { - GML_STDMUTEX_LOCK(dque); // ClearUnitCommandQueues - drawCmdQueueUnits.clear(); } @@ -527,7 +519,7 @@ } //! last argument (with and without pos/speed arguments) is the optional `sfx channel` - AudioChannelImpl* channel = &Channels::General; + IAudioChannel** channel = &Channels::General; if (args >= index) { if (lua_isstring(L, index)) { string channelStr = lua_tostring(L, index); @@ -559,12 +551,12 @@ if (pos_given) { if (speed_given) { - channel->PlaySample(soundID, pos, speed, volume); + channel[0]->PlaySample(soundID, pos, speed, volume); } else { - channel->PlaySample(soundID, pos, volume); + channel[0]->PlaySample(soundID, pos, volume); } } else - channel->PlaySample(soundID, volume); + channel[0]->PlaySample(soundID, volume); success = true; } @@ -584,7 +576,7 @@ const float volume = luaL_optnumber(L, 2, 1.0f); bool enqueue = luaL_optboolean(L, 3, false); - Channels::BGMusic.StreamPlay(soundFile, volume, enqueue); + Channels::BGMusic->StreamPlay(soundFile, volume, enqueue); // .ogg files don't have sound ID's generated // for them (yet), so we always succeed here @@ -598,17 +590,17 @@ int LuaUnsyncedCtrl::StopSoundStream(lua_State*) { - Channels::BGMusic.StreamStop(); + Channels::BGMusic->StreamStop(); return 0; } int LuaUnsyncedCtrl::PauseSoundStream(lua_State*) { - Channels::BGMusic.StreamPause(); + Channels::BGMusic->StreamPause(); return 0; } int LuaUnsyncedCtrl::SetSoundStreamVolume(lua_State* L) { - Channels::BGMusic.SetVolume(luaL_checkfloat(L, 1)); + Channels::BGMusic->SetVolume(luaL_checkfloat(L, 1)); return 0; } @@ -764,8 +756,6 @@ int LuaUnsyncedCtrl::DrawUnitCommands(lua_State* L) { - GML_STDMUTEX_LOCK(dque); // DrawUnitCommands - if (lua_istable(L, 1)) { const bool isMap = luaL_optboolean(L, 2, false); const int unitArg = isMap ? -2 : -1; @@ -1513,8 +1503,6 @@ int LuaUnsyncedCtrl::SetUnitNoSelect(lua_State* L) { - GML_RECMUTEX_LOCK(sel); // SetUnitNoSelect - if (CLuaHandle::GetHandleUserMode(L)) { return 0; } @@ -1843,6 +1831,17 @@ return 0; } +/******************************************************************************/ + +int LuaUnsyncedCtrl::SetClipboard(lua_State* L) +{ + if (!CLuaHandle::CheckModUICtrl(L)) { + return 0; + } + + SDL_SetClipboardText(luaL_checkstring(L, 1)); + return 0; +} /******************************************************************************/ @@ -2029,7 +2028,7 @@ std::vector processArgs; - // arguments given by Lua code, if any + // arguments to Spring binary given by Lua code, if any if (!springArguments.empty()) { processArgs.push_back(springArguments); } @@ -2037,27 +2036,24 @@ if (!scriptContents.empty()) { // create file 'script.txt' with contents given by Lua code std::ofstream scriptFile(scriptFullName.c_str()); + scriptFile.write(scriptContents.c_str(), scriptContents.size()); scriptFile.close(); processArgs.push_back(scriptFullName); } + LOG("[Spring.%s] Spring \"%s\" should be restarting", __FUNCTION__, springFullName.c_str()); + #ifdef _WIN32 - // else OpenAL crashes when using execvp - ISound::Shutdown(); + // else OpenAL crashes when using execvp + ISound::Shutdown(); #endif - const std::string execError = Platform::ExecuteProcess(springFullName, processArgs); - - if (execError.empty()) { - LOG("[Spring.%s] the game should be restarting", __FUNCTION__); - lua_pushboolean(L, true); - } else { - LOG_L(L_ERROR, "[Spring.%s] error %s", __FUNCTION__, execError.c_str()); - lua_pushboolean(L, false); - } + Platform::ExecuteProcess(springFullName, processArgs); + // not reached on success + lua_pushboolean(L, false); return 1; } @@ -2079,10 +2075,7 @@ int LuaUnsyncedCtrl::SetWMCaption(lua_State* L) { const std::string title = luaL_checksstring(L, 1); - const std::string titleShort = luaL_optsstring(L, 2, title); - - WindowManagerHelper::SetCaption(title, titleShort); - + WindowManagerHelper::SetCaption(title); return 0; } @@ -2165,8 +2158,6 @@ int LuaUnsyncedCtrl::SetUnitGroup(lua_State* L) { - GML_RECMUTEX_LOCK(group); // SetUnitGroup - if (!CLuaHandle::CheckModUICtrl(L)) { return 0; } @@ -2761,9 +2752,9 @@ luaL_checkstack(L, 2, __FUNCTION__); lua_pushboolean(L, eoh->SendLuaMessages(aiTeam, inData, outData)); - lua_createtable(L, outData.size(), 0); // push the AI response(s) + lua_createtable(L, outData.size(), 0); for (unsigned int n = 0; n < outData.size(); n++) { lua_pushstring(L, outData[n]); lua_rawseti(L, -2, n + 1); diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaUnsyncedCtrl.h spring-98.0~14.04~ppa6/rts/Lua/LuaUnsyncedCtrl.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaUnsyncedCtrl.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaUnsyncedCtrl.h 2014-10-07 20:09:51.000000000 +0000 @@ -114,6 +114,7 @@ static int WarpMouse(lua_State* L); static int SetMouseCursor(lua_State* L); + static int SetClipboard(lua_State* L); static int SetCameraOffset(lua_State* L); diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaUnsyncedRead.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaUnsyncedRead.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaUnsyncedRead.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaUnsyncedRead.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -40,6 +40,7 @@ #include "Sim/Features/FeatureHandler.h" #include "Sim/Misc/TeamHandler.h" #include "Sim/Misc/QuadField.h" +#include "Sim/Projectiles/Projectile.h" #include "Sim/Units/Unit.h" #include "Sim/Units/UnitHandler.h" #include "Sim/Units/UnitTypes/TransportUnit.h" @@ -54,19 +55,21 @@ #include "System/LoadSave/demofile.h" #include "System/LoadSave/DemoReader.h" #include "System/Log/DefaultFilter.h" -#include "System/Sound/SoundChannels.h" +#include "System/Platform/SDL1_keysym.h" +#include "System/Sound/ISoundChannels.h" #include "System/Misc/SpringTime.h" #if !defined(HEADLESS) && !defined(NO_SOUND) - #include "System/Sound/EFX.h" - #include "System/Sound/EFXPresets.h" + #include "System/Sound/OpenAL/EFX.h" + #include "System/Sound/OpenAL/EFXPresets.h" #endif #include #include #include -#include +#include +#include #include const int CMD_INDEX_OFFSET = 1; // starting index for command descriptions @@ -81,6 +84,11 @@ lua_pushcfunction(L, x); \ lua_rawset(L, -3) +#define REGISTER_NAMED_LUA_CFUNC(x,name) \ + lua_pushstring(L, #name); \ + lua_pushcfunction(L, x); \ + lua_rawset(L, -3) + REGISTER_LUA_CFUNC(IsReplay); REGISTER_LUA_CFUNC(GetReplayLength); REGISTER_LUA_CFUNC(GetModUICtrl); @@ -96,6 +104,7 @@ REGISTER_LUA_CFUNC(GetMiniMapGeometry); REGISTER_LUA_CFUNC(GetMiniMapDualScreen); REGISTER_LUA_CFUNC(IsAboveMiniMap); + REGISTER_LUA_CFUNC(IsGUIHidden); REGISTER_LUA_CFUNC(IsAABBInView); REGISTER_LUA_CFUNC(IsSphereInView); @@ -125,6 +134,11 @@ REGISTER_LUA_CFUNC(GetLocalPlayerID); REGISTER_LUA_CFUNC(GetLocalTeamID); REGISTER_LUA_CFUNC(GetLocalAllyTeamID); + + REGISTER_NAMED_LUA_CFUNC(GetLocalPlayerID, GetMyPlayerID); + REGISTER_NAMED_LUA_CFUNC(GetLocalTeamID, GetMyTeamID); + REGISTER_NAMED_LUA_CFUNC(GetLocalAllyTeamID, GetMyAllyTeamID); + REGISTER_LUA_CFUNC(GetSpectatingState); REGISTER_LUA_CFUNC(GetSelectedUnits); @@ -132,7 +146,6 @@ REGISTER_LUA_CFUNC(GetSelectedUnitsCounts); REGISTER_LUA_CFUNC(GetSelectedUnitsCount); - REGISTER_LUA_CFUNC(IsGUIHidden); REGISTER_LUA_CFUNC(HaveShadows); REGISTER_LUA_CFUNC(HaveAdvShading); REGISTER_LUA_CFUNC(GetWaterMode); @@ -155,21 +168,17 @@ REGISTER_LUA_CFUNC(GetSoundStreamTime); REGISTER_LUA_CFUNC(GetSoundEffectParams); - // moved from LuaUI - REGISTER_LUA_CFUNC(GetFPS); + REGISTER_LUA_CFUNC(GetGameSpeed); REGISTER_LUA_CFUNC(GetActiveCommand); REGISTER_LUA_CFUNC(GetDefaultCommand); REGISTER_LUA_CFUNC(GetActiveCmdDescs); REGISTER_LUA_CFUNC(GetActiveCmdDesc); REGISTER_LUA_CFUNC(GetCmdDescIndex); - REGISTER_LUA_CFUNC(GetBuildFacing); REGISTER_LUA_CFUNC(GetBuildSpacing); - REGISTER_LUA_CFUNC(GetGatherMode); - REGISTER_LUA_CFUNC(GetActivePage); REGISTER_LUA_CFUNC(GetMouseState); @@ -181,25 +190,20 @@ REGISTER_LUA_CFUNC(GetPressedKeys); REGISTER_LUA_CFUNC(GetInvertQueueKey); + REGISTER_LUA_CFUNC(GetClipboard); + REGISTER_LUA_CFUNC(GetKeyCode); REGISTER_LUA_CFUNC(GetKeySymbol); REGISTER_LUA_CFUNC(GetKeyBindings); REGISTER_LUA_CFUNC(GetActionHotKeys); REGISTER_LUA_CFUNC(GetLastMessagePositions); - REGISTER_LUA_CFUNC(GetConsoleBuffer); REGISTER_LUA_CFUNC(GetCurrentTooltip); - REGISTER_LUA_CFUNC(GetMyAllyTeamID); - REGISTER_LUA_CFUNC(GetMyTeamID); - REGISTER_LUA_CFUNC(GetMyPlayerID); - + REGISTER_LUA_CFUNC(GetUnitGroup); REGISTER_LUA_CFUNC(GetGroupList); REGISTER_LUA_CFUNC(GetSelectedGroup); - - REGISTER_LUA_CFUNC(GetUnitGroup); - REGISTER_LUA_CFUNC(GetGroupUnits); REGISTER_LUA_CFUNC(GetGroupUnitsSorted); REGISTER_LUA_CFUNC(GetGroupUnitsCounts); @@ -212,7 +216,6 @@ REGISTER_LUA_CFUNC(GetDrawSelectionInfo); REGISTER_LUA_CFUNC(GetConfigParams); - REGISTER_LUA_CFUNC(GetLogSections); return true; @@ -270,15 +273,6 @@ -static inline void CheckNoArgs(lua_State* L, const char* funcName) -{ - const int args = lua_gettop(L); // number of arguments - if (args != 0) { - luaL_error(L, "%s() takes no arguments", funcName); - } -} - - /******************************************************************************/ /******************************************************************************/ // @@ -287,7 +281,6 @@ int LuaUnsyncedRead::IsReplay(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); if (gameSetup && gameSetup->hostDemo) { lua_pushboolean(L, true); } else { @@ -299,7 +292,6 @@ int LuaUnsyncedRead::GetReplayLength(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); if (gameServer && gameServer->GetDemoReader()) { lua_pushnumber(L, gameServer->GetDemoReader()->GetFileHeader().gameTime); return 1; @@ -310,7 +302,6 @@ int LuaUnsyncedRead::GetModUICtrl(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushboolean(L, CLuaHandle::GetModUICtrl()); return 1; } @@ -320,7 +311,6 @@ int LuaUnsyncedRead::GetViewGeometry(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushnumber(L, globalRendering->viewSizeX); lua_pushnumber(L, globalRendering->viewSizeY); lua_pushnumber(L, globalRendering->viewPosX); @@ -331,8 +321,6 @@ int LuaUnsyncedRead::GetWindowGeometry(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); - // origin BOTTOMLEFT const int winPosY_bl = globalRendering->screenSizeY - globalRendering->winSizeY - globalRendering->winPosY; @@ -346,7 +334,6 @@ int LuaUnsyncedRead::GetScreenGeometry(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushnumber(L, globalRendering->screenSizeX); lua_pushnumber(L, globalRendering->screenSizeY); lua_pushnumber(L, 0.0f); @@ -418,7 +405,6 @@ int LuaUnsyncedRead::GetDrawFrame(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushnumber(L, globalRendering->drawFrame & 0xFFFF); lua_pushnumber(L, (globalRendering->drawFrame >> 16) & 0xFFFF); return 2; @@ -427,7 +413,6 @@ int LuaUnsyncedRead::GetFrameTimeOffset(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushnumber(L, globalRendering->timeOffset); return 1; } @@ -435,14 +420,12 @@ int LuaUnsyncedRead::GetLastUpdateSeconds(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushnumber(L, game->updateDeltaSeconds); return 1; } int LuaUnsyncedRead::GetHasLag(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushboolean(L, (game != NULL)? game->IsLagging(luaL_optfloat(L, 1, 500.0f)) : false); return 1; } @@ -500,11 +483,7 @@ static bool UnitIsIcon(const CUnit* unit) { - const float sqDist = (unit->pos - camera->GetPos()).SqLength(); - const float iconLength = unitDrawer->iconLength; - const float iconDistSqrMult = unit->unitDef->iconType->GetDistanceSqr(); - const float realIconLength = iconLength * iconDistSqrMult; - return (sqDist > realIconLength); + return (unitDrawer->DrawAsIcon(unit, (unit->pos - camera->GetPos()).SqLength())); } @@ -554,8 +533,6 @@ int LuaUnsyncedRead::IsUnitSelected(lua_State* L) { - GML_RECMUTEX_LOCK(sel); // IsUnitSelected - CUnit* unit = ParseUnit(L, __FUNCTION__, 1); if (unit == NULL) { return 0; @@ -789,8 +766,6 @@ unsigned int count = 0; { - GML_RECMUTEX_LOCK(quad); // GetVisibleUnits - unitQuadIter.Reset(); readMap->GridVisibility(camera, CQuadField::BASE_QUAD_SIZE / SQUARE_SIZE, 1e9, &unitQuadIter, INT_MAX); @@ -917,8 +892,6 @@ unsigned int count = 0; { - GML_RECMUTEX_LOCK(quad); // GetVisibleFeatures - featureQuadIter.Reset(); readMap->GridVisibility(camera, CQuadField::BASE_QUAD_SIZE / SQUARE_SIZE, 3000.0f * 2.0f, &featureQuadIter, INT_MAX); @@ -998,15 +971,13 @@ static CVisProjectileQuadDrawer projQuadIter; - const bool addSyncedProjectiles = luaL_optboolean(L, 2, true); + /*const bool addSyncedProjectiles =*/ luaL_optboolean(L, 2, true); const bool addWeaponProjectiles = luaL_optboolean(L, 3, true); const bool addPieceProjectiles = luaL_optboolean(L, 4, true); unsigned int count = 0; { - GML_RECMUTEX_LOCK(quad); // GetVisibleProjectiles - projQuadIter.Reset(); readMap->GridVisibility(camera, CQuadField::BASE_QUAD_SIZE / SQUARE_SIZE, 1e9, &projQuadIter, INT_MAX); @@ -1060,7 +1031,6 @@ int LuaUnsyncedRead::GetLocalPlayerID(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushnumber(L, gu->myPlayerNum); return 1; } @@ -1068,7 +1038,6 @@ int LuaUnsyncedRead::GetLocalTeamID(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushnumber(L, gu->myTeam); return 1; } @@ -1076,7 +1045,6 @@ int LuaUnsyncedRead::GetLocalAllyTeamID(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushnumber(L, gu->myAllyTeam); return 1; } @@ -1084,7 +1052,6 @@ int LuaUnsyncedRead::GetSpectatingState(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushboolean(L, gu->spectating); lua_pushboolean(L, gu->spectatingFullView); lua_pushboolean(L, gu->spectatingFullSelect); @@ -1097,10 +1064,6 @@ int LuaUnsyncedRead::GetSelectedUnits(lua_State* L) { - GML_RECMUTEX_LOCK(sel); // GetSelectedUnits - - CheckNoArgs(L, __FUNCTION__); - unsigned int count = 0; const CUnitSet& selUnits = selectedUnitsHandler.selectedUnits; @@ -1118,10 +1081,6 @@ int LuaUnsyncedRead::GetSelectedUnitsSorted(lua_State* L) { - GML_RECMUTEX_LOCK(sel); // GetSelectedUnitsSorted - - CheckNoArgs(L, __FUNCTION__); - map > unitDefMap; map >::const_iterator mit; @@ -1161,10 +1120,6 @@ int LuaUnsyncedRead::GetSelectedUnitsCounts(lua_State* L) { - GML_RECMUTEX_LOCK(sel); // GetSelectedUnitsCounts - - CheckNoArgs(L, __FUNCTION__); - map countMap; map::const_iterator mit; @@ -1199,7 +1154,6 @@ int LuaUnsyncedRead::GetSelectedUnitsCount(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushnumber(L, selectedUnitsHandler.selectedUnits.size()); return 1; } @@ -1210,7 +1164,6 @@ int LuaUnsyncedRead::IsGUIHidden(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); if (game == NULL) { return 0; } @@ -1221,7 +1174,6 @@ int LuaUnsyncedRead::HaveShadows(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); if (shadowHandler == NULL) { return 0; } @@ -1232,7 +1184,6 @@ int LuaUnsyncedRead::HaveAdvShading(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); if (unitDrawer == NULL) { return 0; } @@ -1243,7 +1194,6 @@ int LuaUnsyncedRead::GetWaterMode(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); if (water == NULL) { return 0; } @@ -1259,8 +1209,6 @@ int LuaUnsyncedRead::GetMapDrawMode(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); - switch (readMap->GetGroundDrawer()->GetDrawMode()) { case CBaseGroundDrawer::drawNormal: { HSTR_PUSH(L, "normal" ); break; } case CBaseGroundDrawer::drawHeight: { HSTR_PUSH(L, "height" ); break; } @@ -1325,8 +1273,6 @@ int LuaUnsyncedRead::GetCameraNames(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); - lua_newtable(L); const std::vector& cc = camHandler->GetAvailableControllers(); for (size_t i = 0; i < cc.size(); ++i) { @@ -1341,8 +1287,6 @@ int LuaUnsyncedRead::GetCameraState(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); - lua_newtable(L); lua_pushliteral(L, "name"); @@ -1364,7 +1308,6 @@ int LuaUnsyncedRead::GetCameraPosition(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushnumber(L, camera->GetPos().x); lua_pushnumber(L, camera->GetPos().y); lua_pushnumber(L, camera->GetPos().z); @@ -1374,7 +1317,6 @@ int LuaUnsyncedRead::GetCameraDirection(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushnumber(L, camera->forward.x); lua_pushnumber(L, camera->forward.y); lua_pushnumber(L, camera->forward.z); @@ -1384,7 +1326,6 @@ int LuaUnsyncedRead::GetCameraFOV(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushnumber(L, camera->GetFov()); return 1; } @@ -1392,8 +1333,6 @@ int LuaUnsyncedRead::GetCameraVectors(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); - #define PACK_CAMERA_VECTOR(n) \ HSTR_PUSH(L, #n); \ lua_createtable(L, 3, 0); \ @@ -1457,7 +1396,7 @@ return 2; } } - const float posY = ground->GetHeightReal(pos.x, pos.z, false); + const float posY = CGround::GetHeightReal(pos.x, pos.z, false); lua_pushliteral(L, "ground"); lua_createtable(L, 3, 0); lua_pushnumber(L, pos.x); lua_rawseti(L, -2, 1); @@ -1667,8 +1606,8 @@ int LuaUnsyncedRead::GetSoundStreamTime(lua_State* L) { - lua_pushnumber(L, Channels::BGMusic.StreamGetPlayTime()); - lua_pushnumber(L, Channels::BGMusic.StreamGetTime()); + lua_pushnumber(L, Channels::BGMusic->StreamGetPlayTime()); + lua_pushnumber(L, Channels::BGMusic->StreamGetTime()); return 2; } @@ -1762,7 +1701,6 @@ int LuaUnsyncedRead::GetFPS(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); if (globalRendering) { lua_pushnumber(L, (int)globalRendering->FPS); } else { @@ -1772,16 +1710,22 @@ } +int LuaUnsyncedRead::GetGameSpeed(lua_State* L) +{ + lua_pushnumber(L, gs->wantedSpeedFactor); + lua_pushnumber(L, gs->speedFactor); + lua_pushboolean(L, gs->paused); + return 3; +} + + /******************************************************************************/ int LuaUnsyncedRead::GetActiveCommand(lua_State* L) { - GML_RECMUTEX_LOCK(gui); // GetActiveCommand - if (guihandler == NULL) { return 0; } - CheckNoArgs(L, __FUNCTION__); const vector& cmdDescs = guihandler->commands; const int cmdDescCount = (int)cmdDescs.size(); @@ -1803,12 +1747,9 @@ if (guihandler == NULL) { return 0; } - CheckNoArgs(L, __FUNCTION__); const int defCmd = guihandler->GetDefaultCommand(mouse->lastx, mouse->lasty); - GML_RECMUTEX_LOCK(gui); // GetDefaultCommand - const vector& cmdDescs = guihandler->commands; const int cmdDescCount = (int)cmdDescs.size(); @@ -1825,12 +1766,9 @@ int LuaUnsyncedRead::GetActiveCmdDescs(lua_State* L) { - GML_RECMUTEX_LOCK(gui); // GetActiveCmdDescs - if (guihandler == NULL) { return 0; } - CheckNoArgs(L, __FUNCTION__); const vector& cmdDescs = guihandler->commands; const int cmdDescCount = (int)cmdDescs.size(); @@ -1848,8 +1786,6 @@ int LuaUnsyncedRead::GetActiveCmdDesc(lua_State* L) { - GML_RECMUTEX_LOCK(gui); // GetActiveCmdDesc - if (guihandler == NULL) { return 0; } @@ -1867,8 +1803,6 @@ int LuaUnsyncedRead::GetCmdDescIndex(lua_State* L) { - GML_RECMUTEX_LOCK(gui); // GetCmdDescIndex - if (guihandler == NULL) { return 0; } @@ -1893,7 +1827,6 @@ if (guihandler == NULL) { return 0; } - CheckNoArgs(L, __FUNCTION__); lua_pushnumber(L, guihandler->buildFacing); return 1; } @@ -1904,7 +1837,6 @@ if (guihandler == NULL) { return 0; } - CheckNoArgs(L, __FUNCTION__); lua_pushnumber(L, guihandler->buildSpacing); return 1; } @@ -1915,7 +1847,6 @@ if (guihandler == NULL) { return 0; } - CheckNoArgs(L, __FUNCTION__); lua_pushnumber(L, guihandler->GetGatherMode()); return 1; } @@ -1938,7 +1869,6 @@ int LuaUnsyncedRead::GetMouseState(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushnumber(L, mouse->lastx - globalRendering->viewPosX); lua_pushnumber(L, globalRendering->viewSizeY - mouse->lasty - 1); lua_pushboolean(L, mouse->buttons[SDL_BUTTON_LEFT].pressed); @@ -1950,7 +1880,6 @@ int LuaUnsyncedRead::GetMouseCursor(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushsstring(L, mouse->GetCurrentCursor()); lua_pushnumber(L, mouse->GetCurrentCursorScale()); return 2; @@ -1985,38 +1914,28 @@ int LuaUnsyncedRead::GetKeyState(lua_State* L) { const int key = luaL_checkint(L, 1); - if ((key < 0) || (key >= SDLK_LAST)) { - lua_pushboolean(L, 0); - } else { - lua_pushboolean(L, keyInput->GetKeyState(key)); - } + lua_pushboolean(L, KeyInput::IsKeyPressed(key)); return 1; } int LuaUnsyncedRead::GetModKeyState(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); - lua_pushboolean(L, keyInput->GetKeyState(SDLK_LALT)); - lua_pushboolean(L, keyInput->GetKeyState(SDLK_LCTRL)); - lua_pushboolean(L, keyInput->GetKeyState(SDLK_LMETA)); - lua_pushboolean(L, keyInput->GetKeyState(SDLK_LSHIFT)); + lua_pushboolean(L, KeyInput::GetKeyModState(KMOD_ALT)); + lua_pushboolean(L, KeyInput::GetKeyModState(KMOD_CTRL)); + lua_pushboolean(L, KeyInput::GetKeyModState(KMOD_GUI)); + lua_pushboolean(L, KeyInput::GetKeyModState(KMOD_SHIFT)); return 4; } int LuaUnsyncedRead::GetPressedKeys(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_newtable(L); - - unsigned int count = 0; - - for (int i = 0; i < SDLK_LAST; i++) { - if (keyInput->GetKeyState(i)) { - lua_pushboolean(L, 1); - lua_rawseti(L, -2, i); - count++; + for (auto key: KeyInput::GetPressedKeys()) { + if (key.second) { + lua_pushboolean(L, true); + lua_rawseti(L, -2, key.first); } } return 1; @@ -2025,7 +1944,6 @@ int LuaUnsyncedRead::GetInvertQueueKey(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); if (guihandler == NULL) { return 0; } @@ -2035,16 +1953,28 @@ /******************************************************************************/ +int LuaUnsyncedRead::GetClipboard(lua_State* L) +{ + char* text = SDL_GetClipboardText(); + if (text == NULL) { + return 0; + } + lua_pushstring(L, text); + SDL_free(text); + return 1; +} + +/******************************************************************************/ + int LuaUnsyncedRead::GetLastMessagePositions(lua_State* L) { CInfoConsole* ic = game->infoConsole; - if (ic == NULL) { + + if (ic == NULL) return 0; - } - CheckNoArgs(L, __FUNCTION__); lua_newtable(L); - for (int i=1; i<=ic->GetMsgPosCount(); i++) { + for (unsigned int i = 1; i <= ic->GetMsgPosCount(); i++) { lua_newtable(L); { const float3 msgpos = ic->GetMsgPos(); lua_pushnumber(L, msgpos.x); lua_rawseti(L, -2, 1); @@ -2091,10 +2021,8 @@ lua_pushliteral(L, "text"); lua_pushsstring(L, lines[i].text); lua_rawset(L, -3); - // FIXME migrate priority to level... lua_pushliteral(L, "priority"); - lua_pushnumber(L, 0); - //lua_pushstring(L, lines[i].level); + lua_pushnumber(L, lines[i].level); lua_rawset(L, -3); } lua_rawset(L, -3); @@ -2106,7 +2034,6 @@ int LuaUnsyncedRead::GetCurrentTooltip(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushsstring(L, mouse->GetCurrentTooltip()); return 1; } @@ -2114,14 +2041,19 @@ int LuaUnsyncedRead::GetKeyCode(lua_State* L) { - lua_pushnumber(L, (keyCodes != NULL)? keyCodes->GetCode(luaL_checksstring(L, 1)): -1); + if (keyCodes == NULL) { + return 0; + } + + const int keycode = keyCodes->GetCode(luaL_checksstring(L, 1)); + lua_pushnumber(L, SDL21_keysyms(keycode)); return 1; } int LuaUnsyncedRead::GetKeySymbol(lua_State* L) { - const int keycode = luaL_checkint(L, 1); + const int keycode = SDL12_keysyms(luaL_checkint(L, 1)); lua_pushsstring(L, (keyCodes != NULL)? keyCodes->GetName(keycode): ""); lua_pushsstring(L, (keyCodes != NULL)? keyCodes->GetDefaultName(keycode): ""); return 2; @@ -2139,14 +2071,17 @@ const CKeyBindings::ActionList& actions = keyBindings->GetActionList(ks); + int i = 1; lua_newtable(L); - for (unsigned int i = 0; i < actions.size(); i++) { - const Action& action = actions[i]; + for (const Action& action: actions) { lua_newtable(L); - lua_pushsstring(L, action.command); - lua_pushsstring(L, action.extra); - lua_rawset(L, -3); - lua_rawseti(L, -2, i + 1); + lua_pushsstring(L, action.command); + lua_pushsstring(L, action.extra); + lua_rawset(L, -3); + LuaPushNamedString(L, "command", action.command); + LuaPushNamedString(L, "extra", action.extra); + LuaPushNamedString(L, "boundWith", action.boundWith); + lua_rawseti(L, -2, i++); } return 1; } @@ -2160,10 +2095,10 @@ const CKeyBindings::HotkeyList& hotkeys = keyBindings->GetHotkeys(luaL_checksstring(L, 1)); lua_newtable(L); - for (unsigned int i = 0; i < hotkeys.size(); i++) { - const string& hotkey = hotkeys[i]; + int i = 1; + for (const std::string& hotkey: hotkeys) { lua_pushsstring(L, hotkey); - lua_rawseti(L, -2, i + 1); + lua_rawseti(L, -2, i++); } return 1; } @@ -2172,9 +2107,6 @@ int LuaUnsyncedRead::GetGroupList(lua_State* L) { - GML_RECMUTEX_LOCK(group); // GetGroupList - - CheckNoArgs(L, __FUNCTION__); if (grouphandlers[gu->myTeam] == NULL) { return 0; } @@ -2199,7 +2131,6 @@ int LuaUnsyncedRead::GetSelectedGroup(lua_State* L) { - CheckNoArgs(L, __FUNCTION__); lua_pushnumber(L, selectedUnitsHandler.GetSelectedGroup()); return 1; } @@ -2223,8 +2154,6 @@ int LuaUnsyncedRead::GetGroupUnits(lua_State* L) { - GML_RECMUTEX_LOCK(group); // GetGroupUnits - const int groupID = luaL_checkint(L, 1); const vector& groups = grouphandlers[gu->myTeam]->groups; if ((groupID < 0) || ((size_t)groupID >= groups.size()) || @@ -2250,8 +2179,6 @@ int LuaUnsyncedRead::GetGroupUnitsSorted(lua_State* L) { - GML_RECMUTEX_LOCK(group); // GetGroupUnitsSorted - const int groupID = luaL_checkint(L, 1); const vector& groups = grouphandlers[gu->myTeam]->groups; if ((groupID < 0) || ((size_t)groupID >= groups.size()) || @@ -2288,8 +2215,6 @@ int LuaUnsyncedRead::GetGroupUnitsCounts(lua_State* L) { - GML_RECMUTEX_LOCK(group); // GetGroupUnitsCounts - const int groupID = luaL_checkint(L, 1); const vector& groups = grouphandlers[gu->myTeam]->groups; if ((groupID < 0) || ((size_t)groupID >= groups.size()) || @@ -2324,8 +2249,6 @@ int LuaUnsyncedRead::GetGroupUnitsCount(lua_State* L) { - GML_RECMUTEX_LOCK(group); // GetGroupUnitsCount - const int groupID = luaL_checkint(L, 1); const vector& groups = grouphandlers[gu->myTeam]->groups; if ((groupID < 0) || ((size_t)groupID >= groups.size()) || @@ -2340,33 +2263,6 @@ /******************************************************************************/ /******************************************************************************/ -int LuaUnsyncedRead::GetMyPlayerID(lua_State* L) -{ - CheckNoArgs(L, __FUNCTION__); - lua_pushnumber(L, gu->myPlayerNum); - return 1; -} - - -int LuaUnsyncedRead::GetMyTeamID(lua_State* L) -{ - CheckNoArgs(L, __FUNCTION__); - lua_pushnumber(L, gu->myTeam); - return 1; -} - - -int LuaUnsyncedRead::GetMyAllyTeamID(lua_State* L) -{ - CheckNoArgs(L, __FUNCTION__); - lua_pushnumber(L, gu->myAllyTeam); - return 1; -} - - -/******************************************************************************/ -/******************************************************************************/ - int LuaUnsyncedRead::GetPlayerRoster(lua_State* L) { const PlayerRoster::SortType oldSortType = playerRoster.GetSortType(); @@ -2406,17 +2302,19 @@ } // only allow viewing stats for specific packet types - if ((playerID != -1) && // all system counts can be read - (playerID != gu->myPlayerNum) && // all self counts can be read - (packetID != -1) && - (packetID != NETMSG_CHAT) && - (packetID != NETMSG_PAUSE) && - (packetID != NETMSG_LUAMSG) && - (packetID != NETMSG_STARTPOS) && - (packetID != NETMSG_USER_SPEED)) { - lua_pushnumber(L, -1); - return 1; - } + if ( + (playerID != -1) && // all system counts can be read + (playerID != gu->myPlayerNum) && // all self counts can be read + (packetID != -1) && + (packetID != NETMSG_CHAT) && + (packetID != NETMSG_PAUSE) && + (packetID != NETMSG_LUAMSG) && + (packetID != NETMSG_STARTPOS) && + (packetID != NETMSG_USER_SPEED) + ) { + lua_pushnumber(L, -1); + return 1; + } const CGame::PlayerTrafficInfo& pti = it->second; if (packetID == -1) { diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaUnsyncedRead.h spring-98.0~14.04~ppa6/rts/Lua/LuaUnsyncedRead.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaUnsyncedRead.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaUnsyncedRead.h 2014-10-07 20:09:51.000000000 +0000 @@ -87,8 +87,8 @@ static int GetSoundStreamTime(lua_State* L); static int GetSoundEffectParams(lua_State* L); - // moved from LuaUI static int GetFPS(lua_State* L); + static int GetGameSpeed(lua_State* L); static int GetMouseState(lua_State* L); static int GetMouseCursor(lua_State* L); @@ -99,6 +99,8 @@ static int GetPressedKeys(lua_State* L); static int GetInvertQueueKey(lua_State* L); + static int GetClipboard(lua_State* L); + static int GetActiveCommand(lua_State* L); static int GetDefaultCommand(lua_State* L); static int GetActiveCmdDescs(lua_State* L); @@ -125,10 +127,6 @@ static int GetGroupList(lua_State* L); static int GetSelectedGroup(lua_State* L); - static int GetMyAllyTeamID(lua_State* L); - static int GetMyTeamID(lua_State* L); - static int GetMyPlayerID(lua_State* L); - static int GetUnitGroup(lua_State* L); static int GetGroupUnits(lua_State* L); diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaUtils.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaUtils.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaUtils.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaUtils.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,13 +1,10 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ -#include "System/Platform/Win/win32.h" +//#include "System/Platform/Win/win32.h" -#include -#include -#include #include #include - +#include #include "LuaUtils.h" @@ -16,7 +13,14 @@ #include "LuaConfig.h" #include -static const int maxDepth = 256; +#if !defined UNITSYNC && !defined DEDICATED && !defined BUILDING_AI + #include "System/TimeProfiler.h" +#else + #define SCOPED_TIMER(x) +#endif + + +static const int maxDepth = 16; int LuaUtils::exportedDataSize = 0; @@ -24,11 +28,11 @@ /******************************************************************************/ -static bool CopyPushData(lua_State* dst, lua_State* src, int index, int depth); -static bool CopyPushTable(lua_State* dst, lua_State* src, int index, int depth); +static bool CopyPushData(lua_State* dst, lua_State* src, int index, int depth, std::map& alreadyCopied); +static bool CopyPushTable(lua_State* dst, lua_State* src, int index, int depth, std::map& alreadyCopied); -static inline int PosLuaIndex(lua_State* src, int index) +static inline int PosAbsLuaIndex(lua_State* src, int index) { if (index > 0) { return index; @@ -38,7 +42,7 @@ } -static bool CopyPushData(lua_State* dst, lua_State* src, int index, int depth) +static bool CopyPushData(lua_State* dst, lua_State* src, int index, int depth, std::map& alreadyCopied) { const int type = lua_type(src, index); switch (type) { @@ -51,13 +55,28 @@ break; } case LUA_TSTRING: { + // get string (pointer) size_t len; const char* data = lua_tolstring(src, index, &len); + + // check cache + auto it = alreadyCopied.find(data); + if (it != alreadyCopied.end()) { + lua_rawgeti(dst, LUA_REGISTRYINDEX, it->second); + break; + } + + // copy string lua_pushlstring(dst, data, len); + + // cache it + lua_pushvalue(dst, -1); + const int dstRef = luaL_ref(dst, LUA_REGISTRYINDEX); + alreadyCopied[data] = dstRef; break; } case LUA_TTABLE: { - CopyPushTable(dst, src, index, depth); + CopyPushTable(dst, src, index, depth, alreadyCopied); break; } default: { @@ -69,18 +88,38 @@ } -static bool CopyPushTable(lua_State* dst, lua_State* src, int index, int depth) +static bool CopyPushTable(lua_State* dst, lua_State* src, int index, int depth, std::map& alreadyCopied) { + const int table = PosAbsLuaIndex(src, index); + + // check cache + const void* p = lua_topointer(src, table); + auto it = alreadyCopied.find(p); + if (it != alreadyCopied.end()) { + lua_rawgeti(dst, LUA_REGISTRYINDEX, it->second); + return true; + } + + // check table depth if (depth++ > maxDepth) { + LOG("CopyTable: reached max table depth '%i'", depth); lua_pushnil(dst); // push something return false; } - lua_newtable(dst); - const int table = PosLuaIndex(src, index); + // create new table + const auto array_len = lua_objlen(src, table); + lua_createtable(dst, array_len, 5); + + // cache it + lua_pushvalue(dst, -1); + const int dstRef = luaL_ref(dst, LUA_REGISTRYINDEX); + alreadyCopied[p] = dstRef; + + // copy table entries for (lua_pushnil(src); lua_next(src, table) != 0; lua_pop(src, 1)) { - CopyPushData(dst, src, -2, depth); // copy the key - CopyPushData(dst, src, -1, depth); // copy the value + CopyPushData(dst, src, -2, depth, alreadyCopied); // copy the key + CopyPushData(dst, src, -1, depth, alreadyCopied); // copy the value lua_rawset(dst, -3); } @@ -90,20 +129,36 @@ int LuaUtils::CopyData(lua_State* dst, lua_State* src, int count) { + SCOPED_TIMER("::CopyData"); + const int srcTop = lua_gettop(src); const int dstTop = lua_gettop(dst); if (srcTop < count) { + LOG_L(L_ERROR, "LuaUtils::CopyData: tried to copy more data than there is"); return 0; } - lua_checkstack(dst, count); // FIXME: not enough for table chains + lua_checkstack(dst, count + 3); // +3 needed for table copying + lua_lock(src); // we need to be sure tables aren't changed while we iterate them + + // hold a map of all already copied tables in the lua's registry table + // needed for recursive tables, i.e. "local t = {}; t[t] = t" + std::map alreadyCopied; const int startIndex = (srcTop - count + 1); const int endIndex = srcTop; for (int i = startIndex; i <= endIndex; i++) { - CopyPushData(dst, src, i, 0); + CopyPushData(dst, src, i, 0, alreadyCopied); } - lua_settop(dst, dstTop + count); + // clear map + for (auto& pair: alreadyCopied) { + luaL_unref(dst, LUA_REGISTRYINDEX, pair.second); + } + + const int curSrcTop = lua_gettop(src); + assert(srcTop == curSrcTop); + lua_settop(dst, dstTop + count); + lua_unlock(src); return count; } @@ -183,7 +238,7 @@ if (depth++ > maxDepth) return false; - const int table = PosLuaIndex(src, index); + const int table = PosAbsLuaIndex(src, index); for (lua_pushnil(src); lua_next(src, table) != 0; lua_pop(src, 1)) { LuaUtils::DataDump dk, dv; BackupData(dk, src, -2, depth); @@ -230,7 +285,7 @@ int LuaUtils::Restore(const std::vector &backup, lua_State* dst) { const int dstTop = lua_gettop(dst); int count = backup.size(); - lua_checkstack(dst, count); // FIXME: not enough for table chains + lua_checkstack(dst, count + 3); for (std::vector::const_iterator i = backup.begin(); i != backup.end(); ++i) { RestoreData(*i, dst, 0); @@ -241,87 +296,6 @@ } -int LuaUtils::ShallowBackup(std::vector &backup, lua_State* src, int count) { - const int srcTop = lua_gettop(src); - if (srcTop < count) - return 0; - - const int startIndex = (srcTop - count + 1); - const int endIndex = srcTop; - - for(int i = startIndex; i <= endIndex; ++i) { - const int type = lua_type(src, i); - ShallowDataDump sdd; - sdd.type = type; - switch (type) { - case LUA_TBOOLEAN: { - sdd.data.bol = lua_toboolean(src, i); - break; - } - case LUA_TNUMBER: { - sdd.data.num = lua_tonumber(src, i); - break; - } - case LUA_TSTRING: { - size_t len = 0; - const char* data = lua_tolstring(src, i, &len); - sdd.data.str = new std::string; - if (len > 0) { - sdd.data.str->resize(len); - memcpy(&(*sdd.data.str)[0], data, len); - } - break; - } - case LUA_TNIL: { - break; - } - default: { - LOG_L(L_WARNING, "ShallowBackup: Invalid type for argument %d", i); - break; // nil - } - } - backup.push_back(sdd); - } - - return count; -} - - -int LuaUtils::ShallowRestore(const std::vector &backup, lua_State* dst) { - int count = backup.size(); - lua_checkstack(dst, count); - - for (int d = 0; d < count; ++d) { - const ShallowDataDump &sdd = backup[d]; - switch (sdd.type) { - case LUA_TBOOLEAN: { - lua_pushboolean(dst, sdd.data.bol); - break; - } - case LUA_TNUMBER: { - lua_pushnumber(dst, sdd.data.num); - break; - } - case LUA_TSTRING: { - lua_pushlstring(dst, sdd.data.str->c_str(), sdd.data.str->size()); - delete sdd.data.str; - break; - } - case LUA_TNIL: { - lua_pushnil(dst); - break; - } - default: { - lua_pushnil(dst); - LOG_L(L_WARNING, "ShallowRestore: Invalid type for argument %d", d + 1); - break; // unhandled type - } - } - } - - return count; -} - /******************************************************************************/ /******************************************************************************/ @@ -368,31 +342,28 @@ /******************************************************************************/ /******************************************************************************/ -static int lowerKeysTable = 0; - -static bool LowerKeysCheck(lua_State* L, int table) +static bool LowerKeysCheck(lua_State* L, int table, int alreadyCheckTable) { - bool used = false; + bool checked = true; lua_pushvalue(L, table); - lua_rawget(L, lowerKeysTable); + lua_rawget(L, alreadyCheckTable); if (lua_isnil(L, -1)) { - used = false; + checked = false; lua_pushvalue(L, table); lua_pushboolean(L, true); - lua_rawset(L, lowerKeysTable); + lua_rawset(L, alreadyCheckTable); } lua_pop(L, 1); - return used; + return checked; } -static bool LowerKeysReal(lua_State* L, int depth) +static bool LowerKeysReal(lua_State* L, int alreadyCheckTable) { - lua_checkstack(L, lowerKeysTable + 8 + (depth * 3)); - + luaL_checkstack(L, 8, __FUNCTION__); const int table = lua_gettop(L); - if (LowerKeysCheck(L, table)) { + if (LowerKeysCheck(L, table, alreadyCheckTable)) { return true; } @@ -402,7 +373,7 @@ for (lua_pushnil(L); lua_next(L, table) != 0; lua_pop(L, 1)) { if (lua_istable(L, -1)) { - LowerKeysReal(L, depth + 1); + LowerKeysReal(L, alreadyCheckTable); } if (lua_israwstring(L, -2)) { const string rawKey = lua_tostring(L, -2); @@ -434,7 +405,6 @@ } lua_pop(L, 1); // pop the changed table - return true; } @@ -446,17 +416,71 @@ } // table of processed tables - lowerKeysTable = lua_gettop(L) + 1; - lua_checkstack(L, lowerKeysTable + 2); + luaL_checkstack(L, 2, __FUNCTION__); lua_newtable(L); + const int checkedTableIdx = lua_gettop(L); lua_pushvalue(L, table); // push the table onto the top of the stack + LowerKeysReal(L, checkedTableIdx); + + lua_pop(L, 2); // the lowered table, and the check table + return true; +} + + +static bool CheckForNaNsReal(lua_State* L, const std::string& path) +{ + luaL_checkstack(L, 3, __FUNCTION__); + const int table = lua_gettop(L); + bool foundNaNs = false; + + for (lua_pushnil(L); lua_next(L, table) != 0; lua_pop(L, 1)) { + if (lua_istable(L, -1)) { + // We can't work on -2 directly cause lua_tostring would replace the value in -2, + // so we need to make a copy and convert that to a string. + lua_pushvalue(L, -2); + const char* key = lua_tostring(L, -1); + const std::string subpath = path + key + "."; + lua_pop(L, 1); + foundNaNs |= CheckForNaNsReal(L, subpath); + } else + if (lua_isnumber(L, -1)) { + // Check for NaN + const float value = lua_tonumber(L, -1); + if (math::isinf(value) || math::isnan(value)) { + // We can't work on -2 directly cause lua_tostring would replace the value in -2, + // so we need to make a copy and convert that to a string. + lua_pushvalue(L, -2); + const char* key = lua_tostring(L, -1); + LOG_L(L_WARNING, "%s%s: Got Invalid NaN/Inf!", path.c_str(), key); + lua_pop(L, 1); + foundNaNs = true; + } + } + } + + return foundNaNs; +} + + +bool LuaUtils::CheckTableForNaNs(lua_State* L, int table, const std::string& name) +{ + if (!lua_istable(L, table)) { + return false; + } + + luaL_checkstack(L, 2, __FUNCTION__); + + // table of processed tables + lua_newtable(L); + // push the table onto the top of the stack + lua_pushvalue(L, table); - LowerKeysReal(L, 0); + const bool foundNaNs = CheckForNaNsReal(L, name + ": "); lua_pop(L, 2); // the lowered table, and the check table - return true; + return foundNaNs; } @@ -490,14 +514,17 @@ for (int i = 1; i <= top; i++) { LOG_L(L_ERROR, " %i: type = %s (%p)", i, luaL_typename(L, i), lua_topointer(L, i)); const int type = lua_type(L, i); - if (type == LUA_TSTRING) { - LOG_L(L_ERROR, "\t\t%s\n", lua_tostring(L, i)); - } else if (type == LUA_TNUMBER) { - LOG_L(L_ERROR, "\t\t%f\n", lua_tonumber(L, i)); - } else if (type == LUA_TBOOLEAN) { - LOG_L(L_ERROR, "\t\t%s\n", lua_toboolean(L, i) ? "true" : "false"); - } else { - LOG_L(L_ERROR, "\n"); + switch(type) { + case LUA_TSTRING: + LOG_L(L_ERROR, "\t\t%s", lua_tostring(L, i)); + break; + case LUA_TNUMBER: + LOG_L(L_ERROR, "\t\t%f", lua_tonumber(L, i)); + break; + case LUA_TBOOLEAN: + LOG_L(L_ERROR, "\t\t%s", lua_toboolean(L, i) ? "true" : "false"); + break; + default: {} } } } @@ -526,29 +553,7 @@ return size; } -/* -// from LuaShaders.cpp (index unused) -int LuaUtils::ParseFloatArray(lua_State* L, int index, float* array, int size) -{ - if (!lua_istable(L, -1)) { - return -1; - } - const int table = lua_gettop(L); - for (int i = 0; i < size; i++) { - lua_rawgeti(L, table, (i + 1)); - if (lua_isnumber(L, -1)) { - array[i] = lua_tofloat(L, -1); - lua_pop(L, 1); - } else { - lua_pop(L, 1); - return i; - } - } - return size; -} -*/ -// from LuaUnsyncedCtrl.cpp int LuaUtils::ParseFloatArray(lua_State* L, int index, float* array, int size) { if (!lua_istable(L, index)) { @@ -900,6 +905,7 @@ #define PUSH_LOG_LEVEL(cmd) LuaPushNamedNumber(L, #cmd, LOG_LEVEL_ ## cmd) PUSH_LOG_LEVEL(DEBUG); PUSH_LOG_LEVEL(INFO); + PUSH_LOG_LEVEL(NOTICE); PUSH_LOG_LEVEL(WARNING); PUSH_LOG_LEVEL(ERROR); PUSH_LOG_LEVEL(FATAL); @@ -935,6 +941,9 @@ else if (loglvlstr == "info") { loglevel = LOG_LEVEL_INFO; } + else if (loglvlstr == "notice") { + loglevel = LOG_LEVEL_INFO; + } else if (loglvlstr == "warning") { loglevel = LOG_LEVEL_WARNING; } @@ -957,117 +966,21 @@ return 0; } - /******************************************************************************/ /******************************************************************************/ - -int LuaUtils::ZlibCompress(lua_State* L) -{ - size_t inLen; - const char* inData = luaL_checklstring(L, 1, &inLen); - - long unsigned bufsize = compressBound(inLen); - std::vector compressed(bufsize, 0); - const int error = compress(&compressed[0], &bufsize, (const boost::uint8_t*)inData, inLen); - if (error == Z_OK) - { - lua_pushlstring(L, (const char*)&compressed[0], bufsize); - return 1; - } - else - { - return luaL_error(L, "Error while compressing"); - } -} - -int LuaUtils::ZlibDecompress(lua_State* L) -{ - size_t inLen; - const char* inData = luaL_checklstring(L, 1, &inLen); - - long unsigned bufsize = std::max(luaL_optint(L, 2, 65000), 0); - - std::vector uncompressed(bufsize, 0); - const int error = uncompress(&uncompressed[0], &bufsize, (const boost::uint8_t*)inData, inLen); - if (error == Z_OK) - { - lua_pushlstring(L, (const char*)&uncompressed[0], bufsize); - return 1; - } - else - { - return luaL_error(L, "Error while decompressing"); - } -} - -/******************************************************************************/ -/******************************************************************************/ - -int LuaUtils::tobool(lua_State* L) -{ - return 1; -} - - -int LuaUtils::isnil(lua_State* L) -{ - lua_pushboolean(L, lua_isnoneornil(L, 1)); - return 1; -} - - -int LuaUtils::isbool(lua_State* L) -{ - lua_pushboolean(L, lua_type(L, 1) == LUA_TBOOLEAN); - return 1; -} - - -int LuaUtils::isnumber(lua_State* L) -{ - lua_pushboolean(L, lua_type(L, 1) == LUA_TNUMBER); - return 1; -} - - -int LuaUtils::isstring(lua_State* L) -{ - lua_pushboolean(L, lua_type(L, 1) == LUA_TSTRING); - return 1; -} - - -int LuaUtils::istable(lua_State* L) -{ - lua_pushboolean(L, lua_type(L, 1) == LUA_TTABLE); - return 1; -} - - -int LuaUtils::isthread(lua_State* L) -{ - lua_pushboolean(L, lua_type(L, 1) == LUA_TTHREAD); - return 1; -} - - -int LuaUtils::isfunction(lua_State* L) +LuaUtils::ScopedStackChecker::ScopedStackChecker(lua_State* L, int _returnVars) + : luaState(L) + , prevTop(lua_gettop(luaState)) + , returnVars(_returnVars) { - lua_pushboolean(L, lua_type(L, 1) == LUA_TFUNCTION); - return 1; } - -int LuaUtils::isuserdata(lua_State* L) -{ - const int type = lua_type(L, 1); - lua_pushboolean(L, (type == LUA_TUSERDATA) || - (type == LUA_TLIGHTUSERDATA)); - return 1; +LuaUtils::ScopedStackChecker::~ScopedStackChecker() { + const int curTop = lua_gettop(luaState); // use var so you can print it in gdb + assert(curTop == prevTop + returnVars); } - /******************************************************************************/ /******************************************************************************/ @@ -1101,17 +1014,19 @@ -LuaUtils::ScopedDebugTraceBack::ScopedDebugTraceBack(lua_State* L) - : luaState(L) - , errFuncIdx(PushDebugTraceback(L)) +LuaUtils::ScopedDebugTraceBack::ScopedDebugTraceBack(lua_State* _L) + : L(_L) + , errFuncIdx(PushDebugTraceback(_L)) { assert(errFuncIdx >= 0); } LuaUtils::ScopedDebugTraceBack::~ScopedDebugTraceBack() { - //FIXME better use lua_remove(L, errFuncIdx) and solve zero case? - assert(errFuncIdx == 0 || lua_gettop(luaState) == errFuncIdx); - lua_pop(luaState, 1); + // make sure we are at same position on the stack + const int curTop = lua_gettop(L); + assert(errFuncIdx == 0 || curTop == errFuncIdx); + + lua_pop(L, 1); } /******************************************************************************/ diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaUtils.h spring-98.0~14.04~ppa6/rts/Lua/LuaUtils.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaUtils.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaUtils.h 2014-10-07 20:09:51.000000000 +0000 @@ -10,8 +10,13 @@ #include "LuaHashString.h" #include "LuaInclude.h" +#include "LuaHandle.h" #include "LuaDefs.h" #include "Sim/Units/CommandAI/Command.h" +#include "Sim/Features/Feature.h" +#include "Sim/Units/Unit.h" +#include "Sim/Misc/TeamHandler.h" +#include "System/EventClient.h" // is defined as macro on FreeBSD (wtf) #ifdef isnumber @@ -20,7 +25,29 @@ class LuaUtils { public: + struct ScopedStackChecker { + public: + ScopedStackChecker(lua_State* L, int returnVars = 0); + ~ScopedStackChecker(); + private: + lua_State* luaState; + int prevTop; + int returnVars; + }; + + struct ScopedDebugTraceBack { + public: + ScopedDebugTraceBack(lua_State* L); + ~ScopedDebugTraceBack(); + void SetErrFuncIdx(int idx) { errFuncIdx = idx; } + int GetErrFuncIdx() const { return errFuncIdx; } + private: + lua_State* L; + int errFuncIdx; + }; + + public: struct DataDump { int type; std::string str; @@ -36,55 +63,35 @@ bool bol; } data; }; - struct ScopedDebugTraceBack { - public: - ScopedDebugTraceBack(lua_State* L); - ~ScopedDebugTraceBack(); - void SetErrFuncIdx(int idx) { errFuncIdx = idx; } - int GetErrFuncIdx() const { return errFuncIdx; } - - private: - lua_State* luaState; - - int errFuncIdx; - }; + public: + // Backups lua data into a c++ vector and restores it from it static int exportedDataSize; //< performance stat - static int Backup(std::vector &backup, lua_State* src, int count); - static int Restore(const std::vector &backup, lua_State* dst); - static int ShallowBackup(std::vector &backup, lua_State* src, int count); - - static int ShallowRestore(const std::vector &backup, lua_State* dst); - + // Copies lua data between 2 lua_States static int CopyData(lua_State* dst, lua_State* src, int count); - static void PushCurrentFuncEnv(lua_State* L, const char* caller); - - static int PushDebugTraceback(lua_State* L); //< returns stack index of traceback function + // returns stack index of traceback function + static int PushDebugTraceback(lua_State* L); // lower case all keys in the table, with recursion static bool LowerKeys(lua_State* L, int tableIndex); + static bool CheckTableForNaNs(lua_State* L, int table, const std::string& name); + static void PushCommandParamsTable(lua_State* L, const Command& cmd, bool subtable); static void PushCommandOptionsTable(lua_State* L, const Command& cmd, bool subtable); // from LuaUI.cpp / LuaSyncedCtrl.cpp (used to be duplicated) - static void ParseCommandOptions( - lua_State* L, - Command& cmd, - const char* caller, - const int idx - ); - static Command ParseCommand(lua_State* L, const char* caller, - int idIndex); - static Command ParseCommandTable(lua_State* L, const char* caller, - int table); - static void ParseCommandArray(lua_State* L, const char* caller, - int table, vector& commands); + static void ParseCommandOptions(lua_State* L, Command& cmd, const char* caller, int index); + static Command ParseCommand(lua_State* L, const char* caller, int idIndex); + static Command ParseCommandTable(lua_State* L, const char* caller, int table); + static void ParseCommandArray(lua_State* L, const char* caller, int table, vector& commands); static int ParseFacing(lua_State* L, const char* caller, int index); + static void PushCurrentFuncEnv(lua_State* L, const char* caller); + static void* GetUserData(lua_State* L, int index, const string& type); static void PrintStack(lua_State* L); @@ -99,19 +106,7 @@ static int Log(lua_State* L); static bool PushLogEntries(lua_State* L); - static int ZlibCompress(lua_State* L); - static int ZlibDecompress(lua_State* L); - static bool PushCustomBaseFunctions(lua_State* L); - static int tobool(lua_State* L); - static int isnil(lua_State* L); - static int isbool(lua_State* L); - static int isnumber(lua_State* L); - static int isstring(lua_State* L); - static int istable(lua_State* L); - static int isthread(lua_State* L); - static int isfunction(lua_State* L); - static int isuserdata(lua_State* L); // not implemented (except for the first two)... static int ParseIntArray(lua_State* L, int tableIndex, @@ -134,7 +129,17 @@ }; -inline void LuaPushNamedBool(lua_State* L, + +static inline void LuaPushNamedNil(lua_State* L, + const string& key) +{ + lua_pushsstring(L, key); + lua_pushnil(L); + lua_rawset(L, -3); +} + + +static inline void LuaPushNamedBool(lua_State* L, const string& key, bool value) { lua_pushsstring(L, key); @@ -143,7 +148,7 @@ } -inline void LuaPushNamedNumber(lua_State* L, +static inline void LuaPushNamedNumber(lua_State* L, const string& key, lua_Number value) { lua_pushsstring(L, key); @@ -152,7 +157,7 @@ } -inline void LuaPushNamedString(lua_State* L, +static inline void LuaPushNamedString(lua_State* L, const string& key, const string& value) { lua_pushsstring(L, key); @@ -161,7 +166,7 @@ } -inline void LuaPushNamedCFunc(lua_State* L, +static inline void LuaPushNamedCFunc(lua_State* L, const string& key, int (*func)(lua_State*)) { lua_pushsstring(L, key); @@ -170,7 +175,7 @@ } -inline void LuaInsertDualMapPair(lua_State* L, const string& name, int number) +static inline void LuaInsertDualMapPair(lua_State* L, const string& name, int number) { lua_pushsstring(L, name); lua_pushnumber(L, number); @@ -180,4 +185,88 @@ lua_rawset(L, -3); } + +static inline bool FullCtrl(const lua_State *L) +{ + return CLuaHandle::GetHandleFullCtrl(L); +} + + +static inline int CtrlTeam(const lua_State *L) +{ + return CLuaHandle::GetHandleCtrlTeam(L); +} + + +static inline int CtrlAllyTeam(const lua_State *L) +{ + const int ctrlTeam = CtrlTeam(L); + if (ctrlTeam < 0) { + return ctrlTeam; + } + return teamHandler->AllyTeam(ctrlTeam); +} + + +static inline bool CanControlTeam(const lua_State *L, int teamID) +{ + const int ctrlTeam = CtrlTeam(L); + if (ctrlTeam < 0) { + return (ctrlTeam == CEventClient::AllAccessTeam) ? true : false; + } + return (ctrlTeam == teamID); +} + + +static inline bool CanControlAllyTeam(const lua_State *L, int allyTeamID) +{ + const int ctrlTeam = CtrlTeam(L); + if (ctrlTeam < 0) { + return (ctrlTeam == CEventClient::AllAccessTeam) ? true : false; + } + return (teamHandler->AllyTeam(ctrlTeam) == allyTeamID); +} + + +static inline bool CanControlUnit(const lua_State *L, const CUnit* unit) +{ + const int ctrlTeam = CtrlTeam(L); + if (ctrlTeam < 0) { + return (ctrlTeam == CEventClient::AllAccessTeam) ? true : false; + } + return (ctrlTeam == unit->team); +} + + +static inline bool CanControlFeatureAllyTeam(const lua_State *L, int allyTeamID) +{ + const int ctrlTeam = CtrlTeam(L); + if (ctrlTeam < 0) { + return (ctrlTeam == CEventClient::AllAccessTeam) ? true : false; + } + if (allyTeamID < 0) { + return (ctrlTeam == teamHandler->GaiaTeamID()); + } + return (teamHandler->AllyTeam(ctrlTeam) == allyTeamID); +} + + +static inline bool CanControlFeature(const lua_State *L, const CFeature* feature) +{ + return CanControlFeatureAllyTeam(L, feature->allyteam); +} + + +static inline bool CanControlProjectileAllyTeam(const lua_State *L, int allyTeamID) +{ + const int ctrlTeam = CtrlTeam(L); + if (ctrlTeam < 0) { + return (ctrlTeam == CEventClient::AllAccessTeam) ? true : false; + } + if (allyTeamID < 0) { + return false; + } + return (teamHandler->AllyTeam(ctrlTeam) == allyTeamID); +} + #endif // LUA_UTILS_H diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaVFS.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaVFS.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaVFS.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaVFS.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,6 +2,7 @@ #include +#include #include #include "LuaVFS.h" @@ -19,11 +20,6 @@ #include "System/FileSystem/FileSystem.h" #include "System/Util.h" -#include -#include -#include -#include - using std::min; @@ -89,6 +85,7 @@ HSTR_PUSH_CFUNC(L, "UseArchive", UseArchive); HSTR_PUSH_CFUNC(L, "CompressFolder", CompressFolder); HSTR_PUSH_CFUNC(L, "MapArchive", MapArchive); + HSTR_PUSH_CFUNC(L, "UnmapArchive", UnmapArchive); HSTR_PUSH_CFUNC(L, "ZlibCompress", ZlibCompress); @@ -383,59 +380,91 @@ int LuaVFS::MapArchive(lua_State* L) { - if (CLuaHandle::GetHandleSynced(L)) // only from unsynced - { + if (CLuaHandle::GetHandleSynced(L)) { + // only from unsynced return 0; } const int args = lua_gettop(L); // number of arguments - const string filename = archiveScanner->ArchiveFromName(luaL_checkstring(L, 1)); + const std::string filename = archiveScanner->ArchiveFromName(luaL_checkstring(L, 1)); + if (!LuaIO::IsSimplePath(filename)) { // the path may point to a file or dir outside of any data-dir - //FIXME return 0; + return 0; } CFileHandler f(filename, SPRING_VFS_RAW); - if (!f.FileExists()) - { + + if (!f.FileExists()) { std::ostringstream buf; buf << "Achive not found: " << filename; + lua_pushboolean(L, false); lua_pushsstring(L, buf.str()); - return 0; + return 2; } - if (args >= 2) - { - const std::string checksumBuf = lua_tostring(L, 2); - int checksum = 0; - std::istringstream buf(checksumBuf); - buf >> checksum; - const int realchecksum = archiveScanner->GetSingleArchiveChecksum(filename); - if (checksum != realchecksum) - { + if (args >= 2) { + // parse checksum as a STRING to convert it to a number because + // lua numbers are float and so limited to 2^24, while the checksum is an int32. + // const unsigned int argChecksum = lua_tonumber(L, 2); + const unsigned int argChecksum = StringToInt(lua_tostring(L, 2)); + const unsigned int realChecksum = archiveScanner->GetSingleArchiveChecksum(filename); + + if (argChecksum != realChecksum) { std::ostringstream buf; - buf << "Bad archive checksum, got: " << realchecksum << " expected: " << checksum; + + buf << "[" << __FUNCTION__ << "] incorrect archive checksum "; + buf << "(got: " << argChecksum << ", expected: " << realChecksum << ")"; + lua_pushboolean(L, false); lua_pushsstring(L, buf.str()); - return 0; + return 2; } } - if (!vfsHandler->AddArchive(filename, false)) - { + + if (!vfsHandler->AddArchive(filename, false)) { std::ostringstream buf; - buf << "Failed to load archive: " << filename; + buf << "[" << __FUNCTION__ << "] failed to load archive: " << filename; + lua_pushboolean(L, false); lua_pushsstring(L, buf.str()); + return 2; } - else - { - lua_pushboolean(L, true); + + lua_pushboolean(L, true); + return 1; +} + +int LuaVFS::UnmapArchive(lua_State* L) +{ + if (CLuaHandle::GetHandleSynced(L)) { + // only from unsynced + return 0; } - return 0; + + const std::string filename = archiveScanner->ArchiveFromName(luaL_checkstring(L, 1)); + + if (!LuaIO::IsSimplePath(filename)) { + // the path may point to a file or dir outside of any data-dir + return 0; + } + + if (!vfsHandler->RemoveArchive(filename)) { + std::ostringstream buf; + buf << "[" << __FUNCTION__ << "] failed to remove archive: " << filename; + + lua_pushboolean(L, false); + lua_pushsstring(L, buf.str()); + return 2; + } + + lua_pushboolean(L, true); + return 1; } + /******************************************************************************/ int LuaVFS::CompressFolder(lua_State* L) @@ -471,20 +500,45 @@ return 0; } -/******************************************************************************/ -/******************************************************************************/ -// -// Zlib compression -// int LuaVFS::ZlibCompress(lua_State* L) { - return LuaUtils::ZlibCompress(L); + size_t inLen; + const char* inData = luaL_checklstring(L, 1, &inLen); + + long unsigned bufsize = compressBound(inLen); + std::vector compressed(bufsize, 0); + const int error = compress(&compressed[0], &bufsize, (const boost::uint8_t*)inData, inLen); + if (error == Z_OK) + { + lua_pushlstring(L, (const char*)&compressed[0], bufsize); + return 1; + } + else + { + return luaL_error(L, "Error while compressing"); + } } + int LuaVFS::ZlibDecompress(lua_State* L) { - return LuaUtils::ZlibDecompress(L); + size_t inLen; + const char* inData = luaL_checklstring(L, 1, &inLen); + + long unsigned bufsize = std::max(luaL_optint(L, 2, 65000), 0); + + std::vector uncompressed(bufsize, 0); + const int error = uncompress(&uncompressed[0], &bufsize, (const boost::uint8_t*)inData, inLen); + if (error == Z_OK) + { + lua_pushlstring(L, (const char*)&uncompressed[0], bufsize); + return 1; + } + else + { + return luaL_error(L, "Error while decompressing"); + } } diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaVFS.h spring-98.0~14.04~ppa6/rts/Lua/LuaVFS.h --- spring-96.0~14.04~ppa4/rts/Lua/LuaVFS.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaVFS.h 2014-10-07 20:09:51.000000000 +0000 @@ -47,6 +47,12 @@ LuaParameters: (string Filename), (unsigned int checksum, optional) */ static int MapArchive(lua_State* L); + /** + @brief Unmaps archives mapped with MapArchive from VFS (only from unsynced) + + LuaParameters: (string Filename) + */ + static int UnmapArchive(lua_State* L); static int ZlibCompress(lua_State* L); static int ZlibDecompress(lua_State* L); diff -Nru spring-96.0~14.04~ppa4/rts/Lua/LuaWeaponDefs.cpp spring-98.0~14.04~ppa6/rts/Lua/LuaWeaponDefs.cpp --- spring-96.0~14.04~ppa4/rts/Lua/LuaWeaponDefs.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Lua/LuaWeaponDefs.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -130,26 +130,26 @@ const void* userData = lua_touserdata(L, lua_upvalueindex(1)); const WeaponDef* wd = static_cast(userData); const DataElement& elem = it->second; - const char* p = ((const char*)wd) + elem.offset; + const void* p = ((const char*)wd) + elem.offset; switch (elem.type) { case READONLY_TYPE: { lua_rawget(L, 1); return 1; } case INT_TYPE: { - lua_pushnumber(L, *((int*)p)); + lua_pushnumber(L, *reinterpret_cast(p)); return 1; } case BOOL_TYPE: { - lua_pushboolean(L, *((bool*)p)); + lua_pushboolean(L, *reinterpret_cast(p)); return 1; } case FLOAT_TYPE: { - lua_pushnumber(L, *((float*)p)); + lua_pushnumber(L, *reinterpret_cast(p)); return 1; } case STRING_TYPE: { - lua_pushsstring(L, *((string*)p)); + lua_pushsstring(L, *reinterpret_cast(p)); return 1; } case FUNCTION_TYPE: { @@ -194,7 +194,7 @@ // Definition editing const DataElement& elem = it->second; - const char* p = ((const char*)wd) + elem.offset; + const void* p = ((const char*)wd) + elem.offset; switch (elem.type) { case FUNCTION_TYPE: diff -Nru spring-96.0~14.04~ppa4/rts/Map/BaseGroundDrawer.cpp spring-98.0~14.04~ppa6/rts/Map/BaseGroundDrawer.cpp --- spring-96.0~14.04~ppa4/rts/Map/BaseGroundDrawer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/BaseGroundDrawer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -36,19 +36,16 @@ drawMode = drawNormal; drawLineOfSight = false; drawRadarAndJammer = true; + drawMapEdges = false; + drawDeferred = false; wireframe = false; advShading = false; highResInfoTex = false; updateTextureState = 0; -#ifdef USE_GML - multiThreadDrawGroundShadow = false; - multiThreadDrawGround = false; -#endif - infoTexPBO.Bind(); - infoTexPBO.Resize(gs->pwr2mapx * gs->pwr2mapy * 4); - infoTexPBO.Unbind(false); + infoTexPBO.New(gs->pwr2mapx * gs->pwr2mapy * 4); + infoTexPBO.Unbind(); highResInfoTexWanted = false; @@ -410,7 +407,7 @@ totalLos = inLos + inAir; } #ifdef RADARHANDLER_SONAR_JAMMER_MAPS - const bool useRadar = (ground->GetHeightReal(xPos, zPos, false) >= 0.0f); + const bool useRadar = (CGround::GetHeightReal(xPos, zPos, false) >= 0.0f); const unsigned short* radarMap = useRadar ? myRadar : mySonar; const unsigned short* jammerMap = useRadar ? myJammer : mySonarJammer; #else @@ -468,7 +465,7 @@ } */ - infoTexPBO.Unbind(false); + infoTexPBO.Unbind(); } @@ -500,7 +497,8 @@ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, gs->pwr2mapx>>1, gs->pwr2mapy>>1, 0, GL_BGRA, GL_UNSIGNED_BYTE, infoTexPBO.GetPtr()); } - infoTexPBO.Unbind(false); + infoTexPBO.Invalidate(); + infoTexPBO.Unbind(); highResInfoTex = highResInfoTexWanted; updateTextureState = 0; @@ -515,7 +513,8 @@ } else { glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, gs->pwr2mapx>>1, gs->pwr2mapy>>1, GL_BGRA, GL_UNSIGNED_BYTE, infoTexPBO.GetPtr()); } - infoTexPBO.Unbind(false); + infoTexPBO.Invalidate(); + infoTexPBO.Unbind(); updateTextureState = 0; return true; diff -Nru spring-96.0~14.04~ppa4/rts/Map/BaseGroundDrawer.h spring-98.0~14.04~ppa6/rts/Map/BaseGroundDrawer.h --- spring-96.0~14.04~ppa4/rts/Map/BaseGroundDrawer.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/BaseGroundDrawer.h 2014-10-07 20:09:51.000000000 +0000 @@ -20,7 +20,7 @@ namespace GL { struct GeometryBuffer; struct LightHandler; -}; +} class CBaseGroundDrawer { @@ -44,6 +44,7 @@ CBaseGroundDrawer(); virtual ~CBaseGroundDrawer(); + CBaseGroundDrawer(const CBaseGroundDrawer&) = delete; // no-copy virtual void Draw(const DrawPass::e& drawPass) = 0; virtual void DrawShadowPass() {} @@ -121,11 +122,6 @@ int updateTextureState; int extraTextureUpdateRate; -#ifdef USE_GML - bool multiThreadDrawGround; - bool multiThreadDrawGroundShadow; -#endif - protected: BaseGroundDrawMode drawMode; diff -Nru spring-96.0~14.04~ppa4/rts/Map/BasicMapDamage.cpp spring-98.0~14.04~ppa6/rts/Map/BasicMapDamage.cpp --- spring-96.0~14.04~ppa4/rts/Map/BasicMapDamage.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/BasicMapDamage.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -6,7 +6,7 @@ #include "MapInfo.h" #include "BaseGroundDrawer.h" #include "HeightMapTexture.h" -#include "Rendering/Env/ITreeDrawer.h" +#include "Rendering/Env/GrassDrawer.h" #include "Rendering/Env/IWater.h" #include "Sim/Misc/GroundBlockingObjectMap.h" #include "Sim/Misc/LosHandler.h" @@ -56,27 +56,21 @@ void CBasicMapDamage::Explosion(const float3& pos, float strength, float radius) { - if ((pos.x < 0.0f) || (pos.x > gs->mapx * SQUARE_SIZE)) { + if (!pos.IsInMap()) { return; } - if ((pos.z < 0.0f) || (pos.z > gs->mapy * SQUARE_SIZE)) { - return; - } - if (strength < 10.0f || radius < 8.0f) { return; } - radius *= 1.5f; - Explo* e = new Explo; e->pos = pos; e->strength = strength; e->ttl = 10; - e->x1 = std::max((int) (pos.x - radius) / SQUARE_SIZE, 2); - e->x2 = std::min((int) (pos.x + radius) / SQUARE_SIZE, gs->mapx - 3); - e->y1 = std::max((int) (pos.z - radius) / SQUARE_SIZE, 2); - e->y2 = std::min((int) (pos.z + radius) / SQUARE_SIZE, gs->mapy - 3); + e->x1 = Clamp((pos.x - radius) / SQUARE_SIZE, 1, gs->mapxm1); + e->x2 = Clamp((pos.x + radius) / SQUARE_SIZE, 1, gs->mapxm1); + e->y1 = Clamp((pos.z - radius) / SQUARE_SIZE, 1, gs->mapym1); + e->y2 = Clamp((pos.z + radius) / SQUARE_SIZE, 1, gs->mapym1); e->squares.reserve((e->y2 - e->y1 + 1) * (e->x2 - e->x1 + 1)); const float* curHeightMap = readMap->GetCornerHeightMapSynced(); @@ -100,9 +94,9 @@ const float relDist = std::min(1.0f, expDist * invRadius); const unsigned int tableIdx = relDist * CRATER_TABLE_SIZE; - float dif = - baseStrength * craterTable[tableIdx] * - invHardness[typeMap[(y / 2) * gs->hmapx + x / 2]]; + float dif = baseStrength; + dif *= craterTable[tableIdx]; + dif *= invHardness[typeMap[(y / 2) * gs->hmapx + x / 2]]; // FIXME: compensate for flattened ground under dead buildings const float prevDif = @@ -116,7 +110,7 @@ e->squares.push_back(dif); if (dif < -0.3f && strength > 200.0f) { - treeDrawer->RemoveGrass(x, y); + grassDrawer->RemoveGrass(float3(x * SQUARE_SIZE, 0.0f, y * SQUARE_SIZE)); } } } @@ -124,9 +118,7 @@ // calculate how much to offset the buildings in the explosion radius with // (while still keeping the ground below them flat) const std::vector& units = quadField->GetUnitsExact(pos, radius); - for (std::vector::const_iterator ui = units.begin(); ui != units.end(); ++ui) { - CUnit* unit = *ui; - + for (const CUnit* unit: units) { if (!unit->blockHeightChanges) { continue; } if (!unit->IsBlocking()) { continue; } @@ -158,7 +150,7 @@ if (totalDif != 0.0f) { ExploBuilding eb; - eb.id = (*ui)->id; + eb.id = unit->id; eb.dif = totalDif; eb.tx1 = unit->mapPos.x; eb.tx2 = unit->mapPos.x + unit->xsize; @@ -214,49 +206,35 @@ { SCOPED_TIMER("BasicMapDamage::Update"); - std::deque::iterator ei; - - for (ei = explosions.begin(); ei != explosions.end(); ++ei) { - Explo* e = *ei; + for (Explo* e: explosions) { if (e->ttl <= 0) { continue; } --e->ttl; - const int x1 = e->x1; - const int x2 = e->x2; - const int y1 = e->y1; - const int y2 = e->y2; std::vector::const_iterator si = e->squares.begin(); - - for (int y = y1; y <= y2; ++y) { - for (int x = x1; x<= x2; ++x) { + for (int y = e->y1; y <= e->y2; ++y) { + for (int x = e->x1; x <= e->x2; ++x) { const float dif = *(si++); readMap->AddHeight(y * gs->mapxp1 + x, dif); } } - std::vector::const_iterator bi; - for (bi = e->buildings.begin(); bi != e->buildings.end(); ++bi) { - const float dif = bi->dif; - const int tx1 = bi->tx1; - const int tx2 = bi->tx2; - const int tz1 = bi->tz1; - const int tz2 = bi->tz2; - - for (int z = tz1; z < tz2; z++) { - for (int x = tx1; x < tx2; x++) { - readMap->AddHeight(z * gs->mapxp1 + x, dif); + + for (ExploBuilding& b: e->buildings) { + for (int z = b.tz1; z < b.tz2; z++) { + for (int x = b.tx1; x < b.tx2; x++) { + readMap->AddHeight(z * gs->mapxp1 + x, b.dif); } } - CUnit* unit = unitHandler->GetUnit(bi->id); - + CUnit* unit = unitHandler->GetUnit(b.id); if (unit != NULL) { - unit->Move(UpVector * dif, true); + unit->Move(UpVector * b.dif, true); } } + if (e->ttl == 0) { - RecalcArea(x1 - 2, x2 + 2, y1 - 2, y2 + 2); + RecalcArea(e->x1 - 1, e->x2 + 1, e->y1 - 1, e->y2 + 1); } } diff -Nru spring-96.0~14.04~ppa4/rts/Map/CMakeLists.txt spring-98.0~14.04~ppa6/rts/Map/CMakeLists.txt --- spring-96.0~14.04~ppa4/rts/Map/CMakeLists.txt 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -36,6 +36,6 @@ "${CMAKE_CURRENT_SOURCE_DIR}/SMF/Legacy/LegacyMeshDrawer.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/SMF/ROAM/Patch.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/SMF/ROAM/RoamMeshDrawer.cpp" + PARENT_SCOPE ) -MakeGlobal(sources_engine_Map) diff -Nru spring-96.0~14.04~ppa4/rts/Map/Ground.cpp spring-98.0~14.04~ppa6/rts/Map/Ground.cpp --- spring-96.0~14.04~ppa4/rts/Map/Ground.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/Ground.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -3,9 +3,6 @@ #include "Ground.h" #include "ReadMap.h" -#include "Game/Camera.h" -#include "Sim/Misc/GeometricObjects.h" -#include "Sim/Projectiles/Projectile.h" #include "System/myMath.h" #include @@ -14,7 +11,7 @@ #undef far // avoid collision with windef.h #undef near -static inline float InterpolateHeight(float x, float y, const float* heightmap) +static inline float InterpolateHeight(float x, float z, const float* heightmap) { // NOTE: // This isn't a bilinear interpolation. Instead it interpolates @@ -22,45 +19,45 @@ // // TL __________ TR // | /| - // | dx+dy / | + // | dx+dz / | // | \<1 / | // | / | // | / | // | / | - // | / dx+dy| + // | / dx+dz| // | / \>=1 | // |/ | // BL ---------- BR - x = Clamp(x, 0.f, float3::maxxpos) / SQUARE_SIZE; - y = Clamp(y, 0.f, float3::maxzpos) / SQUARE_SIZE; + x = Clamp(x, 0.0f, float3::maxxpos) / SQUARE_SIZE; + z = Clamp(z, 0.0f, float3::maxzpos) / SQUARE_SIZE; const int isx = x; - const int isy = y; + const int isz = z; const float dx = x - isx; - const float dy = y - isy; - const int hs = isx + isy * gs->mapxp1; + const float dz = z - isz; + const int hs = isx + isz * gs->mapxp1; float h = 0.0f; - if (dx + dy < 1.0f) { + if (dx + dz < 1.0f) { // top-left triangle const float h00 = heightmap[hs ]; const float h10 = heightmap[hs + 1 ]; const float h01 = heightmap[hs + gs->mapxp1]; - const float xdif = (dx) * (h10 - h00); - const float ydif = (dy) * (h01 - h00); + const float xdif = dx * (h10 - h00); + const float zdif = dz * (h01 - h00); - h = h00 + xdif + ydif; + h = h00 + xdif + zdif; } else { // bottom-right triangle const float h10 = heightmap[hs + 1 ]; const float h11 = heightmap[hs + 1 + gs->mapxp1]; const float h01 = heightmap[hs + gs->mapxp1]; const float xdif = (1.0f - dx) * (h01 - h11); - const float ydif = (1.0f - dy) * (h10 - h11); + const float zdif = (1.0f - dz) * (h10 - h11); - h = h11 + xdif + ydif; + h = h11 + xdif + zdif; } return h; @@ -143,13 +140,6 @@ -CGround* ground = NULL; - -CGround::~CGround() -{ - delete readMap; readMap = NULL; -} - /* void CGround::CheckColSquare(CProjectile* p, int x, int y) { @@ -213,7 +203,7 @@ } -float CGround::LineGroundCol(float3 from, float3 to, bool synced) const +float CGround::LineGroundCol(float3 from, float3 to, bool synced) { const float* hm = readMap->GetSharedCornerHeightMap(synced); const float3* nm = readMap->GetSharedFaceNormals(synced); @@ -384,32 +374,32 @@ } -float CGround::GetApproximateHeight(float x, float y, bool synced) const +float CGround::GetApproximateHeight(float x, float z, bool synced) { const int xsquare = Clamp(int(x) / SQUARE_SIZE, 0, gs->mapxm1); - const int ysquare = Clamp(int(y) / SQUARE_SIZE, 0, gs->mapym1); + const int zsquare = Clamp(int(z) / SQUARE_SIZE, 0, gs->mapym1); const float* heightMap = readMap->GetSharedCenterHeightMap(synced); - return heightMap[xsquare + ysquare * gs->mapx]; + return heightMap[xsquare + zsquare * gs->mapx]; } -float CGround::GetHeightAboveWater(float x, float y, bool synced) const +float CGround::GetHeightAboveWater(float x, float z, bool synced) { - return std::max(0.0f, GetHeightReal(x, y, synced)); + return std::max(0.0f, GetHeightReal(x, z, synced)); } -float CGround::GetHeightReal(float x, float y, bool synced) const +float CGround::GetHeightReal(float x, float z, bool synced) { - return InterpolateHeight(x, y, readMap->GetSharedCornerHeightMap(synced)); + return InterpolateHeight(x, z, readMap->GetSharedCornerHeightMap(synced)); } -float CGround::GetOrigHeight(float x, float y) const +float CGround::GetOrigHeight(float x, float z) { - return InterpolateHeight(x, y, readMap->GetOriginalHeightMapSynced()); + return InterpolateHeight(x, z, readMap->GetOriginalHeightMapSynced()); } -const float3& CGround::GetNormal(float x, float z, bool synced) const +const float3& CGround::GetNormal(float x, float z, bool synced) { const int xsquare = Clamp(int(x) / SQUARE_SIZE, 0, gs->mapxm1); const int zsquare = Clamp(int(z) / SQUARE_SIZE, 0, gs->mapym1); @@ -418,56 +408,46 @@ return normalMap[xsquare + zsquare * gs->mapx]; } -const float3& CGround::GetNormalAboveWater(const float3& p, bool synced) const +const float3& CGround::GetNormalAboveWater(float x, float z, bool synced) { - if (GetHeightReal(p.x, p.z, synced) <= 0.0f) + if (GetHeightReal(x, z, synced) <= 0.0f) return UpVector; - return (GetNormal(p.x, p.z, synced)); + return (GetNormal(x, z, synced)); } -float CGround::GetSlope(float x, float y, bool synced) const +float CGround::GetSlope(float x, float z, bool synced) { const int xhsquare = Clamp(int(x) / (2 * SQUARE_SIZE), 0, gs->hmapx - 1); - const int yhsquare = Clamp(int(y) / (2 * SQUARE_SIZE), 0, gs->hmapy - 1); + const int zhsquare = Clamp(int(z) / (2 * SQUARE_SIZE), 0, gs->hmapy - 1); const float* slopeMap = readMap->GetSharedSlopeMap(synced); - return slopeMap[xhsquare + yhsquare * gs->hmapx]; + return slopeMap[xhsquare + zhsquare * gs->hmapx]; } -float3 CGround::GetSmoothNormal(float x, float y, bool synced) const +float3 CGround::GetSmoothNormal(float x, float z, bool synced) { - int sx = (int) math::floor(x / SQUARE_SIZE); - int sy = (int) math::floor(y / SQUARE_SIZE); - - if (sy < 1) - sy = 1; - if (sx < 1) - sx = 1; - if (sy >= gs->mapym1) - sy = gs->mapy - 2; - if (sx >= gs->mapxm1) - sx = gs->mapx - 2; + const int sx = Clamp(int(math::floor(x / SQUARE_SIZE)), 1, gs->mapx - 2); + const int sz = Clamp(int(math::floor(z / SQUARE_SIZE)), 1, gs->mapy - 2); - float dx = (x / SQUARE_SIZE) - sx; - float dy = (y / SQUARE_SIZE) - sy; + const float dx = (x / SQUARE_SIZE) - sx; + const float dz = (z / SQUARE_SIZE) - sz; - int sy2; - float fy; + int sx2; + int sz2; + float fx; + float fz; - if (dy > 0.5f) { - sy2 = sy + 1; - fy = dy - 0.5f; + if (dz > 0.5f) { + sz2 = sz + 1; + fz = dz - 0.5f; } else { - sy2 = sy - 1; - fy = 0.5f - dy; + sz2 = sz - 1; + fz = 0.5f - dz; } - int sx2; - float fx; - if (dx > 0.5f) { sx2 = sx + 1; fx = dx - 0.5f; @@ -476,28 +456,25 @@ fx = 0.5f - dx; } - float ify = 1.0f - fy; - float ifx = 1.0f - fx; + const float ifz = 1.0f - fz; + const float ifx = 1.0f - fx; const float3* normalMap = readMap->GetSharedCenterNormals(synced); - const float3& n1 = normalMap[sy * gs->mapx + sx ] * ifx * ify; - const float3& n2 = normalMap[sy * gs->mapx + sx2] * fx * ify; - const float3& n3 = normalMap[sy2 * gs->mapx + sx ] * ifx * fy; - const float3& n4 = normalMap[sy2 * gs->mapx + sx2] * fx * fy; - - float3 norm1 = n1 + n2 + n3 + n4; - norm1.Normalize(); + const float3& n1 = normalMap[sz * gs->mapx + sx ] * ifx * ifz; + const float3& n2 = normalMap[sz * gs->mapx + sx2] * fx * ifz; + const float3& n3 = normalMap[sz2 * gs->mapx + sx ] * ifx * fz; + const float3& n4 = normalMap[sz2 * gs->mapx + sx2] * fx * fz; - return norm1; + return ((n1 + n2 + n3 + n4).Normalize()); } -float CGround::TrajectoryGroundCol(float3 from, const float3& flatdir, float length, float linear, float quadratic) const +float CGround::TrajectoryGroundCol(float3 from, const float3& flatdir, float length, float linear, float quadratic) { float3 dir(flatdir.x, linear, flatdir.z); // limit the checking to the `in map part` of the line - std::pair near_far = GetMapBoundaryIntersectionPoints(from, dir*length); + std::pair near_far = GetMapBoundaryIntersectionPoints(from, dir * length); // outside of map if (near_far.second < 0.0f) @@ -507,8 +484,7 @@ const float far = length * std::min(1.0f, near_far.second); for (float l = near; l < far; l += SQUARE_SIZE) { - float3 pos(from + dir*l); - pos.y += quadratic * l * l; + const float3 pos = (from + dir * l) + (UpVector * quadratic * l * l); if (GetApproximateHeight(pos.x, pos.z) > pos.y) { return l; @@ -517,3 +493,4 @@ return -1.0f; } + diff -Nru spring-96.0~14.04~ppa4/rts/Map/Ground.h spring-98.0~14.04~ppa6/rts/Map/Ground.h --- spring-96.0~14.04~ppa4/rts/Map/Ground.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/Ground.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,41 +7,42 @@ #include "Sim/Misc/GlobalConstants.h" #include "Sim/Misc/GlobalSynced.h" -class CProjectile; - - class CGround { public: - CGround() {} - ~CGround(); - /// similar to GetHeightReal, but uses nearest filtering instead of interpolating the heightmap - float GetApproximateHeight(float x, float y, bool synced = true) const; + static float GetApproximateHeight(float x, float z, bool synced = true); /// Returns the height at the specified position, cropped to a non-negative value - float GetHeightAboveWater(float x, float y, bool synced = true) const; + static float GetHeightAboveWater(float x, float z, bool synced = true); /// Returns the real height at the specified position, can be below 0 - float GetHeightReal(float x, float y, bool synced = true) const; - float GetOrigHeight(float x, float y) const; - - float GetSlope(float x, float y, bool synced = true) const; - const float3& GetNormal(float x, float y, bool synced = true) const; - const float3& GetNormalAboveWater(const float3& p, bool synced = true) const; - float3 GetSmoothNormal(float x, float y, bool synced = true) const; + static float GetHeightReal(float x, float z, bool synced = true); + static float GetOrigHeight(float x, float z); - float LineGroundCol(float3 from, float3 to, bool synced = true) const; - float TrajectoryGroundCol(float3 from, const float3& flatdir, float length, float linear, float quadratic) const; - - inline int GetSquare(const float3& pos) const { - return std::max(0, std::min(gs->mapxm1, (int(pos.x) / SQUARE_SIZE))) + + static float GetSlope(float x, float z, bool synced = true); + static const float3& GetNormal(float x, float z, bool synced = true); + static const float3& GetNormalAboveWater(float x, float z, bool synced = true); + static float3 GetSmoothNormal(float x, float z, bool synced = true); + + static float GetApproximateHeight(const float3& p, bool synced = true) { return (GetApproximateHeight(p.x, p.z, synced)); } + static float GetHeightAboveWater(const float3& p, bool synced = true) { return (GetHeightAboveWater(p.x, p.z, synced)); } + static float GetHeightReal(const float3& p, bool synced = true) { return (GetHeightReal(p.x, p.z, synced)); } + static float GetOrigHeight(const float3& p) { return (GetOrigHeight(p.x, p.z)); } + + static float GetSlope(const float3& p, bool synced = true) { return (GetSlope(p.x, p.z, synced)); } + static const float3& GetNormal(const float3& p, bool synced = true) { return (GetNormal(p.x, p.z, synced)); } + static const float3& GetNormalAboveWater(const float3& p, bool synced = true) { return (GetNormalAboveWater(p.x, p.z, synced)); } + static float3 GetSmoothNormal(const float3& p, bool synced = true) { return (GetSmoothNormal(p.x, p.z, synced)); } + + + static float LineGroundCol(float3 from, float3 to, bool synced = true); + static float TrajectoryGroundCol(float3 from, const float3& flatdir, float length, float linear, float quadratic); + + static inline int GetSquare(const float3& pos) { + return + std::max(0, std::min(gs->mapxm1, (int(pos.x) / SQUARE_SIZE))) + std::max(0, std::min(gs->mapym1, (int(pos.z) / SQUARE_SIZE))) * gs->mapx; }; -private: - - void CheckColSquare(CProjectile* p, int x, int y); }; -extern CGround* ground; - #endif // GROUND_H diff -Nru spring-96.0~14.04~ppa4/rts/Map/HeightMapTexture.cpp spring-98.0~14.04~ppa6/rts/Map/HeightMapTexture.cpp --- spring-96.0~14.04~ppa4/rts/Map/HeightMapTexture.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/HeightMapTexture.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -88,24 +88,24 @@ const int sizeZ = rect.z2 - rect.z1 + 1; pbo.Bind(); - pbo.Resize(sizeX * sizeZ * sizeof(float)); + pbo.New(sizeX * sizeZ * sizeof(float)); { float* buf = (float*) pbo.MapBuffer(); - for (int z = 0; z < sizeZ; z++) { const void* src = heightMap + rect.x1 + (z + rect.z1) * xSize; void* dst = buf + z * sizeX; memcpy(dst, src, sizeX * sizeof(float)); } + pbo.UnmapBuffer(); } - pbo.UnmapBuffer(); - glBindTexture(GL_TEXTURE_2D, texID); glTexSubImage2D(GL_TEXTURE_2D, 0, rect.x1, rect.z1, sizeX, sizeZ, GL_LUMINANCE, GL_FLOAT, pbo.GetPtr()); + + pbo.Invalidate(); pbo.Unbind(); } diff -Nru spring-96.0~14.04~ppa4/rts/Map/MapInfo.cpp spring-98.0~14.04~ppa6/rts/Map/MapInfo.cpp --- spring-96.0~14.04~ppa4/rts/Map/MapInfo.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/MapInfo.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -12,10 +12,8 @@ #include "System/Exceptions.h" #include "System/myMath.h" -#if !defined(HEADLESS) && !defined(NO_SOUND) - #include "System/Sound/EFX.h" - #include "System/Sound/EFXPresets.h" -#endif +#include "System/Sound/OpenAL/EFX.h" +#include "System/Sound/OpenAL/EFXPresets.h" #include #include @@ -163,17 +161,17 @@ { const LuaTable& grassTable = parser->GetRoot().SubTable("grass"); const LuaTable& mapResTable = parser->GetRoot().SubTable("resources"); - - grass.bladeWaveScale = grassTable.GetFloat("bladeWaveScale", 1.0f); - grass.bladeWidth = grassTable.GetFloat("bladeWidth", 0.32f); - grass.bladeHeight = grassTable.GetFloat("bladeHeight", 4.0f); - grass.bladeAngle = grassTable.GetFloat("bladeAngle", 1.57f); - grass.color = grassTable.GetFloat3("bladeColor", float3(0.59f, 0.81f, 0.57f)); - - grass.grassBladeTexName = mapResTable.GetString("grassBladeTex", ""); - if (!grass.grassBladeTexName.empty()) { - grass.grassBladeTexName = "maps/" + grass.grassBladeTexName; + grass.bladeWaveScale = grassTable.GetFloat("bladeWaveScale", 1.0f); + grass.bladeWidth = grassTable.GetFloat("bladeWidth", 0.7f); + grass.bladeHeight = grassTable.GetFloat("bladeHeight", 4.5f); + grass.bladeAngle = grassTable.GetFloat("bladeAngle", 1.0f); + grass.maxStrawsPerTurf = grassTable.GetInt("maxStrawsPerTurf", 150); + grass.color = grassTable.GetFloat3("bladeColor", float3(0.10f, 0.40f, 0.10f)); + + grass.bladeTexName = mapResTable.GetString("grassBladeTex", ""); + if (!grass.bladeTexName.empty()) { //FIXME only do when file doesn't exists under that path + grass.bladeTexName = "maps/" + grass.bladeTexName; } } diff -Nru spring-96.0~14.04~ppa4/rts/Map/MapInfo.h spring-98.0~14.04~ppa6/rts/Map/MapInfo.h --- spring-96.0~14.04~ppa4/rts/Map/MapInfo.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/MapInfo.h 2014-10-07 20:09:51.000000000 +0000 @@ -110,8 +110,9 @@ float bladeWidth; float bladeHeight; //! actual blades will be (bladeHeight + randf(0, bladeHeight)) tall float bladeAngle; - float4 color; - std::string grassBladeTexName; // defaults to internally-generated texture + int maxStrawsPerTurf; + float3 color; + std::string bladeTexName; // defaults to internally-generated texture } grass; /** settings read from "MAP\LIGHT" section */ diff -Nru spring-96.0~14.04~ppa4/rts/Map/MapParser.h spring-98.0~14.04~ppa6/rts/Map/MapParser.h --- spring-96.0~14.04~ppa4/rts/Map/MapParser.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/MapParser.h 2014-10-07 20:09:51.000000000 +0000 @@ -19,6 +19,9 @@ MapParser(const std::string& mapFileName); ~MapParser(); + // no-copy + MapParser(const MapParser&) = delete; + LuaParser* GetParser() { return parser; } LuaTable GetRoot(); diff -Nru spring-96.0~14.04~ppa4/rts/Map/MetalMap.cpp spring-98.0~14.04~ppa6/rts/Map/MetalMap.cpp --- spring-96.0~14.04~ppa4/rts/Map/MetalMap.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/MetalMap.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -8,7 +8,7 @@ CONFIG(bool, MetalMapPalette).defaultValue(false); -CR_BIND(CMetalMap,(NULL, 0, 0, 0.0f)); +CR_BIND(CMetalMap,(NULL, 0, 0, 0.0f)) CR_REG_METADATA(CMetalMap,( CR_MEMBER(metalScale), @@ -17,7 +17,7 @@ CR_MEMBER(metalPal), CR_MEMBER(distributionMap), CR_MEMBER(extractionMap) -)); +)) CMetalMap::CMetalMap(const unsigned char* map, int _sizeX, int _sizeZ, float _metalScale) : metalScale(_metalScale) diff -Nru spring-96.0~14.04~ppa4/rts/Map/MetalMap.h spring-98.0~14.04~ppa6/rts/Map/MetalMap.h --- spring-96.0~14.04~ppa4/rts/Map/MetalMap.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/MetalMap.h 2014-10-07 20:09:51.000000000 +0000 @@ -14,7 +14,7 @@ class CMetalMap { - CR_DECLARE_STRUCT(CMetalMap); + CR_DECLARE_STRUCT(CMetalMap) public: /** Receiving a map over all metal, and creating a map over extraction. */ diff -Nru spring-96.0~14.04~ppa4/rts/Map/ReadMap.cpp spring-98.0~14.04~ppa6/rts/Map/ReadMap.cpp --- spring-96.0~14.04~ppa4/rts/Map/ReadMap.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/ReadMap.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -9,7 +9,6 @@ #include "MetalMap.h" // #include "SM3/SM3Map.h" #include "SMF/SMFReadMap.h" -#include "lib/gml/gmlmut.h" #include "Game/LoadScreen.h" #include "System/bitops.h" #include "System/EventHandler.h" @@ -67,7 +66,7 @@ CR_MEMBER(unsyncedHeightMapUpdatesTemp), HEIGHTMAP_DIGESTS CR_SERIALIZER(Serialize) -)); +)) CReadMap* CReadMap::LoadMap(const std::string& mapname) @@ -273,8 +272,6 @@ std::list::const_iterator ushmuIt; { - GML_STDMUTEX_LOCK(map); // UpdateDraw - if (!unsyncedHeightMapUpdates.empty()) unsyncedHeightMapUpdates.swap(unsyncedHeightMapUpdatesTemp); // swap to avoid Optimize() inside a mutex } @@ -299,8 +296,6 @@ } } if (!unsyncedHeightMapUpdatesTemp.empty()) { - GML_STDMUTEX_LOCK(map); // UpdateDraw - unsyncedHeightMapUpdates.splice(unsyncedHeightMapUpdates.end(), unsyncedHeightMapUpdatesTemp); } // unsyncedHeightMapUpdatesTemp is now guaranteed empty @@ -335,7 +330,6 @@ // push the unsynced update if (initialize) { // push 1st update through without LOS check - GML_STDMUTEX_LOCK(map); // UpdateHeightMapSynced unsyncedHeightMapUpdates.push_back(rect); } else { InitHeightMapDigestsVectors(); @@ -355,7 +349,6 @@ HeightMapUpdateLOSCheck(rect); } #else - GML_STDMUTEX_LOCK(map); // UpdateHeightMapSynced unsyncedHeightMapUpdates.push_back(rect); #endif } @@ -521,8 +514,6 @@ /// split the update into multiple invididual (los-square) chunks: void CReadMap::HeightMapUpdateLOSCheck(const SRectangle& rect) { - GML_STDMUTEX_LOCK(map); // HeightMapUpdateLOSCheck - InitHeightMapDigestsVectors(); const int losSqSize = losHandler->losDiv / SQUARE_SIZE; // size of LOS square in heightmap coords const SRectangle& lm = rect * (SQUARE_SIZE * losHandler->invLosDiv); // LOS space diff -Nru spring-96.0~14.04~ppa4/rts/Map/ReadMap.h spring-98.0~14.04~ppa6/rts/Map/ReadMap.h --- spring-96.0~14.04~ppa4/rts/Map/ReadMap.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/ReadMap.h 2014-10-07 20:09:51.000000000 +0000 @@ -53,7 +53,7 @@ virtual void UpdateHeightMapUnsynced(const SRectangle&) = 0; public: - CR_DECLARE(CReadMap); + CR_DECLARE(CReadMap) static CReadMap* LoadMap(const std::string& mapname); static inline unsigned char EncodeHeight(const float h) { diff -Nru spring-96.0~14.04~ppa4/rts/Map/SM3/Frustum.cpp spring-98.0~14.04~ppa6/rts/Map/SM3/Frustum.cpp --- spring-96.0~14.04~ppa4/rts/Map/SM3/Frustum.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/SM3/Frustum.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -98,15 +98,14 @@ { bool full = true; Vector3 c,f; - float dc, df; std::vector::iterator p; for(p=planes.begin(); p!=planes.end(); ++p) { BoxPlaneVerts (min, max, p->GetVector(), c, f); - dc = p->Dist (&c); - df = p->Dist (&f); + const float dc = p->Dist(&c); + const float df = p->Dist(&f); if(dc < 0.0f || df < 0.0f) full=false; if(dc < 0.0f && df < 0.0f) return Outside; } diff -Nru spring-96.0~14.04~ppa4/rts/Map/SM3/SM3Map.cpp spring-98.0~14.04~ppa6/rts/Map/SM3/SM3Map.cpp --- spring-96.0~14.04~ppa4/rts/Map/SM3/SM3Map.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/SM3/SM3Map.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -98,6 +98,7 @@ CSM3ReadMap::~CSM3ReadMap() { + configHandler->RemoveObserver(this); delete groundDrawer; delete renderer; diff -Nru spring-96.0~14.04~ppa4/rts/Map/SM3/terrain/Terrain.cpp spring-98.0~14.04~ppa6/rts/Map/SM3/terrain/Terrain.cpp --- spring-96.0~14.04~ppa4/rts/Map/SM3/terrain/Terrain.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/SM3/terrain/Terrain.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -624,15 +624,13 @@ texturing->BeginTexturing(); for (int pass = 0; pass < numPasses; pass++) { - bool skipNodes = false; - texturing->BeginPass(pass); for (size_t a = 0; a < activeRC->quads.size(); a++) { TQuad* q = activeRC->quads[a].quad; // Setup node texturing - skipNodes = !texturing->SetupNode(q, pass); + const bool skipNodes = !texturing->SetupNode(q, pass); assert(q->renderData); diff -Nru spring-96.0~14.04~ppa4/rts/Map/SM3/terrain/TerrainUtil.cpp spring-98.0~14.04~ppa6/rts/Map/SM3/terrain/TerrainUtil.cpp --- spring-96.0~14.04~ppa4/rts/Map/SM3/terrain/TerrainUtil.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/SM3/terrain/TerrainUtil.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -253,7 +253,7 @@ bool AlphaImage::CopyFromBitmap(CBitmap& bm) { - if (bm.type != CBitmap::BitmapTypeStandardAlpha) + if (bm.channels != 1 || bitmap.compressed) return false; Alloc(bm.xsize, bm.ysize); diff -Nru spring-96.0~14.04~ppa4/rts/Map/SMF/Legacy/LegacyMeshDrawer.cpp spring-98.0~14.04~ppa6/rts/Map/SMF/Legacy/LegacyMeshDrawer.cpp --- spring-96.0~14.04~ppa4/rts/Map/SMF/Legacy/LegacyMeshDrawer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/SMF/Legacy/LegacyMeshDrawer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -15,40 +15,13 @@ #define CLAMP(i) Clamp((i), 0, smfReadMap->maxHeightMapIdx) -#ifdef USE_GML -#include "lib/gml/gmlsrv.h" -extern gmlClientServer* gmlProcessor; - -void CLegacyMeshDrawer::DoDrawGroundRowMT(void* c, int bty) { - ((CLegacyMeshDrawer*) c)->DoDrawGroundRow(cam2, bty); -} - -void CLegacyMeshDrawer::DoDrawGroundShadowLODMT(void* c, int nlod) { - ((CLegacyMeshDrawer*) c)->DoDrawGroundShadowLOD(nlod); -} - -CONFIG(bool, MultiThreadDrawGround).defaultValue(true); -CONFIG(bool, MultiThreadDrawGroundShadow).defaultValue(false); - -#endif - - CLegacyMeshDrawer::CLegacyMeshDrawer(CSMFReadMap* rm, CSMFGroundDrawer* gd) : smfReadMap(rm) , smfGroundDrawer(gd) , viewRadius(4) , neededLod(4) //, waterDrawn(false) -#ifdef USE_GML - // handled by reference! - , multiThreadDrawGround(gd->multiThreadDrawGround) - , multiThreadDrawGroundShadow(gd->multiThreadDrawGroundShadow) -#endif -{ -#ifdef USE_GML - multiThreadDrawGround = configHandler->GetBool("MultiThreadDrawGround"); - multiThreadDrawGroundShadow = configHandler->GetBool("MultiThreadDrawGroundShadow"); -#endif +{ } CLegacyMeshDrawer::~CLegacyMeshDrawer() @@ -76,10 +49,6 @@ ma->AddVertexQ0(x * SQUARE_SIZE, height, y * SQUARE_SIZE); } -void CLegacyMeshDrawer::EndStripQ(CVertexArray* ma) -{ - ma->EndStripQ(); -} void CLegacyMeshDrawer::DrawGroundVertexArrayQ(CVertexArray*& ma) { @@ -265,7 +234,7 @@ int yhlod = y + hlod; int nloop = (xe - xs) / lod + 1; - ma->EnlargeArrays((52 * nloop), 14 * nloop + 1); + ma->EnlargeArrays(52 * nloop); int yhdx = y * smfReadMap->heightMapSizeX; int ylhdx = yhdx + lod * smfReadMap->heightMapSizeX; @@ -300,7 +269,7 @@ float h4 = (GetVisibleVertexHeight(idx2) + GetVisibleVertexHeight(idx2LOD)) * hmocxp + GetVisibleVertexHeight(idx2HLOD) * oldcamxpart; if (inStrip) { - EndStripQ(ma); + ma->EndStrip(); inStrip = false; } @@ -308,18 +277,18 @@ DrawVertexAQ(ma, x, yhlod, h1); DrawVertexAQ(ma, xhlod, y, h2); DrawVertexAQ(ma, xhlod, yhlod, h3); - EndStripQ(ma); + ma->EndStrip(); DrawVertexAQ(ma, x, yhlod, h1); DrawVertexAQ(ma, x, ylod); DrawVertexAQ(ma, xhlod, yhlod, h3); DrawVertexAQ(ma, xhlod, ylod, h4); - EndStripQ(ma); + ma->EndStrip(); DrawVertexAQ(ma, xhlod, ylod, h4); DrawVertexAQ(ma, xlod, ylod); DrawVertexAQ(ma, xhlod, yhlod, h3); DrawVertexAQ(ma, xlod, y); DrawVertexAQ(ma, xhlod, y, h2); - EndStripQ(ma); + ma->EndStrip(); } else if ((x <= cx - vrhlod)) { //! lower LOD to the left @@ -332,7 +301,7 @@ float h4 = (GetVisibleVertexHeight(idx2 ) + GetVisibleVertexHeight(idx2LOD)) * hocxp + GetVisibleVertexHeight(idx2HLOD) * mocxp; if (inStrip) { - EndStripQ(ma); + ma->EndStrip(); inStrip = false; } @@ -340,18 +309,18 @@ DrawVertexAQ(ma, xlod, y); DrawVertexAQ(ma, xhlod, yhlod, h3); DrawVertexAQ(ma, xhlod, y, h2); - EndStripQ(ma); + ma->EndStrip(); DrawVertexAQ(ma, xlod, ylod); DrawVertexAQ(ma, xlod, yhlod, h1); DrawVertexAQ(ma, xhlod, ylod, h4); DrawVertexAQ(ma, xhlod, yhlod, h3); - EndStripQ(ma); + ma->EndStrip(); DrawVertexAQ(ma, xhlod, y, h2); DrawVertexAQ(ma, x, y); DrawVertexAQ(ma, xhlod, yhlod, h3); DrawVertexAQ(ma, x, ylod); DrawVertexAQ(ma, xhlod, ylod, h4); - EndStripQ(ma); + ma->EndStrip(); } if ((y >= cy + vrhlod)) { @@ -365,7 +334,7 @@ float h4 = (GetVisibleVertexHeight(idx2LOD) + GetVisibleVertexHeight(idx1LOD)) * hmocyp + GetVisibleVertexHeight(idx3LOD ) * oldcamypart; if (inStrip) { - EndStripQ(ma); + ma->EndStrip(); inStrip = false; } @@ -375,13 +344,13 @@ DrawVertexAQ(ma, xhlod, yhlod, h3); DrawVertexAQ(ma, xlod, y); DrawVertexAQ(ma, xlod, yhlod, h4); - EndStripQ(ma); + ma->EndStrip(); DrawVertexAQ(ma, x, yhlod, h2); DrawVertexAQ(ma, x, ylod); DrawVertexAQ(ma, xhlod, yhlod, h3); DrawVertexAQ(ma, xlod, ylod); DrawVertexAQ(ma, xlod, yhlod, h4); - EndStripQ(ma); + ma->EndStrip(); } else if ((y <= cy - vrhlod)) { //! lower LOD beneath @@ -394,7 +363,7 @@ float h4 = (GetVisibleVertexHeight(idx2LOD) + GetVisibleVertexHeight(idx1LOD)) * hocyp + GetVisibleVertexHeight(idx3LOD ) * mocyp; if (inStrip) { - EndStripQ(ma); + ma->EndStrip(); inStrip = false; } @@ -404,19 +373,19 @@ DrawVertexAQ(ma, xhlod, ylod, h1); DrawVertexAQ(ma, xlod, yhlod, h4); DrawVertexAQ(ma, xlod, ylod); - EndStripQ(ma); + ma->EndStrip(); DrawVertexAQ(ma, xlod, yhlod, h4); DrawVertexAQ(ma, xlod, y); DrawVertexAQ(ma, xhlod, yhlod, h3); DrawVertexAQ(ma, x, y); DrawVertexAQ(ma, x, yhlod, h2); - EndStripQ(ma); + ma->EndStrip(); } } } if (inStrip) { - EndStripQ(ma); + ma->EndStrip(); inStrip = false; } } //for (y = ystart; y < yend; y += lod) @@ -426,7 +395,7 @@ int nloop = (yed - yst) / lod + 1; if (nloop > 0) - ma->EnlargeArrays((8 * nloop), 2 * nloop); + ma->EnlargeArrays(8 * nloop); //! rita yttre begr?snings yta mot n?ta lod if (maxlx < maxtx && maxlx >= mintx) { @@ -451,7 +420,7 @@ DrawVertexAQ(ma, xlod, y); DrawVertexAQ(ma, xlod, y + lod, h); } - EndStripQ(ma); + ma->EndStrip(); } } @@ -476,7 +445,7 @@ } DrawVertexAQ(ma, xlod, y); DrawVertexAQ(ma, xlod, y + lod); - EndStripQ(ma); + ma->EndStrip(); } } @@ -492,7 +461,7 @@ int nloop = (xe - xs) / lod + 2; //! one extra for if statment int ylhdx = (y + lod) * smfReadMap->heightMapSizeX; - ma->EnlargeArrays((2 * nloop), 1); + ma->EnlargeArrays(2 * nloop); if (x % dlod) { int idx2 = CLAMP(ylhdx + x), idx2PLOD = CLAMP(idx2 + lod), idx2MLOD = CLAMP(idx2 - lod); @@ -514,7 +483,7 @@ DrawVertexAQ(ma, x + lod, ylod, h); } } - EndStripQ(ma); + ma->EndStrip(); } } @@ -530,7 +499,7 @@ int yhdx = y * smfReadMap->heightMapSizeX; int nloop = (xe - xs) / lod + 2; //! one extra for if statment - ma->EnlargeArrays((2 * nloop), 1); + ma->EnlargeArrays(2 * nloop); if (x % dlod) { int idx1 = CLAMP(yhdx + x), idx1PLOD = CLAMP(idx1 + lod), idx1MLOD = CLAMP(idx1 - lod); @@ -553,7 +522,7 @@ DrawVertexAQ(ma, x + lod, ylod); } } - EndStripQ(ma); + ma->EndStrip(); } } @@ -597,26 +566,6 @@ //waterDrawn = (drawPass == DrawPass::WaterReflection); { // profiler scope -#ifdef USE_GML - // Profiler results, 4 threads: multiThreadDrawGround is faster only if ViewRadius is below 60 (probably depends on memory/cache speeds) - const bool mt = GML_PROFILER(multiThreadDrawGround) - - if (mt) { - gmlProcessor->Work( - NULL, // wrk - &CLegacyMeshDrawer::DoDrawGroundRowMT, // wrka - NULL, // wrkit - this, // cls - gmlThreadCount, // mt - FALSE, // sm - NULL, // it - smfReadMap->numBigTexY, // nu - 50, // l1 - 100, // l2 - TRUE // sw - ); - } else -#endif { int camBty = math::floor(cam2->GetPos().z / (smfReadMap->bigSquareSize * SQUARE_SIZE)); camBty = std::max(0, std::min(smfReadMap->numBigTexY - 1, camBty)); @@ -703,9 +652,7 @@ int ydx = y * smfReadMap->heightMapSizeX; int nloop = (xe - xs) / lod + 1; - //! EnlargeArrays(nVertices, nStrips [, stripSize]) - //! includes one extra for final endstrip - ma->EnlargeArrays((52 * nloop), 14 * nloop + 1); + ma->EnlargeArrays(52 * nloop); for (x = xs; x < xe; x += lod) { int xlod = x + lod; @@ -733,25 +680,25 @@ const float h4 = (GetVisibleVertexHeight(ylhdx) + GetVisibleVertexHeight(ylhdx+lod)) * hmocxp + GetVisibleVertexHeight(ylhdx+hlod) * oldcamxpart; if(inStrip){ - EndStripQ(ma); + ma->EndStrip(); inStrip=false; } DrawVertexAQ(ma, x,y); DrawVertexAQ(ma, x,yhlod,h1); DrawVertexAQ(ma, xhlod,y,h2); DrawVertexAQ(ma, xhlod,yhlod,h3); - EndStripQ(ma); + ma->EndStrip(); DrawVertexAQ(ma, x,yhlod,h1); DrawVertexAQ(ma, x,ylod); DrawVertexAQ(ma, xhlod,yhlod,h3); DrawVertexAQ(ma, xhlod,ylod,h4); - EndStripQ(ma); + ma->EndStrip(); DrawVertexAQ(ma, xhlod,ylod,h4); DrawVertexAQ(ma, xlod,ylod); DrawVertexAQ(ma, xhlod,yhlod,h3); DrawVertexAQ(ma, xlod,y); DrawVertexAQ(ma, xhlod,y,h2); - EndStripQ(ma); + ma->EndStrip(); } if (x <= cx - vrhlod) { const float h1 = (GetVisibleVertexHeight(yhdx+lod) + GetVisibleVertexHeight(ylhdx+lod)) * hocxp + GetVisibleVertexHeight(yhhdx+lod ) * mocxp; @@ -760,25 +707,25 @@ const float h4 = (GetVisibleVertexHeight(ylhdx ) + GetVisibleVertexHeight(ylhdx+lod)) * hocxp + GetVisibleVertexHeight(ylhdx+hlod) * mocxp; if(inStrip){ - EndStripQ(ma); + ma->EndStrip(); inStrip=false; } DrawVertexAQ(ma, xlod,yhlod,h1); DrawVertexAQ(ma, xlod,y); DrawVertexAQ(ma, xhlod,yhlod,h3); DrawVertexAQ(ma, xhlod,y,h2); - EndStripQ(ma); + ma->EndStrip(); DrawVertexAQ(ma, xlod,ylod); DrawVertexAQ(ma, xlod,yhlod,h1); DrawVertexAQ(ma, xhlod,ylod,h4); DrawVertexAQ(ma, xhlod,yhlod,h3); - EndStripQ(ma); + ma->EndStrip(); DrawVertexAQ(ma, xhlod,y,h2); DrawVertexAQ(ma, x,y); DrawVertexAQ(ma, xhlod,yhlod,h3); DrawVertexAQ(ma, x,ylod); DrawVertexAQ(ma, xhlod,ylod,h4); - EndStripQ(ma); + ma->EndStrip(); } if (y >= cy + vrhlod) { const float h1 = (GetVisibleVertexHeight(yhdx ) + GetVisibleVertexHeight(yhdx+lod)) * hmocyp + GetVisibleVertexHeight(yhdx+hlod ) * oldcamypart; @@ -787,7 +734,7 @@ const float h4 = (GetVisibleVertexHeight(ylhdx+lod) + GetVisibleVertexHeight(yhdx+lod)) * hmocyp + GetVisibleVertexHeight(yhhdx+lod ) * oldcamypart; if(inStrip){ - EndStripQ(ma); + ma->EndStrip(); inStrip=false; } DrawVertexAQ(ma, x,y); @@ -796,13 +743,13 @@ DrawVertexAQ(ma, xhlod,yhlod,h3); DrawVertexAQ(ma, xlod,y); DrawVertexAQ(ma, xlod,yhlod,h4); - EndStripQ(ma); + ma->EndStrip(); DrawVertexAQ(ma, x,yhlod,h2); DrawVertexAQ(ma, x,ylod); DrawVertexAQ(ma, xhlod,yhlod,h3); DrawVertexAQ(ma, xlod,ylod); DrawVertexAQ(ma, xlod,yhlod,h4); - EndStripQ(ma); + ma->EndStrip(); } if (y <= cy - vrhlod) { const float h1 = (GetVisibleVertexHeight(ylhdx ) + GetVisibleVertexHeight(ylhdx+lod)) * hocyp + GetVisibleVertexHeight(ylhdx+hlod) * mocyp; @@ -811,7 +758,7 @@ const float h4 = (GetVisibleVertexHeight(ylhdx+lod) + GetVisibleVertexHeight(yhdx+lod )) * hocyp + GetVisibleVertexHeight(yhhdx+lod ) * mocyp; if (inStrip) { - EndStripQ(ma); + ma->EndStrip(); inStrip = false; } DrawVertexAQ(ma, x,yhlod,h2); @@ -820,18 +767,18 @@ DrawVertexAQ(ma, xhlod,ylod,h1); DrawVertexAQ(ma, xlod,yhlod,h4); DrawVertexAQ(ma, xlod,ylod); - EndStripQ(ma); + ma->EndStrip(); DrawVertexAQ(ma, xlod,yhlod,h4); DrawVertexAQ(ma, xlod,y); DrawVertexAQ(ma, xhlod,yhlod,h3); DrawVertexAQ(ma, x,y); DrawVertexAQ(ma, x,yhlod,h2); - EndStripQ(ma); + ma->EndStrip(); } } } if (inStrip) { - EndStripQ(ma); + ma->EndStrip(); inStrip=false; } } @@ -839,9 +786,7 @@ int yst = std::max(ystart - lod, minty); int yed = std::min(yend + lod, maxty); int nloop = (yed - yst) / lod + 1; - - if (nloop > 0) - ma->EnlargeArrays((8 * nloop), 2 * nloop); + ma->EnlargeArrays(8 * nloop); //!rita yttre begr?snings yta mot n?ta lod if (maxlx < maxtx && maxlx >= mintx) { @@ -862,7 +807,7 @@ DrawVertexAQ(ma, xlod,y); DrawVertexAQ(ma, xlod,y+lod,h); } - EndStripQ(ma); + ma->EndStrip(); } } @@ -883,7 +828,7 @@ } DrawVertexAQ(ma, xlod,y); DrawVertexAQ(ma, xlod,y+lod); - EndStripQ(ma); + ma->EndStrip(); } } if (maxly < maxty && maxly > minty) { @@ -897,7 +842,7 @@ const int ydx = y * smfReadMap->heightMapSizeX; const int nloop = (xe - xs) / lod + 2; //! two extra for if statment - ma->EnlargeArrays((2 * nloop), 1); + ma->EnlargeArrays(2 * nloop); if (x % dlod) { const int ylhdx = ydx + x + lhdx; @@ -920,7 +865,7 @@ DrawVertexAQ(ma, x+lod,ylod,h); } } - EndStripQ(ma); + ma->EndStrip(); } } if (minly > minty && minly < maxty) { @@ -934,7 +879,7 @@ const int ydx = y * smfReadMap->heightMapSizeX; const int nloop = (xe - xs) / lod + 2; //! two extra for if statment - ma->EnlargeArrays((2 * nloop), 1); + ma->EnlargeArrays(2 * nloop); if (x % dlod) { const int yhdx = ydx + x; @@ -957,7 +902,7 @@ DrawVertexAQ(ma, x + lod, ylod); } } - EndStripQ(ma); + ma->EndStrip(); } } DrawGroundVertexArrayQ(ma); @@ -968,26 +913,6 @@ { { // profiler scope const int NUM_LODS = 4; -#ifdef USE_GML - // Profiler results, 4 threads: multiThreadDrawGroundShadow is rarely faster than single threaded rendering (therefore disabled by default) - const bool mt = GML_PROFILER(multiThreadDrawGroundShadow) - - if (mt) { - gmlProcessor->Work( - NULL, // wrk - &CLegacyMeshDrawer::DoDrawGroundShadowLODMT, // wrka - NULL, // wrkit - this, // cls - gmlThreadCount, // mt - FALSE, // sm - NULL, // it - NUM_LODS + 1, // nu - 50, // l1 - 100, // l2 - TRUE // sw - ); - } else -#endif { for (int nlod = 0; nlod < NUM_LODS + 1; ++nlod) { DoDrawGroundShadowLOD(nlod); diff -Nru spring-96.0~14.04~ppa4/rts/Map/SMF/Legacy/LegacyMeshDrawer.h spring-98.0~14.04~ppa6/rts/Map/SMF/Legacy/LegacyMeshDrawer.h --- spring-96.0~14.04~ppa4/rts/Map/SMF/Legacy/LegacyMeshDrawer.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/SMF/Legacy/LegacyMeshDrawer.h 2014-10-07 20:09:51.000000000 +0000 @@ -36,28 +36,17 @@ inline void DrawVertexAQ(CVertexArray* ma, int x, int y); inline void DrawVertexAQ(CVertexArray* ma, int x, int y, float height); - inline void EndStripQ(CVertexArray* ma); inline void DrawGroundVertexArrayQ(CVertexArray*& ma); void DoDrawGroundRow(const CCamera* cam, int bty); void DoDrawGroundShadowLOD(int nlod); -#ifdef USE_GML - static void DoDrawGroundRowMT(void* c, int bty); - static void DoDrawGroundShadowLODMT(void* c, int nlod); -#endif - private: CSMFReadMap* smfReadMap; CSMFGroundDrawer* smfGroundDrawer; int viewRadius; int neededLod; - -#ifdef USE_GML - bool& multiThreadDrawGround; - bool& multiThreadDrawGroundShadow; -#endif }; #endif // _LEGACY_MESH_DRAWER_H_ diff -Nru spring-96.0~14.04~ppa4/rts/Map/SMF/ROAM/Patch.cpp spring-98.0~14.04~ppa6/rts/Map/SMF/ROAM/Patch.cpp --- spring-96.0~14.04~ppa4/rts/Map/SMF/ROAM/Patch.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/SMF/ROAM/Patch.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -85,7 +85,6 @@ { const size_t th_id = ThreadPool::GetThreadNum(); assert(th_id=0); return pools[th_id]; } @@ -568,34 +567,35 @@ const float3& v2 = *(float3*)&vertices[(left.x + left.y * (PATCH_SIZE + 1))*3]; const float3& v3 = *(float3*)&vertices[(right.x + right.y * (PATCH_SIZE + 1))*3]; - const unsigned char white[] = {255,255,255,255}; - const unsigned char trans[] = {255,255,255,0}; + static const unsigned char white[] = {255,255,255,255}; + static const unsigned char trans[] = {255,255,255,0}; + va->EnlargeArrays(6, 0, VA_SIZE_C); if (i % 2 == 0) { - va->AddVertexC(float3(v2.x, v2.y, v2.z), white); - va->AddVertexC(float3(v2.x, -400.0f, v2.z), trans); - va->AddVertexC(float3(v3.x, v3.y, v3.z), white); - - va->AddVertexC(float3(v3.x, v3.y, v3.z), white); - va->AddVertexC(float3(v2.x, -400.0f, v2.z), trans); - va->AddVertexC(float3(v3.x, -400.0f, v3.z), trans); + va->AddVertexQC(v2, white); + va->AddVertexQC(float3(v2.x, -400.0f, v2.z), trans); + va->AddVertexQC(float3(v3.x, v3.y, v3.z), white); + + va->AddVertexQC(v3, white); + va->AddVertexQC(float3(v2.x, -400.0f, v2.z), trans); + va->AddVertexQC(float3(v3.x, -400.0f, v3.z), trans); } else { if (left_) { - va->AddVertexC(float3(v1.x, v1.y, v1.z), white); - va->AddVertexC(float3(v1.x, -400.0f, v1.z), trans); - va->AddVertexC(float3(v2.x, v2.y, v2.z), white); - - va->AddVertexC(float3(v2.x, v2.y, v2.z), white); - va->AddVertexC(float3(v1.x, -400.0f, v1.z), trans); - va->AddVertexC(float3(v2.x, -400.0f, v2.z), trans); + va->AddVertexQC(v1, white); + va->AddVertexQC(float3(v1.x, -400.0f, v1.z), trans); + va->AddVertexQC(float3(v2.x, v2.y, v2.z), white); + + va->AddVertexQC(v2, white); + va->AddVertexQC(float3(v1.x, -400.0f, v1.z), trans); + va->AddVertexQC(float3(v2.x, -400.0f, v2.z), trans); } else { - va->AddVertexC(float3(v3.x, v3.y, v3.z), white); - va->AddVertexC(float3(v3.x, -400.0f, v3.z), trans); - va->AddVertexC(float3(v1.x, v1.y, v1.z), white); - - va->AddVertexC(float3(v1.x, v1.y, v1.z), white); - va->AddVertexC(float3(v3.x, -400.0f, v3.z), trans); - va->AddVertexC(float3(v1.x, -400.0f, v1.z), trans); + va->AddVertexQC(v3, white); + va->AddVertexQC(float3(v3.x, -400.0f, v3.z), trans); + va->AddVertexQC(float3(v1.x, v1.y, v1.z), white); + + va->AddVertexQC(v1, white); + va->AddVertexQC(float3(v3.x, -400.0f, v3.z), trans); + va->AddVertexQC(float3(v1.x, -400.0f, v1.z), trans); } } @@ -607,12 +607,12 @@ if (i % 2 == 0) { RecursBorderRender(va, tri->LeftChild, apex, left, center, i + 1, !left_); - RecursBorderRender(va, tri->RightChild, right, apex, center, i + 1, left_); + return RecursBorderRender(va, tri->RightChild, right, apex, center, i + 1, left_); // return is needed for tail call optimization (it's still unlikely gcc does so...) } else { if (left_) { - RecursBorderRender(va, tri->LeftChild, apex, left, center, i + 1, left_); + return RecursBorderRender(va, tri->LeftChild, apex, left, center, i + 1, left_); } else { - RecursBorderRender(va, tri->RightChild, right, apex, center, i + 1, !left_); + return RecursBorderRender(va, tri->RightChild, right, apex, center, i + 1, !left_); } } } diff -Nru spring-96.0~14.04~ppa4/rts/Map/SMF/ROAM/RoamMeshDrawer.cpp spring-98.0~14.04~ppa6/rts/Map/SMF/ROAM/RoamMeshDrawer.cpp --- spring-96.0~14.04~ppa4/rts/Map/SMF/ROAM/RoamMeshDrawer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/SMF/ROAM/RoamMeshDrawer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -260,8 +260,7 @@ glPushMatrix(); glLoadIdentity(); glOrtho(0.0f, 1.0f, 0.0f, 1.0f, 0.0, -1.0); - glTranslatef((float)minimap->GetPosX() * globalRendering->pixelX, (float)minimap->GetPosY() * globalRendering->pixelY, 0.0f); - glScalef((float)minimap->GetSizeX() * globalRendering->pixelX, (float)minimap->GetSizeY() * globalRendering->pixelY, 1.0f); + minimap->ApplyConstraintsMatrix(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); diff -Nru spring-96.0~14.04~ppa4/rts/Map/SMF/SMFGroundTextures.cpp spring-98.0~14.04~ppa6/rts/Map/SMF/SMFGroundTextures.cpp --- spring-96.0~14.04~ppa4/rts/Map/SMF/SMFGroundTextures.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/SMF/SMFGroundTextures.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -62,14 +62,18 @@ CFileHandler* ifs = file.GetFileHandler(); const SMFHeader& header = file.GetHeader(); - assert(gs->mapx == header.mapx); - assert(gs->mapy == header.mapy); + if ((gs->mapx != header.mapx) || (gs->mapy != header.mapy)) { + throw content_error("Error loading map: size from header doesn't match map size."); + } ifs->Seek(header.tilesPtr); MapTileHeader tileHeader; READPTR_MAPTILEHEADER(tileHeader, ifs); + if (smfMap->tileCount <= 0) { + throw content_error("Error loading map: count of tiles is 0."); + } tileMap.resize(smfMap->tileCount); tiles.resize(tileHeader.numTiles * SMALL_TILE_SIZE); squares.resize(smfMap->numBigTexX * smfMap->numBigTexY); @@ -97,17 +101,9 @@ char fileNameBuffer[256] = {0}; ifs->Read(&numSmallTiles, sizeof(int)); - // works but would need to seek back - // ifs->Read(&fileNameBuffer[0], sizeof(char) * sizeof(fileNameBuffer)); - + ifs->ReadString(&fileNameBuffer[0], sizeof(char) * (sizeof(fileNameBuffer) - 1)); swabDWordInPlace(numSmallTiles); - for (unsigned int n = 0; n < sizeof(fileNameBuffer); n++) { - if (ifs->Read(&fileNameBuffer[n], sizeof(char)) != 1 || fileNameBuffer[n] == 0) { - break; - } - } - std::string smtFileName = fileNameBuffer; std::string smtFilePath = (!smtHeaderOverride)? (smfDir + smtFileName): @@ -117,11 +113,7 @@ if (!tileFile.FileExists()) { // try absolute path - if (!smtHeaderOverride) { - smtFilePath = smtFileName; - } else { - smtFilePath = smf.smtFileNames[a]; - } + smtFilePath = (!smtHeaderOverride) ? smtFileName : smf.smtFileNames[a]; tileFile.Open(smtFilePath); } @@ -426,7 +418,7 @@ const int numSqBytes = (mipSqSize * mipSqSize) / 2; pbo.Bind(); - pbo.Resize(numSqBytes); + pbo.New(numSqBytes); ExtractSquareTiles(texSquareX, texSquareY, texMipLevel, (GLint*) pbo.MapBuffer()); pbo.UnmapBuffer(); @@ -434,6 +426,7 @@ glCompressedTexImage2D(ttarget, 0, tileTexFormat, texSizeX, texSizeY, 0, numSqBytes, pbo.GetPtr()); glBindTexture(ttarget, 0); + pbo.Invalidate(); pbo.Unbind(); return true; } @@ -446,7 +439,7 @@ const int mipLevel, GLint* tileBuf ) const { - static const int TILE_MIP_OFFSET[] = {0, 512, 640, 672}; + static const int TILE_MIP_OFFSET[] = {0, 512, 512+128, 512+128+32}; static const int BLOCK_SIZE = 32; const int mipOffset = TILE_MIP_OFFSET[mipLevel]; @@ -488,7 +481,7 @@ square->texLevel = level; pbo.Bind(); - pbo.Resize(numSqBytes); + pbo.New(numSqBytes); ExtractSquareTiles(x, y, level, (GLint*) pbo.MapBuffer()); pbo.UnmapBuffer(); @@ -512,6 +505,8 @@ } glCompressedTexImage2D(ttarget, 0, tileTexFormat, mipSqSize, mipSqSize, 0, numSqBytes, pbo.GetPtr()); + + pbo.Invalidate(); pbo.Unbind(); } diff -Nru spring-96.0~14.04~ppa4/rts/Map/SMF/SMFReadMap.cpp spring-98.0~14.04~ppa6/rts/Map/SMF/SMFReadMap.cpp --- spring-96.0~14.04~ppa4/rts/Map/SMF/SMFReadMap.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/SMF/SMFReadMap.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -187,11 +187,7 @@ if (!specularTexBM.Load(mapInfo->smf.specularTexName)) { // maps wants specular lighting, but no moderation specularTexBM.channels = 4; - specularTexBM.Alloc(1, 1); - specularTexBM.mem[0] = 255; - specularTexBM.mem[1] = 255; - specularTexBM.mem[2] = 255; - specularTexBM.mem[3] = 255; + specularTexBM.AllocDummy(SColor(255,255,255,255)); } specularTex = specularTexBM.CreateTexture(false); @@ -228,20 +224,12 @@ if (!splatDetailTexBM.Load(mapInfo->smf.splatDetailTexName)) { // default detail-texture should be all-grey splatDetailTexBM.channels = 4; - splatDetailTexBM.Alloc(1, 1); - splatDetailTexBM.mem[0] = 127; - splatDetailTexBM.mem[1] = 127; - splatDetailTexBM.mem[2] = 127; - splatDetailTexBM.mem[3] = 127; + splatDetailTexBM.AllocDummy(SColor(127,127,127,127)); } if (!splatDistrTexBM.Load(mapInfo->smf.splatDistrTexName)) { splatDistrTexBM.channels = 4; - splatDistrTexBM.Alloc(1, 1); - splatDistrTexBM.mem[0] = 255; - splatDistrTexBM.mem[1] = 0; - splatDistrTexBM.mem[2] = 0; - splatDistrTexBM.mem[3] = 0; + splatDistrTexBM.AllocDummy(SColor(255,0,0,0)); } splatDetailTex = splatDetailTexBM.CreateTexture(true); @@ -752,20 +740,10 @@ const int drawQuadsX = gs->mapx / quadSize; const int drawQuadsY = gs->mapy / quadSize; - int sy = cy - drawSquare; - int ey = cy + drawSquare; - int sxi = cx - drawSquare; - int exi = cx + drawSquare; - - if (sy < 0) - sy = 0; - if (ey > drawQuadsY - 1) - ey = drawQuadsY - 1; - - if (sxi < 0) - sxi = 0; - if (exi > drawQuadsX - 1) - exi = drawQuadsX - 1; + int sy = Clamp(cy - drawSquare, 0, drawQuadsY - 1); + int ey = Clamp(cy + drawSquare, 0, drawQuadsY - 1); + int sxi = Clamp(cx - drawSquare, 0, drawQuadsX - 1); + int exi = Clamp(cx + drawSquare, 0, drawQuadsX - 1); // NOTE: // GridVisibility is only ever passed , not @@ -796,7 +774,7 @@ xtest = ((fli->base + fli->dir * ( y * quadSize) )); xtest2 = ((fli->base + fli->dir * ((y * quadSize) + quadSize))); - if (xtest > xtest2) + if (xtest2 < xtest) //use std::min? xtest = xtest2; xtest /= quadSize; @@ -808,7 +786,7 @@ xtest = ((fli->base + fli->dir * (y * quadSize) )); xtest2 = ((fli->base + fli->dir * ((y * quadSize) + quadSize))); - if (xtest < xtest2) + if (xtest2 > xtest) xtest = xtest2; xtest /= quadSize; diff -Nru spring-96.0~14.04~ppa4/rts/Map/SMF/SMFRenderState.cpp spring-98.0~14.04~ppa6/rts/Map/SMF/SMFRenderState.cpp --- spring-96.0~14.04~ppa4/rts/Map/SMF/SMFRenderState.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/SMF/SMFRenderState.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -108,25 +108,25 @@ glslShaders[n]->AttachShaderObject(sh->CreateShaderObject("GLSL/SMFVertProg.glsl", "#version 120\n" + defs, GL_VERTEX_SHADER)); glslShaders[n]->AttachShaderObject(sh->CreateShaderObject("GLSL/SMFFragProg.glsl", "#version 120\n" + defs, GL_FRAGMENT_SHADER)); - glslShaders[n]->SetFlag("SMF_VOID_WATER", int(mapInfo->map.voidWater)); - glslShaders[n]->SetFlag("SMF_VOID_GROUND", int(mapInfo->map.voidGround)); - glslShaders[n]->SetFlag("SMF_ARB_LIGHTING", int(!smfMap->HaveSpecularTexture())); - glslShaders[n]->SetFlag("SMF_DETAIL_TEXTURE_SPLATTING", int(smfMap->HaveSplatTexture())); - glslShaders[n]->SetFlag("SMF_WATER_ABSORPTION", int(smfMap->HasVisibleWater())); - glslShaders[n]->SetFlag("SMF_SKY_REFLECTIONS", int(smfMap->GetSkyReflectModTexture() != 0)); - glslShaders[n]->SetFlag("SMF_DETAIL_NORMALS", int(smfMap->GetDetailNormalTexture() != 0)); - glslShaders[n]->SetFlag("SMF_LIGHT_EMISSION", int(smfMap->GetLightEmissionTexture() != 0)); - glslShaders[n]->SetFlag("SMF_PARALLAX_MAPPING", int(smfMap->GetParallaxHeightTexture() != 0)); + glslShaders[n]->SetFlag("SMF_VOID_WATER", mapInfo->map.voidWater); + glslShaders[n]->SetFlag("SMF_VOID_GROUND", mapInfo->map.voidGround); + glslShaders[n]->SetFlag("SMF_ARB_LIGHTING", !smfMap->HaveSpecularTexture()); + glslShaders[n]->SetFlag("SMF_DETAIL_TEXTURE_SPLATTING", smfMap->HaveSplatTexture()); + glslShaders[n]->SetFlag("SMF_WATER_ABSORPTION", smfMap->HasVisibleWater()); + glslShaders[n]->SetFlag("SMF_SKY_REFLECTIONS", (smfMap->GetSkyReflectModTexture() != 0)); + glslShaders[n]->SetFlag("SMF_DETAIL_NORMALS", (smfMap->GetDetailNormalTexture() != 0)); + glslShaders[n]->SetFlag("SMF_LIGHT_EMISSION", (smfMap->GetLightEmissionTexture() != 0)); + glslShaders[n]->SetFlag("SMF_PARALLAX_MAPPING", (smfMap->GetParallaxHeightTexture() != 0)); glslShaders[n]->SetFlag("BASE_DYNAMIC_MAP_LIGHT", lightHandler->GetBaseLight()); glslShaders[n]->SetFlag("MAX_DYNAMIC_MAP_LIGHTS", lightHandler->GetMaxLights()); // both are runtime set, but ATI drivers need them set from the beginning - glslShaders[n]->SetFlag("HAVE_SHADOWS", 0); - glslShaders[n]->SetFlag("HAVE_INFOTEX", 0); + glslShaders[n]->SetFlag("HAVE_SHADOWS", false); + glslShaders[n]->SetFlag("HAVE_INFOTEX", false); // used to strip down the shader for the deferred pass - glslShaders[n]->SetFlag("DEFERRED_MODE", int(n != GLSL_SHADER_STANDARD)); + glslShaders[n]->SetFlag("DEFERRED_MODE", (n != GLSL_SHADER_STANDARD)); glslShaders[n]->SetFlag("GBUFFER_NORMTEX_IDX", GL::GeometryBuffer::ATTACHMENT_NORMTEX); glslShaders[n]->SetFlag("GBUFFER_DIFFTEX_IDX", GL::GeometryBuffer::ATTACHMENT_DIFFTEX); glslShaders[n]->SetFlag("GBUFFER_SPECTEX_IDX", GL::GeometryBuffer::ATTACHMENT_SPECTEX); @@ -135,72 +135,40 @@ glslShaders[n]->SetFlag("GBUFFER_ZVALTEX_IDX", GL::GeometryBuffer::ATTACHMENT_ZVALTEX); glslShaders[n]->Link(); - glslShaders[n]->SetUniformLocation("diffuseTex"); // idx 0 - glslShaders[n]->SetUniformLocation("normalsTex"); // idx 1 - glslShaders[n]->SetUniformLocation("shadowTex"); // idx 2 - glslShaders[n]->SetUniformLocation("detailTex"); // idx 3 - glslShaders[n]->SetUniformLocation("specularTex"); // idx 4 - glslShaders[n]->SetUniformLocation("infoTex"); // idx 5 - glslShaders[n]->SetUniformLocation("mapSizePO2"); // idx 6 - glslShaders[n]->SetUniformLocation("mapSize"); // idx 7 - glslShaders[n]->SetUniformLocation("texSquare"); // idx 8 - glslShaders[n]->SetUniformLocation("mapHeights"); // idx 9 - glslShaders[n]->SetUniformLocation("lightDir"); // idx 10 - glslShaders[n]->SetUniformLocation("cameraPos"); // idx 11 - glslShaders[n]->SetUniformLocation("$UNUSED$"); // idx 12 - glslShaders[n]->SetUniformLocation("shadowMat"); // idx 13 - glslShaders[n]->SetUniformLocation("shadowParams"); // idx 14 - glslShaders[n]->SetUniformLocation("groundAmbientColor"); // idx 15 - glslShaders[n]->SetUniformLocation("groundDiffuseColor"); // idx 16 - glslShaders[n]->SetUniformLocation("groundSpecularColor"); // idx 17 - glslShaders[n]->SetUniformLocation("groundShadowDensity"); // idx 18 - glslShaders[n]->SetUniformLocation("waterMinColor"); // idx 19 - glslShaders[n]->SetUniformLocation("waterBaseColor"); // idx 20 - glslShaders[n]->SetUniformLocation("waterAbsorbColor"); // idx 21 - glslShaders[n]->SetUniformLocation("splatDetailTex"); // idx 22 - glslShaders[n]->SetUniformLocation("splatDistrTex"); // idx 23 - glslShaders[n]->SetUniformLocation("splatTexScales"); // idx 24 - glslShaders[n]->SetUniformLocation("splatTexMults"); // idx 25 - glslShaders[n]->SetUniformLocation("skyReflectTex"); // idx 26 - glslShaders[n]->SetUniformLocation("skyReflectModTex"); // idx 27 - glslShaders[n]->SetUniformLocation("detailNormalTex"); // idx 28 - glslShaders[n]->SetUniformLocation("lightEmissionTex"); // idx 29 - glslShaders[n]->SetUniformLocation("parallaxHeightTex"); // idx 30 - glslShaders[n]->SetUniformLocation("infoTexIntensityMul"); // idx 31 - glslShaders[n]->SetUniformLocation("normalTexGen"); // idx 32 - glslShaders[n]->SetUniformLocation("specularTexGen"); // idx 33 - glslShaders[n]->SetUniformLocation("infoTexGen"); // idx 34 - glslShaders[n]->Enable(); - glslShaders[n]->SetUniform1i(0, 0); // diffuseTex (idx 0, texunit 0) - glslShaders[n]->SetUniform1i(1, 5); // normalsTex (idx 1, texunit 5) - glslShaders[n]->SetUniform1i(2, 4); // shadowTex (idx 2, texunit 4) - glslShaders[n]->SetUniform1i(3, 2); // detailTex (idx 3, texunit 2) - glslShaders[n]->SetUniform1i(4, 6); // specularTex (idx 4, texunit 6) - glslShaders[n]->SetUniform1i(5, 14); // infoTex (idx 5, texunit 14) - glslShaders[n]->SetUniform2f(6, (gs->pwr2mapx * SQUARE_SIZE), (gs->pwr2mapy * SQUARE_SIZE)); - glslShaders[n]->SetUniform2f(7, (gs->mapx * SQUARE_SIZE), (gs->mapy * SQUARE_SIZE)); - glslShaders[n]->SetUniform4fv(10, &((sky->GetLight())->GetLightDir()).x); - glslShaders[n]->SetUniform3fv(15, &mapInfo->light.groundAmbientColor[0]); - glslShaders[n]->SetUniform3fv(16, &mapInfo->light.groundSunColor[0]); - glslShaders[n]->SetUniform3fv(17, &mapInfo->light.groundSpecularColor[0]); - glslShaders[n]->SetUniform1f(18, sky->GetLight()->GetGroundShadowDensity()); - glslShaders[n]->SetUniform3fv(19, &mapInfo->water.minColor[0]); - glslShaders[n]->SetUniform3fv(20, &mapInfo->water.baseColor[0]); - glslShaders[n]->SetUniform3fv(21, &mapInfo->water.absorb[0]); - glslShaders[n]->SetUniform1i(22, 7); // splatDetailTex (idx 22, texunit 7) - glslShaders[n]->SetUniform1i(23, 8); // splatDistrTex (idx 23, texunit 8) - glslShaders[n]->SetUniform4fv(24, &mapInfo->splats.texScales[0]); - glslShaders[n]->SetUniform4fv(25, &mapInfo->splats.texMults[0]); - glslShaders[n]->SetUniform1i(26, 9); // skyReflectTex (idx 26, texunit 9) - glslShaders[n]->SetUniform1i(27, 10); // skyReflectModTex (idx 27, texunit 10) - glslShaders[n]->SetUniform1i(28, 11); // detailNormalTex (idx 28, texunit 11) - glslShaders[n]->SetUniform1i(29, 12); // lightEmisionTex (idx 29, texunit 12) - glslShaders[n]->SetUniform1i(30, 13); // parallaxHeightTex (idx 30, texunit 13) - glslShaders[n]->SetUniform1f(31, 1.0f); // infoTexIntensityMul - glslShaders[n]->SetUniform2f(32, 1.0f / ((smfMap->normalTexSize.x - 1) * SQUARE_SIZE), 1.0f / ((smfMap->normalTexSize.y - 1) * SQUARE_SIZE)); - glslShaders[n]->SetUniform2f(33, 1.0f / (gs->mapx * SQUARE_SIZE), 1.0f / (gs->mapy * SQUARE_SIZE)); - glslShaders[n]->SetUniform2f(34, 1.0f / (gs->pwr2mapx * SQUARE_SIZE), 1.0f / (gs->pwr2mapy * SQUARE_SIZE)); + glslShaders[n]->SetUniform("diffuseTex", 0); + glslShaders[n]->SetUniform("detailTex", 2); + glslShaders[n]->SetUniform("shadowTex", 4); + glslShaders[n]->SetUniform("normalsTex", 5); + glslShaders[n]->SetUniform("specularTex", 6); + glslShaders[n]->SetUniform("splatDetailTex", 7); + glslShaders[n]->SetUniform("splatDistrTex", 8); + glslShaders[n]->SetUniform("skyReflectTex", 9); + glslShaders[n]->SetUniform("skyReflectModTex", 10); + glslShaders[n]->SetUniform("detailNormalTex", 11); + glslShaders[n]->SetUniform("lightEmissionTex", 12); + glslShaders[n]->SetUniform("parallaxHeightTex", 13); + glslShaders[n]->SetUniform("infoTex", 14); + + glslShaders[n]->SetUniform("mapSizePO2", float(gs->pwr2mapx * SQUARE_SIZE), float(gs->pwr2mapy * SQUARE_SIZE)); + glslShaders[n]->SetUniform("mapSize", float(gs->mapx * SQUARE_SIZE), float(gs->mapy * SQUARE_SIZE)); + glslShaders[n]->SetUniform4v("lightDir", &sky->GetLight()->GetLightDir()[0]); + glslShaders[n]->SetUniform3v("cameraPos", &FwdVector[0]); + glslShaders[n]->SetUniform3v("groundAmbientColor", &mapInfo->light.groundAmbientColor[0]); + glslShaders[n]->SetUniform3v("groundDiffuseColor", &mapInfo->light.groundSunColor[0]); + glslShaders[n]->SetUniform3v("groundSpecularColor", &mapInfo->light.groundSpecularColor[0]); + glslShaders[n]->SetUniform("groundShadowDensity", sky->GetLight()->GetGroundShadowDensity()); + glslShaders[n]->SetUniform3v("waterMinColor", &mapInfo->water.minColor[0]); + glslShaders[n]->SetUniform3v("waterBaseColor", &mapInfo->water.baseColor[0]); + glslShaders[n]->SetUniform3v("waterAbsorbColor", &mapInfo->water.absorb[0]); + + glslShaders[n]->SetUniform4v("splatTexScales", &mapInfo->splats.texScales[0]); + glslShaders[n]->SetUniform4v("splatTexMults", &mapInfo->splats.texMults[0]); + + glslShaders[n]->SetUniform("infoTexIntensityMul", 1.0f); + glslShaders[n]->SetUniform("normalTexGen", 1.0f / ((smfMap->normalTexSize.x - 1) * SQUARE_SIZE), 1.0f / ((smfMap->normalTexSize.y - 1) * SQUARE_SIZE)); + glslShaders[n]->SetUniform("specularTexGen", 1.0f / (gs->mapx * SQUARE_SIZE), 1.0f / (gs->mapy * SQUARE_SIZE)); + glslShaders[n]->SetUniform("infoTexGen", 1.0f / (gs->pwr2mapx * SQUARE_SIZE), 1.0f / (gs->pwr2mapy * SQUARE_SIZE)); glslShaders[n]->Disable(); glslShaders[n]->Validate(); } @@ -442,33 +410,31 @@ glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glslShaders[GLSL_SHADER_CURRENT]->SetFlag("HAVE_SHADOWS", int(shadowHandler->shadowsLoaded)); - glslShaders[GLSL_SHADER_CURRENT]->SetFlag("HAVE_INFOTEX", int(smfGroundDrawer->DrawExtraTex())); + glslShaders[GLSL_SHADER_CURRENT]->SetFlag("HAVE_SHADOWS", shadowHandler->shadowsLoaded); + glslShaders[GLSL_SHADER_CURRENT]->SetFlag("HAVE_INFOTEX", smfGroundDrawer->DrawExtraTex()); glslShaders[GLSL_SHADER_CURRENT]->Enable(); - glslShaders[GLSL_SHADER_CURRENT]->SetUniform2f(9, readMap->GetCurrMinHeight(), readMap->GetCurrMaxHeight()); - glslShaders[GLSL_SHADER_CURRENT]->SetUniform3fv(11, &camera->GetPos()[0]); - glslShaders[GLSL_SHADER_CURRENT]->SetUniformMatrix4fv(13, false, shadowHandler->shadowMatrix); - glslShaders[GLSL_SHADER_CURRENT]->SetUniform4fv(14, &(shadowHandler->GetShadowParams().x)); - glslShaders[GLSL_SHADER_CURRENT]->SetUniform1f(31, float(smfGroundDrawer->GetDrawMode() == CBaseGroundDrawer::drawMetal) + 1.0f); + glslShaders[GLSL_SHADER_CURRENT]->SetUniform("mapHeights", readMap->GetCurrMinHeight(), readMap->GetCurrMaxHeight()); + glslShaders[GLSL_SHADER_CURRENT]->SetUniform3v("cameraPos", &camera->GetPos()[0]); + glslShaders[GLSL_SHADER_CURRENT]->SetUniformMatrix4x4("shadowMat", false, shadowHandler->shadowMatrix.m); + glslShaders[GLSL_SHADER_CURRENT]->SetUniform4v("shadowParams", &(shadowHandler->GetShadowParams().x)); + glslShaders[GLSL_SHADER_CURRENT]->SetUniform("infoTexIntensityMul", float(smfGroundDrawer->GetDrawMode() == CBaseGroundDrawer::drawMetal) + 1.0f); // already on the MV stack at this point glLoadIdentity(); const_cast(lightHandler)->Update(glslShaders[GLSL_SHADER_CURRENT]); glMultMatrixf(camera->GetViewMatrix()); - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, smfMap->GetShadingTexture()); - glActiveTexture(GL_TEXTURE2); - glBindTexture(GL_TEXTURE_2D, smfMap->GetDetailTexture()); - // setup for shadow2DProj - glActiveTexture(GL_TEXTURE4); - glBindTexture(GL_TEXTURE_2D, shadowHandler->shadowTexture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); - glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY); + if (shadowHandler->shadowsLoaded) { + glActiveTexture(GL_TEXTURE4); + glBindTexture(GL_TEXTURE_2D, shadowHandler->shadowTexture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); + glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY); + } + glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, smfMap->GetDetailTexture()); glActiveTexture(GL_TEXTURE5); glBindTexture(GL_TEXTURE_2D, smfMap->GetNormalsTexture()); glActiveTexture(GL_TEXTURE6); glBindTexture(GL_TEXTURE_2D, smfMap->GetSpecularTexture()); glActiveTexture(GL_TEXTURE7); glBindTexture(GL_TEXTURE_2D, smfMap->GetSplatDetailTexture()); @@ -486,25 +452,11 @@ void SMFRenderStateGLSL::Disable(const CSMFGroundDrawer*, const DrawPass::e&) { glslShaders[GLSL_SHADER_CURRENT]->Disable(); - glActiveTexture(GL_TEXTURE14); glBindTexture(GL_TEXTURE_2D, 0); - glActiveTexture(GL_TEXTURE13); glBindTexture(GL_TEXTURE_2D, 0); - glActiveTexture(GL_TEXTURE12); glBindTexture(GL_TEXTURE_2D, 0); - glActiveTexture(GL_TEXTURE11); glBindTexture(GL_TEXTURE_2D, 0); - glActiveTexture(GL_TEXTURE10); glBindTexture(GL_TEXTURE_2D, 0); - glActiveTexture(GL_TEXTURE9); glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, 0); - glActiveTexture(GL_TEXTURE8); glBindTexture(GL_TEXTURE_2D, 0); - glActiveTexture(GL_TEXTURE7); glBindTexture(GL_TEXTURE_2D, 0); - glActiveTexture(GL_TEXTURE6); glBindTexture(GL_TEXTURE_2D, 0); - glActiveTexture(GL_TEXTURE5); glBindTexture(GL_TEXTURE_2D, 0); - - glActiveTexture(GL_TEXTURE4); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE); - glBindTexture(GL_TEXTURE_2D, 0); - - glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, 0); - glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, 0); - - glActiveTexture(GL_TEXTURE0); + if (shadowHandler->shadowsLoaded) { + glActiveTexture(GL_TEXTURE4); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE); + glActiveTexture(GL_TEXTURE0); + } } @@ -525,7 +477,7 @@ } void SMFRenderStateGLSL::SetSquareTexGen(const int sqx, const int sqy) const { - glslShaders[GLSL_SHADER_CURRENT]->SetUniform2i(8, sqx, sqy); + glslShaders[GLSL_SHADER_CURRENT]->SetUniform("texSquare", sqx, sqy); } @@ -556,8 +508,8 @@ void SMFRenderStateGLSL::UpdateCurrentShader(const ISkyLight* skyLight) const { glslShaders[GLSL_SHADER_CURRENT]->Enable(); - glslShaders[GLSL_SHADER_CURRENT]->SetUniform4fv(10, &skyLight->GetLightDir().x); - glslShaders[GLSL_SHADER_CURRENT]->SetUniform1f(18, skyLight->GetGroundShadowDensity()); + glslShaders[GLSL_SHADER_CURRENT]->SetUniform4v("lightDir", &skyLight->GetLightDir().x); + glslShaders[GLSL_SHADER_CURRENT]->SetUniform("groundShadowDensity", skyLight->GetGroundShadowDensity()); glslShaders[GLSL_SHADER_CURRENT]->Disable(); } diff -Nru spring-96.0~14.04~ppa4/rts/Map/SMF/SMFRenderState.h spring-98.0~14.04~ppa6/rts/Map/SMF/SMFRenderState.h --- spring-96.0~14.04~ppa4/rts/Map/SMF/SMFRenderState.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Map/SMF/SMFRenderState.h 2014-10-07 20:09:51.000000000 +0000 @@ -11,7 +11,7 @@ namespace Shader { struct IProgramObject; -}; +} struct ISMFRenderState { diff -Nru spring-96.0~14.04~ppa4/rts/Menu/alphanum.hpp spring-98.0~14.04~ppa6/rts/Menu/alphanum.hpp --- spring-96.0~14.04~ppa4/rts/Menu/alphanum.hpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Menu/alphanum.hpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,274 @@ +#ifndef ALPHANUM__HPP +#define ALPHANUM__HPP + +/* +The Alphanum Algorithm is an improved sorting algorithm for strings +containing numbers. Instead of sorting numbers in ASCII order like a +standard sort, this algorithm sorts numbers in numeric order. + +The Alphanum Algorithm is discussed at http://www.DaveKoelle.com + +This implementation is Copyright (c) 2008 Dirk Jagdmann . +It is a cleanroom implementation of the algorithm and not derived by +other's works. In contrast to the versions written by Dave Koelle this +source code is distributed with the libpng/zlib license. + +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. */ + +/* $Header: /code/doj/alphanum.hpp,v 1.3 2008/01/28 23:06:47 doj Exp $ */ + +/* +Modifications for spring: +- modified to be case-insensitive +- removed DOJDEBUG code and unit test code +- conform to spring coding guidelines +*/ + +#include +#include +#include +#include + +#ifdef ALPHANUM_LOCALE +#include +#endif + +// TODO: make comparison with hexadecimal numbers. Extend the alphanum_comp() function by traits to choose between decimal and hexadecimal. + +namespace doj { + + // anonymous namespace for functions we use internally. But if you + // are coding in C, you can use alphanum_impl() directly, since it + // uses not C++ features. + namespace { + + // if you want to honour the locale settings for detecting digit + // characters, you should define ALPHANUM_LOCALE +#ifdef ALPHANUM_LOCALE + /** wrapper function for ::isdigit() */ + bool alphanum_isdigit(int c) { + return isdigit(c); + } +#else + /** this function does not consider the current locale and only + works with ASCII digits. + @return true if c is a digit character + */ + bool alphanum_isdigit(const char c) { + return c>='0' && c<='9'; + } +#endif + + /** + compare l and r with strcmp() semantics, but using + the "Alphanum Algorithm". This function is designed to read + through the l and r strings only one time, for + maximum performance. It does not allocate memory for + substrings. It can either use the C-library functions isdigit() + and atoi() to honour your locale settings, when recognizing + digit characters when you "#define ALPHANUM_LOCALE=1" or use + it's own digit character handling which only works with ASCII + digit characters, but provides better performance. + + @param l NULL-terminated C-style string + @param r NULL-terminated C-style string + @return negative if lr + */ + int alphanum_impl(const char *l, const char *r) { + enum mode_t { + STRING, NUMBER + } mode = STRING; + + while (*l && *r) { + if (mode == STRING) { + char l_char, r_char; + while ((l_char = *l) && (r_char = *r)) { + l_char = tolower(l_char); + r_char = tolower(r_char); + + // check if this are digit characters + const bool l_digit = alphanum_isdigit(l_char), r_digit = + alphanum_isdigit(r_char); + // if both characters are digits, we continue in NUMBER mode + if (l_digit && r_digit) { + mode = NUMBER; + break; + } + // if only the left character is a digit, we have a result + if (l_digit) + return -1; + // if only the right character is a digit, we have a result + if (r_digit) + return +1; + // compute the difference of both characters + const int diff = l_char - r_char; + // if they differ we have a result + if (diff != 0) + return diff; + // otherwise process the next characters + ++l; + ++r; + } + } + else { // mode==NUMBER +#ifdef ALPHANUM_LOCALE + // get the left number + char *end; + unsigned long l_int=strtoul(l, &end, 0); + l=end; + + // get the right number + unsigned long r_int=strtoul(r, &end, 0); + r=end; +#else + // get the left number + unsigned long l_int=0; + while(*l && alphanum_isdigit(*l)) { + // TODO: this can overflow + l_int=l_int*10 + *l-'0'; + ++l; + } + + // get the right number + unsigned long r_int=0; + while(*r && alphanum_isdigit(*r)) { + // TODO: this can overflow + r_int=r_int*10 + *r-'0'; + ++r; + } +#endif + + // if the difference is not equal to zero, we have a comparison result + const long diff=l_int-r_int; + if(diff != 0) + return diff; + + // otherwise we process the next substring in STRING mode + mode=STRING; + } + } + + if(*r) return -1; + if(*l) return +1; + return 0; + } + } + + /** + Compare left and right with the same semantics as strcmp(), but with the + "Alphanum Algorithm" which produces more human-friendly + results. The classes lT and rT must implement "std::ostream + operator<< (std::ostream&, const Ty&)". + + @return negative if leftright. + */ + template + int alphanum_comp(const lT& left, const rT& right) { + std::ostringstream l; l << left; + std::ostringstream r; r << right; + return alphanum_impl(l.str().c_str(), r.str().c_str()); + } + + /** + Compare l and r with the same semantics as strcmp(), but with + the "Alphanum Algorithm" which produces more human-friendly + results. + + @return negative if lr. + */ + template <> + inline int alphanum_comp(const std::string& l, const std::string& r) { + return alphanum_impl(l.c_str(), r.c_str()); + } + + //////////////////////////////////////////////////////////////////////////// + + // now follow a lot of overloaded alphanum_comp() functions to get a + // direct call to alphanum_impl() upon the various combinations of c + // and c++ strings. + + /** + Compare l and r with the same semantics as strcmp(), but with + the "Alphanum Algorithm" which produces more human-friendly + results. + + @return negative if lr. + */ + inline int alphanum_comp(char* l, char* r) { + assert(l); + assert(r); + return alphanum_impl(l, r); + } + + inline int alphanum_comp(const char* l, const char* r) { + assert(l); + assert(r); + return alphanum_impl(l, r); + } + + inline int alphanum_comp(char* l, const char* r) { + assert(l); + assert(r); + return alphanum_impl(l, r); + } + + inline int alphanum_comp(const char* l, char* r) { + assert(l); + assert(r); + return alphanum_impl(l, r); + } + + inline int alphanum_comp(const std::string& l, char* r) { + assert(r); + return alphanum_impl(l.c_str(), r); + } + + inline int alphanum_comp(char* l, const std::string& r) { + assert(l); + return alphanum_impl(l, r.c_str()); + } + + inline int alphanum_comp(const std::string& l, const char* r) { + assert(r); + return alphanum_impl(l.c_str(), r); + } + + inline int alphanum_comp(const char* l, const std::string& r) { + assert(l); + return alphanum_impl(l, r.c_str()); + } + + //////////////////////////////////////////////////////////////////////////// + + /** + Functor class to compare two objects with the "Alphanum + Algorithm". If the objects are no std::string, they must + implement "std::ostream operator<< (std::ostream&, const Ty&)". + */ + template + struct alphanum_less : public std::binary_function { + bool operator()(const Ty& left, const Ty& right) const { + return alphanum_comp(left, right) < 0; + } + }; + +} + +#endif diff -Nru spring-96.0~14.04~ppa4/rts/Menu/CMakeLists.txt spring-98.0~14.04~ppa6/rts/Menu/CMakeLists.txt --- spring-96.0~14.04~ppa4/rts/Menu/CMakeLists.txt 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Menu/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -4,6 +4,6 @@ SET(sources_engine_Menu "${CMAKE_CURRENT_SOURCE_DIR}/SelectMenu.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/SelectionWidget.cpp" + PARENT_SCOPE ) -MakeGlobal(sources_engine_Menu) diff -Nru spring-96.0~14.04~ppa4/rts/Menu/SelectionWidget.cpp spring-98.0~14.04~ppa6/rts/Menu/SelectionWidget.cpp --- spring-96.0~14.04~ppa4/rts/Menu/SelectionWidget.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Menu/SelectionWidget.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -12,6 +12,7 @@ #include "ExternalAI/LuaAIImplHandler.h" #include "ExternalAI/Interface/SSkirmishAILibrary.h" #include "System/Info.h" +#include "alphanum.hpp" const std::string SelectionWidget::NoModSelect = "No game selected"; const std::string SelectionWidget::NoMapSelect = "No map selected"; @@ -69,7 +70,7 @@ const std::vector &found = archiveScanner->GetPrimaryMods(); - std::map modMap; // name, desc (using a map to sort) + std::map > modMap; // name, desc (using a map to sort) for (std::vector::const_iterator it = found.begin(); it != found.end(); ++it) { modMap[it->GetNameVersioned()] = it->GetDescription(); } @@ -91,7 +92,7 @@ const std::vector &arFound = archiveScanner->GetMaps(); - std::set mapSet; // use a set to sort them + std::set > mapSet; // use a set to sort them for (std::vector::const_iterator it = arFound.begin(); it != arFound.end(); ++it) { mapSet.insert((*it).c_str()); } diff -Nru spring-96.0~14.04~ppa4/rts/Menu/SelectMenu.cpp spring-98.0~14.04~ppa6/rts/Menu/SelectMenu.cpp --- spring-96.0~14.04~ppa4/rts/Menu/SelectMenu.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Menu/SelectMenu.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,7 +2,7 @@ #include "SelectMenu.h" -#include +#include #include #include #include @@ -13,7 +13,7 @@ #include "Game/ClientSetup.h" #include "Game/GlobalUnsynced.h" #include "Game/PreGame.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Rendering/GL/myGL.h" #include "System/Config/ConfigHandler.h" #include "System/Exceptions.h" @@ -35,6 +35,7 @@ #include "aGui/Window.h" #include "aGui/Picture.h" #include "aGui/List.h" +#include "alphanum.hpp" using std::string; using agui::Button; @@ -119,20 +120,16 @@ }; }; -SelectMenu::SelectMenu(bool server) : GuiElement(NULL), conWindow(NULL), settingsWindow(NULL), curSelect(NULL) +SelectMenu::SelectMenu(boost::shared_ptr setup) +: GuiElement(NULL) +, clientSetup(setup) +, conWindow(NULL) +, settingsWindow(NULL) +, curSelect(NULL) { SetPos(0,0); SetSize(1,1); agui::gui->AddElement(this, true); - mySettings = new ClientSetup(); - - mySettings->isHost = server; - mySettings->myPlayerName = configHandler->GetString("name"); - if (mySettings->myPlayerName.empty()) { - mySettings->myPlayerName = UnnamedPlayerName; - } else { - mySettings->myPlayerName = StringReplaceInPlace(mySettings->myPlayerName, ' ', '_'); - } { // GUI stuff agui::Picture* background = new agui::Picture(this);; @@ -168,7 +165,7 @@ background->GeometryChange(); } - if (!mySettings->isHost) { + if (!clientSetup->isHost) { ShowConnectWindow(true); } } @@ -178,8 +175,6 @@ ShowConnectWindow(false); ShowSettingsWindow(false, ""); CleanWindow(); - - delete mySettings; } bool SelectMenu::Draw() @@ -208,15 +203,14 @@ } else if (!once) // in case of double-click { - if (selw->userScript == SelectionWidget::SandboxAI) { selw->userScript.clear(); } once = true; - mySettings->isHost = true; - pregame = new CPreGame(mySettings); - pregame->LoadSetupscript(StartScriptGen::CreateDefaultSetup(selw->userMap, selw->userMod, selw->userScript, mySettings->myPlayerName)); - agui::gui->RmElement(this); + + pregame = new CPreGame(clientSetup); + pregame->LoadSetupscript(StartScriptGen::CreateDefaultSetup(selw->userMap, selw->userMod, selw->userScript, clientSetup->myPlayerName)); + return agui::gui->RmElement(this); //delete this; } } @@ -224,6 +218,7 @@ void SelectMenu::Quit() { gu->globalQuit = true; + return agui::gui->RmElement(this); //delete this; } @@ -277,7 +272,9 @@ } curSelect->list->RemoveAllItems(); const std::map &data = configHandler->GetData(); - for(std::map::const_iterator iter = data.begin(); iter != data.end(); ++iter) + typedef std::map > DataSorted; + const DataSorted dataSorted(data.begin(), data.end()); + for(DataSorted::const_iterator iter = dataSorted.begin(); iter != dataSorted.end(); ++iter) curSelect->list->AddItem(iter->first + " = " + iter->second, ""); if(data.find(userSetting) != data.end()) curSelect->list->SetCurrentItem(userSetting + " = " + configHandler->GetString(userSetting)); @@ -304,10 +301,11 @@ void SelectMenu::DirectConnect(const std::string& addr) { configHandler->SetString("address", addr); - mySettings->hostIP = addr; - mySettings->isHost = false; - pregame = new CPreGame(mySettings); - agui::gui->RmElement(this); + clientSetup->hostIP = addr; + clientSetup->isHost = false; + pregame = new CPreGame(clientSetup); + return agui::gui->RmElement(this); + //delete this; } bool SelectMenu::HandleEventSelf(const SDL_Event& ev) diff -Nru spring-96.0~14.04~ppa4/rts/Menu/SelectMenu.h spring-98.0~14.04~ppa6/rts/Menu/SelectMenu.h --- spring-96.0~14.04~ppa4/rts/Menu/SelectMenu.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Menu/SelectMenu.h 2014-10-07 20:09:51.000000000 +0000 @@ -5,13 +5,14 @@ #include "aGui/GuiElement.h" #include "Game/GameController.h" +#include -class ClientSetup; -union SDL_Event; class SelectionWidget; class ConnectWindow; class SettingsWindow; class ListSelectWnd; +class ClientSetup; + /** @brief User prompt for options when no script is given @@ -23,7 +24,7 @@ class SelectMenu : public CGameController, public agui::GuiElement { public: - SelectMenu(bool server); + SelectMenu(boost::shared_ptr setup); ~SelectMenu(); bool Draw(); @@ -47,7 +48,8 @@ void SelectSetting(std::string); void CleanWindow(); - ClientSetup* mySettings; +private: + boost::shared_ptr clientSetup; ConnectWindow* conWindow; SelectionWidget* selw; diff -Nru spring-96.0~14.04~ppa4/rts/Net/CMakeLists.txt spring-98.0~14.04~ppa6/rts/Net/CMakeLists.txt --- spring-96.0~14.04~ppa4/rts/Net/CMakeLists.txt 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Net/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -1,16 +1,17 @@ -SET(sources_engine_NetServer +MakeGlobalVar(sources_engine_NetServer "${CMAKE_CURRENT_SOURCE_DIR}/AutohostInterface.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/GameServer.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/GameParticipant.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Protocol/BaseNetProtocol.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/Protocol/NetProtocol.cpp" ) -SET(sources_engine_NetClient +set(sources_engine_NetClient + "${CMAKE_CURRENT_SOURCE_DIR}/Protocol/NetProtocol.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/NetCommands.cpp" ) -Set(sources_engine_Net ${sources_engine_NetServer} ${sources_engine_NetClient}) +MakeGlobalVar(sources_engine_Net + ${sources_engine_NetServer} + ${sources_engine_NetClient} + ) -MakeGlobal(sources_engine_NetServer) -MakeGlobal(sources_engine_Net) diff -Nru spring-96.0~14.04~ppa4/rts/Net/GameServer.cpp spring-98.0~14.04~ppa6/rts/Net/GameServer.cpp --- spring-96.0~14.04~ppa4/rts/Net/GameServer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Net/GameServer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -67,13 +67,13 @@ #define PKTCACHE_VECSIZE 1000 using netcode::RawPacket; - +using boost::format; CONFIG(int, AutohostPort).defaultValue(0); CONFIG(int, SpeedControl).defaultValue(1).minimumValue(1).maximumValue(2) .description("Sets how server adjusts speed according to player's load (CPU), 1: use average, 2: use highest"); -CONFIG(bool, BypassScriptPasswordCheck).defaultValue(false); +CONFIG(bool, AllowSpectatorJoin).defaultValue(true); CONFIG(bool, WhiteListAdditionalPlayers).defaultValue(true); #ifdef DEDICATED CONFIG(bool, ServerRecordDemos).defaultValue(true); @@ -81,15 +81,11 @@ CONFIG(bool, ServerRecordDemos).defaultValue(false); #endif CONFIG(bool, ServerLogInfoMessages).defaultValue(false); -CONFIG(bool, ServerLogErrorMessages).defaultValue(false); CONFIG(bool, ServerLogDebugMessages).defaultValue(false); -CONFIG(bool, ServerLogWarnMessages).defaultValue(false); CONFIG(std::string, AutohostIP).defaultValue("127.0.0.1"); // use the specific section for all LOG*() calls in this source file -// TODO: enable when #4171 is fixed -#if 0 #define LOG_SECTION_GAMESERVER "GameServer" #ifdef LOG_SECTION_CURRENT #undef LOG_SECTION_CURRENT @@ -97,33 +93,33 @@ #define LOG_SECTION_CURRENT LOG_SECTION_GAMESERVER LOG_REGISTER_SECTION_GLOBAL(LOG_SECTION_GAMESERVER) -#endif /// frames until a synccheck will time out and a warning is given out -const unsigned SYNCCHECK_TIMEOUT = 300; +static const unsigned SYNCCHECK_TIMEOUT = 300; /// used to prevent msg spam -const unsigned SYNCCHECK_MSG_TIMEOUT = 400; +static const unsigned SYNCCHECK_MSG_TIMEOUT = 400; /// The time interval in msec for sending player statistics to each client -const spring_time playerInfoTime = spring_secs(2); +static const spring_time playerInfoTime = spring_secs(2); /// every n'th frame will be a keyframe (and contain the server's framenumber) -const unsigned serverKeyframeInterval = 16; +static const unsigned serverKeyframeInterval = 16; /// players incoming bandwidth new allowance every X milliseconds -const unsigned playerBandwidthInterval = 100; +static const unsigned playerBandwidthInterval = 100; /// every 10 sec we'll broadcast current frame in a message that skips queue & cache /// to let clients that are fast-forwarding to current point to know their loading % -const unsigned gameProgressFrameInterval = GAME_SPEED * 10; +static const unsigned gameProgressFrameInterval = GAME_SPEED * 10; -const unsigned syncResponseEchoInterval = GAME_SPEED * 2; +static const unsigned syncResponseEchoInterval = GAME_SPEED * 2; -const std::string SERVER_COMMANDS[] = { +//FIXME remodularize server commands, so they get registered in word completion etc. +static const std::string SERVER_COMMANDS[] = { "kick", "kickbynum", "mute", "mutebynum", "setminspeed", "setmaxspeed", @@ -135,72 +131,57 @@ -using boost::format; - -namespace { - void SetBoolArg(bool& value, const std::string& str) - { - if (str.empty()) { // toggle - value = !value; - } else { // set - value = (atoi(str.c_str()) != 0); - } - } -} - - +CGameServer* gameServer = NULL; std::set CGameServer::commandBlacklist; -CGameServer* gameServer = NULL; CGameServer::CGameServer(const std::string& hostIP, int hostPort, const GameData* const newGameData, const CGameSetup* const mysetup) : setup(mysetup) -{ - assert(setup); - serverStartTime = spring_gettime(); - lastUpdate = serverStartTime; - lastPlayerInfo = serverStartTime; - syncErrorFrame = 0; - syncWarningFrame = 0; - serverFrameNum = 0; - - modGameTime = 0.0f; - gameTime = 0.0f; - startTime = 0.0f; - frameTimeLeft = 0.0f; +, quitServer(false) +, serverFrameNum(0) - quitServer = false; - hasLocalClient = false; - localClientNumber = 0; - - isPaused = false; - gamePausable = true; - - userSpeedFactor = 1.0f; - internalSpeed = 1.0f; - - noHelperAIs = false; - canReconnect = false; - allowSpecDraw = true; - cheating = false; +, serverStartTime(spring_gettime()) +, readyTime(spring_notime) +, gameEndTime(spring_notime) +, lastPlayerInfo(serverStartTime) +, lastUpdate(serverStartTime) + +, modGameTime(0.0f) +, gameTime(0.0f) +, startTime(0.0f) +, frameTimeLeft(0.0f) + +, isPaused(false) +, gamePausable(true) + +, userSpeedFactor(1.0f) +, internalSpeed(1.0f) + +, medianCpu(0.0f) +, medianPing(0) + +, cheating(false) +, noHelperAIs(false) +, canReconnect(false) +, allowSpecDraw(true) - gameHasStarted = false; - generatedGameID = false; +, syncErrorFrame(0) +, syncWarningFrame(0) - gameEndTime = spring_notime; - readyTime = spring_notime; +, hasLocalClient(false) +, localClientNumber(0) - medianCpu = 0.0f; - medianPing = 0; +, gameHasStarted(false) +, generatedGameID(false) +{ + assert(setup); curSpeedCtrl = configHandler->GetInt("SpeedControl"); - bypassScriptPasswordCheck = configHandler->GetBool("BypassScriptPasswordCheck"); + allowSpecJoin = configHandler->GetBool("AllowSpectatorJoin"); whiteListAdditionalPlayers = configHandler->GetBool("WhiteListAdditionalPlayers"); logInfoMessages = configHandler->GetBool("ServerLogInfoMessages"); - logErrorMessages = configHandler->GetBool("ServerLogErrorMessages"); logDebugMessages = configHandler->GetBool("ServerLogDebugMessages"); - logWarnMessages = configHandler->GetBool("ServerLogWarnMessages"); if (!setup->onlyLocal) { UDPNet.reset(new netcode::UDPListener(hostPort, hostIP)); @@ -274,7 +255,6 @@ } } - canReconnect = false; linkMinPacketSize = globalConfig->linkIncomingMaxPacketRate > 0 ? (globalConfig->linkIncomingSustainedBandwidth / globalConfig->linkIncomingMaxPacketRate) : 1; lastBandwidthUpdate = spring_gettime(); @@ -286,6 +266,12 @@ // Set single precision floating point math. streflop::streflop_init(); #endif + + if (!demoReader) { + GenerateAndSendGameID(); + rng.Seed(gameID.intArray[0] ^ gameID.intArray[1] ^ gameID.intArray[2] ^ gameID.intArray[3]); + Broadcast(CBaseNetProtocol::Get().SendRandSeed(rng())); + } } CGameServer::~CGameServer() @@ -338,7 +324,7 @@ for (TdfParser::sectionsMap_t::iterator it = rootSec->sections.begin(); it != rootSec->sections.end(); ++it) { const std::string& sectionKey = StringToLower(it->first); - if (sectionKey.find("player") != 0) + if (!StringStartsWith(sectionKey, "player")) continue; TdfParser::TdfSection* playerSec = it->second; @@ -368,10 +354,7 @@ return; if (autohostIP == "localhost") { - if (logErrorMessages) { - LOG_L(L_ERROR, "[%s] auto-host IP address not in x.y.z.w format!", __FUNCTION__); - } - + LOG_L(L_ERROR, "Autohost IP address not in x.y.z.w format!"); return; } @@ -611,7 +594,7 @@ CommandMessage msg(rpkt); const Action& action = msg.GetAction(); if (msg.GetPlayerID() == SERVER_PLAYER && action.command == "cheat") - SetBoolArg(cheating, action.extra); + InverseOrSetBool(cheating, action.extra); } catch (const netcode::UnpackPacketException& ex) { Message(str(format("Warning: Discarding invalid command message packet in demo: %s") %ex.what())); continue; @@ -645,12 +628,12 @@ { for (size_t p = 0; p < players.size(); ++p) players[p].SendData(packet); - if (canReconnect || bypassScriptPasswordCheck || !gameHasStarted) + + if (canReconnect || allowSpecJoin || !gameHasStarted) AddToPacketCache(packet); - if (demoRecorder != NULL) { + if (demoRecorder != NULL) demoRecorder->SaveToDemo(packet->data, packet->length, GetDemoTime()); - } } void CGameServer::Message(const std::string& message, bool broadcast) @@ -664,8 +647,9 @@ } if (hostif) hostif->Message(message); -#if defined DEDICATED - std::cout << message << std::endl; + +#ifdef DEDICATED + LOG("%s", message.c_str()); #endif } @@ -769,7 +753,7 @@ // TODO enable this when we have resync //serverNet->SendPause(SERVER_PLAYER, true); -#ifdef SYNCDEBUG + #ifdef SYNCDEBUG CSyncDebugger::GetInstance()->ServerTriggerSyncErrorHandling(serverFrameNum); if (demoReader) // pause is a synced message, thus demo spectators may not pause for real Message(str(format("%s paused the demo") %players[gu->myPlayerNum].name)); @@ -777,7 +761,7 @@ Broadcast(CBaseNetProtocol::Get().SendPause(gu->myPlayerNum, true)); isPaused = true; Broadcast(CBaseNetProtocol::Get().SendSdCheckrequest(serverFrameNum)); -#endif + #endif // For each group, output a message with list of player names in it. // TODO this should be linked to the resync system so it can roundrobin // the resync checksum request packets to multiple clients in the same group. @@ -791,10 +775,8 @@ for (std::map::const_iterator s = desyncSpecs.begin(); s != desyncSpecs.end(); ++s) { int playerNum = s->first; - if (logErrorMessages) { - LOG_L(L_ERROR, "%s", str(format(SyncError) %players[playerNum].name %(*f) %s->second %correctChecksum).c_str()); - Message(str(format(SyncError) %players[playerNum].name %(*f) %s->second %correctChecksum)); - } + LOG_L(L_ERROR, "%s", str(format(SyncError) %players[playerNum].name %(*f) %s->second %correctChecksum).c_str()); + Message(str(format(SyncError) %players[playerNum].name %(*f) %s->second %correctChecksum)); PrivateMessage(playerNum, str(format(SyncError) %players[playerNum].name %(*f) %s->second %correctChecksum)); } @@ -822,11 +804,13 @@ #endif } + float CGameServer::GetDemoTime() const { if (!gameHasStarted) return gameTime; return (startTime + serverFrameNum / float(GAME_SPEED)); } + void CGameServer::Update() { const float tdif = spring_tomsecs(spring_gettime() - lastUpdate) * 0.001f; @@ -910,7 +894,7 @@ cpu.reserve(players.size()); ping.reserve(players.size()); - // detect reference cpu usage + // detect reference cpu usage ( highest ) float refCpuUsage = 0.0f; for (size_t a = 0; a < players.size(); ++a) { GameParticipant& player = players[a]; @@ -953,17 +937,23 @@ // adjust game speed if (refCpuUsage > 0.0f && !isPaused) { + //userSpeedFactor holds the wanted speed adjusted manually by user ( normally 1) + //internalSpeed holds the current speed the sim is running + //refCpuUsage holds the highest cpu if curSpeedCtrl == 0 or median if curSpeedCtrl == 1 + // aim for 60% cpu usage if median is used as reference and 75% cpu usage if max is the reference float wantedCpuUsage = (curSpeedCtrl == 1) ? 0.60f : 0.75f; - wantedCpuUsage += (1.0f - internalSpeed / userSpeedFactor) * 0.5f; //??? - float newSpeed = internalSpeed * wantedCpuUsage / refCpuUsage; - newSpeed = (newSpeed + internalSpeed) * 0.5f; + //the following line can actually make it go faster than wanted normal speed ( userSpeedFactor ) + //if the current cpu of the target is smaller than the aimed cpu target but the clamp will cap it + // the clamp will throttle it to the wanted one, otherwise it's a simple linear proportion aiming + // to keep cpu load constant + float newSpeed = internalSpeed/refCpuUsage*wantedCpuUsage; newSpeed = Clamp(newSpeed, 0.1f, userSpeedFactor); - if (userSpeedFactor <= 2.f) - newSpeed = std::max(newSpeed, (curSpeedCtrl == 1) ? userSpeedFactor * 0.8f : userSpeedFactor * 0.5f); - + //average to smooth the speed change over time to reduce the impact of cpu spikes in the players + newSpeed = (newSpeed + internalSpeed) * 0.5f; #ifndef DEDICATED + // in non-dedicated hosting, we'll add an additional safeguard to make sure the host can keep up with the game's speed // adjust game speed to localclient's (:= host) maximum SimFrame rate const float maxSimFPS = (1000.0f / gu->avgSimFrameTime) * (1.0f - gu->reconnectSimDrawBalance); newSpeed = Clamp(newSpeed, 0.1f, ((maxSimFPS / GAME_SPEED) + internalSpeed) * 0.5f); @@ -1920,24 +1910,25 @@ gameID.intArray[2] = crc.GetDigest(); CRC entropy; - entropy.Update(spring_tomsecs(lastNewFrameTick - serverStartTime)); + entropy.Update((lastNewFrameTick - serverStartTime).toNanoSecsi()); gameID.intArray[3] = entropy.GetDigest(); // fixed gameID? if (!setup->gameID.empty()) { unsigned char p[16]; #if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) - // workaround missing C99 support in a msvc lib with %02hhx + // workaround missing C99 support in a msvc lib with %2hhx generatedGameID = (sscanf(setup->gameID.c_str(), "%02hc%02hc%02hc%02hc%02hc%02hc%02hc%02hc" "%02hc%02hc%02hc%02hc%02hc%02hc%02hc%02hc", &p[ 0], &p[ 1], &p[ 2], &p[ 3], &p[ 4], &p[ 5], &p[ 6], &p[ 7], &p[ 8], &p[ 9], &p[10], &p[11], &p[12], &p[13], &p[14], &p[15]) == 16); #else - auto s = reinterpret_cast(&p[0]); generatedGameID = (sscanf(setup->gameID.c_str(), - "%02hx%02hx%02hx%02hx%02hx%02hx%02hx%02hx", - &s[ 0], &s[ 1], &s[ 2], &s[ 3], &s[ 4], &s[ 5], &s[ 6], &s[ 7]) == 8); + "%hhx%hhx%hhx%hhx%hhx%hhx%hhx%hhx" + "%hhx%hhx%hhx%hhx%hhx%hhx%hhx%hhx", + &p[ 0], &p[ 1], &p[ 2], &p[ 3], &p[ 4], &p[ 5], &p[ 6], &p[ 7], + &p[ 8], &p[ 9], &p[10], &p[11], &p[12], &p[13], &p[14], &p[15]) == 16); #endif if (generatedGameID) for (int i = 0; i<16; ++i) @@ -1997,10 +1988,10 @@ assert(!gameHasStarted); gameHasStarted = true; startTime = gameTime; - if (!canReconnect && !bypassScriptPasswordCheck) + if (!canReconnect && !allowSpecJoin) packetCache.clear(); // free memory - if (UDPNet && !canReconnect && !bypassScriptPasswordCheck) + if (UDPNet && !canReconnect && !allowSpecJoin) UDPNet->SetAcceptingConnections(false); // do not accept new connections // make sure initial game speed is within allowed range and send a new speed if not @@ -2064,9 +2055,6 @@ } } - GenerateAndSendGameID(); - rng.Seed(gameID.intArray[0] ^ gameID.intArray[1] ^ gameID.intArray[2] ^ gameID.intArray[3]); - Broadcast(CBaseNetProtocol::Get().SendRandSeed(rng())); Broadcast(CBaseNetProtocol::Get().SendStartPlaying(0)); if (hostif != NULL) { @@ -2111,24 +2099,20 @@ } else if (action.command == "mute") { if (action.extra.empty()) { - if (logWarnMessages) { - LOG_L(L_WARNING, "failed to mute player, usage: /mute [chatmute] [drawmute]"); - } + LOG_L(L_WARNING, "Failed to mute player, usage: /mute [chatmute] [drawmute]"); } else { const std::vector& tokens = CSimpleParser::Tokenize(action.extra); if (tokens.empty() || tokens.size() > 3) { - if (logWarnMessages) { - LOG_L(L_WARNING, "failed to mute player, usage: /mute [chatmute] [drawmute]"); - } + LOG_L(L_WARNING, "Failed to mute player, usage: /mute [chatmute] [drawmute]"); } else { const std::string name = StringToLower(tokens[0]); - bool muteChat; - bool muteDraw; + bool muteChat = true; + bool muteDraw = true; - if (!tokens.empty()) SetBoolArg(muteChat, tokens[1]); - if (tokens.size() >= 2) SetBoolArg(muteDraw, tokens[2]); + if (tokens.size() >= 2) InverseOrSetBool(muteChat, tokens[1]); + if (tokens.size() >= 3) InverseOrSetBool(muteDraw, tokens[2]); for (size_t a = 0; a < players.size(); ++a) { const std::string playerLower = StringToLower(players[a].name); @@ -2144,23 +2128,19 @@ else if (action.command == "mutebynum") { if (action.extra.empty()) { - if (logWarnMessages) { - LOG_L(L_WARNING, "failed to mute player, usage: /mutebynum [chatmute] [drawmute]"); - } + LOG_L(L_WARNING, "Failed to mute player, usage: /mutebynum [chatmute] [drawmute]"); } else { const std::vector& tokens = CSimpleParser::Tokenize(action.extra); if (tokens.empty() || tokens.size() > 3) { - if (logWarnMessages) { - LOG_L(L_WARNING, "failed to mute player, usage: /mutebynum [chatmute] [drawmute]"); - } + LOG_L(L_WARNING, "Failed to mute player, usage: /mutebynum [chatmute] [drawmute]"); } else { const int playerID = atoi(tokens[0].c_str()); bool muteChat = true; bool muteDraw = true; - if (!tokens.empty()) SetBoolArg(muteChat, tokens[1]); - if (tokens.size() >= 2) SetBoolArg(muteDraw, tokens[2]); + if (tokens.size() >= 2) InverseOrSetBool(muteChat, tokens[1]); + if (tokens.size() >= 3) InverseOrSetBool(muteDraw, tokens[2]); MutePlayer(playerID, muteChat, muteDraw); } @@ -2185,16 +2165,16 @@ } } else if (action.command == "nopause") { - SetBoolArg(gamePausable, action.extra); + InverseOrSetBool(gamePausable, action.extra); } else if (action.command == "nohelp") { - SetBoolArg(noHelperAIs, action.extra); + InverseOrSetBool(noHelperAIs, action.extra); // sent it because clients have to do stuff when this changes CommandMessage msg(action, SERVER_PLAYER); Broadcast(boost::shared_ptr(msg.Pack())); } else if (action.command == "nospecdraw") { - SetBoolArg(allowSpecDraw, action.extra); + InverseOrSetBool(allowSpecDraw, action.extra); // sent it because clients have to do stuff when this changes CommandMessage msg(action, SERVER_PLAYER); Broadcast(boost::shared_ptr(msg.Pack())); @@ -2254,7 +2234,7 @@ } } else if (action.command == "cheat") { - SetBoolArg(cheating, action.extra); + InverseOrSetBool(cheating, action.extra); CommandMessage msg(action, SERVER_PLAYER); Broadcast(boost::shared_ptr(msg.Pack())); } @@ -2291,45 +2271,26 @@ std::find_if( players.begin(), players.end(), boost::bind( &GameParticipant::name, _1 ) == name ); if (participantIter != players.end()) { - const GameParticipant::customOpts &opts = participantIter->GetAllValues(); - GameParticipant::customOpts::const_iterator it; - if ((it = opts.find("origpass")) == opts.end() || it->second == "") { - it = opts.find("password"); - if(it != opts.end()) - participantIter->SetValue("origpass", it->second); - } participantIter->SetValue("password", pwd); - if (logInfoMessages) { - LOG_L(L_INFO, "[%s] changed player/spectator password: \"%s\" \"%s\"", __FUNCTION__, name.c_str(), pwd.c_str()); - } + LOG("Changed player/spectator password: \"%s\" \"%s\"", name.c_str(), pwd.c_str()); } else { AddAdditionalUser(name, pwd, false, spectator, team); - if (logInfoMessages) { - LOG_L( - L_INFO, - "[%s] added client \"%s\" with password \"%s\" to team %d (as a %s)", - __FUNCTION__, name.c_str(), pwd.c_str(), team, (spectator? "spectator": "player") - ); - } - } - } else { - if (logWarnMessages) { - LOG_L(L_WARNING, - "[%s] failed to add player/spectator password. usage: " - "/adduser [spectator] [team]", - __FUNCTION__ + LOG("Added client \"%s\" with password \"%s\" to team %d (as a %s)", + name.c_str(), pwd.c_str(), team, (spectator? "spectator": "player") ); } + } else { + LOG_L(L_WARNING, + "Failed to add player/spectator password. usage: " + "/adduser [spectator] [team]" + ); } } } else if (action.command == "kill") { - if (logInfoMessages) { - LOG_L(L_INFO, "[%s] server killed", __FUNCTION__); - } - + LOG("Server killed!!!"); quitServer = true; } else if (action.command == "pause") { @@ -2344,7 +2305,7 @@ newPausedState = !isPaused; } else { // if a param is given, interpret it as "bool setPaused" - SetBoolArg(newPausedState, action.extra); + InverseOrSetBool(newPausedState, action.extra); } isPaused = newPausedState; @@ -2462,34 +2423,36 @@ for (size_t p = 0; p < players.size(); ++p) players[p].SendData(progressPacket); } -#ifdef SYNCCHECK + #ifdef SYNCCHECK outstandingSyncFrames.insert(serverFrameNum); -#endif + #endif } } } -void CGameServer::UpdateSpeedControl(int speedCtrl) { + +void CGameServer::UpdateSpeedControl(int speedCtrl) +{ if (speedCtrl != curSpeedCtrl) { - Message(str(format("Server speed control: %s") - %(SpeedControlToString(speedCtrl).c_str()))); + Message(str(format("Server speed control: %s") %(SpeedControlToString(speedCtrl).c_str()))); curSpeedCtrl = speedCtrl; } } -std::string CGameServer::SpeedControlToString(int speedCtrl) { - std::string desc; +std::string CGameServer::SpeedControlToString(int speedCtrl) +{ + std::string desc = ""; if (speedCtrl == 0) { desc = "Maximum CPU"; - } else if (speedCtrl == 1) { + } else + if (speedCtrl == 1) { desc = "Average CPU"; - } else { - desc = ""; } return desc; } + __FORCE_ALIGN_STACK__ void CGameServer::UpdateLoop() { @@ -2497,8 +2460,9 @@ Threading::SetThreadName("netcode"); Threading::SetAffinity(~0); + //FIXME use async callback funcs in boost udp sockets and so get rid of any latency & remove netcode thread while (!quitServer) { - spring_sleep(spring_msecs(1)); + spring_sleep(spring_msecs(5)); if (UDPNet) UDPNet->Update(); @@ -2516,9 +2480,9 @@ // this is to make sure the Flush has any effect at all (we don't want a forced flush) spring_sleep(spring_msecs(1000)); - for (size_t i = 0; i < players.size(); ++i) { - if (players[i].link) - players[i].link->Flush(); + for (GameParticipant& p: players) { + if (p.link) + p.link->Flush(); } // now let clients close their connections @@ -2526,10 +2490,6 @@ } CATCH_SPRING_ERRORS } -bool CGameServer::WaitsOnCon() const -{ - return (UDPNet && UDPNet->IsAcceptingConnections()); -} void CGameServer::KickPlayer(const int playerNum) { @@ -2544,25 +2504,26 @@ hostif->SendPlayerLeft(playerNum, 2); } -void CGameServer::MutePlayer(const int playerNum, bool muteChat, bool muteDraw ) + +void CGameServer::MutePlayer(const int playerNum, bool muteChat, bool muteDraw) { if (playerNum >= players.size()) { - if (logWarnMessages) { - LOG_L(L_WARNING,"invalid playerNum"); - } + LOG_L(L_WARNING, "MutePlayer: invalid playerNum"); return; } - if ( playerNum < mutedPlayersChat.size() ) { - mutedPlayersChat.resize(playerNum); + if ( playerNum >= mutedPlayersChat.size() ) { + mutedPlayersChat.resize(playerNum+1); } - if ( playerNum < mutedPlayersDraw.size() ) { - mutedPlayersDraw.resize(playerNum); + if ( playerNum >= mutedPlayersDraw.size() ) { + mutedPlayersDraw.resize(playerNum+1); } mutedPlayersChat[playerNum] = muteChat; mutedPlayersDraw[playerNum] = muteDraw; } -void CGameServer::SpecPlayer(const int player) { + +void CGameServer::SpecPlayer(const int player) +{ if (!players[player].link) { Message(str(format("Attempt to spec user %d who is not connected") %player)); return; @@ -2575,6 +2536,7 @@ ResignPlayer(player); } + void CGameServer::ResignPlayer(const int player) { Broadcast(CBaseNetProtocol::Get().SendResign(player)); @@ -2608,6 +2570,21 @@ } +bool CGameServer::CheckPlayersPassword(const int playerNum, const std::string& pw) const +{ + if (playerNum >= players.size()) // new player + return true; + + const GameParticipant::customOpts& opts = players[playerNum].GetAllValues(); + auto it = opts.find("password"); + + if (it == opts.end() || it->second == pw) + return true; + + return false; +} + + void CGameServer::AddAdditionalUser(const std::string& name, const std::string& passwd, bool fromDemo, bool spectator, int team) { GameParticipant buf; @@ -2616,8 +2593,8 @@ buf.spectator = spectator; buf.team = team; buf.isMidgameJoin = true; - if (passwd.size() > 0) - buf.SetValue("password",passwd); + if (!passwd.empty()) + buf.SetValue("password", passwd); players.push_back(buf); UpdatePlayerNumberMap(); if (!fromDemo) @@ -2638,69 +2615,66 @@ std::string errmsg = ""; bool terminate = false; + // find the player in the current list for (size_t i = 0; i < players.size(); ++i) { - if (name == players[i].name) { - if (!players[i].isFromDemo) { - if (!players[i].link) { - if (reconnect) - errmsg = "User is not ingame"; - else if (canReconnect || !gameHasStarted) - newPlayerNumber = i; - else - errmsg = "Game has already started"; - break; - } - else { - bool reconnectAllowed = canReconnect && players[i].link->CheckTimeout(-1); - if (!reconnect && reconnectAllowed) { - newPlayerNumber = i; - terminate = true; - } - else if (reconnect && reconnectAllowed && players[i].link->GetFullAddress() != link->GetFullAddress()) - newPlayerNumber = i; - else - errmsg = "User is already ingame"; - break; - } - } - else { - errmsg = "User name duplicated in the demo"; + const GameParticipant& p = players[i]; + + if (name != p.name) + continue; + + if (p.isFromDemo) { + errmsg = "User name duplicated in the demo"; + } else + if (!p.link) { + if (reconnect) + errmsg = "User is not ingame"; + else if (canReconnect || !gameHasStarted) + newPlayerNumber = i; + else + errmsg = "Game has already started"; + } + else { + bool reconnectAllowed = canReconnect && p.link->CheckTimeout(-1); + if (!reconnect && reconnectAllowed) { + newPlayerNumber = i; + terminate = true; } + else if (reconnect && reconnectAllowed && p.link->GetFullAddress() != link->GetFullAddress()) + newPlayerNumber = i; + else + errmsg = "User is already ingame"; } + break; } - if (newPlayerNumber >= players.size() && errmsg == "") { - if (demoReader || bypassScriptPasswordCheck) + // not found in the original start script, allow spector join? + if (errmsg.empty() && newPlayerNumber >= players.size()) { + if (demoReader || allowSpecJoin) AddAdditionalUser(name, passwd); else errmsg = "User name not authorized to connect"; } - // check for user's password - if (errmsg == "" && !isLocal) { - if (newPlayerNumber < players.size()) { - const GameParticipant::customOpts &opts = players[newPlayerNumber].GetAllValues(); - GameParticipant::customOpts::const_iterator it; - if ((it = opts.find("password")) != opts.end() && passwd != it->second) { - if ((!reconnect || (it = opts.find("origpass")) == opts.end() || it->second == "" || passwd != it->second)) - errmsg = "Incorrect password"; - } - else if (!reconnect) // forget about origpass whenever a real mid-game join succeeds - players[newPlayerNumber].SetValue("origpass", ""); - } - } + // check user's password + if (errmsg.empty() && !isLocal) // disable pw check for local host + if (!CheckPlayersPassword(newPlayerNumber, passwd)) + errmsg = "Incorrect password"; - if(!reconnect) // don't respond before we are sure we want to do it + if (!reconnect) // don't respond before we are sure we want to do it link->Unmute(); // never respond to reconnection attempts, it could interfere with the protocol and desync - if (newPlayerNumber >= players.size() || errmsg != "") { + // >> Reject Connection << + if (!errmsg.empty() || newPlayerNumber >= players.size()) { Message(str(format(" -> %s") %errmsg)); link->SendData(CBaseNetProtocol::Get().SendQuit(str(format("Connection rejected: %s") %errmsg))); return 0; } + // >> Accept Connection << GameParticipant& newPlayer = players[newPlayerNumber]; + newPlayer.isReconn = gameHasStarted; + // there is a running link already -> terminate it if (terminate) { Message(str(format(PlayerLeft) %newPlayer.GetType() %newPlayer.name %" terminating existing connection")); Broadcast(CBaseNetProtocol::Get().SendPlayerLeft(newPlayerNumber, 0)); @@ -2710,12 +2684,11 @@ hostif->SendPlayerLeft(newPlayerNumber, 0); } - if (newPlayer.isMidgameJoin) { - link->SendData(CBaseNetProtocol::Get().SendCreateNewPlayer(newPlayerNumber, newPlayer.spectator, newPlayer.team, newPlayer.name)); // inform the player about himself if it's a midgame join - } - - newPlayer.isReconn = gameHasStarted; + // inform the player about himself if it's a midgame join + if (newPlayer.isMidgameJoin) + link->SendData(CBaseNetProtocol::Get().SendCreateNewPlayer(newPlayerNumber, newPlayer.spectator, newPlayer.team, newPlayer.name)); + // there is an open link -> reconnect if (newPlayer.link) { newPlayer.link->ReconnectTo(*link); if (UDPNet) @@ -2746,24 +2719,26 @@ } } + // new connection established Message(str(format(" -> Connection established (given id %i)") %newPlayerNumber)); - link->SetLossFactor(netloss); link->Flush(!gameHasStarted); return newPlayerNumber; } + void CGameServer::GotChatMessage(const ChatMessage& msg) { if (!msg.msg.empty()) { // silently drop empty chat messages Broadcast(boost::shared_ptr(msg.Pack())); - if (hostif && msg.fromPlayer >= 0 && static_cast(msg.fromPlayer) != SERVER_PLAYER) { + if (hostif && msg.fromPlayer >= 0 && msg.fromPlayer != SERVER_PLAYER) { // do not echo packets to the autohost - hostif->SendPlayerChat(msg.fromPlayer, msg.destination, msg.msg); + hostif->SendPlayerChat(msg.fromPlayer, msg.destination, msg.msg); } } } + void CGameServer::InternalSpeedChange(float newSpeed) { if (internalSpeed == newSpeed) { @@ -2773,9 +2748,10 @@ internalSpeed = newSpeed; } + void CGameServer::UserSpeedChange(float newSpeed, int player) { - newSpeed = std::min(maxUserSpeed, std::max(newSpeed, minUserSpeed)); + newSpeed = Clamp(newSpeed, minUserSpeed, maxUserSpeed); if (userSpeedFactor != newSpeed) { if (internalSpeed > newSpeed || internalSpeed == userSpeedFactor) // insta-raise speed when not slowed down @@ -2786,8 +2762,9 @@ } } -unsigned char CGameServer::ReserveNextAvailableSkirmishAIId() { +unsigned char CGameServer::ReserveNextAvailableSkirmishAIId() +{ if (usedSkirmishAIIds.size() >= MAX_AIS) return MAX_AIS; // no available IDs @@ -2804,11 +2781,15 @@ return skirmishAIId; } -void CGameServer::FreeSkirmishAIId(const unsigned char skirmishAIId) { + +void CGameServer::FreeSkirmishAIId(const unsigned char skirmishAIId) +{ usedSkirmishAIIds.remove(skirmishAIId); } -void CGameServer::AddToPacketCache(boost::shared_ptr &pckt) { + +void CGameServer::AddToPacketCache(boost::shared_ptr &pckt) +{ if (packetCache.empty() || packetCache.back().size() >= PKTCACHE_VECSIZE) { packetCache.push_back(std::vector >()); packetCache.back().reserve(PKTCACHE_VECSIZE); diff -Nru spring-96.0~14.04~ppa4/rts/Net/GameServer.h spring-98.0~14.04~ppa6/rts/Net/GameServer.h --- spring-96.0~14.04~ppa4/rts/Net/GameServer.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Net/GameServer.h 2014-10-07 20:09:51.000000000 +0000 @@ -41,7 +41,6 @@ class CDemoRecorder; class AutohostInterface; class CGameSetup; -class ClientSetup; class ChatMessage; class GameParticipant; class GameSkirmishAI; @@ -72,6 +71,8 @@ CGameServer(const std::string& hostIP, int hostPort, const GameData* const gameData, const CGameSetup* const setup); ~CGameServer(); + CGameServer(const CGameServer&) = delete; // no-copy + void AddLocalClient(const std::string& myName, const std::string& myVersion); void AddAutohostInterface(const std::string& autohostIP, const int autohostPort); @@ -84,8 +85,6 @@ void CreateNewFrame(bool fromServerThread, bool fixedFrameTime); - bool WaitsOnCon() const; - void SetGamePausable(const bool arg); bool HasStarted() const { return gameHasStarted; } @@ -124,9 +123,10 @@ /** * @brief drops chat or drawin messages for given playerNum */ - void MutePlayer(const int playerNum, bool muteChat, bool muteDraw ); + void MutePlayer(const int playerNum, bool muteChat, bool muteDraw); void ResignPlayer(const int playerNum); + bool CheckPlayersPassword(const int playerNum, const std::string& pw) const; unsigned BindConnection(std::string name, const std::string& passwd, const std::string& version, bool isLocal, boost::shared_ptr link, bool reconnect = false, int netloss = 0); @@ -168,8 +168,11 @@ float GetDemoTime() const; private: - /////////////////// game status variables /////////////////// + /////////////////// game settings /////////////////// + boost::scoped_ptr setup; + boost::scoped_ptr gameData; + /////////////////// game status variables /////////////////// unsigned char playerNumberMap[256]; volatile bool quitServer; int serverFrameNum; @@ -195,11 +198,8 @@ float userSpeedFactor; float internalSpeed; - unsigned char ReserveNextAvailableSkirmishAIId(); - std::map ais; std::list usedSkirmishAIIds; - void FreeSkirmishAIId(const unsigned char skirmishAIId); std::vector players; std::vector teams; @@ -212,13 +212,8 @@ int medianPing; int curSpeedCtrl; - /////////////////// game settings /////////////////// - boost::scoped_ptr setup; - boost::scoped_ptr gameData; - /// The maximum speed users are allowed to set float maxUserSpeed; - /// The minimum speed users are allowed to set (actual speed can be lower due to high cpu usage) float minUserSpeed; @@ -226,13 +221,11 @@ bool noHelperAIs; bool canReconnect; bool allowSpecDraw; - bool bypassScriptPasswordCheck; + bool allowSpecJoin; bool whiteListAdditionalPlayers; bool logInfoMessages; - bool logErrorMessages; bool logDebugMessages; - bool logWarnMessages; std::list< std::vector > > packetCache; @@ -248,6 +241,8 @@ void UserSpeedChange(float newSpeed, int player); void AddAdditionalUser( const std::string& name, const std::string& passwd, bool fromDemo = false, bool spectator = true, int team = 0); + unsigned char ReserveNextAvailableSkirmishAIId(); + void FreeSkirmishAIId(const unsigned char skirmishAIId); bool hasLocalClient; unsigned localClientNumber; diff -Nru spring-96.0~14.04~ppa4/rts/Net/NetCommands.cpp spring-98.0~14.04~ppa6/rts/Net/NetCommands.cpp --- spring-96.0~14.04~ppa4/rts/Net/NetCommands.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Net/NetCommands.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -20,7 +20,7 @@ #include "Game/Players/PlayerHandler.h" #include "Game/UI/GameSetupDrawer.h" #include "Game/UI/MouseHandler.h" -#include "Lua/LuaRules.h" +#include "Lua/LuaHandle.h" #include "Rendering/GlobalRendering.h" #include "Sim/Misc/TeamHandler.h" #include "Sim/Path/IPathManager.h" @@ -40,6 +40,9 @@ LOG_REGISTER_SECTION_GLOBAL(LOG_SECTION_NET) +static std::map mySyncChecksums; + + void CGame::AddTraffic(int playerID, int packetCode, int length) { std::map::iterator it = playerTraffic.find(playerID); @@ -68,7 +71,7 @@ if (playing) { const float simProcUsage = (profiler.GetPercent("SimFrame")); const float drawProcUsage = (profiler.GetPercent("GameController::Draw") / std::max(1.0f, globalRendering->FPS)) * gu->minFPS; - const float totalProcUsage = simProcUsage + drawProcUsage * (!GML::SimEnabled() || !GML::MultiThreadSim()); + const float totalProcUsage = simProcUsage + drawProcUsage; // take the minimum drawframes into account, too net->Send(CBaseNetProtocol::Get().SendCPUUsage(totalProcUsage)); @@ -105,14 +108,11 @@ case NETMSG_NEWFRAME: case NETMSG_KEYFRAME: - ++numQueuedFrames; + if (numQueuedFrames < maxFrames) + ++numQueuedFrames; default: ++packetPeekIndex; } - - if (numQueuedFrames > maxFrames) { - break; - } } return numQueuedFrames; @@ -128,13 +128,17 @@ const spring_time currTime = spring_gettime(); const spring_time deltaTime = currTime - lastUpdateTime; - if (globalConfig->useNetMessageSmoothingBuffer) { - // update consumption-rate faster at higher game speeds - if (deltaTime.toMilliSecsf() < (1000.0f / gs->speedFactor)) - return; + // update consumption-rate faster at higher game speeds + if (deltaTime.toMilliSecsf() < (500.0f / gs->speedFactor)) + return; - const unsigned int numQueuedFrames = GetNumQueuedSimFrameMessages(GAME_SPEED * gs->speedFactor * 5); + // NOTE: + // unnecessary to scan entire queue *unless* joining a running game + // only reason in that case is to handle NETMSG_GAME_FRAME_PROGRESS + // + const unsigned int numQueuedFrames = GetNumQueuedSimFrameMessages(-1u); + if (globalConfig->useNetMessageSmoothingBuffer) { if (numQueuedFrames < lastNumQueuedSimFrames) { // conservative policy: take minimum of current and previous queue size // we *NEVER* want the queue to run completely dry (by not keeping a few @@ -151,16 +155,17 @@ // at higher speeds we need to keep more distance! // (because effect of network jitter is amplified) consumeSpeedMult = GAME_SPEED * gs->speedFactor + lastNumQueuedSimFrames - (2 * gs->speedFactor); - lastUpdateTime = currTime; } else { - if (deltaTime.toMilliSecsf() < 1000.0f) - return; - - // SPRING95 - // this uses no buffering which makes it too sensitive - // to jitter (especially on lower-quality connections) - consumeSpeedMult = GAME_SPEED * gs->speedFactor + (GetNumQueuedSimFrameMessages(-1u) / 2); + // Modified SPRING95 behaviour + // Aim at staying 2 sim frames behind. + consumeSpeedMult = GAME_SPEED * gs->speedFactor + (numQueuedFrames/2) - 1; } + + // await one sim frame if queue is dry + if (numQueuedFrames == 0) + msgProcTimeLeft = -1000.0f * gs->speedFactor; + + lastUpdateTime = currTime; } void CGame::UpdateNetMessageProcessingTimeLeft() @@ -180,8 +185,6 @@ // (the amount of processing time is weighted by dt and also increases // when more messages are waiting) // - // don't let the limit get over 1000ms - msgProcTimeLeft -= (1000.0f * float(msgProcTimeLeft > 1000.0f)); msgProcTimeLeft += (consumeSpeedMult * deltaReadNetTime.toMilliSecsf()); } @@ -204,23 +207,16 @@ const float minDrawFPS = gu->reconnectSimDrawBalance * 1000.0f / std::max(0.01f, gu->avgDrawFrameTime); const float simDrawRatio = maxSimFPS / minDrawFPS; - float limit = 0.0f; - - if (GML::SimEnabled() && GML::MultiThreadSim()) { - limit = (1000.0f / gu->minFPS); - } else { - limit = Clamp(simDrawRatio * gu->avgSimFrameTime, 5.0f, 1000.0f / gu->minFPS); - } - - return limit; + return Clamp(simDrawRatio * gu->avgSimFrameTime, 5.0f, 1000.0f / gu->minFPS); } void CGame::ClientReadNet() { - UpdateNetMessageProcessingTimeLeft(); // look ahead so we can adapt consumeSpeedMult to network fluctuations UpdateNumQueuedSimFrames(); + UpdateNetMessageProcessingTimeLeft(); + const spring_time msgProcEndTime = spring_gettime() + spring_msecs(GetNetMessageProcessingTimeLimit()); // really process the messages @@ -335,8 +331,6 @@ } case NETMSG_USER_SPEED: { - gs->wantedSpeedFactor = *((float*) &inbuf[2]); - const unsigned char player = inbuf[1]; if (!playerHandler->IsValidPlayer(player) && player != SERVER_PLAYER) { LOG_L(L_ERROR, "Got invalid player num %i in user speed msg", player); @@ -344,6 +338,7 @@ } const char* pName = (player == SERVER_PLAYER)? "server": playerHandler->Player(player)->name.c_str(); + gs->wantedSpeedFactor = *((float*) &inbuf[2]); LOG("Speed set to %.1f [%s]", gs->wantedSpeedFactor, pName); AddTraffic(player, packetCode, dataLength); break; @@ -432,7 +427,7 @@ CTeam* team = teamHandler->Team(teamID); team->ClampStartPosInStartBox(&clampedPos); - if (!luaRules || luaRules->AllowStartPosition(playerID, rdyState, clampedPos, rawPickPos)) { + if (eventHandler.AllowStartPosition(playerID, rdyState, clampedPos, rawPickPos)) { team->SetStartPos(clampedPos); if (playerID != SERVER_PLAYER) { @@ -516,6 +511,11 @@ ASSERT_SYNCED(CSyncChecker::GetChecksum()); net->Send(CBaseNetProtocol::Get().SendSyncResponse(gu->myPlayerNum, gs->frameNum, CSyncChecker::GetChecksum())); + if (gameServer != NULL && gameServer->GetDemoReader() != NULL) { + // buffer all checksums, so we can check sync later between demo & local + mySyncChecksums[gs->frameNum] = CSyncChecker::GetChecksum(); + } + if ((gs->frameNum & 4095) == 0) { // reset checksum every 4096 frames =~ 2.5 minutes CSyncChecker::NewFrame(); @@ -538,10 +538,11 @@ netcode::UnpackPacket pckt(packet, 1); unsigned char playerNum; pckt >> playerNum; - int frameNum; pckt >> frameNum; + int frameNum; pckt >> frameNum; unsigned int checkSum; pckt >> checkSum; - const unsigned int ourCheckSum = CSyncChecker::GetChecksum(); + const unsigned int ourCheckSum = mySyncChecksums[frameNum]; + const char* fmtStr = "[DESYNC_WARNING] checksum %x from player %d (%s)" " does not match our checksum %x for frame-number %d"; @@ -550,11 +551,10 @@ // check if our checksum for this frame matches what // player sent to the server at the same // frame in the original game (in case of a demo) - if (playerNum == gu->myPlayerNum) { return; } - if (gs->frameNum != frameNum) { return; } - if (checkSum == ourCheckSum) { return; } + if (playerNum == gu->myPlayerNum) { break; } + if (checkSum == ourCheckSum) { break; } - LOG_L(L_ERROR, fmtStr, checkSum, playerNum, player->name.c_str(), ourCheckSum, gs->frameNum); + LOG_L(L_ERROR, fmtStr, checkSum, playerNum, player->name.c_str(), ourCheckSum, frameNum); } #endif } break; @@ -780,13 +780,13 @@ pckt >> energyShare; if (metalShare > 0.0f) { - if (!luaRules || luaRules->AllowResourceTransfer(srcTeam, dstTeam, "m", metalShare)) { + if (eventHandler.AllowResourceTransfer(srcTeam, dstTeam, "m", metalShare)) { teamHandler->Team(srcTeam)->metal -= metalShare; teamHandler->Team(dstTeam)->metal += metalShare; } } if (energyShare > 0.0f) { - if (!luaRules || luaRules->AllowResourceTransfer(srcTeam, dstTeam, "e", energyShare)) { + if (eventHandler.AllowResourceTransfer(srcTeam, dstTeam, "e", energyShare)) { teamHandler->Team(srcTeam)->energy -= energyShare; teamHandler->Team(dstTeam)->energy += energyShare; } @@ -851,7 +851,7 @@ const float energyShare = Clamp(*(float*)&inbuf[8], 0.0f, (float)srcTeam->energy); if (metalShare > 0.0f) { - if (!luaRules || luaRules->AllowResourceTransfer(srcTeamID, dstTeamID, "m", metalShare)) { + if (eventHandler.AllowResourceTransfer(srcTeamID, dstTeamID, "m", metalShare)) { srcTeam->metal -= metalShare; srcTeam->metalSent += metalShare; srcTeam->currentStats->metalSent += metalShare; @@ -861,7 +861,7 @@ } } if (energyShare > 0.0f) { - if (!luaRules || luaRules->AllowResourceTransfer(srcTeamID, dstTeamID, "e", energyShare)) { + if (eventHandler.AllowResourceTransfer(srcTeamID, dstTeamID, "e", energyShare)) { srcTeam->energy -= energyShare; srcTeam->energySent += energyShare; srcTeam->currentStats->energySent += energyShare; @@ -916,10 +916,10 @@ float metalShare=*(float*)&inbuf[3]; float energyShare=*(float*)&inbuf[7]; - if (!luaRules || luaRules->AllowResourceLevel(team, "m", metalShare)) { + if (eventHandler.AllowResourceLevel(team, "m", metalShare)) { teamHandler->Team(team)->metalShare = metalShare; } - if (!luaRules || luaRules->AllowResourceLevel(team, "e", energyShare)) { + if (eventHandler.AllowResourceLevel(team, "e", energyShare)) { teamHandler->Team(team)->energyShare = energyShare; } AddTraffic(player, packetCode, dataLength); @@ -1290,7 +1290,9 @@ } break; } - // drop NETMSG_GAME_FRAME_PROGRESS, if we recieved it here, it means we're the host ( so message wasn't processed ), so discard it + + // if we received this packet here we are the host player + // (meaning the message was not processed), so discard it case NETMSG_GAME_FRAME_PROGRESS: { break; } diff -Nru spring-96.0~14.04~ppa4/rts/Net/Protocol/BaseNetProtocol.h spring-98.0~14.04~ppa6/rts/Net/Protocol/BaseNetProtocol.h --- spring-96.0~14.04~ppa4/rts/Net/Protocol/BaseNetProtocol.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Net/Protocol/BaseNetProtocol.h 2014-10-07 20:09:51.000000000 +0000 @@ -18,7 +18,7 @@ struct PlayerStatistics; -const unsigned short NETWORK_VERSION = atoi(SpringVersion::GetMajor().c_str()); +static const unsigned short NETWORK_VERSION = atoi(SpringVersion::GetMajor().c_str()); /* diff -Nru spring-96.0~14.04~ppa4/rts/Net/Protocol/NetProtocol.cpp spring-98.0~14.04~ppa6/rts/Net/Protocol/NetProtocol.cpp --- spring-96.0~14.04~ppa4/rts/Net/Protocol/NetProtocol.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Net/Protocol/NetProtocol.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -19,11 +19,10 @@ #include "System/Config/ConfigHandler.h" #include "System/GlobalConfig.h" #include "System/Log/ILog.h" -#include "lib/gml/gmlmut.h" CONFIG(int, SourcePort).defaultValue(0); -CNetProtocol::CNetProtocol() : loading(false) +CNetProtocol::CNetProtocol() : keepUpdating(false) { demoRecorder.reset(NULL); } @@ -37,23 +36,23 @@ void CNetProtocol::InitClient(const char* server_addr, unsigned portnum, const std::string& myName, const std::string& myPasswd, const std::string& myVersion) { - GML_STDMUTEX_LOCK(net); // InitClient + userName = myName; + userPasswd = myPasswd; netcode::UDPConnection* conn = new netcode::UDPConnection(configHandler->GetInt("SourcePort"), server_addr, portnum); conn->Unmute(); serverConn.reset(conn); - serverConn->SendData(CBaseNetProtocol::Get().SendAttemptConnect(myName, myPasswd, myVersion, globalConfig->networkLossFactor)); + serverConn->SendData(CBaseNetProtocol::Get().SendAttemptConnect(userName, userPasswd, myVersion, globalConfig->networkLossFactor)); serverConn->Flush(true); LOG("Connecting to %s:%i using name %s", server_addr, portnum, myName.c_str()); } -void CNetProtocol::AttemptReconnect(const std::string& myName, const std::string& myPasswd, const std::string& myVersion) { - GML_STDMUTEX_LOCK(net); // AttemptReconnect - +void CNetProtocol::AttemptReconnect(const std::string& myVersion) +{ netcode::UDPConnection* conn = new netcode::UDPConnection(*serverConn); conn->Unmute(); - conn->SendData(CBaseNetProtocol::Get().SendAttemptConnect(myName, myPasswd, myVersion, globalConfig->networkLossFactor, true)); + conn->SendData(CBaseNetProtocol::Get().SendAttemptConnect(userName, userPasswd, myVersion, globalConfig->networkLossFactor, true)); conn->Flush(true); LOG("Reconnecting to server... %ds", dynamic_cast(*serverConn).GetReconnectSecs()); @@ -67,8 +66,6 @@ void CNetProtocol::InitLocalClient() { - GML_STDMUTEX_LOCK(net); // InitLocalClient - serverConn.reset(new netcode::CLocalConnection); serverConn->Flush(); @@ -91,15 +88,11 @@ boost::shared_ptr CNetProtocol::Peek(unsigned ahead) const { - GML_STDMUTEX_LOCK(net); // Peek - return serverConn->Peek(ahead); } void CNetProtocol::DeleteBufferPacketAt(unsigned index) { - GML_STDMUTEX_LOCK(net); // DeleteBufferPacketAt - return serverConn->DeleteBufferPacketAt(index); } @@ -113,8 +106,6 @@ boost::shared_ptr CNetProtocol::GetData(int frameNum) { - GML_STDMUTEX_LOCK(net); // GetData - boost::shared_ptr ret = serverConn->GetData(); if (ret.get() == NULL) { return ret; } @@ -129,8 +120,6 @@ void CNetProtocol::Send(boost::shared_ptr pkt) { - GML_STDMUTEX_LOCK(net); // Send - serverConn->SendData(pkt); } @@ -144,23 +133,20 @@ void CNetProtocol::UpdateLoop() { Threading::SetThreadName("heartbeat"); - loading = true; - while (loading) { + + while (keepUpdating) { Update(); - spring_msecs(400).sleep(); + spring_msecs(100).sleep(); } } void CNetProtocol::Update() { - GML_STDMUTEX_LOCK(net); // Update - serverConn->Update(); } -void CNetProtocol::Close(bool flush) { - GML_STDMUTEX_LOCK(net); // Close - +void CNetProtocol::Close(bool flush) +{ serverConn->Close(flush); } diff -Nru spring-96.0~14.04~ppa4/rts/Net/Protocol/NetProtocol.h spring-98.0~14.04~ppa6/rts/Net/Protocol/NetProtocol.h --- spring-96.0~14.04~ppa4/rts/Net/Protocol/NetProtocol.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Net/Protocol/NetProtocol.h 2014-10-07 20:09:51.000000000 +0000 @@ -43,7 +43,7 @@ /// Are we still connected (or did the connection time-out)? bool CheckTimeout(int nsecs = 0, bool initial = false) const; - void AttemptReconnect(const std::string& myName, const std::string& myPasswd, const std::string& myVersion); + void AttemptReconnect(const std::string& myVersion); bool NeedsReconnect(); @@ -89,7 +89,7 @@ /** * Updates our network while the game loads to prevent timeouts. - * Runs until \a loading is false. + * Runs until \a keepUpdating is false. */ void UpdateLoop(); @@ -98,7 +98,7 @@ void Close(bool flush = false); - void SetLoading(bool b) { loading = b; } + void KeepUpdating(bool b) { keepUpdating = b; } void SetDemoRecorder(CDemoRecorder* r); CDemoRecorder* GetDemoRecorder() const; @@ -107,10 +107,13 @@ private: - volatile bool loading; + volatile bool keepUpdating; boost::scoped_ptr serverConn; boost::scoped_ptr demoRecorder; + + std::string userName; + std::string userPasswd; }; extern CNetProtocol* net; diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/CMakeLists.txt spring-98.0~14.04~ppa6/rts/Rendering/CMakeLists.txt --- spring-96.0~14.04~ppa4/rts/Rendering/CMakeLists.txt 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -74,11 +74,14 @@ "${CMAKE_CURRENT_SOURCE_DIR}/Textures/TextureAtlas.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Textures/nv_dds.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Textures/QuadtreeAtlasAlloc.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/Textures/RowAtlasAlloc.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/UnitDrawer.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/UnitDrawerState.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/VerticalSync.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/WorldDrawer.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/glFont.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/Fonts/CFontTexture.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/Fonts/glFont.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/Fonts/TextWrap.cpp" + PARENT_SCOPE ) -MakeGlobal(sources_engine_Rendering) diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Colors.h spring-98.0~14.04~ppa6/rts/Rendering/Colors.h --- spring-96.0~14.04~ppa4/rts/Rendering/Colors.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Colors.h 2014-10-07 20:09:51.000000000 +0000 @@ -11,6 +11,6 @@ const unsigned char green[4] = {0, 255, 0, 25}; const unsigned char white[4] = {255, 255, 255, 255}; const unsigned char whiteA[4] = {255, 255, 255, 25}; -}; +} #endif // COLORS_H diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/CommandDrawer.cpp spring-98.0~14.04~ppa6/rts/Rendering/CommandDrawer.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/CommandDrawer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/CommandDrawer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -79,7 +79,7 @@ } else { const float x = ci->params[0]; const float z = ci->params[2]; - const float y = ground->GetHeightReal(x, z, false) + 3.0f; + const float y = CGround::GetHeightReal(x, z, false) + 3.0f; lineDrawer.DrawLineAndIcon(cmdID, float3(x, y, z), cmdColors.attack); } @@ -147,7 +147,7 @@ } else { const float x = ci->params[0]; const float z = ci->params[2]; - const float y = ground->GetHeightReal(x, z, false) + 3.0f; + const float y = CGround::GetHeightReal(x, z, false) + 3.0f; lineDrawer.DrawLineAndIcon(cmdID, float3(x, y, z), cmdColors.attack); } @@ -280,7 +280,7 @@ } else { const float x = ci->params[0]; const float z = ci->params[2]; - const float y = ground->GetHeightReal(x, z, false) + 3.0f; + const float y = CGround::GetHeightReal(x, z, false) + 3.0f; lineDrawer.DrawLineAndIcon(cmdID, float3(x, y, z), cmdColors.attack); } @@ -309,8 +309,6 @@ const unsigned int id = signedId; if (id >= unitHandler->MaxUnits()) { - GML_RECMUTEX_LOCK(feat); // DrawCommands - CFeature* feature = featureHandler->GetFeature(id - unitHandler->MaxUnits()); if (feature) { const float3 endPos = feature->midPos; @@ -422,7 +420,7 @@ } else { const float x = ci->params[0]; const float z = ci->params[2]; - const float y = ground->GetHeightReal(x, z, false) + 3.0f; + const float y = CGround::GetHeightReal(x, z, false) + 3.0f; lineDrawer.DrawLineAndIcon(cmdID, float3(x, y, z), cmdColors.attack); } @@ -522,7 +520,7 @@ else if (ci->params.size() >= 3) { const float x = ci->params[0]; const float z = ci->params[2]; - const float y = ground->GetHeightReal(x, z, false) + 3.0f; + const float y = CGround::GetHeightReal(x, z, false) + 3.0f; lineDrawer.DrawLineAndIcon(cmdID, float3(x, y, z), cmdColors.attack); } @@ -605,7 +603,7 @@ } else { const float x = ci->params[0]; const float z = ci->params[2]; - const float y = ground->GetHeightReal(x, z, false) + 3.0f; + const float y = CGround::GetHeightReal(x, z, false) + 3.0f; lineDrawer.DrawLineAndIcon(cmdID, float3(x, y, z), cmdColors.attack); } diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/DebugColVolDrawer.cpp spring-98.0~14.04~ppa6/rts/Rendering/DebugColVolDrawer.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/DebugColVolDrawer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/DebugColVolDrawer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -255,8 +255,7 @@ void Draw() { - // DebugColVolDrawer is not thread-safe - if (GML::Enabled() || !enable) + if (!enable) return; glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT); diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/DebugColVolDrawer.h spring-98.0~14.04~ppa6/rts/Rendering/DebugColVolDrawer.h --- spring-96.0~14.04~ppa4/rts/Rendering/DebugColVolDrawer.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/DebugColVolDrawer.h 2014-10-07 20:09:51.000000000 +0000 @@ -9,7 +9,7 @@ extern bool enable; void Draw(); -}; +} #endif /* DEBUGCOLVOLDRAWER_H_ */ diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/DebugDrawerAI.cpp spring-98.0~14.04~ppa6/rts/Rendering/DebugDrawerAI.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/DebugDrawerAI.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/DebugDrawerAI.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -3,7 +3,7 @@ #include "ExternalAI/SkirmishAIHandler.h" #include "Game/GlobalUnsynced.h" #include "Rendering/DebugDrawerAI.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Rendering/GlobalRendering.h" #include "Rendering/GL/myGL.h" #include "Rendering/GL/VertexArray.h" @@ -37,8 +37,6 @@ void DebugDrawerAI::Draw() { - if (GML::SimEnabled()) - return; if (!draw || !gu->spectating) { return; } @@ -213,7 +211,7 @@ // recalculate the graph scales for (lit = lines.begin(); lit != lines.end(); ++lit) { - minScale.x = std::min((lit->second).lineMin.x, minScale.x); + minScale.x = std::min((lit->second).lineMin.x, minScale.x); minScale.y = std::min((lit->second).lineMin.y, minScale.y); maxScale.x = std::max((lit->second).lineMax.x, maxScale.x); maxScale.y = std::max((lit->second).lineMax.y, maxScale.y); @@ -392,8 +390,6 @@ } void DebugDrawerAI::TexSet::UpdateTexture(int texHandle, const float* data, int x, int y, int w, int h) { - if (GML::SimEnabled()) - return; std::map::iterator it = textures.find(texHandle); if (it == textures.end()) { @@ -486,8 +482,6 @@ labelWidth(0.0f), labelHeight(0.0f) { - if (GML::SimEnabled()) - return; const int intFormat = GL_RGBA; // note: data only holds the red component const int extFormat = GL_RED; const int dataType = GL_FLOAT; @@ -503,8 +497,6 @@ } DebugDrawerAI::TexSet::Texture::~Texture() { - if (GML::SimEnabled()) - return; glDeleteTextures(1, &id); } diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/DefaultPathDrawer.cpp spring-98.0~14.04~ppa6/rts/Rendering/DefaultPathDrawer.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/DefaultPathDrawer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/DefaultPathDrawer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -26,10 +26,11 @@ #include "Sim/Path/Default/PathFlowMap.hpp" #undef private -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Rendering/DefaultPathDrawer.h" #include "Rendering/GL/myGL.h" #include "Rendering/GL/glExtra.h" +#include "Rendering/GL/VertexArray.h" #include "System/myMath.h" #include "System/Util.h" @@ -56,7 +57,7 @@ void DefaultPathDrawer::DrawAll() const { // CPathManager is not thread-safe - if (!GML::SimEnabled() && enabled && (gs->cheatEnabled || gu->spectating)) { + if (enabled && (gs->cheatEnabled || gu->spectating)) { glPushAttrib(GL_ENABLE_BIT); Draw(); @@ -71,24 +72,16 @@ void DefaultPathDrawer::DrawInMiniMap() { - const CBaseGroundDrawer* gd = readMap->GetGroundDrawer(); - const auto pe = pm->medResPE; - const MoveDef* md = GetSelectedMoveDef(); + const CPathEstimator* pe = pm->medResPE; - if (md == NULL) - return; - - if (gd->GetDrawMode() < CBaseGroundDrawer::drawPathTrav) - return; - if (gd->GetDrawMode() > CBaseGroundDrawer::drawPathCost) + if (!IsEnabled()) return; glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); - glOrtho(0.0f, 1.0f, 0.0f, 1.0f, 0.0f, -1.0f); - glTranslatef((float)minimap->GetPosX() * globalRendering->pixelX, (float)minimap->GetPosY() * globalRendering->pixelY, 0.0f); - glScalef((float)minimap->GetSizeX() * globalRendering->pixelX, (float)minimap->GetSizeY() * globalRendering->pixelY, 1.0f); + glOrtho(0.0f, 1.0f, 0.0f, 1.0f, 0.0, -1.0); + minimap->ApplyConstraintsMatrix(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); @@ -98,13 +91,12 @@ glDisable(GL_TEXTURE_2D); glColor4f(1.0f, 1.0f, 0.0f, 0.7f); - for (const CPathEstimator::SingleBlock& sb: pe->updatedBlocks) { - if (sb.moveDef == md) { - const int blockIdxX = sb.blockPos.x * pe->GetBlockSize(); - const int blockIdxY = sb.blockPos.y * pe->GetBlockSize(); - glRectf(blockIdxX, blockIdxY, blockIdxX + pe->GetBlockSize(), blockIdxY + pe->GetBlockSize()); - } + for (const int2& sb: pe->updatedBlocks) { + const int blockIdxX = sb.x * pe->GetBlockSize(); + const int blockIdxY = sb.y * pe->GetBlockSize(); + glRectf(blockIdxX, blockIdxY, blockIdxX + pe->GetBlockSize(), blockIdxY + pe->GetBlockSize()); } + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glEnable(GL_TEXTURE_2D); @@ -146,8 +138,6 @@ CFeature* f = NULL; - GML_RECMUTEX_LOCK(quad); // UpdateExtraTexture - testunitbuildsquare accesses features in the quadfield - if (CGameHelper::TestUnitBuildSquare(bi, f, gu->myAllyTeam, false)) { if (f != NULL) { status = OBJECTBLOCKED; @@ -247,12 +237,12 @@ } break; case CBaseGroundDrawer::drawPathCost: { - const PathNodeStateBuffer& maxResStates = pm->maxResPF->squareStates; + const PathNodeStateBuffer& maxResStates = pm->maxResPF->blockStates; const PathNodeStateBuffer& medResStates = pm->medResPE->blockStates; const PathNodeStateBuffer& lowResStates = pm->lowResPE->blockStates; - const unsigned int medResBlockSize = pm->medResPE->BLOCK_SIZE, medResBlocksX = pm->medResPE->nbrOfBlocksX; - const unsigned int lowResBlockSize = pm->lowResPE->BLOCK_SIZE, lowResBlocksX = pm->lowResPE->nbrOfBlocksX; + const unsigned int medResBlockSize = pm->medResPE->BLOCK_SIZE, medResBlocksX = pm->medResPE->GetNumBlocks().x; + const unsigned int lowResBlockSize = pm->lowResPE->BLOCK_SIZE, lowResBlocksX = pm->lowResPE->GetNumBlocks().x; const float gCostMax[3] = { std::max(1.0f, maxResStates.GetMaxCost(NODE_COST_G)), @@ -344,58 +334,49 @@ void DefaultPathDrawer::Draw(const CPathFinderDef* pfd) const { - glColor4f(0.0f, 1.0f, 1.0f, 1.0f); + if (pfd->synced) { + glColor4f(1.0f, 1.0f, 0.0f, 1.0f); + } else { + glColor4f(0.0f, 1.0f, 1.0f, 1.0f); + } glSurfaceCircle(pfd->goal, math::sqrt(pfd->sqGoalRadius), 20); } void DefaultPathDrawer::Draw(const CPathFinder* pf) const { glColor3f(0.7f, 0.2f, 0.2f); glDisable(GL_TEXTURE_2D); - glBegin(GL_LINES); + CVertexArray* va = GetVertexArray(); + va->Initialize(); - for (unsigned int idx = 0; idx < pf->openSquareBuffer.GetSize(); idx++) { - const PathNode* os = pf->openSquareBuffer.GetNode(idx); + for (unsigned int idx = 0; idx < pf->openBlockBuffer.GetSize(); idx++) { + const PathNode* os = pf->openBlockBuffer.GetNode(idx); const int2 sqr = os->nodePos; const int square = os->nodeNum; - - if (pf->squareStates.nodeMask[square] & PATHOPT_START) - continue; - float3 p1; p1.x = sqr.x * SQUARE_SIZE; p1.z = sqr.y * SQUARE_SIZE; - p1.y = ground->GetHeightAboveWater(p1.x, p1.z, false) + 15.0f; + p1.y = CGround::GetHeightAboveWater(p1.x, p1.z, false) + 15.0f; + + const unsigned int dir = pf->blockStates.nodeMask[square] & PATHOPT_CARDINALS; + const int2 obp = sqr - (CPathFinder::GetDirectionVectorsTable2D())[dir]; float3 p2; + p2.x = obp.x * SQUARE_SIZE; + p2.z = obp.y * SQUARE_SIZE; + p2.y = CGround::GetHeightAboveWater(p2.x, p2.z, false) + 15.0f; if (!camera->InView(p1) && !camera->InView(p2)) continue; - const unsigned int dir = pf->squareStates.nodeMask[square] & PATHOPT_AXIS_DIRS; - const unsigned int obx = sqr.x - pf->directionVectors2D[dir].x; - const unsigned int obz = sqr.y - pf->directionVectors2D[dir].y; - /* - const unsigned int obsquare = obz * gs->mapx + obx; - - // is always greater 0? - if (obsquare >= 0) { - */ - p2.x = obx * SQUARE_SIZE; - p2.z = obz * SQUARE_SIZE; - p2.y = ground->GetHeightAboveWater(p2.x, p2.z, false) + 15.0f; - - glVertexf3(p1); - glVertexf3(p2); - //} + va->AddVertex0(p1); + va->AddVertex0(p2); } - glEnd(); + va->DrawArray0(GL_LINES); } void DefaultPathDrawer::Draw(const CPathEstimator* pe) const { - GML_RECMUTEX_LOCK(sel); // Draw - const MoveDef* md = GetSelectedMoveDef(); const PathNodeStateBuffer& blockStates = pe->blockStates; @@ -407,12 +388,12 @@ #if (PE_EXTRA_DEBUG_OVERLAYS == 1) const int overlayPeriod = GAME_SPEED * 5; - const int overlayNumber = (gs->frameNum % (overlayPeriod * 3)) / overlayPeriod; + const int overlayNumber = (gs->frameNum % (overlayPeriod * 2)) / overlayPeriod; const bool extraOverlay = (overlayNumber == 0 && pe == pm->medResPE) || (overlayNumber == 1 && pe == pm->lowResPE); - const int peNumBlocks = pe->nbrOfBlocksX * pe->nbrOfBlocksZ; - const float peBlueValue = (pe == pm->lowResPE)? 1.0f: 0.0f; + const int peNumBlocks = pe->GetNumBlocks().x * pe->GetNumBlocks().y; + const float peBlueValue = (pe == pm->lowResPE)? 0.75f: 0.0f; // alternate between the extra debug-overlays // (normally TMI, but useful to keep the code @@ -420,14 +401,14 @@ if (extraOverlay) { glBegin(GL_LINES); - for (int z = 0; z < pe->nbrOfBlocksZ; z++) { - for (int x = 0; x < pe->nbrOfBlocksX; x++) { - const int blockNr = z * pe->nbrOfBlocksX + x; + for (int z = 0; z < pe->GetNumBlocks().y; z++) { + for (int x = 0; x < pe->GetNumBlocks().x; x++) { + const int blockNr = pe->BlockPosToIdx(int2(x,z)); float3 p1; - p1.x = (blockStates.peNodeOffsets[blockNr][md->pathType].x) * SQUARE_SIZE; - p1.z = (blockStates.peNodeOffsets[blockNr][md->pathType].y) * SQUARE_SIZE; - p1.y = ground->GetHeightAboveWater(p1.x, p1.z, false) + 10.0f; + p1.x = (blockStates.peNodeOffsets[md->pathType][blockNr].x) * SQUARE_SIZE; + p1.z = (blockStates.peNodeOffsets[md->pathType][blockNr].y) * SQUARE_SIZE; + p1.y = CGround::GetHeightAboveWater(p1.x, p1.z, false) + 10.0f; if (!camera->InView(p1)) continue; @@ -437,24 +418,24 @@ glVertexf3(p1 - UpVector * 10.0f); for (int dir = 0; dir < PATH_DIRECTION_VERTICES; dir++) { - const int obx = x + pe->directionVectors[dir].x; - const int obz = z + pe->directionVectors[dir].y; + const int obx = x + (CPathEstimator::GetDirectionVectorsTable())[dir].x; + const int obz = z + (CPathEstimator::GetDirectionVectorsTable())[dir].y; if (obx < 0) continue; if (obz < 0) continue; - if (obx >= pe->nbrOfBlocksX) continue; - if (obz >= pe->nbrOfBlocksZ) continue; + if (obx >= pe->GetNumBlocks().x) continue; + if (obz >= pe->GetNumBlocks().y) continue; - const int obBlockNr = obz * pe->nbrOfBlocksX + obx; + const int obBlockNr = obz * pe->GetNumBlocks().x + obx; const int vertexNr = md->pathType * peNumBlocks * PATH_DIRECTION_VERTICES + - blockNr * PATH_DIRECTION_VERTICES + GetBlockVertexOffset(dir, pe->nbrOfBlocksX); + blockNr * PATH_DIRECTION_VERTICES + GetBlockVertexOffset(dir, pe->GetNumBlocks().x); const float cost = pe->vertexCosts[vertexNr] / pe->BLOCK_SIZE; float3 p2; - p2.x = (blockStates.peNodeOffsets[obBlockNr][md->pathType].x) * SQUARE_SIZE; - p2.z = (blockStates.peNodeOffsets[obBlockNr][md->pathType].y) * SQUARE_SIZE; - p2.y = ground->GetHeightAboveWater(p2.x, p2.z, false) + 10.0f; + p2.x = (blockStates.peNodeOffsets[md->pathType][obBlockNr].x) * SQUARE_SIZE; + p2.z = (blockStates.peNodeOffsets[md->pathType][obBlockNr].y) * SQUARE_SIZE; + p2.y = CGround::GetHeightAboveWater(p2.x, p2.z, false) + 10.0f; glColor3f(1.0f / math::sqrtf(cost), 1.0f / cost, peBlueValue); glVertexf3(p1); @@ -465,37 +446,37 @@ glEnd(); - for (int z = 0; z < pe->nbrOfBlocksZ; z++) { - for (int x = 0; x < pe->nbrOfBlocksX; x++) { - const int blockNr = z * pe->nbrOfBlocksX + x; + for (int z = 0; z < pe->GetNumBlocks().y; z++) { + for (int x = 0; x < pe->GetNumBlocks().x; x++) { + const int blockNr = z * pe->GetNumBlocks().x + x; float3 p1; - p1.x = (blockStates.peNodeOffsets[blockNr][md->pathType].x) * SQUARE_SIZE; - p1.z = (blockStates.peNodeOffsets[blockNr][md->pathType].y) * SQUARE_SIZE; - p1.y = ground->GetHeightAboveWater(p1.x, p1.z, false) + 10.0f; + p1.x = (blockStates.peNodeOffsets[md->pathType][blockNr].x) * SQUARE_SIZE; + p1.z = (blockStates.peNodeOffsets[md->pathType][blockNr].y) * SQUARE_SIZE; + p1.y = CGround::GetHeightAboveWater(p1.x, p1.z, false) + 10.0f; if (!camera->InView(p1)) continue; for (int dir = 0; dir < PATH_DIRECTION_VERTICES; dir++) { - const int obx = x + pe->directionVectors[dir].x; - const int obz = z + pe->directionVectors[dir].y; + const int obx = x + (CPathEstimator::GetDirectionVectorsTable())[dir].x; + const int obz = z + (CPathEstimator::GetDirectionVectorsTable())[dir].y; if (obx < 0) continue; if (obz < 0) continue; - if (obx >= pe->nbrOfBlocksX) continue; - if (obz >= pe->nbrOfBlocksZ) continue; + if (obx >= pe->GetNumBlocks().x) continue; + if (obz >= pe->GetNumBlocks().y) continue; - const int obBlockNr = obz * pe->nbrOfBlocksX + obx; + const int obBlockNr = obz * pe->GetNumBlocks().x + obx; const int vertexNr = md->pathType * peNumBlocks * PATH_DIRECTION_VERTICES + - blockNr * PATH_DIRECTION_VERTICES + GetBlockVertexOffset(dir, pe->nbrOfBlocksX); + blockNr * PATH_DIRECTION_VERTICES + GetBlockVertexOffset(dir, pe->GetNumBlocks().x); const float cost = pe->vertexCosts[vertexNr] / pe->BLOCK_SIZE; float3 p2; - p2.x = (blockStates.peNodeOffsets[obBlockNr][md->pathType].x) * SQUARE_SIZE; - p2.z = (blockStates.peNodeOffsets[obBlockNr][md->pathType].y) * SQUARE_SIZE; - p2.y = ground->GetHeightAboveWater(p2.x, p2.z, false) + 10.0f; + p2.x = (blockStates.peNodeOffsets[md->pathType][obBlockNr].x) * SQUARE_SIZE; + p2.z = (blockStates.peNodeOffsets[md->pathType][obBlockNr].y) * SQUARE_SIZE; + p2.y = CGround::GetHeightAboveWater(p2.x, p2.z, false) + 10.0f; p2 = (p1 + p2) / 2.0f; @@ -514,40 +495,43 @@ if (pe == pm->medResPE) { - glColor3f(0.2f, 0.7f, 0.2f); + glColor3f(0.7f, 0.2f, 0.7f); } else { - glColor3f(0.2f, 0.2f, 0.7f); + glColor3f(0.2f, 0.7f, 0.7f); } { - glBegin(GL_LINES); + CVertexArray* va = GetVertexArray(); + va->Initialize(); + for (unsigned int idx = 0; idx < pe->openBlockBuffer.GetSize(); idx++) { const PathNode* ob = pe->openBlockBuffer.GetNode(idx); const int blockNr = ob->nodeNum; - const int obx = blockStates.peParentNodePos[ob->nodeNum].x; - const int obz = blockStates.peParentNodePos[ob->nodeNum].y; - const int obBlockNr = obz * pe->nbrOfBlocksX + obx; + auto pathOptDir = blockStates.nodeMask[blockNr] & PATHOPT_CARDINALS; + auto pathDir = PathOpt2PathDir(pathOptDir); + const int2 obp = pe->BlockIdxToPos(blockNr) - pe->PE_DIRECTION_VECTORS[pathDir]; + const int obBlockNr = pe->BlockPosToIdx(obp); if (obBlockNr < 0) continue; float3 p1; - p1.x = (blockStates.peNodeOffsets[blockNr][md->pathType].x) * SQUARE_SIZE; - p1.z = (blockStates.peNodeOffsets[blockNr][md->pathType].y) * SQUARE_SIZE; - p1.y = ground->GetHeightAboveWater(p1.x, p1.z, false) + 15.0f; + p1.x = (blockStates.peNodeOffsets[md->pathType][blockNr].x) * SQUARE_SIZE; + p1.z = (blockStates.peNodeOffsets[md->pathType][blockNr].y) * SQUARE_SIZE; + p1.y = CGround::GetHeightAboveWater(p1.x, p1.z, false) + 15.0f; float3 p2; - p2.x = (blockStates.peNodeOffsets[obBlockNr][md->pathType].x) * SQUARE_SIZE; - p2.z = (blockStates.peNodeOffsets[obBlockNr][md->pathType].y) * SQUARE_SIZE; - p2.y = ground->GetHeightAboveWater(p2.x, p2.z, false) + 15.0f; + p2.x = (blockStates.peNodeOffsets[md->pathType][obBlockNr].x) * SQUARE_SIZE; + p2.z = (blockStates.peNodeOffsets[md->pathType][obBlockNr].y) * SQUARE_SIZE; + p2.y = CGround::GetHeightAboveWater(p2.x, p2.z, false) + 15.0f; if (!camera->InView(p1) && !camera->InView(p2)) continue; - glVertexf3(p1); - glVertexf3(p2); + va->AddVertex0(p1); + va->AddVertex0(p2); } - glEnd(); + va->DrawArray0(GL_LINES); } #if (PE_EXTRA_DEBUG_OVERLAYS == 1) @@ -560,9 +544,9 @@ const int blockNr = ob->nodeNum; float3 p1; - p1.x = (blockStates.peNodeOffsets[blockNr][md->pathType].x) * SQUARE_SIZE; - p1.z = (blockStates.peNodeOffsets[blockNr][md->pathType].y) * SQUARE_SIZE; - p1.y = ground->GetHeightAboveWater(p1.x, p1.z, false) + 35.0f; + p1.x = (blockStates.peNodeOffsets[md->pathType][blockNr].x) * SQUARE_SIZE; + p1.z = (blockStates.peNodeOffsets[md->pathType][blockNr].y) * SQUARE_SIZE; + p1.y = CGround::GetHeightAboveWater(p1.x, p1.z, false) + 35.0f; if (!camera->InView(p1)) continue; diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Env/AdvSky.cpp spring-98.0~14.04~ppa6/rts/Rendering/Env/AdvSky.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Env/AdvSky.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Env/AdvSky.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -803,11 +803,6 @@ glColor4f(c,c,c,ifade); va->DrawArrayT(GL_QUADS); } -/* unsigned char buf[256*256*4]; - glReadPixels(0,0,256,256,GL_RGBA,GL_UNSIGNED_BYTE,buf); - CBitmap bm(buf,256,256); - bm.Save("dc.bmp"); -*/ glViewport(globalRendering->viewPosX,0,globalRendering->viewSizeX,globalRendering->viewSizeY); fbo.Unbind(); diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Env/AdvTreeDrawer.cpp spring-98.0~14.04~ppa6/rts/Rendering/Env/AdvTreeDrawer.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Env/AdvTreeDrawer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Env/AdvTreeDrawer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,7 +2,6 @@ #include "AdvTreeDrawer.h" #include "AdvTreeGenerator.h" -#include "GrassDrawer.h" #include "Game/Camera.h" #include "Game/GlobalUnsynced.h" #include "Map/BaseGroundDrawer.h" @@ -51,7 +50,6 @@ treeGen = new CAdvTreeGenerator(); treeGen->CreateFarTex(treeShaders[TREE_PROGRAM_NEAR_BASIC]); - grassDrawer = new CGrassDrawer(); oldTreeDistance = 4; lastListClean = 0; @@ -82,7 +80,6 @@ delete[] trees; delete treeGen; - delete grassDrawer; shaderHandler->ReleaseProgramObjects("[TreeDrawer]"); treeShaders.clear(); @@ -216,8 +213,6 @@ void CAdvTreeDrawer::Update() { - GML_STDMUTEX_LOCK(tree); // Update - for (std::list::iterator fti = fallingTrees.begin(); fti != fallingTrees.end(); ) { fti->fallPos += (fti->speed * 0.1f); @@ -491,9 +486,6 @@ CAdvTreeSquareDrawer drawer(this, cx, cy, treeDistance * SQUARE_SIZE * TREE_SQUARE_SIZE, drawDetailed); - GML_RECMUTEX_LOCK(feat); // Draw - GML_STDMUTEX_LOCK(tree); // Draw - oldTreeDistance = treeDistance; // draw far-trees using map-dependent grid-visibility (FIXME: ignores LOS) @@ -904,9 +896,6 @@ Shader::IProgramObject* po = NULL; - GML_RECMUTEX_LOCK(feat); // DrawShadowPass - GML_STDMUTEX_LOCK(tree); // DrawShadowPass - // draw with extraSize=1 readMap->GridVisibility(camera, TREE_SQUARE_SIZE, drawer.treeDistance * 2.0f, &drawer, 1); @@ -1041,6 +1030,7 @@ po = shadowHandler->GetShadowGenProg(CShadowHandler::SHADOWGEN_PROGRAM_TREE_FAR); po->Enable(); + // draw far-distance trees glBindTexture(GL_TEXTURE_2D, activeFarTex); va->DrawArrayT(GL_QUADS); @@ -1074,19 +1064,7 @@ glDisable(GL_ALPHA_TEST); } -void CAdvTreeDrawer::DrawGrass() -{ - if (drawTrees) { - grassDrawer->Draw(); - } -} -void CAdvTreeDrawer::DrawShadowGrass() -{ - if (drawTrees) { - grassDrawer->DrawShadow(); - } -} void CAdvTreeDrawer::ResetPos(const float3& pos) { const int x = (int) pos.x / TREE_SQUARE_SIZE / SQUARE_SIZE; @@ -1101,13 +1079,10 @@ delDispLists.push_back(pTSS->farDispList); pTSS->farDispList = 0; } - grassDrawer->ResetPos(pos); } void CAdvTreeDrawer::AddTree(int treeID, int treeType, const float3& pos, float size) { - GML_STDMUTEX_LOCK(tree); // AddTree - TreeStruct ts; ts.id = treeID; ts.type = treeType; @@ -1124,8 +1099,6 @@ void CAdvTreeDrawer::DeleteTree(int treeID, const float3& pos) { - GML_STDMUTEX_LOCK(tree); // DeleteTree - const int treeSquareSize = SQUARE_SIZE * TREE_SQUARE_SIZE; const int treeSquareIdx = ((int)pos.x / (treeSquareSize)) + @@ -1138,8 +1111,6 @@ void CAdvTreeDrawer::AddFallingTree(int treeID, int treeType, const float3& pos, const float3& dir) { - GML_STDMUTEX_LOCK(tree); // AddFallingTree - float3 dirPlane(dir.x, 0.0f, dir.z); const float len = dirPlane.Length(); if (len > 500) { @@ -1158,18 +1129,3 @@ fallingTrees.push_back(ft); } -void CAdvTreeDrawer::AddGrass(const float3& pos) -{ - GML_STDMUTEX_LOCK(tree); // AddGrass - - grassDrawer->AddGrass(pos); -} - -void CAdvTreeDrawer::RemoveGrass(int x, int z) -{ - GML_STDMUTEX_LOCK(tree); // RemoveGrass - - grassDrawer->RemoveGrass(x, z); -} - - diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Env/AdvTreeDrawer.h spring-98.0~14.04~ppa6/rts/Rendering/Env/AdvTreeDrawer.h --- spring-96.0~14.04~ppa4/rts/Rendering/Env/AdvTreeDrawer.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Env/AdvTreeDrawer.h 2014-10-07 20:09:51.000000000 +0000 @@ -3,12 +3,10 @@ #ifndef _ADV_TREE_DRAWER_H_ #define _ADV_TREE_DRAWER_H_ -#include #include #include "ITreeDrawer.h" class CVertexArray; -class CGrassDrawer; namespace Shader { struct IProgramObject; @@ -27,10 +25,6 @@ void AddTree(int treeID, int treeType, const float3& pos, float size); void DeleteTree(int treeID, const float3& pos); void AddFallingTree(int treeID, int treeType, const float3& pos, const float3& dir); - void DrawGrass(); - void DrawShadowGrass(); - void AddGrass(const float3& pos); - void RemoveGrass(int x, int z); void DrawShadowPass(); static void DrawTreeVertexA(CVertexArray* va, float3& ftpos, float dx, float dy); @@ -73,8 +67,6 @@ std::vector treeShaders; std::list fallingTrees; - - CGrassDrawer* grassDrawer; }; #endif // _ADV_TREE_DRAWER_H_ diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Env/AdvWater.cpp spring-98.0~14.04~ppa6/rts/Rendering/Env/AdvWater.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Env/AdvWater.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Env/AdvWater.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -203,7 +203,7 @@ xbase += dh; } - va->EndStripQ(); + va->EndStrip(); base += dv; screenY -= yInc; } @@ -276,6 +276,7 @@ va->DrawArrayT(GL_QUADS); + va = GetVertexArray(); va->Initialize(); glBindTexture(GL_TEXTURE_2D, rawBumpTexture[1]); @@ -286,6 +287,7 @@ va->DrawArrayT(GL_QUADS); + va = GetVertexArray(); va->Initialize(); glBindTexture(GL_TEXTURE_2D, rawBumpTexture[2]); diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Env/BasicTreeDrawer.cpp spring-98.0~14.04~ppa6/rts/Rendering/Env/BasicTreeDrawer.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Env/BasicTreeDrawer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Env/BasicTreeDrawer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -367,9 +367,6 @@ CBasicTreeSquareDrawer drawer(this, cx, cy, treeDistance * SQUARE_SIZE * TREE_SQUARE_SIZE); - GML_RECMUTEX_LOCK(feat); // Draw - GML_STDMUTEX_LOCK(tree); // Draw - readMap->GridVisibility (camera, TREE_SQUARE_SIZE, drawer.treeDistance * 2.0f, &drawer); const int startClean = lastListClean * 20 % nTrees; @@ -419,8 +416,6 @@ void CBasicTreeDrawer::Update() { - GML_STDMUTEX_LOCK(tree); // Update - } void CBasicTreeDrawer::ResetPos(const float3& pos) @@ -440,8 +435,6 @@ void CBasicTreeDrawer::AddTree(int treeID, int treeType, const float3& pos, float size) { - GML_STDMUTEX_LOCK(tree); // AddTree - TreeStruct ts; ts.id = treeID; @@ -459,8 +452,6 @@ void CBasicTreeDrawer::DeleteTree(int treeID, const float3& pos) { - GML_STDMUTEX_LOCK(tree); // DeleteTree - const int treeSquareSize = SQUARE_SIZE * TREE_SQUARE_SIZE; const int treeSquareIdx = (((int)pos.x) / (treeSquareSize)) + diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Env/BasicTreeDrawer.h spring-98.0~14.04~ppa6/rts/Rendering/Env/BasicTreeDrawer.h --- spring-96.0~14.04~ppa4/rts/Rendering/Env/BasicTreeDrawer.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Env/BasicTreeDrawer.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,8 +7,6 @@ #include "ITreeDrawer.h" #include "Rendering/GL/myGL.h" -class CVertexArray; - // XXX This has a duplicate in AdvTreeGenerator.h #define MAX_TREE_HEIGHT 60 diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Env/BasicWater.cpp spring-98.0~14.04~ppa6/rts/Rendering/Env/BasicWater.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Env/BasicWater.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Env/BasicWater.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -21,12 +21,7 @@ LOG_L(L_WARNING, "[%s] could not read water texture from file \"%s\"", __FUNCTION__, mapInfo->water.texture.c_str()); // fallback - waterTexBM.channels = 4; - waterTexBM.Alloc(1, 1); - waterTexBM.mem[0] = 0; - waterTexBM.mem[1] = 0; - waterTexBM.mem[2] = 255; - waterTexBM.mem[3] = 255; + waterTexBM.AllocDummy(SColor(0,0,255,255)); } // create mipmapped texture diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Env/BumpWater.cpp spring-98.0~14.04~ppa6/rts/Rendering/Env/BumpWater.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Env/BumpWater.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Env/BumpWater.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -127,30 +127,24 @@ } -static void DrawRadialDisc() +static void DrawRadialDisc(CVertexArray* va) { //! SAME ALGORITHM AS FOR WATER-PLANE IN BFGroundDrawer.cpp! const float xsize = (gs->mapx * SQUARE_SIZE) >> 2; const float ysize = (gs->mapy * SQUARE_SIZE) >> 2; - CVertexArray* va = GetVertexArray(); - va->Initialize(); - float3 p; const float alphainc = fastmath::PI2 / 32; const float size = std::min(xsize, ysize); - float alpha, r1, r2; - for (int n = 0; n < 4 ; ++n) { - r1 = n*n * size; + const float r1 = n*n * size; + float r2 = (n + 1) * (n + 1) * size; if (n == 3) { r2 = (n + 0.5) * (n + 0.5) * size; - } else { - r2 = (n + 1) * (n + 1) * size; } - for (alpha = 0.0f; (alpha - fastmath::PI2) < alphainc; alpha += alphainc) { + for (float alpha = 0.0f; (alpha - fastmath::PI2) < alphainc; alpha += alphainc) { p.x = r1 * fastmath::sin(alpha) + 2 * xsize; p.z = r1 * fastmath::cos(alpha) + 2 * ysize; va->AddVertex0(p); @@ -170,6 +164,20 @@ CBumpWater::CBumpWater() : CEventClient("[CBumpWater]", 271923, false) + , target(GL_TEXTURE_2D) + , screenTextureX(globalRendering->viewSizeX) + , screenTextureY(globalRendering->viewSizeY) + , displayList(0) + , refractTexture(0) + , reflectTexture(0) + , depthTexture(0) + , waveRandTexture(0) + , foamTexture(0) + , normalTexture(0) + , normalTexture2(0) + , coastTexture(0) + , coastUpdateTexture(0) + , wasVisibleLastFrame(false) { eventHandler.AddClient(this); @@ -189,9 +197,6 @@ dynWaves = (configHandler->GetBool("BumpWaterDynamicWaves")) && (mapInfo->water.numTiles > 1); useUniforms = (configHandler->GetBool("BumpWaterUseUniforms")); - refractTexture = 0; - reflectTexture = 0; - // CHECK HARDWARE if (!globalRendering->haveGLSL) { throw content_error("[" LOG_SECTION_BUMP_WATER "] your hardware/driver setup does not support GLSL"); @@ -303,16 +308,11 @@ // CREATE TEXTURES if ((refraction > 0) || depthCopy) { //! ATIs do not have GLSL support for texrects - screenTextureX = globalRendering->viewSizeX; - screenTextureY = globalRendering->viewSizeY; if (GLEW_ARB_texture_rectangle && !globalRendering->atiHacks) { target = GL_TEXTURE_RECTANGLE_ARB; - } else { - target = GL_TEXTURE_2D; - if (!globalRendering->supportNPOTs) { - screenTextureX = next_power_of_2(globalRendering->viewSizeX); - screenTextureY = next_power_of_2(globalRendering->viewSizeY); - } + } else if (!globalRendering->supportNPOTs) { + screenTextureX = next_power_of_2(screenTextureX); + screenTextureY = next_power_of_2(screenTextureY); } } @@ -354,12 +354,8 @@ glBindTexture(target, depthTexture); glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - GLuint depthFormat = GL_DEPTH_COMPONENT; - switch (globalRendering->depthBufferBits) { // use same depth as screen framebuffer - case 16: depthFormat = GL_DEPTH_COMPONENT16; break; - case 24: if (!globalRendering->atiHacks) { depthFormat = GL_DEPTH_COMPONENT24; break; } // ATIs fall through and use 32bit! - default: depthFormat = GL_DEPTH_COMPONENT32; break; - } + GLuint depthFormat = GL_DEPTH_COMPONENT32; + if (!globalRendering->atiHacks) { depthFormat = GL_DEPTH_COMPONENT24; } glTexImage2D(target, 0, depthFormat, screenTextureX, screenTextureY, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL); } @@ -396,18 +392,18 @@ reflectFBO.Bind(); reflectFBO.CreateRenderBuffer(GL_DEPTH_ATTACHMENT_EXT, depthRBOFormat, reflTexSize, reflTexSize); reflectFBO.AttachTexture(reflectTexture); - } - if (!reflectFBO.CheckStatus("BUMPWATER(reflection)")) { - reflection = 0; + if (!reflectFBO.CheckStatus("BUMPWATER(reflection)")) { + reflection = 0; + } } if (refraction>0) { refractFBO.Bind(); refractFBO.CreateRenderBuffer(GL_DEPTH_ATTACHMENT_EXT, depthRBOFormat, screenTextureX, screenTextureY); refractFBO.AttachTexture(refractTexture,target); - } - if (!refractFBO.CheckStatus("BUMPWATER(refraction)")) { - refraction = 0; + if (!refractFBO.CheckStatus("BUMPWATER(refraction)")) { + refraction = 0; + } } if (dynWaves) { @@ -541,19 +537,19 @@ // CREATE DISPLAYLIST displayList = glGenLists(1); + CVertexArray* va = GetVertexArray(); + va->Initialize(); + va->CheckInitSize(4 * 33 * 2); // endless glNewList(displayList, GL_COMPILE); if (endlessOcean) { - DrawRadialDisc(); + DrawRadialDisc(va); } else { const int mapX = gs->mapx * SQUARE_SIZE; const int mapZ = gs->mapy * SQUARE_SIZE; - CVertexArray* va = GetVertexArray(); - va->Initialize(); for (int z = 0; z < 9; z++) { for (int x = 0; x < 10; x++) { - for (int zs = 0; zs <= 1; zs++) { - va->AddVertex0(float3(x*(mapX/9.0f), 0.0f, (z + zs)*(mapZ/9.0f))); - } + va->AddVertex0(float3(x*(mapX/9.0f), 0.0f, (z + 0)*(mapZ/9.0f))); + va->AddVertex0(float3(x*(mapX/9.0f), 0.0f, (z + 1)*(mapZ/9.0f))); } va->EndStrip(); } diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Env/CubeMapHandler.cpp spring-98.0~14.04~ppa6/rts/Rendering/Env/CubeMapHandler.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Env/CubeMapHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Env/CubeMapHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -197,7 +197,7 @@ camera->forward = camDir; camera->SetFov(90.0f); - camera->SetPos((camera->GetPos()) * XZVector + UpVector * (ground->GetHeightAboveWater(camera->GetPos().x, camera->GetPos().z, false) + 50.0f)); + camera->SetPos((camera->GetPos()) * XZVector + UpVector * (CGround::GetHeightAboveWater(camera->GetPos().x, camera->GetPos().z, false) + 50.0f)); // calculate temporary new coor-system and matrices camera->Update(true); diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Env/Decals/DecalsDrawerGL4.cpp spring-98.0~14.04~ppa6/rts/Rendering/Env/Decals/DecalsDrawerGL4.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Env/Decals/DecalsDrawerGL4.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Env/Decals/DecalsDrawerGL4.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -432,8 +432,8 @@ vboVertices.Bind(GL_ARRAY_BUFFER); vboIndices.Bind(GL_ELEMENT_ARRAY_BUFFER); - vboVertices.Resize(sizeof(boxverts) * sizeof(float3), GL_STATIC_DRAW, &boxverts[0]); - vboIndices.Resize(sizeof(indices) * sizeof(GLubyte), GL_STATIC_DRAW, &indices[0]); + vboVertices.New(sizeof(boxverts) * sizeof(float3), GL_STATIC_DRAW, &boxverts[0]); + vboIndices.New(sizeof(indices) * sizeof(GLubyte), GL_STATIC_DRAW, &indices[0]); vboVertices.Unbind(); vboIndices.Unbind(); @@ -444,6 +444,7 @@ { { GLuint uniformBlockIndex = glGetUniformBlockIndex(decalShader->GetObjID(), "SGroundLighting"); + assert(uniformBlockIndex != GL_INVALID_INDEX); GLsizei uniformBlockSize = 0; glGetActiveUniformBlockiv(decalShader->GetObjID(), uniformBlockIndex, GL_UNIFORM_BLOCK_DATA_SIZE, &uniformBlockSize); @@ -458,7 +459,7 @@ uboGroundLighting.Bind(GL_UNIFORM_BUFFER); - uboGroundLighting.Resize(uniformBlockSize, GL_STATIC_DRAW); + uboGroundLighting.New(uniformBlockSize, GL_STATIC_DRAW); SGLSLGroundLighting* uboGroundLightingData = (SGLSLGroundLighting*)uboGroundLighting.MapBuffer(0, sizeof(SGLSLGroundLighting)); uboGroundLightingData->ambientColor = mapInfo->light.groundAmbientColor * CGlobalRendering::SMF_INTENSITY_MULT; uboGroundLightingData->diffuseColor = mapInfo->light.groundSunColor * CGlobalRendering::SMF_INTENSITY_MULT; @@ -476,7 +477,8 @@ { uboDecalsStructures.Bind(GL_UNIFORM_BUFFER); - GLuint uniformBlockIndex = glGetUniformBlockIndex(decalShader->GetObjID(), "decals"); + // Uniform Array Solution + /*GLuint uniformBlockIndex = glGetUniformBlockIndex(decalShader->GetObjID(), "decals"); GLsizei uniformBlockSize = 0; glGetActiveUniformBlockiv(decalShader->GetObjID(), uniformBlockIndex, GL_UNIFORM_BLOCK_DATA_SIZE, &uniformBlockSize); @@ -487,16 +489,20 @@ maxDecals = uniformBlockSize / sizeof(SGLSLDecal); + uniformBlockSize = maxDecals * sizeof(SGLSLDecal); + uboDecalsStructures.New(uniformBlockSize, GL_DYNAMIC_DRAW); + + glUniformBlockBinding(decalShader->GetObjID(), uniformBlockIndex, 3); + glBindBufferBase(GL_UNIFORM_BUFFER, 3, uboDecalsStructures.GetId());*/ + + // TBO solution GLint maxTexBufSize; glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, &maxTexBufSize); maxDecals = (maxTexBufSize / sizeof(SGLSLDecal)) / 2; - uniformBlockSize = maxDecals * sizeof(SGLSLDecal); - uboDecalsStructures.Resize(uniformBlockSize, GL_DYNAMIC_DRAW); - - glUniformBlockBinding(decalShader->GetObjID(), uniformBlockIndex, 3); - glBindBufferBase(GL_UNIFORM_BUFFER, 3, uboDecalsStructures.GetId()); + GLsizei uniformBlockSize = maxDecals * sizeof(SGLSLDecal); + uboDecalsStructures.New(uniformBlockSize, GL_DYNAMIC_DRAW); uboDecalsStructures.Unbind(); } @@ -506,7 +512,7 @@ /*{ vboVisibilityFeeback.Bind(GL_UNIFORM_BUFFER); - vboVisibilityFeeback.Resize(maxDecals, GL_STATIC_DRAW); + vboVisibilityFeeback.New(maxDecals, GL_STATIC_DRAW); vboVisibilityFeeback.Unbind(); }*/ } @@ -708,7 +714,7 @@ // return; //FIXME decalLevel is private! const float lifeTime = decalLevel * damage * 3.0f; - const float altitude = pos.y - ground->GetHeightReal(pos.x, pos.z, false); + const float altitude = pos.y - CGround::GetHeightReal(pos.x, pos.z, false); // no decals for below-ground & in-air explosions if (abs(altitude) > radius) { return; } @@ -737,8 +743,6 @@ SNPRINTF(buf, sizeof(buf), "%i", r); s->texOffsets = atlasTexs[std::string(buf)]; - GML_STDMUTEX_LOCK(decal); - if (decals.size() < maxDecals) { //FIXME use mt-safe container decals.push_back(s); @@ -756,8 +760,6 @@ if (!unit->unitDef->decalDef.useGroundDecal) return; - GML_STDMUTEX_LOCK(decal); - const int sizex = unit->unitDef->decalDef.groundDecalSizeX; const int sizey = unit->unitDef->decalDef.groundDecalSizeY; @@ -785,8 +787,6 @@ if (!unit->unitDef->decalDef.useGroundDecal) return; - GML_STDMUTEX_LOCK(decal); - //TODO FINISH //decal->owner = NULL; //decal->gbOwner = gb; diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Env/Decals/DecalsDrawerGL4.h spring-98.0~14.04~ppa6/rts/Rendering/Env/Decals/DecalsDrawerGL4.h --- spring-96.0~14.04~ppa4/rts/Rendering/Env/Decals/DecalsDrawerGL4.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Env/Decals/DecalsDrawerGL4.h 2014-10-07 20:09:51.000000000 +0000 @@ -18,6 +18,7 @@ #if !defined(GL_VERSION_4_0) || HEADLESS class CDecalsDrawerGL4: public IGroundDecalDrawer { + public: CDecalsDrawerGL4(); virtual ~CDecalsDrawerGL4() {} diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Env/Decals/GroundDecalHandler.cpp spring-98.0~14.04~ppa6/rts/Rendering/Env/Decals/GroundDecalHandler.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Env/Decals/GroundDecalHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Env/Decals/GroundDecalHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -221,7 +221,7 @@ const int gsmx1 = gsmx + 1; const int gsmy = gs->mapy; - unsigned char color[4] = {255, 255, 255, (unsigned char)(decal->alpha * 255)}; + SColor color(255, 255, 255, int(decal->alpha * 255)); #ifndef DEBUG #define HEIGHT(z, x) (hm[((z) * gsmx1) + (x)]) @@ -297,19 +297,17 @@ } } } else { - const float c = *((float*) (color)); - const int start = 0; - const int stride = 6; - const int sdi = decal->va->drawIndex(); - - for (int i = start; i < sdi; i += stride) { - const int x = int(decal->va->drawArray[i + 0]) >> 3; - const int z = int(decal->va->drawArray[i + 2]) >> 3; - const float h = hm[z * gsmx1 + x]; + const int num = decal->va->drawIndex() / VA_SIZE_TC; + decal->va->ResetPos(); + VA_TYPE_TC* mem = decal->va->GetTypedVertexArray(num); + + for (int i = 0; i < num; ++i) { + const int x = int(mem[i].p.x) >> 3; + const int z = int(mem[i].p.z) >> 3; // update the height and alpha - decal->va->drawArray[i + 1] = h; - decal->va->drawArray[i + 5] = c; + mem[i].p.y = hm[z * gsmx1 + x]; + mem[i].c = color; } decal->va->DrawArrayTC(GL_QUADS); @@ -325,12 +323,7 @@ if (!camera->InView(scar->pos, scar->radius + 16)) return; - const float* hm = readMap->GetCornerHeightMapUnsynced(); - - const int gsmx = gs->mapx; - const int gsmx1 = gsmx + 1; - - unsigned char color[4] = {255, 255, 255, 255}; + SColor color(255, 255, 255, 255); if (scar->va == NULL) { scar->va = new CVertexArray(); @@ -350,7 +343,6 @@ // create the scar texture-quads float px1 = sx * 16; for (int x = sx; x <= ex; ++x) { - //const float* hm2 = hm; float px2 = px1 + 16; float pz1 = sz * 16; @@ -360,20 +352,18 @@ float tx2 = max(0.0f, (pos.x - px2) / radius4 + 0.25f); float tz1 = min(0.5f, (pos.z - pz1) / radius4 + 0.25f); float tz2 = max(0.0f, (pos.z - pz2) / radius4 + 0.25f); - float h1 = ground->GetHeightReal(px1, pz1, false); - float h2 = ground->GetHeightReal(px2, pz1, false); - float h3 = ground->GetHeightReal(px2, pz2, false); - float h4 = ground->GetHeightReal(px1, pz2, false); + float h1 = CGround::GetHeightReal(px1, pz1, false); + float h2 = CGround::GetHeightReal(px2, pz1, false); + float h3 = CGround::GetHeightReal(px2, pz2, false); + float h4 = CGround::GetHeightReal(px1, pz2, false); scar->va->AddVertexTC(float3(px1, h1, pz1), tx1 + tx, tz1 + ty, color); scar->va->AddVertexTC(float3(px2, h2, pz1), tx2 + tx, tz1 + ty, color); scar->va->AddVertexTC(float3(px2, h3, pz2), tx2 + tx, tz2 + ty, color); scar->va->AddVertexTC(float3(px1, h4, pz2), tx1 + tx, tz2 + ty, color); - //hm2 += gsmx12; pz1 = pz2; } - //hm2 += 2; px1 = px2; } } else { @@ -384,17 +374,20 @@ color[3] = (int) (scar->startAlpha - (gs->frameNum - scar->creationTime) * scar->alphaFalloff); } - const int start = 0; - const int stride = 6; - const int sdi = scar->va->drawIndex(); - - for (int i = start; i < sdi; i += stride) { - const int x = int(scar->va->drawArray[i + 0]) >> 3; - const int z = int(scar->va->drawArray[i + 2]) >> 3; + const int gsmx1 = gs->mapx + 1; + const float* hm = readMap->GetCornerHeightMapUnsynced(); + + const int num = scar->va->drawIndex() / VA_SIZE_TC; + scar->va->ResetPos(); + VA_TYPE_TC* mem = scar->va->GetTypedVertexArray(num); + + for (int i = 0; i < num; ++i) { + const int x = int(mem[i].p.x) >> 3; + const int z = int(mem[i].p.z) >> 3; // update the height and alpha - scar->va->drawArray[i + 1] = hm[z * gsmx1 + x]; - scar->va->drawArray[i + 5] = *reinterpret_cast(color); + mem[i].p.y = hm[z * gsmx1 + x]; + mem[i].c = color; } } @@ -491,7 +484,6 @@ glBindTexture(GL_TEXTURE_2D, decalType->texture); { - GML_STDMUTEX_LOCK(decal); // Draw GatherDecalsForType(decalType); } @@ -507,8 +499,6 @@ void CGroundDecalHandler::AddTracks() { { - GML_STDMUTEX_LOCK(track); // AddTracks - // Delayed addition of new tracks for (std::vector::iterator ti = tracksToBeAdded.begin(); ti != tracksToBeAdded.end(); ++ti) { const TrackToAdd* tta = &(*ti); @@ -626,9 +616,8 @@ } } -void CGroundDecalHandler::CleanTracks() { - GML_STDMUTEX_LOCK(track); // CleanTracks - +void CGroundDecalHandler::CleanTracks() +{ // Cleanup old tracks for (std::vector::iterator ti = tracksToBeCleaned.begin(); ti != tracksToBeCleaned.end(); ++ti) { TrackToClean* ttc = &(*ti); @@ -656,12 +645,11 @@ -void CGroundDecalHandler::AddScars() { +void CGroundDecalHandler::AddScars() +{ scarsToBeChecked.clear(); { - GML_STDMUTEX_LOCK(scar); // AddScars - for (std::vector::iterator si = scarsToBeAdded.begin(); si != scarsToBeAdded.end(); ++si) scarsToBeChecked.push_back(*si); @@ -891,16 +879,14 @@ TrackPart* tp = new TrackPart(); tp->pos1 = pos + unit->rightdir * decalDef.trackDecalWidth * 0.5f; tp->pos2 = pos - unit->rightdir * decalDef.trackDecalWidth * 0.5f; - tp->pos1.y = ground->GetHeightReal(tp->pos1.x, tp->pos1.z, false); - tp->pos2.y = ground->GetHeightReal(tp->pos2.x, tp->pos2.z, false); + tp->pos1.y = CGround::GetHeightReal(tp->pos1.x, tp->pos1.z, false); + tp->pos2.y = CGround::GetHeightReal(tp->pos2.x, tp->pos2.z, false); tp->creationTime = gs->frameNum; TrackToAdd tta; tta.tp = tp; tta.unit = unit; - GML_STDMUTEX_LOCK(track); // AddDecalAndTrack - if (unit->myTrack == NULL) { unit->myTrack = new UnitTrackStruct(unit); unit->myTrack->lifeTime = trackLifeTime; @@ -946,8 +932,6 @@ tt->name = lowerName; tt->texture = LoadTexture(lowerName); -// GML_STDMUTEX_LOCK(tracktype); // GetTrackType - trackTypes.push_back(tt); return (trackTypes.size() - 1); @@ -993,7 +977,7 @@ if (decalLevel == 0 || !addScar) return; - const float altitude = pos.y - ground->GetHeightReal(pos.x, pos.z, false); + const float altitude = pos.y - CGround::GetHeightReal(pos.x, pos.z, false); // no decals for below-ground explosions if (altitude <= -1.0f) @@ -1036,8 +1020,6 @@ s->overdrawn = 0; s->lastTest = 0; - GML_STDMUTEX_LOCK(scar); // AddExplosion - scarsToBeAdded.push_back(s); } @@ -1175,8 +1157,6 @@ return; } - GML_STDMUTEX_LOCK(decal); // AddSolidObject - SolidObjectGroundDecal* olddecal = object->groundDecal; if (olddecal != NULL) { olddecal->owner = NULL; @@ -1218,8 +1198,6 @@ if (decalLevel == 0) return; - GML_STDMUTEX_LOCK(decal); // RemoveSolidObject - assert(object); SolidObjectGroundDecal* decal = object->groundDecal; @@ -1243,8 +1221,6 @@ if (decalLevel == 0) return; - GML_STDMUTEX_LOCK(decal); // ForcedRemoveSolidObject - SolidObjectGroundDecal* decal = object->groundDecal; if (decal == NULL) @@ -1266,8 +1242,6 @@ int decalType = 0; - GML_STDMUTEX_LOCK(decal); // GetSolidObjectDecalType - std::vector::iterator bi; for (bi = objectDecalTypes.begin(); bi != objectDecalTypes.end(); ++bi) { if ((*bi)->name == lowerName) { @@ -1322,8 +1296,6 @@ if (decalLevel == 0) return; - GML_STDMUTEX_LOCK(track); // RemoveUnit - CUnit* u = const_cast(unit); RemoveSolidObject(u, NULL); diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Env/DynWater.cpp spring-98.0~14.04~ppa6/rts/Rendering/Env/DynWater.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Env/DynWater.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Env/DynWater.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -908,7 +908,7 @@ const int yhlod = y + hlod; const int nloop = (xe - xs) / lod + 1; - va->EnlargeArrays(nloop*13, 4*nloop + 1); + va->EnlargeArrays(nloop*13); for (int x = xs; x < xe; x += lod) { const int xlod = x + lod; const int xhlod = x + hlod; @@ -924,49 +924,49 @@ } else { // inre begr?sning mot f?eg?nde lod FIXME if (x >= (cx + vrhlod)) { if (inStrip) { - va->EndStripQ(); + va->EndStrip(); inStrip = false; } DrawVertexAQ(x,y); DrawVertexAQ(x,yhlod); DrawVertexAQ(xhlod,y); DrawVertexAQ(xhlod,yhlod); - va->EndStripQ(); + va->EndStrip(); DrawVertexAQ(x,yhlod); DrawVertexAQ(x,ylod); DrawVertexAQ(xhlod,yhlod); DrawVertexAQ(xhlod,ylod); - va->EndStripQ(); + va->EndStrip(); DrawVertexAQ(xhlod,ylod); DrawVertexAQ(xlod,ylod); DrawVertexAQ(xhlod,yhlod); DrawVertexAQ(xlod,y); DrawVertexAQ(xhlod,y); - va->EndStripQ(); + va->EndStrip(); } else if (x <= (cx - vrhlod)) { if (inStrip) { - va->EndStripQ(); + va->EndStrip(); inStrip = false; } DrawVertexAQ(xlod, yhlod); DrawVertexAQ(xlod, y); DrawVertexAQ(xhlod, yhlod); DrawVertexAQ(xhlod, y); - va->EndStripQ(); + va->EndStrip(); DrawVertexAQ(xlod, ylod); DrawVertexAQ(xlod, yhlod); DrawVertexAQ(xhlod, ylod); DrawVertexAQ(xhlod, yhlod); - va->EndStripQ(); + va->EndStrip(); DrawVertexAQ(xhlod, y); DrawVertexAQ(x, y); DrawVertexAQ(xhlod, yhlod); DrawVertexAQ(x, ylod); DrawVertexAQ(xhlod, ylod); - va->EndStripQ(); + va->EndStrip(); } else if (y >= (cy + vrhlod)) { if (inStrip) { - va->EndStripQ(); + va->EndStrip(); inStrip = false; } DrawVertexAQ(x, y); @@ -975,16 +975,16 @@ DrawVertexAQ(xhlod, yhlod); DrawVertexAQ(xlod, y); DrawVertexAQ(xlod, yhlod); - va->EndStripQ(); + va->EndStrip(); DrawVertexAQ(x, yhlod); DrawVertexAQ(x, ylod); DrawVertexAQ(xhlod, yhlod); DrawVertexAQ(xlod, ylod); DrawVertexAQ(xlod, yhlod); - va->EndStripQ(); + va->EndStrip(); } else if (y <= (cy - vrhlod)) { if (inStrip) { - va->EndStripQ(); + va->EndStrip(); inStrip = false; } DrawVertexAQ(x, yhlod); @@ -993,18 +993,18 @@ DrawVertexAQ(xhlod, ylod); DrawVertexAQ(xlod, yhlod); DrawVertexAQ(xlod, ylod); - va->EndStripQ(); + va->EndStrip(); DrawVertexAQ(xlod, yhlod); DrawVertexAQ(xlod, y); DrawVertexAQ(xhlod, yhlod); DrawVertexAQ(x, y); DrawVertexAQ(x, yhlod); - va->EndStripQ(); + va->EndStrip(); } } } if (inStrip) { - va->EndStripQ(); + va->EndStrip(); inStrip = false; } } @@ -1112,8 +1112,6 @@ va2->Initialize(); { - GML_RECMUTEX_LOCK(unit); // AddShipWakes - const std::set& units = unitDrawer->GetUnsortedUnits(); const int nadd = units.size() * 4; @@ -1203,8 +1201,6 @@ void CDynWater::AddExplosions() { - GML_STDMUTEX_LOCK(water); // AddExplosions - if (explosions.empty()) { return; } @@ -1294,8 +1290,6 @@ return; } - GML_STDMUTEX_LOCK(water); // AddExplosion - explosions.push_back(Explosion(pos, std::min(size*20, strength), size)); } @@ -1352,7 +1346,7 @@ CVertexArray* va = GetVertexArray(); va->Initialize(); - va->EnlargeArrays(3*3*16*16*4, 0); + va->EnlargeArrays(3*3*16*16*4); float posx = camPosBig2.x - WH_SIZE - WF_SIZE; float posy = camPosBig2.z - WH_SIZE - WF_SIZE; diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Env/GrassDrawer.cpp spring-98.0~14.04~ppa6/rts/Rendering/Env/GrassDrawer.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Env/GrassDrawer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Env/GrassDrawer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -11,6 +11,7 @@ #include "Rendering/GlobalRendering.h" #include "Rendering/ShadowHandler.h" #include "Rendering/Env/ISky.h" +#include "Rendering/Env/CubeMapHandler.h" #include "Rendering/GL/myGL.h" #include "Rendering/GL/FBO.h" #include "Rendering/GL/VertexArray.h" @@ -18,17 +19,22 @@ #include "Rendering/Shaders/Shader.h" #include "Rendering/Textures/Bitmap.h" #include "Sim/Misc/Wind.h" +#include "System/EventHandler.h" #include "System/myMath.h" #include "System/Config/ConfigHandler.h" +#include "System/Color.h" #include "System/Exceptions.h" #include "System/UnsyncedRNG.h" #include "System/Util.h" +#include "System/ThreadPool.h" +#include "System/TimeProfiler.h" +#include "System/Log/ILog.h" #include "System/FileSystem/FileHandler.h" CONFIG(int, GrassDetail).defaultValue(7).minimumValue(0).description("Sets how detailed the engine rendered grass will be on any given map."); static const float turfSize = 20.0f; // single turf size -static const float partTurfSize = turfSize * 0.6f; // single turf size +static const float partTurfSize = turfSize * 1.0f; // single turf size static const int grassSquareSize = 4; // mapsquares per grass square static const int grassBlockSize = 4; // grass squares per grass block static const int blockMapSize = grassSquareSize * grassBlockSize; @@ -39,70 +45,62 @@ static UnsyncedRNG rng; +CGrassDrawer* grassDrawer = nullptr; + + CGrassDrawer::CGrassDrawer() +: CEventClient("[GrassDrawer]", 199992, false) +, grassOff(false) +, blocksX(gs->mapx / grassSquareSize / grassBlockSize) +, blocksY(gs->mapy / grassSquareSize / grassBlockSize) +, grassDL(0) +, grassBladeTex(0) +, farTex(0) +, farnearVA(nullptr) +, updateBillboards(false) +, grassMap(nullptr) { + rng.Seed(15); const int detail = configHandler->GetInt("GrassDetail"); // some ATI drivers crash with grass enabled, default to disabled if ((detail == 0) || ((detail == 7) && globalRendering->haveATI)) { grassOff = true; return; - } else { - grassOff = false; } - MapBitmapInfo grassbm; - unsigned char* grassdata = readMap->GetInfoMap("grass", &grassbm); + // needed to create the far tex + if (!GLEW_EXT_framebuffer_blit) { + grassOff = true; + return; + } + + // load grass density from map + { + MapBitmapInfo grassbm; + unsigned char* grassdata = readMap->GetInfoMap("grass", &grassbm); + if (!grassdata) { + grassOff = true; + return; + } - if (grassdata) { if (grassbm.width != gs->mapx / grassSquareSize || grassbm.height != gs->mapy / grassSquareSize) { char b[128]; SNPRINTF(b, sizeof(b), "grass-map has wrong size (%dx%d, should be %dx%d)\n", grassbm.width, grassbm.height, gs->mapx / 4, gs->mapy / 4); throw std::runtime_error(b); } - const int grassMapSize = gs->mapx * gs->mapy / (grassSquareSize * grassSquareSize); grassMap = new unsigned char[grassMapSize]; - memcpy(grassMap, grassdata, grassMapSize); readMap->FreeInfoMap("grass", grassdata); - } else { - grassOff = true; - return; - } - - // TODO: get rid of the magic constants - maxGrassDist = 800 + std::sqrt((float) detail) * 240; - maxDetailedDist = 146 + detail * 24; - detailedBlocks = int((maxDetailedDist - 24) / bMSsq) + 1; - const float detail_lim = std::min(3, detail); - numTurfs = 3 + int(detail_lim * 0.5f); - strawPerTurf = 50 + int(std::sqrt(detail_lim) * 10); - - blocksX = gs->mapx / grassSquareSize / grassBlockSize; - blocksY = gs->mapy / grassSquareSize / grassBlockSize; - - for (int y = 0; y < 32; y++) { - for (int x = 0; x < 32; x++) { - grass[y * 32 + x].va = 0; - grass[y * 32 + x].lastSeen = 0; - grass[y * 32 + x].pos = ZeroVector; - grass[y * 32 + x].square = 0; - - nearGrass[y * 32 + x].square = -1; - } } - lastListClean = 0; - grassDL = glGenLists(1); - rng.Seed(15); - CreateGrassDispList(grassDL); - + // create/load blade texture { CBitmap grassBladeTexBM; - if (!grassBladeTexBM.Load(mapInfo->grass.grassBladeTexName)) { - //! map didn't define a grasstex, so generate one + if (!grassBladeTexBM.Load(mapInfo->grass.bladeTexName)) { + // map didn't define a grasstex, so generate one grassBladeTexBM.channels = 4; grassBladeTexBM.Alloc(256,64); @@ -110,557 +108,420 @@ CreateGrassBladeTex(&grassBladeTexBM.mem[a * 16 * 4]); } } - - glGenTextures(1, &grassBladeTex); - glBindTexture(GL_TEXTURE_2D, grassBladeTex); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); - glBuildMipmaps(GL_TEXTURE_2D, GL_RGBA8, grassBladeTexBM.xsize, grassBladeTexBM.ysize, GL_RGBA, GL_UNSIGNED_BYTE, &grassBladeTexBM.mem[0]); + //grassBladeTexBM.Save("blade.png", false); + grassBladeTex = grassBladeTexBM.CreateTexture(true); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } - CreateFarTex(); + // create shaders * finalize + grass.resize(blocksX * blocksY); + farnearVA = new CVertexArray; + grassDL = glGenLists(1); + + ChangeDetail(detail); LoadGrassShaders(); + configHandler->NotifyOnChange(this); + + // eventclient + autoLinkEvents = true; + RegisterLinkedEvents(this); + eventHandler.AddClient(this); } CGrassDrawer::~CGrassDrawer() { - if (grassOff) - return; - - for (int y = 0; y < 32; y++) { - for (int x = 0; x < 32; x++) { - if (grass[y * 32 + x].va) - delete grass[y * 32 + x].va; - } - } + configHandler->RemoveObserver(this); + delete farnearVA; delete[] grassMap; - glDeleteLists(grassDL, 1); glDeleteTextures(1, &grassBladeTex); glDeleteTextures(1, &farTex); - shaderHandler->ReleaseProgramObjects("[GrassDrawer]"); - grassShaders.clear(); } +CGrassDrawer::GrassStruct::~GrassStruct() { + delete va; +} + + +void CGrassDrawer::ChangeDetail(int detail) { + // TODO: get rid of the magic constants + const int detail_lim = std::min(3, detail); + maxGrassDist = 800 + std::sqrt((float) detail) * 240; + maxDetailedDist = 146 + detail * 24; + detailedBlocks = int((maxDetailedDist + 128.f * 1.5f) / bMSsq) + 1; + numTurfs = 3 + int(detail_lim * 0.5f); + strawPerTurf = std::min(50 + int(std::sqrt(detail_lim) * 10), mapInfo->grass.maxStrawsPerTurf); + + // recreate textures & XBOs + CreateGrassDispList(grassDL); + CreateFarTex(); + + // reset all cached blocks + for (GrassStruct& pGS: grass) { + ResetPos(pGS.posX, pGS.posZ); + } +} + + +void CGrassDrawer::ConfigNotify(const std::string& key, const std::string& value) { + if (key == "GrassDetail") { + ChangeDetail(std::atoi(value.c_str())); + } +} + void CGrassDrawer::LoadGrassShaders() { + if (!globalRendering->haveGLSL) { + return; + } + #define sh shaderHandler grassShaders.resize(GRASS_PROGRAM_LAST, NULL); static const std::string shaderNames[GRASS_PROGRAM_LAST] = { "grassNearAdvShader", "grassDistAdvShader", - "grassDistDefShader", - // "grassShadGenShader" + "grassShadGenShader" }; static const std::string shaderDefines[GRASS_PROGRAM_LAST] = { - "#define DISTANCE_NEAR\n#define HAVE_SHADOW\n", - "#define DISTANCE_FAR\n#define HAVE_SHADOW\n", + "#define DISTANCE_NEAR\n", "#define DISTANCE_FAR\n", - // "#define GRASS_SHADOW_GEN\n" - }; - - static const int NUM_UNIFORMS = 11; - static const std::string uniformNames[NUM_UNIFORMS] = { - "mapSizePO2", - "mapSize", - "texOffset", - "billboardDirX", - "billboardDirY", - "billboardDirZ", - "shadowMatrix", - "shadowParams", - "simFrame", - "windSpeed", - "camPos" + "#define SHADOW_GEN\n" }; - const std::string extraDefs = - (mapInfo->grass.bladeWaveScale > 0.0f)? - "#define ANIMATION\n": - ""; - - if (globalRendering->haveGLSL) { - for (int i = GRASS_PROGRAM_NEAR_SHADOW; i < GRASS_PROGRAM_LAST; i++) { - grassShaders[i] = sh->CreateProgramObject("[GrassDrawer]", shaderNames[i] + "GLSL", false); - grassShaders[i]->AttachShaderObject(sh->CreateShaderObject("GLSL/GrassVertProg.glsl", shaderDefines[i] + extraDefs, GL_VERTEX_SHADER)); - grassShaders[i]->AttachShaderObject(sh->CreateShaderObject("GLSL/GrassFragProg.glsl", shaderDefines[i] + extraDefs, GL_FRAGMENT_SHADER)); + for (int i = 0; i < GRASS_PROGRAM_LAST; i++) { + grassShaders[i] = sh->CreateProgramObject("[GrassDrawer]", shaderNames[i] + "GLSL", false); + grassShaders[i]->AttachShaderObject(sh->CreateShaderObject("GLSL/GrassVertProg.glsl", shaderDefines[i], GL_VERTEX_SHADER)); + grassShaders[i]->AttachShaderObject(sh->CreateShaderObject("GLSL/GrassFragProg.glsl", shaderDefines[i], GL_FRAGMENT_SHADER)); + grassShaders[i]->Link(); + + grassShaders[i]->Enable(); + grassShaders[i]->SetUniform("mapSizePO2", 1.0f / (gs->pwr2mapx * SQUARE_SIZE), 1.0f / (gs->pwr2mapy * SQUARE_SIZE)); + grassShaders[i]->SetUniform("mapSize", 1.0f / (gs->mapx * SQUARE_SIZE), 1.0f / (gs->mapy * SQUARE_SIZE)); + grassShaders[i]->SetUniform("bladeTex", 0); + grassShaders[i]->SetUniform("grassShadingTex", 1); + grassShaders[i]->SetUniform("shadingTex", 2); + grassShaders[i]->SetUniform("infoMap", 3); + grassShaders[i]->SetUniform("shadowMap", 4); + grassShaders[i]->SetUniform("specularTex", 5); + grassShaders[i]->Disable(); + grassShaders[i]->Validate(); + + if (!grassShaders[i]->IsValid()) { + grassOff = true; + return; } + } - for (int i = GRASS_PROGRAM_NEAR_SHADOW; i < GRASS_PROGRAM_LAST; i++) { - grassShaders[i]->Link(); + #undef sh +} - for (int j = 0; j < NUM_UNIFORMS; j++) { - grassShaders[i]->SetUniformLocation(uniformNames[j]); - } +void CGrassDrawer::EnableShader(const GrassShaderProgram type) { + CBaseGroundDrawer* gd = readMap->GetGroundDrawer(); + const float3 windSpeed = + wind.GetCurrentDirection() * + wind.GetCurrentStrength() * + mapInfo->grass.bladeWaveScale; - grassShaders[i]->SetUniformLocation("shadingTex"); - grassShaders[i]->SetUniformLocation("shadowMap"); - grassShaders[i]->SetUniformLocation("grassShadingTex"); - grassShaders[i]->SetUniformLocation("bladeTex"); - grassShaders[i]->SetUniformLocation("infoMap"); - - grassShaders[i]->Enable(); - grassShaders[i]->SetUniform2f(0, 1.0f / (gs->pwr2mapx * SQUARE_SIZE), 1.0f / (gs->pwr2mapy * SQUARE_SIZE)); - grassShaders[i]->SetUniform2f(1, 1.0f / (gs->mapx * SQUARE_SIZE), 1.0f / (gs->mapy * SQUARE_SIZE)); - grassShaders[i]->SetUniform1i(NUM_UNIFORMS, 0); - grassShaders[i]->SetUniform1i(NUM_UNIFORMS + 1, 1); - grassShaders[i]->SetUniform1i(NUM_UNIFORMS + 2, 2); - grassShaders[i]->SetUniform1i(NUM_UNIFORMS + 3, 3); - grassShaders[i]->SetUniform1i(NUM_UNIFORMS + 4, 4); - grassShaders[i]->Disable(); - grassShaders[i]->Validate(); - } - } + grassShader = grassShaders[type]; + grassShader->SetFlag("HAVE_INFOTEX", gd->DrawExtraTex()); + grassShader->SetFlag("HAVE_SHADOWS", shadowHandler->shadowsLoaded); + grassShader->Enable(); - #undef sh + grassShader->SetUniform("frame", gs->frameNum + globalRendering->timeOffset); + grassShader->SetUniform3v("windSpeed", &windSpeed.x); + grassShader->SetUniform3v("camPos", &camera->GetPos().x); + grassShader->SetUniform3v("camDir", &camera->forward.x); + grassShader->SetUniform3v("camUp", &camera->up.x); + grassShader->SetUniform3v("camRight", &camera->right.x); + + grassShader->SetUniform("groundShadowDensity", mapInfo->light.groundShadowDensity); + grassShader->SetUniformMatrix4x4("shadowMatrix", false, &shadowHandler->shadowMatrix.m[0]); + grassShader->SetUniform4v("shadowParams", &shadowHandler->GetShadowParams().x); + + grassShader->SetUniform3v("ambientLightColor", &mapInfo->light.unitAmbientColor.x); + grassShader->SetUniform3v("diffuseLightColor", &mapInfo->light.unitSunColor.x); + grassShader->SetUniform3v("specularLightColor", &mapInfo->light.unitSpecularColor.x); + grassShader->SetUniform3v("sunDir", &mapInfo->light.sunDir.x); } +static float GetCamDistOfGrassBlock(const int x, const int y, const bool square = false) +{ + float3 quadCenter = float3(x, 0.f, y) * gSSsq; + quadCenter.y = CGround::GetHeightReal(quadCenter.x, quadCenter.z, false); + const float3 dif = camera->GetPos() - quadCenter; + return (square) ? dif.SqLength() : dif.Length(); +} -static const bool GrassSort(const CGrassDrawer::InviewGrass& a, const CGrassDrawer::InviewGrass& b) { return (a.dist > b.dist); } -static const bool GrassSortNear(const CGrassDrawer::InviewNearGrass& a, const CGrassDrawer::InviewNearGrass& b) { return (a.dist > b.dist); } +static const bool GrassSort(const CGrassDrawer::GrassStruct* a, const CGrassDrawer::GrassStruct* b) { + const float distA = GetCamDistOfGrassBlock((a->posX + 0.5f) * grassBlockSize, (a->posZ + 0.5f) * grassBlockSize, true); + const float distB = GetCamDistOfGrassBlock((b->posX + 0.5f) * grassBlockSize, (b->posZ + 0.5f) * grassBlockSize, true); + return (distA > distB); +} +static const bool GrassSortNear(const CGrassDrawer::InviewNearGrass& a, const CGrassDrawer::InviewNearGrass& b) { return (a.dist > b.dist); } +////////////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////////////// +/// CGrassBlockDrawer class CGrassBlockDrawer: public CReadMap::IQuadDrawer { public: - std::vector inviewGrass; + std::vector inviewGrass; std::vector inviewNearGrass; + std::vector inviewFarGrass; int cx, cy; CGrassDrawer* gd; void DrawQuad(int x, int y); + +private: + void DrawDetailQuad(const int x, const int y); + void DrawFarQuad(const int x, const int y); }; -void CGrassBlockDrawer::DrawQuad(int x, int y) -{ - const float maxDetailedDist = gd->maxDetailedDist; +static CGrassBlockDrawer drawer; - CGrassDrawer::NearGrassStruct* nearGrass = gd->nearGrass; - - if (abs(x - cx) <= gd->detailedBlocks && abs(y - cy) <= gd->detailedBlocks) { - //! blocks close to the camera - for (int y2 = y * grassBlockSize; y2 < (y + 1) * grassBlockSize; ++y2) { - for (int x2 = x * grassBlockSize; x2 < (x + 1) * grassBlockSize; ++x2) { - if (gd->grassMap[y2 * gs->mapx / grassSquareSize + x2]) { - float3 squarePos((x2 + 0.5f) * gSSsq, 0.0f, (y2 + 0.5f) * gSSsq); - squarePos.y = ground->GetHeightReal(squarePos.x, squarePos.z, false); - - const float sqdist = (camera->GetPos() - squarePos).SqLength(); - - CGrassDrawer::NearGrassStruct* ng = &nearGrass[(y2 & 31) * 32 + (x2 & 31)]; - - if (sqdist < (maxDetailedDist * maxDetailedDist)) { - //! close grass, draw directly - rng.Seed(y2 * 1025 + x2); - - for (int a = 0; a < gd->numTurfs; a++) { - const float dx = (x2 + rng.RandFloat()) * gSSsq; - const float dy = (y2 + rng.RandFloat()) * gSSsq; - - float3 pos(dx, ground->GetHeightReal(dx, dy, false), dy); - pos.y -= ground->GetSlope(dx, dy, false) * 10.0f + 0.03f; - - if (ng->square != y2 * 2048 + x2) { - const float3 v = squarePos - camera->GetPos(); - ng->rotation = GetHeadingFromVector(v.x, v.z) * 180.0f / 32768 + 180; //FIXME make more random - ng->square = y2 * 2048 + x2; - } - - glPushMatrix(); - glTranslatef3(pos); - glRotatef(ng->rotation, 0.0f, 1.0f, 0.0f); - glCallList(gd->grassDL); - glPopMatrix(); - } - } else { - //! near but not close, save for later drawing - CGrassDrawer::InviewNearGrass iv; - iv.dist = sqdist; - iv.x = x2; - iv.y = y2; - inviewNearGrass.push_back(iv); - ng->square = -1; - } - } - } - } +void CGrassBlockDrawer::DrawQuad(int x, int y) +{ + const float distSq = GetCamDistOfGrassBlock((x + 0.5f) * grassBlockSize, (y + 0.5f) * grassBlockSize, true); + if (distSq > Square(gd->maxGrassDist)) return; - } - - const float3 dif(camera->GetPos().x - ((x + 0.5f) * bMSsq), 0.0f, camera->GetPos().z - ((y + 0.5f) * bMSsq)); - const float dist = dif.SqLength2D(); - - if (dist < Square(gd->maxGrassDist)) { - const int curSquare = y * gd->blocksX + x; - const int curModSquare = (y & 31) * 32 + (x & 31); - - CGrassDrawer::GrassStruct* grass = gd->grass + curModSquare; - grass->lastSeen = gs->frameNum; - - if (grass->square != curSquare) { - grass->square = curSquare; - - delete grass->va; - grass->va = NULL; - } - - if (!grass->va) { - grass->va = new CVertexArray; - grass->pos = float3((x + 0.5f) * bMSsq, ground->GetHeightReal((x + 0.5f) * bMSsq, (y + 0.5f) * bMSsq, false), (y + 0.5f) * bMSsq); - CVertexArray* va = grass->va; - va->Initialize(); - - for (int y2 = y * grassBlockSize; y2 < (y + 1) * grassBlockSize; ++y2) { - for (int x2 = x * grassBlockSize; x2 < (x + 1) * grassBlockSize; ++x2) { - if (gd->grassMap[y2 * gs->mapx / grassSquareSize + x2]) { - rng.Seed(y2 * 1025 + x2); - - for (int a = 0; a < gd->numTurfs; a++) { - const float dx = (x2 + rng.RandFloat()) * gSSsq; - const float dy = (y2 + rng.RandFloat()) * gSSsq; - const float col = 1.0f; - - float3 pos(dx, ground->GetHeightReal(dx, dy, false) + 0.5f, dy); - pos.y -= (ground->GetSlope(dx, dy, false) * 10.0f + 0.03f); - - va->AddVertexTN(pos, 0.0f, 0.0f, float3(-partTurfSize, -partTurfSize, col)); - va->AddVertexTN(pos, 1.0f / 16.0f, 0.0f, float3( partTurfSize, -partTurfSize, col)); - va->AddVertexTN(pos, 1.0f / 16.0f, 1.0f, float3( partTurfSize, partTurfSize, col)); - va->AddVertexTN(pos, 0.0f, 1.0f, float3(-partTurfSize, partTurfSize, col)); - } - } - } - } - } - - CGrassDrawer::InviewGrass ig; - ig.num = curModSquare; - ig.dist = dif.Length2D(); - inviewGrass.push_back(ig); + if (abs(x - cx) <= gd->detailedBlocks && abs(y - cy) <= gd->detailedBlocks) { + return DrawDetailQuad(x, y); } + DrawFarQuad(x, y); } -void CGrassDrawer::SetupGlStateNear() -{ - CBaseGroundDrawer* gd = readMap->GetGroundDrawer(); - - const float3 windSpeed = - wind.GetCurrentDirection() * - wind.GetCurrentStrength() * - mapInfo->grass.bladeWaveScale; - - if (shadowHandler->shadowsLoaded && globalRendering->haveGLSL) { - grassShader = grassShaders[GRASS_PROGRAM_NEAR_SHADOW]; - grassShader->SetFlag("HAVE_INFOTEX", gd->DrawExtraTex()); - grassShader->Enable(); - - grassShader->SetUniform2f(2, 0.0f, 0.0f); - grassShader->SetUniformMatrix4fv(6, false, shadowHandler->shadowMatrix); - grassShader->SetUniform4fv(7, shadowHandler->GetShadowParams()); - grassShader->SetUniform1f(8, gs->frameNum); - grassShader->SetUniform3fv(9, &windSpeed.x); - grassShader->SetUniform3fv(10, &camera->GetPos().x); - - glActiveTextureARB(GL_TEXTURE0_ARB); - glBindTexture(GL_TEXTURE_2D, readMap->GetShadingTexture()); - - glActiveTextureARB(GL_TEXTURE1_ARB); - glBindTexture(GL_TEXTURE_2D, shadowHandler->shadowTexture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); - glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_ALPHA); - static const float texConstant[] = { - mapInfo->light.groundAmbientColor.x * 1.24f, - mapInfo->light.groundAmbientColor.y * 1.24f, - mapInfo->light.groundAmbientColor.z * 1.24f, - 1.0f - }; - glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, texConstant); - - glActiveTextureARB(GL_TEXTURE2_ARB); - glBindTexture(GL_TEXTURE_2D, readMap->GetGrassShadingTexture()); - - glActiveTextureARB(GL_TEXTURE3_ARB); - glBindTexture(GL_TEXTURE_2D, grassBladeTex); - - if (gd->DrawExtraTex()) { - glActiveTextureARB(GL_TEXTURE4_ARB); - glBindTexture(GL_TEXTURE_2D, gd->GetActiveInfoTexture()); - } - glActiveTextureARB(GL_TEXTURE0_ARB); +void CGrassBlockDrawer::DrawDetailQuad(const int x, const int y) +{ + const float maxDetailedDist = gd->maxDetailedDist; - if (!globalRendering->haveGLSL) { - glActiveTextureARB(GL_TEXTURE1_ARB); - glEnable(GL_TEXTURE_2D); - glActiveTextureARB(GL_TEXTURE2_ARB); - glEnable(GL_TEXTURE_2D); - glActiveTextureARB(GL_TEXTURE3_ARB); - glEnable(GL_TEXTURE_2D); - if (gd->DrawExtraTex()) { - glActiveTextureARB(GL_TEXTURE4_ARB); - glEnable(GL_TEXTURE_2D); + // blocks close to the camera + for (int y2 = y * grassBlockSize; y2 < (y + 1) * grassBlockSize; ++y2) { + for (int x2 = x * grassBlockSize; x2 < (x + 1) * grassBlockSize; ++x2) { + if (!gd->grassMap[y2 * gs->mapx / grassSquareSize + x2]) { + continue; } - glActiveTextureARB(GL_TEXTURE0_ARB); - glEnable(GL_TEXTURE_2D); - } - - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glMultMatrixf(camera->GetViewMatrix()); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - } else { - glActiveTextureARB(GL_TEXTURE0_ARB); - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, grassBladeTex); - - glActiveTextureARB(GL_TEXTURE1_ARB); - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, readMap->GetGrassShadingTexture()); - glMultiTexCoord4f(GL_TEXTURE1_ARB, 1.0f,1.0f,1.0f,1.0f); // workaround a nvidia bug with TexGen - SetTexGen(1.0f / (gs->mapx * SQUARE_SIZE), 1.0f / (gs->mapy * SQUARE_SIZE), 0.0f, 0.0f); - glActiveTextureARB(GL_TEXTURE2_ARB); - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, readMap->GetShadingTexture()); - - glMultiTexCoord4f(GL_TEXTURE2_ARB, 1.0f,1.0f,1.0f,1.0f); // workaround a nvidia bug with TexGen - SetTexGen(1.0f / (gs->pwr2mapx * SQUARE_SIZE), 1.0f / (gs->pwr2mapy * SQUARE_SIZE), 0.0f, 0.0f); - - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE); - glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2); - - if (gd->DrawExtraTex()) { - glActiveTextureARB(GL_TEXTURE3_ARB); - glEnable(GL_TEXTURE_2D); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD_SIGNED_ARB); - glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_MODULATE); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS_ARB); - glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB, GL_TEXTURE); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); - - glMultiTexCoord4f(GL_TEXTURE3_ARB, 1.0f,1.0f,1.0f,1.0f); // workaround a nvidia bug with TexGen - SetTexGen(1.0f / (gs->pwr2mapx * SQUARE_SIZE), 1.0f / (gs->pwr2mapy * SQUARE_SIZE), 0.0f, 0.0f); + rng.Seed(y2 * gs->mapx / grassSquareSize + x2); + const float dist = GetCamDistOfGrassBlock(x2, y2, false); + const float rdist = 1.0f + rng.RandFloat() * 0.5f; + + //TODO instead of adding grass turfs depending on their distance to the camera, + // there should be a fixed sized pool for mesh & billboard turfs + // and then we fill these pools with _preference_ for close distance turfs. + // So when a map has only less turfs, render them independent of the cam distance as mesh. + // -> see Ravaged_2 + if (dist < (maxDetailedDist + 128.f * rdist)) { + // close grass (render as mesh) + CGrassDrawer::InviewNearGrass iv; + iv.dist = dist; + iv.x = x2; + iv.y = y2; + inviewGrass.push_back(iv); + } - glBindTexture(GL_TEXTURE_2D, gd->GetActiveInfoTexture()); - glActiveTextureARB(GL_TEXTURE0_ARB); + if (dist > maxDetailedDist) { + // near but not close, save for later drawing + CGrassDrawer::InviewNearGrass iv; + iv.dist = dist; + iv.x = x2; + iv.y = y2; + inviewNearGrass.push_back(iv); + } } - - glActiveTextureARB(GL_TEXTURE0_ARB); } - - glDisable(GL_BLEND); - glDisable(GL_ALPHA_TEST); - glDepthMask(GL_TRUE); - - ISky::SetupFog(); } -void CGrassDrawer::ResetGlStateNear() +void CGrassBlockDrawer::DrawFarQuad(const int x, const int y) { - CBaseGroundDrawer* gd = readMap->GetGroundDrawer(); - - if (shadowHandler->shadowsLoaded && globalRendering->haveGLSL) { - grassShader->Disable(); - - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - - /*glActiveTextureARB(GL_TEXTURE1_ARB); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); - glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_LUMINANCE); - glActiveTextureARB(GL_TEXTURE0_ARB);*/ - } else { - glActiveTextureARB(GL_TEXTURE1_ARB); - glDisable(GL_TEXTURE_2D); - glDisable(GL_TEXTURE_GEN_S); - glDisable(GL_TEXTURE_GEN_T); - - glActiveTextureARB(GL_TEXTURE2_ARB); - glDisable(GL_TEXTURE_2D); - glDisable(GL_TEXTURE_GEN_S); - glDisable(GL_TEXTURE_GEN_T); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1); - - if (gd->DrawExtraTex()) { - glActiveTextureARB(GL_TEXTURE3_ARB); - glDisable(GL_TEXTURE_2D); - glDisable(GL_TEXTURE_GEN_S); - glDisable(GL_TEXTURE_GEN_T); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - } - - glActiveTextureARB(GL_TEXTURE0_ARB); - } - - glDisable(GL_TEXTURE_2D); - glEnable(GL_BLEND); + const int curSquare = y * gd->blocksX + x; + CGrassDrawer::GrassStruct* grass = &gd->grass[curSquare]; + grass->lastSeen = globalRendering->drawFrame; + grass->posX = x; + grass->posZ = y; + inviewFarGrass.push_back(grass); } -void CGrassDrawer::SetupGlStateFar() -{ - assert(globalRendering->haveGLSL); - - CBaseGroundDrawer* gd = readMap->GetGroundDrawer(); - - const float3 windSpeed = - wind.GetCurrentDirection() * - wind.GetCurrentStrength() * - mapInfo->grass.bladeWaveScale; - - glEnable(GL_ALPHA_TEST); - glAlphaFunc(GL_GREATER, 0.01f); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDepthMask(GL_FALSE); - - if (shadowHandler->shadowsLoaded) { - grassShader = grassShaders[GRASS_PROGRAM_DIST_SHADOW]; - grassShader->SetFlag("HAVE_INFOTEX", gd->DrawExtraTex()); - grassShader->Enable(); - - grassShader->SetUniformMatrix4fv(6, false, &shadowHandler->shadowMatrix.m[0]); - grassShader->SetUniform4fv(7, shadowHandler->GetShadowParams()); - grassShader->SetUniform1f(8, gs->frameNum); - grassShader->SetUniform3fv(9, &windSpeed.x); - grassShader->SetUniform3fv(10, &camera->GetPos().x); - - glActiveTextureARB(GL_TEXTURE0_ARB); - glBindTexture(GL_TEXTURE_2D, readMap->GetShadingTexture()); - - glActiveTextureARB(GL_TEXTURE1_ARB); - glBindTexture(GL_TEXTURE_2D, shadowHandler->shadowTexture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); - glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_ALPHA); - static const float texConstant[] = { - mapInfo->light.groundAmbientColor.x * 1.24f, - mapInfo->light.groundAmbientColor.y * 1.24f, - mapInfo->light.groundAmbientColor.z * 1.24f, - 1.0f - }; - glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, texConstant); - - glActiveTextureARB(GL_TEXTURE2_ARB); - glBindTexture(GL_TEXTURE_2D, readMap->GetGrassShadingTexture()); - - glActiveTextureARB(GL_TEXTURE3_ARB); - glBindTexture(GL_TEXTURE_2D, farTex); - - if (gd->DrawExtraTex()) { - glActiveTextureARB(GL_TEXTURE4_ARB); - glBindTexture(GL_TEXTURE_2D, gd->GetActiveInfoTexture()); - } +////////////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////////////// - glActiveTextureARB(GL_TEXTURE0_ARB); - } else { - grassShader = grassShaders[GRASS_PROGRAM_DIST_BASIC]; - grassShader->Enable(); +struct STurfParams { + float x, y, rotation; +}; - grassShader->SetUniform1f(8, gs->frameNum); - grassShader->SetUniform3fv(9, &windSpeed.x); - grassShader->SetUniform3fv(10, &camera->GetPos().x); - glActiveTextureARB(GL_TEXTURE0_ARB); - glBindTexture(GL_TEXTURE_2D, readMap->GetShadingTexture()); +static STurfParams GetTurfParams(UnsyncedRNG& rng, const int x, const int y) +{ + STurfParams result; + result.x = (x + rng.RandFloat()) * gSSsq; + result.y = (y + rng.RandFloat()) * gSSsq; + result.rotation = rng.RandFloat() * 360.f; + return result; +} - //glActiveTextureARB(GL_TEXTURE1_ARB); - glActiveTextureARB(GL_TEXTURE2_ARB); - glBindTexture(GL_TEXTURE_2D, readMap->GetGrassShadingTexture()); - glActiveTextureARB(GL_TEXTURE3_ARB); - glBindTexture(GL_TEXTURE_2D, farTex); - - if (gd->DrawExtraTex()) { - glActiveTextureARB(GL_TEXTURE4_ARB); - glBindTexture(GL_TEXTURE_2D, gd->GetActiveInfoTexture()); - } +void CGrassDrawer::DrawNear(const std::vector& inviewGrass) +{ + for (const InviewNearGrass& g: inviewGrass) { + rng.Seed(g.y * gs->mapx / grassSquareSize + g.x); +// const float distSq = GetCamDistOfGrassBlock(g.x, g.y, true); + const float rdist = 1.0f + rng.RandFloat() * 0.5f; + const float alpha = linearstep(maxDetailedDist, maxDetailedDist + 128.f * rdist, g.dist); - glActiveTextureARB(GL_TEXTURE0_ARB); + for (int a = 0; a < numTurfs; a++) { + const STurfParams& p = GetTurfParams(rng, g.x, g.y); + float3 pos(p.x, CGround::GetHeightReal(p.x, p.y, false), p.y); + pos.y -= CGround::GetSlope(p.x, p.y, false) * 30.0f; + pos.y -= 2.0f * mapInfo->grass.bladeHeight * alpha; + + glPushMatrix(); + glTranslatef3(pos); + glRotatef(p.rotation, 0.0f, 1.0f, 0.0f); + glCallList(grassDL); + glPopMatrix(); + } } } -void CGrassDrawer::ResetGlStateFar() +void CGrassDrawer::DrawBillboard(const int x, const int y, const float dist, VA_TYPE_TN* va_tn) { - grassShader->Disable(); - if (shadowHandler->shadowsLoaded) { - glActiveTextureARB(GL_TEXTURE1_ARB); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); - glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_LUMINANCE); + UnsyncedRNG rng; // need our own, cause this function may run threaded + rng.Seed(y * gs->mapx / grassSquareSize + x); + const float rdist = 1.0f + rng.RandFloat() * 0.5f; + float alpha = 1.0f - linearstep(maxGrassDist, maxGrassDist + 127.f, dist + 128.f); + alpha = std::min(alpha, linearstep(maxDetailedDist, maxDetailedDist + 128.f * rdist, dist)); + + for (int a = 0; a < numTurfs; a++) { + const STurfParams p = GetTurfParams(rng, x, y); + float3 pos(p.x, CGround::GetHeightReal(p.x, p.y, false), p.y); + pos.y -= CGround::GetSlope(p.x, p.y, false) * 30.0f; + + va_tn[a * 4 + 0] = { pos, 0.0f, 1.0f, float3(-partTurfSize, -partTurfSize, alpha) }; + va_tn[a * 4 + 1] = { pos, 1.0f / 16.0f, 1.0f, float3( partTurfSize, -partTurfSize, alpha) }; + va_tn[a * 4 + 2] = { pos, 1.0f / 16.0f, 0.0f, float3( partTurfSize, partTurfSize, alpha) }; + va_tn[a * 4 + 3] = { pos, 0.0f, 0.0f, float3(-partTurfSize, partTurfSize, alpha) }; } - - glDepthMask(GL_TRUE); - glDisable(GL_ALPHA_TEST); - } -void CGrassDrawer::DrawFarBillboards(const std::vector& inviewGrass) +void CGrassDrawer::DrawFarBillboards(const std::vector& inviewFarGrass) { - for (std::vector::const_iterator gi = inviewGrass.begin(); gi != inviewGrass.end(); ++gi) { - if ((*gi).dist + 128 < maxGrassDist) { - glColor4f(0.62f, 0.62f, 0.62f, 1.0f); - } else { - glColor4f(0.62f, 0.62f, 0.62f, 1.0f - ((*gi).dist + 128 - maxGrassDist) / 128.0f); - } + // update far grass blocks + if (updateBillboards) { + updateBillboards = false; + + for_mt(0, inviewFarGrass.size(), [&](const int i){ + GrassStruct& g = *inviewFarGrass[i]; + if (!g.va) { + //TODO vertex arrays need to be send each frame to the gpu, that's slow. switch to VBOs. + CVertexArray* va = new CVertexArray; + g.va = va; + g.lastDist = -1; // force a recreate + } + + const float distSq = GetCamDistOfGrassBlock((g.posX + 0.5f) * grassBlockSize, (g.posZ + 0.5f) * grassBlockSize, true); + if (distSq == g.lastDist) + return; + + bool inAlphaRange1 = ( distSq < Square(maxDetailedDist + 128.f * 1.5f)) || ( distSq > Square(maxGrassDist - 128.f)); + bool inAlphaRange2 = (g.lastDist < Square(maxDetailedDist + 128.f * 1.5f)) || (g.lastDist > Square(maxGrassDist - 128.f)); + if (!inAlphaRange1 && (inAlphaRange1 == inAlphaRange2)) { + return; + } + + g.lastDist = distSq; + CVertexArray* va = g.va; + va->Initialize(); + + for (int y2 = g.posZ * grassBlockSize; y2 < (g.posZ + 1) * grassBlockSize; ++y2) { + for (int x2 = g.posX * grassBlockSize; x2 < (g.posX + 1) * grassBlockSize; ++x2) { + if (!grassMap[y2 * gs->mapx / grassSquareSize + x2]) { + continue; + } + + const float dist = GetCamDistOfGrassBlock(x2, y2); + auto* va_tn = va->GetTypedVertexArray(numTurfs * 4); + DrawBillboard(x2, y2, dist, va_tn); + } + } + }); + } - grass[(*gi).num].va->DrawArrayTN(GL_QUADS); + // render far grass blocks + for (const GrassStruct* g: inviewFarGrass) { + g->va->DrawArrayTN(GL_QUADS); } } void CGrassDrawer::DrawNearBillboards(const std::vector& inviewNearGrass) { - CVertexArray* va = GetVertexArray(); - va->Initialize(); - va->EnlargeArrays(inviewNearGrass.size() * numTurfs * 4, 0, VA_SIZE_TN); + if (farnearVA->drawIndex() == 0) { + auto* va_tn = farnearVA->GetTypedVertexArray(inviewNearGrass.size() * numTurfs * 4); + for_mt(0, inviewNearGrass.size(), [&](const int i){ + const InviewNearGrass& gi = inviewNearGrass[i]; + DrawBillboard(gi.x, gi.y, gi.dist, &va_tn[i * numTurfs * 4]); + }); + } - for (std::vector::const_iterator gi = inviewNearGrass.begin(); gi != inviewNearGrass.end(); ++gi) { - const int x = (*gi).x; - const int y = (*gi).y; + farnearVA->DrawArrayTN(GL_QUADS); +} - rng.Seed(y * 1025 + x); - for (int a = 0; a < numTurfs; a++) { - const float dx = (x + rng.RandFloat()) * gSSsq; - const float dy = (y + rng.RandFloat()) * gSSsq; - const float col = 1.0f; +void CGrassDrawer::Update() +{ + // update visible turfs + if (oldCamPos != camera->GetPos() || oldCamDir != camera->forward) { + SCOPED_TIMER("Grass::Update"); + oldCamPos = camera->GetPos(); + oldCamDir = camera->forward; + lastVisibilityUpdate = globalRendering->drawFrame; - float3 pos(dx, ground->GetHeightReal(dx, dy, false) + 0.5f, dy); - pos.y -= (ground->GetSlope(dx, dy, false) * 10.0f + 0.03f); + drawer.cx = int(camera->GetPos().x / bMSsq); + drawer.cy = int(camera->GetPos().z / bMSsq); + drawer.inviewGrass.clear(); + drawer.inviewFarGrass.clear(); + drawer.inviewNearGrass.clear(); + drawer.gd = this; + readMap->GridVisibility(camera, blockMapSize, maxGrassDist, &drawer); - va->AddVertexQTN(pos, 0.0f, 0.0f, float3(-partTurfSize, -partTurfSize, col)); - va->AddVertexQTN(pos, 1.0f / 16.0f, 0.0f, float3( partTurfSize, -partTurfSize, col)); - va->AddVertexQTN(pos, 1.0f / 16.0f, 1.0f, float3( partTurfSize, partTurfSize, col)); - va->AddVertexQTN(pos, 0.0f, 1.0f, float3(-partTurfSize, partTurfSize, col)); + if ( + globalRendering->haveGLSL + && (!shadowHandler->shadowsLoaded || !globalRendering->atiHacks) // Ati crashes w/o an error when shadows are enabled!? + ) { + std::sort(drawer.inviewFarGrass.begin(), drawer.inviewFarGrass.end(), GrassSort); + std::sort(drawer.inviewNearGrass.begin(), drawer.inviewNearGrass.end(), GrassSortNear); + farnearVA->Initialize(); + updateBillboards = true; } } - va->DrawArrayTN(GL_QUADS); + // collect garbage + for (GrassStruct& pGS: grass) { + if ((pGS.lastSeen != lastVisibilityUpdate) + && (pGS.lastSeen < globalRendering->drawFrame - 50) + && pGS.va + ) { + ResetPos(pGS.posX, pGS.posZ); + } + } } @@ -669,61 +530,40 @@ if (grassOff || !readMap->GetGrassShadingTexture()) return; + SCOPED_TIMER("Grass::Draw"); glPushAttrib(GL_CURRENT_BIT); - glColor4f(0.62f, 0.62f, 0.62f, 1.0f); + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - SetupGlStateNear(); - GML_RECMUTEX_LOCK(grass); // Draw - static CGrassBlockDrawer drawer; - drawer.cx = int(camera->GetPos().x / bMSsq); - drawer.cy = int(camera->GetPos().z / bMSsq); - drawer.inviewGrass.clear(); - drawer.inviewNearGrass.clear(); - drawer.gd = this; - - readMap->GridVisibility(camera, blockMapSize, maxGrassDist, &drawer); - ResetGlStateNear(); + if (!drawer.inviewGrass.empty()) { + SetupGlStateNear(); + DrawNear(drawer.inviewGrass); + ResetGlStateNear(); + } if ( globalRendering->haveGLSL && (!shadowHandler->shadowsLoaded || !globalRendering->atiHacks) // Ati crashes w/o an error when shadows are enabled!? + && !(drawer.inviewFarGrass.empty() && drawer.inviewNearGrass.empty()) ) { SetupGlStateFar(); - std::sort(drawer.inviewGrass.begin(), drawer.inviewGrass.end(), GrassSort); - std::sort(drawer.inviewNearGrass.begin(), drawer.inviewNearGrass.end(), GrassSortNear); - - glColor4f(0.62f, 0.62f, 0.62f, 1.0f); - DrawFarBillboards(drawer.inviewGrass); - - glColor4f(0.62f, 0.62f, 0.62f, 1.0f); + DrawFarBillboards(drawer.inviewFarGrass); DrawNearBillboards(drawer.inviewNearGrass); ResetGlStateFar(); } glPopAttrib(); - GarbageCollect(); } void CGrassDrawer::DrawShadow() { // Grass self-shadowing doesn't look that good atm - /*if (grassOff || !readMap->GetGrassShadingTexture()) +/* if (grassOff || !readMap->GetGrassShadingTexture()) return; - const float3 windSpeed = - wind.GetCurrentDirection() * - wind.GetCurrentStrength() * - mapInfo->grass.bladeWaveScale; - - grassShader = grassShaders[GRASS_PROGRAM_SHADOW_GEN]; - grassShader->Enable(); - grassShader->SetUniform2f(2, 0.0f, 0.0f); - grassShader->SetUniformMatrix4fv(6, false, shadowHandler->shadowMatrix); - grassShader->SetUniform4fv(7, shadowHandler->GetShadowParams()); - grassShader->SetUniform1f(8, gs->frameNum); - grassShader->SetUniform3fv(9, &windSpeed.x); - grassShader->SetUniform3fv(10, &camera->GetPos().x); + // looks ad with low density grass + //TODO either enable it on high density only, or wait for alpha transparent shadows and use those then + EnableShader(GRASS_PROGRAM_SHADOW_GEN); glActiveTexture(GL_TEXTURE0); //glBindTexture(GL_TEXTURE_2D, activeFarTex); @@ -734,73 +574,222 @@ glPolygonOffset(5, 15); glEnable(GL_POLYGON_OFFSET_FILL); - GML_RECMUTEX_LOCK(grass); // Draw + // we pass it as uniform and want to have pos & rot + // of the turfs to be saved alone in the modelview matrix + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + static CGrassBlockDrawer drawer; - drawer.cx = int(camera->GetPos().x / bMSsq); - drawer.cy = int(camera->GetPos().z / bMSsq); - drawer.inviewGrass.clear(); - drawer.inviewNearGrass.clear(); - drawer.gd = this; - readMap->GridVisibility(camera, blockMapSize, maxGrassDist * 10.0f, &drawer); + drawer.cx = int(camera->GetPos().x / bMSsq); + drawer.cy = int(camera->GetPos().z / bMSsq); + drawer.inviewGrass.clear(); + drawer.inviewFarGrass.clear(); + drawer.inviewNearGrass.clear(); + drawer.gd = this; + readMap->GridVisibility(camera, blockMapSize, maxGrassDist, &drawer); + + DrawNear(drawer.inviewGrass); + + //FIXME needs own shader! + //DrawNearBillboards(drawer.inviewNearGrass); + + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); glEnable(GL_CULL_FACE); glDisable(GL_POLYGON_OFFSET_FILL); glDisable(GL_TEXTURE_2D); glDisable(GL_ALPHA_TEST); - grassShader->Disable(); - */ + grassShader->Disable();*/ } -void CGrassDrawer::GarbageCollect() +void CGrassDrawer::SetupGlStateNear() { - const int startClean = (lastListClean * 20) % (32 * 32); - const int endClean = (gs->frameNum * 20) % (32 * 32); + CBaseGroundDrawer* gd = readMap->GetGroundDrawer(); - if (startClean > endClean) { - for (GrassStruct* pGS = grass + startClean; pGS < grass + 32 * 32; ++pGS) { - if ((pGS->lastSeen < gs->frameNum - 50) && pGS->va) { - delete pGS->va; - pGS->va = 0; - } + // bind textures + { + glActiveTextureARB(GL_TEXTURE0_ARB); + glBindTexture(GL_TEXTURE_2D, grassBladeTex); + glActiveTextureARB(GL_TEXTURE1_ARB); + glBindTexture(GL_TEXTURE_2D, readMap->GetGrassShadingTexture()); + glActiveTextureARB(GL_TEXTURE2_ARB); + glBindTexture(GL_TEXTURE_2D, readMap->GetShadingTexture()); + if (gd->DrawExtraTex()) { + glActiveTextureARB(GL_TEXTURE3_ARB); + glBindTexture(GL_TEXTURE_2D, gd->GetActiveInfoTexture()); } - for (GrassStruct* pGS = grass; pGS < grass + endClean; ++pGS) { - if ((pGS->lastSeen < gs->frameNum - 50) && pGS->va) { - delete pGS->va; - pGS->va = 0; - } + glActiveTextureARB(GL_TEXTURE5_ARB); + glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, cubeMapHandler->GetSpecularTextureID()); + } + + // bind shader + if (globalRendering->haveGLSL) { + EnableShader(GRASS_PROGRAM_NEAR); + + if (shadowHandler->shadowsLoaded) { + glActiveTextureARB(GL_TEXTURE4_ARB); + glBindTexture(GL_TEXTURE_2D, shadowHandler->shadowTexture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); + glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_ALPHA); } + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glMultMatrixf(camera->GetViewMatrix()); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); } else { - for (GrassStruct* pGS = grass + startClean; pGS < grass + endClean; ++pGS) { - if ((pGS->lastSeen < gs->frameNum - 50) && pGS->va) { - delete pGS->va; - pGS->va = 0; - } + // FPP enable textures + glActiveTextureARB(GL_TEXTURE0_ARB); + glEnable(GL_TEXTURE_2D); + glActiveTextureARB(GL_TEXTURE1_ARB); + glEnable(GL_TEXTURE_2D); + glMultiTexCoord4f(GL_TEXTURE1_ARB, 1.0f,1.0f,1.0f,1.0f); // workaround a nvidia bug with TexGen + SetTexGen(1.0f / (gs->mapx * SQUARE_SIZE), 1.0f / (gs->mapy * SQUARE_SIZE), 0.0f, 0.0f); + glActiveTextureARB(GL_TEXTURE2_ARB); + glEnable(GL_TEXTURE_2D); + glMultiTexCoord4f(GL_TEXTURE2_ARB, 1.0f,1.0f,1.0f,1.0f); // workaround a nvidia bug with TexGen + SetTexGen(1.0f / (gs->pwr2mapx * SQUARE_SIZE), 1.0f / (gs->pwr2mapy * SQUARE_SIZE), 0.0f, 0.0f); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2); + if (gd->DrawExtraTex()) { + glActiveTextureARB(GL_TEXTURE3_ARB); + glEnable(GL_TEXTURE_2D); + glMultiTexCoord4f(GL_TEXTURE3_ARB, 1.0f,1.0f,1.0f,1.0f); // workaround a nvidia bug with TexGen + SetTexGen(1.0f / (gs->pwr2mapx * SQUARE_SIZE), 1.0f / (gs->pwr2mapy * SQUARE_SIZE), 0.0f, 0.0f); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD_SIGNED_ARB); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_PREVIOUS_ARB); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB, GL_TEXTURE); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); } } - lastListClean = gs->frameNum; + glActiveTextureARB(GL_TEXTURE0_ARB); + glDisable(GL_BLEND); + glDisable(GL_ALPHA_TEST); + glDepthMask(GL_TRUE); + ISky::SetupFog(); } -void CGrassDrawer::ResetPos(const float3& pos) +void CGrassDrawer::ResetGlStateNear() { - if (grassOff) - return; + CBaseGroundDrawer* gd = readMap->GetGroundDrawer(); + + if (globalRendering->haveGLSL) { + grassShader->Disable(); + + if (shadowHandler->shadowsLoaded) { + glActiveTextureARB(GL_TEXTURE1_ARB); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); + glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_LUMINANCE); + glActiveTextureARB(GL_TEXTURE0_ARB); + } + + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + } else { + glActiveTextureARB(GL_TEXTURE1_ARB); + glDisable(GL_TEXTURE_2D); + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + glActiveTextureARB(GL_TEXTURE2_ARB); + glDisable(GL_TEXTURE_2D); + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1); + if (gd->DrawExtraTex()) { + glActiveTextureARB(GL_TEXTURE3_ARB); + glDisable(GL_TEXTURE_2D); + glDisable(GL_TEXTURE_GEN_S); + glDisable(GL_TEXTURE_GEN_T); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + } + glActiveTextureARB(GL_TEXTURE0_ARB); + } + + glDisable(GL_TEXTURE_2D); + glEnable(GL_BLEND); +} + + +void CGrassDrawer::SetupGlStateFar() +{ + assert(globalRendering->haveGLSL); + + CBaseGroundDrawer* gd = readMap->GetGroundDrawer(); + + //glEnable(GL_ALPHA_TEST); + //glAlphaFunc(GL_GREATER, 0.01f); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDepthMask(GL_FALSE); + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glMultMatrixf(camera->GetViewMatrix()); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + + EnableShader(GRASS_PROGRAM_DIST); + + glActiveTextureARB(GL_TEXTURE0_ARB); + glBindTexture(GL_TEXTURE_2D, farTex); + glActiveTextureARB(GL_TEXTURE1_ARB); + glBindTexture(GL_TEXTURE_2D, readMap->GetGrassShadingTexture()); + glActiveTextureARB(GL_TEXTURE2_ARB); + glBindTexture(GL_TEXTURE_2D, readMap->GetShadingTexture()); + if (gd->DrawExtraTex()) { + glActiveTextureARB(GL_TEXTURE3_ARB); + glBindTexture(GL_TEXTURE_2D, gd->GetActiveInfoTexture()); + } + if (shadowHandler->shadowsLoaded) { + glActiveTextureARB(GL_TEXTURE4_ARB); + glBindTexture(GL_TEXTURE_2D, shadowHandler->shadowTexture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); + glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_ALPHA); + } - GML_RECMUTEX_LOCK(grass); // ResetPos + glActiveTextureARB(GL_TEXTURE0_ARB); +} + + +void CGrassDrawer::ResetGlStateFar() +{ + grassShader->Disable(); - const int idx = - (int(pos.z / bMSsq) & 31) * 32 + - (int(pos.x / bMSsq) & 31); + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); - if (grass[idx].va) { - delete grass[idx].va; - grass[idx].va = 0; + if (shadowHandler->shadowsLoaded) { + glActiveTextureARB(GL_TEXTURE1_ARB); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE); + glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_LUMINANCE); + glActiveTextureARB(GL_TEXTURE0_ARB); } - grass[idx].square = -1; + glDepthMask(GL_TRUE); + glDisable(GL_ALPHA_TEST); + } @@ -808,155 +797,197 @@ { CVertexArray* va = GetVertexArray(); va->Initialize(); + rng.Seed(15); for (int a = 0; a < strawPerTurf; ++a) { - const float maxAng = mapInfo->grass.bladeAngle * rng.RandFloat(); - const float length = mapInfo->grass.bladeHeight + mapInfo->grass.bladeHeight * rng.RandFloat(); + // draw a single blade + const float lngRnd = rng.RandFloat(); + const float length = mapInfo->grass.bladeHeight * (1.0f + lngRnd); + const float maxAng = mapInfo->grass.bladeAngle * std::max(rng.RandFloat(), 1.f - smoothstep(0.f,1.f,lngRnd)); float3 sideVect(rng.RandFloat() - 0.5f, 0.0f, rng.RandFloat() - 0.5f); sideVect.ANormalize(); - float3 forwardVect = sideVect.cross(UpVector); - sideVect *= mapInfo->grass.bladeWidth; + float3 bendVect = sideVect.cross(UpVector); // direction to bend into + sideVect *= mapInfo->grass.bladeWidth * (-0.15f * lngRnd + 1.0f); + const float3 basePos = rng.RandVector2D() * (turfSize - (bendVect * std::sin(maxAng) * length).Length2D()); - const float3 cornerPos = (UpVector * std::cos(maxAng) + forwardVect * std::sin(maxAng)) * length; - float3 basePos(30.0f, 0.0f, 30.0f); + // select one of the 16 color shadings + const float xtexCoord = (rng.RandInt() % 16) / 16.0f; + const int numSections = 2 + int(maxAng * 1.2f + length * 0.2f); - while (basePos.SqLength2D() > (turfSize * turfSize / 4)) { - basePos = float3(turfSize * rng.RandFloat() - turfSize * 0.5f, 0.0f, turfSize * rng.RandFloat() - turfSize * 0.5f); - } + float3 normalBend = -bendVect; - const int xtexOffset = int(15.9999f * rng.RandFloat()); - const float xtexBase = xtexOffset * (1.0f / 16.0f); - const int numSections = 1 + int(maxAng * 5.0f); + // start btm + va->AddVertexTN(basePos + sideVect - float3(0.0f, 3.0f, 0.0f), xtexCoord , 0.f, normalBend); + va->AddVertexTN(basePos - sideVect - float3(0.0f, 3.0f, 0.0f), xtexCoord + (1.0f / 16), 0.f, normalBend); - for (int b = 0; b < numSections; ++b) { - const float h = b * (1.0f / numSections); + for (float h = 0.0f; h < 1.0f; h += (1.0f / numSections)) { const float ang = maxAng * h; + const float3 n = (normalBend * std::cos(ang) + UpVector * std::sin(ang)).ANormalize(); + const float3 edgePos = (UpVector * std::cos(ang) + bendVect * std::sin(ang)) * length * h; + const float3 edgePosL = edgePos - sideVect * (1.0f - h); + const float3 edgePosR = edgePos + sideVect * (1.0f - h); + + va->AddVertexTN(basePos + edgePosR, xtexCoord + (1.0f / 32) * h , h, (n + sideVect * 0.04f).ANormalize()); + va->AddVertexTN(basePos + edgePosL, xtexCoord - (1.0f / 32) * h + (1.0f / 16), h, (n - sideVect * 0.04f).ANormalize()); + } + + // end top tip (single triangle) + const float3 edgePos = (UpVector * std::cos(maxAng) + bendVect * std::sin(maxAng)) * length; + const float3 n = (normalBend * std::cos(maxAng) + UpVector * std::sin(maxAng)).ANormalize(); + va->AddVertexTN(basePos + edgePos, xtexCoord + (1.0f / 32), 1.0f, n); - const float3 edgePosL = - -sideVect * (1 - h) + - (UpVector * std::cos(ang) + forwardVect * std::sin(ang)) * length * h; - const float3 edgePosR = - sideVect * (1.0f - h) + - (UpVector * std::cos(ang) + forwardVect * std::sin(ang)) * length * h; - - if (b == 0) { - va->AddVertexT(basePos + (edgePosR - float3(0.0f, 0.1f, 0.0f)), xtexBase + xtexOffset, h); - va->AddVertexT(basePos + (edgePosR - float3(0.0f, 0.1f, 0.0f)), xtexBase + xtexOffset, h); - } else { - va->AddVertexT((basePos + edgePosR), xtexBase + xtexOffset, h); - } - - va->AddVertexT((basePos + edgePosL), xtexBase + (1.0f / 16) + xtexOffset, h); - } - - va->AddVertexT(basePos + cornerPos, xtexBase + xtexOffset + (1.0f / 32), 1.0f); - va->AddVertexT(basePos + cornerPos, xtexBase + xtexOffset + (1.0f / 32), 1.0f); + // next blade + va->EndStrip(); } glNewList(listNum, GL_COMPILE); - va->DrawArrayT(GL_TRIANGLE_STRIP); + va->DrawArrayTN(GL_TRIANGLE_STRIP); glEndList(); } void CGrassDrawer::CreateGrassBladeTex(unsigned char* buf) { - float3 col( mapInfo->grass.color + float3(0.11f * rng.RandFloat(), 0.08f * rng.RandFloat(), 0.11f * rng.RandFloat()) ); + float3 redish = float3(0.95f, 0.70f, 0.4f); + float3 col = mix(mapInfo->grass.color, redish, 0.1f * rng.RandFloat()); col.x = Clamp(col.x, 0.f, 1.f); col.y = Clamp(col.y, 0.f, 1.f); col.z = Clamp(col.z, 0.f, 1.f); - for(int y=0;y<64;++y){ - for(int x=0;x<16;++x){ - const float brightness = (0.4f + 0.6f * (y/64.0f)) * 255.f; - buf[(y*256+x)*4+0] = (unsigned char)(col.x * brightness); - buf[(y*256+x)*4+1] = (unsigned char)(col.y * brightness); - buf[(y*256+x)*4+2] = (unsigned char)(col.z * brightness); - buf[(y*256+x)*4+3] = 1; + SColor* img = reinterpret_cast(buf); + for (int y=0; y<64; ++y) { + for (int x=0; x<16; ++x) { + const float brightness = smoothstep(-0.8f, 0.5f, y/63.0f) + ((x%2) == 0 ? 0.035f : 0.0f); + const float3 c = col * brightness; + img[y*256+x] = SColor(c.r, c.g, c.b, 1.0f); } } } void CGrassDrawer::CreateFarTex() { - int sizeMod=2; - unsigned char* buf=new unsigned char[64*sizeMod*1024*sizeMod*4]; - unsigned char* buf2=new unsigned char[256*sizeMod*256*sizeMod*4]; - memset(buf,0,64*sizeMod*1024*sizeMod*4); - memset(buf2,0,256*sizeMod*256*sizeMod*4); + //TODO create normalmap, too? + const int sizeMod = 2; + const int billboardSize = 256; + const int numAngles = 16; + const int texSizeX = billboardSize * numAngles; + const int texSizeY = billboardSize; + + if (farTex == 0) { + glGenTextures(1, &farTex); + glBindTexture(GL_TEXTURE_2D, farTex); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glSpringTexStorage2D(GL_TEXTURE_2D, -1, GL_RGBA8, texSizeX, texSizeY); + } + + FBO fboTex; + fboTex.Bind(); + fboTex.AttachTexture(farTex); + fboTex.CheckStatus("GRASSDRAWER1"); FBO fbo; fbo.Bind(); - fbo.CreateRenderBuffer(GL_DEPTH_ATTACHMENT_EXT, GL_DEPTH_COMPONENT16, 256*sizeMod, 256*sizeMod); - fbo.CreateRenderBuffer(GL_COLOR_ATTACHMENT0_EXT, GL_RGBA8, 256*sizeMod, 256*sizeMod); - fbo.CheckStatus("GRASSDRAWER"); + fbo.CreateRenderBuffer(GL_DEPTH_ATTACHMENT_EXT, GL_DEPTH_COMPONENT16, texSizeX * sizeMod, texSizeY * sizeMod); + fbo.CreateRenderBuffer(GL_COLOR_ATTACHMENT0_EXT, GL_RGBA8, texSizeX * sizeMod, texSizeY * sizeMod); + fbo.CheckStatus("GRASSDRAWER2"); + + if (!fboTex.IsValid() || !fbo.IsValid()) { + grassOff = true; + return; + } glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glPushMatrix(); - glEnable(GL_TEXTURE_2D); + glDisable(GL_FOG); glDisable(GL_BLEND); glDisable(GL_ALPHA_TEST); glBindTexture(GL_TEXTURE_2D, grassBladeTex); glEnable(GL_TEXTURE_2D); - glDisable(GL_FOG); - glDisable(GL_BLEND); + glEnable(GL_CLIP_PLANE0); + glEnable(GL_DEPTH_TEST); + glDepthMask(GL_TRUE); glColor4f(1,1,1,1); - glViewport(0,0,256*sizeMod,256*sizeMod); - - for(int a=0;a<16;++a){ - glClearColor(0.0f,0.0f,0.0f,0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glViewport(0,0,texSizeX*sizeMod, texSizeY*sizeMod); + glClearColor(mapInfo->grass.color.r,mapInfo->grass.color.g,mapInfo->grass.color.b,0.f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glClearColor(0.f,0.f,0.f,0.f); + + static const GLdouble eq[4] = {0.f, 1.f, 0.f, 0.f}; + + // render turf from different vertical angles + for (int a=0;a fill background with blurred color data + fboTex.Bind(); + for (int mipLevel = mipLevels - 2; mipLevel >= 0; --mipLevel) { + fboTex.AttachTexture(farTex, GL_TEXTURE_2D, GL_COLOR_ATTACHMENT0_EXT, mipLevel); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, mipLevel + 1.f); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, mipLevel + 1.f); + glViewport(0, 0, texSizeX>>mipLevel, texSizeY>>mipLevel); + + CVertexArray* va = GetVertexArray(); + va->Initialize(); + va->AddVertexT(float3(-1.0f, 1.0f, 0.0f), 0.0f, 1.0f); + va->AddVertexT(float3( 1.0f, 1.0f, 0.0f), 1.0f, 1.0f); + va->AddVertexT(float3( 1.0f, -1.0f, 0.0f), 1.0f, 0.0f); + va->AddVertexT(float3(-1.0f, -1.0f, 0.0f), 0.0f, 0.0f); + va->DrawArrayT(GL_QUADS); } + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + // recreate mipmaps from now blurred base level + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, -1000.f); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 1000.f); + glGenerateMipmap(GL_TEXTURE_2D); } glViewport(globalRendering->viewPosX, 0, globalRendering->viewSizeX, globalRendering->viewSizeY); @@ -965,40 +996,68 @@ glMatrixMode(GL_MODELVIEW); glPopMatrix(); - fbo.Unbind(); + FBO::Unbind(); + //glSaveTexture(farTex, "grassfar.png"); +} - glGenTextures(1, &farTex); - glBindTexture(GL_TEXTURE_2D, farTex); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glBuildMipmaps(GL_TEXTURE_2D, GL_RGBA8, 1024 * sizeMod, 64 * sizeMod, GL_RGBA, GL_UNSIGNED_BYTE, buf); - delete[] buf; - delete[] buf2; +void CGrassDrawer::ResetPos(const int grassBlockX, const int grassBlockZ) +{ + if (grassOff) + return; + + assert(grassBlockX >= 0 && grassBlockX < blocksX); + assert(grassBlockZ >= 0 && grassBlockZ < blocksY); + + GrassStruct& gb = grass[grassBlockZ * blocksX + grassBlockX]; + delete gb.va; + gb.va = nullptr; + + updateBillboards = true; +} + + +void CGrassDrawer::ResetPos(const float3& pos) +{ + ResetPos(pos.x / bMSsq, pos.z / bMSsq); } + void CGrassDrawer::AddGrass(const float3& pos) { if (grassOff) return; - GML_RECMUTEX_LOCK(grass); // AddGrass - - const int x = int(pos.x) / SQUARE_SIZE / grassSquareSize; - const int z = int(pos.z) / SQUARE_SIZE / grassSquareSize; + const int x = int(pos.x) / (SQUARE_SIZE * grassSquareSize); + const int z = int(pos.z) / (SQUARE_SIZE * grassSquareSize); + assert(x >= 0 && x < (gs->mapx / grassSquareSize)); + assert(z >= 0 && z < (gs->mapy / grassSquareSize)); grassMap[z * gs->mapx / grassSquareSize + x] = 1; + ResetPos(pos); } -void CGrassDrawer::RemoveGrass(int x, int z) + +void CGrassDrawer::RemoveGrass(const float3& pos) { if (grassOff) return; - GML_RECMUTEX_LOCK(grass); // RemoveGrass + const int x = int(pos.x) / (SQUARE_SIZE * grassSquareSize); + const int z = int(pos.z) / (SQUARE_SIZE * grassSquareSize); + assert(x >= 0 && x < (gs->mapx / grassSquareSize)); + assert(z >= 0 && z < (gs->mapy / grassSquareSize)); + + grassMap[z * gs->mapx / grassSquareSize + x] = 0; + ResetPos(pos); +} + - grassMap[(z / grassSquareSize) * gs->mapx / grassSquareSize + x / grassSquareSize] = 0; - ResetPos(float3(x * SQUARE_SIZE, 0.0f, z * SQUARE_SIZE)); +void CGrassDrawer::UnsyncedHeightMapUpdate(const SRectangle& rect) +{ + for (int z = rect.z1; z <= rect.z2; ++z) { + for (int x = rect.x1; x <= rect.x2; ++x) { + ResetPos(float3(x, 0.f, z)); + } + } } diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Env/GrassDrawer.h spring-98.0~14.04~ppa6/rts/Rendering/Env/GrassDrawer.h --- spring-96.0~14.04~ppa4/rts/Rendering/Env/GrassDrawer.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Env/GrassDrawer.h 2014-10-07 20:09:51.000000000 +0000 @@ -5,13 +5,17 @@ #include #include "System/float3.h" +#include "System/EventClient.h" namespace Shader { struct IProgramObject; } class CVertexArray; -class CGrassDrawer +struct VA_TYPE_TN; + + +class CGrassDrawer : public CEventClient { public: CGrassDrawer(); @@ -21,33 +25,44 @@ void DrawShadow(); void AddGrass(const float3& pos); void ResetPos(const float3& pos); - void RemoveGrass(int x, int z); + void RemoveGrass(const float3& pos); - struct InviewGrass { - int num; - float dist; - }; + void ChangeDetail(int detail); + + /// @see ConfigHandler::ConfigNotifyCallback + void ConfigNotify(const std::string& key, const std::string& value); + +public: + // EventClient + void UnsyncedHeightMapUpdate(const SRectangle& rect); + void Update(); + +public: struct InviewNearGrass { int x; int y; float dist; }; struct GrassStruct { + GrassStruct() + : posX(0) + , posZ(0) + , va(nullptr) + , lastSeen(0) + , lastDist(0.f) + {} + ~GrassStruct(); + + int posX, posZ; CVertexArray* va; int lastSeen; - int square; - float3 pos; - }; - struct NearGrassStruct { - float rotation; - int square; + float lastDist; }; enum GrassShaderProgram { - GRASS_PROGRAM_NEAR_SHADOW = 0, // near-grass shader (V+F) with self-shadowing - GRASS_PROGRAM_DIST_SHADOW = 1, // far-grass shader (V+F) with self-shadowing - GRASS_PROGRAM_DIST_BASIC = 2, // far-grass shader (V) without self-shadowing - // GRASS_PROGRAM_SHADOW_GEN = 3, + GRASS_PROGRAM_NEAR = 0, + GRASS_PROGRAM_DIST = 1, + GRASS_PROGRAM_SHADOW_GEN = 2, GRASS_PROGRAM_LAST = 3 }; @@ -55,21 +70,21 @@ void LoadGrassShaders(); void CreateGrassBladeTex(unsigned char* buf); void CreateFarTex(); + void CreateGrassDispList(int listNum); + void EnableShader(const GrassShaderProgram type); void SetupGlStateNear(); void ResetGlStateNear(); void SetupGlStateFar(); void ResetGlStateFar(); - void DrawFarBillboards(const std::vector& inviewGrass); + void DrawNear(const std::vector& inviewGrass); + void DrawFarBillboards(const std::vector& inviewGrass); void DrawNearBillboards(const std::vector& inviewNearGrass); - void GarbageCollect(); - - GrassStruct grass[32 * 32]; - NearGrassStruct nearGrass[32 * 32]; + void DrawBillboard(const int x, const int y, const float dist, VA_TYPE_TN* va_tn); - int lastListClean; - void CreateGrassDispList(int listNum); + void ResetPos(const int grassBlockX, const int grassBlockZ); +protected: friend class CGrassBlockDrawer; bool grassOff; @@ -80,6 +95,7 @@ unsigned int grassDL; unsigned int grassBladeTex; unsigned int farTex; + CVertexArray* farnearVA; std::vector grassShaders; Shader::IProgramObject* grassShader; @@ -90,8 +106,16 @@ int numTurfs; int strawPerTurf; + float3 oldCamPos; + float3 oldCamDir; + int lastVisibilityUpdate; + bool updateBillboards; + + std::vector grass; unsigned char* grassMap; }; +extern CGrassDrawer* grassDrawer; //FIXME can be nullptr + #endif /* GRASSDRAWER_H */ diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Env/ISky.cpp spring-98.0~14.04~ppa6/rts/Rendering/Env/ISky.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Env/ISky.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Env/ISky.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -90,7 +90,7 @@ // cast a ray *toward* the sun from // sun is visible if no terrain blocks it - const float3 sunDir = skyLight->GetLightDir(); + const float3& sunDir = skyLight->GetLightDir(); const float sunDist = TraceRay::GuiTraceRay(pos, sunDir, globalRendering->viewRange, NULL, hitUnit, hitFeature, false, true, false); return (sunDist < 0.0f || sunDist >= globalRendering->viewRange); diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Env/ITreeDrawer.cpp spring-98.0~14.04~ppa6/rts/Rendering/Env/ITreeDrawer.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Env/ITreeDrawer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Env/ITreeDrawer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -91,10 +91,8 @@ Draw(treeDistance, drawReflection); } -void ITreeDrawer::Update() { - - GML_STDMUTEX_LOCK(tree); // Update - +void ITreeDrawer::Update() +{ std::vector::iterator i; for (i = delDispLists.begin(); i != delDispLists.end(); ++i) { glDeleteLists(*i, 1); diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Env/ITreeDrawer.h spring-98.0~14.04~ppa6/rts/Rendering/Env/ITreeDrawer.h --- spring-96.0~14.04~ppa4/rts/Rendering/Env/ITreeDrawer.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Env/ITreeDrawer.h 2014-10-07 20:09:51.000000000 +0000 @@ -22,19 +22,13 @@ void Draw(bool drawReflection); virtual void Draw(float treeDistance, bool drawReflection) = 0; - virtual void DrawGrass() {} - virtual void DrawShadowGrass() {} + virtual void DrawShadowPass(); virtual void Update() = 0; virtual void ResetPos(const float3& pos) = 0; - virtual void AddTree(int treeID, int treeType, const float3& pos, float size) = 0; virtual void DeleteTree(int treeID, const float3& pos) = 0; - virtual void AddFallingTree(int treeID, int treeType, const float3& pos, const float3& dir) {} - virtual void AddGrass(const float3& pos) {} - virtual void RemoveGrass(int x, int z) {} - virtual void DrawShadowPass(); bool WantsEvent(const std::string& eventName) { return diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Env/IWater.cpp spring-98.0~14.04~ppa6/rts/Rendering/Env/IWater.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Env/IWater.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Env/IWater.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -33,9 +33,8 @@ } -void IWater::PushWaterMode(int nextWaterRenderMode) { - GML_STDMUTEX_LOCK(water); // PushWaterMode - +void IWater::PushWaterMode(int nextWaterRenderMode) +{ waterModes.push_back(nextWaterRenderMode); } @@ -44,8 +43,6 @@ std::vector wm; { - GML_STDMUTEX_LOCK(water); // UpdateIWater - wm.swap(waterModes); } @@ -112,8 +109,8 @@ case WATER_RENDERER_BUMPMAPPED: { const bool canLoad = GLEW_ARB_shading_language_100 && - GL_ARB_fragment_shader && - GL_ARB_vertex_shader; + GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader; if (canLoad) { try { diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/FarTextureHandler.cpp spring-98.0~14.04~ppa6/rts/Rendering/FarTextureHandler.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/FarTextureHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/FarTextureHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -286,7 +286,7 @@ } // create new far-icons - for (GML_VECTOR::iterator it = queuedForRender.begin(); it != queuedForRender.end(); ++it) { + for (std::vector::iterator it = queuedForRender.begin(); it != queuedForRender.end(); ++it) { const CSolidObject* obj = *it; if (!HaveFarIcon(obj)) { CreateFarTexture(obj); @@ -308,7 +308,7 @@ CVertexArray* va = GetVertexArray(); va->Initialize(); va->EnlargeArrays(queuedForRender.size() * 4, 0, VA_SIZE_T); - for (GML_VECTOR::iterator it = queuedForRender.begin(); it != queuedForRender.end(); ++it) { + for (std::vector::iterator it = queuedForRender.begin(); it != queuedForRender.end(); ++it) { DrawFarTexture(*it, va); } diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/FarTextureHandler.h spring-98.0~14.04~ppa6/rts/Rendering/FarTextureHandler.h --- spring-96.0~14.04~ppa4/rts/Rendering/FarTextureHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/FarTextureHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -31,7 +31,7 @@ static const int iconSizeY; static const int numOrientations; - GML_VECTOR queuedForRender; + std::vector queuedForRender; std::vector< std::vector > cache; FBO fbo; diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/FeatureDrawer.cpp spring-98.0~14.04~ppa6/rts/Rendering/FeatureDrawer.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/FeatureDrawer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/FeatureDrawer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -4,7 +4,6 @@ #include "Game/Camera.h" #include "Game/GlobalUnsynced.h" -#include "Lua/LuaRules.h" #include "Map/MapInfo.h" #include "Map/ReadMap.h" #include "Map/BaseGroundDrawer.h" @@ -49,12 +48,12 @@ /******************************************************************************/ -CR_BIND(CFeatureDrawer, ); -CR_BIND(CFeatureDrawer::DrawQuad, ); +CR_BIND(CFeatureDrawer, ) +CR_BIND(CFeatureDrawer::DrawQuad, ) CR_REG_METADATA(CFeatureDrawer, ( CR_POSTLOAD(PostLoad) -)); +)) /******************************************************************************/ @@ -67,9 +66,6 @@ drawQuadsX = gs->mapx/DRAW_QUAD_SIZE; drawQuadsY = gs->mapy/DRAW_QUAD_SIZE; drawQuads.resize(drawQuadsX * drawQuadsY); -#ifdef USE_GML - showRezBars = GML::Enabled() && configHandler->GetBool("ShowRezBars"); -#endif featureDrawDistance = configHandler->GetFloat("FeatureDrawDistance"); featureFadeDistance = std::min(configHandler->GetFloat("FeatureFadeDistance"), featureDrawDistance); opaqueModelRenderers.resize(MODELTYPE_OTHER, NULL); @@ -102,9 +98,6 @@ CFeature* f = const_cast(feature); texturehandlerS3O->UpdateDraw(); - if (GML::SimEnabled() && !GML::ShareLists() && feature->model && TEX_TYPE(feature) < 0) - TEX_TYPE(f) = texturehandlerS3O->LoadS3OTextureNow(feature->model); - if (feature->def->drawType == DRAWTYPE_MODEL) { f->drawQuad = -1; UpdateDrawQuad(f); @@ -173,8 +166,6 @@ eventHandler.UpdateDrawFeatures(); { - GML_RECMUTEX_LOCK(feat); // Update - for (std::set::iterator fsi = unsortedFeatures.begin(); fsi != unsortedFeatures.end(); ++fsi) { UpdateDrawPos(*fsi); } @@ -184,8 +175,7 @@ inline void CFeatureDrawer::UpdateDrawPos(CFeature* f) { - const float time = /*!GML::SimEnabled() ?*/ globalRendering->timeOffset /*: - ((float)spring_tomsecs(globalRendering->lastFrameStart) - (float)f->lastFeatUpdate) * globalRendering->weightedSpeedFactor*/; + const float time = globalRendering->timeOffset; f->drawPos = f->pos + (f->speed * time); f->drawMidPos = f->midPos + (f->speed * time); @@ -196,8 +186,6 @@ { ISky::SetupFog(); - GML_RECMUTEX_LOCK(feat); // Draw - CBaseGroundDrawer* gd = readMap->GetGroundDrawer(); if (gd->DrawExtraTex()) { @@ -237,9 +225,6 @@ glDisable(GL_TEXTURE_2D); glDisable(GL_FOG); -#ifdef USE_GML - DrawFeatureStats(); -#endif } void CFeatureDrawer::DrawOpaqueFeatures(int modelType) @@ -266,56 +251,6 @@ } } -#ifdef USE_GML -void CFeatureDrawer::DrawFeatureStats() -{ - if (!drawStat.empty()) { - if (!water->DrawReflectionPass()) { - for (std::vector::iterator fi = drawStat.begin(); fi != drawStat.end(); ++fi) { - DrawFeatureStatBars(*fi); - } - } - - drawStat.clear(); - } -} - -void CFeatureDrawer::DrawFeatureStatBars(const CFeature* feature) -{ - float3 interPos = feature->pos; - interPos.y += feature->height + 5.0f; - - glPushMatrix(); - glTranslatef(interPos.x, interPos.y, interPos.z); - glMultMatrixf(camera->GetBillBoardMatrix()); - - const float recl = feature->reclaimLeft; - const float rezp = feature->resurrectProgress; - - // black background for the bar - glColor3f(0.0f, 0.0f, 0.0f); - glRectf(-5.0f, 4.0f, +5.0f, 6.0f); - - // rez/metalbar - const float rmin = std::min(recl, rezp) * 10.0f; - if (rmin > 0.0f) { - glColor3f(1.0f, 0.0f, 1.0f); - glRectf(-5.0f, 4.0f, rmin - 5.0f, 6.0f); - } - if (recl > rezp) { - float col = 0.8 - 0.3 * recl; - glColor3f(col, col, col); - glRectf(rmin - 5.0f, 4.0f, recl * 10.0f - 5.0f, 6.0f); - } - if (recl < rezp) { - glColor3f(0.5f, 0.0f, 1.0f); - glRectf(rmin - 5.0f, 4.0f, rezp * 10.0f - 5.0f, 6.0f); - } - - glPopMatrix(); -} -#endif - bool CFeatureDrawer::DrawFeatureNow(const CFeature* feature, float alpha) { if (feature->IsInVoid()) { return false; } @@ -333,7 +268,7 @@ unitDrawer->SetTeamColour(feature->team, alpha); - if (!(feature->luaDraw && luaRules != NULL && luaRules->DrawFeature(feature))) { + if (!(feature->luaDraw && eventHandler.DrawFeature(feature))) { feature->model->DrawStatic(); } @@ -368,8 +303,6 @@ ISky::SetupFog(); { - GML_RECMUTEX_LOCK(feat); // DrawFadeFeatures - for (int modelType = MODELTYPE_3DO; modelType < MODELTYPE_OTHER; modelType++) { cloakedModelRenderers[modelType]->PushRenderState(); DrawFadeFeaturesHelper(modelType); @@ -440,8 +373,6 @@ po->Enable(); { - GML_RECMUTEX_LOCK(feat); // DrawShadowPass - // note: for the shadow-pass, we want to make sure // out-of-view features casting frustum-intersecting // shadows are still rendered, but this is expensive @@ -489,9 +420,6 @@ float sqFadeDistBegin; float sqFadeDistEnd; bool farFeatures; -#ifdef USE_GML - std::vector* statFeatures; -#endif std::vector* drawQuads; @@ -522,7 +450,7 @@ camera->GetPos() * (f->midPos.y / dif) + f->midPos * (-camera->GetPos().y / dif); } - if (ground->GetApproximateHeight(zeroPos.x, zeroPos.z, false) > f->drawRadius) { + if (CGround::GetApproximateHeight(zeroPos.x, zeroPos.z, false) > f->drawRadius) { continue; } } @@ -533,10 +461,6 @@ const float sqDist = (f->pos - camera->GetPos()).SqLength(); const float farLength = f->sqRadius * unitDrawer->unitDrawDistSqr; -#ifdef USE_GML - if (statFeatures && (f->reclaimLeft < 1.0f || f->resurrectProgress > 0.0f)) - statFeatures->push_back(f); -#endif if (sqDist < farLength) { float sqFadeDistE; @@ -582,16 +506,11 @@ drawer.sqFadeDistEnd = featureDrawDistance * featureDrawDistance; drawer.sqFadeDistBegin = featureFadeDistance * featureFadeDistance; drawer.farFeatures = drawFar; -#ifdef USE_GML - drawer.statFeatures = showRezBars ? &drawStat : NULL; -#endif readMap->GridVisibility(camera, DRAW_QUAD_SIZE, featureDrawDistance, &drawer, extraSize); } void CFeatureDrawer::SwapFeatures() { - GML_RECMUTEX_LOCK(feat); // SwapFeatures - for(int i = 0; i < MODELTYPE_OTHER; ++i) { opaqueModelRenderers[i]->SwapFeatures(); cloakedModelRenderers[i]->SwapFeatures(); diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/FeatureDrawer.h spring-98.0~14.04~ppa6/rts/Rendering/FeatureDrawer.h --- spring-96.0~14.04~ppa4/rts/Rendering/FeatureDrawer.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/FeatureDrawer.h 2014-10-07 20:09:51.000000000 +0000 @@ -11,13 +11,12 @@ class CFeature; class IWorldObjectModelRenderer; -class CVertexArray; class CFeatureDrawer: public CEventClient { - CR_DECLARE_STRUCT(CFeatureDrawer); - CR_DECLARE_SUB(DrawQuad); + CR_DECLARE_STRUCT(CFeatureDrawer) + CR_DECLARE_SUB(DrawQuad) typedef std::map FeatureSet; typedef std::map FeatureRenderBin; @@ -46,15 +45,6 @@ virtual void RenderFeatureDestroyed(const CFeature* feature); virtual void RenderFeatureMoved(const CFeature* feature, const float3& oldpos, const float3& newpos); -#ifdef USE_GML - void DrawFeatureStats(); - void DrawFeatureStatBars(const CFeature*); - std::vector drawStat; - bool showRezBars; - void SetShowRezBars(bool b) { showRezBars = b; } - bool GetShowRezBars() const { return showRezBars; } -#endif - private: static void UpdateDrawPos(CFeature* f); @@ -70,7 +60,7 @@ std::set unsortedFeatures; struct DrawQuad { - CR_DECLARE_STRUCT(DrawQuad); + CR_DECLARE_STRUCT(DrawQuad) std::set features; }; diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Fonts/CFontTexture.cpp spring-98.0~14.04~ppa6/rts/Rendering/Fonts/CFontTexture.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Fonts/CFontTexture.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Fonts/CFontTexture.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,671 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include "CFontTexture.h" +#include "FontLogSection.h" +#include "LanguageBlocksDefs.h" + +#include +#include +#include // for memset, memcpy + +#include + +#ifndef HEADLESS + #include + #include FT_FREETYPE_H + #ifdef USE_FONTCONFIG + #include + #include + #endif +#endif // HEADLESS + +#include "Game/Camera.h" +#include "Rendering/GL/myGL.h" +#include "Rendering/GlobalRendering.h" +#include "Rendering/Textures/Bitmap.h" +#include "System/Log/ILog.h" +#include "System/FileSystem/FileHandler.h" +#include "System/FileSystem/FileSystem.h" +#include "System/Exceptions.h" +#include "System/Util.h" +#include "System/float4.h" +#include "System/bitops.h" + + +#ifndef HEADLESS + #undef __FTERRORS_H__ + #define FT_ERRORDEF( e, v, s ) { e, s }, + #define FT_ERROR_START_LIST { + #define FT_ERROR_END_LIST { 0, 0 } }; + struct ErrorString { + int err_code; + const char* err_msg; + } static errorTable[] = + #include FT_ERRORS_H + + + static const char* GetFTError(FT_Error e) { + for (int a = 0; errorTable[a].err_msg; ++a) { + if (errorTable[a].err_code == e) + return errorTable[a].err_msg; + } + return "Unknown error"; + } +#endif // HEADLESS + + + + +#ifdef HEADLESS +typedef unsigned char FT_Byte; +#endif + +struct FontFace { + FontFace(FT_Face f, std::shared_ptr& mem) : face(f), memory(mem) { } + ~FontFace() { + #ifndef HEADLESS + FT_Done_Face(face); + #endif + } + operator FT_Face() { return this->face; } + + FT_Face face; + std::shared_ptr memory; +}; +static std::unordered_set allFonts; +static std::unordered_map> fontCache; +static std::unordered_map> fontMemCache; +static boost::recursive_mutex m; + + + +#ifndef HEADLESS +class FtLibraryHandler +{ +public: + FtLibraryHandler() { + FT_Error error = FT_Init_FreeType(&lib); + if (error) { + std::string msg = "FT_Init_FreeType failed:"; + msg += GetFTError(error); + throw std::runtime_error(msg); + } + #ifdef USE_FONTCONFIG + if (!FcInit()) { + throw std::runtime_error("FontConfig failed"); + } + #endif + }; + + ~FtLibraryHandler() { + FT_Done_FreeType(lib); + #ifdef USE_FONTCONFIG + FcFini(); + #endif + }; + + static FT_Library& GetLibrary() { + // singleton +#ifndef WIN32 + std::call_once(flag, [](){ + singleton.reset(new FtLibraryHandler()); + }); +#else + std::lock_guard lk(m); + if (flag) { + singleton.reset(new FtLibraryHandler()); + flag = false; + } +#endif + return singleton->lib; + }; + +private: + FT_Library lib; +#ifndef WIN32 + static std::once_flag flag; +#else + static bool flag; +#endif + static std::unique_ptr singleton; + +}; + +#ifndef WIN32 +std::once_flag FtLibraryHandler::flag; +#else +bool FtLibraryHandler::flag = true; +#endif +std::unique_ptr FtLibraryHandler::singleton = nullptr; +#endif + + + +/*******************************************************************************/ +/*******************************************************************************/ +/*******************************************************************************/ +/*******************************************************************************/ +/*******************************************************************************/ +/*******************************************************************************/ +/*******************************************************************************/ +/*******************************************************************************/ + +static inline uint32_t GetKerningHash(char32_t lchar, char32_t rchar) +{ + if (lchar < 128 && rchar < 128) { + return (lchar << 7) | rchar; // 14bit used + } + return (lchar << 16) | rchar; // 32bit used +} + + +#ifndef HEADLESS +static std::shared_ptr GetFontFace(const std::string& fontfile, const int size) +{ + std::lock_guard lk(m); + + //TODO add support to load fonts by name (needs fontconfig) + + auto it = fontCache.find(fontfile + IntToString(size)); + if (it != fontCache.end() && !it->second.expired()) + return it->second.lock(); + + // get the file (no need to cache, takes too less time) + std::string fontPath(fontfile); + CFileHandler* f = new CFileHandler(fontPath); + if (!f->FileExists()) { + // check in 'fonts/', too + if (fontPath.substr(0,6) != "fonts/") { + delete f; + fontPath = "fonts/" + fontPath; + f = new CFileHandler(fontPath); + } + + if (!f->FileExists()) { + delete f; + throw content_error("Couldn't find font '" + fontfile + "'."); + } + } + + // we need to keep a copy of the memory + const int filesize = f->FileSize(); + std::weak_ptr& fontMemWeak = fontMemCache[fontPath]; + std::shared_ptr fontMem = fontMemWeak.lock(); + if (fontMemWeak.expired()) { + fontMem = std::make_shared(new FT_Byte[filesize]); + f->Read(*fontMem, filesize); + fontMemWeak = fontMem; + } + delete f; + + // load the font + FT_Face face = NULL; + FT_Error error = FT_New_Memory_Face(FtLibraryHandler::GetLibrary(), *fontMem, filesize, 0, &face); + auto shFace = std::make_shared(face, fontMem); + if (error) { + std::string msg = fontfile + ": FT_New_Face failed: "; + msg += GetFTError(error); + throw content_error(msg); + } + + // set render size + error = FT_Set_Pixel_Sizes(face, 0, size); + if (error) { + std::string msg = fontfile + ": FT_Set_Pixel_Sizes failed: "; + msg += GetFTError(error); + throw content_error(msg); + } + + // select unicode charmap + error = FT_Select_Charmap(face, FT_ENCODING_UNICODE); + if (error) { + std::string msg = fontfile + ": FT_Select_Charmap failed: "; + msg += GetFTError(error); + throw content_error(msg); + } + + fontCache[fontfile + IntToString(size)] = shFace; + return shFace; +} +#endif + + + +static std::shared_ptr GetFontForCharacters(std::list& characters, const FT_Face origFace, const int origSize) +{ +#if !defined(HEADLESS) && defined(USE_FONTCONFIG) + if (characters.empty()) { + return nullptr; + } + + // create list of wanted characters + FcCharSet* cset = FcCharSetCreate(); + for (auto c: characters) { + FcCharSetAddChar(cset, c); + } + + // create properties of the wanted font + FcPattern* pattern = FcPatternCreate(); + { + FcValue v; + v.type = FcTypeBool; + v.u.b = FcTrue; + FcPatternAddWeak(pattern, FC_ANTIALIAS, v, FcFalse); + + FcPatternAddCharSet(pattern, FC_CHARSET, cset); + FcPatternAddBool(pattern, FC_SCALABLE, FcTrue); + + int weight = FC_WEIGHT_NORMAL; + int slant = FC_SLANT_ROMAN; + { + const FcChar8* ftname = reinterpret_cast("not used"); + FcBlanks* blanks = FcBlanksCreate(); + FcPattern* origPattern = FcFreeTypeQueryFace(origFace, ftname, 0, blanks); + FcBlanksDestroy(blanks); + if (origPattern) { + FcPatternGetInteger(origPattern, FC_WEIGHT, 0, &weight); + FcPatternGetInteger(origPattern, FC_SLANT, 0, &slant); + FcPatternDestroy(origPattern); + } + } + FcPatternAddInteger(pattern, FC_WEIGHT, weight); + FcPatternAddInteger(pattern, FC_SLANT, slant); + } + + // search fonts that fit our request + FcResult res; + FcFontSet* fs = FcFontSort(nullptr, pattern, FcFalse, nullptr, &res); + + // dtors + auto del = [&](FcFontSet* fs){ FcFontSetDestroy(fs); }; + std::unique_ptr fs_(fs, del); + FcPatternDestroy(pattern); + FcCharSetDestroy(cset); + if (!fs) return nullptr; + if (res != FcResultMatch) return nullptr; + + // iterate returned font list + for (int i = 0; i < fs->nfont; ++i) { + FcPattern* font = fs->fonts[i]; + FcChar8* cFilename = nullptr; + FcResult r = FcPatternGetString(font, FC_FILE, 0, &cFilename); + if (r != FcResultMatch || cFilename == nullptr) continue; + + const std::string filename = reinterpret_cast(cFilename); + try { + return GetFontFace(filename, origSize); + } catch(const content_error& ex) { + LOG_L(L_DEBUG, "%s: %s", filename.c_str(), ex.what()); + } + } + return nullptr; +#else + return nullptr; +#endif +} + + +/*******************************************************************************/ +/*******************************************************************************/ +/*******************************************************************************/ +/*******************************************************************************/ +/*******************************************************************************/ +/*******************************************************************************/ +/*******************************************************************************/ +/*******************************************************************************/ + + +CFontTexture::CFontTexture(const std::string& fontfile, int size, int _outlinesize, float _outlineweight) + : outlineSize(_outlinesize) + , outlineWeight(_outlineweight) + , lineHeight(0) + , fontDescender(0) + , fontSize(size) + , texWidth(0) + , texHeight(0) + , wantedTexWidth(0) + , wantedTexHeight(0) + , texture(0) + , textureSpaceMatrix(0) + , atlasUpdate(NULL) + , atlasUpdateShadow(NULL) + , lastTextureUpdate(0) + , curTextureUpdate(0) + , face(NULL) +{ + if (fontSize <= 0) + fontSize = 14; + + static const int FT_INTERNAL_DPI = 64; + normScale = 1.0f / (fontSize * FT_INTERNAL_DPI); + + fontFamily = "unknown"; + fontStyle = "unknown"; + +#ifndef HEADLESS + shFace = GetFontFace(fontfile, fontSize); + face = *shFace; + + if (!face) + return; + + fontFamily = face->family_name; + fontStyle = face->style_name; + + fontDescender = normScale * FT_MulFix(face->descender, face->size->metrics.y_scale); + //lineHeight = FT_MulFix(face->height, face->size->metrics.y_scale); // bad results + lineHeight = face->height / face->units_per_EM; + if (lineHeight <= 0) + lineHeight = 1.25 * (face->bbox.yMax - face->bbox.yMin); + + // has to be done before first GetGlyph() call! + CreateTexture(32, 32); + + // precache ASCII glyphs & kernings (save them in an array for better lvl2 cpu cache hitrate) + memset(kerningPrecached, 0, 128*128*sizeof(float)); + for (char32_t i=32; i<127; ++i) { + const auto& lgl = GetGlyph(i); + const float advance = lgl.advance; + for (char32_t j=32; j<127; ++j) { + const auto& rgl = GetGlyph(j); + const auto hash = GetKerningHash(i, j); + FT_Vector kerning; + FT_Get_Kerning(face, lgl.index, rgl.index, FT_KERNING_DEFAULT, &kerning); + kerningPrecached[hash] = advance + normScale * kerning.x; + } + } + + allFonts.insert(this); +#endif +} + +CFontTexture::~CFontTexture() +{ +#ifndef HEADLESS + allFonts.erase(this); + glDeleteTextures(1, (const GLuint*)&texture); + glDeleteLists(textureSpaceMatrix, 1); +#endif +} + + +void CFontTexture::Update() { + std::lock_guard lk(m); + for (auto& font: allFonts) { + font->UpdateTexture(); + } +} + + +const GlyphInfo& CFontTexture::GetGlyph(char32_t ch) +{ +#ifndef HEADLESS + const auto it = glyphs.find(ch); + if (it != glyphs.end()) + return it->second; + + // Get block start pos + char32_t start, end; + start = GetLanguageBlock(ch, end); + + // Load an entire block + LoadBlock(start, end); + return GetGlyph(ch); +#else + static GlyphInfo g = GlyphInfo(); + return g; +#endif +} + + +float CFontTexture::GetKerning(const GlyphInfo& lgl, const GlyphInfo& rgl) +{ +#ifndef HEADLESS + // first check caches + uint32_t hash = GetKerningHash(lgl.utf16, rgl.utf16); + if (hash < 128*128) { + return kerningPrecached[hash]; + } + const auto it = kerningDynamic.find(hash); + if (it != kerningDynamic.end()) { + return it->second; + } + + if (lgl.face != rgl.face) { + return (kerningDynamic[hash] = lgl.advance); + } + + // load & cache + FT_Vector kerning; + FT_Get_Kerning(lgl.face, lgl.index, rgl.index, FT_KERNING_DEFAULT, &kerning); + return (kerningDynamic[hash] = lgl.advance + normScale * kerning.x); +#else + return 0; +#endif +} + + +void CFontTexture::LoadBlock(char32_t start, char32_t end) +{ + std::lock_guard lk(m); + + // generate list of wnated glyphs + std::list map; + for(char32_t i=start; i f = shFace; + std::set> alreadyCheckedFonts; +#ifndef HEADLESS + do { + alreadyCheckedFonts.insert(f); + for (auto it = map.begin(); it != map.end();) { + FT_UInt index = FT_Get_Char_Index(*f, *it); + + if (index != 0) { + LoadGlyph(f, *it, index); + it = map.erase(it); + } else { + ++it; + } + } + f = GetFontForCharacters(map, *f, fontSize); + usedFallbackFonts.insert(f); + } while (!map.empty() && f && (alreadyCheckedFonts.find(f) == alreadyCheckedFonts.end())); +#endif + // load fail glyph for all remaining ones (they will all share the same fail glyph) + for (auto c: map) { + LoadGlyph(shFace, c, 0); + } + + + // readback textureatlas allocator data + { + atlasAlloc.SetNonPowerOfTwo(globalRendering->supportNPOTs); + const bool success = atlasAlloc.Allocate(); + if (!success) + LOG_L(L_WARNING, "Texture limit reached! (try to reduce the font size and/or outlinewidth)"); + + wantedTexWidth = atlasAlloc.GetAtlasSize().x; + wantedTexHeight = atlasAlloc.GetAtlasSize().y; + if ((atlasUpdate->xsize != wantedTexWidth) || (atlasUpdate->ysize != wantedTexHeight)) { + (*atlasUpdate) = atlasUpdate->CanvasResize(wantedTexWidth, wantedTexHeight, false); + } + + if (!atlasUpdateShadow) { + atlasUpdateShadow = new CBitmap(); + atlasUpdateShadow->channels = 1; + atlasUpdateShadow->Alloc(wantedTexWidth, wantedTexHeight); + } + if ((atlasUpdateShadow->xsize != wantedTexWidth) || (atlasUpdateShadow->ysize != wantedTexHeight)) { + (*atlasUpdateShadow) = atlasUpdateShadow->CanvasResize(wantedTexWidth, wantedTexHeight, false); + } + + for(char32_t i=start; iCopySubImage(*glyphbm, texpos.x, texpos.y); + if (texpos2[2] != 0) atlasUpdateShadow->CopySubImage(*glyphbm, texpos2.x + outlineSize, texpos2.y + outlineSize); + delete glyphbm; glyphbm = NULL; + } + atlasAlloc.clear(); + } + + ++curTextureUpdate; +} + + + +void CFontTexture::LoadGlyph(std::shared_ptr& f, char32_t ch, unsigned index) +{ +#ifndef HEADLESS + if (glyphs.find(ch) != glyphs.end()) + return; + + // check for duplicated glyphs + for (auto& it: glyphs) { + if (it.second.index == index && it.second.face == f->face) { + auto& glyph = glyphs[ch]; + glyph = it.second; + glyph.utf16 = ch; + return; + } + } + + auto& glyph = glyphs[ch]; + glyph.face = f->face; + glyph.index = index; + glyph.utf16 = ch; + + // load glyph + FT_Error error = FT_Load_Glyph(*f, index, FT_LOAD_RENDER); + if (error) { + LOG_L(L_ERROR, "Couldn't load glyph %d", ch); + } + + FT_GlyphSlot slot = f->face->glyph; + + const float xbearing = slot->metrics.horiBearingX * normScale; + const float ybearing = slot->metrics.horiBearingY * normScale; + + glyph.size.x = xbearing; + glyph.size.y = ybearing - fontDescender; + glyph.size.w = slot->metrics.width * normScale; + glyph.size.h = -slot->metrics.height * normScale; + + glyph.advance = slot->advance.x * normScale; + glyph.height = slot->metrics.height * normScale; + glyph.descender = ybearing - glyph.height; + + // workaround bugs in FreeSansBold (in range 0x02B0 - 0x0300) + if (glyph.advance == 0 && glyph.size.w > 0) glyph.advance = glyph.size.w; + + const int width = slot->bitmap.width; + const int height = slot->bitmap.rows; + + if (width<=0 || height<=0) { + return; + } + + if (slot->bitmap.pixel_mode != FT_PIXEL_MODE_GRAY) { + LOG_L(L_ERROR, "invalid pixeldata mode"); + return; + } + + if (slot->bitmap.pitch != width) { + LOG_L(L_ERROR, "invalid pitch"); + return; + } + + CBitmap* gbm = new CBitmap(slot->bitmap.buffer, width, height, 1); + atlasAlloc.AddEntry(IntToString(ch), int2(width, height), (void*)gbm); + atlasAlloc.AddEntry(IntToString(ch) + "sh", int2(width + 2 * outlineSize, height + 2 * outlineSize)); +#endif +} + + +void CFontTexture::CreateTexture(const int width, const int height) +{ +#ifndef HEADLESS + glPushAttrib(GL_TEXTURE_BIT); + + glGenTextures(1, &texture); + glBindTexture(GL_TEXTURE_2D, texture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + if (GLEW_ARB_texture_border_clamp) { + const GLfloat borderColor[4] = { 1.0f,1.0f,1.0f,0.0f }; + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); + } else { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + } + + glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 1, 1, 0, GL_ALPHA, GL_UNSIGNED_BYTE, NULL); + + texWidth = wantedTexWidth = width; + texHeight = wantedTexHeight = height; + glPopAttrib(); + + atlasUpdate = new CBitmap(); + atlasUpdate->channels = 1; + atlasUpdate->Alloc(texWidth, texHeight); + + textureSpaceMatrix = glGenLists(1); + glNewList(textureSpaceMatrix, GL_COMPILE); + glEndList(); +#endif +} + + +void CFontTexture::UpdateTexture() +{ +#ifndef HEADLESS + std::lock_guard lk(m); + if (curTextureUpdate == lastTextureUpdate) return; + lastTextureUpdate = curTextureUpdate; + texWidth = wantedTexWidth; + texHeight = wantedTexHeight; + + // merge shadowing + if (atlasUpdateShadow) { + atlasUpdateShadow->Blur(outlineSize, outlineWeight); + assert((atlasUpdate->xsize * atlasUpdate->ysize) % 4 == 0); + auto src = reinterpret_cast(atlasUpdateShadow->mem); + auto dst = reinterpret_cast(atlasUpdate->mem); + auto size = (atlasUpdate->xsize * atlasUpdate->ysize) / 4; + for (int i=0; imem); + + // update texture space dlist (this affects already compiled dlists too!) + glNewList(textureSpaceMatrix, GL_COMPILE); + glScalef(1.f/texWidth, 1.f/texHeight, 1.f); + glEndList(); + glPopAttrib(); +#endif +} diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Fonts/CFontTexture.h spring-98.0~14.04~ppa6/rts/Rendering/Fonts/CFontTexture.h --- spring-96.0~14.04~ppa4/rts/Rendering/Fonts/CFontTexture.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Fonts/CFontTexture.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,142 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef _CFONTTEXTURE_H +#define _CFONTTEXTURE_H +#include +#include +#include +#include +#include +#include "Rendering/Textures/IAtlasAllocator.h" +#include "Rendering/Textures/RowAtlasAlloc.h" + + +struct FT_FaceRec_; +typedef struct FT_FaceRec_* FT_Face; +class CBitmap; +struct FontFace; + + +struct IGlyphRect { //FIXME use SRect or float4 + IGlyphRect(): + x(0),y(0), + w(0),h(0) { + }; + + IGlyphRect(float _x,float _y,float _w,float _h): + x(_x),y(_y), + w(_w),h(_h) { + }; + + float x0() const { + return x; + }; + float x1() const { + return x+w; + }; + float y0() const { + return y; + }; + float y1() const { + return y+h; + }; + + float x,y; + float w,h; +}; + +struct GlyphInfo { + GlyphInfo() + : advance(0) + , height(0) + , descender(0) + , index(0) + , utf16(0) + , face(NULL) + { }; + + IGlyphRect size; + IGlyphRect texCord; + IGlyphRect shadowTexCord; + float advance, height, descender; + unsigned index; + char32_t utf16; + FT_Face face; +}; + + + +/** +This class just store glyphs and load new glyphs if requred +It works with image and don't care about rendering these glyphs +It works only and only with UTF32 chars +**/ +class CFontTexture +{ +public: + static void Update(); + +public: + CFontTexture(const std::string& fontfile, int size, int outlinesize, float outlineweight); + virtual ~CFontTexture(); + +public: + int GetSize() const { return fontSize; } + int GetTextureWidth() const { return texWidth; } + int GetTextureHeight() const { return texHeight; } + int GetOutlineWidth() const { return outlineSize; } + float GetOutlineWeight() const { return outlineWeight; } + float GetLineHeight() const { return lineHeight; } + float GetDescender() const { return fontDescender; } + int GetTexture() const { return texture; } + const std::string& GetFamily() const { return fontFamily; } + const std::string& GetStyle() const { return fontStyle; } + + const GlyphInfo& GetGlyph(char32_t ch); //< Get or load a glyph + +protected: + float GetKerning(const GlyphInfo& lgl,const GlyphInfo& rgl); + void UpdateTexture(); + +private: + void CreateTexture(const int width, const int height); + + // Load all chars in block's range + void LoadBlock(char32_t start, char32_t end); + void LoadGlyph(std::shared_ptr& f, char32_t ch, unsigned index); + +protected: + std::unordered_map glyphs; // UTF16 -> GlyphInfo + + float kerningPrecached[128 * 128]; // contains ASCII kerning + std::unordered_map kerningDynamic; // contains unicode kerning + + int outlineSize; + float outlineWeight; + float lineHeight; + float fontDescender; + float normScale; + int fontSize; + std::string fontFamily; + std::string fontStyle; + int texWidth, texHeight; + int wantedTexWidth, wantedTexHeight; + unsigned int texture; + +public: + unsigned int textureSpaceMatrix; + +private: + CBitmap* atlasUpdate; + CBitmap* atlasUpdateShadow; + int lastTextureUpdate; + int curTextureUpdate; + + FT_Face face; + std::shared_ptr shFace; + std::unordered_set> usedFallbackFonts; + + CRowAtlasAlloc atlasAlloc; +}; + +#endif // CFONTTEXTURE_H diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Fonts/FontLogSection.h spring-98.0~14.04~ppa6/rts/Rendering/Fonts/FontLogSection.h --- spring-96.0~14.04~ppa4/rts/Rendering/Fonts/FontLogSection.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Fonts/FontLogSection.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,18 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef _FONT_LOG_H_ +#define _FONT_LOG_H_ + +#define LOG_SECTION_FONT "Font" + +// use the specific section for all LOG*() calls in this source file +#ifdef LOG_SECTION_CURRENT + #undef LOG_SECTION_CURRENT +#endif +#define LOG_SECTION_CURRENT LOG_SECTION_FONT + +#include "System/Log/ILog.h" + +LOG_REGISTER_SECTION_GLOBAL(LOG_SECTION_FONT) + +#endif // _FONT_LOG_H_ diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Fonts/glFont.cpp spring-98.0~14.04~ppa6/rts/Rendering/Fonts/glFont.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Fonts/glFont.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Fonts/glFont.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,955 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + + +#include "glFont.h" +#include "FontLogSection.h" +#include +#include + +#include "Game/Camera.h" +#include "Rendering/GlobalRendering.h" +#include "Rendering/GL/VertexArray.h" +#include "System/Log/ILog.h" +#include "System/Color.h" +#include "System/Exceptions.h" +#include "System/myMath.h" +#include "System/Util.h" + +#undef GetCharWidth // winapi.h + + + +/*******************************************************************************/ +/*******************************************************************************/ + +CglFont* font = nullptr; +CglFont* smallFont = nullptr; + +static const unsigned char nullChar = 0; +static const float4 white(1.00f, 1.00f, 1.00f, 0.95f); +static const float4 darkOutline(0.05f, 0.05f, 0.05f, 0.95f); +static const float4 lightOutline(0.95f, 0.95f, 0.95f, 0.8f); + +static const float darkLuminosity = 0.05 + + 0.2126f * math::powf(darkOutline[0], 2.2) + + 0.7152f * math::powf(darkOutline[1], 2.2) + + 0.0722f * math::powf(darkOutline[2], 2.2); + +/*******************************************************************************/ +/*******************************************************************************/ + +CglFont::CglFont(const std::string& fontfile, int size, int _outlinewidth, float _outlineweight) +: CTextWrap(fontfile,size,_outlinewidth,_outlineweight) +, fontPath(fontfile) +, inBeginEnd(false) +, autoOutlineColor(true) +, setColor(false) +{ + va = new CVertexArray(); + va2 = new CVertexArray(); + + textColor = white; + outlineColor = darkOutline; +} + +CglFont* CglFont::LoadFont(const std::string& fontFile, int size, int outlinewidth, float outlineweight) +{ + try { + CglFont* newFont = new CglFont(fontFile, size, outlinewidth, outlineweight); + return newFont; + } catch (const content_error& ex) { + LOG_L(L_ERROR, "Failed creating font: %s", ex.what()); + return NULL; + } +} + + +CglFont::~CglFont() +{ + delete va; + delete va2; +} + + +/*******************************************************************************/ +/*******************************************************************************/ + +template +static inline int SkipColorCodes(const std::u8string& text, T pos) +{ + while (text[pos] == CglFont::ColorCodeIndicator) { + pos += 4; + if (pos >= text.size()) { return -1; } + } + return pos; +} + + +template +static inline bool SkipColorCodesAndNewLines(const std::u8string& text, T* pos, float4* color, bool* colorChanged, int* skippedLines, float4* colorReset) +{ + const size_t length = text.length(); + (*colorChanged) = false; + (*skippedLines) = 0; + while (*pos < length) { + const char8_t& chr = text[*pos]; + switch(chr) { + case CglFont::ColorCodeIndicator: + *pos += 4; + if ((*pos) < length) { + (*color)[0] = text[(*pos) - 3] / 255.0f; + (*color)[1] = text[(*pos) - 2] / 255.0f; + (*color)[2] = text[(*pos) - 1] / 255.0f; + *colorChanged = true; + } + break; + + case CglFont::ColorResetIndicator: + (*pos)++; + (*color) = *colorReset; + *colorChanged = true; + break; + + case 0x0d: // CR + (*skippedLines)++; + (*pos)++; + if (*pos < length && text[*pos] == 0x0a) { // CR+LF + (*pos)++; + } + break; + + case 0x0a: // LF + (*skippedLines)++; + (*pos)++; + break; + + default: + return false; + } + } + return true; +} + + +static inline void TextStripCallback(void* data) +{ + CglFont::ColorMap::iterator& sci = *reinterpret_cast(data); + glColor4fv(*sci++); +} + + +/*******************************************************************************/ +/*******************************************************************************/ + +std::string CglFont::StripColorCodes_(const std::u8string& text) +{ + const size_t len = text.size(); + + std::string nocolor; + nocolor.reserve(len); + for (int i = 0; i < len; i++) { + if (text[i] == ColorCodeIndicator) { + i += 3; + } else { + nocolor += text[i]; + } + } + return nocolor; +} + + +float CglFont::GetCharacterWidth(const char32_t c) +{ + return GetGlyph(c).advance; +} + + +float CglFont::GetTextWidth_(const std::u8string& text) +{ + if (text.empty()) return 0.0f; + + float w = 0.0f; + float maxw = 0.0f; + + const GlyphInfo* prv_g=NULL; + const GlyphInfo* cur_g; + + int pos = 0; + while (pos < text.length()) { + const char32_t u = Utf8GetNextChar(text, pos); + + switch (u) { + // inlined colorcode + case ColorCodeIndicator: + pos = SkipColorCodes(text, pos - 1); + if (pos<0) { + pos = text.length(); + } + break; + + // reset color + case ColorResetIndicator: + break; + + // newline + case 0x0d: // CR+LF + if (pos < text.length() && text[pos] == 0x0a) + pos++; + case 0x0a: // LF + if (prv_g) + w += prv_g->advance; + if (w > maxw) + maxw = w; + w = 0.0f; + prv_g = NULL; + break; + + // printable char + default: + cur_g = &GetGlyph(u); + if (prv_g) w += GetKerning(*prv_g, *cur_g); + prv_g = cur_g; + } + } + + if (prv_g) + w += prv_g->advance; + if (w > maxw) + maxw = w; + + return maxw; +} + + +float CglFont::GetTextHeight_(const std::u8string& text, float* descender, int* numLines) +{ + if (text.empty()) { + if (descender) *descender = 0.0f; + if (numLines) *numLines = 0; + return 0.0f; + } + + float h = 0.0f, d = GetLineHeight() + GetDescender(); + unsigned int multiLine = 1; + + int pos = 0; + while (pos < text.length()) { + const char32_t u = Utf8GetNextChar(text, pos); + switch(u) { + // inlined colorcode + case ColorCodeIndicator: + pos = SkipColorCodes(text, pos - 1); + if (pos<0) { + pos = text.length(); + } + break; + + // reset color + case ColorResetIndicator: + break; + + // newline + case 0x0d: // CR+LF + if (pos < text.length() && text[pos] == 0x0a) + ++pos; + case 0x0a: // LF + multiLine++; + d = GetLineHeight() + GetDescender(); + break; + + // printable char + default: + const GlyphInfo& g = GetGlyph(u); + if (g.descender < d) d = g.descender; + if (multiLine < 2 && g.height > h) h = g.height; // only calc height for the first line + } + } + + if (multiLine>1) d -= (multiLine-1) * GetLineHeight(); + if (descender) *descender = d; + if (numLines) *numLines = multiLine; + + return h; +} + + +int CglFont::GetTextNumLines_(const std::u8string& text) +{ + if (text.empty()) + return 0; + + int lines = 1; + + for (int pos = 0 ; pos < text.length(); pos++) { + const char8_t& c = text[pos]; + switch(c) { + // inlined colorcode + case ColorCodeIndicator: + pos = SkipColorCodes(text, pos); + if (pos<0) { + pos = text.length(); + } else { + pos--; + } + break; + + // reset color + case ColorResetIndicator: + break; + + // newline + case 0x0d: + if (pos+1 < text.length() && text[pos+1] == 0x0a) + pos++; + case 0x0a: + lines++; + break; + + //default: + } + } + + return lines; +} + + +std::list CglFont::SplitIntoLines(const std::u8string& text) +{ + std::list lines; + + if (text.empty()) + return lines; + + lines.push_back(""); + std::list colorCodeStack; + for (int pos = 0 ; pos < text.length(); pos++) { + const char8_t& c = text[pos]; + switch(c) { + // inlined colorcode + case ColorCodeIndicator: + if ((pos + 3) < text.length()) { + colorCodeStack.push_back(text.substr(pos, 4)); + lines.back() += colorCodeStack.back(); + pos += 3; + } + break; + + // reset color + case ColorResetIndicator: + colorCodeStack.pop_back(); + lines.back() += c; + break; + + // newline + case 0x0d: + if (pos+1 < text.length() && text[pos+1] == 0x0a) + pos++; + case 0x0a: + lines.push_back(""); + for (auto& color: colorCodeStack) + lines.back() = color; + break; + + default: + lines.back() += c; + } + } + + return lines; +} + + +/*******************************************************************************/ +/*******************************************************************************/ + +void CglFont::SetAutoOutlineColor(bool enable) +{ + autoOutlineColor = enable; +} + + +void CglFont::SetTextColor(const float4* color) +{ + if (color == NULL) color = &white; + + if (inBeginEnd && !(*color==textColor)) { + if (va->drawIndex() == 0 && !stripTextColors.empty()) { + stripTextColors.back() = *color; + } else { + stripTextColors.push_back(*color); + va->EndStrip(); + } + } + + textColor = *color; +} + + +void CglFont::SetOutlineColor(const float4* color) +{ + if (color == NULL) color = ChooseOutlineColor(textColor); + + if (inBeginEnd && !(*color==outlineColor)) { + if (va2->drawIndex() == 0 && !stripOutlineColors.empty()) { + stripOutlineColors.back() = *color; + } else { + stripOutlineColors.push_back(*color); + va2->EndStrip(); + } + } + + outlineColor = *color; +} + + +void CglFont::SetColors(const float4* _textColor, const float4* _outlineColor) +{ + SetTextColor(_textColor); + SetOutlineColor(_outlineColor); +} + + +const float4* CglFont::ChooseOutlineColor(const float4& textColor) +{ + const float luminosity = 0.05 + + 0.2126f * math::powf(textColor[0], 2.2) + + 0.7152f * math::powf(textColor[1], 2.2) + + 0.0722f * math::powf(textColor[2], 2.2); + + const float lumdiff = std::max(luminosity,darkLuminosity) / std::min(luminosity,darkLuminosity); + if (lumdiff > 5.0f) { + return &darkOutline; + } else { + return &lightOutline; + } +} + + +/*******************************************************************************/ +/*******************************************************************************/ + +void CglFont::Begin(const bool immediate, const bool resetColors) +{ + if (inBeginEnd) { + LOG_L(L_ERROR, "called Begin() multiple times"); + return; + } + + autoOutlineColor = true; + + setColor = !immediate; + if (resetColors) { + SetColors(); // reset colors + } + + inBeginEnd = true; + + va->Initialize(); + va2->Initialize(); + stripTextColors.clear(); + stripOutlineColors.clear(); + stripTextColors.push_back(textColor); + stripOutlineColors.push_back(outlineColor); + + glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT); + glDisable(GL_LIGHTING); + glDisable(GL_DEPTH_TEST); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +} + + +void CglFont::End() +{ + if (!inBeginEnd) { + LOG_L(L_ERROR, "called End() without Begin()"); + return; + } + inBeginEnd = false; + + if (va->drawIndex() == 0) { + glPopAttrib(); + return; + } + + GLboolean inListCompile; + glGetBooleanv(GL_LIST_INDEX, &inListCompile); + if (!inListCompile) { + UpdateTexture(); + } + + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, GetTexture()); + + // Because texture size can change, texture coordinats are absolute in texels. + // We could use also just use GL_TEXTURE_RECTANGLE + // but then all shaders would need to detect so and use different funcs & types if supported -> more work + glMatrixMode(GL_TEXTURE); + glPushMatrix(); + glCallList(textureSpaceMatrix); + glMatrixMode(GL_MODELVIEW); + + if (va2->drawIndex() > 0) { + if (stripOutlineColors.size() > 1) { + ColorMap::iterator sci = stripOutlineColors.begin(); + va2->DrawArray2dT(GL_QUADS,TextStripCallback,&sci); + } else { + glColor4fv(outlineColor); + va2->DrawArray2dT(GL_QUADS); + } + } + + if (stripTextColors.size() > 1) { + ColorMap::iterator sci = stripTextColors.begin(); + va->DrawArray2dT(GL_QUADS,TextStripCallback,&sci);//FIXME calls a 0 length strip! + } else { + if (setColor) glColor4fv(textColor); + va->DrawArray2dT(GL_QUADS); + } + + // pop texture matrix + glMatrixMode(GL_TEXTURE); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + + glPopAttrib(); +} + + +/*******************************************************************************/ +/*******************************************************************************/ + +void CglFont::RenderString(float x, float y, const float& scaleX, const float& scaleY, const std::string& str) +{ + /** + * NOTE: + * Font rendering does not use display lists, but VAs. It's actually faster + * (450% faster with a 7600GT!) for these reasons: + * + * 1. When using DLs, we can not group multiple glyphs into one glBegin/End pair + * because glTranslatef can not go between such a pair. + * 2. We can now eliminate all glPushMatrix/PopMatrix pairs related to font rendering + * because the transformations are calculated on the fly. These are just a couple of + * floating point multiplications and shouldn't be too expensive. + */ + + const float startx = x; + const float lineHeight_ = scaleY * GetLineHeight(); + unsigned int length = (unsigned int)str.length(); + const std::u8string& ustr = toustring(str); + + va->EnlargeArrays(length * 4, 0, VA_SIZE_2DT); + + int skippedLines; + bool colorChanged; + const GlyphInfo* g = NULL; + float4 newColor = textColor; + char32_t c; + int i = 0; + + do { + const bool endOfString = SkipColorCodesAndNewLines(ustr, &i, &newColor, &colorChanged, &skippedLines, &baseTextColor); + + if (endOfString) + return; + + c = Utf8GetNextChar(str,i); + + if (colorChanged) { + if (autoOutlineColor) { + SetColors(&newColor,NULL); + } else { + SetTextColor(&newColor); + } + } + const GlyphInfo* c_g = &GetGlyph(c); + if (skippedLines>0) { + x = startx; + y -= skippedLines * lineHeight_; + } else if (g) { + x += scaleX * GetKerning(*g, *c_g); + } + + g = c_g; + + const auto& tc = g->texCord; + const float dx0 = (scaleX * g->size.x0()) + x, dy0 = (scaleY * g->size.y0()) + y; + const float dx1 = (scaleX * g->size.x1()) + x, dy1 = (scaleY * g->size.y1()) + y; + + va->AddVertexQ2dT(dx0, dy1, tc.x0(), tc.y1()); + va->AddVertexQ2dT(dx0, dy0, tc.x0(), tc.y0()); + va->AddVertexQ2dT(dx1, dy0, tc.x1(), tc.y0()); + va->AddVertexQ2dT(dx1, dy1, tc.x1(), tc.y1()); + } while(true); +} + + +void CglFont::RenderStringShadow(float x, float y, const float& scaleX, const float& scaleY, const std::string& str) +{ + const float shiftX = scaleX*0.1, shiftY = scaleY*0.1; + const float ssX = (scaleX/fontSize) * GetOutlineWidth(), ssY = (scaleY/fontSize) * GetOutlineWidth(); + + const float startx = x; + const float lineHeight_ = scaleY * GetLineHeight(); + unsigned int length = (unsigned int)str.length(); + const std::u8string& ustr = toustring(str); + + va->EnlargeArrays(length * 4, 0, VA_SIZE_2DT); + va2->EnlargeArrays(length * 4, 0, VA_SIZE_2DT); + + int skippedLines; + bool colorChanged; + const GlyphInfo* g = NULL; + float4 newColor = textColor; + char32_t c; + int i = 0; + + do { + const bool endOfString = SkipColorCodesAndNewLines(ustr, &i, &newColor, &colorChanged, &skippedLines, &baseTextColor); + + if (endOfString) + return; + + c = Utf8GetNextChar(str,i); + + if (colorChanged) { + if (autoOutlineColor) { + SetColors(&newColor,NULL); + } else { + SetTextColor(&newColor); + } + } + + const GlyphInfo* c_g = &GetGlyph(c); + if (skippedLines>0) { + x = startx; + y -= skippedLines * lineHeight_; + } else if (g) { + x += scaleX * GetKerning(*g, *c_g); + } + + g = c_g; + + const auto& tc = g->texCord; + const auto& stc = g->shadowTexCord; + const float dx0 = (scaleX * g->size.x0()) + x, dy0 = (scaleY * g->size.y0()) + y; + const float dx1 = (scaleX * g->size.x1()) + x, dy1 = (scaleY * g->size.y1()) + y; + + // draw shadow + va2->AddVertexQ2dT(dx0+shiftX-ssX, dy1-shiftY-ssY, stc.x0(), stc.y1()); + va2->AddVertexQ2dT(dx0+shiftX-ssX, dy0-shiftY+ssY, stc.x0(), stc.y0()); + va2->AddVertexQ2dT(dx1+shiftX+ssX, dy0-shiftY+ssY, stc.x1(), stc.y0()); + va2->AddVertexQ2dT(dx1+shiftX+ssX, dy1-shiftY-ssY, stc.x1(), stc.y1()); + + // draw the actual character + va->AddVertexQ2dT(dx0, dy1, tc.x0(), tc.y1()); + va->AddVertexQ2dT(dx0, dy0, tc.x0(), tc.y0()); + va->AddVertexQ2dT(dx1, dy0, tc.x1(), tc.y0()); + va->AddVertexQ2dT(dx1, dy1, tc.x1(), tc.y1()); + } while(true); +} + +void CglFont::RenderStringOutlined(float x, float y, const float& scaleX, const float& scaleY, const std::string& str) +{ + const float shiftX = (scaleX/fontSize) * GetOutlineWidth(), shiftY = (scaleY/fontSize) * GetOutlineWidth(); + + const float startx = x; + const float lineHeight_ = scaleY * GetLineHeight(); + const std::u8string& ustr = toustring(str); + const size_t length = str.length(); + + va->EnlargeArrays(length * 4, 0, VA_SIZE_2DT); + va2->EnlargeArrays(length * 4, 0, VA_SIZE_2DT); + + int skippedLines; + bool colorChanged; + const GlyphInfo* g = NULL; + float4 newColor = textColor; + char32_t c; + int i = 0; + + do { + const bool endOfString = SkipColorCodesAndNewLines(ustr, &i, &newColor, &colorChanged, &skippedLines, &baseTextColor); + + if (endOfString) + return; + + c = Utf8GetNextChar(str,i); + + if (colorChanged) { + if (autoOutlineColor) { + SetColors(&newColor,NULL); + } else { + SetTextColor(&newColor); + } + } + + const GlyphInfo* c_g = &GetGlyph(c); + if (skippedLines>0) { + x = startx; + y -= skippedLines * lineHeight_; + } else if (g) { + x += scaleX * GetKerning(*g, *c_g); + } + + g = c_g; + + const auto& tc = g->texCord; + const auto& stc = g->shadowTexCord; + const float dx0 = (scaleX * g->size.x0()) + x, dy0 = (scaleY * g->size.y0()) + y; + const float dx1 = (scaleX * g->size.x1()) + x, dy1 = (scaleY * g->size.y1()) + y; + + // draw outline + va2->AddVertexQ2dT(dx0-shiftX, dy1-shiftY, stc.x0(), stc.y1()); + va2->AddVertexQ2dT(dx0-shiftX, dy0+shiftY, stc.x0(), stc.y0()); + va2->AddVertexQ2dT(dx1+shiftX, dy0+shiftY, stc.x1(), stc.y0()); + va2->AddVertexQ2dT(dx1+shiftX, dy1-shiftY, stc.x1(), stc.y1()); + + // draw the actual character + va->AddVertexQ2dT(dx0, dy1, tc.x0(), tc.y1()); + va->AddVertexQ2dT(dx0, dy0, tc.x0(), tc.y0()); + va->AddVertexQ2dT(dx1, dy0, tc.x1(), tc.y0()); + va->AddVertexQ2dT(dx1, dy1, tc.x1(), tc.y1()); + } while(true); +} + + +void CglFont::glWorldPrint(const float3& p, const float size, const std::string& str) +{ + glPushMatrix(); + glTranslatef(p.x, p.y, p.z); + glMultMatrixf(camera->GetBillBoardMatrix()); + Begin(false, false); + glPrint(0.0f, 0.0f, size, FONT_DESCENDER | FONT_CENTER | FONT_OUTLINE, str); + End(); + glPopMatrix(); +} + + +void CglFont::glPrint(float x, float y, float s, const int options, const std::string& text) +{ + // s := scale or absolute size? + if (options & FONT_SCALE) { + s *= fontSize; + } + + float sizeX = s, sizeY = s; + + // render in normalized coords (0..1) instead of screencoords (0..~1024) + if (options & FONT_NORM) { + sizeX *= globalRendering->pixelX; + sizeY *= globalRendering->pixelY; + } + + // horizontal alignment (FONT_LEFT is default) + if (options & FONT_CENTER) { + x -= sizeX * 0.5f * GetTextWidth(text); + } else if (options & FONT_RIGHT) { + x -= sizeX * GetTextWidth(text); + } + + + // vertical alignment + y += sizeY * GetDescender(); // move to baseline (note: descender is negative) + if (options & FONT_BASELINE) { + // nothing + } else if (options & FONT_DESCENDER) { + y -= sizeY * GetDescender(); + } else if (options & FONT_VCENTER) { + float textDescender; + y -= sizeY * 0.5f * GetTextHeight(text,&textDescender); + y -= sizeY * 0.5f * textDescender; + } else if (options & FONT_TOP) { + y -= sizeY * GetTextHeight(text); + } else if (options & FONT_ASCENDER) { + y -= sizeY * GetDescender(); + y -= sizeY; + } else if (options & FONT_BOTTOM) { + float textDescender; + GetTextHeight(text,&textDescender); + y -= sizeY * textDescender; + } + + if (options & FONT_NEAREST) { + x = (int)x; + y = (int)y; + } + + // backup text & outline colors (also ::ColorResetIndicator will reset to those) + baseTextColor = textColor; + baseOutlineColor = outlineColor; + + // immediate mode? + const bool immediate = !inBeginEnd; + if (immediate) { + Begin(!(options & (FONT_OUTLINE | FONT_SHADOW))); + } + + + // select correct decoration RenderString function + if (options & FONT_OUTLINE) { + RenderStringOutlined(x, y, sizeX, sizeY, text); + } else if (options & FONT_SHADOW) { + RenderStringShadow(x, y, sizeX, sizeY, text); + } else { + RenderString(x, y, sizeX, sizeY, text); + } + + + // immediate mode? + if (immediate) { + End(); + } + + // reset text & outline colors (if changed via in text colorcodes) + SetColors(&baseTextColor,&baseOutlineColor); +} + +void CglFont::glPrintTable(float x, float y, float s, const int options, const std::string& text) +{ + std::vector coltext; + coltext.push_back(""); + + std::vector colColor; + SColor defaultcolor(0,0,0); + defaultcolor[0] = ColorCodeIndicator; + for (int i = 0; i < 3; ++i) + defaultcolor[i+1] = (unsigned char)(textColor[i] * 255.0f); + colColor.push_back(defaultcolor); + SColor curcolor(defaultcolor); + + int col = 0; + int row = 0; + for (int pos = 0; pos < text.length(); pos++) { + const unsigned char& c = text[pos]; + switch(c) { + // inline colorcodes + case ColorCodeIndicator: + for (int i = 0; i < 4 && pos < text.length(); ++i, ++pos) { + coltext[col] += text[pos]; + curcolor[i] = text[pos]; + } + colColor[col] = curcolor; + --pos; + break; + + // column separator is `\t`==`horizontal tab` + case '\t': + ++col; + if (col >= coltext.size()) { + coltext.push_back(""); + for(int i = 0; i < row; ++i) + coltext[col] += 0x0a; + colColor.push_back(defaultcolor); + } + if (colColor[col] != curcolor) { + for(int i = 0; i < 4; ++i) + coltext[col] += curcolor[i]; + colColor[col] = curcolor; + } + break; + + // newline + case 0x0d: // CR+LF + if (pos+1 < text.length() && text[pos + 1] == 0x0a) + pos++; + case 0x0a: // LF + for (int i = 0; i < coltext.size(); ++i) + coltext[i] += 0x0a; + if (colColor[0] != curcolor) { + for(int i = 0; i < 4; ++i) + coltext[0] += curcolor[i]; + colColor[0] = curcolor; + } + col = 0; + ++row; + break; + + // printable char + default: + coltext[col] += c; + } + } + + float totalWidth = 0.0f; + float maxHeight = 0.0f; + float minDescender = 0.0f; + std::vector colWidths(coltext.size(), 0.0f); + for (int i = 0; i < coltext.size(); ++i) { + float colwidth = GetTextWidth(coltext[i]); + colWidths[i] = colwidth; + totalWidth += colwidth; + float textDescender; + float textHeight = GetTextHeight(coltext[i], &textDescender); + if (textHeight > maxHeight) + maxHeight = textHeight; + if (textDescender < minDescender) + minDescender = textDescender; + } + + // s := scale or absolute size? + float ss = s; + if (options & FONT_SCALE) { + ss *= fontSize; + } + + float sizeX = ss, sizeY = ss; + + // render in normalized coords (0..1) instead of screencoords (0..~1024) + if (options & FONT_NORM) { + sizeX *= globalRendering->pixelX; + sizeY *= globalRendering->pixelY; + } + + // horizontal alignment (FONT_LEFT is default) + if (options & FONT_CENTER) { + x -= sizeX * 0.5f * totalWidth; + } else if (options & FONT_RIGHT) { + x -= sizeX * totalWidth; + } + + // vertical alignment + if (options & FONT_BASELINE) { + // nothing + } else if (options & FONT_DESCENDER) { + y -= sizeY * GetDescender(); + } else if (options & FONT_VCENTER) { + y -= sizeY * 0.5f * maxHeight; + y -= sizeY * 0.5f * minDescender; + } else if (options & FONT_TOP) { + y -= sizeY * maxHeight; + } else if (options & FONT_ASCENDER) { + y -= sizeY * GetDescender(); + y -= sizeY; + } else if (options & FONT_BOTTOM) { + y -= sizeY * minDescender; + } + + for (int i = 0; i < coltext.size(); ++i) { + glPrint(x, y, s, (options | FONT_BASELINE) & ~(FONT_RIGHT | FONT_CENTER), coltext[i]); + x += sizeX * colWidths[i]; + } +} + + +// macro for formatting printf-style +#define FORMAT_STRING(lastarg,fmt,out) \ + char out[512]; \ + va_list ap; \ + if (fmt == NULL) return; \ + va_start(ap, lastarg); \ + VSNPRINTF(out, sizeof(out), fmt, ap); \ + va_end(ap); + +void CglFont::glFormat(float x, float y, float s, const int options, const char* fmt, ...) +{ + FORMAT_STRING(fmt,fmt,text); + glPrint(x, y, s, options, std::string(text)); +} + + +void CglFont::glFormat(float x, float y, float s, const int options, const std::string& fmt, ...) +{ + FORMAT_STRING(fmt,fmt.c_str(),text); + glPrint(x, y, s, options, std::string(text)); +} diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Fonts/glFont.h spring-98.0~14.04~ppa6/rts/Rendering/Fonts/glFont.h --- spring-96.0~14.04~ppa4/rts/Rendering/Fonts/glFont.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Fonts/glFont.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,147 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef _GLFONT_H +#define _GLFONT_H + +#include +#include + +#include "System/float4.h" +#include "TextWrap.h" +#include "ustring.h" + +#undef GetCharWidth // winapi.h + +static const int FONT_LEFT = 1 << 0; +static const int FONT_RIGHT = 1 << 1; +static const int FONT_CENTER = 1 << 2; +static const int FONT_BASELINE = 1 << 3; //! align to face baseline +static const int FONT_VCENTER = 1 << 4; +static const int FONT_TOP = 1 << 5; //! align to text ascender +static const int FONT_BOTTOM = 1 << 6; //! align to text descender +static const int FONT_ASCENDER = 1 << 7; //! align to face ascender +static const int FONT_DESCENDER= 1 << 8; //! align to face descender + +static const int FONT_OUTLINE = 1 << 9; +static const int FONT_SHADOW = 1 << 10; +static const int FONT_NORM = 1 << 11; //! render in 0..1 space instead of 0..vsx|vsy +static const int FONT_SCALE = 1 << 12; //! given size argument will be treated as scaling and not absolute fontsize + +static const int FONT_NEAREST = 1 << 13; //! round x,y render pos to nearest integer, so there is no interpolation blur for small fontsizes + + +class CVertexArray; + + +class CglFont : public CTextWrap +{ +public: + static CglFont* LoadFont(const std::string& fontFile, int size, int outlinewidth = 2, float outlineweight = 5.0f); + CglFont(const std::string& fontfile, int size, int outlinewidth, float outlineweight); + virtual ~CglFont(); + + //! The calling of Begin() .. End() is optional, + //! but can increase the performance of drawing multiple strings a lot (upto 10x) + void Begin(const bool immediate = false, const bool resetColors = true); + void End(); + + void glWorldPrint(const float3& p, const float size, const std::string& str); + /** + * @param s absolute font size, or relative scale, if option FONT_SCALE is set + * @param options FONT_SCALE | FONT_NORM | + * (FONT_LEFT | FONT_CENTER | FONT_RIGHT) | + * (FONT_BASELINE | FONT_DESCENDER | FONT_VCENTER | + * FONT_TOP | FONT_ASCENDER | FONT_BOTTOM) | + * FONT_NEAREST | FONT_OUTLINE | FONT_SHADOW + */ + void glPrint(float x, float y, float s, const int options, const std::string& str); + void glPrintTable(float x, float y, float s, const int options, const std::string& str); + void glFormat(float x, float y, float s, const int options, const std::string& fmt, ...); + void glFormat(float x, float y, float s, const int options, const char* fmt, ...); + + void SetAutoOutlineColor(bool enable); //! auto select outline color for in-text-colorcodes + void SetTextColor(const float4* color = NULL); + void SetOutlineColor(const float4* color = NULL); + void SetColors(const float4* textColor = NULL, const float4* outlineColor = NULL); + void SetTextColor(const float& r, const float& g, const float& b, const float& a) { const float4 f = float4(r,g,b,a); SetTextColor(&f); }; + void SetOutlineColor(const float& r, const float& g, const float& b, const float& a) { const float4 f = float4(r,g,b,a); SetOutlineColor(&f); }; + + float GetCharacterWidth(const char32_t c); +#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 6) + #define _final +#else + #define _final final +#endif + inline float GetTextWidth(const std::string& text) _final; +#undef _final + inline float GetTextHeight(const std::string& text, float* descender = NULL, int* numLines = NULL); + inline static int GetTextNumLines(const std::string& text); + inline static std::string StripColorCodes(const std::string& text); + static std::list SplitIntoLines(const std::u8string&); + + const std::string& GetFilePath() const { return fontPath; } + + static const char8_t ColorCodeIndicator = 0xFF; + static const char8_t ColorResetIndicator = 0x08; //! =: '\\b' + +private: + static const float4* ChooseOutlineColor(const float4& textColor); + + void RenderString(float x, float y, const float& scaleX, const float& scaleY, const std::string& str); + void RenderStringShadow(float x, float y, const float& scaleX, const float& scaleY, const std::string& str); + void RenderStringOutlined(float x, float y, const float& scaleX, const float& scaleY, const std::string& str); + +private: + float GetTextWidth_(const std::u8string& text); + float GetTextHeight_(const std::u8string& text, float* descender = NULL, int* numLines = NULL); + static int GetTextNumLines_(const std::u8string& text); + static std::string StripColorCodes_(const std::u8string& text); + +public: + typedef std::vector ColorMap; + +private: + std::string fontPath; + + ColorMap stripTextColors; + ColorMap stripOutlineColors; + + CVertexArray* va; + CVertexArray* va2; + + bool inBeginEnd; + bool autoOutlineColor; //! auto select outline color for in-text-colorcodes + bool setColor; //! used for backward compability (so you can call glPrint (w/o BeginEnd and no shadow/outline!) and set the color yourself via glColor) + + float4 textColor; + float4 outlineColor; + + //! \::ColorResetIndicator will reset to those (they are the colors set when glPrint was called) + float4 baseTextColor; + float4 baseOutlineColor; +}; + + +extern CglFont* font; +extern CglFont* smallFont; + + +// wrappers +float CglFont::GetTextWidth(const std::string& text) +{ + return GetTextWidth_(toustring(text)); +} +float CglFont::GetTextHeight(const std::string& text, float* descender, int* numLines) +{ + return GetTextHeight_(toustring(text), descender, numLines); +} +int CglFont::GetTextNumLines(const std::string& text) +{ + return GetTextNumLines_(toustring(text)); +} +std::string CglFont::StripColorCodes(const std::string& text) +{ + return StripColorCodes_(toustring(text)); +} + +#endif /* _GLFONT_H */ diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Fonts/LanguageBlocksDefs.h spring-98.0~14.04~ppa6/rts/Rendering/Fonts/LanguageBlocksDefs.h --- spring-96.0~14.04~ppa4/rts/Rendering/Fonts/LanguageBlocksDefs.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Fonts/LanguageBlocksDefs.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,55 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef LANGUAGEBLOCKSDEFS_H_INCLUDED +#define LANGUAGEBLOCKSDEFS_H_INCLUDED + +#include +#include +#include + +// Predefined blocks +// It contains only the most widly used blocks (Latin and Cyrilic) +static const std::map> blocks { + {"NULL", std::make_tuple(0x0000, 0x0001)}, + {"ASCII", std::make_tuple(0x0020, 0x007F)}, + {"Latin-1", std::make_tuple(0x00A1, 0x0100)}, + {"Latin-A", std::make_tuple(0x0100, 0x0180)}, + {"Latin-B", std::make_tuple(0x0180, 0x0250)}, + {"Greek", std::make_tuple(0x0370, 0x0400)}, + {"Cyrillic", std::make_tuple(0x0400, 0x0500)}, + {"Hebrew", std::make_tuple(0x0590, 0x0600)}, + {"Arabic", std::make_tuple(0x0600, 0x0700)}, + {"FigureSpace", std::make_tuple(0x2007, 0x2008)}, // used by TextWrap + {"Ellipsis", std::make_tuple(0x2026, 0x2027)}, // '' +}; + +static const unsigned int undefBlocksSize = 32; // Any other blocks assumed to be 32 size + +static bool IsInRange(char32_t ch, std::tuple& range) +{ + const auto start = std::get<0>(range); + const auto end = std::get<1>(range); + return (ch < end && ch >= start); +} + +static char32_t GetUndefLanguageBlock(char32_t ch, char32_t& end) +{ + char32_t start = (ch/undefBlocksSize)*undefBlocksSize; + end = start + undefBlocksSize; + return start; +} + + +static char32_t GetLanguageBlock(char32_t ch, char32_t& end) +{ + for (auto it: blocks) { + if (IsInRange(ch, it.second)) { + end = std::get<1>(it.second); + return std::get<0>(it.second); + } + } + + return GetUndefLanguageBlock(ch, end); +} + +#endif // LANGUAGEBLOCKSDEFS_H_INCLUDED diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Fonts/TextWrap.cpp spring-98.0~14.04~ppa6/rts/Rendering/Fonts/TextWrap.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Fonts/TextWrap.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Fonts/TextWrap.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,590 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include "TextWrap.h" +#include "glFont.h" +#include "FontLogSection.h" +#include "System/Log/ILog.h" +#include "System/myMath.h" +#include "System/Util.h" + + +static const char32_t ellipsisUTF16 = 0x2026; +static const std::string ellipsisUTF8 = UnicodeToUtf8(ellipsisUTF16); +static const char32_t spaceUTF16 = 0x20; + + +/*******************************************************************************/ +/*******************************************************************************/ + +template +static inline int SkipColorCodes(const std::u8string& text, T* pos, SColor* color) +{ + int colorFound = 0; + while (text[(*pos)] == CTextWrap::ColorCodeIndicator) { + (*pos) += 4; + if ((*pos) >= text.size()) { + return -(1 + colorFound); + } else { + color->r = text[(*pos)-3]; + color->g = text[(*pos)-2]; + color->b = text[(*pos)-1]; + colorFound = 1; + } + } + return colorFound; +} + + +/*******************************************************************************/ +/*******************************************************************************/ + +CTextWrap::CTextWrap(const std::string& fontfile, int size, int outlinewidth, float outlineweight) +: CFontTexture(fontfile,size,outlinewidth,outlineweight) +{ +} + + +/*******************************************************************************/ +/*******************************************************************************/ + +/** + * @brief IsUpperCase + * @return true if the given char is an uppercase + */ +static inline bool IsUpperCase(const char32_t& c) +{ + // overkill to add unicode + return + (c >= 0x41 && c <= 0x5A) || + (c >= 0xC0 && c <= 0xD6) || + (c >= 0xD8 && c <= 0xDE) || + (c == 0x8A) || + (c == 0x8C) || + (c == 0x8E) || + (c == 0x9F); +} + +static inline bool IsLowerCase(const char32_t& c) +{ + // overkill to add unicode + return c >= 0x61 && c <= 0x7A; // only ascii (no latin-1!) +} + + +/** + * @brief GetPenalty + * @param c character at %strpos% in the word + * @param strpos position of c in the word + * @param strlen total length of the word + * @return penalty (smaller is better) to split a word at that position + */ +static inline float GetPenalty(const char32_t& c, unsigned int strpos, unsigned int strlen) +{ + const float dist = strlen - strpos; + + if (dist > (strlen / 2) && dist < 4) { + return 1e9; + } else if (IsLowerCase(c)) { + // lowercase char + return 1.0f + (strlen - strpos); + } else if (c >= 0x30 && c <= 0x39) { + // is number + return 1.0f + (strlen - strpos)*0.9; + } else if (IsUpperCase(c)) { + // uppercase char + return 1.0f + (strlen - strpos)*0.75; + } else { + // any special chars + return Square(dist / 4); + } + return Square(dist / 4); +} + + +CTextWrap::word CTextWrap::SplitWord(CTextWrap::word& w, float wantedWidth, bool smart) +{ + // returns two pieces 'L'eft and 'R'ight of the split word (returns L, *wi becomes R) + + word w2; + w2.pos = w.pos; + + const float spaceAdvance = GetGlyph(spaceUTF16).advance; + if (w.isLineBreak) { + // shouldn't happen + w2 = w; + w.isSpace = true; + } else if (w.isSpace) { + const int split = (int)math::floor(wantedWidth / spaceAdvance); + w2.isSpace = true; + w2.numSpaces = split; + w2.width = spaceAdvance * w2.numSpaces; + w.numSpaces -= split; + w.width = spaceAdvance * w.numSpaces; + w.pos += split; + } else { + if (smart) { + if ( + (wantedWidth < 8 * spaceAdvance) || + (w.text.length() < 1) + ) { + w2.isSpace = true; + return w2; + } + } + + float width = 0.0f; + int i = 0; + float min_penalty = 1e9; + unsigned int goodbreak = 0; + char32_t c = Utf8GetNextChar(w.text,i); + const GlyphInfo* curGlyph = &GetGlyph(c); + const GlyphInfo* nextGlyph = curGlyph; + + do { + const int lastCharPos = i; + const char32_t co = c; + curGlyph = nextGlyph; + c = Utf8GetNextChar(w.text,i); + nextGlyph = &GetGlyph(c); + width += GetKerning(*curGlyph, *nextGlyph); + + if (width > wantedWidth) { + break; + } + + if (smart) { + const float penalty = GetPenalty(co, lastCharPos, w.text.length()); + if (penalty < min_penalty) { + min_penalty = penalty; + goodbreak = lastCharPos; + } + } else { + goodbreak = i; + } + } while(i < w.text.length()); + + w2.text = toustring(w.text.substr(0,goodbreak)); + w2.width = GetTextWidth(w2.text); + w.text.erase(0,goodbreak); + w.width = GetTextWidth(w.text); + w.pos += goodbreak; + } + return w2; +} + + +void CTextWrap::AddEllipsis(std::list& lines, std::list& words, float maxWidth) +{ + const float ellipsisAdvance = GetGlyph(ellipsisUTF16).advance; + const float spaceAdvance = GetGlyph(spaceUTF16).advance; + + if (ellipsisAdvance > maxWidth) + return; + + line* l = &(lines.back()); + + // If the last line ends with a linebreak, remove it + std::list::iterator wi_end = l->end; + if (wi_end->isLineBreak) { + if (l->start == l->end || l->end == words.begin()) { + // there is just the linebreak in that line, so replace linebreak with just a null space + word w; + w.pos = wi_end->pos; + w.isSpace = true; + w.numSpaces = 0; + l->start = words.insert(wi_end,w); + l->end = l->start; + + words.erase(wi_end); + } else { + wi_end = words.erase(wi_end); + l->end = --wi_end; + } + } + + // remove as many words until we have enough free space for the ellipsis + while (l->end != l->start) { + word& w = *l->end; + + // we have enough free space + if (l->width + ellipsisAdvance < maxWidth) + break; + + // we can cut the last word to get enough freespace (so show as many as possible characters of that word) + if ( + ((l->width - w.width + ellipsisAdvance) < maxWidth) && + (w.width > ellipsisAdvance) + ) { + break; + } + + l->width -= w.width; + --(l->end); + } + + // we don't even have enough space for the ellipsis + word& w = *l->end; + if ((l->width - w.width) + ellipsisAdvance > maxWidth) + return; + + // sometimes words aren't hyphenated for visual aspects + // but if we put an ellipsis in there, it is better to show as many as possible characters of those words + std::list::iterator nextwi(l->end); + ++nextwi; + if ( + (!l->forceLineBreak) && + (nextwi != words.end()) && + (w.isSpace || w.isLineBreak) && + (l->width + ellipsisAdvance < maxWidth) && + !(nextwi->isSpace || nextwi->isLineBreak) + ) { + float spaceLeft = maxWidth - (l->width + ellipsisAdvance); + l->end = words.insert( nextwi, SplitWord(*nextwi, spaceLeft, false) ); + l->width += l->end->width; + } + + // the last word in the line needs to be cut + if (l->width + ellipsisAdvance > maxWidth) { + word& w = *l->end; + l->width -= w.width; + float spaceLeft = maxWidth - (l->width + ellipsisAdvance); + l->end = words.insert( l->end, SplitWord(w, spaceLeft, false) ); + l->width += l->end->width; + } + + // put in a space between words and the ellipsis (if there is enough space) + if (l->forceLineBreak && !l->end->isSpace) { + if (l->width + ellipsisAdvance + spaceAdvance <= maxWidth) { + word space; + space.isSpace = true; + space.numSpaces = 1; + space.width = spaceAdvance; + std::list::iterator wi(l->end); + ++l->end; + if (l->end == words.end()) { + space.pos = wi->pos + wi->text.length() + 1; + } else { + space.pos = l->end->pos; + } + l->end = words.insert( l->end, space ); + l->width += l->end->width; + } + } + + // add our ellipsis + word ellipsis; + ellipsis.text = toustring(ellipsisUTF8); + ellipsis.width = ellipsisAdvance; + std::list::iterator wi(l->end); + ++l->end; + if (l->end == words.end()) { + ellipsis.pos = wi->pos + wi->text.length() + 1; + } else { + ellipsis.pos = l->end->pos; + } + l->end = words.insert( l->end, ellipsis ); + l->width += l->end->width; +} + + +void CTextWrap::WrapTextConsole(std::list& words, float maxWidth, float maxHeight) +{ + if (words.empty() || (GetLineHeight()<=0.0f)) + return; + const bool splitAllWords = false; + const unsigned int maxLines = (unsigned int)math::floor(std::max(0.0f, maxHeight / GetLineHeight())); + + line* currLine; + word linebreak; + linebreak.isLineBreak = true; + + bool addEllipsis = false; + bool currLineValid = false; // true if there was added any data to the current line + + std::list::iterator wi = words.begin(); + + std::list lines; + lines.push_back(line()); + currLine = &(lines.back()); + currLine->start = words.begin(); + + for (; ;) { + currLineValid = true; + if (wi->isLineBreak) { + currLine->forceLineBreak = true; + currLine->end = wi; + + // start a new line after the '\n' + lines.push_back(line()); + currLineValid = false; + currLine = &(lines.back()); + currLine->start = wi; + ++currLine->start; + } else { + currLine->width += wi->width; + currLine->end = wi; + + if (currLine->width > maxWidth) { + currLine->width -= wi->width; + + // line grew too long by adding the last word, insert a LineBreak + const bool splitLastWord = (wi->width > (0.5 * maxWidth)); + const float freeWordSpace = (maxWidth - currLine->width); + + if (splitAllWords || splitLastWord) { + // last word W is larger than 0.5 * maxLineWidth, split it into + // get 'L'eft and 'R'ight parts of the split (wL becomes Left, *wi becomes R) + + bool restart = (currLine->start == wi); + // turns *wi into R + word wL = SplitWord(*wi, freeWordSpace); + + if (splitLastWord && wL.width == 0.0f) { + // With smart splitting it can happen that the word isn't split at all, + // this can cause a race condition when the word is longer than maxWidth. + // In this case we have to force an unaesthetic split. + wL = SplitWord(*wi, freeWordSpace, false); + } + + // increase by the width of the L-part of *wi + currLine->width += wL.width; + + // insert the L-part right before R + wi = words.insert(wi, wL); + if (restart) + currLine->start = wi; + ++wi; + } + + // insert the forced linebreak (either after W or before R) + linebreak.pos = wi->pos; + currLine->end = words.insert(wi, linebreak); + + while (wi != words.end() && wi->isSpace) + wi = words.erase(wi); + + lines.push_back(line()); + currLineValid = false; + currLine = &(lines.back()); + currLine->start = wi; + --wi; // compensate the wi++ downwards + } + } + + ++wi; + + if (wi == words.end()) { + break; + } + + if (lines.size() > maxLines) { + addEllipsis = true; + break; + } + } + + // empty row + if (!currLineValid || (currLine->start == words.end() && !currLine->forceLineBreak)) { + lines.pop_back(); + currLine = &(lines.back()); + } + + // if we had to cut the text because of missing space, add an ellipsis + if (addEllipsis) + AddEllipsis(lines, words, maxWidth); + + wi = currLine->end; + ++wi; + wi = words.erase(wi, words.end()); +} + + +void CTextWrap::SplitTextInWords(const std::u8string& text, std::list* words, std::list* colorcodes) +{ + const unsigned int length = (unsigned int)text.length(); + const float spaceAdvance = GetGlyph(spaceUTF16).advance; + + words->push_back(word()); + word* w = &(words->back()); + + unsigned int numChar = 0; + for (int pos = 0; pos < length; pos++) { + const char8_t& c = text[pos]; + switch(c) { + // space + case spaceUTF16: + if (!w->isSpace) { + if (!w->isLineBreak) { + w->width = GetTextWidth(w->text); + } + words->push_back(word()); + w = &(words->back()); + w->isSpace = true; + w->pos = numChar; + } + w->numSpaces++; + w->width = spaceAdvance * w->numSpaces; + break; + + // inlined colorcodes + case ColorCodeIndicator: + { + colorcodes->push_back(colorcode()); + colorcode& cc = colorcodes->back(); + cc.pos = numChar; + SkipColorCodes(text, &pos, &(cc.color)); + if (pos<0) { + pos = length; + } else { + // SkipColorCodes jumps 1 too far (it jumps on the first non + // colorcode char, but our for-loop will still do "pos++;") + pos--; + } + } break; + case ColorResetIndicator: + { + colorcode* cc = &colorcodes->back(); + if (cc->pos != numChar) { + colorcodes->push_back(colorcode()); + cc = &colorcodes->back(); + cc->pos = numChar; + } + cc->resetColor = true; + } break; + + // newlines + case 0x0d: // CR+LF + if (pos+1 < length && text[pos+1] == 0x0a) + pos++; + case 0x0a: // LF + if (w->isSpace) { + w->width = spaceAdvance * w->numSpaces; + } else if (!w->isLineBreak) { + w->width = GetTextWidth(w->text); + } + words->push_back(word()); + w = &(words->back()); + w->isLineBreak = true; + w->pos = numChar; + break; + + // printable chars + default: + if (w->isSpace || w->isLineBreak) { + if (w->isSpace) { + w->width = spaceAdvance * w->numSpaces; + } else if (!w->isLineBreak) { + w->width = GetTextWidth(w->text); + } + words->push_back(word()); + w = &(words->back()); + w->pos = numChar; + } + w->text += c; + numChar++; + } + } + if (w->isSpace) { + w->width = spaceAdvance * w->numSpaces; + } else if (!w->isLineBreak) { + w->width = GetTextWidth(w->text); + } +} + + +void CTextWrap::RemergeColorCodes(std::list* words, std::list& colorcodes) const +{ + auto wi = words->begin(); + auto wi2 = words->begin(); + for (auto& c: colorcodes) { + while(wi != words->end() && wi->pos <= c.pos) { + wi2 = wi; + ++wi; + } + + word wc; + wc.pos = c.pos; + wc.isColorCode = true; + wc.text = toustring(c.tostring()); + + if (wi2->isSpace || wi2->isLineBreak) { + while(wi2 != words->end() && (wi2->isSpace || wi2->isLineBreak)) + ++wi2; + + if (wi == words->end() && (wi2->pos + wi2->numSpaces) < c.pos) { + return; + } + + wi2 = words->insert(wi2, wc); + } else { + if (wi == words->end() && (wi2->pos + wi2->text.size()) < (c.pos + 1)) { + return; + } + + size_t pos = c.pos - wi2->pos; + if (pos < wi2->text.size() && pos > 0) { + word w2; + w2.text = toustring(wi2->text.substr(0,pos)); + w2.pos = wi2->pos; + wi2->text.erase(0,pos); + wi2->pos += pos; + wi2 = words->insert(wi2, wc); + wi2 = words->insert(wi2, w2); + } else { + wi2 = words->insert(wi2, wc); + } + } + wi = wi2; + ++wi; + } +} + + +int CTextWrap::WrapInPlace(std::u8string& text, float _fontSize, float maxWidth, float maxHeight) +{ + // TODO make an option to insert '-' for word wrappings (and perhaps try to syllabificate) + + if (_fontSize <= 0.0f) + _fontSize = GetSize(); + + const float maxWidthf = maxWidth / _fontSize; + const float maxHeightf = maxHeight / _fontSize; + + std::list words; + std::list colorcodes; + + SplitTextInWords(text, &words, &colorcodes); + WrapTextConsole(words, maxWidthf, maxHeightf); + //WrapTextKnuth(&lines, words, maxWidthf, maxHeightf); + RemergeColorCodes(&words, colorcodes); + + // create the wrapped string + text = ""; + if (words.empty()) + return 0; + unsigned int numlines = 1; + for (auto& w: words) { + if (w.isSpace) { + for (unsigned int j = 0; j < w.numSpaces; ++j) { + text += " "; + } + } else if (w.isLineBreak) { + text += "\x0d\x0a"; + numlines++; + } else { + text += w.text; + } + } + return numlines; +} + + +std::u8string CTextWrap::Wrap(const std::u8string& text, float _fontSize, float maxWidth, float maxHeight) +{ + std::u8string out(text); + WrapInPlace(out, _fontSize, maxWidth, maxHeight); + return out; +} + +/*******************************************************************************/ +/*******************************************************************************/ diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Fonts/TextWrap.h spring-98.0~14.04~ppa6/rts/Rendering/Fonts/TextWrap.h --- spring-96.0~14.04~ppa4/rts/Rendering/Fonts/TextWrap.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Fonts/TextWrap.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,94 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef _TEXTWRAP_H +#define _TEXTWRAP_H + +#include +#include + +#include "CFontTexture.h" +#include "ustring.h" +#include "System/Color.h" + + +class CTextWrap : public CFontTexture +{ +public: + CTextWrap(const std::string& fontfile, int size, int outlinesize, float outlineweight); + virtual ~CTextWrap() {} + + //! Adds \n's (and '...' if it would be too high) until the text fits into maxWidth/maxHeight + inline int WrapInPlace(std::string& text, float fontSize, float maxWidth, float maxHeight = 1e9); + inline std::string Wrap(const std::string& text, float fontSize, float maxWidth, float maxHeight = 1e9); + + static const char8_t ColorCodeIndicator = 0xFF; + static const char8_t ColorResetIndicator = 0x08; //! =: '\\b' + +public: + virtual float GetTextWidth(const std::string& text) = 0; + +private: + struct colorcode { + colorcode() : resetColor(false),color(1.f,1.f,1.f,1.f),pos(0) {}; + bool resetColor; + SColor color; + unsigned int pos; + + std::string tostring() const { + std::string out; + out.reserve(4); + if (resetColor) { + out = ColorResetIndicator; + } else { + out = ColorCodeIndicator; + out += color.r; + out += color.g; + out += color.b; + } + return out; + } + }; + struct word { + word() : width(0.0f), text(""), isSpace(false), isLineBreak(false), isColorCode(false), numSpaces(0), pos(0) {}; + + float width; + std::u8string text; + bool isSpace; + bool isLineBreak; + bool isColorCode; + unsigned int numSpaces; + unsigned int pos; //! position in the original text (needed for remerging colorcodes after wrapping; in printable chars (linebreaks and space don't count)) + }; + struct line { + line() : width(0.0f), cost(0.0f), forceLineBreak(false) {}; + + std::list::iterator start, end; + float width; + float cost; + bool forceLineBreak; + }; + + word SplitWord(word& w, float wantedWidth, bool smart = true); + + void SplitTextInWords(const std::u8string& text, std::list* words, std::list* colorcodes); + void RemergeColorCodes(std::list* words, std::list& colorcodes) const; + + void AddEllipsis(std::list& lines, std::list& words, float maxWidth); + + void WrapTextConsole(std::list& words, float maxWidth, float maxHeight); + + int WrapInPlace(std::u8string& text, float fontSize, float maxWidth, float maxHeight = 1e9); + std::u8string Wrap(const std::u8string& text, float fontSize, float maxWidth, float maxHeight = 1e9); +}; + +// wrappers +int CTextWrap::WrapInPlace(std::string& text, float fontSize, float maxWidth, float maxHeight) +{ + return WrapInPlace(toustring(text), fontSize, maxWidth, maxHeight); +} +std::string CTextWrap::Wrap(const std::string& text, float fontSize, float maxWidth, float maxHeight) +{ + return Wrap(toustring(text), fontSize, maxWidth, maxHeight); +} + +#endif /* _TEXTWRAP_H */ diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Fonts/ustring.h spring-98.0~14.04~ppa6/rts/Rendering/Fonts/ustring.h --- spring-96.0~14.04~ppa4/rts/Rendering/Fonts/ustring.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Fonts/ustring.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,46 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef _UNSIGNED_STRING_H +#define _UNSIGNED_STRING_H + +#include + +typedef unsigned char char8_t; + +namespace std { + class u8string : public string { + public: + // copy ctors + //using string::string; // gcc4.8 and newer + explicit u8string(const std::string& s) : string(s) {} + u8string(const char* c) : string(c) {} + + //! this is an important difference, we return an unsigned value here! + //! std::string returns a _signed_ one and breaks this way: + //! std::string("\0xFF")[0] == 0xFF // FAILS!!! + //! std::u8string("\0xFF")[0] == 0xFF // WORKS!!! + //! PS: this is very important with our Color...Indicator cause those + //! are defined as unsigned to be compatible with char32_t! + const char8_t& operator[] (const int t) const { + auto& str = *static_cast(this); + return *reinterpret_cast(&str[t]); + } + }; + + // alternative solution + // We would need to overload all ctors & funcs with "char*" argument then. + // too complicated -> the above is less code + //using u8string = basic_string; +} + +static inline const std::u8string& toustring(const std::string& str) +{ + return *static_cast(&str); +} + +static inline std::u8string& toustring(std::string& str) +{ + return *static_cast(&str); +} + +#endif diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/GL/GeometryBuffer.cpp spring-98.0~14.04~ppa6/rts/Rendering/GL/GeometryBuffer.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/GL/GeometryBuffer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/GL/GeometryBuffer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,6 +2,7 @@ #include "GeometryBuffer.h" #include "Rendering/GlobalRendering.h" +#include //memset void GL::GeometryBuffer::Init() { memset(&bufferTextureIDs[0], 0, sizeof(bufferTextureIDs)); @@ -38,6 +39,10 @@ buffer.Unbind(); glDeleteTextures(ATTACHMENT_COUNT, &bufferTextureIDs[0]); + + // return to incomplete state + memset(&bufferTextureIDs[0], 0, sizeof(bufferTextureIDs)); + memset(&bufferAttachments[0], 0, sizeof(bufferAttachments)); } void GL::GeometryBuffer::DrawDebug(unsigned int texID) { @@ -113,18 +118,18 @@ if (!buffer.IsValid()) return false; - if (buffer.GetStatus() == GL_FRAMEBUFFER_COMPLETE_EXT) { - // FBO cannot be complete yet during init! - // - // however GL spec says that FBO's with only - // empty attachments are complete by default - // --> extend FBO class to test for this? + // buffer isn't bound by calling context, can not call + // GetStatus to check for GL_FRAMEBUFFER_COMPLETE_EXT + // + if (HasAttachments()) { + // technically a buffer can not be complete yet during + // initialization, however the GL spec says that FBO's + // with only empty attachments are complete by default // assert(!init); - // FBO was already initialized (during init - // or from Lua) so it will have attachments - // --> check if they need to be regenerated - // (eg. if a window resize event happened) + // FBO was already initialized (during init or from Lua) + // so it will have attachments -> check if they need to + // be regenerated, eg. if a window resize event happened if (prevBufferSize == currBufferSize) return true; diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/GL/GeometryBuffer.h spring-98.0~14.04~ppa6/rts/Rendering/GL/GeometryBuffer.h --- spring-96.0~14.04~ppa4/rts/Rendering/GL/GeometryBuffer.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/GL/GeometryBuffer.h 2014-10-07 20:09:51.000000000 +0000 @@ -19,7 +19,7 @@ ATTACHMENT_COUNT = 6, }; - GeometryBuffer() { Init(); } + GeometryBuffer() : bufferName(NULL) { Init(); } ~GeometryBuffer() { Kill(); } void Init(); @@ -29,6 +29,7 @@ void DrawDebug(unsigned int texID); void SetName(const char* name) { bufferName = name; } + bool HasAttachments() const { return (bufferTextureIDs[0] != 0); } bool Valid() const { return (buffer.IsValid()); } bool Create(const int2 size); bool Update(const bool init); @@ -58,7 +59,7 @@ const char* bufferName; }; -}; +} #endif diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/GL/glExtra.cpp spring-98.0~14.04~ppa6/rts/Rendering/GL/glExtra.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/GL/glExtra.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/GL/glExtra.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -19,7 +19,7 @@ float3 pos; pos.x = center.x + (fastmath::sin(radians) * radius); pos.z = center.z + (fastmath::cos(radians) * radius); - pos.y = ground->GetHeightAboveWater(pos.x, pos.z, false) + 5.0f; + pos.y = CGround::GetHeightAboveWater(pos.x, pos.z, false) + 5.0f; va->AddVertex0(pos); } va->DrawArray0(GL_LINE_LOOP); @@ -35,10 +35,10 @@ CVertexArray* va=GetVertexArray(); va->Initialize(); - va->AddVertex0(p0.x, ground->GetHeightAboveWater(p0.x, p0.z, false), p0.z); - va->AddVertex0(p1.x, ground->GetHeightAboveWater(p1.x, p1.z, false), p1.z); - va->AddVertex0(p2.x, ground->GetHeightAboveWater(p2.x, p2.z, false), p2.z); - va->AddVertex0(p3.x, ground->GetHeightAboveWater(p3.x, p3.z, false), p3.z); + va->AddVertex0(p0.x, CGround::GetHeightAboveWater(p0.x, p0.z, false), p0.z); + va->AddVertex0(p1.x, CGround::GetHeightAboveWater(p1.x, p1.z, false), p1.z); + va->AddVertex0(p2.x, CGround::GetHeightAboveWater(p2.x, p2.z, false), p2.z); + va->AddVertex0(p3.x, CGround::GetHeightAboveWater(p3.x, p3.z, false), p3.z); va->DrawArray0(GL_LINE_LOOP); } @@ -72,8 +72,7 @@ va->Initialize(); va->EnlargeArrays(resolution, 0, VA_SIZE_0); - float3* vertices = reinterpret_cast(va->drawArray); - va->drawArrayPos = va->drawArray + resolution * 3; + float3* vertices = va->GetTypedVertexArray(resolution); for_mt(0, resolution, [&](const int i) { const float radians = (2.0f * PI) * (float)i / (float)resolution; @@ -83,7 +82,7 @@ float3 pos; pos.x = center.x + (sinR * rad); pos.z = center.z + (cosR * rad); - pos.y = ground->GetHeightAboveWater(pos.x, pos.z, false); + pos.y = CGround::GetHeightAboveWater(pos.x, pos.z, false); float heightDiff = (pos.y - center.y) * 0.5f; rad -= heightDiff * slope; float adjRadius = weapon ? weapon->GetRange2D(heightDiff * weapon->heightMod) : rad; @@ -98,7 +97,7 @@ } pos.x = center.x + (sinR * rad); pos.z = center.z + (cosR * rad); - float newY = ground->GetHeightAboveWater(pos.x, pos.z, false); + float newY = CGround::GetHeightAboveWater(pos.x, pos.z, false); ydiff = math::fabs(pos.y - newY); pos.y = newY; heightDiff = (pos.y - center.y); @@ -106,7 +105,7 @@ } pos.x = center.x + (sinR * adjRadius); pos.z = center.z + (cosR * adjRadius); - pos.y = ground->GetHeightAboveWater(pos.x, pos.z, false) + 5.0f; + pos.y = CGround::GetHeightAboveWater(pos.x, pos.z, false) + 5.0f; vertices[i] = pos; }); diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/GL/Light.h spring-98.0~14.04~ppa6/rts/Rendering/GL/Light.h --- spring-96.0~14.04~ppa4/rts/Rendering/GL/Light.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/GL/Light.h 2014-10-07 20:09:51.000000000 +0000 @@ -162,6 +162,6 @@ const float3* trackPosition; const float3* trackDirection; }; -}; +} #endif // _GL_LIGHT_H diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/GL/LightHandler.h spring-98.0~14.04~ppa6/rts/Rendering/GL/LightHandler.h --- spring-96.0~14.04~ppa4/rts/Rendering/GL/LightHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/GL/LightHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -39,6 +39,6 @@ unsigned int numLights; unsigned int lightHandle; }; -}; +} #endif // _GL_LIGHTHANDLER_H diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/GL/myGL.cpp spring-98.0~14.04~ppa6/rts/Rendering/GL/myGL.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/GL/myGL.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/GL/myGL.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,5 +1,6 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ +#include #include #include @@ -10,58 +11,35 @@ #include "myGL.h" #include "VertexArray.h" -#include "VertexArrayRange.h" #include "Rendering/GlobalRendering.h" +#include "Rendering/Textures/Bitmap.h" #include "System/Log/ILog.h" #include "System/Exceptions.h" #include "System/TimeProfiler.h" #include "System/Config/ConfigHandler.h" #include "System/FileSystem/FileHandler.h" -#include "System/Platform/MessageBox.h" - -#ifdef DEBUG //used for StacktraceOnGLErrors #include "System/Platform/CrashHandler.h" +#include "System/Platform/MessageBox.h" #include "System/Platform/Threading.h" -#endif +#include "System/type2.h" CONFIG(bool, DisableCrappyGPUWarning).defaultValue(false).description("Disables the warning an user will receive if (s)he attempts to run Spring on an outdated and underpowered video card."); -CONFIG(bool, ReportGLErrors).defaultValue(false); -CONFIG(bool, StacktraceOnGLErrors).defaultValue(false).description("Create a stacktrace when an OpenGL error occurs (only available in DEBUG builds)"); +CONFIG(bool, DebugGL).defaultValue(false).description("Enables _driver_ debug feedback. (see GL_ARB_debug_output)"); +CONFIG(bool, DebugGLStacktraces).defaultValue(false).description("Create a stacktrace when an OpenGL error occurs"); -static CVertexArray* vertexArray1 = NULL; -static CVertexArray* vertexArray2 = NULL; +static std::vector vertexArrays; +static int currentVertexArray = 0; + -#ifdef USE_GML -static CVertexArray vertexArrays1[GML_MAX_NUM_THREADS]; -static CVertexArray vertexArrays2[GML_MAX_NUM_THREADS]; -static CVertexArray* currentVertexArrays[GML_MAX_NUM_THREADS]; -#else -static CVertexArray* currentVertexArray = NULL; -#endif -//BOOL gmlVertexArrayEnable = 0; /******************************************************************************/ /******************************************************************************/ CVertexArray* GetVertexArray() { -#ifdef USE_GML // each thread gets its own array to avoid conflicts - int thread = GML::ThreadNumber(); - if (currentVertexArrays[thread] == &vertexArrays1[thread]) { - currentVertexArrays[thread] = &vertexArrays2[thread]; - } else { - currentVertexArrays[thread] = &vertexArrays1[thread]; - } - return currentVertexArrays[thread]; -#else - if (currentVertexArray == vertexArray1){ - currentVertexArray = vertexArray2; - } else { - currentVertexArray = vertexArray1; - } - return currentVertexArray; -#endif + currentVertexArray = (currentVertexArray + 1) % vertexArrays.size(); + return vertexArrays[currentVertexArray]; } @@ -70,22 +48,29 @@ void PrintAvailableResolutions() { // Get available fullscreen/hardware modes - SDL_Rect** modes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_OPENGL); - if (modes == (SDL_Rect**)0) { - LOG("Supported Video modes: No modes available!"); - } else if (modes == (SDL_Rect**)-1) { - LOG("Supported Video modes: All modes available."); - } else { - char buffer[1024]; - unsigned char n = 0; - for (int i = 0; modes[i]; ++i) { - n += SNPRINTF(&buffer[n], 1024-n, "%dx%d, ", modes[i]->w, modes[i]->h); + const int numdisplays = SDL_GetNumVideoDisplays(); + for(int k=0; k < numdisplays; ++k) { + std::string modes; + SDL_Rect rect; + const int nummodes = SDL_GetNumDisplayModes(k); + SDL_GetDisplayBounds(k, &rect); + + std::set resolutions; + for (int i = 0; i < nummodes; ++i) { + SDL_DisplayMode mode; + SDL_GetDisplayMode(k, i, &mode); + resolutions.insert(int2(mode.w, mode.h)); + } + for (const int2& res: resolutions) { + if (!modes.empty()) { + modes += ", "; + } + modes += IntToString(res.x) + "x" + IntToString(res.y); } - // remove last comma - if (n >= 2) { - buffer[n - 2] = '\0'; + if (nummodes < 1) { + modes = "NONE"; } - LOG("Supported Video modes: %s", buffer); + LOG("Supported Video modes on Display %d x:%d y:%d %dx%d:\n\t%s", k+1,rect.x, rect.y, rect.w, rect.h, modes.c_str()); } } @@ -99,7 +84,8 @@ #else #define _APIENTRY #endif -void _APIENTRY OpenGLDebugMessageCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, GLvoid* userParam) + +void _APIENTRY OpenGLDebugMessageCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const GLvoid* userParam) { std::string sourceStr; std::string typeStr; @@ -169,12 +155,10 @@ LOG_L(L_ERROR, "OpenGL: source<%s> type<%s> id<%u> severity<%s>:\n%s", sourceStr.c_str(), typeStr.c_str(), id, severityStr.c_str(), messageStr.c_str()); -#ifdef DEBUG - if (configHandler->GetBool("StacktraceOnGLErrors")) { - const std::string threadName = "rendering"; - CrashHandler::Stacktrace(Threading::GetCurrentThread(), threadName); + + if (configHandler->GetBool("DebugGLStacktraces")) { + CrashHandler::Stacktrace(Threading::GetCurrentThread(), "rendering", LOG_LEVEL_WARNING); } -#endif } #endif // GL_ARB_debug_output @@ -203,7 +187,7 @@ } else #endif { - memory[0] = SDL_GetVideoInfo()->video_mem; + memory[0] = 0; memory[1] = memory[0]; // not available } @@ -300,7 +284,11 @@ { glewInit(); - const SDL_version* sdlVersion = SDL_Linked_Version(); + SDL_version sdlVersionCompiled; + SDL_version sdlVersionLinked; + + SDL_VERSION(&sdlVersionCompiled); + SDL_GetVersion(&sdlVersionLinked); const char* glVersion = (const char*) glGetString(GL_VERSION); const char* glVendor = (const char*) glGetString(GL_VENDOR); const char* glRenderer = (const char*) glGetString(GL_RENDERER); @@ -321,26 +309,17 @@ } // log some useful version info - LOG("SDL version: %d.%d.%d", sdlVersion->major, sdlVersion->minor, sdlVersion->patch); + LOG("SDL version: linked %d.%d.%d; compiled %d.%d.%d", sdlVersionLinked.major, sdlVersionLinked.minor, sdlVersionLinked.patch, sdlVersionCompiled.major, sdlVersionCompiled.minor, sdlVersionCompiled.patch); LOG("GL version: %s", glVersion); LOG("GL vendor: %s", glVendor); LOG("GL renderer: %s", glRenderer); LOG("GLSL version: %s", glslVersion); LOG("GLEW version: %s", glewVersion); LOG("Video RAM: %s", glVidMemStr); + LOG("SwapInterval: %d", SDL_GL_GetSwapInterval()); ShowCrappyGpuWarning(glVendor, glRenderer); - /*{ - std::string s = (char*)glGetString(GL_EXTENSIONS); - for (unsigned int i=0; iGetBool("ReportGLErrors")) { + if (GLEW_ARB_debug_output && configHandler->GetBool("DebugGL")) { LOG("Installing OpenGL-DebugMessageHandler"); - glDebugMessageCallbackARB(&OpenGLDebugMessageCallback, NULL); + //typecast is a workarround for #4510, signature of the callback message changed :-| + glDebugMessageCallbackARB((GLDEBUGPROCARB)&OpenGLDebugMessageCallback, NULL); - #ifdef DEBUG - if (configHandler->GetBool("StacktraceOnGLErrors")) { + if (configHandler->GetBool("DebugGLStacktraces")) { // The callback should happen in the thread that made the gl call // so we get proper stacktraces. glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); } - #endif } #endif - vertexArray1 = new CVertexArray; - vertexArray2 = new CVertexArray; + for (int i = 0; i<2; ++i) + vertexArrays.push_back(new CVertexArray); } void UnloadExtensions() { - delete vertexArray1; - delete vertexArray2; - vertexArray1 = NULL; - vertexArray2 = NULL; + for (CVertexArray* va: vertexArrays) + delete va; } /******************************************************************************/ @@ -414,6 +390,60 @@ /******************************************************************************/ +void glSaveTexture(const GLuint textureID, const std::string& filename) +{ + const GLenum target = GL_TEXTURE_2D; + GLenum format = GL_RGBA8; + int sizeX, sizeY; + + int bits = 0; + { + glBindTexture(GL_TEXTURE_2D, textureID); + + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &sizeX); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &sizeY); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, (GLint*)&format); + + GLint _cbits; + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &_cbits); bits += _cbits; + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_SIZE, &_cbits); bits += _cbits; + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_SIZE, &_cbits); bits += _cbits; + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE, &_cbits); bits += _cbits; + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_DEPTH_SIZE, &_cbits); bits += _cbits; + } + assert(bits == 32); + assert(format == GL_RGBA8); + + CBitmap bmp; + bmp.channels = 4; + bmp.Alloc(sizeX,sizeY); + glGetTexImage(target,0,GL_RGBA,GL_UNSIGNED_BYTE, &bmp.mem[0]); + bmp.Save(filename, false); +} + + +void glSpringTexStorage2D(const GLenum target, GLint levels, const GLint internalFormat, const GLsizei width, const GLsizei height) +{ +#ifdef GLEW_ARB_texture_storage + if (levels < 0) + levels = std::ceil(std::log(std::max(width, height) + 1)); + + if (GLEW_ARB_texture_storage) { + glTexStorage2D(target, levels, internalFormat, width, height); + } else +#endif + { + GLenum format = GL_RGBA, type = GL_UNSIGNED_BYTE; + switch (internalFormat) { + case GL_RGBA8: format = GL_RGBA; type = GL_UNSIGNED_BYTE; break; + case GL_RGB8: format = GL_RGB; type = GL_UNSIGNED_BYTE; break; + default: LOG_L(L_ERROR, "[%s] Couldn't detct format& type for %i", __FUNCTION__, internalFormat); + } + glTexImage2D(target, 0, internalFormat, width, height, 0, format, type, nullptr); + } +} + + void glBuildMipmaps(const GLenum target, GLint internalFormat, const GLsizei width, const GLsizei height, const GLenum format, const GLenum type, const void* data) { if (globalRendering->compressTextures) { diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/GL/myGL.h spring-98.0~14.04~ppa6/rts/Rendering/GL/myGL.h --- spring-96.0~14.04~ppa4/rts/Rendering/GL/myGL.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/GL/myGL.h 2014-10-07 20:09:51.000000000 +0000 @@ -14,7 +14,6 @@ #else #include #endif // defined(HEADLESS) -#include "lib/gml/gml.h" // includes boost now! #include "System/float3.h" @@ -33,47 +32,22 @@ #endif // defined(HEADLESS) -inline void glVertexf3(const float3& v) -{ - glVertex3f(v.x, v.y, v.z); -} - -inline void glColorf3(const float3& v) -{ - glColor3f(v.x, v.y, v.z); -} - -inline void glNormalf3(const float3& v) -{ - glNormal3f(v.x, v.y, v.z); -} - -inline void glTranslatef3(const float3& v) -{ - glTranslatef(v.x, v.y, v.z); -} - -inline void glSecondaryColorf3(const float3& v) -{ - glSecondaryColor3f(v.x, v.y, v.z); -} - -inline void glColorf4(const float3& v, const float alpha) -{ - glColor4f(v.x, v.y, v.z, alpha); -} - -inline void glUniformf3(const GLint location, const float3& v) -{ - glUniform3f(location, v.x, v.y, v.z); -} +static inline void glVertexf3(const float3& v) { glVertex3f(v.x, v.y, v.z); } +static inline void glColorf3(const float3& v) { glColor3f(v.x, v.y, v.z); } +static inline void glNormalf3(const float3& v) { glNormal3f(v.x, v.y, v.z); } +static inline void glTranslatef3(const float3& v) { glTranslatef(v.x, v.y, v.z); } +static inline void glSecondaryColorf3(const float3& v) { glSecondaryColor3f(v.x, v.y, v.z); } +static inline void glColorf4(const float3& v, const float alpha) { glColor4f(v.x, v.y, v.z, alpha); } +static inline void glUniformf3(const GLint location, const float3& v) { glUniform3f(location, v.x, v.y, v.z); } + void WorkaroundATIPointSizeBug(); +void SetTexGen(const float& scaleX, const float& scaleZ, const float& offsetX, const float& offsetZ); +void glSaveTexture(const GLuint textureID, const std::string& filename); +void glSpringTexStorage2D(const GLenum target, GLint levels, const GLint internalFormat, const GLsizei width, const GLsizei height); void glBuildMipmaps(const GLenum target, GLint internalFormat, const GLsizei width, const GLsizei height, const GLenum format, const GLenum type, const void* data); -void SetTexGen(const float& scaleX, const float& scaleZ, const float& offsetX, const float& offsetZ); - void ClearScreen(); bool ProgramStringIsNative(GLenum target, const char* filename); diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/GL/PBO.h spring-98.0~14.04~ppa6/rts/Rendering/GL/PBO.h --- spring-96.0~14.04~ppa4/rts/Rendering/GL/PBO.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/GL/PBO.h 2014-10-07 20:09:51.000000000 +0000 @@ -16,9 +16,6 @@ public: PBO() : VBO(GL_PIXEL_UNPACK_BUFFER) {} virtual ~PBO() {} - - void Bind() const { VBO::Bind(GL_PIXEL_UNPACK_BUFFER); } - void Unbind(bool discard = true) { VBO::Unbind(discard); } }; #endif /* PBO_H */ diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/GL/VBO.cpp spring-98.0~14.04~ppa6/rts/Rendering/GL/VBO.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/GL/VBO.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/GL/VBO.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -46,11 +46,11 @@ } -VBO::VBO(GLenum _defTarget) : vboId(0) +VBO::VBO(GLenum _defTarget, const bool storage) : vboId(0), VBOused(true) { bound = false; mapped = false; - data = NULL; + data = nullptr; size = 0; curBoundTarget = _defTarget; defTarget = _defTarget; @@ -58,21 +58,49 @@ nullSizeMapped = false; VBOused = IsSupported(); + immutableStorage = storage; - // With GML the ctor can be called by a non-render thread - // so delay the buffer generation to the first usage - //if (VBOused) glGenBuffers(1, &vboId); +#ifdef GLEW_ARB_buffer_storage + if (immutableStorage && !GLEW_ARB_buffer_storage) { + //note: We can't fallback to traditional BufferObjects, cause then we would have to map/unmap on each change. + // Only sysram/cpu VAs give an equivalent behaviour. + VBOused = false; + immutableStorage = false; + //LOG_L(L_ERROR, "VBO/PBO: cannot create immutable storage, gpu drivers missing support for it!"); + } +#endif } VBO::~VBO() { - if (VBOused) { - glDeleteBuffers(1, &vboId); - } else { - delete[] data; - data = NULL; + if (mapped) { + Bind(); + UnmapBuffer(); + Unbind(); } + glDeleteBuffers(1, &vboId); + delete[] data; + data = nullptr; +} + + +VBO* VBO::operator=(VBO&& other) +{ + std::swap(vboId, other.vboId); + std::swap(bound, other.bound); + std::swap(mapped, other.mapped); + std::swap(data, other.data); + std::swap(size, other.size); + std::swap(curBoundTarget, other.curBoundTarget); + std::swap(defTarget, other.defTarget); + std::swap(usage, other.usage); + std::swap(nullSizeMapped, other.nullSizeMapped); + + std::swap(VBOused, other.VBOused); + std::swap(immutableStorage, other.immutableStorage); + + return this; } @@ -100,58 +128,121 @@ } -void VBO::Unbind(bool discard) +void VBO::Resize(GLsizeiptr _size, GLenum usage) { assert(bound); + assert(!mapped); + + if (_size == size && usage == this->usage) // no size change -> nothing to do + return; + + if (size == 0) // first call: none *BO there yet to copy old data from, so use ::New() (faster) + return New(_size, usage, nullptr); + + assert(_size > size); + auto osize = size; + size = _size; + this->usage = usage; if (VBOused) { - if (discard) { - if (!globalRendering->atiHacks) { - glBufferData(curBoundTarget, 0, 0, usage); - } else { - glBindBuffer(curBoundTarget, 0); - glDeleteBuffers(1, &vboId); - glGenBuffers(1, &vboId); - } - } - glBindBuffer(curBoundTarget, 0); - } else { - if (discard) { - delete[] data; - data = NULL; + glClearErrors(); + auto oldBoundTarget = curBoundTarget; + + #ifdef GLEW_ARB_copy_buffer + if (GLEW_ARB_copy_buffer) { + VBO vbo(GL_COPY_WRITE_BUFFER, immutableStorage); + vbo.Bind(GL_COPY_WRITE_BUFFER); + vbo.New(size, GL_STREAM_DRAW); + + // gpu internal copy (fast) + if (osize > 0) glCopyBufferSubData(curBoundTarget, GL_COPY_WRITE_BUFFER, 0, 0, osize); + + vbo.Unbind(); + Unbind(); + *this = std::move(vbo); + Bind(oldBoundTarget); + } else + #endif + { + void* memsrc = MapBuffer(GL_READ_ONLY); + Unbind(); + + VBO vbo(oldBoundTarget, immutableStorage); + vbo.Bind(oldBoundTarget); + vbo.New(size, GL_STREAM_DRAW); + void* memdst = vbo.MapBuffer(GL_WRITE_ONLY); + + // cpu download & copy (slow) + memcpy(memdst, memsrc, osize); + vbo.UnmapBuffer(); vbo.Unbind(); + Bind(); UnmapBuffer(); Unbind(); + + *this = std::move(vbo); + Bind(oldBoundTarget); } - } - bound = false; - if (discard) { - size = 0; + const GLenum err = glGetError(); + if (err != GL_NO_ERROR) { + LOG_L(L_ERROR, "VBO/PBO: out of memory"); + Unbind(); + VBOused = false; // disable VBO and fallback to VA/sysmem + immutableStorage = false; + Bind(); + Resize(_size, usage); //FIXME copy old vbo data to new sysram one + } + } else { + auto newdata = new GLubyte[size]; + assert(newdata); + if (data) memcpy(newdata, data, osize); + delete[] data; + data = newdata; } } -void VBO::Resize(GLsizeiptr _size, GLenum usage, const void* data_) +void VBO::New(GLsizeiptr _size, GLenum usage, const void* data_) { assert(bound); + assert(!mapped); + + if (data_ == nullptr && _size == size && usage == this->usage) + return; + + if (immutableStorage && size != 0) { + LOG_L(L_ERROR, "VBO/PBO: cannot recreate already existing persistent storage buffer"); + return; + } size = _size; + this->usage = usage; + if (VBOused) { glClearErrors(); - this->usage = usage; - glBufferData(curBoundTarget, size, data_, usage); + #ifdef GLEW_ARB_buffer_storage + if (immutableStorage) { + usage = GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT | GL_DYNAMIC_STORAGE_BIT; + glBufferStorage(curBoundTarget, size, data_, usage); + } else + #endif + { + glBufferData(curBoundTarget, size, data_, usage); + } const GLenum err = glGetError(); if (err != GL_NO_ERROR) { LOG_L(L_ERROR, "VBO/PBO: out of memory"); Unbind(); - VBOused = false; + VBOused = false; // disable VBO and fallback to VA/sysmem + immutableStorage = false; Bind(curBoundTarget); - Resize(_size, usage, data_); + New(_size, usage, data_); } } else { delete[] data; - data = NULL; // to prevent a dead-pointer in case of an out-of-memory exception on the next line + data = nullptr; // to prevent a dead-pointer in case of an out-of-memory exception on the next line data = new GLubyte[size]; + assert(data); if (data_) { memcpy(data, data_, size); } @@ -169,12 +260,19 @@ GLubyte* VBO::MapBuffer(GLintptr offset, GLsizeiptr _size, GLbitfield access) { assert(!mapped); + assert(offset + _size <= size); + mapped = true; // glMapBuffer & glMapBufferRange use different flags for their access argument // for easier handling convert the glMapBuffer ones here switch (access) { case GL_WRITE_ONLY: access = GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_UNSYNCHRONIZED_BIT; + #ifdef GLEW_ARB_buffer_storage + if (immutableStorage) { + access = GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT; + } + #endif break; case GL_READ_WRITE: access = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT; @@ -184,8 +282,6 @@ break; } - mapped = true; - if (_size == 0) { // nvidia incorrectly returns GL_INVALID_VALUE when trying to call glMapBufferRange with size zero // so catch it ourselves @@ -194,10 +290,12 @@ } if (VBOused) { - return (GLubyte*)glMapBufferRange(curBoundTarget, offset, _size, access); + GLubyte* ptr = (GLubyte*)glMapBufferRange(curBoundTarget, offset, _size, access); + assert(ptr); + return ptr; } else { assert(data); - return data+offset; + return data + offset; } } @@ -218,6 +316,33 @@ } +void VBO::Invalidate() +{ + assert(bound); + assert(immutableStorage || !mapped); + +#ifdef GLEW_ARB_invalidate_subdata + // OpenGL4 way + if (VBOused && GLEW_ARB_invalidate_subdata) { + glInvalidateBufferData(GetId()); + return; + } +#endif + if (VBOused && globalRendering->atiHacks) { + Unbind(); + glDeleteBuffers(1, &vboId); + glGenBuffers(1, &vboId); + Bind(); + size = -size; // else New() would early-exit + New(-size, usage, nullptr); + return; + } + + // note: allocating memory doesn't actually block the memory it just makes room in _virtual_ memory space + New(size, usage, nullptr); +} + + const GLvoid* VBO::GetPtr(GLintptr offset) const { assert(bound); @@ -225,7 +350,7 @@ if (VBOused) { return (GLvoid*)((char*)NULL + (offset)); } else { - assert(data); + if (!data) return nullptr; return (GLvoid*)(data + offset); } } diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/GL/VBO.h spring-98.0~14.04~ppa6/rts/Rendering/GL/VBO.h --- spring-96.0~14.04~ppa4/rts/Rendering/GL/VBO.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/GL/VBO.h 2014-10-07 20:09:51.000000000 +0000 @@ -13,9 +13,11 @@ class VBO { public: - VBO(GLenum defTarget = GL_ARRAY_BUFFER); + VBO(GLenum defTarget = GL_ARRAY_BUFFER, const bool storage = false); virtual ~VBO(); + VBO* operator=(VBO&& other); + bool IsSupported() const; static bool IsVBOSupported(); static bool IsPBOSupported(); @@ -24,41 +26,47 @@ * @param target can be either GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER, GL_PIXEL_PACK_BUFFER, GL_PIXEL_UNPACK_BUFFER or GL_UNIFORM_BUFFER_EXT * @see http://www.opengl.org/sdk/docs/man/xhtml/glBindBuffer.xml */ + void Bind() const { Bind(defTarget); } void Bind(GLenum target) const; void Unbind() const; - void Unbind(bool discard); /** * @param usage can be either GL_STREAM_DRAW, GL_STREAM_READ, GL_STREAM_COPY, GL_STATIC_DRAW, GL_STATIC_READ, GL_STATIC_COPY, GL_DYNAMIC_DRAW, GL_DYNAMIC_READ, or GL_DYNAMIC_COPY * @param data (optional) initialize the VBO with the data (the array must have minimum `size` length!) - * @see http://www.opengl.org/sdk/docs/man/xhtml/glBindBuffer.xml + * @see http://www.opengl.org/sdk/docs/man/xhtml/glBufferData.xml */ - void Resize(GLsizeiptr size, GLenum usage = GL_STREAM_DRAW, const void* data = NULL); + void Resize(GLsizeiptr size, GLenum usage = GL_STREAM_DRAW); + void New(GLsizeiptr size, GLenum usage = GL_STREAM_DRAW, const void* data = nullptr); + void Invalidate(); //< discards all current data (frees the memory w/o resizing) + /** + * @see http://www.opengl.org/sdk/docs/man/xhtml/glMapBufferRange.xml + */ GLubyte* MapBuffer(GLbitfield access = GL_WRITE_ONLY); GLubyte* MapBuffer(GLintptr offset, GLsizeiptr size, GLbitfield access = GL_WRITE_ONLY); void UnmapBuffer(); GLuint GetId() const { - if (VBOused && vboId == 0) glGenBuffers(1, &vboId); + if (VBOused && (vboId == 0)) glGenBuffers(1, &vboId); return vboId; } size_t GetSize() const { return size; } const GLvoid* GetPtr(GLintptr offset = 0) const; -protected: +public: mutable GLuint vboId; size_t size; mutable GLenum curBoundTarget; GLenum defTarget; GLenum usage; -private: +public: bool VBOused; mutable bool bound; bool mapped; bool nullSizeMapped; //< Nvidia workaround + bool immutableStorage; GLubyte* data; }; diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/GL/VertexArray.cpp spring-98.0~14.04~ppa6/rts/Rendering/GL/VertexArray.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/GL/VertexArray.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/GL/VertexArray.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -21,6 +21,8 @@ { delete[] drawArray; delete[] stripArray; + drawArray = NULL; + stripArray = NULL; } @@ -311,31 +313,6 @@ glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); } - - -void CVertexArray::DrawArrayT2(const int drawType, unsigned int stride) -{ - if (drawIndex() == 0) - return; - - CheckEndStrip(); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(3, GL_FLOAT, stride, drawArray); - glTexCoordPointer(2, GL_FLOAT, stride, drawArray + 3); - - glClientActiveTextureARB(GL_TEXTURE1_ARB); - glTexCoordPointer(2, GL_FLOAT, stride, drawArray + 5); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glClientActiveTextureARB(GL_TEXTURE0_ARB); - DrawArrays(drawType, stride); - glClientActiveTextureARB(GL_TEXTURE1_ARB); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glClientActiveTextureARB(GL_TEXTURE0_ARB); - - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); -} void CVertexArray::DrawArrayTN(const int drawType, unsigned int stride) diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/GL/VertexArray.h spring-98.0~14.04~ppa6/rts/Rendering/GL/VertexArray.h --- spring-96.0~14.04~ppa4/rts/Rendering/GL/VertexArray.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/GL/VertexArray.h 2014-10-07 20:09:51.000000000 +0000 @@ -5,24 +5,74 @@ #include "myGL.h" #include "System/Platform/errorhandler.h" +#include "System/Color.h" #define VA_INIT_VERTEXES 1000 // please don't change this, some files rely on specific initial sizes #define VA_INIT_STRIPS 100 + +struct VA_TYPE_0 { + float3 p; +}; +struct VA_TYPE_N { + float3 p; + float3 n; +}; +struct VA_TYPE_C { + float3 p; + SColor c; +}; +struct VA_TYPE_T { + float3 p; + float s, t; +}; +struct VA_TYPE_TN { + float3 p; + float s, t; + float3 n; +}; +struct VA_TYPE_TC { + float3 p; + float s, t; + SColor c; +}; +struct VA_TYPE_TNT { + float3 p; + float s, t; + float3 n; + float3 uv1; + float3 uv2; +}; +struct VA_TYPE_2d0 { + float x, y; +}; +struct VA_TYPE_2dT { + float x, y; + float s, t; +}; +struct VA_TYPE_2dTC { + float x, y; + float s, t; + SColor c; +}; + + // number of elements (bytes / sizeof(float)) per vertex -#define VA_SIZE_2D0 2 -#define VA_SIZE_0 3 -#define VA_SIZE_C 4 -#define VA_SIZE_N 6 -#define VA_SIZE_T 5 -#define VA_SIZE_TN 8 -#define VA_SIZE_TNT 14 -#define VA_SIZE_TC 6 -#define VA_SIZE_T2 7 -#define VA_SIZE_2DT 4 -#define VA_SIZE_2DTC 5 +#define VA_SIZE_0 (sizeof(VA_TYPE_0) / sizeof(float)) +#define VA_SIZE_C (sizeof(VA_TYPE_C) / sizeof(float)) +#define VA_SIZE_N (sizeof(VA_TYPE_N) / sizeof(float)) +#define VA_SIZE_T (sizeof(VA_TYPE_T) / sizeof(float)) +#define VA_SIZE_TN (sizeof(VA_TYPE_TN) / sizeof(float)) +#define VA_SIZE_TC (sizeof(VA_TYPE_TC) / sizeof(float)) +#define VA_SIZE_TNT (sizeof(VA_TYPE_TNT) / sizeof(float)) +#define VA_SIZE_2D0 (sizeof(VA_TYPE_2d0) / sizeof(float)) +#define VA_SIZE_2DT (sizeof(VA_TYPE_2dT) / sizeof(float)) +#define VA_SIZE_2DTC (sizeof(VA_TYPE_2dTC) / sizeof(float)) + -class CVertexArray + + +class CVertexArray { public: typedef void (*StripCallback)(void* data); @@ -31,22 +81,53 @@ CVertexArray(unsigned int maxVerts = 1 << 16); virtual ~CVertexArray(); + bool IsReady() const; void Initialize(); inline void CheckInitSize(const unsigned int vertexes, const unsigned int strips = 0); + inline void EnlargeArrays(const unsigned int vertexes, const unsigned int strips = 0, const unsigned int stripsize = VA_SIZE_0); + unsigned int drawIndex() const { return drawArrayPos - drawArray; } + void ResetPos() { drawArrayPos = drawArray; } + // standard API inline void AddVertex0(const float3& p); inline void AddVertex0(float x, float y, float z); - inline void AddVertex2d0(float x, float z); inline void AddVertexN(const float3& p, const float3& n); inline void AddVertexT(const float3& p, float tx, float ty); inline void AddVertexC(const float3& p, const unsigned char* c); inline void AddVertexTC(const float3& p, float tx, float ty, const unsigned char* c); inline void AddVertexTN(const float3& p, float tx, float ty, const float3& n); inline void AddVertexTNT(const float3& p, float tx, float ty, const float3& n, const float3& st, const float3& tt); - inline void AddVertexT2(const float3& p, float t1x, float t1y, float t2x, float t2y); + inline void AddVertex2d0(float x, float z); inline void AddVertex2dT(float x, float y, float tx, float ty); inline void AddVertex2dTC(float x, float y, float tx, float ty, const unsigned char* c); + // same as the AddVertex... functions just without automated CheckEnlargeDrawArray + inline void AddVertexQ0(float x, float y, float z); + inline void AddVertexQ0(const float3& f3); + inline void AddVertexQN(const float3& p, const float3& n); + inline void AddVertexQC(const float3& p, const unsigned char* c); + inline void AddVertexQT(const float3& p, float tx, float ty); + inline void AddVertexQTN(const float3& p, float tx, float ty, const float3& n); + inline void AddVertexQTNT(const float3& p, float tx, float ty, const float3& n, const float3& st, const float3& tt); + inline void AddVertexQTC(const float3& p, float tx, float ty, const unsigned char* c); + inline void AddVertexQ2d0(float x, float z); + inline void AddVertexQ2dT(float x, float y, float tx, float ty); + inline void AddVertexQ2dTC(float x, float y, float tx, float ty, const unsigned char* c); + + // 3rd and newest API + // it appends a block of size * sizeof(T) at the end of the VA and returns the typed address to it + template T* GetTypedVertexArrayQ(const int size) { + T* r = reinterpret_cast(drawArrayPos); + drawArrayPos += (sizeof(T) / sizeof(float)) * size; + return r; + } + template T* GetTypedVertexArray(const int size) { + EnlargeArrays(size, 0, (sizeof(T) / sizeof(float))); + return GetTypedVertexArrayQ(size); + } + + + // Render the VA void DrawArray0(const int drawType, unsigned int stride = sizeof(float) * VA_SIZE_0); void DrawArray2d0(const int drawType, unsigned int stride = sizeof(float) * VA_SIZE_2D0); void DrawArrayN(const int drawType, unsigned int stride = sizeof(float) * VA_SIZE_N); @@ -55,32 +136,22 @@ void DrawArrayTC(const int drawType, unsigned int stride = sizeof(float) * VA_SIZE_TC); void DrawArrayTN(const int drawType, unsigned int stride = sizeof(float) * VA_SIZE_TN); void DrawArrayTNT(const int drawType, unsigned int stride = sizeof(float) * VA_SIZE_TNT); - void DrawArrayT2(const int drawType, unsigned int stride = sizeof(float) * VA_SIZE_T2); void DrawArray2dT(const int drawType, unsigned int stride = sizeof(float) * VA_SIZE_2DT); void DrawArray2dTC(const int drawType, unsigned int stride = sizeof(float) * VA_SIZE_2DTC); void DrawArray2dT(const int drawType, StripCallback callback, void* data, unsigned int stride = sizeof(float) * VA_SIZE_2DT); - //! same as the AddVertex... functions just without automated CheckEnlargeDrawArray - inline void AddVertexQ0(float x, float y, float z); - inline void AddVertexQ0(const float3& f3) { AddVertexQ0(f3.x, f3.y, f3.z); } - inline void AddVertex2dQ0(float x, float z); - inline void AddVertexQN(const float3& p, const float3& n); - inline void AddVertexQC(const float3& p, const unsigned char* c); - inline void AddVertexQT(const float3& p, float tx, float ty); - inline void AddVertex2dQT(float x, float y, float tx, float ty); - inline void AddVertexQTN(const float3& p, float tx, float ty, const float3& n); - inline void AddVertexQTNT(const float3& p, float tx, float ty, const float3& n, const float3& st, const float3& tt); - inline void AddVertexQTC(const float3& p, float tx, float ty, const unsigned char* c); - - //! same as EndStrip, but without automated EnlargeStripArray - inline void EndStripQ(); - + // same as EndStrip, but without automated EnlargeStripArray void EndStrip(); - bool IsReady() const; - inline unsigned int drawIndex() const; - inline void EnlargeArrays(const unsigned int vertexes, const unsigned int strips, const unsigned int stripsize = VA_SIZE_0); +protected: + void DrawArrays(const GLenum mode, const unsigned int stride); + void DrawArraysCallback(const GLenum mode, const unsigned int stride, StripCallback callback, void* data); + inline void CheckEnlargeDrawArray(); + void EnlargeStripArray(); + void EnlargeDrawArray(); + inline void CheckEndStrip(); +protected: float* drawArray; float* drawArrayPos; float* drawArraySize; @@ -90,16 +161,9 @@ unsigned int* stripArraySize; unsigned int maxVertices; - -protected: - void DrawArrays(const GLenum mode, const unsigned int stride); - void DrawArraysCallback(const GLenum mode, const unsigned int stride, StripCallback callback, void* data); - inline void CheckEnlargeDrawArray(); - void EnlargeStripArray(); - void EnlargeDrawArray(); - inline void CheckEndStrip(); }; + #include "VertexArray.inl" #endif /* VERTEXARRAY_H */ diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/GL/VertexArray.inl spring-98.0~14.04~ppa6/rts/Rendering/GL/VertexArray.inl --- spring-96.0~14.04~ppa4/rts/Rendering/GL/VertexArray.inl 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/GL/VertexArray.inl 2014-10-07 20:09:51.000000000 +0000 @@ -1,13 +1,6 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ -#ifdef DEBUG - #define ASSERT_SIZE(x) assert(drawArraySize>=drawArrayPos+ x ); -#else - #define ASSERT_SIZE(x) -#endif - - -//! calls to this function will be removed by the optimizer unless the size is too small +// calls to this function will be removed by the optimizer unless the size is too small void CVertexArray::CheckInitSize(const unsigned int vertexes, const unsigned int strips) { if(vertexes>VA_INIT_VERTEXES || strips>VA_INIT_STRIPS) { handleerror(drawArrayPos=NULL, "Vertex array initial size is too small", "Rendering error", MBF_OK | MBF_EXCL); @@ -28,223 +21,177 @@ } +////////////////////////////////////////////////////////////////////// +// +////////////////////////////////////////////////////////////////////// -void CVertexArray::AddVertexQ0(float x, float y, float z) { +#ifdef DEBUG + #define ASSERT_SIZE(x) assert(drawArrayPos + x <= drawArraySize); +#else + #define ASSERT_SIZE(x) +#endif + + + +void CVertexArray::AddVertexQ0(const float3& pos) { ASSERT_SIZE(VA_SIZE_0) - *drawArrayPos++ = x; - *drawArrayPos++ = y; - *drawArrayPos++ = z; + VA_TYPE_0* vat = GetTypedVertexArrayQ(1); + vat->p = pos; } -void CVertexArray::AddVertex2dQ0(float x, float z) { - ASSERT_SIZE(VA_SIZE_2D0) - *drawArrayPos++ = x; - *drawArrayPos++ = z; +void CVertexArray::AddVertexQ0(float x, float y, float z) { + ASSERT_SIZE(VA_SIZE_0) + VA_TYPE_0* vat = GetTypedVertexArrayQ(1); + vat->p.x = x; + vat->p.y = y; + vat->p.z = z; } void CVertexArray::AddVertexQN(const float3& pos, const float3& normal) { ASSERT_SIZE(VA_SIZE_N) - *drawArrayPos++ = pos.x; - *drawArrayPos++ = pos.y; - *drawArrayPos++ = pos.z; - *drawArrayPos++ = normal.x; - *drawArrayPos++ = normal.y; - *drawArrayPos++ = normal.z; + VA_TYPE_N* vat = GetTypedVertexArrayQ(1); + vat->p = pos; + vat->n = normal; } void CVertexArray::AddVertexQC(const float3& pos, const unsigned char* color) { ASSERT_SIZE(VA_SIZE_C) - *drawArrayPos++ = pos.x; - *drawArrayPos++ = pos.y; - *drawArrayPos++ = pos.z; - *drawArrayPos++ = *(reinterpret_cast(color)); + VA_TYPE_C* vat = GetTypedVertexArrayQ(1); + vat->p = pos; + vat->c = SColor(color); } void CVertexArray::AddVertexQT(const float3& pos, float tx, float ty) { ASSERT_SIZE(VA_SIZE_T) - *drawArrayPos++ = pos.x; - *drawArrayPos++ = pos.y; - *drawArrayPos++ = pos.z; - *drawArrayPos++ = tx; - *drawArrayPos++ = ty; + VA_TYPE_T* vat = GetTypedVertexArrayQ(1); + vat->p = pos; + vat->s = tx; + vat->t = ty; } void CVertexArray::AddVertexQTN(const float3& pos, float tx, float ty, const float3& norm) { ASSERT_SIZE(VA_SIZE_TN) - *drawArrayPos++ = pos.x; - *drawArrayPos++ = pos.y; - *drawArrayPos++ = pos.z; - *drawArrayPos++ = tx; - *drawArrayPos++ = ty; - *drawArrayPos++ = norm.x; - *drawArrayPos++ = norm.y; - *drawArrayPos++ = norm.z; + VA_TYPE_TN* vat = GetTypedVertexArrayQ(1); + vat->p = pos; + vat->s = tx; + vat->t = ty; + vat->n = norm; } void CVertexArray::AddVertexQTNT(const float3& p, float tx, float ty, const float3& n, const float3& st, const float3& tt) { ASSERT_SIZE(VA_SIZE_TNT) - *drawArrayPos++ = p.x; - *drawArrayPos++ = p.y; - *drawArrayPos++ = p.z; - *drawArrayPos++ = tx; - *drawArrayPos++ = ty; - *drawArrayPos++ = n.x; - *drawArrayPos++ = n.y; - *drawArrayPos++ = n.z; - *drawArrayPos++ = st.x; - *drawArrayPos++ = st.y; - *drawArrayPos++ = st.z; - *drawArrayPos++ = tt.x; - *drawArrayPos++ = tt.y; - *drawArrayPos++ = tt.z; + VA_TYPE_TNT* vat = GetTypedVertexArrayQ(1); + vat->p = p; + vat->s = tx; + vat->t = ty; + vat->n = n; + vat->uv1 = st; + vat->uv2 = tt; } void CVertexArray::AddVertexQTC(const float3& pos, float tx, float ty, const unsigned char* col) { ASSERT_SIZE(VA_SIZE_TC) - *drawArrayPos++ = pos.x; - *drawArrayPos++ = pos.y; - *drawArrayPos++ = pos.z; - *drawArrayPos++ = tx; - *drawArrayPos++ = ty; - *drawArrayPos++ = *(reinterpret_cast(col)); + VA_TYPE_TC* vat = GetTypedVertexArrayQ(1); + vat->p = pos; + vat->s = tx; + vat->t = ty; + vat->c = SColor(col); +} + +void CVertexArray::AddVertexQ2d0(float x, float z) { + ASSERT_SIZE(VA_SIZE_2D0) + VA_TYPE_2d0* vat = GetTypedVertexArrayQ(1); + vat->x = x; + vat->y = z; +} + +void CVertexArray::AddVertexQ2dT(float x, float y, float tx, float ty) { + ASSERT_SIZE(VA_SIZE_2DT) + VA_TYPE_2dT* vat = GetTypedVertexArrayQ(1); + vat->x = x; + vat->y = y; + vat->s = tx; + vat->t = ty; } -void CVertexArray::AddVertex2dQT(float x, float y, float tx, float ty) { +void CVertexArray::AddVertexQ2dTC(float x, float y, float tx, float ty, const unsigned char* c) { ASSERT_SIZE(VA_SIZE_2DT) - *drawArrayPos++ = x; - *drawArrayPos++ = y; - *drawArrayPos++ = tx; - *drawArrayPos++ = ty; + VA_TYPE_2dTC* vat = GetTypedVertexArrayQ(1); + vat->x = x; + vat->y = y; + vat->s = tx; + vat->t = ty; + vat->c = SColor(c); } +////////////////////////////////////////////////////////////////////// +// +////////////////////////////////////////////////////////////////////// + void CVertexArray::AddVertex0(const float3& pos) { CheckEnlargeDrawArray(); - *drawArrayPos++ = pos.x; - *drawArrayPos++ = pos.y; - *drawArrayPos++ = pos.z; + AddVertexQ0(pos); } void CVertexArray::AddVertex0(float x, float y, float z) { CheckEnlargeDrawArray(); - *drawArrayPos++ = x; - *drawArrayPos++ = y; - *drawArrayPos++ = z; -} - -void CVertexArray::AddVertex2d0(float x, float z) { - CheckEnlargeDrawArray(); - *drawArrayPos++ = x; - *drawArrayPos++ = z; + AddVertexQ0(x,y,z); } void CVertexArray::AddVertexN(const float3& pos, const float3& normal) { CheckEnlargeDrawArray(); - *drawArrayPos++ = pos.x; - *drawArrayPos++ = pos.y; - *drawArrayPos++ = pos.z; - *drawArrayPos++ = normal.x; - *drawArrayPos++ = normal.y; - *drawArrayPos++ = normal.z; + AddVertexQN(pos, normal); } void CVertexArray::AddVertexC(const float3& pos, const unsigned char* color) { CheckEnlargeDrawArray(); - *drawArrayPos++ = pos.x; - *drawArrayPos++ = pos.y; - *drawArrayPos++ = pos.z; - *drawArrayPos++ = *(reinterpret_cast(color)); + AddVertexQC(pos, color); } void CVertexArray::AddVertexT(const float3& pos, float tx, float ty) { CheckEnlargeDrawArray(); - *drawArrayPos++ = pos.x; - *drawArrayPos++ = pos.y; - *drawArrayPos++ = pos.z; - *drawArrayPos++ = tx; - *drawArrayPos++ = ty; -} - -void CVertexArray::AddVertexT2(const float3& pos, float tx, float ty, float t2x, float t2y) { - CheckEnlargeDrawArray(); - *drawArrayPos++ = pos.x; - *drawArrayPos++ = pos.y; - *drawArrayPos++ = pos.z; - *drawArrayPos++ = tx; - *drawArrayPos++ = ty; - *drawArrayPos++ = t2x; - *drawArrayPos++ = t2y; + AddVertexQT(pos, tx, ty); } void CVertexArray::AddVertexTN(const float3& pos, float tx, float ty, const float3& norm) { CheckEnlargeDrawArray(); - *drawArrayPos++ = pos.x; - *drawArrayPos++ = pos.y; - *drawArrayPos++ = pos.z; - *drawArrayPos++ = tx; - *drawArrayPos++ = ty; - *drawArrayPos++ = norm.x; - *drawArrayPos++ = norm.y; - *drawArrayPos++ = norm.z; + AddVertexQTN(pos, tx, ty, norm); } void CVertexArray::AddVertexTNT(const float3& p, float tx, float ty, const float3& n, const float3& st, const float3& tt) { CheckEnlargeDrawArray(); - *drawArrayPos++ = p.x; - *drawArrayPos++ = p.y; - *drawArrayPos++ = p.z; - *drawArrayPos++ = tx; - *drawArrayPos++ = ty; - *drawArrayPos++ = n.x; - *drawArrayPos++ = n.y; - *drawArrayPos++ = n.z; - *drawArrayPos++ = st.x; - *drawArrayPos++ = st.y; - *drawArrayPos++ = st.z; - *drawArrayPos++ = tt.x; - *drawArrayPos++ = tt.y; - *drawArrayPos++ = tt.z; + AddVertexQTNT(p, tx, ty, n, st, tt); } void CVertexArray::AddVertexTC(const float3& pos, float tx, float ty, const unsigned char* col) { CheckEnlargeDrawArray(); - *drawArrayPos++ = pos.x; - *drawArrayPos++ = pos.y; - *drawArrayPos++ = pos.z; - *drawArrayPos++ = tx; - *drawArrayPos++ = ty; - *drawArrayPos++ = *(reinterpret_cast(col)); + AddVertexQTC(pos, tx, ty, col); +} + +void CVertexArray::AddVertex2d0(float x, float z) { + CheckEnlargeDrawArray(); + AddVertexQ2d0(x,z); } void CVertexArray::AddVertex2dT(float x, float y, float tx, float ty) { CheckEnlargeDrawArray(); - *drawArrayPos++ = x; - *drawArrayPos++ = y; - *drawArrayPos++ = tx; - *drawArrayPos++ = ty; + AddVertexQ2dT(x, y, tx, ty); } void CVertexArray::AddVertex2dTC(float x, float y, float tx, float ty, const unsigned char* col) { CheckEnlargeDrawArray(); - *drawArrayPos++ = x; - *drawArrayPos++ = y; - *drawArrayPos++ = tx; - *drawArrayPos++ = ty; - *drawArrayPos++ = *(reinterpret_cast(col)); + AddVertexQ2dTC(x, y, tx, ty, col); } +////////////////////////////////////////////////////////////////////// +// +////////////////////////////////////////////////////////////////////// + void CVertexArray::CheckEndStrip() { if (stripArrayPos == stripArray || ((ptrdiff_t) * (stripArrayPos - 1)) != ((char*) drawArrayPos - (char*) drawArray)) EndStrip(); } -unsigned int CVertexArray::drawIndex() const { - return drawArrayPos-drawArray; -} - -void CVertexArray::EndStripQ() { - assert(stripArraySize >= stripArrayPos + 1); - *stripArrayPos++ = ((char*) drawArrayPos - (char*) drawArray); -} diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/GLContext.h spring-98.0~14.04~ppa6/rts/Rendering/GLContext.h --- spring-96.0~14.04~ppa4/rts/Rendering/GLContext.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/GLContext.h 2014-10-07 20:09:51.000000000 +0000 @@ -32,6 +32,6 @@ void Free(); void InsertHookSet(Func init, Func free, void* data); void RemoveHookSet(Func init, Func free, void* data); -}; +} #endif /* GL_CONTEXT_H */ diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/glFont.cpp spring-98.0~14.04~ppa6/rts/Rendering/glFont.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/glFont.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/glFont.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,2111 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - - -#include "glFont.h" -#include -#include // for memset, memcpy -#include -#include -#include -#ifndef HEADLESS -#include -#include FT_FREETYPE_H -#endif // HEADLESS - -#include "Game/Camera.h" -#include "Rendering/GlobalRendering.h" -#include "Rendering/GL/VertexArray.h" -#include "Rendering/Textures/Bitmap.h" -#include "System/Log/ILog.h" -#include "System/myMath.h" -#include "System/FileSystem/FileHandler.h" -#include "System/FileSystem/FileSystem.h" -#include "System/Util.h" -#include "System/Exceptions.h" -#include "System/float4.h" -#include "System/bitops.h" - -#undef GetCharWidth // winapi.h - -using std::string; - - -#define LOG_SECTION_FONT "Font" -LOG_REGISTER_SECTION_GLOBAL(LOG_SECTION_FONT) - -// use the specific section for all LOG*() calls in this source file -#ifdef LOG_SECTION_CURRENT - #undef LOG_SECTION_CURRENT -#endif -#define LOG_SECTION_CURRENT LOG_SECTION_FONT - -/*******************************************************************************/ -/*******************************************************************************/ - -CglFont* font; -CglFont* smallFont; - -#define GLYPH_MARGIN 2 //! margin between glyphs in texture-atlas - -static const unsigned char nullChar = 0; -static const float4 white(1.00f, 1.00f, 1.00f, 0.95f); -static const float4 darkOutline(0.05f, 0.05f, 0.05f, 0.95f); -static const float4 lightOutline(0.95f, 0.95f, 0.95f, 0.8f); - -static const float darkLuminosity = 0.05 + - 0.2126f * math::powf(darkOutline[0], 2.2) + - 0.7152f * math::powf(darkOutline[1], 2.2) + - 0.0722f * math::powf(darkOutline[2], 2.2); - -/*******************************************************************************/ -/*******************************************************************************/ - -/** - * Those chars aren't part of the ISO-8859 and because of that not mapped - * 1:1 into unicode. So we need this table for translation. - * - * copied from: - * http://unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT - */ - -int WinLatinToUnicode_[32] = { - /*0x80*/ 0x20AC, //EURO SIGN - /*0x81*/ 0x0, //UNDEFINED - /*0x82*/ 0x201A, //SINGLE LOW-9 QUOTATION MARK - /*0x83*/ 0x0192, //LATIN SMALL LETTER F WITH HOOK - /*0x84*/ 0x201E, //DOUBLE LOW-9 QUOTATION MARK - /*0x85*/ 0x2026, //HORIZONTAL ELLIPSIS - /*0x86*/ 0x2020, //DAGGER - /*0x87*/ 0x2021, //DOUBLE DAGGER - /*0x88*/ 0x02C6, //MODIFIER LETTER CIRCUMFLEX ACCENT - /*0x89*/ 0x2030, //PER MILLE SIGN - /*0x8A*/ 0x0160, //LATIN CAPITAL LETTER S WITH CARON - /*0x8B*/ 0x2039, //SINGLE LEFT-POINTING ANGLE QUOTATION MARK - /*0x8C*/ 0x0152, //LATIN CAPITAL LIGATURE OE - /*0x8D*/ 0x0, //UNDEFINED - /*0x8E*/ 0x017D, //LATIN CAPITAL LETTER Z WITH CARON - /*0x8F*/ 0x0, //UNDEFINED - /*0x90*/ 0x0, //UNDEFINED - /*0x91*/ 0x2018, //LEFT SINGLE QUOTATION MARK - /*0x92*/ 0x2019, //RIGHT SINGLE QUOTATION MARK - /*0x93*/ 0x201C, //LEFT DOUBLE QUOTATION MARK - /*0x94*/ 0x201D, //RIGHT DOUBLE QUOTATION MARK - /*0x95*/ 0x2022, //BULLET - /*0x96*/ 0x2013, //EN DASH - /*0x97*/ 0x2014, //EM DASH - /*0x98*/ 0x02DC, //SMALL TILDE - /*0x99*/ 0x2122, //TRADE MARK SIGN - /*0x9A*/ 0x0161, //LATIN SMALL LETTER S WITH CARON - /*0x9B*/ 0x203A, //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK - /*0x9C*/ 0x0153, //LATIN SMALL LIGATURE OE - /*0x9D*/ 0x0, //UNDEFINED - /*0x9E*/ 0x017E, //LATIN SMALL LETTER Z WITH CARON - /*0x9F*/ 0x0178 //LATIN CAPITAL LETTER Y WITH DIAERESIS -}; - -inline static int WinLatinToUnicode(int c) -{ - if (c>=0x80 && c<=0x9F) { - return WinLatinToUnicode_[ c - 0x80 ]; - } - return c; //! all other chars are mapped 1:1 -} - -/*******************************************************************************/ -/*******************************************************************************/ - -class texture_size_exception : public std::exception -{ -}; - - -#ifndef HEADLESS -#undef __FTERRORS_H__ -#define FT_ERRORDEF( e, v, s ) { e, s }, -#define FT_ERROR_START_LIST { -#define FT_ERROR_END_LIST { 0, 0 } }; - struct ErrorString - { - int err_code; - const char* err_msg; - } static errorTable[] = -#include FT_ERRORS_H - - -static const char* GetFTError(FT_Error e) -{ - for (int a = 0; errorTable[a].err_msg; ++a) { - if (errorTable[a].err_code == e) - return errorTable[a].err_msg; - } - return "Unknown error"; -} -#endif // HEADLESS - -/*******************************************************************************/ -/*******************************************************************************/ - -/** - * A utility class for CglFont which collects all glyphs of - * a font into one alpha-only texture. - */ -class CFontTextureRenderer -{ -public: - CFontTextureRenderer(int _outlinewidth, int _outlineweight) - : texWidth(0), texHeight(0), - outlinewidth(_outlinewidth), outlineweight(_outlineweight), - atlas(NULL), - cur(NULL), - curX(0), curY(0), - curHeight(0), - numGlyphs(0), - maxGlyphWidth(0), maxGlyphHeight(0), - numPixels(0) - { - }; - - GLuint CreateTexture(); - - void AddGlyph(unsigned int index, int xsize, int ysize, unsigned char* pixels, int pitch); - void GetGlyph(unsigned int index, CglFont::GlyphInfo* g) const; - - int texWidth, texHeight; -private: - void CopyGlyphsIntoBitmapAtlas(bool outline = false); - void ApproximateTextureWidth(int* width, int* height); - -private: - struct GlyphInfo { - GlyphInfo() : pixels(NULL), xsize(0), ysize(0), u(INT_MAX),v(INT_MAX),us(INT_MAX),vs(INT_MAX) {}; - ~GlyphInfo() {delete[] pixels;}; - unsigned char* pixels; - int xsize; - int ysize; - int u,v; - int us,vs; - } glyphs[256]; - -private: - std::list sortByHeight; - - int outlinewidth, outlineweight; - - unsigned char* atlas; - unsigned char* cur; - int curX, curY; - int curHeight; //! height of highest glyph in current line - - unsigned int numGlyphs; - unsigned int maxGlyphWidth, maxGlyphHeight; - unsigned int numPixels; -}; - - -void CFontTextureRenderer::CopyGlyphsIntoBitmapAtlas(bool outline) -{ - const int border = (outline) ? outlinewidth : 0; - const int twoborder = 2 * border; - - std::list::iterator gi, finish; - std::list::reverse_iterator rgi, rfinish; - if (outline) { - gi = sortByHeight.begin(); - finish = sortByHeight.end(); - } else { - rgi = sortByHeight.rbegin(); - rfinish = sortByHeight.rend(); - } - - for(; (outline && gi != finish) || (!outline && rgi != rfinish); (outline) ? (void *)&++gi : (void *)&++rgi) { - GlyphInfo& g = glyphs[(outline) ? gi->x : rgi->x]; - - if (g.xsize==0 || g.ysize==0) - continue; - - if (g.xsize + twoborder > texWidth - curX) { - curX = 0; - curY += curHeight + GLYPH_MARGIN; - - curHeight = 0; - cur = atlas + curY * texWidth; - if (g.xsize + twoborder > texWidth - curX) { - delete[] atlas; - throw texture_size_exception(); - } - } - - if (g.ysize + twoborder > texHeight - curY) { - unsigned int oldTexHeight = texHeight; - unsigned char* oldAtlas = atlas; - texHeight <<= 2; - atlas = new unsigned char[texWidth * texHeight]; - memcpy(atlas, oldAtlas, texWidth * oldTexHeight); - memset(atlas + texWidth * oldTexHeight, 0, texWidth * (texHeight - oldTexHeight)); - delete[] oldAtlas; - cur = atlas + curY * texWidth; - if (texHeight>2048) { - delete[] atlas; - throw texture_size_exception(); - } - } - - //! blit the bitmap into our buffer - for (int y = 0; y < g.ysize; y++) { - const unsigned char* src = g.pixels + y * g.xsize; - unsigned char* dst = cur + (y + border) * texWidth + border; - memcpy(dst, src, g.xsize); - } - - if (outline) { - g.us = curX; g.vs = curY; - } else { - g.u = curX; g.v = curY; - } - - curX += g.xsize + GLYPH_MARGIN + twoborder; //! leave a margin between each glyph - cur += g.xsize + GLYPH_MARGIN + twoborder; - curHeight = std::max(curHeight, g.ysize + twoborder); - } -} - - - -void CFontTextureRenderer::GetGlyph(unsigned int index, CglFont::GlyphInfo* g) const -{ - const GlyphInfo& gi = glyphs[index]; - g->u0 = gi.u / (float)texWidth; - g->v0 = gi.v / (float)texHeight; - g->u1 = (gi.u+gi.xsize) / (float)texWidth; - g->v1 = (gi.v+gi.ysize) / (float)texHeight; - g->us0 = gi.us / (float)texWidth; - g->vs0 = gi.vs / (float)texHeight; - g->us1 = (gi.us+gi.xsize+2*outlinewidth) / (float)texWidth; - g->vs1 = (gi.vs+gi.ysize+2*outlinewidth) / (float)texHeight; -} - - -void CFontTextureRenderer::AddGlyph(unsigned int index, int xsize, int ysize, unsigned char* pixels, int pitch) -{ - GlyphInfo& g = glyphs[index]; - g.xsize = xsize; - g.ysize = ysize; - g.pixels = new unsigned char[xsize*ysize]; - - for (int y = 0; y < ysize; y++) { - const unsigned char* src = pixels + y * pitch; - unsigned char* dst = g.pixels + y * xsize; - memcpy(dst,src,xsize); - } - - numGlyphs++; - - //! 1st approach to approximate needed texture size - numPixels += (xsize + GLYPH_MARGIN) * (ysize + GLYPH_MARGIN); - numPixels += (xsize + 2 * outlinewidth + GLYPH_MARGIN) * (ysize + 2 * outlinewidth + GLYPH_MARGIN); - - //! needed for the 2nd approach - if (xsize>maxGlyphWidth) maxGlyphWidth = xsize; - if (ysize>maxGlyphHeight) maxGlyphHeight = ysize; - - sortByHeight.push_back(int2(index,ysize)); -} - - -void CFontTextureRenderer::ApproximateTextureWidth(int* width, int* height) -{ - //! 2nd approach to approximate needed texture size - unsigned int numPixels2 = numGlyphs * (maxGlyphWidth + GLYPH_MARGIN) * (maxGlyphHeight + GLYPH_MARGIN); - numPixels2 += numGlyphs * (maxGlyphWidth + 2 * outlinewidth + GLYPH_MARGIN) * (maxGlyphHeight + 2 * outlinewidth + GLYPH_MARGIN); - - /** - * 1st approach is too fatuous (it assumes there is no wasted space in the atlas) - * 2nd approach is too pessimistic (it just takes the largest glyph and multiplies it with the num of glyphs) - * - * So what do we do? .. YEAH! we just take the average of them ;) - */ - unsigned int numPixelsAvg = (numPixels + numPixels2) / 2; - - *width = next_power_of_2(math::ceil(math::sqrtf( (float)numPixelsAvg ))); - *height = next_power_of_2(math::ceil( (float)numPixelsAvg / (float)*width )); - - if (*width > 2048) - throw texture_size_exception(); -} - - -static inline bool sortByHeightFunc(int2 first, int2 second) -{ - return (first.y < second.y); -} - - -GLuint CFontTextureRenderer::CreateTexture() -{ -//FIXME add support to expand the texture size to the right and not only to the bottom - ApproximateTextureWidth(&texWidth,&texHeight); - - atlas = new unsigned char[texWidth * texHeight]; - memset(atlas,0,texWidth * texHeight); - cur = atlas; - - //! sort the glyphs by height to gain a few pixels - sortByHeight.sort(sortByHeightFunc); - - //! insert `outlined/shadowed` glyphs - CopyGlyphsIntoBitmapAtlas(true); - - //! blur `outlined/shadowed` glyphs - CBitmap blurbmp; - blurbmp.channels = 1; - blurbmp.xsize = texWidth; - blurbmp.ysize = curY+curHeight; - if (blurbmp.mem == NULL) { - blurbmp.mem = atlas; - blurbmp.Blur(outlinewidth,outlineweight); - blurbmp.mem = NULL; - } - - //! adjust outline weight - /*for (int y = 0; y < curY+curHeight; y++) { - unsigned char* src = atlas + y * texWidth; - for (int x = 0; x < texWidth; x++) { - unsigned char luminance = src[x]; - src[x] = (unsigned char)std::min(0xFF, outlineweight * luminance); - } - }*/ - - //! insert `normal` glyphs - CopyGlyphsIntoBitmapAtlas(); - - //! generate the ogl texture - texHeight = curY + curHeight; - if (!globalRendering->supportNPOTs) - texHeight = next_power_of_2(texHeight); - GLuint tex; - glGenTextures(1, &tex); - glBindTexture(GL_TEXTURE_2D, tex); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - if (GLEW_ARB_texture_border_clamp) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); - } - else { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); - } - static const GLfloat borderColor[4] = {1.0f,1.0f,1.0f,0.0f}; - glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor); - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, texWidth, texHeight, 0, GL_ALPHA, GL_UNSIGNED_BYTE, atlas); - delete[] atlas; - - return tex; -} - -/*******************************************************************************/ -/*******************************************************************************/ - -CglFont::CglFont(const std::string& fontfile, int size, int _outlinewidth, float _outlineweight): - fontSize(size), - fontPath(fontfile), - outlineWidth(_outlinewidth), - outlineWeight(_outlineweight), - inBeginEnd(false), - autoOutlineColor(true), - setColor(false) -{ - va = new CVertexArray(); - va2 = new CVertexArray(); - - if (size<=0) - size = 14; - - - //! setup character range - charstart = 32; - charend = 254; //! char 255 = colorcode - chars = (charend - charstart) + 1; - -#ifndef HEADLESS - const float invSize = 1.0f / size; - const float normScale = invSize / 64.0f; - FT_Library library; - FT_Face face; - - //! initialize Freetype2 library - FT_Error error = FT_Init_FreeType(&library); - if (error) { - string msg = "FT_Init_FreeType failed:"; - msg += GetFTError(error); - throw std::runtime_error(msg); - } - - //! load font via VFS - CFileHandler* f = new CFileHandler(fontPath); - if (!f->FileExists()) { - //! check in 'fonts/', too - if (fontPath.substr(0, 6) != "fonts/") { - delete f; - fontPath = "fonts/" + fontPath; - f = new CFileHandler(fontPath); - } - - if (!f->FileExists()) { - delete f; - FT_Done_FreeType(library); - throw content_error("Couldn't find font '" + fontfile + "'."); - } - } - int filesize = f->FileSize(); - FT_Byte* buf = new FT_Byte[filesize]; - f->Read(buf,filesize); - delete f; - - //! create face - error = FT_New_Memory_Face(library, buf, filesize, 0, &face); - if (error) { - FT_Done_FreeType(library); - delete[] buf; - string msg = fontfile + ": FT_New_Face failed: "; - msg += GetFTError(error); - throw content_error(msg); - } - - //! set render size - error = FT_Set_Pixel_Sizes(face, 0, size); - if (error) { - FT_Done_Face(face); - FT_Done_FreeType(library); - delete[] buf; - string msg = fontfile + ": FT_Set_Pixel_Sizes failed: "; - msg += GetFTError(error); - throw content_error(msg); - } - - //! get font information - fontFamily = face->family_name; - fontStyle = face->style_name; - - //! font's descender & height (in pixels) - fontDescender = normScale * FT_MulFix(face->descender, face->size->metrics.y_scale); - //lineHeight = invSize * (FT_MulFix(face->height, face->size->metrics.y_scale) / 64.0f); - //lineHeight = invSize * math::ceil(FT_MulFix(face->height, face->size->metrics.y_scale) / 64.0f); - lineHeight = face->height / face->units_per_EM; - //lineHeight = invSize * face->size->metrics.height / 64.0f; - - if (lineHeight<=0.0f) { - lineHeight = 1.25 * invSize * (face->bbox.yMax - face->bbox.yMin); - } - - //! used to create the glyph textureatlas - CFontTextureRenderer texRenderer(outlineWidth, outlineWeight); - - for (unsigned int i = charstart; i <= charend; i++) { - GlyphInfo* g = &glyphs[i]; - - //! translate WinLatin (codepage-1252) to Unicode (used by freetype) - int unicode = WinLatinToUnicode(i); - - //! convert to an anti-aliased bitmap - error = FT_Load_Char(face, unicode, FT_LOAD_RENDER); - if ( error ) { - continue; - } - FT_GlyphSlot slot = face->glyph; - - //! Keep sign! - const float ybearing = slot->metrics.horiBearingY * normScale; - const float xbearing = slot->metrics.horiBearingX * normScale; - - g->advance = slot->advance.x * normScale; - g->height = slot->metrics.height * normScale; - g->descender = ybearing - g->height; - - g->x0 = xbearing; - g->y0 = ybearing - fontDescender; - g->x1 = (xbearing + slot->metrics.width * normScale); - g->y1 = g->y0 - g->height; - - texRenderer.AddGlyph(i, slot->bitmap.width, slot->bitmap.rows, slot->bitmap.buffer, slot->bitmap.pitch); - } - - //! create font atlas texture - fontTexture = texRenderer.CreateTexture(); - texWidth = texRenderer.texWidth; - texHeight = texRenderer.texHeight; - - //! get glyph's uv coords in the atlas - for (unsigned int i = charstart; i <= charend; i++) { - texRenderer.GetGlyph(i,&glyphs[i]); - } - - //! generate kerning tables - for (unsigned int i = charstart; i <= charend; i++) { - GlyphInfo& g = glyphs[i]; - int unicode = WinLatinToUnicode(i); - FT_UInt left_glyph = FT_Get_Char_Index(face, unicode); - for (unsigned int j = 0; j <= 255; j++) { - unicode = WinLatinToUnicode(j); - FT_UInt right_glyph = FT_Get_Char_Index(face, unicode); - FT_Vector kerning; - kerning.x = kerning.y = 0.0f; - FT_Get_Kerning(face, left_glyph, right_glyph, FT_KERNING_DEFAULT, &kerning); - g.kerning[j] = g.advance + normScale * static_cast(kerning.x); - } - } - - //! initialize null char - GlyphInfo& g = glyphs[0]; - g.height = g.descender = g.advance = 0.0f; - for (unsigned int j = 0; j <= 255; j++) { - g.kerning[j] = 0.0f; - } - - FT_Done_Face(face); - FT_Done_FreeType(library); - delete[] buf; -#else // HEADLESS - fontFamily = "NONE"; - fontStyle = "NONE"; - fontDescender = 0.0f; - lineHeight = 0.0f; - fontTexture = 0; - texWidth = 0; - texHeight = 0; -#endif // HEADLESS - - textColor = white; - outlineColor = darkOutline; -} - - -CglFont* CglFont::LoadFont(const std::string& fontFile, int size, int outlinewidth, float outlineweight, int start, int end) -{ - try { - CglFont* newFont = new CglFont(fontFile, size, outlinewidth, outlineweight); - return newFont; - } catch (const texture_size_exception&) { - LOG_L(L_ERROR, "Failed creating font: Could not create GlyphAtlas! (try to reduce the font size/outline-width)"); - return NULL; - } catch (const content_error& ex) { - LOG_L(L_ERROR, "Failed creating font: %s", ex.what()); - return NULL; - } -} - - -CglFont::~CglFont() -{ - glDeleteTextures(1, &fontTexture); - - delete va; - delete va2; -} - - -/*******************************************************************************/ -/*******************************************************************************/ - -template -static inline int SkipColorCodesOld(const std::string& text, T pos) -{ - while (text[pos] == CglFont::ColorCodeIndicator) { - pos += 4; - if (pos >= text.size()) { return -1; } - } - return pos; -} - - -template -static inline int SkipColorCodes(const std::string& text, T* pos, float4* color) -{ - int colorFound = 0; - while (text[(*pos)] == CglFont::ColorCodeIndicator) { - (*pos) += 4; - if ((*pos) >= text.size()) { - return -(1 + colorFound); - } else { - (*color)[0] = ((unsigned char) text[(*pos)-3]) / 255.0f; - (*color)[1] = ((unsigned char) text[(*pos)-2]) / 255.0f; - (*color)[2] = ((unsigned char) text[(*pos)-1]) / 255.0f; - colorFound = 1; - } - } - return colorFound; -} - - -/** - * @brief SkipNewLine - * @param text - * @param pos index in the string - * @return <0 := end of string; returned value is: -(skippedLines + 1) - * else: number of skipped lines (can be zero) - */ -template -static inline int SkipNewLine(const std::string& text, T* pos) -{ - const size_t length = text.length(); - int skippedLines = 0; - while (*pos < length) { - const char& chr = text[*pos]; - switch(chr) { - case '\x0d': //! CR - skippedLines++; - (*pos)++; - if (*pos < length && text[*pos] == '\x0a') { //! CR+LF - (*pos)++; - } - break; - - case '\x0a': //! LF - skippedLines++; - (*pos)++; - break; - - default: - return skippedLines; - } - } - return -(1 + skippedLines); -} - - -template -static inline bool SkipColorCodesAndNewLines(const std::string& text, T* pos, float4* color, bool* colorChanged, int* skippedLines, float4* colorReset) -{ - const size_t length = text.length(); - (*colorChanged) = false; - (*skippedLines) = 0; - while (*pos < length) { - const char& chr = text[*pos]; - switch(chr) { - case CglFont::ColorCodeIndicator: - *pos += 4; - if ((*pos) < length) { - (*color)[0] = ((unsigned char) text[(*pos) - 3]) / 255.0f; - (*color)[1] = ((unsigned char) text[(*pos) - 2]) / 255.0f; - (*color)[2] = ((unsigned char) text[(*pos) - 1]) / 255.0f; - *colorChanged = true; - } - break; - - case CglFont::ColorResetIndicator: - (*pos)++; - (*color) = *colorReset; - *colorChanged = true; - break; - - case '\x0d': //! CR - (*skippedLines)++; - (*pos)++; - if (*pos < length && text[*pos] == '\x0a') { //! CR+LF - (*pos)++; - } - break; - - case '\x0a': //! LF - (*skippedLines)++; - (*pos)++; - break; - - default: - return false; - } - } - return true; -} - - -static inline void TextStripCallback(void* data) -{ - CglFont::ColorMap::iterator& sci = *reinterpret_cast(data); - glColor4fv(*sci++); -} - - -/*******************************************************************************/ -/*******************************************************************************/ - -std::string CglFont::StripColorCodes(const std::string& text) -{ - const size_t len = text.size(); - - std::string nocolor; - nocolor.reserve(len); - for (unsigned int i = 0; i < len; i++) { - if (text[i] == ColorCodeIndicator) { - i += 3; - } else { - nocolor += text[i]; - } - } - return nocolor; -} - - -float CglFont::GetKerning(const unsigned int left_char, const unsigned int right_char) const -{ - return glyphs[left_char].kerning[right_char]; -} - - -float CglFont::GetCharacterWidth(const unsigned char c) const -{ - return glyphs[c].advance; -} - - -float CglFont::GetTextWidth(const std::string& text) const -{ - if (text.size()==0) return 0.0f; - - float w = 0.0f; - float maxw = 0.0f; - - const unsigned char* prv_char = &nullChar; - const unsigned char* cur_char; - - for (int pos = 0; pos < text.length(); pos++) { - const char& c = text[pos]; - switch(c) { - //! inlined colorcode - case ColorCodeIndicator: - pos = SkipColorCodesOld(text, pos); - if (pos<0) { - pos = text.length(); - } else { - pos--; - } - break; - - //! reset color - case ColorResetIndicator: - break; - - //! newline - case '\x0d': //! CR+LF - if (pos+1 < text.length() && text[pos+1] == '\x0a') - pos++; - case '\x0a': //! LF - w += glyphs[*prv_char].kerning[0]; - if (w > maxw) - maxw = w; - w = 0.0f; - prv_char = &nullChar; - break; - - //! printable char - default: - cur_char = reinterpret_cast(&c); - w += glyphs[*prv_char].kerning[*cur_char]; - prv_char = cur_char; - } - } - - w += glyphs[*prv_char].kerning[0]; - if (w > maxw) - maxw = w; - - return maxw; -} - - -float CglFont::GetTextHeight(const std::string& text, float* descender, int* numLines) const -{ - if (text.empty()) { - if (descender) *descender = 0.0f; - if (numLines) *numLines = 0; - return 0.0f; - } - - float h = 0.0f, d = lineHeight + fontDescender; - unsigned int multiLine = 1; - - for (int pos = 0 ; pos < text.length(); pos++) { - const char& c = text[pos]; - switch(c) { - //! inlined colorcode - case ColorCodeIndicator: - pos = SkipColorCodesOld(text, pos); - if (pos<0) { - pos = text.length(); - } else { - pos--; - } - break; - - //! reset color - case ColorResetIndicator: - break; - - //! newline - case '\x0d': //! CR+LF - if (pos+1 < text.length() && text[pos+1] == '\x0a') - pos++; - case '\x0a': //! LF - multiLine++; - d = lineHeight + fontDescender; - break; - - //! printable char - default: - const unsigned char* uc = reinterpret_cast(&c); - const GlyphInfo* g = &glyphs[ *uc ]; - if (g->descender < d) d = g->descender; - if (multiLine < 2 && g->height > h) h = g->height; //! only calc height for the first line - } - } - - if (multiLine>1) d -= (multiLine-1) * lineHeight; - if (descender) *descender = d; - if (numLines) *numLines = multiLine; - - return h; -} - - -int CglFont::GetTextNumLines(const std::string& text) const -{ - if (text.empty()) - return 0; - - int lines = 1; - - for (int pos = 0 ; pos < text.length(); pos++) { - const char& c = text[pos]; - switch(c) { - //! inlined colorcode - case ColorCodeIndicator: - pos = SkipColorCodesOld(text, pos); - if (pos<0) { - pos = text.length(); - } else { - pos--; - } - break; - - //! reset color - case ColorResetIndicator: - break; - - //! newline - case '\x0d': - if (pos+1 < text.length() && text[pos+1] == '\x0a') - pos++; - case '\x0a': - lines++; - break; - - //default: - } - } - - return lines; -} - -/*******************************************************************************/ -/*******************************************************************************/ - -/** - * @brief IsUpperCase - * @return true if the given uchar is an uppercase character (WinLatin charmap) - */ -static inline bool IsUpperCase(const unsigned char& c) -{ - return (c >= 0x41 && c <= 0x5A) || - (c >= 0xC0 && c <= 0xD6) || - (c >= 0xD8 && c <= 0xDE) || - (c == 0x8A) || - (c == 0x8C) || - (c == 0x8E) || - (c == 0x9F); -} - - -/** - * @brief GetPenalty - * @param c character at %strpos% in the word - * @param strpos position of c in the word - * @param strlen total length of the word - * @return penalty (smaller is better) to split a word at that position - */ -static inline float GetPenalty(const unsigned char& c, unsigned int strpos, unsigned int strlen) -{ - const float dist = strlen - strpos; - - if (dist > (strlen / 2) && dist < 4) { - return 1e9; - } else if (c >= 0x61 && c <= 0x7A) { - //! lowercase char - return 1.0f + (strlen - strpos); - } else if (c >= 0x30 && c <= 0x39) { - //! is number - return 1.0f + (strlen - strpos)*0.9; - } else if (IsUpperCase(c)) { - //! uppercase char - return 1.0f + (strlen - strpos)*0.75; - } else { - //! any special chars - return Square(dist / 4); - } -} - - -CglFont::word CglFont::SplitWord(CglFont::word& w, float wantedWidth, bool smart) const -{ - //! returns two pieces 'L'eft and 'R'ight of the split word (returns L, *wi becomes R) - - word w2; - w2.pos = w.pos; - - const float spaceAdvance = glyphs[0x20].advance; - if (w.isLineBreak) { - //! shouldn't happen - w2 = w; - w.isSpace = true; - } else if (w.isSpace) { - int split = (int)math::floor(wantedWidth / spaceAdvance); - w2.isSpace = true; - w2.numSpaces = split; - w2.width = spaceAdvance * w2.numSpaces; - w.numSpaces -= split; - w.width = spaceAdvance * w.numSpaces; - w.pos += split; - } else { - if (!smart) { - float width = 0.0f; - unsigned int i = 0; - const unsigned char* c = reinterpret_cast(&w.text[i]); - do { - const GlyphInfo& g = glyphs[*c]; - ++i; - - if (i < w.text.length()) { - c = reinterpret_cast(&w.text[i]); - width += g.kerning[*c]; - } else { - width += g.kerning[0x20]; - } - - if (width > wantedWidth) { - w2.text = w.text.substr(0,i - 1); - w2.width = GetTextWidth(w2.text); - w.text.erase(0,i - 1); - w.width = GetTextWidth(w.text); - w.pos += i - 1; - return w2; - } - } while(i < w.text.length()); - } - - if( - (wantedWidth < 8 * spaceAdvance) || - (w.text.length() < 1) - ) { - w2.isSpace = true; - return w2; - } - - float width = 0.0f; - unsigned int i = 0; - float min_penalty = 1e9; - unsigned int goodbreak = 0; - const unsigned char* c = reinterpret_cast(&w.text[i]); - do { - const unsigned char* co = c; - unsigned int io = i; - const GlyphInfo& g = glyphs[*c]; - ++i; - - if (i < w.text.length()) { - c = reinterpret_cast(&w.text[i]); - width += g.kerning[*c]; - } else { - width += g.kerning[0x20]; - } - - if (width > wantedWidth) { - w2.text = w.text.substr(0,goodbreak); - w2.width = GetTextWidth(w2.text); - w.text.erase(0,goodbreak); - w.width = GetTextWidth(w.text); - w.pos += goodbreak; - break; - } - - float penalty = GetPenalty(*co, io, w.text.length()); - if (penalty < min_penalty) { - min_penalty = penalty; - goodbreak = i; - } - } while(i < w.text.length()); - } - return w2; -} - - -void CglFont::AddEllipsis(std::list& lines, std::list& words, float maxWidth) const -{ - const float ellipsisAdvance = glyphs[0x85].advance; - const float spaceAdvance = glyphs[0x20].advance; - - if (ellipsisAdvance > maxWidth) - return; - - line* l = &(lines.back()); - - //! If the last line ends with a linebreak, remove it - std::list::iterator wi_end = l->end; - if (wi_end->isLineBreak) { - if (l->start == l->end || l->end == words.begin()) { - //! there is just the linebreak in that line, so replace linebreak with just a null space - word w; - w.pos = wi_end->pos; - w.isSpace = true; - w.numSpaces = 0; - l->start = words.insert(wi_end,w); - l->end = l->start; - - words.erase(wi_end); - } else { - wi_end = words.erase(wi_end); - l->end = --wi_end; - } - } - - //! remove as many words until we have enough free space for the ellipsis - while (l->end != l->start) { - word& w = *l->end; - - //! we have enough free space - if (l->width + ellipsisAdvance < maxWidth) - break; - - //! we can cut the last word to get enough freespace (so show as many as possible characters of that word) - if ( - ((l->width - w.width + ellipsisAdvance) < maxWidth) && - (w.width > ellipsisAdvance) - ) { - break; - } - - l->width -= w.width; - --(l->end); - } - - //! we don't even have enough space for the ellipsis - word& w = *l->end; - if ((l->width - w.width) + ellipsisAdvance > maxWidth) - return; - - //! sometimes words aren't hyphenated for visual aspects - //! but if we put an ellipsis in there, it is better to show as many as possible characters of those words - std::list::iterator nextwi(l->end); ++nextwi; - if ( - (!l->forceLineBreak) && - (nextwi != words.end()) && - (w.isSpace || w.isLineBreak) && - (l->width + ellipsisAdvance < maxWidth) && - !(nextwi->isSpace || nextwi->isLineBreak) - ) { - float spaceLeft = maxWidth - (l->width + ellipsisAdvance); - l->end = words.insert( nextwi, SplitWord(*nextwi, spaceLeft, false) ); - l->width += l->end->width; - } - - //! the last word in the line needs to be cut - if (l->width + ellipsisAdvance > maxWidth) { - word& w = *l->end; - l->width -= w.width; - float spaceLeft = maxWidth - (l->width + ellipsisAdvance); - l->end = words.insert( l->end, SplitWord(w, spaceLeft, false) ); - l->width += l->end->width; - } - - //! put in a space between words and the ellipsis (if there is enough space) - if (l->forceLineBreak && !l->end->isSpace) { - if (l->width + ellipsisAdvance + spaceAdvance <= maxWidth) { - word space; - space.isSpace = true; - space.numSpaces = 1; - space.width = spaceAdvance; - std::list::iterator wi(l->end); - ++l->end; - if (l->end == words.end()) { - space.pos = wi->pos + wi->text.length() + 1; - } else { - space.pos = l->end->pos; - } - l->end = words.insert( l->end, space ); - l->width += l->end->width; - } - } - - //! add our ellipsis - word ellipsis; - ellipsis.text = "\x85"; - ellipsis.width = ellipsisAdvance; - std::list::iterator wi(l->end); - ++l->end; - if (l->end == words.end()) { - ellipsis.pos = wi->pos + wi->text.length() + 1; - } else { - ellipsis.pos = l->end->pos; - } - l->end = words.insert( l->end, ellipsis ); - l->width += l->end->width; -} - - -void CglFont::WrapTextConsole(std::list& words, float maxWidth, float maxHeight) const -{ - if (words.empty() || (lineHeight<=0.0f)) - return; - const bool splitAllWords = false; - const unsigned int maxLines = (unsigned int)math::floor(std::max(0.0f, maxHeight / lineHeight )); - - line* currLine; - word linebreak; - linebreak.isLineBreak = true; - - bool addEllipsis = false; - bool currLineValid = false; //! true if there was added any data to the current line - - std::list::iterator wi = words.begin(); - - std::list splitWords; - std::list lines; - lines.push_back(line()); - currLine = &(lines.back()); - currLine->start = words.begin(); - - for (; ;) { - currLineValid = true; - if (wi->isLineBreak) { - currLine->forceLineBreak = true; - currLine->end = wi; - - //! start a new line after the '\n' - lines.push_back(line()); - currLineValid = false; - currLine = &(lines.back()); - currLine->start = wi; - ++currLine->start; - } else { - currLine->width += wi->width; - currLine->end = wi; - - if (currLine->width > maxWidth) { - currLine->width -= wi->width; - - //! line grew too long by adding the last word, insert a LineBreak - const bool splitLastWord = (wi->width > (0.5 * maxWidth)); - const float freeWordSpace = (maxWidth - currLine->width); - - if (splitAllWords || splitLastWord) { - //! last word W is larger than 0.5 * maxLineWidth, split it into - //! get 'L'eft and 'R'ight parts of the split (wL becomes Left, *wi becomes R) - - bool restart = (currLine->start == wi); - //! turns *wi into R - word wL = SplitWord(*wi, freeWordSpace); - - if (splitLastWord && wL.width == 0.0f) { - //! With smart splitting it can happen that the word isn't split at all, - //! this can cause a race condition when the word is longer than maxWidth. - //! In this case we have to force an unaesthetic split. - wL = SplitWord(*wi, freeWordSpace, false); - } - - //! increase by the width of the L-part of *wi - currLine->width += wL.width; - - //! insert the L-part right before R - wi = words.insert(wi, wL); - if(restart) - currLine->start = wi; - ++wi; - } - - //! insert the forced linebreak (either after W or before R) - linebreak.pos = wi->pos; - currLine->end = words.insert(wi, linebreak); - - while (wi != words.end() && wi->isSpace) - wi = words.erase(wi); - - lines.push_back(line()); - currLineValid = false; - currLine = &(lines.back()); - currLine->start = wi; - --wi; //! compensate the wi++ downwards - } - } - - ++wi; - - if (wi == words.end()) { - break; - } - - if (lines.size() > maxLines) { - addEllipsis = true; - break; - } - } - - - - //! empty row - if (!currLineValid || (currLine->start == words.end() && !currLine->forceLineBreak)) { - lines.pop_back(); - currLine = &(lines.back()); - } - - //! if we had to cut the text because of missing space, add an ellipsis - if (addEllipsis) - AddEllipsis(lines, words, maxWidth); - - wi = currLine->end; ++wi; - wi = words.erase(wi, words.end()); -} - - -void CglFont::WrapTextKnuth(std::list& words, float maxWidth, float maxHeight) const -{ - // TODO FINISH ME!!! (Knuths algorithm would try to share deadspace between lines, with the smallest sum of (deadspace of line)^2) -} - - -void CglFont::SplitTextInWords(const std::string& text, std::list* words, std::list* colorcodes) const -{ - const unsigned int length = (unsigned int)text.length(); - const float spaceAdvance = glyphs[0x20].advance; - - words->push_back(word()); - word* w = &(words->back()); - - unsigned int numChar = 0; - for (int pos = 0; pos < length; pos++) { - const char& c = text[pos]; - switch(c) { - //! space - case '\x20': - if (!w->isSpace) { - if (w->isSpace) { - w->width = spaceAdvance * w->numSpaces; - } else if (!w->isLineBreak) { - w->width = GetTextWidth(w->text); - } - words->push_back(word()); - w = &(words->back()); - w->isSpace = true; - w->pos = numChar; - } - w->numSpaces++; - break; - - //! inlined colorcodes - case ColorCodeIndicator: - { - colorcodes->push_back(colorcode()); - colorcode& cc = colorcodes->back(); - cc.pos = numChar; - SkipColorCodes(text, &pos, &(cc.color)); - if (pos<0) { - pos = length; - } else { - //! SkipColorCodes jumps 1 too far (it jumps on the first non - //! colorcode char, but our for-loop will still do "pos++;") - pos--; - } - } break; - case ColorResetIndicator: - { - colorcode* cc = &colorcodes->back(); - if (cc->pos != numChar) { - colorcodes->push_back(colorcode()); - cc = &colorcodes->back(); - cc->pos = numChar; - } - cc->resetColor = true; - } break; - - //! newlines - case '\x0d': //! CR+LF - if (pos+1 < length && text[pos+1] == '\x0a') - pos++; - case '\x0a': //! LF - if (w->isSpace) { - w->width = spaceAdvance * w->numSpaces; - } else if (!w->isLineBreak) { - w->width = GetTextWidth(w->text); - } - words->push_back(word()); - w = &(words->back()); - w->isLineBreak = true; - w->pos = numChar; - break; - - //! printable chars - default: - if (w->isSpace || w->isLineBreak) { - if (w->isSpace) { - w->width = spaceAdvance * w->numSpaces; - } else if (!w->isLineBreak) { - w->width = GetTextWidth(w->text); - } - words->push_back(word()); - w = &(words->back()); - w->pos = numChar; - } - w->text += c; - numChar++; - } - } - if (w->isSpace) { - w->width = spaceAdvance * w->numSpaces; - } else if (!w->isLineBreak) { - w->width = GetTextWidth(w->text); - } -} - - -void CglFont::RemergeColorCodes(std::list* words, std::list& colorcodes) const -{ - std::list::iterator wi = words->begin(); - std::list::iterator wi2 = words->begin(); - std::list::iterator ci; - for (ci = colorcodes.begin(); ci != colorcodes.end(); ++ci) { - while(wi != words->end() && wi->pos <= ci->pos) { - wi2 = wi; - ++wi; - } - - word wc; - wc.pos = ci->pos; - wc.isColorCode = true; - - if (ci->resetColor) { - wc.text = ColorResetIndicator; - } else { - wc.text = ColorCodeIndicator; - wc.text += (unsigned char)(255 * ci->color[0]); - wc.text += (unsigned char)(255 * ci->color[1]); - wc.text += (unsigned char)(255 * ci->color[2]); - } - - - if (wi2->isSpace || wi2->isLineBreak) { - while(wi2 != words->end() && (wi2->isSpace || wi2->isLineBreak)) - ++wi2; - - if (wi == words->end() && (wi2->pos + wi2->numSpaces) < ci->pos) { - return; - } - - wi2 = words->insert(wi2, wc); - } else { - if (wi == words->end() && (wi2->pos + wi2->text.size()) < (ci->pos + 1)) { - return; - } - - size_t pos = ci->pos - wi2->pos; - if (pos < wi2->text.size() && pos > 0) { - word w2; - w2.text = wi2->text.substr(0,pos); - w2.pos = wi2->pos; - wi2->text.erase(0,pos); - wi2->pos += pos; - wi2 = words->insert(wi2, wc); - wi2 = words->insert(wi2, w2); - } else { - wi2 = words->insert(wi2, wc); - } - } - wi = wi2; - ++wi; - } -} - - -int CglFont::WrapInPlace(std::string& text, float _fontSize, const float maxWidth, const float maxHeight) const -{ - // TODO make an option to insert '-' for word wrappings (and perhaps try to syllabificate) - - if (_fontSize <= 0.0f) - _fontSize = fontSize; - - const float maxWidthf = maxWidth / _fontSize; - const float maxHeightf = maxHeight / _fontSize; - - std::list words; - std::list colorcodes; - - SplitTextInWords(text, &words, &colorcodes); - WrapTextConsole(words, maxWidthf, maxHeightf); - //WrapTextKnuth(&lines, words, maxWidthf, maxHeightf); - RemergeColorCodes(&words, colorcodes); - - //! create the wrapped string - text = ""; - unsigned int numlines = 0; - if (!words.empty()) { - numlines++; - for (std::list::iterator wi = words.begin(); wi != words.end(); ++wi) { - if (wi->isSpace) { - for (unsigned int j = 0; j < wi->numSpaces; ++j) { - text += " "; - } - } else if (wi->isLineBreak) { - text += "\x0d\x0a"; - numlines++; - } else { - text += wi->text; - } - } - } - - return numlines; -} - - -std::list CglFont::Wrap(const std::string& text, float _fontSize, const float maxWidth, const float maxHeight) const -{ - // TODO make an option to insert '-' for word wrappings (and perhaps try to syllabificate) - - if (_fontSize <= 0.0f) - _fontSize = fontSize; - - const float maxWidthf = maxWidth / _fontSize; - const float maxHeightf = maxHeight / _fontSize; - - std::list words; - std::list colorcodes; - - SplitTextInWords(text, &words, &colorcodes); - WrapTextConsole(words, maxWidthf, maxHeightf); - //WrapTextKnuth(&lines, words, maxWidthf, maxHeightf); - RemergeColorCodes(&words, colorcodes); - - //! create the string lines of the wrapped text - std::list::iterator lastColorCode = words.end(); - std::list strlines; - if (!words.empty()) { - strlines.push_back(""); - std::string* sl = &strlines.back(); - for (std::list::iterator wi = words.begin(); wi != words.end(); ++wi) { - if (wi->isSpace) { - for (unsigned int j = 0; j < wi->numSpaces; ++j) { - *sl += " "; - } - } else if (wi->isLineBreak) { - strlines.push_back(""); - sl = &strlines.back(); - if (lastColorCode != words.end()) - *sl += lastColorCode->text; - } else { - *sl += wi->text; - if (wi->isColorCode) - lastColorCode = wi; - } - } - } - - return strlines; -} - - -/*******************************************************************************/ -/*******************************************************************************/ - -void CglFont::SetAutoOutlineColor(bool enable) -{ - autoOutlineColor = enable; -} - - -void CglFont::SetTextColor(const float4* color) -{ - if (color == NULL) color = &white; - - if (inBeginEnd && !(*color==textColor)) { - if ((va->stripArrayPos - va->stripArray) != (va->drawArrayPos - va->drawArray)) { - stripTextColors.push_back(*color); - va->EndStrip(); - } else { - float4& back = stripTextColors.back(); - back = *color; - } - } - - textColor = *color; -} - - -void CglFont::SetOutlineColor(const float4* color) -{ - if (color == NULL) color = ChooseOutlineColor(textColor); - - if (inBeginEnd && !(*color==outlineColor)) { - if ((va2->stripArrayPos - va2->stripArray) != (va2->drawArrayPos - va2->drawArray)) { - stripOutlineColors.push_back(*color); - va2->EndStrip(); - } else { - float4& back = stripOutlineColors.back(); - back = *color; - } - } - - outlineColor = *color; -} - - -void CglFont::SetColors(const float4* _textColor, const float4* _outlineColor) -{ - if (_textColor == NULL) _textColor = &white; - if (_outlineColor == NULL) _outlineColor = ChooseOutlineColor(*_textColor); - - if (inBeginEnd) { - if (!(*_textColor==textColor)) { - if ((va->stripArrayPos - va->stripArray) != (va->drawArrayPos - va->drawArray)) { - stripTextColors.push_back(*_textColor); - va->EndStrip(); - } else { - float4& back = stripTextColors.back(); - back = *_textColor; - } - } - if (!(*_outlineColor==outlineColor)) { - if ((va2->stripArrayPos - va2->stripArray) != (va2->drawArrayPos - va2->drawArray)) { - stripOutlineColors.push_back(*_outlineColor); - va2->EndStrip(); - } else { - float4& back = stripOutlineColors.back(); - back = *_outlineColor; - } - } - } - - textColor = *_textColor; - outlineColor = *_outlineColor; -} - - -const float4* CglFont::ChooseOutlineColor(const float4& textColor) -{ - const float luminosity = 0.05 + - 0.2126f * math::powf(textColor[0], 2.2) + - 0.7152f * math::powf(textColor[1], 2.2) + - 0.0722f * math::powf(textColor[2], 2.2); - - const float lumdiff = std::max(luminosity,darkLuminosity) / std::min(luminosity,darkLuminosity); - if (lumdiff > 5.0f) { - return &darkOutline; - } else { - return &lightOutline; - } -} - - -void CglFont::Begin(const bool immediate, const bool resetColors) -{ - if (inBeginEnd) { - LOG_L(L_ERROR, "called Begin() multiple times"); - return; - } - - autoOutlineColor = true; - - setColor = !immediate; - if (resetColors) { - SetColors(); //! reset colors - } - - inBeginEnd = true; - - va->Initialize(); - va2->Initialize(); - stripTextColors.clear(); - stripOutlineColors.clear(); - stripTextColors.push_back(textColor); - stripOutlineColors.push_back(outlineColor); - - glPushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT); - glDisable(GL_LIGHTING); - glDisable(GL_DEPTH_TEST); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -} - - -void CglFont::End() -{ - if (!inBeginEnd) { - LOG_L(L_ERROR, "called End() without Begin()"); - return; - } - inBeginEnd = false; - - if (va->drawIndex() == 0) { - glPopAttrib(); - return; - } - - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, fontTexture); - - if (va2->drawIndex() > 0) { - if (stripOutlineColors.size() > 1) { - ColorMap::iterator sci = stripOutlineColors.begin(); - va2->DrawArray2dT(GL_QUADS,TextStripCallback,&sci); - } else { - glColor4fv(outlineColor); - va2->DrawArray2dT(GL_QUADS); - } - } - - if (stripTextColors.size() > 1) { - ColorMap::iterator sci = stripTextColors.begin(); - va->DrawArray2dT(GL_QUADS,TextStripCallback,&sci); - } else { - if (setColor) glColor4fv(textColor); - va->DrawArray2dT(GL_QUADS); - } - - glPopAttrib(); -} - - -void CglFont::RenderString(float x, float y, const float& scaleX, const float& scaleY, const std::string& str) -{ - /** - * NOTE: - * Font rendering does not use display lists, but VAs. It's actually faster - * (450% faster with a 7600GT!) for these reasons: - * - * 1. When using DLs, we can not group multiple glyphs into one glBegin/End pair - * because glTranslatef can not go between such a pair. - * 2. We can now eliminate all glPushMatrix/PopMatrix pairs related to font rendering - * because the transformations are calculated on the fly. These are just a couple of - * floating point multiplications and shouldn't be too expensive. - */ - - const float startx = x; - const float lineHeight_ = scaleY * lineHeight; - unsigned int length = (unsigned int)str.length(); - - va->EnlargeArrays(length * 4, 0, VA_SIZE_2DT); - - int skippedLines; - bool endOfString, colorChanged; - const GlyphInfo* g = NULL; - const unsigned char* c; - float4 newColor; newColor[3] = 1.0f; - unsigned int i = 0; - - do { - endOfString = SkipColorCodesAndNewLines(str, &i, &newColor, &colorChanged, &skippedLines, &baseTextColor); - - if (endOfString) - return; - - c = reinterpret_cast(&str[i]); - ++i; - - if (colorChanged) { - if (autoOutlineColor) { - SetColors(&newColor,NULL); - } else { - SetTextColor(&newColor); - } - } - - if (skippedLines>0) { - x = startx; - y -= skippedLines * lineHeight_; - } else if (g) { - x += scaleX * g->kerning[*c]; - } - - g = &glyphs[*c]; - - va->AddVertex2dQT(x+scaleX*g->x0, y+scaleY*g->y1, g->u0, g->v1); - va->AddVertex2dQT(x+scaleX*g->x0, y+scaleY*g->y0, g->u0, g->v0); - va->AddVertex2dQT(x+scaleX*g->x1, y+scaleY*g->y0, g->u1, g->v0); - va->AddVertex2dQT(x+scaleX*g->x1, y+scaleY*g->y1, g->u1, g->v1); - } while(true); -} - - -void CglFont::RenderStringShadow(float x, float y, const float& scaleX, const float& scaleY, const std::string& str) -{ - const float shiftX = scaleX*0.1, shiftY = scaleY*0.1; - const float ssX = (scaleX/fontSize)*outlineWidth, ssY = (scaleY/fontSize)*outlineWidth; - - const float startx = x; - const float lineHeight_ = scaleY * lineHeight; - unsigned int length = (unsigned int)str.length(); - - va->EnlargeArrays(length * 4, 0, VA_SIZE_2DT); - va2->EnlargeArrays(length * 4, 0, VA_SIZE_2DT); - - int skippedLines; - bool endOfString, colorChanged; - const GlyphInfo* g = NULL; - const unsigned char* c; - float4 newColor; newColor[3] = 1.0f; - unsigned int i = 0; - - do { - endOfString = SkipColorCodesAndNewLines(str, &i, &newColor, &colorChanged, &skippedLines, &baseTextColor); - - if (endOfString) - return; - - c = reinterpret_cast(&str[i]); - ++i; - - if (colorChanged) { - if (autoOutlineColor) { - SetColors(&newColor,NULL); - } else { - SetTextColor(&newColor); - } - } - - if (skippedLines>0) { - x = startx; - y -= skippedLines * lineHeight_; - } else if (g) { - x += scaleX * g->kerning[*c]; - } - - g = &glyphs[*c]; - - const float dx0 = x + scaleX * g->x0, dy0 = y + scaleY * g->y0; - const float dx1 = x + scaleX * g->x1, dy1 = y + scaleY * g->y1; - - //! draw shadow - va2->AddVertex2dQT(dx0+shiftX-ssX, dy1-shiftY-ssY, g->us0, g->vs1); - va2->AddVertex2dQT(dx0+shiftX-ssX, dy0-shiftY+ssY, g->us0, g->vs0); - va2->AddVertex2dQT(dx1+shiftX+ssX, dy0-shiftY+ssY, g->us1, g->vs0); - va2->AddVertex2dQT(dx1+shiftX+ssX, dy1-shiftY-ssY, g->us1, g->vs1); - - //! draw the actual character - va->AddVertex2dQT(dx0, dy1, g->u0, g->v1); - va->AddVertex2dQT(dx0, dy0, g->u0, g->v0); - va->AddVertex2dQT(dx1, dy0, g->u1, g->v0); - va->AddVertex2dQT(dx1, dy1, g->u1, g->v1); - } while(true); -} - - -void CglFont::RenderStringOutlined(float x, float y, const float& scaleX, const float& scaleY, const std::string& str) -{ - const float shiftX = (scaleX/fontSize)*outlineWidth, shiftY = (scaleY/fontSize)*outlineWidth; - - const float startx = x; - const float lineHeight_ = scaleY * lineHeight; - unsigned int length = (unsigned int)str.length(); - - va->EnlargeArrays(length * 4, 0, VA_SIZE_2DT); - va2->EnlargeArrays(length * 4, 0, VA_SIZE_2DT); - - int skippedLines; - bool endOfString, colorChanged; - const GlyphInfo* g = NULL; - const unsigned char* c; - float4 newColor; newColor[3] = 1.0f; - unsigned int i = 0; - - do { - endOfString = SkipColorCodesAndNewLines(str, &i, &newColor, &colorChanged, &skippedLines, &baseTextColor); - - if (endOfString) - return; - - c = reinterpret_cast(&str[i]); - ++i; - - if (colorChanged) { - if (autoOutlineColor) { - SetColors(&newColor,NULL); - } else { - SetTextColor(&newColor); - } - } - - if (skippedLines>0) { - x = startx; - y -= skippedLines * lineHeight_; - } else if (g) { - x += scaleX * g->kerning[*c]; - } - - g = &glyphs[*c]; - - const float dx0 = x + scaleX * g->x0, dy0 = y + scaleY * g->y0; - const float dx1 = x + scaleX * g->x1, dy1 = y + scaleY * g->y1; - - //! draw outline - va2->AddVertex2dQT(dx0-shiftX, dy1-shiftY, g->us0, g->vs1); - va2->AddVertex2dQT(dx0-shiftX, dy0+shiftY, g->us0, g->vs0); - va2->AddVertex2dQT(dx1+shiftX, dy0+shiftY, g->us1, g->vs0); - va2->AddVertex2dQT(dx1+shiftX, dy1-shiftY, g->us1, g->vs1); - - //! draw the actual character - va->AddVertex2dQT(dx0, dy1, g->u0, g->v1); - va->AddVertex2dQT(dx0, dy0, g->u0, g->v0); - va->AddVertex2dQT(dx1, dy0, g->u1, g->v0); - va->AddVertex2dQT(dx1, dy1, g->u1, g->v1); - } while(true); -} - - -void CglFont::glWorldPrint(const float3& p, const float size, const std::string& str) -{ - - glPushMatrix(); - glTranslatef(p.x, p.y, p.z); - glMultMatrixf(camera->GetBillBoardMatrix()); - Begin(false, false); - glPrint(0.0f, 0.0f, size, FONT_DESCENDER | FONT_CENTER | FONT_OUTLINE, str); - End(); - glPopMatrix(); -} - - -void CglFont::glPrint(float x, float y, float s, const int options, const std::string& text) -{ - //! s := scale or absolute size? - if (options & FONT_SCALE) { - s *= fontSize; - } - - float sizeX = s, sizeY = s; - - //! render in normalized coords (0..1) instead of screencoords (0..~1024) - if (options & FONT_NORM) { - sizeX *= globalRendering->pixelX; - sizeY *= globalRendering->pixelY; - } - - //! horizontal alignment (FONT_LEFT is default) - if (options & FONT_CENTER) { - x -= sizeX * 0.5f * GetTextWidth(text); - } else if (options & FONT_RIGHT) { - x -= sizeX * GetTextWidth(text); - } - - - //! vertical alignment - y += sizeY * fontDescender; //! move to baseline (note: descender is negative) - if (options & FONT_BASELINE) { - //! nothing - } else if (options & FONT_DESCENDER) { - y -= sizeY * fontDescender; - } else if (options & FONT_VCENTER) { - float textDescender; - y -= sizeY * 0.5f * GetTextHeight(text,&textDescender); - y -= sizeY * 0.5f * textDescender; - } else if (options & FONT_TOP) { - y -= sizeY * GetTextHeight(text); - } else if (options & FONT_ASCENDER) { - y -= sizeY * fontDescender; - y -= sizeY; - } else if (options & FONT_BOTTOM) { - float textDescender; - GetTextHeight(text,&textDescender); - y -= sizeY * textDescender; - } - - if (options & FONT_NEAREST) { - x = (int)x; - y = (int)y; - } - - // backup text & outline colors (also ::ColorResetIndicator will reset to those) - baseTextColor = textColor; - baseOutlineColor = outlineColor; - - //! immediate mode? - const bool immediate = !inBeginEnd; - if (immediate) { - Begin(!(options & (FONT_OUTLINE | FONT_SHADOW))); - } - - - //! select correct decoration RenderString function - if (options & FONT_OUTLINE) { - RenderStringOutlined(x, y, sizeX, sizeY, text); - } else if (options & FONT_SHADOW) { - RenderStringShadow(x, y, sizeX, sizeY, text); - } else { - RenderString(x, y, sizeX, sizeY, text); - } - - - //! immediate mode? - if (immediate) { - End(); - } - - //! reset text & outline colors (if changed via in text colorcodes) - SetColors(&baseTextColor,&baseOutlineColor); -} - -void CglFont::glPrintTable(float x, float y, float s, const int options, const std::string& text) { - int col = 0; - int row = 0; - std::vector coltext; - std::vector coldata; - coltext.reserve(text.length()); - coltext.push_back(""); - unsigned char curcolor[4]; - unsigned char defaultcolor[4]; - defaultcolor[0] = ColorCodeIndicator; - for(int i = 0; i < 3; ++i) - defaultcolor[i+1] = (unsigned char)(textColor[i]*255.0f); - coldata.push_back(*(int *)&defaultcolor); - for(int i = 0; i < 4; ++i) - curcolor[i] = defaultcolor[i]; - - for (int pos = 0; pos < text.length(); pos++) { - const char& c = text[pos]; - switch(c) { - //! inline colorcodes - case ColorCodeIndicator: - for(int i = 0; i < 4 && pos < text.length(); ++i, ++pos) { - coltext[col] += text[pos]; - ((unsigned char *)curcolor)[i] = text[pos]; - } - coldata[col] = *(int *)curcolor; - --pos; - break; - - // column separator is `\t`==`horizontal tab` - case '\x09': - ++col; - if(col >= coltext.size()) { - coltext.push_back(""); - for(int i = 0; i < row; ++i) - coltext[col] += '\x0a'; - coldata.push_back(*(int *)&defaultcolor); - } - if(coldata[col] != *(int *)curcolor) { - for(int i = 0; i < 4; ++i) - coltext[col] += curcolor[i]; - coldata[col] = *(int *)curcolor; - } - break; - - //! newline - case '\x0d': //! CR+LF - if (pos+1 < text.length() && text[pos + 1] == '\x0a') - pos++; - case '\x0a': //! LF - for(int i = 0; i < coltext.size(); ++i) - coltext[i] += '\x0a'; - if(coldata[0] != *(int *)curcolor) { - for(int i = 0; i < 4; ++i) - coltext[0] += curcolor[i]; - coldata[0] = *(int *)curcolor; - } - col = 0; - ++row; - break; - - //! printable char - default: - coltext[col] += c; - } - } - - float totalWidth = 0.0f; - float maxHeight = 0.0f; - float minDescender = 0.0f; - for(int i = 0; i < coltext.size(); ++i) { - float colwidth = GetTextWidth(coltext[i]); - coldata[i] = *(int *)&colwidth; - totalWidth += colwidth; - float textDescender; - float textHeight = GetTextHeight(coltext[i], &textDescender); - if(textHeight > maxHeight) - maxHeight = textHeight; - if(textDescender < minDescender) - minDescender = textDescender; - } - - //! s := scale or absolute size? - float ss = s; - if (options & FONT_SCALE) { - ss *= fontSize; - } - - float sizeX = ss, sizeY = ss; - - //! render in normalized coords (0..1) instead of screencoords (0..~1024) - if (options & FONT_NORM) { - sizeX *= globalRendering->pixelX; - sizeY *= globalRendering->pixelY; - } - - //! horizontal alignment (FONT_LEFT is default) - if (options & FONT_CENTER) { - x -= sizeX * 0.5f * totalWidth; - } else if (options & FONT_RIGHT) { - x -= sizeX * totalWidth; - } - - //! vertical alignment - if (options & FONT_BASELINE) { - //! nothing - } else if (options & FONT_DESCENDER) { - y -= sizeY * fontDescender; - } else if (options & FONT_VCENTER) { - y -= sizeY * 0.5f * maxHeight; - y -= sizeY * 0.5f * minDescender; - } else if (options & FONT_TOP) { - y -= sizeY * maxHeight; - } else if (options & FONT_ASCENDER) { - y -= sizeY * fontDescender; - y -= sizeY; - } else if (options & FONT_BOTTOM) { - y -= sizeY * minDescender; - } - - for(int i = 0; i < coltext.size(); ++i) { - glPrint(x, y, s, (options | FONT_BASELINE) & ~(FONT_RIGHT | FONT_CENTER), coltext[i]); - int colwidth = coldata[i]; - x += sizeX * *(float *)&colwidth; - } -} - - -//! macro for formatting printf-style -#define FORMAT_STRING(lastarg,fmt,out) \ - char out[512]; \ - va_list ap; \ - if (fmt == NULL) return; \ - va_start(ap, lastarg); \ - VSNPRINTF(out, sizeof(out), fmt, ap); \ - va_end(ap); - -void CglFont::glFormat(float x, float y, float s, const int options, const char* fmt, ...) -{ - FORMAT_STRING(fmt,fmt,text); - glPrint(x, y, s, options, string(text)); -} - - -void CglFont::glFormat(float x, float y, float s, const int options, const string& fmt, ...) -{ - FORMAT_STRING(fmt,fmt.c_str(),text); - glPrint(x, y, s, options, string(text)); -} diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/glFont.h spring-98.0~14.04~ppa6/rts/Rendering/glFont.h --- spring-96.0~14.04~ppa4/rts/Rendering/glFont.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/glFont.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,202 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#ifndef _GLFONT_H -#define _GLFONT_H - -#include -#include -#include // for INT_MAX - -#include "System/float4.h" - -#undef GetCharWidth // winapi.h - - -static const int FONT_LEFT = 1 << 0; -static const int FONT_RIGHT = 1 << 1; -static const int FONT_CENTER = 1 << 2; -static const int FONT_BASELINE = 1 << 3; //! align to face baseline -static const int FONT_VCENTER = 1 << 4; -static const int FONT_TOP = 1 << 5; //! align to text ascender -static const int FONT_BOTTOM = 1 << 6; //! align to text descender -static const int FONT_ASCENDER = 1 << 7; //! align to face ascender -static const int FONT_DESCENDER= 1 << 8; //! align to face descender - -static const int FONT_OUTLINE = 1 << 9; -static const int FONT_SHADOW = 1 << 10; -static const int FONT_NORM = 1 << 11; //! render in 0..1 space instead of 0..vsx|vsy -static const int FONT_SCALE = 1 << 12; //! given size argument will be treated as scaling and not absolute fontsize - -static const int FONT_NEAREST = 1 << 13; //! round x,y render pos to nearest integer, so there is no interpolation blur for small fontsizes - -class CVertexArray; -class CglFont -{ -public: - static CglFont* LoadFont(const std::string& fontFile, int size, int outlinewidth = 2, float outlineweight = 5.0f, int start = 32, int end = 254); - CglFont(const std::string& fontfile, int size, int outlinewidth, float outlineweight); - ~CglFont(); - - //! The calling of Begin() .. End() is optional, - //! but can increase the performance of drawing multiple strings a lot (upto 10x) - void Begin(const bool immediate = false, const bool resetColors = true); - void End(); - - void glWorldPrint(const float3& p, const float size, const std::string& str); - /** - * @param s absolute font size, or relative scale, if option FONT_SCALE is set - * @param options FONT_SCALE | FONT_NORM | - * (FONT_LEFT | FONT_CENTER | FONT_RIGHT) | - * (FONT_BASELINE | FONT_DESCENDER | FONT_VCENTER | - * FONT_TOP | FONT_ASCENDER | FONT_BOTTOM) | - * FONT_NEAREST | FONT_OUTLINE | FONT_SHADOW - */ - void glPrint(float x, float y, float s, const int options, const std::string& str); - void glPrintTable(float x, float y, float s, const int options, const std::string& str); - void glFormat(float x, float y, float s, const int options, const std::string& fmt, ...); - void glFormat(float x, float y, float s, const int options, const char* fmt, ...); - - void SetAutoOutlineColor(bool enable); //! auto select outline color for in-text-colorcodes - void SetTextColor(const float4* color = NULL); - void SetOutlineColor(const float4* color = NULL); - void SetColors(const float4* textColor = NULL, const float4* outlineColor = NULL); - void SetTextColor(const float& r, const float& g, const float& b, const float& a) { const float4 f = float4(r,g,b,a); SetTextColor(&f); }; - void SetOutlineColor(const float& r, const float& g, const float& b, const float& a) { const float4 f = float4(r,g,b,a); SetOutlineColor(&f); }; - - //! Adds \n's (and '...' if it would be too high) until the text fits into maxWidth/maxHeight - int WrapInPlace(std::string& text, float fontSize, const float maxWidth, const float maxHeight = 1e9) const; - std::list Wrap(const std::string& text, float fontSize, const float maxWidth, const float maxHeight = 1e9) const; - - float GetKerning(const unsigned int left_char, const unsigned int right_char) const; - float GetCharacterWidth(const unsigned char c) const; - float GetTextWidth(const std::string& text) const; - float GetTextHeight(const std::string& text, float* descender = NULL, int* numLines = NULL) const; - int GetTextNumLines(const std::string& text) const; - static std::string StripColorCodes(const std::string& text); - - inline float GetLineHeight() const { return lineHeight; } - inline float GetSize() const { return fontSize; } - inline float GetDescender() const { return fontDescender; } - inline int GetOutlineWidth() const { return outlineWidth; } - inline float GetOutlineWeight() const { return outlineWeight; } - inline std::string GetFilePath() const { return fontPath; } - inline std::string GetFamily() const { return fontFamily; } - inline std::string GetStyle() const { return fontStyle; } - int GetCharStart() const { return charstart; } - int GetCharEnd() const { return charend; } - - inline unsigned int GetTexture() const { return fontTexture; } - inline unsigned int GetTexWidth() const { return texWidth; } - inline unsigned int GetTexHeight() const { return texHeight; } - - static const char ColorCodeIndicator = '\xFF'; //FIXME use a non-printable char? (<32) - static const char ColorResetIndicator = '\x08'; //! =: '\\b' - -public: - typedef std::vector ColorMap; - - struct GlyphInfo - { - GlyphInfo() - { - u0 = v0 = u1 = v1 = 1.0f; - x0 = y0 = x1 = y1 = 0.0f; - us0 = vs0 = us1 = vs1 = 1.0f; - advance = height = 1.0f; - descender = 0.0f; - - for (int i = 0; i <= 255; i++) { - kerning[i] = 1.0f; - } - }; - - float u0, v0, u1, v1; - float x0, y0, x1, y1; - float us0, vs0, us1, vs1; //! shadow texcoords - float advance, height, descender; - float kerning[256]; - } glyphs[256]; - -private: - static const float4* ChooseOutlineColor(const float4& textColor); - - void RenderString(float x, float y, const float& scaleX, const float& scaleY, const std::string& str); - void RenderStringShadow(float x, float y, const float& scaleX, const float& scaleY, const std::string& str); - void RenderStringOutlined(float x, float y, const float& scaleX, const float& scaleY, const std::string& str); - -private: - struct colorcode { - colorcode() : resetColor(false),pos(0) {}; - bool resetColor; - float4 color; - unsigned int pos; - }; - struct word { - word() : width(0.0f), text(""), isSpace(false), isLineBreak(false), isColorCode(false), numSpaces(0), pos(0) {}; - - float width; - std::string text; - bool isSpace; - bool isLineBreak; - bool isColorCode; - unsigned int numSpaces; - unsigned int pos; //! position in the original text (needed for remerging colorcodes after wrapping; in printable chars (linebreaks and space don't count)) - }; - struct line { - line() : width(0.0f), cost(0.0f), forceLineBreak(false) {}; - - std::list::iterator start, end; - float width; - float cost; - bool forceLineBreak; - }; - - word SplitWord(word& w, float wantedWidth, bool smart = true) const; - - void SplitTextInWords(const std::string& text, std::list* words, std::list* colorcodes) const; - void RemergeColorCodes(std::list* words, std::list& colorcodes) const; - - void AddEllipsis(std::list& lines, std::list& words, float maxWidth) const; - - void WrapTextConsole(std::list& words, float maxWidth, float maxHeight) const; - void WrapTextKnuth(std::list& words, float maxWidth, float maxHeight) const; - -private: - float fontSize; - float fontDescender; - float lineHeight; - std::string fontPath; - std::string fontFamily; - std::string fontStyle; - int outlineWidth; - float outlineWeight; - int chars; - unsigned int charstart; - unsigned int charend; - - unsigned int fontTexture; - unsigned int texWidth,texHeight; - - ColorMap stripTextColors; - ColorMap stripOutlineColors; - - bool inBeginEnd; - CVertexArray* va; - CVertexArray* va2; - - bool autoOutlineColor; //! auto select outline color for in-text-colorcodes - - bool setColor; //! used for backward compability (so you can call glPrint (w/o BeginEnd and no shadow/outline!) and set the color yourself via glColor) - - float4 textColor; - float4 outlineColor; - - //! \::ColorResetIndicator will reset to those (they are the colors set when glPrint was called) - float4 baseTextColor; - float4 baseOutlineColor; -}; - -extern CglFont* font; -extern CglFont* smallFont; - -#endif /* _GLFONT_H */ diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/GlobalRendering.cpp spring-98.0~14.04~ppa6/rts/Rendering/GlobalRendering.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/GlobalRendering.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/GlobalRendering.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -14,8 +14,8 @@ #include -CONFIG(bool, CompressTextures).defaultValue(false).safemodeValue(true); // in safemode enabled, cause it ways more likely the gpu runs out of memory than this extension cause crashes! -CONFIG(bool, ForceEnableIntelShaderSupport).defaultValue(false); +CONFIG(bool, CompressTextures).defaultValue(false).safemodeValue(true).description("Runtime compress most textures to save VideoRAM."); // in safemode enabled, cause it ways more likely the gpu runs out of memory than this extension cause crashes! +CONFIG(int, ForceShaders).defaultValue(-1).minimumValue(-1).maximumValue(1); CONFIG(int, AtiHacks).defaultValue(-1).minimumValue(-1).maximumValue(1).description("Enables graphics drivers workarounds for users with ATI video cards.\n -1:=runtime detect, 0:=off, 1:=on"); CONFIG(bool, DualScreenMode).defaultValue(false).description("Sets whether to split the screen in half, with one half for minimap and one for main screen. Right side is for minimap unless DualScreenMiniMapOnLeft is set."); CONFIG(bool, DualScreenMiniMapOnLeft).defaultValue(false).description("When set, will make the left half of the screen the minimap when DualScreenMode is set."); @@ -32,7 +32,7 @@ const float CGlobalRendering::NEAR_PLANE = 2.8f; const float CGlobalRendering::SMF_INTENSITY_MULT = 210.0f / 255.0f; -CR_BIND(CGlobalRendering, ); +CR_BIND(CGlobalRendering, ) CR_REG_METADATA(CGlobalRendering, ( CR_MEMBER(teamNanospray), @@ -67,7 +67,6 @@ CR_IGNORED(zNear), CR_IGNORED(viewRange), CR_IGNORED(FSAA), - CR_IGNORED(depthBufferBits), CR_IGNORED(maxTextureSize), CR_IGNORED(teamNanospray), @@ -93,8 +92,9 @@ CR_IGNORED(glslMaxUniformBufferSize), CR_IGNORED(dualScreenMode), CR_IGNORED(dualScreenMiniMapOnLeft), - CR_IGNORED(fullScreen) -)); + CR_IGNORED(fullScreen), + CR_IGNORED(window) +)) CGlobalRendering::CGlobalRendering() : timeOffset(0.0f) @@ -129,7 +129,6 @@ , zNear(NEAR_PLANE) , viewRange(MAX_VIEW_RANGE) , FSAA(0) - , depthBufferBits(0) , maxTextureSize(2048) @@ -167,6 +166,8 @@ , dualScreenMode(false) , dualScreenMiniMapOnLeft(false) , fullScreen(true) + + , window(nullptr) { } @@ -188,20 +189,18 @@ haveIntel = (vendor.find("intel") != std::string::npos); haveNvidia = (vendor.find("nvidia ") != std::string::npos); - // FIXME: - // neither Intel's nor Mesa's GLSL implementation seem to be - // in a workable state atm (date: Nov. 2011), ARB support is - // also still crap (April 2013) - if (configHandler->GetBool("ForceEnableIntelShaderSupport")) { - haveARB |= haveIntel; - haveARB |= haveMesa; - haveGLSL |= haveIntel; - haveGLSL |= haveMesa; - } else { - haveARB &= !haveIntel; - haveARB &= !haveMesa; + const int useGlslShaders = configHandler->GetInt("ForceShaders"); + if (useGlslShaders < 0) { + // disable Shaders for Mesa & Intel drivers + haveARB &= !haveIntel; + haveARB &= !haveMesa; haveGLSL &= !haveIntel; haveGLSL &= !haveMesa; + } else if (useGlslShaders == 0) { + haveARB = false; + haveGLSL = false; + } else if (useGlslShaders > 0) { + // rely on extension detection (don't force enable shaders, when the extensions aren't exposed!) } if (haveATI) { @@ -326,19 +325,7 @@ } } -void CGlobalRendering::UpdateWindowGeometry() { - // NOTE: - // in headless builds this is not called, - // therefore winSize{X,Y} both remain 1 - screenSizeX = viewSizeX; - screenSizeY = viewSizeY; - winSizeX = viewSizeX; - winSizeY = viewSizeY; - winPosX = 0; - winPosY = 0; -} - -void CGlobalRendering::UpdateViewPortGeometry(bool windowExposed) { +void CGlobalRendering::UpdateViewPortGeometry() { // NOTE: viewPosY is not currently used (always 0) if (!dualScreenMode) { viewSizeX = winSizeX; @@ -346,12 +333,6 @@ viewPosX = 0; viewPosY = 0; } else { - // if window was exposed in full-screen mode then - // this would divide its size in half (cyclically) - // --> keep the old params - if (fullScreen && windowExposed) - return; - viewSizeX = winSizeX / 2; viewSizeY = winSizeY; diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/GlobalRendering.h spring-98.0~14.04~ppa6/rts/Rendering/GlobalRendering.h --- spring-96.0~14.04~ppa4/rts/Rendering/GlobalRendering.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/GlobalRendering.h 2014-10-07 20:09:51.000000000 +0000 @@ -6,6 +6,8 @@ #include "System/creg/creg_cond.h" #include "System/Misc/SpringTime.h" +struct SDL_Window; + /** * @brief Globally accessible unsynced, rendering related data * @@ -13,7 +15,7 @@ * that does not remain synced. */ class CGlobalRendering { - CR_DECLARE_STRUCT(CGlobalRendering); + CR_DECLARE_STRUCT(CGlobalRendering) CGlobalRendering(); @@ -22,8 +24,7 @@ void SetFullScreen(bool configFullScreen, bool cmdLineWindowed, bool cmdLineFullScreen); void SetViewSize(int vsx, int vsy); void SetDualScreenParams(); - void UpdateWindowGeometry(); - void UpdateViewPortGeometry(bool windowExposed); + void UpdateViewPortGeometry(); void UpdatePixelGeometry(); @@ -111,13 +112,6 @@ int FSAA; /** - * @brief Depthbuffer bits - * - * depthbuffer precision - */ - int depthBufferBits; - - /** * @brief maxTextureSize * * maximum 2D texture size @@ -247,7 +241,7 @@ */ bool fullScreen; - + SDL_Window* window; /** * @brief max view range in elmos diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/GroundFlash.cpp spring-98.0~14.04~ppa6/rts/Rendering/GroundFlash.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/GroundFlash.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/GroundFlash.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -11,16 +11,16 @@ #include "Rendering/ProjectileDrawer.h" #include "Sim/Projectiles/ProjectileHandler.h" -CR_BIND_DERIVED(CGroundFlash, CExpGenSpawnable, ); +CR_BIND_DERIVED(CGroundFlash, CExpGenSpawnable, ) CR_REG_METADATA(CGroundFlash, ( CR_MEMBER_BEGINFLAG(CM_Config), CR_MEMBER(size), CR_MEMBER(depthTest), CR_MEMBER(depthMask), CR_MEMBER_ENDFLAG(CM_Config) -)); +)) -CR_BIND_DERIVED(CStandardGroundFlash, CGroundFlash, ); +CR_BIND_DERIVED(CStandardGroundFlash, CGroundFlash, ) CR_REG_METADATA(CStandardGroundFlash, ( CR_MEMBER_BEGINFLAG(CM_Config), CR_MEMBER(flashSize), @@ -38,9 +38,9 @@ CR_MEMBER(circleAlphaDec), CR_MEMBER(color), CR_MEMBER(ttl) -)); +)) -CR_BIND_DERIVED(CSeismicGroundFlash, CGroundFlash, (ZeroVector, 1, 0, 1, 1, 1, ZeroVector)); +CR_BIND_DERIVED(CSeismicGroundFlash, CGroundFlash, (ZeroVector, 1, 0, 1, 1, 1, ZeroVector)) CR_REG_METADATA(CSeismicGroundFlash, ( CR_MEMBER(side1), CR_MEMBER(side2), @@ -50,9 +50,9 @@ CR_MEMBER(fade), CR_MEMBER(ttl), CR_MEMBER(color) -)); +)) -CR_BIND_DERIVED(CSimpleGroundFlash, CGroundFlash, ); +CR_BIND_DERIVED(CSimpleGroundFlash, CGroundFlash, ) CR_REG_METADATA(CSimpleGroundFlash, ( CR_MEMBER(side1), CR_MEMBER(side2), @@ -64,7 +64,7 @@ CR_MEMBER(colorMap), CR_MEMBER(texture), CR_MEMBER_ENDFLAG(CM_Config) -)); +)) @@ -124,19 +124,19 @@ } const float3 fw = camera->forward * -1000.0f; - this->pos.y = ground->GetHeightReal(p.x, p.z, false) + 1.0f; + this->pos.y = CGround::GetHeightReal(p.x, p.z, false) + 1.0f; float3 p1(p.x + flashSize, 0, p.z); - p1.y = ground->GetApproximateHeight(p1.x, p1.z, false); + p1.y = CGround::GetApproximateHeight(p1.x, p1.z, false); p1 += fw; float3 p2(p.x - flashSize, 0, p.z); - p2.y = ground->GetApproximateHeight(p2.x, p2.z, false); + p2.y = CGround::GetApproximateHeight(p2.x, p2.z, false); p2 += fw; float3 p3(p.x, 0, p.z + flashSize); - p3.y = ground->GetApproximateHeight(p3.x, p3.z, false); + p3.y = CGround::GetApproximateHeight(p3.x, p3.z, false); p3 += fw; float3 p4(p.x, 0, p.z - flashSize); - p4.y = ground->GetApproximateHeight(p4.x, p4.z, false); + p4.y = CGround::GetApproximateHeight(p4.x, p4.z, false); p4 += fw; // else ANormalize() fails! @@ -227,7 +227,7 @@ sizeGrowth = 0.0f; } -void CSimpleGroundFlash::Init(CUnit* owner, const float3& offset) +void CSimpleGroundFlash::Init(const CUnit* owner, const float3& offset) { pos += offset; age = ttl ? 0.0f : 1.0f; @@ -236,19 +236,19 @@ const float flashsize = size + (sizeGrowth * ttl); const float3 fw = camera->forward * -1000.0f; - this->pos.y = ground->GetHeightReal(pos.x, pos.z, false) + 1.0f; + this->pos.y = CGround::GetHeightReal(pos.x, pos.z, false) + 1.0f; float3 p1(pos.x + flashsize, 0.0f, pos.z); - p1.y = ground->GetApproximateHeight(p1.x, p1.z, false); + p1.y = CGround::GetApproximateHeight(p1.x, p1.z, false); p1 += fw; float3 p2(pos.x - flashsize, 0.0f, pos.z); - p2.y = ground->GetApproximateHeight(p2.x, p2.z, false); + p2.y = CGround::GetApproximateHeight(p2.x, p2.z, false); p2 += fw; float3 p3(pos.x, 0.0f, pos.z + flashsize); - p3.y = ground->GetApproximateHeight(p3.x, p3.z, false); + p3.y = CGround::GetApproximateHeight(p3.x, p3.z, false); p3 += fw; float3 p4(pos.x, 0.0f, pos.z - flashsize); - p4.y = ground->GetApproximateHeight(p4.x, p4.z, false); + p4.y = CGround::GetApproximateHeight(p4.x, p4.z, false); p4 += fw; const float3 n1 = ((p3 - p1).cross(p4 - p1)).ANormalize(); @@ -306,19 +306,19 @@ const float flashsize = size + sizeGrowth * ttl; const float3 fw = camera->forward * -1000.0f; - this->pos.y = ground->GetHeightReal(p.x, p.z, false) + 1.0f; + this->pos.y = CGround::GetHeightReal(p.x, p.z, false) + 1.0f; float3 p1(p.x + flashsize, 0.0f, p.z); - p1.y = ground->GetApproximateHeight(p1.x, p1.z, false); + p1.y = CGround::GetApproximateHeight(p1.x, p1.z, false); p1 += fw; float3 p2(p.x - flashsize, 0.0f, p.z); - p2.y = ground->GetApproximateHeight(p2.x, p2.z, false); + p2.y = CGround::GetApproximateHeight(p2.x, p2.z, false); p2 += fw; float3 p3(p.x, 0.0f, p.z + flashsize); - p3.y = ground->GetApproximateHeight(p3.x, p3.z, false); + p3.y = CGround::GetApproximateHeight(p3.x, p3.z, false); p3 += fw; float3 p4(p.x, 0.0f, p.z - flashsize); - p4.y = ground->GetApproximateHeight(p4.x, p4.z, false); + p4.y = CGround::GetApproximateHeight(p4.x, p4.z, false); p4 += fw; const float3 n1 = ((p3 - p1).cross(p4 - p1)).SafeANormalize(); diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/GroundFlash.h spring-98.0~14.04~ppa6/rts/Rendering/GroundFlash.h --- spring-96.0~14.04~ppa4/rts/Rendering/GroundFlash.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/GroundFlash.h 2014-10-07 20:09:51.000000000 +0000 @@ -13,15 +13,16 @@ class CGroundFlash : public CExpGenSpawnable { public: - CR_DECLARE(CGroundFlash); + CR_DECLARE(CGroundFlash) CGroundFlash(const float3& p); CGroundFlash(); + virtual ~CGroundFlash() {} virtual void Draw() {} /// @return false when it should be deleted virtual bool Update() { return false; } - virtual void Init(CUnit* owner, const float3& offset) {} + virtual void Init(const CUnit* owner, const float3& offset) {} float size; bool depthTest; @@ -30,16 +31,17 @@ static CVertexArray* va; }; + + class CStandardGroundFlash : public CGroundFlash { public: - CR_DECLARE(CStandardGroundFlash); + CR_DECLARE(CStandardGroundFlash) CStandardGroundFlash(); CStandardGroundFlash(const float3& pos, float circleAlpha, float flashAlpha, float flashSize, float circleSpeed, float ttl, const float3& color = float3(1.0f, 1.0f, 0.7f)); void Draw(); - /// @return false when it should be deleted bool Update(); float3 side1; @@ -53,7 +55,9 @@ float flashAge; float flashAgeSpeed; float circleAlphaDec; + unsigned char color[3]; + int ttl; }; @@ -64,13 +68,12 @@ class CSimpleGroundFlash : public CGroundFlash { public: - CR_DECLARE(CSimpleGroundFlash); + CR_DECLARE(CSimpleGroundFlash) CSimpleGroundFlash(); - void Init(CUnit* owner, const float3& offset); + void Init(const CUnit* owner, const float3& offset); void Draw(); - /// @return false when it should be deleted bool Update(); float3 side1; @@ -86,14 +89,15 @@ /** * A simple groundflash, only creating one quad with specified texture. - * This one also sets alwaysVisible=true, because it is used - * by the seismic effect, so do not use it (or fix it) - * for things that should be affected by LOS. + * This one also sets alwaysVisible=true because it is used by the + * seismic effect, so do not use it (or fix it) for things that should + * be affected by LOS. */ class CSeismicGroundFlash : public CGroundFlash { public: - CR_DECLARE(CSeismicGroundFlash); + CR_DECLARE(CSeismicGroundFlash) + CSeismicGroundFlash(const float3& pos, int ttl, int fade, float size, float sizeGrowth, float alpha, const float3& col); void Draw(); @@ -104,10 +108,13 @@ float3 side2; AtlasedTexture* texture; + float sizeGrowth; float alpha; + int fade; int ttl; + unsigned char color[4]; }; diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/HUDDrawer.cpp spring-98.0~14.04~ppa6/rts/Rendering/HUDDrawer.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/HUDDrawer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/HUDDrawer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,7 +2,7 @@ #include "HUDDrawer.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Rendering/GlobalRendering.h" #include "Rendering/GL/myGL.h" #include "Rendering/Models/3DModel.h" diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Icon.h spring-98.0~14.04~ppa6/rts/Rendering/Icon.h --- spring-96.0~14.04~ppa4/rts/Rendering/Icon.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Icon.h 2014-10-07 20:09:51.000000000 +0000 @@ -21,6 +21,6 @@ private: CIconData* data; }; -}; +} #endif // ICON_H diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/IconHandler.cpp spring-98.0~14.04~ppa6/rts/Rendering/IconHandler.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/IconHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/IconHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -358,4 +358,4 @@ /******************************************************************************/ -}; +} diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/IconHandler.h spring-98.0~14.04~ppa6/rts/Rendering/IconHandler.h --- spring-96.0~14.04~ppa4/rts/Rendering/IconHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/IconHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -62,6 +62,7 @@ public: CIconHandler(); ~CIconHandler(); + CIconHandler(const CIconHandler&) = delete; // no-copy bool AddIcon(const std::string& iconName, const std::string& textureName, @@ -92,6 +93,6 @@ }; extern CIconHandler* iconHandler; -}; +} #endif // ICON_HANDLER_H diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/InMapDrawView.cpp spring-98.0~14.04~ppa6/rts/Rendering/InMapDrawView.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/InMapDrawView.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/InMapDrawView.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -3,7 +3,7 @@ #include "InMapDrawView.h" #include "Rendering/Colors.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Rendering/GL/VertexArray.h" #include "Rendering/GlobalRendering.h" @@ -192,8 +192,6 @@ void CInMapDrawView::Draw() { - GML_STDMUTEX_LOCK(inmap); // Draw - CVertexArray* pointsVa = GetVertexArray(); pointsVa->Initialize(); CVertexArray* linesVa = GetVertexArray(); diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/IPathDrawer.cpp spring-98.0~14.04~ppa6/rts/Rendering/IPathDrawer.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/IPathDrawer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/IPathDrawer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -3,7 +3,6 @@ #include "DefaultPathDrawer.h" #include "QTPFSPathDrawer.h" #include "Game/SelectedUnitsHandler.h" -#include "lib/gml/gmlmut.h" #include "Sim/MoveTypes/MoveDefHandler.h" #include "Sim/Path/IPathManager.h" #include "Sim/Path/Default/PathManager.h" @@ -45,16 +44,12 @@ } const MoveDef* IPathDrawer::GetSelectedMoveDef() { - GML_RECMUTEX_LOCK(sel); // UpdateExtraTexture - const MoveDef* md = NULL; const CUnitSet& unitSet = selectedUnitsHandler.selectedUnits; if (!unitSet.empty()) { const CUnit* unit = *(unitSet.begin()); - const MoveDef* moveDef = unit->moveDef; - - md = moveDef; + md = unit->moveDef; } return md; diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Models/3DModel.cpp spring-98.0~14.04~ppa6/rts/Rendering/Models/3DModel.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Models/3DModel.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Models/3DModel.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -14,7 +14,7 @@ #include #include -CR_BIND(LocalModelPiece, (NULL)); +CR_BIND(LocalModelPiece, (NULL)) CR_REG_METADATA(LocalModelPiece, ( CR_MEMBER(pos), CR_MEMBER(rot), @@ -36,14 +36,14 @@ CR_IGNORED(original), CR_IGNORED(lodDispLists) //FIXME GL idx! -)); +)) -CR_BIND(LocalModel, (NULL)); +CR_BIND(LocalModel, (NULL)) CR_REG_METADATA(LocalModel, ( CR_IGNORED(dirtyPieces), CR_IGNORED(lodCount), //FIXME? CR_MEMBER(pieces) -)); +)) /** **************************************************************************************************** diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Models/3DModel.h spring-98.0~14.04~ppa6/rts/Rendering/Models/3DModel.h --- spring-96.0~14.04~ppa4/rts/Rendering/Models/3DModel.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Models/3DModel.h 2014-10-07 20:09:51.000000000 +0000 @@ -221,7 +221,7 @@ struct LocalModelPiece { - CR_DECLARE_STRUCT(LocalModelPiece); + CR_DECLARE_STRUCT(LocalModelPiece) LocalModelPiece(const S3DModelPiece* piece); ~LocalModelPiece(); @@ -289,7 +289,7 @@ struct LocalModel { - CR_DECLARE_STRUCT(LocalModel); + CR_DECLARE_STRUCT(LocalModel) LocalModel(const S3DModel* model) : dirtyPieces(model->numPieces) diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Models/AssParser.cpp spring-98.0~14.04~ppa6/rts/Rendering/Models/AssParser.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Models/AssParser.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Models/AssParser.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -92,6 +92,7 @@ // return (CMatrix44f(n.GetPos(), n.GetX(), n.GetZ(), -n.GetY())); } +/* static float3 aiQuaternionToRadianAngles(const aiQuaternion q1) { const float sqw = q1.w * q1.w; @@ -120,7 +121,7 @@ return (aiVectorToFloat3(angles)); } - +*/ @@ -137,7 +138,7 @@ S3DModel* CAssParser::Load(const std::string& modelFilePath) { - LOG_S(LOG_SECTION_MODEL, "Loading model: %s", modelFilePath.c_str()); + LOG_SL(LOG_SECTION_MODEL, L_INFO, "Loading model: %s", modelFilePath.c_str()); const std::string& modelPath = FileSystem::GetDirectory(modelFilePath); const std::string& modelName = FileSystem::GetBasename(modelFilePath); @@ -150,7 +151,7 @@ metaFileName = modelPath + '/' + modelName + ".lua"; } if (!CFileHandler::FileExists(metaFileName, SPRING_VFS_ZIP)) { - LOG_S(LOG_SECTION_MODEL, "No meta-file '%s'. Using defaults.", metaFileName.c_str()); + LOG_SL(LOG_SECTION_MODEL, L_INFO, "No meta-file '%s'. Using defaults.", metaFileName.c_str()); } LuaParser metaFileParser(metaFileName, SPRING_VFS_MOD_BASE, SPRING_VFS_ZIP); @@ -163,7 +164,7 @@ const LuaTable& modelTable = metaFileParser.GetRoot(); if (!modelTable.IsValid()) { - LOG_S(LOG_SECTION_MODEL, "No valid model metadata in '%s' or no meta-file", metaFileName.c_str()); + LOG_SL(LOG_SECTION_MODEL, L_INFO, "No valid model metadata in '%s' or no meta-file", metaFileName.c_str()); } @@ -193,7 +194,7 @@ #endif // Read the model file to build a scene object - LOG_S(LOG_SECTION_MODEL, "Importing model file: %s", modelFilePath.c_str()); + LOG_SL(LOG_SECTION_MODEL, L_INFO, "Importing model file: %s", modelFilePath.c_str()); const aiScene* scene; { @@ -203,7 +204,7 @@ } if (scene != NULL) { - LOG_S(LOG_SECTION_MODEL, + LOG_SL(LOG_SECTION_MODEL, L_INFO, "Processing scene for model: %s (%d meshes / %d materials / %d textures)", modelFilePath.c_str(), scene->mNumMeshes, scene->mNumMaterials, scene->mNumTextures); @@ -217,11 +218,11 @@ // Load textures FindTextures(model, scene, modelTable, modelPath, modelName); - LOG_S(LOG_SECTION_MODEL, "Loading textures. Tex1: '%s' Tex2: '%s'", model->tex1.c_str(), model->tex2.c_str()); + LOG_SL(LOG_SECTION_MODEL, L_INFO, "Loading textures. Tex1: '%s' Tex2: '%s'", model->tex1.c_str(), model->tex2.c_str()); texturehandlerS3O->LoadS3OTexture(model); // Load all pieces in the model - LOG_S(LOG_SECTION_MODEL, "Loading pieces from root node '%s'", scene->mRootNode->mName.data); + LOG_SL(LOG_SECTION_MODEL, L_INFO, "Loading pieces from root node '%s'", scene->mRootNode->mName.data); LoadPiece(model, scene->mRootNode, scene, modelTable); // Update piece hierarchy based on metadata @@ -236,7 +237,7 @@ LOG_SL(LOG_SECTION_MODEL, L_DEBUG, "model->drawRadius: %f", model->drawRadius); LOG_SL(LOG_SECTION_MODEL, L_DEBUG, "model->mins: (%f,%f,%f)", model->mins[0], model->mins[1], model->mins[2]); LOG_SL(LOG_SECTION_MODEL, L_DEBUG, "model->maxs: (%f,%f,%f)", model->maxs[0], model->maxs[1], model->maxs[2]); - LOG_S(LOG_SECTION_MODEL, "Model %s Imported.", model->name.c_str()); + LOG_SL(LOG_SECTION_MODEL, L_INFO, "Model %s Imported.", model->name.c_str()); return model; } @@ -316,14 +317,14 @@ pieceRotAngles.z = pieceTable.GetFloat("rotatez", pieceRotAngles.z); pieceRotAngles *= DEGTORAD; - LOG_S(LOG_SECTION_PIECE, + LOG_SL(LOG_SECTION_PIECE, L_INFO, "(%d:%s) Assimp offset (%f,%f,%f), rotate (%f,%f,%f,%f), scale (%f,%f,%f)", model->numPieces, piece->name.c_str(), aiTransVec.x, aiTransVec.y, aiTransVec.z, aiRotateQuat.w, aiRotateQuat.x, aiRotateQuat.y, aiRotateQuat.z, aiScaleVec.x, aiScaleVec.y, aiScaleVec.z ); - LOG_S(LOG_SECTION_PIECE, + LOG_SL(LOG_SECTION_PIECE, L_INFO, "(%d:%s) Relative offset (%f,%f,%f), rotate (%f,%f,%f), scale (%f,%f,%f)", model->numPieces, piece->name.c_str(), piece->offset.x, piece->offset.y, piece->offset.z, @@ -387,7 +388,7 @@ if (!pieceTable.KeyExists("height")) { model->height = piece->offset.y; - LOG_S(LOG_SECTION_MODEL, "Model height of %f set by special node 'SpringHeight'", model->height); + LOG_SL(LOG_SECTION_MODEL, L_INFO, "Model height of %f set by special node 'SpringHeight'", model->height); } --model->numPieces; @@ -405,7 +406,7 @@ // piece can be placed anywhere within the hierarchy model->relMidPos = scaleRotMat.Mul(piece->offset); - LOG_S(LOG_SECTION_MODEL, + LOG_SL(LOG_SECTION_MODEL, L_INFO, "Model midpos of (%f,%f,%f) set by special node 'SpringRadius'", model->relMidPos.x, model->relMidPos.y, model->relMidPos.z); } @@ -428,7 +429,7 @@ model->radius = piece->maxs.x; } - LOG_S(LOG_SECTION_MODEL, "Model radius of %f set by special node 'SpringRadius'", model->radius); + LOG_SL(LOG_SECTION_MODEL, L_INFO, "Model radius of %f set by special node 'SpringRadius'", model->radius); } --model->numPieces; @@ -604,13 +605,13 @@ SetPieceName(piece, model, pieceNode); - LOG_S(LOG_SECTION_PIECE, "Converting node '%s' to piece '%s' (%d meshes).", pieceNode->mName.data, piece->name.c_str(), pieceNode->mNumMeshes); + LOG_SL(LOG_SECTION_PIECE, L_INFO, "Converting node '%s' to piece '%s' (%d meshes).", pieceNode->mName.data, piece->name.c_str(), pieceNode->mNumMeshes); // Load additional piece properties from metadata const LuaTable& pieceTable = modelTable.SubTable("pieces").SubTable(piece->name); if (pieceTable.IsValid()) { - LOG_S(LOG_SECTION_PIECE, "Found metadata for piece '%s'", piece->name.c_str()); + LOG_SL(LOG_SECTION_PIECE, L_INFO, "Found metadata for piece '%s'", piece->name.c_str()); } // Load transforms @@ -623,9 +624,9 @@ SetPieceParentName(piece, model, pieceNode, pieceTable); // Verbose logging of piece properties - LOG_S(LOG_SECTION_PIECE, "Loaded model piece: %s with %d meshes", piece->name.c_str(), pieceNode->mNumMeshes); - LOG_S(LOG_SECTION_PIECE, "piece->name: %s", piece->name.c_str()); - LOG_S(LOG_SECTION_PIECE, "piece->parent: %s", piece->parentName.c_str()); + LOG_SL(LOG_SECTION_PIECE, L_INFO, "Loaded model piece: %s with %d meshes", piece->name.c_str(), pieceNode->mNumMeshes); + LOG_SL(LOG_SECTION_PIECE, L_INFO, "piece->name: %s", piece->name.c_str()); + LOG_SL(LOG_SECTION_PIECE, L_INFO, "piece->parent: %s", piece->parentName.c_str()); // Recursively process all child pieces for (unsigned int i = 0; i < pieceNode->mNumChildren; ++i) { @@ -813,11 +814,11 @@ //FIXME share 1 VBO for ALL models vboAttributes.Bind(GL_ARRAY_BUFFER); - vboAttributes.Resize(vertices.size() * sizeof(SAssVertex), GL_STATIC_DRAW, &vertices[0]); + vboAttributes.New(vertices.size() * sizeof(SAssVertex), GL_STATIC_DRAW, &vertices[0]); vboAttributes.Unbind(); vboIndices.Bind(GL_ELEMENT_ARRAY_BUFFER); - vboIndices.Resize(vertexDrawIndices.size() * sizeof(unsigned int), GL_STATIC_DRAW, &vertexDrawIndices[0]); + vboIndices.New(vertexDrawIndices.size() * sizeof(unsigned int), GL_STATIC_DRAW, &vertexDrawIndices[0]); vboIndices.Unbind(); // NOTE: wasteful to keep these around, but still needed (eg. for Shatter()) diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Models/IModelParser.cpp spring-98.0~14.04~ppa6/rts/Rendering/Models/IModelParser.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Models/IModelParser.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Models/IModelParser.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -17,7 +17,6 @@ #include "System/Util.h" #include "System/Log/ILog.h" #include "System/Exceptions.h" -#include "lib/gml/gml_base.h" #include "lib/assimp/include/assimp/Importer.hpp" C3DModelLoader* modelParser = NULL; @@ -119,11 +118,6 @@ cache.clear(); parsers.clear(); - if (GML::SimEnabled() && !GML::ShareLists()) { - createLists.clear(); - fixLocalModels.clear(); - Update(); // delete remaining local models - } } @@ -185,8 +179,6 @@ S3DModel* C3DModelLoader::Load3DModel(std::string modelName) { - GML_RECMUTEX_LOCK(model); // Load3DModel - // cannot happen except through SpawnProjectile if (modelName.empty()) return NULL; @@ -261,27 +253,6 @@ cache[modelPath] = model->id; } -void C3DModelLoader::Update() { - if (GML::SimEnabled() && !GML::ShareLists()) { - GML_RECMUTEX_LOCK(model); // Update - - for (std::list::iterator it = createLists.begin(); it != createLists.end(); ++it) { - CreateListsNow(*it); - } - createLists.clear(); - - for (std::list::iterator i = fixLocalModels.begin(); i != fixLocalModels.end(); ++i) { - (*i)->ReloadDisplayLists(); - } - fixLocalModels.clear(); - - for (std::list::iterator i = deleteLocalModels.begin(); i != deleteLocalModels.end(); ++i) { - delete *i; - } - deleteLocalModels.clear(); - } -} - void C3DModelLoader::CreateLocalModel(LocalModel* localModel) @@ -291,26 +262,11 @@ if (ompRoot->GetDisplayListID() != 0) return; - - if (GML::SimEnabled() && !GML::ShareLists()) { - GML_RECMUTEX_LOCK(model); // CreateLocalModel - - fixLocalModels.push_back(localModel); - } } void C3DModelLoader::DeleteLocalModel(LocalModel* localModel) { - if (GML::SimEnabled() && !GML::ShareLists()) { - GML_RECMUTEX_LOCK(model); // DeleteLocalModel - - std::list::iterator it = find(fixLocalModels.begin(), fixLocalModels.end(), localModel); - if (it != fixLocalModels.end()) - fixLocalModels.erase(it); - deleteLocalModels.push_back(localModel); - } else { - delete localModel; - } + delete localModel; } @@ -331,11 +287,7 @@ void C3DModelLoader::CreateLists(S3DModelPiece* o) { - if (GML::SimEnabled() && !GML::ShareLists()) - // already mutex'ed via ::Load3DModel() - createLists.push_back(o); - else - CreateListsNow(o); + CreateListsNow(o); } /******************************************************************************/ diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Models/IModelParser.h spring-98.0~14.04~ppa6/rts/Rendering/Models/IModelParser.h --- spring-96.0~14.04~ppa4/rts/Rendering/Models/IModelParser.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Models/IModelParser.h 2014-10-07 20:09:51.000000000 +0000 @@ -25,7 +25,6 @@ C3DModelLoader(); ~C3DModelLoader(); - void Update(); void CreateLocalModel(LocalModel* model); void DeleteLocalModel(LocalModel* model); diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Models/ModelDrawer.h spring-98.0~14.04~ppa6/rts/Rendering/Models/ModelDrawer.h --- spring-96.0~14.04~ppa4/rts/Rendering/Models/ModelDrawer.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Models/ModelDrawer.h 2014-10-07 20:09:51.000000000 +0000 @@ -25,7 +25,6 @@ virtual ~IModelDrawer(); virtual void Draw(); - // NOTE: GML synchronization points virtual void RenderUnitCreated(const CUnit* u, int cloaked); virtual void RenderUnitDestroyed(const CUnit* u); virtual void RenderUnitCloakChanged(const CUnit* u, int cloaked); diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Models/OBJParser.cpp spring-98.0~14.04~ppa6/rts/Rendering/Models/OBJParser.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Models/OBJParser.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Models/OBJParser.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -478,27 +478,27 @@ } vboPositions.Bind(GL_ARRAY_BUFFER); - vboPositions.Resize(vertices.size() * sizeof(float3), GL_STATIC_DRAW, &vertices[0]); + vboPositions.New(vertices.size() * sizeof(float3), GL_STATIC_DRAW, &vertices[0]); vboPositions.Unbind(); vboNormals.Bind(GL_ARRAY_BUFFER); - vboNormals.Resize(vnormals.size() * sizeof(float3), GL_STATIC_DRAW, &vnormals[0]); + vboNormals.New(vnormals.size() * sizeof(float3), GL_STATIC_DRAW, &vnormals[0]); vboNormals.Unbind(); vboTexcoords.Bind(GL_ARRAY_BUFFER); - vboTexcoords.Resize(texcoors.size() * sizeof(float2), GL_STATIC_DRAW, &texcoors[0]); + vboTexcoords.New(texcoors.size() * sizeof(float2), GL_STATIC_DRAW, &texcoors[0]); vboTexcoords.Unbind(); vbosTangents.Bind(GL_ARRAY_BUFFER); - vbosTangents.Resize(sTangents.size() * sizeof(float3), GL_STATIC_DRAW, &sTangents[0]); + vbosTangents.New(sTangents.size() * sizeof(float3), GL_STATIC_DRAW, &sTangents[0]); vbosTangents.Unbind(); vbotTangents.Bind(GL_ARRAY_BUFFER); - vbotTangents.Resize(tTangents.size() * sizeof(float3), GL_STATIC_DRAW, &tTangents[0]); + vbotTangents.New(tTangents.size() * sizeof(float3), GL_STATIC_DRAW, &tTangents[0]); vbotTangents.Unbind(); vboIndices.Bind(GL_ELEMENT_ARRAY_BUFFER); - vboIndices.Resize(vertexDrawIndices.size() * sizeof(unsigned int), GL_STATIC_DRAW, &vertexDrawIndices[0]); + vboIndices.New(vertexDrawIndices.size() * sizeof(unsigned int), GL_STATIC_DRAW, &vertexDrawIndices[0]); vboIndices.Unbind(); // FIXME: diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Models/S3OParser.cpp spring-98.0~14.04~ppa6/rts/Rendering/Models/S3OParser.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Models/S3OParser.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Models/S3OParser.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -138,11 +138,11 @@ //FIXME share 1 VBO for ALL models vboAttributes.Bind(GL_ARRAY_BUFFER); - vboAttributes.Resize(vertices.size() * sizeof(SS3OVertex), GL_STATIC_DRAW, &vertices[0]); + vboAttributes.New(vertices.size() * sizeof(SS3OVertex), GL_STATIC_DRAW, &vertices[0]); vboAttributes.Unbind(); vboIndices.Bind(GL_ELEMENT_ARRAY_BUFFER); - vboIndices.Resize(vertexDrawIndices.size() * sizeof(unsigned int), GL_STATIC_DRAW, &vertexDrawIndices[0]); + vboIndices.New(vertexDrawIndices.size() * sizeof(unsigned int), GL_STATIC_DRAW, &vertexDrawIndices[0]); vboIndices.Unbind(); // NOTE: wasteful to keep these around, but still needed (eg. for Shatter()) diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Models/WorldObjectModelRenderer.cpp spring-98.0~14.04~ppa6/rts/Rendering/Models/WorldObjectModelRenderer.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Models/WorldObjectModelRenderer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Models/WorldObjectModelRenderer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -52,28 +52,15 @@ { PushRenderState(); - { - GML_RECMUTEX_LOCK(unit); // Draw - - for (UnitRenderBinIt uIt = units.begin(); uIt != units.end(); ++uIt) { - DrawModels(units[uIt->first]); - } + for (UnitRenderBinIt uIt = units.begin(); uIt != units.end(); ++uIt) { + DrawModels(units[uIt->first]); } - { - GML_RECMUTEX_LOCK(feat); // Draw - - for (FeatureRenderBinIt fIt = features.begin(); fIt != features.end(); ++fIt) { - DrawModels(features[fIt->first]); - } + for (FeatureRenderBinIt fIt = features.begin(); fIt != features.end(); ++fIt) { + DrawModels(features[fIt->first]); } - { - GML_RECMUTEX_LOCK(proj); // Draw - - for (ProjectileRenderBinIt pIt = projectiles.begin(); pIt != projectiles.end(); ++pIt) { - DrawModels(projectiles[pIt->first]); - } + for (ProjectileRenderBinIt pIt = projectiles.begin(); pIt != projectiles.end(); ++pIt) { + DrawModels(projectiles[pIt->first]); } - PopRenderState(); } diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/ProjectileDrawer.cpp spring-98.0~14.04~ppa6/rts/Rendering/ProjectileDrawer.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/ProjectileDrawer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/ProjectileDrawer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,6 @@ #include "Game/GlobalUnsynced.h" #include "Game/LoadScreen.h" #include "Lua/LuaParser.h" -#include "Lua/LuaRules.h" #include "Map/MapInfo.h" #include "Rendering/GroundFlash.h" #include "Rendering/GlobalRendering.h" @@ -435,11 +434,7 @@ { const CUnit* owner = pro->owner(); - if (GML::SimEnabled()) { - pro->drawPos = pro->pos + (pro->speed * (spring_tomsecs(globalRendering->lastFrameStart)*1.0f - pro->lastProjUpdate*1.0f) * globalRendering->weightedSpeedFactor); - } else { - pro->drawPos = pro->pos + (pro->speed * globalRendering->timeOffset); - } + pro->drawPos = pro->pos + (pro->speed * globalRendering->timeOffset); const bool visible = (gu->spectatingFullView || losHandler->InLos(pro, gu->myAllyTeam) || (owner && teamHandler->Ally(owner->allyteam, gu->myAllyTeam))); @@ -456,7 +451,7 @@ const float dif = pro->pos.y - camera->GetPos().y; const float3 zeroPos = camera->GetPos() * (pro->pos.y / dif) + pro->pos * (-camera->GetPos().y / dif); - if (ground->GetApproximateHeight(zeroPos.x, zeroPos.z, false) > 3 + 0.5f * pro->drawRadius) { + if (CGround::GetApproximateHeight(zeroPos.x, zeroPos.z, false) > 3 + 0.5f * pro->drawRadius) { return; } } @@ -467,8 +462,12 @@ DrawProjectileModel(pro, false); - pro->tempdist = pro->pos.dot(camera->forward); - zSortedProjectiles.insert(pro); + if (pro->drawSorted) { + pro->SetSortDist(pro->pos.dot(camera->forward)); + zSortedProjectiles.insert(pro); + } else { + unsortedProjectiles.push_back(pro); + } } @@ -517,8 +516,6 @@ void CProjectileDrawer::DrawProjectilesMiniMap() { - GML_RECMUTEX_LOCK(proj); // DrawProjectilesMiniMap - typedef std::set ProjectileSet; typedef std::set::const_iterator ProjectileSetIt; typedef std::map ProjectileBin; @@ -623,8 +620,6 @@ ISky::SetupFog(); { - GML_STDMUTEX_LOCK(rpiece); // Draw - projectileHandler->flyingPieces3DO.delete_delayed(); projectileHandler->flyingPieces3DO.add_delayed(); projectileHandler->flyingPiecesS3O.delete_delayed(); @@ -632,6 +627,7 @@ } zSortedProjectiles.clear(); + // unsortedProjectiles.clear(); int numFlyingPieces = projectileHandler->flyingPieces3DO.render_size() + projectileHandler->flyingPiecesS3O.render_size(); int drawnPieces = 0; @@ -639,8 +635,6 @@ Update(); { - GML_RECMUTEX_LOCK(proj); // Draw - unitDrawer->SetupForUnitDrawing(false); for (int modelType = MODELTYPE_3DO; modelType < MODELTYPE_OTHER; modelType++) { @@ -651,7 +645,8 @@ unitDrawer->CleanUpUnitDrawing(false); - // z-sort the model-less projectiles + // note: model-less projectiles are NOT drawn by this call but + // only z-sorted (if the projectiles indicate they want to be) DrawProjectilesSet(renderProjectiles, drawReflection, drawRefraction); projectileHandler->currentParticles = 0; @@ -660,7 +655,10 @@ CProjectile::va->Initialize(); // draw the particle effects - for (std::set::iterator it = zSortedProjectiles.begin(); it != zSortedProjectiles.end(); ++it) { + for (auto it = zSortedProjectiles.begin(); it != zSortedProjectiles.end(); ++it) { + (*it)->Draw(); + } + for (auto it = unsortedProjectiles.begin(); it != unsortedProjectiles.end(); it = unsortedProjectiles.erase(it)) { (*it)->Draw(); } } @@ -669,7 +667,7 @@ glDisable(GL_FOG); if (CProjectile::inArray) { - // Alpha transculent particles + // alpha-translucent particles glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_TEXTURE_2D); textureAtlas->BindTexture(); @@ -714,8 +712,6 @@ CProjectile::va->Initialize(); { - GML_RECMUTEX_LOCK(proj); // DrawShadowPass - for (int modelType = MODELTYPE_3DO; modelType < MODELTYPE_OTHER; modelType++) { DrawProjectilesShadow(modelType); } @@ -758,7 +754,7 @@ glPushMatrix(); glMultMatrixf(wp->GetTransformMatrix(wp->GetProjectileType() == WEAPON_MISSILE_PROJECTILE)); - if (!(/*p->luaDraw &&*/ luaRules != NULL && luaRules->DrawProjectile(p))) { + if (!(/*p->luaDraw &&*/ eventHandler.DrawProjectile(p))) { wp->model->DrawStatic(); } glPopMatrix(); @@ -779,7 +775,7 @@ glTranslatef3(pp->pos); glRotatef(pp->spinAngle, pp->spinVec.x, pp->spinVec.y, pp->spinVec.z); - if (!(/*p->luaDraw &&*/ luaRules != NULL && luaRules->DrawProjectile(p))) { + if (!(/*p->luaDraw &&*/ eventHandler.DrawProjectile(p))) { glCallList(pp->dispList); } glPopMatrix(); @@ -809,8 +805,6 @@ glFogfv(GL_FOG_COLOR, black); { - GML_STDMUTEX_LOCK(rflash); // DrawGroundFlashes - projectileHandler->groundFlashes.delete_delayed(); projectileHandler->groundFlashes.add_delayed(); } @@ -918,7 +912,7 @@ CVertexArray* va = GetVertexArray(); va->Initialize(); - va->CheckInitSize(4 * VA_SIZE_TC, 0); + va->CheckInitSize(4 * VA_SIZE_TC); for (int b = 0; b < 4; ++b) col[b] = int((1.0f - perlinBlend[a]) * 16 * size); @@ -935,7 +929,7 @@ va = GetVertexArray(); va->Initialize(); - va->CheckInitSize(4 * VA_SIZE_TC, 0); + va->CheckInitSize(4 * VA_SIZE_TC); for (int b = 0; b < 4; ++b) col[b] = int(perlinBlend[a] * 16 * size); @@ -988,9 +982,6 @@ { texturehandlerS3O->UpdateDraw(); - if (GML::SimEnabled() && !GML::ShareLists() && p->model && TEX_TYPE(p) < 0) - TEX_TYPE(p) = texturehandlerS3O->LoadS3OTextureNow(p->model); - if (p->model) { modelRenderers[MDL_TYPE(p)]->AddProjectile(p); } else { diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/ProjectileDrawer.h spring-98.0~14.04~ppa6/rts/Rendering/ProjectileDrawer.h --- spring-96.0~14.04~ppa4/rts/Rendering/ProjectileDrawer.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/ProjectileDrawer.h 2014-10-07 20:09:51.000000000 +0000 @@ -21,11 +21,7 @@ typedef ThreadListSimRender, std::set, CGroundFlash*> GroundFlashContainer; -#if defined(USE_GML) && GML_ENABLE_SIM -typedef ThreadListSimRender, std::set, FlyingPiece*> FlyingPieceContainer; -#else typedef ThreadListSimRender, void, FlyingPiece*> FlyingPieceContainer; -#endif class CProjectileDrawer: public CEventClient { @@ -33,6 +29,9 @@ CProjectileDrawer(); ~CProjectileDrawer(); + typedef std::set SortedProjectileSet; + typedef std::list UnsortedProjectileList; + void Draw(bool drawReflection, bool drawRefraction = false); void DrawProjectilesMiniMap(); bool DrawProjectileModel(const CProjectile* projectile, bool shadowPass); @@ -126,10 +125,11 @@ std::vector modelRenderers; /** - * z-sorted set of all projectiles; used to - * render particle effects in back-to-front order + * z-sorted set of projectiles without models; used + * to render particle effects in back-to-front order */ - std::set zSortedProjectiles; + SortedProjectileSet zSortedProjectiles; + UnsortedProjectileList unsortedProjectiles; }; extern CProjectileDrawer* projectileDrawer; diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/QTPFSPathDrawer.cpp spring-98.0~14.04~ppa6/rts/Rendering/QTPFSPathDrawer.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/QTPFSPathDrawer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/QTPFSPathDrawer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -20,7 +20,7 @@ #undef protected #undef private -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Rendering/QTPFSPathDrawer.h" #include "Rendering/GL/glExtra.h" #include "Rendering/GL/myGL.h" @@ -37,8 +37,7 @@ if (md == NULL) return; - // QTPFS::PathManager is not thread-safe - if (!GML::SimEnabled() && enabled && (gs->cheatEnabled || gu->spectating)) { + if (enabled && (gs->cheatEnabled || gu->spectating)) { glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT); glDisable(GL_TEXTURE_2D); glDisable(GL_LIGHTING); @@ -161,8 +160,8 @@ if (!camera->InView(p0) && !camera->InView(p1)) continue; - p0.y = ground->GetHeightReal(p0.x, p0.z, false); - p1.y = ground->GetHeightReal(p1.x, p1.z, false); + p0.y = CGround::GetHeightReal(p0.x, p0.z, false); + p1.y = CGround::GetHeightReal(p1.x, p1.z, false); va->AddVertexQC(p0, color); va->AddVertexQC(p1, color); @@ -250,11 +249,11 @@ #define zmidw (node->zmid() * SQUARE_SIZE) const float3 verts[5] = { - float3(xminw, ground->GetHeightReal(xminw, zminw, false) + 4.0f, zminw), - float3(xmaxw, ground->GetHeightReal(xmaxw, zminw, false) + 4.0f, zminw), - float3(xmaxw, ground->GetHeightReal(xmaxw, zmaxw, false) + 4.0f, zmaxw), - float3(xminw, ground->GetHeightReal(xminw, zmaxw, false) + 4.0f, zmaxw), - float3(xmidw, ground->GetHeightReal(xmidw, zmidw, false) + 4.0f, zmidw), + float3(xminw, CGround::GetHeightReal(xminw, zminw, false) + 4.0f, zminw), + float3(xmaxw, CGround::GetHeightReal(xmaxw, zminw, false) + 4.0f, zminw), + float3(xmaxw, CGround::GetHeightReal(xmaxw, zmaxw, false) + 4.0f, zmaxw), + float3(xminw, CGround::GetHeightReal(xminw, zmaxw, false) + 4.0f, zmaxw), + float3(xmidw, CGround::GetHeightReal(xmidw, zmidw, false) + 4.0f, zmidw), }; static const unsigned char colors[3][4] = { {1 * 255, 0 * 255, 0 * 255, 1 * 255}, // red --> blocked @@ -313,8 +312,8 @@ #define zmidw(n) (n->zmid() * SQUARE_SIZE) const float3 verts[2] = { - float3(xmidw(pushedNode), ground->GetHeightReal(xmidw(pushedNode), zmidw(pushedNode), false) + 4.0f, zmidw(pushedNode)), - float3(xmidw(poppedNode), ground->GetHeightReal(xmidw(poppedNode), zmidw(poppedNode), false) + 4.0f, zmidw(poppedNode)), + float3(xmidw(pushedNode), CGround::GetHeightReal(xmidw(pushedNode), zmidw(pushedNode), false) + 4.0f, zmidw(pushedNode)), + float3(xmidw(poppedNode), CGround::GetHeightReal(xmidw(poppedNode), zmidw(poppedNode), false) + 4.0f, zmidw(poppedNode)), }; static const unsigned char color[4] = { 1 * 255, 0 * 255, 1 * 255, 1 * 128, diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/QTPFSPathDrawer.h spring-98.0~14.04~ppa6/rts/Rendering/QTPFSPathDrawer.h --- spring-96.0~14.04~ppa4/rts/Rendering/QTPFSPathDrawer.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/QTPFSPathDrawer.h 2014-10-07 20:09:51.000000000 +0000 @@ -18,8 +18,8 @@ namespace PathSearchTrace { struct Execution; - }; -}; + } +} struct QTPFSPathDrawer: public IPathDrawer { public: diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Shaders/GLSLCopyState.cpp spring-98.0~14.04~ppa6/rts/Rendering/Shaders/GLSLCopyState.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Shaders/GLSLCopyState.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Shaders/GLSLCopyState.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -373,13 +373,42 @@ } + +static bool CopyShaderState_ContainsGeometryShader(GLuint oldProgID) +{ + bool ret = false; + + GLsizei numAttachedShaders = 0; + GLuint attachedShaderIDs[3] = {0}; + GLint attachedShaderType = 0; + + // glGetProgramiv(oldProgID, GL_ATTACHED_SHADERS, &numAttachedShaders); + glGetAttachedShaders(oldProgID, 3, &numAttachedShaders, &attachedShaderIDs[0]); + + for (GLsizei n = 0; n < numAttachedShaders; n++) { + glGetShaderiv(attachedShaderIDs[n], GL_SHADER_TYPE, &attachedShaderType); + + if ((ret |= (attachedShaderType == GL_GEOMETRY_SHADER))) { + break; + } + } + + return ret; +} + static void CopyShaderState_Geometry(GLuint newProgID, GLuint oldProgID) { #if defined(GL_ARB_geometry_shader4) && defined(GL_ARB_get_program_binary) if (!GLEW_ARB_geometry_shader4) return; + // "GL_INVALID_OPERATION is generated if pname is GL_GEOMETRY_VERTICES_OUT, + // GL_GEOMETRY_INPUT_TYPE, or GL_GEOMETRY_OUTPUT_TYPE, and program does not + // contain a geometry shader." + if (!CopyShaderState_ContainsGeometryShader(oldProgID)) + return; GLint verticesOut = 0, inputType = 0, outputType = 0; + glGetProgramiv(oldProgID, GL_GEOMETRY_INPUT_TYPE, &inputType); glGetProgramiv(oldProgID, GL_GEOMETRY_OUTPUT_TYPE, &outputType); glGetProgramiv(oldProgID, GL_GEOMETRY_VERTICES_OUT, &verticesOut); diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Shaders/Shader.cpp spring-98.0~14.04~ppa6/rts/Rendering/Shaders/Shader.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Shaders/Shader.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Shaders/Shader.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -8,6 +8,12 @@ #include "System/FileSystem/FileHandler.h" #include "System/Log/ILog.h" #include +#ifdef DEBUG + #include // strncmp +#endif +#ifdef HEADLESS + #define GL_INVALID_INDEX -1 +#endif #define LOG_SECTION_SHADER "Shader" @@ -20,6 +26,10 @@ #define LOG_SECTION_CURRENT LOG_SECTION_SHADER +static std::unordered_map glslShadersCache; + + + static bool glslIsValid(GLuint obj) { const bool isShader = glIsShader(obj); @@ -61,7 +71,7 @@ } -static std::string GetShaderSource(std::string fileName) +static std::string GetShaderSource(const std::string& fileName) { std::string soPath = "shaders/" + fileName; std::string soSource = ""; @@ -78,6 +88,19 @@ return soSource; } +static bool ExtractGlslVersion(std::string* src, std::string* version) +{ + const auto pos = src->find("#version "); + + if (pos != std::string::npos) { + const auto eol = src->find('\n', pos) + 1; + *version = src->substr(pos, eol - pos); + src->erase(pos, eol - pos); + return true; + } + return false; +} + @@ -143,46 +166,31 @@ curShaderSrc = GetShaderSource(srcFile); std::string sourceStr = curShaderSrc; + std::string defFlags = rawDefStrs + "\n" + modDefStrs; std::string versionStr; // extract #version pragma and put it on the first line (only allowed there) // version pragma in definitions overrides version pragma in source (if any) - const size_t foo = sourceStr.find("#version "); - const size_t bar = rawDefStrs.find("#version "); - const size_t eos = std::string::npos; - - if (foo != eos) { - versionStr = sourceStr.substr(foo, sourceStr.find('\n', foo) + 1); - sourceStr = sourceStr.substr(0, foo) + sourceStr.substr(sourceStr.find('\n', foo) + 1, eos); - } - if (bar != eos) { - versionStr = rawDefStrs.substr(bar, rawDefStrs.find('\n', bar) + 1); - rawDefStrs = rawDefStrs.substr(0, bar) + rawDefStrs.substr(rawDefStrs.find('\n', bar) + 1, eos); - } - - if (!versionStr.empty() && versionStr[versionStr.size() - 1] != '\n') { versionStr += "\n"; } - if (!rawDefStrs.empty() && rawDefStrs[rawDefStrs.size() - 1] != '\n') { rawDefStrs += "\n"; } - if (!modDefStrs.empty() && modDefStrs[modDefStrs.size() - 1] != '\n') { modDefStrs += "\n"; } - - // NOTE: some drivers cannot handle "#line 0" (?!) - sourceStr = "#line 1\n" + sourceStr; + ExtractGlslVersion(&sourceStr, &versionStr); + ExtractGlslVersion(&defFlags, &versionStr); + if (!versionStr.empty()) EnsureEndsWith(&versionStr, "\n"); + if (!defFlags.empty()) EnsureEndsWith(&defFlags, "\n"); // NOTE: many definition flags are not set until after shader is compiled - const GLchar* sources[7] = { + std::vector sources = { "// SHADER VERSION\n", versionStr.c_str(), "// SHADER FLAGS\n", - rawDefStrs.c_str(), - modDefStrs.c_str(), + defFlags.c_str(), "// SHADER SOURCE\n", + "#line 1\n", sourceStr.c_str() }; - const GLint lengths[7] = {-1, -1, -1, -1, -1, -1, -1}; if (objID == 0) objID = glCreateShader(type); - glShaderSource(objID, 7, sources, lengths); + glShaderSource(objID, sources.size(), &sources[0], NULL); glCompileShader(objID); valid = glslIsValid(objID); @@ -202,49 +210,24 @@ IProgramObject::IProgramObject(const std::string& poName): name(poName), objID(0), curHash(0), valid(false), bound(false) { -#ifdef USE_GML - memset(tbound, 0, sizeof(tbound)); -#endif } void IProgramObject::Enable() { -#ifdef USE_GML - if (GML::ServerActive()) { - tbound[GML::ThreadNumber()] = bound ? 0 : 1; - } else -#endif - { - bound = true; - } + bound = true; } void IProgramObject::Disable() { -#ifdef USE_GML - if (GML::ServerActive()) { - tbound[GML::ThreadNumber()] = bound ? -1 : 0; - } else -#endif - { - bound = false; - } + bound = false; } bool IProgramObject::IsBound() const { -#ifdef USE_GML - if (GML::ServerActive()) { - char tb = tbound[GML::ThreadNumber()]; - return (tb != 0) ? tb > 0 : bound; - } else -#endif - { - return bound; - } + return bound; } void IProgramObject::Release() { - for (SOVecIt it = shaderObjs.begin(); it != shaderObjs.end(); ++it) { - (*it)->Release(); - delete *it; + for (IShaderObject*& so: shaderObjs) { + so->Release(); + delete so; } shaderObjs.clear(); @@ -264,12 +247,10 @@ // NOTE: this does not preserve the #version pragma const std::string definitionFlags = GetString(); - for (SOVecIt it = shaderObjs.begin(); it != shaderObjs.end(); ++it) { - (*it)->SetDefinitions(definitionFlags); + for (IShaderObject*& so: shaderObjs) { + so->SetDefinitions(definitionFlags); } - curHash = hash; - Reload(false); PrintInfo(); } @@ -289,50 +270,42 @@ } } + UniformState* IProgramObject::GetNewUniformState(const std::string name) + { + UniformState* us = &uniformStates.emplace(hashString(name.c_str()), name).first->second; + us->SetLocation(GetUniformLoc(name)); + #if DEBUG + if (us->IsLocationValid()) + us->SetType(GetUniformType(us->GetLocation())); + #endif + return us; + } + ARBProgramObject::ARBProgramObject(const std::string& poName): IProgramObject(poName) { objID = -1; // not used for ARBProgramObject instances uniformTarget = -1; -#ifdef USE_GML - for (int i = 0; i < GML_MAX_NUM_THREADS; ++i) { - tuniformTargets[i] = -1; - } -#endif } void ARBProgramObject::SetUniformTarget(int target) { -#ifdef USE_GML - if (GML::ServerActive()) { - tuniformTargets[GML::ThreadNumber()] = target; - } else -#endif - { - uniformTarget = target; - } + uniformTarget = target; } int ARBProgramObject::GetUnitformTarget() { -#ifdef USE_GML - if (GML::ServerActive()) { - return tuniformTargets[GML::ThreadNumber()]; - } else -#endif - { - return uniformTarget; - } + return uniformTarget; } void ARBProgramObject::Enable() { RecompileIfNeeded(); - for (SOVecConstIt it = shaderObjs.begin(); it != shaderObjs.end(); it++) { - glEnable((*it)->GetType()); - glBindProgramARB((*it)->GetType(), (*it)->GetObjID()); + for (const IShaderObject* so: shaderObjs) { + glEnable(so->GetType()); + glBindProgramARB(so->GetType(), so->GetObjID()); } IProgramObject::Enable(); } void ARBProgramObject::Disable() { - for (SOVecConstIt it = shaderObjs.begin(); it != shaderObjs.end(); it++) { - glBindProgramARB((*it)->GetType(), 0); - glDisable((*it)->GetType()); + for (const IShaderObject* so: shaderObjs) { + glBindProgramARB(so->GetType(), 0); + glDisable(so->GetType()); } IProgramObject::Disable(); } @@ -340,8 +313,8 @@ void ARBProgramObject::Link() { bool shaderObjectsValid = true; - for (SOVecConstIt it = shaderObjs.begin(); it != shaderObjs.end(); it++) { - shaderObjectsValid = (shaderObjectsValid && (*it)->IsValid()); + for (const IShaderObject* so: shaderObjs) { + shaderObjectsValid = (shaderObjectsValid && so->IsValid()); } valid = shaderObjectsValid; @@ -420,6 +393,38 @@ log += glslGetLog(objID); valid = valid && bool(validated); + + #ifdef DEBUG + GLsizei numUniforms, maxUniformNameLength; + glGetProgramiv(objID, GL_ACTIVE_UNIFORMS, &numUniforms); + glGetProgramiv(objID, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformNameLength); + + if (maxUniformNameLength <= 0) + return; + + std::string bufname(maxUniformNameLength, 0); + for (int i = 0; i < numUniforms; ++i) { + GLsizei nameLength = 0; + GLint size = 0; + GLenum type = 0; + glGetActiveUniform(objID, i, maxUniformNameLength, &nameLength, &size, &type, &bufname[0]); + bufname[nameLength] = 0; + + if (nameLength == 0) + continue; + + if (strncmp(&bufname[0], "gl_", 3) == 0) + continue; + + const auto hash = hashString(&bufname[0]); + auto it = uniformStates.find(hash); + if (it != uniformStates.end()) + continue; + + LOG_L(L_WARNING, "[GLSL-PO::%s] program-object name: %s, unset uniform: %s", __FUNCTION__, name.c_str(), &bufname[0]); + //assert(false); + } + #endif } void GLSLProgramObject::Release() { @@ -430,6 +435,9 @@ } void GLSLProgramObject::Reload(bool reloadFromDisk) { + const unsigned int oldHash = curHash; + curHash = GetHash(); + log = ""; valid = false; @@ -439,25 +447,42 @@ GLuint oldProgID = objID; - for (SOVecIt it = GetAttachedShaderObjs().begin(); it != GetAttachedShaderObjs().end(); ++it) { - glDetachShader(oldProgID, (*it)->GetObjID()); + for (auto& us_pair: uniformStates) { + us_pair.second.SetLocation(GL_INVALID_INDEX); } - for (SOVecIt it = GetAttachedShaderObjs().begin(); it != GetAttachedShaderObjs().end(); ++it) { - (*it)->Release(); - (*it)->Compile(reloadFromDisk); + + bool deleteOldShader = false; + if (glslShadersCache.find(oldHash) == glslShadersCache.end()) { + glslShadersCache[oldHash] = oldProgID; + } else { + for (IShaderObject*& so: GetAttachedShaderObjs()) { + glDetachShader(oldProgID, so->GetObjID()); + so->Release(); + } + deleteOldShader = true; } - objID = glCreateProgram(); - for (SOVecIt it = GetAttachedShaderObjs().begin(); it != GetAttachedShaderObjs().end(); ++it) { - if ((*it)->IsValid()) { - glAttachShader(objID, (*it)->GetObjID()); + auto it = glslShadersCache.find(curHash); + if (it != glslShadersCache.end()) { + objID = it->second; + glslShadersCache.erase(it); + } else { + objID = glCreateProgram(); + for (IShaderObject*& so: GetAttachedShaderObjs()) { + so->Compile(reloadFromDisk); //FIXME check if changed or not (when it did, we can't use shader cache!) + } + for (IShaderObject*& so: GetAttachedShaderObjs()) { + if (so->IsValid()) { + glAttachShader(objID, so->GetObjID()); + } } + Link(); } - Link(); GLSLCopyState(objID, oldProgID, &((IProgramObject*)(this))->uniformStates); - glDeleteProgram(oldProgID); + if (deleteOldShader) + glDeleteProgram(oldProgID); } void GLSLProgramObject::AttachShaderObject(IShaderObject* so) { @@ -471,6 +496,14 @@ } } + int GLSLProgramObject::GetUniformType(const int loc) { + GLint size = 0; + GLenum type = 0; + glGetActiveUniform(objID, loc, 0, nullptr, &size, &type, nullptr); + assert(size == 1); // arrays aren't handled yet + return type; + } + int GLSLProgramObject::GetUniformLoc(const std::string& name) { return glGetUniformLocation(objID, name.c_str()); } diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Shaders/Shader.h spring-98.0~14.04~ppa6/rts/Rendering/Shaders/Shader.h --- spring-96.0~14.04~ppa4/rts/Rendering/Shaders/Shader.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Shaders/Shader.h 2014-10-07 20:09:51.000000000 +0000 @@ -8,7 +8,6 @@ #include #include #include "ShaderStates.h" -#include "lib/gml/gmlcnf.h" @@ -92,39 +91,50 @@ void PrintInfo(); + private: + virtual int GetUniformLoc(const std::string& name) = 0; + virtual int GetUniformType(const int loc) = 0; + + private: + UniformState* GetNewUniformState(const std::string name); + public: int GetUniformLocation(const std::string& name) { return GetUniformState(name)->GetLocation(); } + UniformState* GetUniformState(const std::string& name) { - return GetUniformState(hashString(name.c_str()), name); + const auto hash = hashString(name.c_str()); // never compiletime const (std::string is never a literal) + auto it = uniformStates.find(hash); + if (it != uniformStates.end()) + return &it->second; + return GetNewUniformState(name); } - UniformState* GetUniformState(const size_t hash, const std::string& name) { + UniformState* GetUniformState(const char* name) { + // (when inlined) hash might be compiletime const cause of constexpr of hashString + // WARNING: Cause of a bug in gcc, you _must_ assign the constexpr to a var before + // passing it to a function. I.e. foo.find(hashString(name)) would always + // be runtime evaluated (even when `name` is a literal)! + const auto hash = hashString(name); auto it = uniformStates.find(hash); if (it != uniformStates.end()) return &it->second; - //UniformState* us = &uniformStates.emplace(h, name).first->second; - UniformState* us = &uniformStates.insert(std::pair(hash, Shader::UniformState(name))).first->second; - us->SetLocation(GetUniformLoc(name)); - return us; + return GetNewUniformState(name); } - //private: - virtual int GetUniformLoc(const std::string& name) = 0; - - //public: - template inline void SetUniform(const TK& name, TV v0) { SetUniform(GetUniformState(hashString(name), name), v0); } - template inline void SetUniform(const TK& name, TV v0, TV v1) { SetUniform(GetUniformState(hashString(name), name), v0, v1); } - template inline void SetUniform(const TK& name, TV v0, TV v1, TV v2) { SetUniform(GetUniformState(hashString(name), name), v0, v1, v2); } - template inline void SetUniform(const TK& name, TV v0, TV v1, TV v2, TV v3) { SetUniform(GetUniformState(hashString(name), name), v0, v1, v2, v3); } - - template inline void SetUniform2v(const TK& name, const TV* v) { SetUniform2v(GetUniformState(hashString(name), name), v); } - template inline void SetUniform3v(const TK& name, const TV* v) { SetUniform3v(GetUniformState(hashString(name), name), v); } - template inline void SetUniform4v(const TK& name, const TV* v) { SetUniform4v(GetUniformState(hashString(name), name), v); } - - template inline void SetUniformMatrix2x2(const TK& name, bool transp, const TV* v) { SetUniformMatrix2x2(GetUniformState(hashString(name), name), transp, v); } - template inline void SetUniformMatrix3x3(const TK& name, bool transp, const TV* v) { SetUniformMatrix3x3(GetUniformState(hashString(name), name), transp, v); } - template inline void SetUniformMatrix4x4(const TK& name, bool transp, const TV* v) { SetUniformMatrix4x4(GetUniformState(hashString(name), name), transp, v); } + public: + template inline void SetUniform(const TK& name, TV v0) { SetUniform(GetUniformState(name), v0); } + template inline void SetUniform(const TK& name, TV v0, TV v1) { SetUniform(GetUniformState(name), v0, v1); } + template inline void SetUniform(const TK& name, TV v0, TV v1, TV v2) { SetUniform(GetUniformState(name), v0, v1, v2); } + template inline void SetUniform(const TK& name, TV v0, TV v1, TV v2, TV v3) { SetUniform(GetUniformState(name), v0, v1, v2, v3); } + + template inline void SetUniform2v(const TK& name, const TV* v) { SetUniform2v(GetUniformState(name), v); } + template inline void SetUniform3v(const TK& name, const TV* v) { SetUniform3v(GetUniformState(name), v); } + template inline void SetUniform4v(const TK& name, const TV* v) { SetUniform4v(GetUniformState(name), v); } + + template inline void SetUniformMatrix2x2(const TK& name, bool transp, const TV* v) { SetUniformMatrix2x2(GetUniformState(name), transp, v); } + template inline void SetUniformMatrix3x3(const TK& name, bool transp, const TV* v) { SetUniformMatrix3x3(GetUniformState(name), transp, v); } + template inline void SetUniformMatrix4x4(const TK& name, bool transp, const TV* v) { SetUniformMatrix4x4(GetUniformState(name), transp, v); } virtual void SetUniform(UniformState* uState, int v0) { SetUniform1i(uState->GetLocation(), v0); } @@ -143,9 +153,9 @@ virtual void SetUniform4v(UniformState* uState, const int* v) { SetUniform4iv(uState->GetLocation(), v); } virtual void SetUniform4v(UniformState* uState, const float* v) { SetUniform4fv(uState->GetLocation(), v); } - virtual void SetUniformMatrix2x2(UniformState* uState, bool transp, const float* m) { SetUniformMatrix2fv(uState->GetLocation(), transp, m); } - virtual void SetUniformMatrix3x3(UniformState* uState, bool transp, const float* m) { SetUniformMatrix3fv(uState->GetLocation(), transp, m); } - virtual void SetUniformMatrix4x4(UniformState* uState, bool transp, const float* m) { SetUniformMatrix4fv(uState->GetLocation(), transp, m); } + virtual void SetUniformMatrix2x2(UniformState* uState, bool transp, const float* m) { SetUniformMatrix2fv(uState->GetLocation(), transp, m); } + virtual void SetUniformMatrix3x3(UniformState* uState, bool transp, const float* m) { SetUniformMatrix3fv(uState->GetLocation(), transp, m); } + virtual void SetUniformMatrix4x4(UniformState* uState, bool transp, const float* m) { SetUniformMatrix4fv(uState->GetLocation(), transp, m); } virtual void SetUniformTarget(int) {} @@ -203,9 +213,6 @@ bool valid; bool bound; -#ifdef USE_GML - char tbound[GML_MAX_NUM_THREADS]; -#endif SOVec shaderObjs; public: std::unordered_map uniformStates; @@ -220,6 +227,7 @@ void Reload(bool reloadFromDisk) {} int GetUniformLoc(const std::string& name) { return -1; } + int GetUniformType(const int loc) { return -1; } void SetUniform1i(int idx, int v0) {} void SetUniform2i(int idx, int v0, int v1) {} @@ -248,6 +256,7 @@ void Reload(bool reloadFromDisk); int GetUniformLoc(const std::string& name); + int GetUniformType(const int loc) { return -1; } void SetUniformTarget(int target); int GetUnitformTarget(); @@ -271,9 +280,6 @@ private: int uniformTarget; -#ifdef USE_GML - int tuniformTargets[GML_MAX_NUM_THREADS]; -#endif }; struct GLSLProgramObject: public Shader::IProgramObject { @@ -286,6 +292,7 @@ void Release(); void Reload(bool reloadFromDisk); + int GetUniformType(const int loc); int GetUniformLoc(const std::string& name); void SetUniformLocation(const std::string&); diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Shaders/ShaderStates.cpp spring-98.0~14.04~ppa6/rts/Rendering/Shaders/ShaderStates.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Shaders/ShaderStates.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Shaders/ShaderStates.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -3,9 +3,97 @@ //#include #include "Rendering/Shaders/ShaderStates.h" #include "System/Sync/HsiehHash.h" +#include + + +static std::unordered_set samplerTypes{ +#ifndef HEADLESS + GL_SAMPLER_1D, + GL_SAMPLER_2D, + GL_SAMPLER_3D, + GL_SAMPLER_CUBE, + GL_SAMPLER_1D_SHADOW, + GL_SAMPLER_2D_SHADOW, + GL_SAMPLER_1D_ARRAY, + GL_SAMPLER_2D_ARRAY, + GL_SAMPLER_1D_ARRAY_SHADOW, + GL_SAMPLER_2D_ARRAY_SHADOW, + GL_SAMPLER_2D_MULTISAMPLE, + GL_SAMPLER_2D_MULTISAMPLE_ARRAY, + GL_SAMPLER_CUBE_SHADOW, + GL_SAMPLER_BUFFER, + GL_SAMPLER_2D_RECT, + GL_SAMPLER_2D_RECT_SHADOW, + + GL_INT_SAMPLER_1D, + GL_INT_SAMPLER_2D, + GL_INT_SAMPLER_3D, + GL_INT_SAMPLER_CUBE, + GL_INT_SAMPLER_1D_ARRAY, + GL_INT_SAMPLER_2D_ARRAY, + GL_INT_SAMPLER_2D_MULTISAMPLE, + GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, + GL_INT_SAMPLER_BUFFER, + GL_INT_SAMPLER_2D_RECT, + + GL_UNSIGNED_INT_SAMPLER_1D, + GL_UNSIGNED_INT_SAMPLER_2D, + GL_UNSIGNED_INT_SAMPLER_3D, + GL_UNSIGNED_INT_SAMPLER_CUBE, + GL_UNSIGNED_INT_SAMPLER_1D_ARRAY, + GL_UNSIGNED_INT_SAMPLER_2D_ARRAY, + GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE, + GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, + GL_UNSIGNED_INT_SAMPLER_BUFFER, + GL_UNSIGNED_INT_SAMPLER_2D_RECT, +#endif +}; namespace Shader { + int UniformState::Hash(const int v0, const int v1, const int v2, const int v3) const + { + int hash = ~0; + hash += v0 ^ (hash * 33); + hash += v1 ^ (hash * 33); + hash += v2 ^ (hash * 33); + hash += v3 ^ (hash * 33); + return hash; + } + + + int UniformState::Hash(const int* v, int count) const + { + int hash = ~0; + for (int n = 0; n < count; ++n) { + hash += v[n] ^ (hash * 33); + } + return hash; + } + + + bool UniformState::IsLocationValid() const + { + #ifdef HEADLESS + // our stub headers are outdated and are missing GL_INVALID_INDEX + return false; + #else + return (location != GL_INVALID_INDEX); + #endif + } + + +#ifdef DEBUG + void UniformState::AssertType(int type) const + { + int utype = this->type; + if (samplerTypes.find(utype) != samplerTypes.end()) + utype = GL_INT; + assert(type == utype || utype == -1); + } +#endif + + unsigned int SShaderFlagState::GetHash() { if (updates != lastUpdates) { diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Shaders/ShaderStates.h spring-98.0~14.04~ppa6/rts/Rendering/Shaders/ShaderStates.h --- spring-96.0~14.04~ppa4/rts/Rendering/Shaders/ShaderStates.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Shaders/ShaderStates.h 2014-10-07 20:09:51.000000000 +0000 @@ -3,13 +3,20 @@ #ifndef SPRING_SHADER_STATES_HDR #define SPRING_SHADER_STATES_HDR +#include "Rendering/GL/myGL.h" + #include #include #include #include #include -#include "lib/gml/gml_base.h" +// NOTE: +// the hash used here collides too much on certain inputs (eg. team-color +// uniforms) and is not any faster to calculate than 4 direct comparisons +// for floating-point inputs the v* are their bitwise representations (so +// equality testing still works as expected) +//#define USE_HASH_COMPARISON namespace Shader { struct UniformState { @@ -19,87 +26,93 @@ float f[17]; }; - // TODO implement (should be either GL_FLOAT_VEC2, GL_INT_SAMPLER_CUBE, ... see GLSLCopyState.cpp) - // int type; - // current glGetUniformLocation + /// current glGetUniformLocation int location; + /// uniform name in the shader std::string name; + #ifdef DEBUG + /// uniform type + int type; + #endif + public: UniformState(const std::string& _name): location(-1), name(_name) { i[0] = -0xFFFFFF; i[1] = -0xFFFFFF; i[2] = -0xFFFFFF; i[3] = -0xFFFFFF; + #ifdef DEBUG + type = -1; + #endif } const int* GetIntValues() const { return &i[0]; } const float* GetFltValues() const { return &f[0]; } - // int GetType() const { return type; } int GetLocation() const { return location; } const std::string& GetName() const { return name; } - // void SetType(int type) { type = type; } void SetLocation(int loc) { location = loc; } + bool IsLocationValid() const; bool IsUninit() const { return (i[0] == -0xFFFFFF) && (i[1] == -0xFFFFFF) && (i[2] == -0xFFFFFF) && (i[3] == -0xFFFFFF); } - int Hash(const int v0, const int v1, const int v2, const int v3) const { - int hash = ~0;//FIXME check if this is really faster than a for() if() - hash += v0 ^ (hash * 33); - hash += v1 ^ (hash * 33); - hash += v2 ^ (hash * 33); - hash += v3 ^ (hash * 33); - return hash; - } - int Hash(const int* v, int count) const { - int hash = ~0; - for (int n = 0; n < count; ++n) { - hash += v[n] ^ (hash * 33); - } - return hash; - } + public: + int GetType() const { + #ifdef DEBUG + return type; + #else + return -1; + #endif + } + void SetType(int type) { + #ifdef DEBUG + this->type = type; + #endif + } + #ifdef DEBUG + void AssertType(int type) const; + #else + void AssertType(int type) const {} + #endif + + public: + int Hash(const int v0, const int v1, const int v2, const int v3) const; + int Hash(const int* v, int count) const; bool CheckHash(const int v0, const int v1 = 0, const int v2 = 0, const int v3 = 0) const { - // NOTE: - // the hash used here collides too much on certain inputs (eg. team-color - // uniforms) and is not any faster to calculate than 4 direct comparisons - // for floating-point inputs the v* are their bitwise representations (so - // equality testing still works as expected) - #ifdef USE_HASH_COMPARISON + #ifdef USE_HASH_COMPARISON return (Hash(i[0], i[1], i[2], i[3]) == Hash(v0, v1, v2, v3)); - #else + #else return (i[0] == v0 && i[1] == v1 && i[2] == v2 && i[3] == v3); - #endif + #endif } bool CheckHash(const int* v, int count) const { - #ifdef USE_HASH_COMPARISON + #ifdef USE_HASH_COMPARISON return (Hash(i, count) == Hash(v, count)); - #else + #else bool equal = true; for (int n = 0; (n < count) && equal; n++) { equal &= (v[n] == i[n]); } return equal; - #endif + #endif } - - bool Set(const int v0, const int v1 = 0, const int v2 = 0, const int v3 = 0) { - if (GML::ServerActive()) return true; + private: + bool Set_(const int v0, const int v1, const int v2, const int v3) { if (CheckHash(v0, v1, v2, v3)) return false; i[0] = v0; i[1] = v1; i[2] = v2; i[3] = v3; - return true; + return IsLocationValid(); } - bool Set(const float v0, const float v1 = 0.0f, const float v2 = 0.0f, const float v3 = 0.0f) { - if (GML::ServerActive()) return true; + bool Set_(const float v0, const float v1, const float v2, const float v3) { const int i0 = *reinterpret_cast(&v0); const int i1 = *reinterpret_cast(&v1); const int i2 = *reinterpret_cast(&v2); @@ -107,85 +120,103 @@ if (CheckHash(i0, i1, i2, i3)) return false; f[0] = v0; f[1] = v1; f[2] = v2; f[3] = v3; - return true; + return IsLocationValid(); } + public: + bool Set(const int v0, const int v1, const int v2, const int v3) + { AssertType(GL_INT_VEC4); return Set_(v0, v1, v2, v3); } + bool Set(const int v0, const int v1, const int v2) + { AssertType(GL_INT_VEC3); return Set_(v0, v1, v2, 0); } + bool Set(const int v0, const int v1) + { AssertType(GL_INT_VEC2); return Set_(v0, v1, 0, 0); } + bool Set(const int v0) + { AssertType(GL_INT ); return Set_(v0, 0, 0, 0); } + + bool Set(const float v0, const float v1, const float v2, const float v3) + { AssertType(GL_FLOAT_VEC4); return Set_(v0, v1, v2, v3); } + bool Set(const float v0, const float v1, const float v2) + { AssertType(GL_FLOAT_VEC3); return Set_(v0, v1, v2, 0.f); } + bool Set(const float v0, const float v1) + { AssertType(GL_FLOAT_VEC2); return Set_(v0, v1, 0.f, 0.f); } + bool Set(const float v0) + { AssertType(GL_FLOAT ); return Set_(v0, 0.f, 0.f, 0.f); } bool Set2v(const int* v) { - if (GML::ServerActive()) return true; + AssertType(GL_INT_VEC2); if (CheckHash(v[0], v[1])) return false; i[0] = v[0]; i[1] = v[1]; - return true; + return IsLocationValid(); } bool Set3v(const int* v) { - if (GML::ServerActive()) return true; + AssertType(GL_INT_VEC3); if (CheckHash(v[0], v[1], v[2])) return false; i[0] = v[0]; i[1] = v[1]; i[2] = v[2]; - return true; + return IsLocationValid(); } bool Set4v(const int* v) { - if (GML::ServerActive()) return true; + AssertType(GL_INT_VEC4); if (CheckHash(v[0], v[1], v[2], v[3])) return false; i[0] = v[0]; i[1] = v[1]; i[2] = v[2]; i[3] = v[3]; - return true; + return IsLocationValid(); } bool Set2v(const float* v) { - if (GML::ServerActive()) return true; + AssertType(GL_FLOAT_VEC2); const int* vi = reinterpret_cast(v); if (CheckHash(vi[0], vi[1])) return false; f[0] = v[0]; f[1] = v[1]; - return true; + return IsLocationValid(); } bool Set3v(const float* v) { - if (GML::ServerActive()) return true; + AssertType(GL_FLOAT_VEC3); const int* vi = reinterpret_cast(v); if (CheckHash(vi[0], vi[1], vi[2])) return false; f[0] = v[0]; f[1] = v[1]; f[2] = v[2]; - return true; + return IsLocationValid(); } bool Set4v(const float* v) { - if (GML::ServerActive()) return true; + AssertType(GL_FLOAT_VEC4); const int* vi = reinterpret_cast(v); if (CheckHash(vi[0], vi[1], vi[2], vi[3])) return false; f[0] = v[0]; f[1] = v[1]; f[2] = v[2]; f[3] = v[3]; - return true; + return IsLocationValid(); } bool Set2x2(const float* v, bool transp) { - if (GML::ServerActive()) return true; + AssertType(GL_FLOAT_MAT2); const int* vi = reinterpret_cast(v); if (CheckHash(vi, 4) && (bool)i[16] == transp) return false; memcpy(f, v, 4 * sizeof(float)); i[16] = transp; - return true; + return IsLocationValid(); } bool Set3x3(const float* v, bool transp) { - if (GML::ServerActive()) return true; + AssertType(GL_FLOAT_MAT3); const int* vi = reinterpret_cast(v); if (CheckHash(vi, 9) && (bool)i[16] == transp) return false; memcpy(f, v, 9 * sizeof(float)); i[16] = transp; - return true; + return IsLocationValid(); } bool Set4x4(const float* v, bool transp) { - if (GML::ServerActive()) return true; + AssertType(GL_FLOAT_MAT4); const int* vi = reinterpret_cast(v); if (CheckHash(vi, 16) && (bool)i[16] == transp) return false; memcpy(f, v, 16 * sizeof(float)); i[16] = transp; - return true; + return IsLocationValid(); } }; diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/ShadowHandler.cpp spring-98.0~14.04~ppa6/rts/Rendering/ShadowHandler.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/ShadowHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/ShadowHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -12,6 +12,7 @@ #include "Rendering/FeatureDrawer.h" #include "Rendering/ProjectileDrawer.h" #include "Rendering/UnitDrawer.h" +#include "Rendering/Env/GrassDrawer.h" #include "Rendering/Env/ISky.h" #include "Rendering/Env/ITreeDrawer.h" #include "Rendering/GL/FBO.h" @@ -27,7 +28,7 @@ #define SHADOWMATRIX_NONLINEAR 0 -CONFIG(int, Shadows).defaultValue(2).minimumValue(0).description("Sets whether shadows are rendered.\n0:=off, 1:=full, 2:=fast (skip terrain)"); //FIXME document bitmask +CONFIG(int, Shadows).defaultValue(2).minimumValue(-1).safemodeValue(-1).description("Sets whether shadows are rendered.\n-1:=forceoff, 0:=off, 1:=full, 2:=fast (skip terrain)"); //FIXME document bitmask CONFIG(int, ShadowMapSize).defaultValue(CShadowHandler::DEF_SHADOWMAP_SIZE).minimumValue(32).description("Sets the resolution of shadows. Higher numbers increase quality at the cost of performance."); CONFIG(int, ShadowProjectionMode).defaultValue(CShadowHandler::SHADOWPROMODE_CAM_CENTER); @@ -331,7 +332,7 @@ if ((shadowGenBits & SHADOWGEN_BIT_TREE) != 0) { treeDrawer->DrawShadowPass(); - treeDrawer->DrawShadowGrass(); + grassDrawer->DrawShadow(); } if ((shadowGenBits & SHADOWGEN_BIT_PROJ) != 0) @@ -588,7 +589,7 @@ projectionMidPos.x = (gs->mapx * SQUARE_SIZE) * 0.5f; projectionMidPos.z = (gs->mapy * SQUARE_SIZE) * 0.5f; - projectionMidPos.y = ground->GetHeightReal(projectionMidPos.x, projectionMidPos.z, false); + projectionMidPos.y = CGround::GetHeightReal(projectionMidPos.x, projectionMidPos.z, false); } return curMapDiameter; @@ -624,8 +625,8 @@ cx1 = Clamp(x1, 0.0f, (float3::maxxpos + 1.0f)), cz1 = Clamp(z1, 0.0f, (float3::maxzpos + 1.0f)); - const float3 p0 = float3(cx0, ground->GetHeightReal(cx0, cz0, false), cz0); - const float3 p1 = float3(cx1, ground->GetHeightReal(cx1, cz1, false), cz1); + const float3 p0 = float3(cx0, CGround::GetHeightReal(cx0, cz0, false), cz0); + const float3 p1 = float3(cx1, CGround::GetHeightReal(cx1, cz1, false), cz1); frustumPoints[j + 0] = p0; frustumPoints[j + 1] = p1; @@ -638,7 +639,7 @@ projectionMidPos.x = frustumCenter.x / (sides.size() * 2); projectionMidPos.z = frustumCenter.z / (sides.size() * 2); - projectionMidPos.y = ground->GetHeightReal(projectionMidPos.x, projectionMidPos.z, false); + projectionMidPos.y = CGround::GetHeightReal(projectionMidPos.x, projectionMidPos.z, false); // calculate the radius of the minimally-bounding sphere around the projected frustum for (unsigned int n = 0; n < (sides.size() * 2); n++) { diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/ShadowHandler.h spring-98.0~14.04~ppa6/rts/Rendering/ShadowHandler.h --- spring-96.0~14.04~ppa4/rts/Rendering/ShadowHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/ShadowHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -11,7 +11,7 @@ namespace Shader { struct IProgramObject; -}; +} class CCamera; class CShadowHandler diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/SmoothHeightMeshDrawer.cpp spring-98.0~14.04~ppa6/rts/Rendering/SmoothHeightMeshDrawer.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/SmoothHeightMeshDrawer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/SmoothHeightMeshDrawer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -17,7 +17,7 @@ "Show/Hide the smooth air-mesh map overlay") {} bool Execute(const UnsyncedAction& action) const { - SetBoolArg(smoothHeightMeshDrawer->DrawEnabled(), action.GetArgs()); + InverseOrSetBool(smoothHeightMeshDrawer->DrawEnabled(), action.GetArgs()); LogSystemStatus("smooth air-mesh map overlay", smoothHeightMeshDrawer->DrawEnabled()); return true; } diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Textures/Bitmap.cpp spring-98.0~14.04~ppa6/rts/Rendering/Textures/Bitmap.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Textures/Bitmap.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Textures/Bitmap.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,6 +1,6 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - +#include #include #include #include @@ -74,7 +74,7 @@ , xsize(0) , ysize(0) , channels(4) - , type(BitmapTypeStandardRGBA) + , compressed(false) #ifndef BITMAP_NO_OPENGL , textype(GL_TEXTURE_2D) , ddsimage(NULL) @@ -97,13 +97,13 @@ , xsize(old.xsize) , ysize(old.ysize) , channels(old.channels) - , type(old.type) + , compressed(false) #ifndef BITMAP_NO_OPENGL , textype(old.textype) , ddsimage(NULL) #endif // !BITMAP_NO_OPENGL { - assert(old.type != BitmapTypeDDS); + assert(!old.compressed); const int size = xsize*ysize * channels; mem = new unsigned char[size]; @@ -111,16 +111,30 @@ } -CBitmap::CBitmap(const unsigned char* data, int xsize, int ysize) +CBitmap::CBitmap(CBitmap&& bm) + : mem(std::move(bm.mem)) + , xsize(std::move(bm.xsize)) + , ysize(std::move(bm.ysize)) + , channels(std::move(bm.channels)) + , compressed(std::move(bm.compressed)) +#ifndef BITMAP_NO_OPENGL + , textype(std::move(bm.textype)) + , ddsimage(std::move(bm.ddsimage)) +#endif +{ +} + + +CBitmap::CBitmap(const unsigned char* data, int _xsize, int _ysize, int _channels) : mem(NULL) - , xsize(xsize) - , ysize(ysize) - , channels(4) - , type(BitmapTypeStandardRGBA) + , xsize(_xsize) + , ysize(_ysize) + , channels(_channels) + , compressed(false) #ifndef BITMAP_NO_OPENGL , textype(GL_TEXTURE_2D) , ddsimage(NULL) -#endif // !BITMAP_NO_OPENGL +#endif { const int size = xsize*ysize * channels; mem = new unsigned char[size]; @@ -131,10 +145,10 @@ CBitmap& CBitmap::operator=(const CBitmap& bm) { if (this != &bm) { - type = bm.type; xsize = bm.xsize; ysize = bm.ysize; channels = bm.channels; + compressed = bm.compressed; const int size = xsize*ysize * channels; delete[] mem; @@ -157,6 +171,25 @@ } +CBitmap& CBitmap::operator=(CBitmap&& bm) +{ + xsize = bm.xsize; + ysize = bm.ysize; + channels = bm.channels; + compressed = bm.compressed; + mem = bm.mem; + bm.mem = NULL; + +#ifndef BITMAP_NO_OPENGL + textype = bm.textype; + ddsimage = bm.ddsimage; + bm.ddsimage = NULL; +#endif // !BITMAP_NO_OPENGL + + return *this; +} + + void CBitmap::Alloc(int w, int h, int c) { delete[] mem; @@ -176,14 +209,11 @@ Alloc(w, h, channels); } -void CBitmap::AllocDummy() +void CBitmap::AllocDummy(const SColor fill) { - channels = 4; - Alloc(1, 1); - mem[0] = 255; // Red allows us to easily see textures that failed to load - mem[1] = 0; - mem[2] = 0; - mem[3] = 255; // Non Transparent + compressed = false; + Alloc(1, 1, 4); + reinterpret_cast(mem)[0] = fill; } bool CBitmap::Load(std::string const& filename, unsigned char defaultAlpha) @@ -203,7 +233,7 @@ if (filename.find(".dds") != std::string::npos) { #ifndef BITMAP_NO_OPENGL - type = BitmapTypeDDS; + compressed = true; xsize = 0; ysize = 0; channels = 0; @@ -237,7 +267,7 @@ #endif // !BITMAP_NO_OPENGL } - type = BitmapTypeStandardRGBA; + compressed = false; channels = 4; CFileHandler file(filename); @@ -304,7 +334,7 @@ bool CBitmap::LoadGrayscale(const std::string& filename) { - type = BitmapTypeStandardAlpha; + compressed = false; channels = 1; CFileHandler file(filename); @@ -348,7 +378,7 @@ bool CBitmap::Save(std::string const& filename, bool opaque) const { - if (type == BitmapTypeDDS) { + if (compressed) { #ifndef BITMAP_NO_OPENGL return ddsimage->save(filename); #else @@ -399,7 +429,7 @@ #ifndef BITMAP_NO_OPENGL const unsigned int CBitmap::CreateTexture(bool mipmaps) const { - if (type == BitmapTypeDDS) { + if (compressed) { return CreateDDSTexture(0, mipmaps); } @@ -556,9 +586,9 @@ } -void CBitmap::SetTransparent(const SColor& c, const SColor& trans) +void CBitmap::SetTransparent(const SColor& c, const SColor trans) { - if (type != BitmapTypeStandardRGBA) { + if (compressed) { return; } @@ -625,7 +655,7 @@ if ((ty < 0) || (ty >= dst->ysize)) { yoffset = 0; } - int offset = (xoffset + yoffset * dst->xsize) * dst->channels; + int offset = (yoffset * dst->xsize + xoffset) * dst->channels; if (i == 4) { fragment += weight * blurkernel[i] * src[pos + offset]; } else { @@ -639,7 +669,7 @@ void CBitmap::Blur(int iterations, float weight) { - if (type == BitmapTypeDDS) { + if (compressed) { return; } @@ -648,16 +678,14 @@ dst->channels = src->channels; dst->Alloc(xsize,ysize); - for (int i=0; i < iterations; ++i){ - { - for_mt(0, ysize, [&](const int y) { - for (int x=0; x < xsize; x++) { - for (int j=0; j < channels; j++) { - kernelBlur(dst, src->mem, x, y, j, weight); - } + for (int i=0; i < iterations; ++i) { + for_mt(0, ysize, [&](const int y) { + for (int x=0; x < xsize; x++) { + for (int j=0; j < channels; j++) { + kernelBlur(dst, src->mem, x, y, j, weight); } - }); - } + } + }); std::swap(src, dst); } @@ -670,38 +698,15 @@ } -// Unused -CBitmap CBitmap::GetRegion(int startx, int starty, int width, int height) const -{ - CBitmap bm; - - delete[] bm.mem; - bm.mem = new unsigned char[width*height * channels]; - bm.channels = channels; - bm.type = type; - bm.xsize = width; - bm.ysize = height; - - for (int y=0; y < height; ++y) { - for (int x=0; x < width; ++x) { - for (int i=0; i < channels; ++i) { - bm.mem[(y*width + x)*channels + i] = mem[((starty + y)*xsize + startx + x)*channels + i]; - } - } - } - - return bm; -} - - void CBitmap::CopySubImage(const CBitmap& src, int xpos, int ypos) { if (xpos + src.xsize > xsize || ypos + src.ysize > ysize) { - LOG_L(L_WARNING, "CBitmap::CopySubImage src image does not fit into dst"); + LOG_L(L_WARNING, "CBitmap::CopySubImage src image does not fit into dst!"); return; } - if (src.type != BitmapTypeStandardRGBA || type != BitmapTypeStandardRGBA) { + if (compressed || src.compressed) { + LOG_L(L_WARNING, "CBitmap::CopySubImage can't copy compressed textures!"); return; } @@ -715,10 +720,36 @@ } +CBitmap CBitmap::CanvasResize(const int newx, const int newy, const bool center) const +{ + CBitmap bm; + + if (xsize > newx || ysize > newy) { + LOG_L(L_WARNING, "CBitmap::CanvasResize can only upscale (tried to resize %ix%i to %ix%i)!", xsize,ysize,newx,newy); + bm.AllocDummy(); + return bm; + } + + const int borderLeft = (center) ? (newx - xsize) / 2 : 0; + const int borderTop = (center) ? (newy - ysize) / 2 : 0; + + bm.channels = channels; + bm.Alloc(newx, newy); + bm.CopySubImage(*this, borderLeft, borderTop); + + return bm; +} + + SDL_Surface* CBitmap::CreateSDLSurface(bool newPixelData) const { SDL_Surface* surface = NULL; + if (channels < 3) { + LOG_L(L_WARNING, "CBitmap::CreateSDLSurface works only with 24bit RGB and 32bit RGBA pictures!"); + return surface; + } + unsigned char* surfData = NULL; if (newPixelData) { // copy pixel data @@ -745,6 +776,19 @@ newy = std::max(1, newy); CBitmap bm; + + if (compressed) { + LOG_L(L_WARNING, "CBitmap::CreateRescaled doesn't work with compressed textures!"); + bm.AllocDummy(); + return bm; + } + + if (channels != 4) { + LOG_L(L_WARNING, "CBitmap::CreateRescaled only works with RGBA data!"); + bm.AllocDummy(); + return bm; + } + bm.Alloc(newx, newy); const float dx = (float) xsize / newx; @@ -793,7 +837,7 @@ void CBitmap::InvertColors() { - if (type != BitmapTypeStandardRGBA) { + if (compressed) { return; } for (int y = 0; y < ysize; ++y) { @@ -810,7 +854,7 @@ void CBitmap::InvertAlpha() { - if (type != BitmapTypeStandardRGBA) return; // Don't try to invert DDS + if (compressed) return; // Don't try to invert DDS for (int y = 0; y < ysize; ++y) { for (int x = 0; x < xsize; ++x) { const int base = ((y * xsize) + x) * 4; @@ -822,7 +866,7 @@ void CBitmap::GrayScale() { - if (type != BitmapTypeStandardRGBA) { + if (compressed) { return; } for (int y = 0; y < ysize; ++y) { @@ -851,7 +895,7 @@ void CBitmap::Tint(const float tint[3]) { - if (type != BitmapTypeStandardRGBA) { + if (compressed) { return; } for (int y = 0; y < ysize; y++) { @@ -868,7 +912,7 @@ void CBitmap::ReverseYAxis() { - if (type != BitmapTypeStandardRGBA) return; // don't try to flip DDS + if (compressed) return; // don't try to flip DDS unsigned char* tmpLine = new unsigned char[channels * xsize]; for (int y=0; y < (ysize / 2); ++y) { const int pixelLow = (((y ) * xsize) + 0) * channels; diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Textures/Bitmap.h spring-98.0~14.04~ppa6/rts/Rendering/Textures/Bitmap.h --- spring-96.0~14.04~ppa4/rts/Rendering/Textures/Bitmap.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Textures/Bitmap.h 2014-10-07 20:09:51.000000000 +0000 @@ -17,15 +17,18 @@ class CBitmap { public: - CBitmap(const unsigned char* data,int xsize,int ysize); + CBitmap(const unsigned char* data, int xsize, int ysize, int channels = 4); CBitmap(); CBitmap(const CBitmap& old); CBitmap& operator=(const CBitmap& bm); + CBitmap(CBitmap&& bm); + CBitmap& operator=(CBitmap&& bm); virtual ~CBitmap(); void Alloc(int w, int h, int c); void Alloc(int w, int h); + void AllocDummy(const SColor fill = SColor(255,0,0,255)); /// Load data from a file on the VFS bool Load(std::string const& filename, unsigned char defaultAlpha = 255); @@ -37,12 +40,11 @@ const unsigned int CreateDDSTexture(unsigned int texID = 0, bool mipmaps = false) const; void CreateAlpha(unsigned char red, unsigned char green, unsigned char blue); - void SetTransparent(const SColor& c, const SColor& trans = SColor(0,0,0,0)); + void SetTransparent(const SColor& c, const SColor trans = SColor(0,0,0,0)); void Renormalize(float3 newCol); void Blur(int iterations = 1, float weight = 1.0f); - CBitmap GetRegion(int startx, int starty, int width, int height) const; void CopySubImage(const CBitmap& src, int x, int y); /** @@ -64,15 +66,7 @@ int xsize; int ysize; int channels; - - enum BitmapType - { - BitmapTypeStandardRGBA, - BitmapTypeStandardAlpha, - BitmapTypeDDS - }; - - BitmapType type; + bool compressed; #ifndef BITMAP_NO_OPENGL int textype; //! GL_TEXTURE_2D, GL_TEXTURE_CUBE_MAP, ... @@ -80,17 +74,13 @@ #endif // !BITMAP_NO_OPENGL public: + CBitmap CanvasResize(const int newx, const int newy, const bool center = true) const; CBitmap CreateRescaled(int newx, int newy) const; void ReverseYAxis(); void InvertColors(); void InvertAlpha(); void GrayScale(); void Tint(const float tint[3]); -private: - /** - * Allocates a red 1x1, 4-channel bitmap - */ - void AllocDummy(); }; #endif // _BITMAP_H diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Textures/ColorMap.cpp spring-98.0~14.04~ppa6/rts/Rendering/Textures/ColorMap.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Textures/ColorMap.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Textures/ColorMap.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -15,14 +15,14 @@ std::vector CColorMap::colorMaps; std::map CColorMap::colorMapsMap; -CR_BIND(CColorMap,); +CR_BIND(CColorMap,) CR_REG_METADATA(CColorMap, ( CR_MEMBER_UN(map), CR_MEMBER_UN(xsize), CR_MEMBER_UN(nxsize), CR_MEMBER_UN(ysize), CR_MEMBER_UN(nysize) -)); +)) CColorMap::CColorMap() : xsize(0) @@ -59,7 +59,7 @@ throw content_error("Could not load texture from file " + fileName); } - if ((bitmap.type != CBitmap::BitmapTypeStandardRGBA) || (bitmap.xsize < 2)) { + if (bitmap.compressed || (bitmap.channels != 4) || (bitmap.xsize < 2)) { throw content_error("Unsupported bitmap format in file " + fileName); } diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Textures/ColorMap.h spring-98.0~14.04~ppa6/rts/Rendering/Textures/ColorMap.h --- spring-96.0~14.04~ppa4/rts/Rendering/Textures/ColorMap.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Textures/ColorMap.h 2014-10-07 20:09:51.000000000 +0000 @@ -17,7 +17,7 @@ */ class CColorMap { - CR_DECLARE_STRUCT(CColorMap); + CR_DECLARE_STRUCT(CColorMap) public: CColorMap(); /// Loads from a float vector diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Textures/IAtlasAllocator.h spring-98.0~14.04~ppa6/rts/Rendering/Textures/IAtlasAllocator.h --- spring-96.0~14.04~ppa4/rts/Rendering/Textures/IAtlasAllocator.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Textures/IAtlasAllocator.h 2014-10-07 20:09:51.000000000 +0000 @@ -23,9 +23,9 @@ virtual int GetMaxMipMaps() = 0; public: - void AddEntry(const std::string& name, int2 size) + void AddEntry(const std::string& name, int2 size, void* data = NULL) { - entries[name] = SAtlasEntry(size); + entries[name] = SAtlasEntry(size, data); } float4 GetEntry(const std::string& name) @@ -33,6 +33,12 @@ return entries[name].texCoords; } + void*& GetEntryData(const std::string& name) + { + assert(entries[name].data); + return entries[name].data; + } + float4 GetTexCoords(const std::string& name) { float4 uv(entries[name].texCoords); @@ -50,17 +56,31 @@ return uv; } + bool contains(const std::string& name) const + { + return (entries.find(name) != entries.end()); + } + + //! note: it doesn't clear the atlas! it only clears the entry db! + void clear() + { + entries.clear(); + } + //auto begin() { return entries.begin(); } + //auto end() { return entries.end(); } + int2 GetMaxSize() const { return maxsize; } int2 GetAtlasSize() const { return atlasSize; } protected: struct SAtlasEntry { - SAtlasEntry() {} - SAtlasEntry(int2 _size) : size(_size) {} + SAtlasEntry() : data(NULL) {} + SAtlasEntry(const int2 _size, void* _data = NULL) : size(_size), data(_data) {} int2 size; float4 texCoords; + void* data; }; std::map entries; diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Textures/LegacyAtlasAlloc.cpp spring-98.0~14.04~ppa6/rts/Rendering/Textures/LegacyAtlasAlloc.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Textures/LegacyAtlasAlloc.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Textures/LegacyAtlasAlloc.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,9 +1,7 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - #include "LegacyAtlasAlloc.h" -#include "System/Log/ILog.h" -#include "System/Exceptions.h" +#include #include @@ -76,7 +74,7 @@ if (max.y > atlasSize.y) { if (IncreaseSize()) { - nextSub.clear(); + nextSub.clear(); thisSub.clear(); cur.y = max.y = cur.x = 0; recalc = true; diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Textures/NamedTextures.cpp spring-98.0~14.04~ppa6/rts/Rendering/Textures/NamedTextures.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Textures/NamedTextures.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Textures/NamedTextures.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -38,8 +38,6 @@ void Kill() { - GML_STDMUTEX_LOCK(ntex); // Kill - TEXMAP::iterator it; for (it = texMap.begin(); it != texMap.end(); ++it) { const GLuint texID = it->second.id; @@ -130,7 +128,7 @@ return false; } - if (bitmap.type == CBitmap::BitmapTypeDDS) { + if (bitmap.compressed) { texID = bitmap.CreateDDSTexture(texID); } else { if (resize) { @@ -206,7 +204,6 @@ } texInfo.id = texID; - texInfo.type = bitmap.type; texInfo.xsize = bitmap.xsize; texInfo.ysize = bitmap.ysize; @@ -222,8 +219,6 @@ return false; } - GML_STDMUTEX_LOCK(ntex); // Bind - // cached TEXMAP::iterator it = texMap.find(texName); if (it != texMap.end()) { @@ -261,8 +256,6 @@ return; } - GML_STDMUTEX_LOCK(ntex); // Update - glPushAttrib(GL_TEXTURE_BIT); for (std::vector::iterator it = texWaiting.begin(); it != texWaiting.end(); ++it) { TEXMAP::iterator mit = texMap.find(*it); @@ -281,8 +274,6 @@ return false; } - GML_STDMUTEX_LOCK(ntex); // Free - TEXMAP::iterator it = texMap.find(texName); if (it != texMap.end()) { const GLuint texID = it->second.id; @@ -300,8 +291,6 @@ return NULL; } - GML_STDMUTEX_LOCK(ntex); // GetInfo - TEXMAP::const_iterator it = texMap.find(texName); if (it != texMap.end()) { return &it->second; diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Textures/NamedTextures.h spring-98.0~14.04~ppa6/rts/Rendering/Textures/NamedTextures.h --- spring-96.0~14.04~ppa4/rts/Rendering/Textures/NamedTextures.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Textures/NamedTextures.h 2014-10-07 20:09:51.000000000 +0000 @@ -22,15 +22,14 @@ struct TexInfo { TexInfo() - : id(0), type(-1), xsize(-1), ysize(-1), alpha(false) {} + : id(0), xsize(-1), ysize(-1), alpha(false) {} unsigned int id; - int type; int xsize; int ysize; bool alpha; }; const TexInfo* GetInfo(const std::string& texName, const bool forceLoad = false); -}; +} #endif /* NAMED_TEXTURES_H */ diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Textures/nv_dds.cpp spring-98.0~14.04~ppa6/rts/Rendering/Textures/nv_dds.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Textures/nv_dds.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Textures/nv_dds.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -686,9 +686,6 @@ if (is_compressed()) { -#ifdef USE_GML - :: -#endif glCompressedTexImage1DARB(GL_TEXTURE_1D, 0, m_format, baseImage.get_width(), 0, baseImage.get_size(), baseImage); @@ -696,9 +693,6 @@ for (unsigned int i = 0; i < baseImage.get_num_mipmaps(); i++) { const CSurface &mipmap = baseImage.get_mipmap(i); -#ifdef USE_GML - :: -#endif glCompressedTexImage1DARB(GL_TEXTURE_1D, i+1, m_format, mipmap.get_width(), 0, mipmap.get_size(), mipmap); } @@ -761,9 +755,6 @@ if (is_compressed()) { -#ifdef USE_GML - :: -#endif glCompressedTexImage2DARB(target, 0, m_format, image.get_width(), image.get_height(), 0, image.get_size(), image); @@ -771,9 +762,6 @@ for (unsigned int i = 0; i < image.get_num_mipmaps(); i++) { const CSurface &mipmap = image.get_mipmap(i); -#ifdef USE_GML - :: -#endif glCompressedTexImage2DARB(target, i+1, m_format, mipmap.get_width(), mipmap.get_height(), 0, mipmap.get_size(), mipmap); @@ -822,9 +810,6 @@ if (is_compressed()) { -#ifdef USE_GML - :: -#endif glCompressedTexImage3DARB(GL_TEXTURE_3D, 0, m_format, baseImage.get_width(), baseImage.get_height(), baseImage.get_depth(), 0, baseImage.get_size(), baseImage); @@ -833,9 +818,6 @@ for (unsigned int i = 0; i < baseImage.get_num_mipmaps(); i++) { const CSurface &mipmap = baseImage.get_mipmap(i); -#ifdef USE_GML - :: -#endif glCompressedTexImage3DARB(GL_TEXTURE_3D, i+1, m_format, mipmap.get_width(), mipmap.get_height(), mipmap.get_depth(), 0, mipmap.get_size(), mipmap); @@ -850,9 +832,6 @@ glPixelStorei(GL_UNPACK_ALIGNMENT, 1); } -#ifdef USE_GML - :: -#endif glTexImage3D(GL_TEXTURE_3D, 0, m_components, baseImage.get_width(), baseImage.get_height(), baseImage.get_depth(), 0, m_format, GL_UNSIGNED_BYTE, baseImage); @@ -862,9 +841,6 @@ { const CSurface &mipmap = baseImage.get_mipmap(i); -#ifdef USE_GML - :: -#endif glTexImage3D(GL_TEXTURE_3D, i+1, m_components, mipmap.get_width(), mipmap.get_height(), mipmap.get_depth(), 0, m_format, GL_UNSIGNED_BYTE, mipmap); diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Textures/QuadtreeAtlasAlloc.cpp spring-98.0~14.04~ppa6/rts/Rendering/Textures/QuadtreeAtlasAlloc.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Textures/QuadtreeAtlasAlloc.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Textures/QuadtreeAtlasAlloc.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,6 +2,7 @@ #include "QuadtreeAtlasAlloc.h" +#include // memset #include "System/Exceptions.h" #include "System/bitops.h" #include "System/Log/ILog.h" diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Textures/RowAtlasAlloc.cpp spring-98.0~14.04~ppa6/rts/Rendering/Textures/RowAtlasAlloc.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Textures/RowAtlasAlloc.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Textures/RowAtlasAlloc.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,153 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include "RowAtlasAlloc.h" +#include +#include "System/bitops.h" + +// texture spacing in the atlas (in pixels) +static const int ATLAS_PADDING = 1; + + +CRowAtlasAlloc::CRowAtlasAlloc() +: nextRowPos(0) +{ + atlasSize.x = 256; + atlasSize.y = 256; +} + + +inline int CRowAtlasAlloc::CompareTex(SAtlasEntry* tex1, SAtlasEntry* tex2) +{ + // sort by large to small + if (tex1->size.y == tex2->size.y) { + return (tex1->size.x > tex2->size.x); + } + return (tex1->size.y > tex2->size.y); +} + + +void CRowAtlasAlloc::EstimateNeededSize() +{ + int spaceNeeded = 0; + int spaceFree = atlasSize.x * (atlasSize.y - nextRowPos); + for (auto it: entries) { + spaceNeeded += it.second.size.x * it.second.size.y; + } + for(auto& row: imageRows) { + spaceFree += row.height * (atlasSize.x - row.width); + } + + while (spaceFree < spaceNeeded * 1.2f) { + if (atlasSize.x>=maxsize.x && atlasSize.y>=maxsize.y) { + break; + } + + // Resize texture + if ((atlasSize.x << 1) <= maxsize.x) { + spaceFree += atlasSize.x * atlasSize.y; + atlasSize.x = std::min(maxsize.x, atlasSize.x << 1); + } + if ((atlasSize.y << 1) <= maxsize.y) { + spaceFree += atlasSize.x * atlasSize.y; + atlasSize.y = std::min(maxsize.y, atlasSize.y << 1); + } + } +} + + +CRowAtlasAlloc::Row* CRowAtlasAlloc::AddRow(int glyphWidth, int glyphHeight) +{ + const int wantedRowHeight = glyphHeight; + while (atlasSize.y < (nextRowPos + wantedRowHeight)) { + if (atlasSize.x>=maxsize.x && atlasSize.y>=maxsize.y) { + //throw texture_size_exception(); + return nullptr; + } + + // Resize texture + atlasSize.x = std::min(maxsize.x, atlasSize.x << 1); + atlasSize.y = std::min(maxsize.y, atlasSize.y << 1); + } + + Row newrow(nextRowPos, wantedRowHeight); + nextRowPos += wantedRowHeight; + imageRows.push_back(newrow); + return &imageRows.back(); +} + + +bool CRowAtlasAlloc::Allocate() +{ + bool success = true; + + if (npot) { + // revert the used height clamping at the bottom of this function + // else for the case when Allocate() is called multiple times, the width would grew faster than height + // also AddRow() only works with PowerOfTwo values. + atlasSize.y = next_power_of_2(atlasSize.y); + } + + // it gives much better results when we resize the available space before starting allocation + // esp. allocation is more horizontal and so we can clip more free space at bottom + EstimateNeededSize(); + + // sort new entries by height from large to small + std::vector memtextures; + for (auto it = entries.begin(); it != entries.end(); ++it) { + memtextures.push_back(&it->second); + } + sort(memtextures.begin(), memtextures.end(), CRowAtlasAlloc::CompareTex); + + // find space for them + for (auto& curtex: memtextures) { + Row* row = FindRow(curtex->size.x + ATLAS_PADDING, curtex->size.y + ATLAS_PADDING); + if (!row) { + success = false; + continue; + } + + curtex->texCoords.x1 = row->width; + curtex->texCoords.y1 = row->position; + curtex->texCoords.x2 = row->width + curtex->size.x; + curtex->texCoords.y2 = row->position + curtex->size.y; + row->width += curtex->size.x + ATLAS_PADDING; + } + + if (npot) { + atlasSize.y = nextRowPos; + } else { + atlasSize.y = next_power_of_2(nextRowPos); + } + + return success; +} + + +CRowAtlasAlloc::Row* CRowAtlasAlloc::FindRow(int glyphWidth, int glyphHeight) +{ + int best_width = atlasSize.x; + float best_ratio = 10000.0f; + Row* best_row = nullptr; + + // first try to find a row with similar height + for(auto& row: imageRows) { + // Check if there is enough space in this row + if (glyphWidth > (atlasSize.x - row.width)) + continue; + if (glyphHeight > row.height) + continue; + + const float ratio = float(row.height) / glyphHeight; + if ((ratio < best_ratio) || ((ratio == best_ratio) && (row.width < best_width))) { + best_width = row.width; + best_ratio = ratio; + best_row = &row; + } + } + + if (best_row != nullptr) + return best_row; + + // no row found create a new one + return AddRow(glyphWidth, glyphHeight); +} diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Textures/RowAtlasAlloc.h spring-98.0~14.04~ppa6/rts/Rendering/Textures/RowAtlasAlloc.h --- spring-96.0~14.04~ppa4/rts/Rendering/Textures/RowAtlasAlloc.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Textures/RowAtlasAlloc.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,42 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef ROW_ATLAS_ALLOC_H +#define ROW_ATLAS_ALLOC_H + +#include "IAtlasAllocator.h" +#include + + +class CRowAtlasAlloc : public IAtlasAllocator +{ +public: + CRowAtlasAlloc(); + + virtual bool Allocate(); + virtual int GetMaxMipMaps() { return 0; } + +private: + struct Row { + Row(int _ypos,int _height): + position(_ypos), + height(_height), + width(0) { + }; + + int position; + int height; + int width; + }; + +private: + int nextRowPos; + std::list imageRows; + +private: + void EstimateNeededSize(); + Row* AddRow(int glyphWidth, int glyphHeight); + Row* FindRow(int glyphWidth, int glyphHeight); + static int CompareTex(SAtlasEntry* tex1, SAtlasEntry* tex2); +}; + +#endif // ROW_ATLAS_ALLOC_H diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Textures/S3OTextureHandler.cpp spring-98.0~14.04~ppa6/rts/Rendering/Textures/S3OTextureHandler.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Textures/S3OTextureHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Textures/S3OTextureHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -45,9 +45,6 @@ // dummies textures.push_back(new S3OTexMat()); textures.push_back(new S3OTexMat()); - - if (GML::SimEnabled() && GML::ShareLists()) - DoUpdateDraw(); } CS3OTextureHandler::~CS3OTextureHandler() @@ -60,13 +57,12 @@ } void CS3OTextureHandler::LoadS3OTexture(S3DModel* model) { - model->textureType = GML::SimEnabled() && !GML::ShareLists() && GML::IsSimThread() ? -1 : LoadS3OTextureNow(model); + model->textureType = LoadS3OTextureNow(model); } int CS3OTextureHandler::LoadS3OTextureNow(const S3DModel* model) { - GML_RECMUTEX_LOCK(model); // LoadS3OTextureNow - LOG("Load S3O texture now (Flip Y Axis: %s, Invert Team Alpha: %s)", + LOG_L(L_INFO, "Load S3O texture now (Flip Y Axis: %s, Invert Team Alpha: %s)", model->invertTexYAxis ? "yes" : "no", model->invertTexAlpha ? "yes" : "no"); @@ -84,11 +80,7 @@ __FUNCTION__, model->tex1.c_str(), model->name.c_str()); // file not found (or headless build), set single pixel to red so unit is visible - texBitMaps[0].Alloc(1, 1, 4); - texBitMaps[0].mem[0] = 255; - texBitMaps[0].mem[1] = 0; - texBitMaps[0].mem[2] = 0; - texBitMaps[0].mem[3] = 255; // team-color + texBitMaps[0].AllocDummy(SColor(255, 0, 0, 255)); } } @@ -107,11 +99,7 @@ if (texCacheIters[1] == textureCache.end()) { if (!texBitMaps[1].Load(model->tex2)) { if (!texBitMaps[1].Load("unittextures/" + model->tex2)) { - texBitMaps[1].Alloc(1, 1, 4); - texBitMaps[1].mem[0] = 0; // self-illum - texBitMaps[1].mem[1] = 0; // spec+refl - texBitMaps[1].mem[2] = 0; // unused - texBitMaps[1].mem[3] = 255; // transparency + texBitMaps[1].AllocDummy(SColor(0, 0, 0, 255)); } } @@ -160,9 +148,6 @@ textures.push_back(texMat); textureTable[TEX_MAT_UID(texMat->tex1, texMat->tex2)] = texMat; - if (GML::SimEnabled() && GML::ShareLists() && !GML::IsSimThread()) - DoUpdateDraw(); - return texMat; } @@ -181,24 +166,9 @@ void CS3OTextureHandler::SetS3oTexture(int num) { - if (GML::SimEnabled() && GML::ShareLists()) { - if (!GML::IsSimThread()) { - DoSetTexture(texturesDraw[num]); - } else { - // it seems this is only accessed by draw thread, but just in case.. - GML_RECMUTEX_LOCK(model); // SetS3oTexture - DoSetTexture(textures[num]); - } - } else { - DoSetTexture(textures[num]); - } + DoSetTexture(textures[num]); } void CS3OTextureHandler::UpdateDraw() { - if (GML::SimEnabled() && GML::ShareLists()) { - GML_RECMUTEX_LOCK(model); // UpdateDraw - - DoUpdateDraw(); - } } diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Textures/S3OTextureHandler.h spring-98.0~14.04~ppa6/rts/Rendering/Textures/S3OTextureHandler.h --- spring-96.0~14.04~ppa4/rts/Rendering/Textures/S3OTextureHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Textures/S3OTextureHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -48,18 +48,7 @@ public: const S3OTexMat* GetS3oTex(unsigned int num) { S3OTexMat* texMat = NULL; - - if (GML::SimEnabled() && GML::ShareLists()) { - if (!GML::IsSimThread()) { - texMat = (num < texturesDraw.size())? texturesDraw[num]: NULL; - } else { - GML_RECMUTEX_LOCK(model); // GetS3oTex - texMat = (num < textures.size())? textures[num]: NULL; - } - } else { - texMat = (num < textures.size())? textures[num]: NULL; - } - + texMat = (num < textures.size())? textures[num]: NULL; return texMat; } @@ -69,10 +58,6 @@ S3OTexMat* InsertTextureMat(const S3DModel* model); inline void DoUpdateDraw() { - if (GML::SimEnabled() && GML::ShareLists()) { - while (texturesDraw.size() < textures.size()) - texturesDraw.push_back(textures[texturesDraw.size()]); - } } private: diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Textures/TextureAtlas.cpp spring-98.0~14.04~ppa6/rts/Rendering/Textures/TextureAtlas.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/Textures/TextureAtlas.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Textures/TextureAtlas.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -17,13 +17,13 @@ #include #include -CR_BIND(AtlasedTexture, ); +CR_BIND(AtlasedTexture, ) CR_REG_METADATA(AtlasedTexture, - (CR_MEMBER(x), CR_MEMBER(y), CR_MEMBER(z), CR_MEMBER(w))); + (CR_MEMBER(x), CR_MEMBER(y), CR_MEMBER(z), CR_MEMBER(w))) -CR_BIND(GroundFXTexture, ); +CR_BIND(GroundFXTexture, ) CR_REG_METADATA(GroundFXTexture, - (CR_MEMBER(x), CR_MEMBER(y), CR_MEMBER(z), CR_MEMBER(w))); + (CR_MEMBER(x), CR_MEMBER(y), CR_MEMBER(z), CR_MEMBER(w))) // texture spacing in the atlas (in pixels) #define TEXMARGIN 2 @@ -100,7 +100,7 @@ throw content_error("Could not load texture from file " + file); } - if (bitmap.type != CBitmap::BitmapTypeStandardRGBA) { + if (bitmap.channels != 4 || bitmap.compressed) { // only suport RGBA for now throw content_error("Unsupported bitmap format in file " + file); } @@ -134,7 +134,7 @@ PBO pbo; pbo.Bind(); - pbo.Resize(atlasSize.x * atlasSize.y * 4); + pbo.New(atlasSize.x * atlasSize.y * 4); unsigned char* data = (unsigned char*)pbo.MapBuffer(GL_WRITE_ONLY); @@ -182,6 +182,7 @@ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, atlasSize.x, atlasSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, pbo.GetPtr()); } + pbo.Invalidate(); pbo.Unbind(); initialized = true; diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/Textures/TextureAtlas.h spring-98.0~14.04~ppa6/rts/Rendering/Textures/TextureAtlas.h --- spring-96.0~14.04~ppa4/rts/Rendering/Textures/TextureAtlas.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/Textures/TextureAtlas.h 2014-10-07 20:09:51.000000000 +0000 @@ -22,7 +22,7 @@ AtlasedTexture() : float4() {} AtlasedTexture(const float4& f) : float4(f) {} - CR_DECLARE_STRUCT(AtlasedTexture); + CR_DECLARE_STRUCT(AtlasedTexture) }; @@ -33,7 +33,7 @@ */ struct GroundFXTexture : public AtlasedTexture { - CR_DECLARE_STRUCT(GroundFXTexture); + CR_DECLARE_STRUCT(GroundFXTexture) }; diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/UnitDrawer.cpp spring-98.0~14.04~ppa6/rts/Rendering/UnitDrawer.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/UnitDrawer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/UnitDrawer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -13,7 +13,6 @@ #include "Game/UI/MiniMap.h" #include "Lua/LuaMaterial.h" #include "Lua/LuaUnitMaterial.h" -#include "Lua/LuaRules.h" #include "Map/BaseGroundDrawer.h" #include "Map/Ground.h" #include "Map/MapInfo.h" @@ -23,7 +22,7 @@ #include "Rendering/Env/IWater.h" #include "Rendering/Env/CubeMapHandler.h" #include "Rendering/FarTextureHandler.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Rendering/GL/glExtra.h" #include "Rendering/GL/VertexArray.h" #include "Rendering/Env/IGroundDecalDrawer.h" @@ -58,11 +57,6 @@ #include "System/TimeProfiler.h" #include "System/Util.h" -#ifdef USE_GML -#include "lib/gml/gmlsrv.h" -extern gmlClientServer *gmlProcessor; -#endif - #define UNIT_SHADOW_ALPHA_MASKING CUnitDrawer* unitDrawer; @@ -70,9 +64,6 @@ CONFIG(int, UnitLodDist).defaultValue(1000); CONFIG(int, UnitIconDist).defaultValue(200); CONFIG(float, UnitTransparency).defaultValue(0.7f); -CONFIG(bool, ShowHealthBars).defaultValue(true); -CONFIG(bool, MultiThreadDrawUnit).defaultValue(true); -CONFIG(bool, MultiThreadDrawUnitShadow).defaultValue(true); CONFIG(int, MaxDynamicModelLights) .defaultValue(1) @@ -152,12 +143,6 @@ unitRadarIcons.resize(teamHandler->ActiveAllyTeams()); -#ifdef USE_GML - showHealthBars = GML::Enabled() && configHandler->GetBool("ShowHealthBars"); - multiThreadDrawUnit = configHandler->GetBool("MultiThreadDrawUnit"); - multiThreadDrawUnitShadow = configHandler->GetBool("MultiThreadDrawUnitShadow"); -#endif - // LH must be initialized before drawer-state is initialized lightHandler.Init(2U, configHandler->GetInt("MaxDynamicModelLights")); geomBuffer.SetName("UNITDRAWER-GBUFFER"); @@ -239,7 +224,6 @@ void CUnitDrawer::Update() { { - GML_STDMUTEX_LOCK(temp); // Update while (!tempDrawUnits.empty() && tempDrawUnits.begin()->first < gs->frameNum - 1) { tempDrawUnits.erase(tempDrawUnits.begin()); @@ -252,12 +236,8 @@ eventHandler.UpdateDrawUnits(); { - GML_RECMUTEX_LOCK(unit); // Update drawIcon.clear(); -#ifdef USE_GML - drawStat.clear(); -#endif for (std::set::iterator usi = unsortedUnits.begin(); usi != unsortedUnits.end(); ++usi) { CUnit* unit = *usi; @@ -271,7 +251,7 @@ if (useDistToGroundForIcons) { const float3& camPos = camera->GetPos(); // use the height at the current camera position - //const float groundHeight = ground->GetHeightAboveWater(camPos.x, camPos.z, false); + //const float groundHeight = CGround::GetHeightAboveWater(camPos.x, camPos.z, false); // use the middle between the highest and lowest position on the map as average const float groundHeight = (readMap->GetCurrMinHeight() + readMap->GetCurrMaxHeight()) * 0.5f; const float overGround = camPos.y - groundHeight; @@ -302,8 +282,6 @@ // only called by DrawOpaqueUnit inline bool CUnitDrawer::DrawUnitLOD(CUnit* unit) { - GML_LODMUTEX_LOCK(unit); // DrawUnitLOD - if (unit->lodCount > 0) { if (unit->isCloaked) { const LuaMatType matType = (water->DrawReflectionPass())? @@ -356,7 +334,7 @@ camera->GetPos() * (unit->drawMidPos.y / dif) + unit->drawMidPos * (-camera->GetPos().y / dif); } - if (ground->GetApproximateHeight(zeroPos.x, zeroPos.z, false) > unit->drawRadius) { + if (CGround::GetApproximateHeight(zeroPos.x, zeroPos.z, false) > unit->drawRadius) { return; } } @@ -365,10 +343,6 @@ return; } } -#ifdef USE_GML - else - unit->lastDrawFrame = gs->frameNum; -#endif if (!unit->isIcon) { if ((unit->pos).SqDistance(camera->GetPos()) > (unit->sqRadius * unitDrawDistSqr)) { @@ -412,15 +386,6 @@ SetupForUnitDrawing(false); { - GML_RECMUTEX_LOCK(unit); // Draw (lock on the bins) - - #ifdef USE_GML - // these member vars will be accessed by DrawOpaqueUnitMT - mtDrawReflection = drawReflection; - mtDrawRefraction = drawRefraction; - mtExcludeUnit = excludeUnit; - #endif - for (int modelType = MODELTYPE_3DO; modelType < MODELTYPE_OTHER; modelType++) { opaqueModelRenderers[modelType]->PushRenderState(); DrawOpaqueUnits(modelType, excludeUnit, drawReflection, drawRefraction); @@ -472,8 +437,6 @@ SetupForUnitDrawing(true); { - GML_RECMUTEX_LOCK(unit); // Draw (lock on the bins) - for (int modelType = MODELTYPE_3DO; modelType < MODELTYPE_OTHER; modelType++) { opaqueModelRenderers[modelType]->PushRenderState(); DrawOpaqueUnits(modelType, excludeUnit, drawReflection, drawRefraction); @@ -510,19 +473,6 @@ const UnitSet& unitSet = unitBinIt->second; -#ifdef USE_GML - const bool mt = GML_PROFILER(multiThreadDrawUnit) //FIXME DAMN CRAPPY MACRO!!! - - // small unitSets will add a significant overhead - // Profiler results, 4 threads, one single large unitSet: Approximately 20% faster with multiThreadDrawUnit - if (mt && unitSet.size() >= GML::ThreadCount() * 4) { - gmlProcessor->Work( - NULL, NULL, &CUnitDrawer::DrawOpaqueUnitMT, this, GML::ThreadCount(), - FALSE, &unitSet, unitSet.size(), 50, 100, TRUE - ); - } - else -#endif { for (unitSetIt = unitSet.begin(); unitSetIt != unitSet.end(); ++unitSetIt) { DrawOpaqueUnit(*unitSetIt, excludeUnit, drawReflection, drawRefraction); @@ -537,8 +487,6 @@ void CUnitDrawer::DrawOpaqueAIUnits() { - GML_STDMUTEX_LOCK(temp); // DrawOpaqueAIUnits - // non-cloaked AI unit ghosts (FIXME: s3o's + teamcolor) for (std::multimap::iterator ti = tempDrawUnits.begin(); ti != tempDrawUnits.end(); ++ti) { if (camera->InView(ti->second.pos, 100)) { @@ -574,11 +522,6 @@ glDisable(GL_TEXTURE_2D); glDisable(GL_ALPHA_TEST); -#ifdef USE_GML - for (std::set::iterator ui = drawStat.begin(); ui != drawStat.end(); ++ui) { - DrawUnitStatBars(*ui); - } -#endif glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } } @@ -618,19 +561,13 @@ bin->Execute(*currMat, deferredPass); currMat = bin; - const GML_VECTOR& units = bin->GetUnits(); + const std::vector& units = bin->GetUnits(); const int count = (int)units.size(); for (int i = 0; i < count; i++) { CUnit* unit = units[i]; - GML_LODMUTEX_LOCK(unit); // DrawLuaMatBins - const LuaUnitMaterial& unitMat = unit->luaMats[type]; const LuaUnitLODMaterial* lodMat = unitMat.GetMaterial(unit->currentLOD); -#ifdef USE_GML - if (!lodMat || !lodMat->IsActive()) - continue; -#endif lodMat->uniforms.Execute(unit); unitDrawer->SetTeamColour(unit->team); @@ -804,8 +741,6 @@ if (unit->isCloaked) { return; } if (DrawAsIcon(unit, sqDist)) { return; } - GML_LODMUTEX_LOCK(unit); // DrawOpaqueUnitShadow - if (unit->lodCount <= 0) { PUSH_SHADOW_TEXTURE_STATE(unit->model); DrawUnitNow(unit); @@ -840,16 +775,6 @@ for (unitBinIt = unitBin.begin(); unitBinIt != unitBin.end(); ++unitBinIt) { const UnitSet& unitSet = unitBinIt->second; -#ifdef USE_GML - bool mt = GML_PROFILER(multiThreadDrawUnitShadow) - if (mt && unitSet.size() >= GML::ThreadCount() * 4) { // small unitSets will add a significant overhead - gmlProcessor->Work( // Profiler results, 4 threads, one single large unitSet: Approximately 20% faster with multiThreadDrawUnitShadow - NULL, NULL, &CUnitDrawer::DrawOpaqueUnitShadowMT, this, GML::ThreadCount(), - FALSE, &unitSet, unitSet.size(), 50, 100, TRUE - ); - } - else -#endif { for (unitSetIt = unitSet.begin(); unitSetIt != unitSet.end(); ++unitSetIt) { DrawOpaqueUnitShadow(*unitSetIt); @@ -875,8 +800,6 @@ SetUnitGlobalLODFactor(LODScale * LODScaleShadow); - GML_RECMUTEX_LOCK(unit); // DrawShadowPass - { // 3DO's have clockwise-wound faces and // (usually) holes, so disable backface @@ -929,7 +852,7 @@ } // make sure icon is above ground (needed before we calculate scale below) - const float h = ground->GetHeightReal(pos.x, pos.z, false); + const float h = CGround::GetHeightReal(pos.x, pos.z, false); if (pos.y < h) { pos.y = h; @@ -1035,8 +958,6 @@ glColor4f(1.0f, 1.0f, 1.0f, cloakAlpha); { - GML_RECMUTEX_LOCK(unit); // DrawCloakedUnits - for (int modelType = MODELTYPE_3DO; modelType < MODELTYPE_OTHER; modelType++) { cloakedModelRenderers[modelType]->PushRenderState(); DrawCloakedUnitsHelper(modelType); @@ -1149,8 +1070,6 @@ void CUnitDrawer::DrawCloakedAIUnits() { - GML_STDMUTEX_LOCK(temp); // DrawCloakedAIUnits - // cloaked AI unit ghosts (FIXME: S3O's need different state) for (std::multimap::iterator ti = tempTransparentDrawUnits.begin(); ti != tempTransparentDrawUnits.end(); ++ti) { if (camera->InView(ti->second.pos, 100)) { @@ -1368,8 +1287,6 @@ LuaUnitLODMaterial* lodMat = NULL; - GML_LODMUTEX_LOCK(unit); // DrawIndividual - if (unit->lodCount > 0) { const LuaMatType matType = (water->DrawReflectionPass())? LUAMAT_OPAQUE_REFLECT : LUAMAT_OPAQUE; @@ -1640,20 +1557,13 @@ inline void CUnitDrawer::DrawUnitModel(CUnit* unit) { - if (unit->luaDraw && luaRules != NULL && luaRules->DrawUnit(unit)) { + if (unit->luaDraw && eventHandler.DrawUnit(unit)) { return; } if (unit->lodCount <= 0) { unit->localModel->Draw(); } else { - - GML_LODMUTEX_LOCK(unit); // DrawUnitModel -#ifdef USE_GML - if (unit->lodCount <= 0) // re-read the value inside the mutex - unit->localModel->Draw(); - else -#endif unit->localModel->DrawLOD(unit->currentLOD); } } @@ -1723,13 +1633,6 @@ if (unit->lodCount <= 0) { unit->localModel->Draw(); } else { - - GML_LODMUTEX_LOCK(unit); // DrawUnitRawModel -#ifdef USE_GML - if (unit->lodCount <= 0) - unit->localModel->Draw(); - else -#endif unit->localModel->DrawLOD(unit->currentLOD); } } @@ -1753,92 +1656,6 @@ glPopMatrix(); } -#ifdef USE_GML -void CUnitDrawer::DrawUnitStatBars(CUnit* unit) -{ - if ((gu->myAllyTeam != unit->allyteam) && - !gu->spectatingFullView && unit->unitDef->hideDamage) { - return; - } - - float3 interPos = unit->drawPos; - interPos.y += unit->model->height + 5.0f; - - // setup the billboard transformation - glPushMatrix(); - glTranslatef(interPos.x, interPos.y, interPos.z); - glMultMatrixf(camera->GetBillBoardMatrix()); - - if (unit->health < unit->maxHealth || unit->paralyzeDamage > 0.0f) { - // black background for healthbar - glColor3f(0.0f, 0.0f, 0.0f); - glRectf(-5.0f, 4.0f, +5.0f, 6.0f); - - // health & stun level - const float health = std::max(0.0f, unit->health / unit->maxHealth); - const float stun = std::min(1.0f, unit->paralyzeDamage / unit->maxHealth); - float hsmin = std::min(health, stun); - const float colR = std::max(0.0f, 2.0f - 2.0f * health); - const float colG = std::min(2.0f * health, 1.0f); - if (hsmin > 0.0f) { - const float hscol = 0.8f - 0.5f * hsmin; - hsmin *= 10.0f; - glColor3f(colR * hscol, colG * hscol, 1.0f); - glRectf(-5.0f, 4.0f, hsmin - 5.0f, 6.0f); - } - if (health > stun) { - glColor3f(colR, colG, 0.0f); - glRectf(hsmin - 5.0f, 4.0f, health * 10.0f - 5.0f, 6.0f); - } - if (health < stun) { - glColor3f(0.0f, 0.0f, 1.0f); - glRectf(hsmin - 5.0f, 4.0f, stun * 10.0f - 5.0f, 6.0f); - } - } - - // skip the rest of the indicators if it isn't a local unit - if ((gu->myTeam == unit->team) || gu->spectatingFullView) { - // experience bar - if (unit->limExperience > 0.0f) { - const float eEnd = (unit->limExperience * 0.8f) * 10.0f; - glColor3f(1.0f, 1.0f, 1.0f); - glRectf(6.0f, -2.0f, 8.0f, eEnd - 2.0f); - } - if (unit->beingBuilt) { - const float bEnd = (unit->buildProgress * 0.8f) * 10.0f; - glColor3f(1.0f, 0.0f, 0.0f); - glRectf(-8.0f, -2.0f, -6.0f, bEnd - 2.0f); - } - else if (unit->stockpileWeapon) { - const float sEnd = (unit->stockpileWeapon->buildPercent * 0.8f) * 10.0f; - glColor3f(1.0f, 0.0f, 0.0f); - glRectf(-8.0f, -2.0f, -6.0f, sEnd - 2.0f); - } - if (unit->group) { - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - font->glFormat(8.0f, 0.0f, 10.0f, FONT_BASELINE, "%i", unit->group->id); - } - } - - glPopMatrix(); -} - -inline bool CUnitDrawer::UnitStatBarVisible(const CUnit* u) { - if (!showHealthBars) - return false; - if (u->noDraw) - return false; - if (u->IsInVoid()) - return false; - if ((u->pos - camera->GetPos()).SqLength() >= (unitDrawDistSqr * 500.0f)) - return false; - - return (u->health < u->maxHealth || u->paralyzeDamage > 0.0f || u->limExperience > 0.0f || u->beingBuilt || u->stockpileWeapon || u->group != NULL); -} -#endif - - - inline void CUnitDrawer::UpdateUnitIconState(CUnit* unit) { const unsigned short losStatus = unit->losStatus[gu->myAllyTeam]; @@ -1848,11 +1665,6 @@ if ((losStatus & LOS_INLOS) || gu->spectatingFullView) { unit->isIcon = DrawAsIcon(unit, (unit->pos - camera->GetPos()).SqLength()); -#ifdef USE_GML - if (UnitStatBarVisible(unit)) { - drawStat.insert(unit); - } -#endif } else if ((losStatus & LOS_PREVLOS) && (losStatus & LOS_CONTRADAR)) { if (gameSetup->ghostedBuildings && unit->unitDef->IsImmobileUnit()) { unit->isIcon = DrawAsIcon(unit, (unit->pos - camera->GetPos()).SqLength()); @@ -1866,21 +1678,10 @@ inline void CUnitDrawer::UpdateUnitDrawPos(CUnit* u) { const CTransportUnit* trans = u->GetTransporter(); - if (!GML::SimEnabled()) { - if (trans != NULL) { - u->drawPos = u->pos + (trans->speed * globalRendering->timeOffset); - } else { - u->drawPos = u->pos + (u->speed * globalRendering->timeOffset); - } + if (trans != NULL) { + u->drawPos = u->pos + (trans->speed * globalRendering->timeOffset); } else { - const float timeOffset = (1.0f * spring_tomsecs(globalRendering->lastFrameStart)) - (1.0f * u->lastUnitUpdate); - const float timeInterp = timeOffset * globalRendering->weightedSpeedFactor; - - if (trans != NULL) { - u->drawPos = u->pos + (trans->speed * timeInterp); - } else { - u->drawPos = u->pos + (u->speed * timeInterp); - } + u->drawPos = u->pos + (u->speed * globalRendering->timeOffset); } u->drawMidPos = u->drawPos + (u->midPos - u->pos); @@ -1922,7 +1723,6 @@ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); CFeature* feature = NULL; - CVertexArray* va = GetVertexArray(); std::vector buildableSquares; // buildable squares std::vector featureSquares; // occupied squares @@ -1952,6 +1752,7 @@ glColor4f(0.9f, 0.8f, 0.0f, 0.7f); } + CVertexArray* va = GetVertexArray(); va->Initialize(); va->EnlargeArrays(buildableSquares.size() * 4, 0, VA_SIZE_0); @@ -1965,6 +1766,7 @@ glColor4f(0.9f, 0.8f, 0.0f, 0.7f); + va = GetVertexArray(); va->Initialize(); va->EnlargeArrays(featureSquares.size() * 4, 0, VA_SIZE_0); @@ -1978,6 +1780,7 @@ glColor4f(0.9f, 0.0f, 0.0f, 0.7f); + va = GetVertexArray(); va->Initialize(); va->EnlargeArrays(illegalSquares.size() * 4, 0, VA_SIZE_0); @@ -1994,6 +1797,7 @@ const unsigned char s[4] = { 0, 0, 255, 128 }; // start color const unsigned char e[4] = { 0, 128, 255, 255 }; // end color + va = GetVertexArray(); va->Initialize(); va->EnlargeArrays(8, 0, VA_SIZE_C); va->AddVertexQC(float3(x1, h, z1), s); va->AddVertexQC(float3(x1, 0.f, z1), e); @@ -2002,6 +1806,7 @@ va->AddVertexQC(float3(x2, h, z1), s); va->AddVertexQC(float3(x2, 0.f, z1), e); va->DrawArrayC(GL_LINES); + va = GetVertexArray(); va->Initialize(); va->AddVertexQC(float3(x1, 0.0f, z1), e); va->AddVertexQC(float3(x1, 0.0f, z2), e); @@ -2159,13 +1964,6 @@ CUnit* unit = const_cast(u); texturehandlerS3O->UpdateDraw(); - if (GML::SimEnabled() && !GML::ShareLists()) { - if (u->model && TEX_TYPE(u) < 0) - TEX_TYPE(u) = texturehandlerS3O->LoadS3OTextureNow(u->model); - if ((unsortedUnits.size() % 10) == 0) - Watchdog::ClearPrimaryTimers(); // batching can create an avalance of events during /give xxx, triggering hang detection - } - if (u->model != NULL) { if (cloaked) { cloakedModelRenderers[MDL_TYPE(u)]->AddUnit(u); @@ -2181,7 +1979,6 @@ void CUnitDrawer::RenderUnitDestroyed(const CUnit* unit) { CUnit* u = const_cast(unit); - GhostSolidObject* gb = NULL; if ((dynamic_cast(u) != NULL) && gameSetup->ghostedBuildings && !(u->losStatus[gu->myAllyTeam] & (LOS_INLOS | LOS_CONTRADAR)) && @@ -2191,7 +1988,7 @@ const UnitDef* decoyDef = u->unitDef->decoyDef; S3DModel* gbModel = (decoyDef == NULL) ? u->model : decoyDef->LoadModel(); - gb = new GhostSolidObject(); + GhostSolidObject* gb = new GhostSolidObject(); gb->pos = u->pos; gb->model = gbModel; gb->decal = NULL; @@ -2217,11 +2014,6 @@ for (std::vector >::iterator it = unitRadarIcons.begin(); it != unitRadarIcons.end(); ++it) { (*it).erase(u); } -#ifdef USE_GML - drawIcon.erase(u); - drawStat.erase(u); -#endif - UpdateUnitMiniMapIcon(unit, false, true); SetUnitLODCount(u, 0); } @@ -2319,8 +2111,6 @@ void CUnitDrawer::SetUnitLODCount(CUnit* unit, unsigned int count) { - GML_LODMUTEX_LOCK(unit); // SetUnitLODCount - const unsigned int oldCount = unit->lodCount; unit->lodCount = count; @@ -2334,20 +2124,8 @@ for (int m = 0; m < LUAMAT_TYPE_COUNT; m++) { unit->luaMats[m].SetLODCount(count); } -#ifdef USE_GML - if (unit->currentLOD >= count) - unit->currentLOD = (count == 0) ? 0 : count - 1; -#endif } - - - - - - - - void CUnitDrawer::PlayerChanged(int playerNum) { if (playerNum != gu->myPlayerNum) return; diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/UnitDrawer.h spring-98.0~14.04~ppa6/rts/Rendering/UnitDrawer.h --- spring-96.0~14.04~ppa4/rts/Rendering/UnitDrawer.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/UnitDrawer.h 2014-10-07 20:09:51.000000000 +0000 @@ -92,6 +92,9 @@ static void DrawBuildingSample(const UnitDef* unitdef, int team, float3 pos, int facing = 0); static void DrawUnitDef(const UnitDef* unitDef, int team); + /// Returns true if the given unit should be drawn as icon in the current frame. + bool DrawAsIcon(const CUnit* unit, const float sqUnitCamDist) const; + /** LuaOpenGL::Unit{Raw} **/ void DrawIndividual(CUnit* unit); @@ -123,30 +126,6 @@ void SetUseAdvFading(bool b) { advFading = b; } -#ifdef USE_GML - bool multiThreadDrawUnit; - bool multiThreadDrawUnitShadow; - - volatile bool mtDrawReflection; - volatile bool mtDrawRefraction; - const CUnit* volatile mtExcludeUnit; - - bool showHealthBars; - - static void DrawOpaqueUnitMT(void* c, CUnit* unit) { - CUnitDrawer* const ud = reinterpret_cast(c); - ud->DrawOpaqueUnit(unit, ud->mtExcludeUnit, ud->mtDrawReflection, ud->mtDrawRefraction); - } - - static void DrawOpaqueUnitShadowMT(void* c, CUnit* unit) { - reinterpret_cast(c)->DrawOpaqueUnitShadow(unit); - } - - bool UnitStatBarVisible(const CUnit* unit); - void DrawUnitStatBars(CUnit* unit); -#endif - - private: bool DrawUnitLOD(CUnit* unit); void DrawOpaqueUnit(CUnit* unit, const CUnit* excludeUnit, bool drawReflection, bool drawRefraction); @@ -180,9 +159,6 @@ void DrawCloakedUnitsHelper(int modelType); void DrawCloakedUnit(CUnit* unit, int modelType, bool drawGhostBuildingsPass); - /// Returns true if the given unit should be drawn as icon in the current frame. - bool DrawAsIcon(const CUnit* unit, const float sqUnitCamDist) const; - void SelectRenderState(bool shaderPath) { unitDrawerState = shaderPath? unitDrawerStateSSP: unitDrawerStateFFP; } @@ -249,9 +225,6 @@ std::vector > liveGhostBuildings; std::set drawIcon; -#ifdef USE_GML - std::set drawStat; -#endif std::vector > unitRadarIcons; std::map > unitsByIcon; diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/UnitDrawerState.cpp spring-98.0~14.04~ppa6/rts/Rendering/UnitDrawerState.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/UnitDrawerState.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/UnitDrawerState.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -43,6 +43,7 @@ glLoadIdentity(); SetActiveShader(shadowHandler->shadowsLoaded, deferredPass); + assert(modelShaders[MODEL_SHADER_ACTIVE] != NULL); modelShaders[MODEL_SHADER_ACTIVE]->Enable(); // TODO: refactor to use EnableTexturesCommon @@ -75,6 +76,9 @@ } void IUnitDrawerState::DisableCommon(const CUnitDrawer* ud, bool) { + assert(modelShaders[MODEL_SHADER_ACTIVE] != NULL); + + modelShaders[MODEL_SHADER_ACTIVE]->Disable(); SetActiveShader(shadowHandler->shadowsLoaded, false); // TODO: refactor to use DisableTexturesCommon @@ -227,7 +231,7 @@ return false; } if (!configHandler->GetBool("AdvUnitShading")) { - // not allowed to do (ARB) shader-based map rendering + // not allowed to do (ARB) shader-based model rendering return false; } @@ -282,7 +286,6 @@ } void UnitDrawerStateARB::Disable(const CUnitDrawer* ud, bool) { - modelShaders[MODEL_SHADER_ACTIVE]->Disable(); DisableCommon(ud, false); } @@ -330,7 +333,7 @@ return false; } if (!configHandler->GetBool("AdvUnitShading")) { - // not allowed to do (GLSL) shader-based map rendering + // not allowed to do (GLSL) shader-based model rendering return false; } @@ -423,7 +426,6 @@ } void UnitDrawerStateGLSL::Disable(const CUnitDrawer* ud, bool deferredPass) { - modelShaders[MODEL_SHADER_ACTIVE]->Disable(); DisableCommon(ud, deferredPass); } @@ -437,12 +439,11 @@ void UnitDrawerStateGLSL::UpdateCurrentShader(const CUnitDrawer* ud, const ISkyLight* skyLight) const { const float3 modUnitSunColor = ud->unitSunColor * skyLight->GetLightIntensity(); - const float3 sunDir = skyLight->GetLightDir(); // note: the NOSHADOW shaders do not care about shadow-density for (unsigned int n = MODEL_SHADER_NOSHADOW_STANDARD; n <= MODEL_SHADER_SHADOWED_DEFERRED; n++) { modelShaders[n]->Enable(); - modelShaders[n]->SetUniform3fv(5, &sunDir.x); + modelShaders[n]->SetUniform3fv(5, &skyLight->GetLightDir().x); modelShaders[n]->SetUniform1f(12, skyLight->GetUnitShadowDensity()); modelShaders[n]->SetUniform3fv(11, &modUnitSunColor.x); modelShaders[n]->Disable(); diff -Nru spring-96.0~14.04~ppa4/rts/Rendering/WorldDrawer.cpp spring-98.0~14.04~ppa6/rts/Rendering/WorldDrawer.cpp --- spring-96.0~14.04~ppa4/rts/Rendering/WorldDrawer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Rendering/WorldDrawer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -5,6 +5,7 @@ #include "WorldDrawer.h" #include "Rendering/Env/CubeMapHandler.h" +#include "Rendering/Env/GrassDrawer.h" #include "Rendering/Env/IGroundDecalDrawer.h" #include "Rendering/Env/ISky.h" #include "Rendering/Env/ITreeDrawer.h" @@ -49,6 +50,7 @@ loadscreen->SetLoadMessage("Creating TreeDrawer"); treeDrawer = ITreeDrawer::GetTreeDrawer(); + grassDrawer = new CGrassDrawer(); inMapDrawerView = new CInMapDrawView(); pathDrawer = IPathDrawer::GetInstance(); @@ -74,6 +76,7 @@ SafeDelete(water); SafeDelete(sky); SafeDelete(treeDrawer); + SafeDelete(grassDrawer); SafeDelete(pathDrawer); SafeDelete(modelDrawer); SafeDelete(shadowHandler); @@ -130,7 +133,7 @@ } { SCOPED_TIMER("WorldDrawer::Foliage"); - treeDrawer->DrawGrass(); + grassDrawer->Draw(); gd->DrawTrees(); } smoothHeightMeshDrawer->Draw(1.0f); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/CMakeLists.txt spring-98.0~14.04~ppa6/rts/Sim/CMakeLists.txt --- spring-96.0~14.04~ppa4/rts/Sim/CMakeLists.txt 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -1,7 +1,7 @@ # This list was created using this *nix shell command: # > find . -name "*.cpp"" | sort -SET(sources_engine_Sim +add_library(engineSim STATIC "${CMAKE_CURRENT_SOURCE_DIR}/Features/Feature.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Features/FeatureDef.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Features/FeatureHandler.cpp" @@ -52,7 +52,7 @@ "${CMAKE_CURRENT_SOURCE_DIR}/Objects/SolidObject.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Objects/SolidObjectDef.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Objects/WorldObject.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/Path/Default/PathAllocator.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/Path/Default/IPathFinder.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Path/Default/PathCache.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Path/Default/PathEstimator.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Path/Default/PathFinder.cpp" @@ -163,4 +163,13 @@ "${CMAKE_CURRENT_SOURCE_DIR}/Weapons/WeaponLoader.cpp" ) -MakeGlobal(sources_engine_Sim) +include_directories(${SDL2_INCLUDE_DIR}) + +get_property(SPRING_SIM_LIBRARIES TARGET engineSim PROPERTY LOCATION) +if( CMAKE_COMPILER_IS_GNUCXX) + # FIXME: hack to avoid linkers to remove not referenced symbols. required because of + # http://springrts.com/mantis/view.php?id=4511 + MakeGlobalVar(SPRING_SIM_LIBRARIES "-Wl,-whole-archive ${SPRING_SIM_LIBRARIES} -Wl,-no-whole-archive") +else() + MakeGlobalVar(SPRING_SIM_LIBRARIES "${SPRING_SIM_LIBRARIES}") +endif() diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Features/Feature.cpp spring-98.0~14.04~ppa6/rts/Sim/Features/Feature.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Features/Feature.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Features/Feature.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -4,7 +4,6 @@ #include "Feature.h" #include "FeatureHandler.h" #include "Game/GlobalUnsynced.h" -#include "Lua/LuaRules.h" #include "Map/Ground.h" #include "Map/ReadMap.h" #include "Map/MapInfo.h" @@ -35,7 +34,6 @@ CR_MEMBER(resurrectProgress), CR_MEMBER(reclaimLeft), CR_MEMBER(finalHeight), - CR_MEMBER(tempNum), CR_MEMBER(lastReclaim), CR_MEMBER(drawQuad), CR_MEMBER(fireTime), @@ -47,7 +45,7 @@ CR_MEMBER(solidOnTop), CR_MEMBER(transMatrix), CR_POSTLOAD(PostLoad) -)); +)) CFeature::CFeature() : CSolidObject(), @@ -58,7 +56,6 @@ resurrectProgress(0.0f), reclaimLeft(1.0f), finalHeight(0.0f), - tempNum(0), lastReclaim(0), drawQuad(-2), fireTime(0), @@ -220,9 +217,9 @@ eventHandler.FeatureCreated(this); if (def->floating) { - finalHeight = ground->GetHeightAboveWater(pos.x, pos.z); + finalHeight = CGround::GetHeightAboveWater(pos.x, pos.z); } else { - finalHeight = ground->GetHeightReal(pos.x, pos.z); + finalHeight = CGround::GetHeightReal(pos.x, pos.z); } UpdatePhysicalStateBit(CSolidObject::PSTATE_BIT_MOVING, ((SetSpeed(params.speed) != 0.0f) || (std::fabs(pos.y - finalHeight) >= 0.01f))); @@ -231,7 +228,7 @@ void CFeature::CalculateTransform() { - updir = (!def->upright)? ground->GetNormal(pos.x, pos.z): UpVector; + updir = (!def->upright)? CGround::GetNormal(pos.x, pos.z): UpVector; frontdir = GetVectorFromHeading(heading); rightdir = (frontdir.cross(updir)).Normalize(); frontdir = (updir.cross(rightdir)).Normalize(); @@ -272,11 +269,10 @@ // Work out how much that will cost const float metalUse = step * def->metal; const float energyUse = step * def->energy; - - const bool repairAllowed = (luaRules == NULL || luaRules->AllowFeatureBuildStep(builder, this, step)); const bool canExecRepair = (builderTeam->metal >= metalUse && builderTeam->energy >= energyUse); + const bool repairAllowed = !canExecRepair ? false : eventHandler.AllowFeatureBuildStep(builder, this, step); - if (repairAllowed && canExecRepair) { + if (repairAllowed) { builder->UseMetal(metalUse); builder->UseEnergy(energyUse); @@ -314,7 +310,7 @@ const float step = (-amount) / def->reclaimTime; - if (luaRules != NULL && !luaRules->AllowFeatureBuildStep(builder, this, -step)) + if (!eventHandler.AllowFeatureBuildStep(builder, this, -step)) return false; // stop the last bit giving too much resource @@ -388,8 +384,8 @@ float baseDamage = damages.GetDefaultDamage(); float impulseMult = float((def->drawType >= DRAWTYPE_TREE) || (udef != NULL && !udef->IsImmobileUnit())); - if (luaRules != NULL) { - luaRules->FeaturePreDamaged(this, attacker, baseDamage, weaponDefID, projectileID, &baseDamage, &impulseMult); + if (eventHandler.FeaturePreDamaged(this, attacker, baseDamage, weaponDefID, projectileID, &baseDamage, &impulseMult)) { + return; } // NOTE: @@ -462,16 +458,10 @@ void CFeature::ForcedSpin(const float3& newDir) { - float3 updir = UpVector; - if (updir == newDir) { - //FIXME perhaps save the old right,up,front directions, so we can - // reconstruct the old upvector and generate a better assumption for updir - updir -= GetVectorFromHeading(heading); - } - float3 rightdir = newDir.cross(updir).Normalize(); - updir = rightdir.cross(newDir); - transMatrix = CMatrix44f(pos, -rightdir, updir, newDir); - heading = GetHeadingFromVector(newDir.x, newDir.z); + // update local direction-vectors + CSolidObject::ForcedSpin(newDir); + + transMatrix = CMatrix44f(pos, -rightdir, updir, frontdir); } @@ -488,7 +478,7 @@ // even if their "owner" was a floating object (as is the case for // ships anyway) if (IsMoving()) { - const float realGroundHeight = ground->GetHeightReal(pos.x, pos.z); + const float realGroundHeight = CGround::GetHeightReal(pos.x, pos.z); const bool reachedWater = ( pos.y <= 0.1f); const bool reachedGround = ((pos.y - realGroundHeight) <= 0.1f); @@ -499,15 +489,18 @@ CWorldObject::SetVelocity(speed + GetDragAccelerationVec(float4(mapInfo->atmosphere.fluidDensity, mapInfo->water.fluidDensity, 1.0f, 0.1f))); if (speed.SqLength2D() > 0.01f) { - UnBlock(); + //hint: only this updates horizontal position all other + // lines in this function update vertical speed only! + quadField->RemoveFeature(this); + UnBlock(); // update our forward speed (and quadfield // position) if it is still greater than 0 Move(speed, true); - quadField->AddFeature(this); Block(); + quadField->AddFeature(this); } else { CWorldObject::SetVelocity(speed * UpVector); } @@ -571,6 +564,7 @@ UpdatePhysicalStateBit(CSolidObject::PSTATE_BIT_MOVING, ((SetSpeed(speed) != 0.0f) || (std::fabs(pos.y - finalHeight) >= 0.01f))); UpdatePhysicalState(0.1f); + Block(); // does the check if wanted itself return (IsMoving()); } @@ -582,9 +576,9 @@ if (useGroundHeight) { if (def->floating) { - finalHeight = ground->GetHeightAboveWater(pos.x, pos.z); + finalHeight = CGround::GetHeightAboveWater(pos.x, pos.z); } else { - finalHeight = ground->GetHeightReal(pos.x, pos.z); + finalHeight = CGround::GetHeightReal(pos.x, pos.z); } } else { // permanently stay at this height, diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Features/FeatureDef.cpp spring-98.0~14.04~ppa6/rts/Sim/Features/FeatureDef.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Features/FeatureDef.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Features/FeatureDef.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -4,7 +4,7 @@ #include "Sim/Misc/CollisionVolume.h" #include "System/EventHandler.h" -CR_BIND(FeatureDef, ); +CR_BIND(FeatureDef, ) CR_REG_METADATA(FeatureDef, ( CR_MEMBER(description), @@ -18,7 +18,7 @@ CR_MEMBER(geoThermal), CR_MEMBER(deathFeatureDefID), CR_MEMBER(smokeTime) -)); +)) FeatureDef::FeatureDef() : deathFeatureDefID(-1) diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Features/FeatureDef.h spring-98.0~14.04~ppa6/rts/Sim/Features/FeatureDef.h --- spring-96.0~14.04~ppa4/rts/Sim/Features/FeatureDef.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Features/FeatureDef.h 2014-10-07 20:09:51.000000000 +0000 @@ -16,7 +16,7 @@ struct FeatureDef: public SolidObjectDef { - CR_DECLARE_STRUCT(FeatureDef); + CR_DECLARE_STRUCT(FeatureDef) FeatureDef(); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Features/Feature.h spring-98.0~14.04~ppa6/rts/Sim/Features/Feature.h --- spring-96.0~14.04~ppa4/rts/Sim/Features/Feature.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Features/Feature.h 2014-10-07 20:09:51.000000000 +0000 @@ -12,7 +12,6 @@ #include "Sim/Units/UnitHandler.h" #include "System/Matrix44f.h" #include "Sim/Misc/LosHandler.h" -#include "Sim/Misc/ModInfo.h" #define TREE_RADIUS 20 @@ -26,7 +25,7 @@ class CFeature: public CSolidObject, public boost::noncopyable { - CR_DECLARE(CFeature); + CR_DECLARE(CFeature) public: CFeature(); @@ -89,7 +88,6 @@ float reclaimLeft; float finalHeight; - int tempNum; int lastReclaim; /// which drawQuad we are part of diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Features/FeatureHandler.cpp spring-98.0~14.04~ppa6/rts/Sim/Features/FeatureHandler.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Features/FeatureHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Features/FeatureHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -3,7 +3,6 @@ #include "FeatureHandler.h" #include "Lua/LuaParser.h" -#include "Lua/LuaRules.h" #include "Map/ReadMap.h" #include "Sim/Misc/CollisionVolume.h" #include "Sim/Misc/QuadField.h" @@ -20,7 +19,7 @@ /******************************************************************************/ -CR_BIND(CFeatureHandler, (NULL)); +CR_BIND(CFeatureHandler, (NULL)) CR_REG_METADATA(CFeatureHandler, ( CR_MEMBER(idPool), CR_MEMBER(featureDefs), @@ -30,7 +29,7 @@ CR_MEMBER(features), CR_MEMBER(toBeRemoved), CR_MEMBER(updateFeatures) -)); +)) /******************************************************************************/ @@ -298,7 +297,7 @@ def->second, NULL, - float3(mfi[a].pos.x, ground->GetHeightReal(mfi[a].pos.x, mfi[a].pos.z), mfi[a].pos.z), + float3(mfi[a].pos.x, CGround::GetHeightReal(mfi[a].pos.x, mfi[a].pos.z), mfi[a].pos.z), ZeroVector, -1, // featureID @@ -414,7 +413,7 @@ } } - if (luaRules && !luaRules->AllowFeatureCreation(fd, cparams.teamID, cparams.pos)) + if (!eventHandler.AllowFeatureCreation(fd, cparams.teamID, cparams.pos)) return NULL; if (!fd->modelName.empty()) { @@ -452,17 +451,12 @@ } { - GML_STDMUTEX_LOCK(rfeat); // Update - if (!toBeRemoved.empty()) { - GML_RECMUTEX_LOCK(obj); // Update eventHandler.DeleteSyncedObjects(); - GML_RECMUTEX_LOCK(feat); // Update eventHandler.DeleteSyncedFeatures(); - GML_RECMUTEX_LOCK(quad); // Update while (!toBeRemoved.empty()) { CFeature* feature = GetFeature(toBeRemoved.back()); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Features/FeatureHandler.h spring-98.0~14.04~ppa6/rts/Sim/Features/FeatureHandler.h --- spring-96.0~14.04~ppa4/rts/Sim/Features/FeatureHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Features/FeatureHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -37,7 +37,7 @@ class LuaParser; class CFeatureHandler : public boost::noncopyable { - CR_DECLARE_STRUCT(CFeatureHandler); + CR_DECLARE_STRUCT(CFeatureHandler) public: CFeatureHandler(LuaParser* defsParser); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/AirBaseHandler.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/AirBaseHandler.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/AirBaseHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/AirBaseHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -19,15 +19,15 @@ CR_MEMBER(bases), CR_MEMBER(airBaseIDs), CR_RESERVED(16) -)); +)) -CR_BIND_DERIVED(CAirBaseHandler::LandingPad, CObject, (0, 0, NULL)); +CR_BIND_DERIVED(CAirBaseHandler::LandingPad, CObject, (0, 0, NULL)) CR_REG_METADATA_SUB(CAirBaseHandler, LandingPad, ( CR_MEMBER(unit), CR_MEMBER(piece), CR_MEMBER(base), CR_RESERVED(8) -)); +)) CR_BIND(CAirBaseHandler::AirBase, (NULL)) CR_REG_METADATA_SUB(CAirBaseHandler, AirBase, ( @@ -35,7 +35,7 @@ CR_MEMBER(freePads), CR_MEMBER(pads), CR_RESERVED(8) -)); +)) CAirBaseHandler::CAirBaseHandler() : bases(teamHandler->ActiveAllyTeams()) @@ -155,9 +155,10 @@ LandingPad* foundPad = foundBase->freePads.front(); foundBase->freePads.pop_front(); return foundPad; - } else { - if (!foundBase->pads.empty()) - return foundBase->pads.front(); + } + + if (!foundBase->pads.empty()) { + return foundBase->pads.front(); } } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/AirBaseHandler.h spring-98.0~14.04~ppa6/rts/Sim/Misc/AirBaseHandler.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/AirBaseHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/AirBaseHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -14,9 +14,9 @@ class CAirBaseHandler : public boost::noncopyable { - CR_DECLARE_STRUCT(CAirBaseHandler); - CR_DECLARE_SUB(LandingPad); - CR_DECLARE_SUB(AirBase); + CR_DECLARE_STRUCT(CAirBaseHandler) + CR_DECLARE_SUB(LandingPad) + CR_DECLARE_SUB(AirBase) private: struct AirBase; @@ -24,7 +24,7 @@ public: class LandingPad: public CObject, public boost::noncopyable { - CR_DECLARE(LandingPad); + CR_DECLARE(LandingPad) public: LandingPad(int p, CUnit* u, AirBase* b): @@ -43,7 +43,7 @@ private: struct AirBase: public boost::noncopyable { - CR_DECLARE_STRUCT(AirBase); + CR_DECLARE_STRUCT(AirBase) AirBase(CUnit* u) : unit(u) {} CUnit* unit; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/AllyTeam.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/AllyTeam.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/AllyTeam.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/AllyTeam.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -6,7 +6,7 @@ #include "System/creg/STL_Map.h" -CR_BIND(AllyTeam, ); +CR_BIND(AllyTeam, ) CR_REG_METADATA(AllyTeam, ( CR_MEMBER(startRectTop), @@ -15,7 +15,7 @@ CR_MEMBER(startRectRight), CR_MEMBER(allies), CR_MEMBER(customValues) -)); +)) AllyTeam::AllyTeam() diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/AllyTeam.h spring-98.0~14.04~ppa6/rts/Sim/Misc/AllyTeam.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/AllyTeam.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/AllyTeam.h 2014-10-07 20:09:51.000000000 +0000 @@ -11,7 +11,7 @@ class AllyTeam { - CR_DECLARE_STRUCT(AllyTeam); + CR_DECLARE_STRUCT(AllyTeam) public: AllyTeam(); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/CategoryHandler.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/CategoryHandler.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/CategoryHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/CategoryHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -9,15 +9,14 @@ #include "System/creg/STL_Map.h" #include "System/Util.h" #include "System/Log/ILog.h" -#include "lib/gml/gmlmut.h" -CR_BIND(CCategoryHandler, ); +CR_BIND(CCategoryHandler, ) CR_REG_METADATA(CCategoryHandler, ( CR_MEMBER(categories), CR_MEMBER(firstUnused), CR_RESERVED(8) - )); + )) CCategoryHandler* CCategoryHandler::instance; @@ -49,8 +48,6 @@ unsigned int cat = 0; - GML_STDMUTEX_LOCK(cat); // GetCategory - if (categories.find(name) == categories.end()) { // this category is yet unknown if (firstUnused >= CCategoryHandler::GetMaxCategories()) { @@ -100,8 +97,6 @@ std::map::const_iterator it; - GML_STDMUTEX_LOCK(cat); // GetCategoryNames - for (unsigned int bit = 1; bit != 0; bit = (bit << 1)) { if ((bit & bits) != 0) { for (it = categories.begin(); it != categories.end(); ++it) { diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/CategoryHandler.h spring-98.0~14.04~ppa6/rts/Sim/Misc/CategoryHandler.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/CategoryHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/CategoryHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -11,7 +11,7 @@ class CCategoryHandler : public boost::noncopyable { - CR_DECLARE_STRUCT(CCategoryHandler); + CR_DECLARE_STRUCT(CCategoryHandler) public: static inline unsigned int GetMaxCategories() { diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/CollisionHandler.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/CollisionHandler.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/CollisionHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/CollisionHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -73,9 +73,8 @@ // if is a sphere, then the bounding radius is just its own radius --> // we do not need to test the COLVOL_TYPE_SPHERE case again when this fails - if ((v->GetWorldSpacePos(o) - p).SqLength() > v->GetBoundingRadiusSq()) { + if ((v->GetWorldSpacePos(o) - p).SqLength() > v->GetBoundingRadiusSq()) return hit; - } if (v->DefaultToFootPrint()) { hit = CCollisionHandler::CollisionFootPrint(o, p); @@ -221,7 +220,7 @@ const CMatrix44f& mat, const float3& p0, const float3& p1, - std::list* cqs + std::vector* cqs ) { bool ret = false; @@ -252,11 +251,18 @@ const CUnit* u, const float3& p0, const float3& p1, - std::list* cqs + CollisionQuery* cq ) { CMatrix44f unitMat = u->GetTransformMatrix(true); CMatrix44f volMat; - CollisionQuery cq; + + CollisionQuery cqt; + + if (cq == NULL) + cq = &cqt; + + float minDistSq = std::numeric_limits::max(); + float curDistSq = std::numeric_limits::max(); for (unsigned int n = 0; n < u->localModel->pieces.size(); n++) { const LocalModelPiece* lmp = u->localModel->GetPiece(n); @@ -268,51 +274,33 @@ volMat = unitMat * lmp->GetModelSpaceMatrix(); volMat.Translate(lmpVol->GetOffsets()); - if (!CCollisionHandler::Intersect(lmpVol, volMat, p0, p1, &cq)) + if (!CCollisionHandler::Intersect(lmpVol, volMat, p0, p1, cq)) continue; // skip if neither an ingress nor an egress hit - if (cq.GetHitPos() == ZeroVector) + if (cq->GetHitPos() == ZeroVector) continue; - cq.SetHitPiece(const_cast(lmp)); - cqs->push_back(cq); + cq->SetHitPiece(const_cast(lmp)); + + // save the closest intersection (others are not needed) + if ((curDistSq = (cq->GetHitPos() - p0).SqLength()) >= minDistSq) + continue; + + minDistSq = curDistSq; } // true iff at least one piece was intersected - return (cq.GetHitPiece() != NULL); + // (query must have been reset by calling code) + return (cq->GetHitPiece() != NULL); } bool CCollisionHandler::IntersectPieceTree(const CUnit* u, const float3& p0, const float3& p1, CollisionQuery* cq) { - std::list cqs; - std::list::const_iterator cqsIt; - // TODO: // needs an early-out test, but gets complicated because // pieces can move --> no clearly defined bounding volume - if (!IntersectPiecesHelper(u, p0, p1, &cqs)) - return false; - - assert(!cqs.empty()); - - // not interested in the details - if (cq == NULL) - return true; - - float minDstSq = std::numeric_limits::max(); - float curDstSq = 0.0f; - - // save the closest intersection - for (cqsIt = cqs.begin(); cqsIt != cqs.end(); ++cqsIt) { - if ((curDstSq = (cqsIt->GetHitPos() - p0).SqLength()) >= minDstSq) - continue; - - minDstSq = curDstSq; - *cq = *cqsIt; - } - - return true; + return (IntersectPiecesHelper(u, p0, p1, cq)); } inline bool CCollisionHandler::Intersect(const CollisionVolume* v, const CSolidObject* o, const float3 p0, const float3 p1, CollisionQuery* cq) @@ -434,7 +422,7 @@ // get the intersection point in sphere-space const float3 pTmp = pii0 + (dir * t0); // get the intersection point in volume-space - const float3 p0(pTmp.x * v->GetHScales().x, pTmp.y * v->GetHScales().y, pTmp.z * v->GetHScales().z); + const float3 p0 = pTmp * v->GetHScales(); // get the distance from the start of the segment // to the intersection point in volume-space const float dSq0 = (p0 - pi0).SqLength(); @@ -460,8 +448,8 @@ const float3 pTmp0 = pii0 + (dir * t0); const float3 pTmp1 = pii0 + (dir * t1); // get the intersection points in volume-space - const float3 p0(pTmp0.x * v->GetHScales().x, pTmp0.y * v->GetHScales().y, pTmp0.z * v->GetHScales().z); - const float3 p1(pTmp1.x * v->GetHScales().x, pTmp1.y * v->GetHScales().y, pTmp1.z * v->GetHScales().z); + const float3 p0 = pTmp0 * v->GetHScales(); + const float3 p1 = pTmp1 * v->GetHScales(); // get the distances from the start of the ray // to the intersection points in volume-space const float dSq0 = (p0 - pi0).SqLength(); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/CollisionHandler.h spring-98.0~14.04~ppa6/rts/Sim/Misc/CollisionHandler.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/CollisionHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/CollisionHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -5,7 +5,6 @@ #include "System/creg/creg_cond.h" #include "System/float3.h" -#include struct CollisionVolume; class CMatrix44f; @@ -21,8 +20,8 @@ struct CollisionQuery { public: - CollisionQuery(): lmp(NULL) { Reset(); } - CollisionQuery(const CollisionQuery& cq): lmp(NULL) { Reset(&cq); } + CollisionQuery( ): lmp(NULL) { Reset(NULL); } + CollisionQuery(const CollisionQuery& cq): lmp(NULL) { Reset( &cq); } void Reset(const CollisionQuery* cq = NULL) { // (0, 0, 0) is volume-space center, so impossible @@ -53,9 +52,10 @@ } // if the hit-position equals ZeroVector (i.e. if we have an - // inside-hit special case), the projected distance would be - // negative --> clamp it - float GetHitPosDist(const float3& pos, const float3& dir) const { return (std::max(0.0f, ((GetHitPos() - pos).dot(dir)))); } + // inside-hit special case), the projected distance could be + // positive or negative depending on but we want it to + // be 0 --> turn into a ZeroVector if InsideHit() + float GetHitPosDist(const float3& pos, const float3& dir) const { return (std::max(0.0f, ((GetHitPos() - pos * (1 - InsideHit())).dot(dir)))); } float GetIngressPosDist(const float3& pos, const float3& dir) const { return (std::max(0.0f, ((GetIngressPos() - pos).dot(dir)))); } float GetEgressPosDist(const float3& pos, const float3& dir) const { return (std::max(0.0f, ((GetEgressPos() - pos).dot(dir)))); } @@ -111,8 +111,7 @@ static bool Intersect(const CollisionVolume* v, const CMatrix44f& m, const float3& p0, const float3& p1, CollisionQuery* cq); static bool IntersectPieceTree(const CUnit* u, const float3& p0, const float3& p1, CollisionQuery* cq); - static bool IntersectPieceTreeHelper(LocalModelPiece* lmp, const CMatrix44f& mat, const float3& p0, const float3& p1, std::list* cqs); - static bool IntersectPiecesHelper(const CUnit* u, const float3& p0, const float3& p1, std::list* cqs); + static bool IntersectPiecesHelper(const CUnit* u, const float3& p0, const float3& p1, CollisionQuery* cqp); public: static bool IntersectEllipsoid(const CollisionVolume* v, const float3& pi0, const float3& pi1, CollisionQuery* cq); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/CollisionVolume.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/CollisionVolume.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/CollisionVolume.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/CollisionVolume.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ #include "System/Matrix44f.h" #include "System/myMath.h" -CR_BIND(CollisionVolume, ); +CR_BIND(CollisionVolume, ) CR_REG_METADATA(CollisionVolume, ( CR_MEMBER(fAxisScales), CR_MEMBER(hAxisScales), @@ -22,7 +22,7 @@ CR_MEMBER(useContHitTest), CR_MEMBER(defaultToFootPrint), CR_MEMBER(defaultToPieceTree) -)); +)) // base ctor (CREG-only) CollisionVolume::CollisionVolume(): @@ -328,14 +328,15 @@ case COLVOL_TYPE_CYLINDER: { // code below is only valid for non-ellipsoidal cylinders assert(hAxisScales[volumeAxes[1]] == hAxisScales[volumeAxes[2]]); + assert(hsqAxisScales[volumeAxes[1]] == hsqAxisScales[volumeAxes[2]]); float pSq = 0.0f; float rSq = 0.0f; #define CYLINDER_CASE(a, b, c) \ { \ - pSq = pv.b * pv.b + pv.c * pv.c; \ - rSq = hsqAxisScales.b + hsqAxisScales.c; \ + pSq = (pv.b * pv.b) + (pv.c * pv.c); \ + rSq = (hsqAxisScales.b + hsqAxisScales.c) * 0.5f; \ \ if (pv.a >= -hAxisScales.a && pv.a <= hAxisScales.a) { \ /* case 1: point is between end-cap bounds along primary axis */ \ @@ -345,28 +346,18 @@ /* case 2: point is outside end-cap bounds but inside inf-tube */ \ d = std::max(math::fabs(pv.a) - hAxisScales.a, 0.0f); \ } else { \ - /* general case: compute distance to end-cap edge */ \ - l = math::fabs(pv.a) - hAxisScales.a; \ - d = 1.0f / (math::sqrt(pSq) / math::sqrt(rSq)); \ - pt.b = pv.b * d; \ - pt.c = pv.c * d; \ - d = math::sqrt((l * l) + (pv - pt).SqLength()); \ + /* case 3: compute orthogonal distance to end-cap edge (rim) */ \ + l = Square(math::fabs(pv.a) - hAxisScales.a); \ + d = Square(std::max(math::sqrt(pSq) - math::sqrt(rSq), 0.0f)); \ + d = math::sqrt(l + d); \ } \ } \ } switch (volumeAxes[0]) { - case COLVOL_AXIS_X: { - CYLINDER_CASE(x, y, z) - } break; - - case COLVOL_AXIS_Y: { - CYLINDER_CASE(y, x, z) - } break; - - case COLVOL_AXIS_Z: { - CYLINDER_CASE(z, x, y) - } break; + case COLVOL_AXIS_X: { CYLINDER_CASE(x, y, z) } break; + case COLVOL_AXIS_Y: { CYLINDER_CASE(y, x, z) } break; + case COLVOL_AXIS_Z: { CYLINDER_CASE(z, x, y) } break; } #undef CYLINDER_CASE diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/CollisionVolume.h spring-98.0~14.04~ppa6/rts/Sim/Misc/CollisionVolume.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/CollisionVolume.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/CollisionVolume.h 2014-10-07 20:09:51.000000000 +0000 @@ -20,7 +20,7 @@ struct CollisionVolume { - CR_DECLARE_STRUCT(CollisionVolume); + CR_DECLARE_STRUCT(CollisionVolume) public: enum { diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/DamageArray.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/DamageArray.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/DamageArray.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/DamageArray.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -3,7 +3,7 @@ #include "DamageArray.h" #include "DamageArrayHandler.h" -CR_BIND(DamageArray, ); +CR_BIND(DamageArray, ) CR_REG_METADATA(DamageArray, ( CR_MEMBER(paralyzeDamageTime), @@ -12,7 +12,7 @@ CR_MEMBER(craterMult), CR_MEMBER(craterBoost), CR_MEMBER(damages) -)); +)) diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/DamageArray.h spring-98.0~14.04~ppa6/rts/Sim/Misc/DamageArray.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/DamageArray.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/DamageArray.h 2014-10-07 20:09:51.000000000 +0000 @@ -9,7 +9,7 @@ struct DamageArray { - CR_DECLARE_STRUCT(DamageArray); + CR_DECLARE_STRUCT(DamageArray) public: DamageArray(float damage = 1.0f); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/DamageArrayHandler.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/DamageArrayHandler.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/DamageArrayHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/DamageArrayHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -15,13 +15,13 @@ #include "System/Util.h" -CR_BIND(CDamageArrayHandler, (NULL)); +CR_BIND(CDamageArrayHandler, (NULL)) CR_REG_METADATA(CDamageArrayHandler, ( CR_MEMBER(armorDefNameIdxMap), CR_MEMBER(armorDefKeys), CR_RESERVED(16) -)); +)) CDamageArrayHandler* damageArrayHandler; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/DamageArrayHandler.h spring-98.0~14.04~ppa6/rts/Sim/Misc/DamageArrayHandler.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/DamageArrayHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/DamageArrayHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -12,7 +12,7 @@ class LuaParser; class CDamageArrayHandler : public boost::noncopyable { - CR_DECLARE_STRUCT(CDamageArrayHandler); + CR_DECLARE_STRUCT(CDamageArrayHandler) public: CDamageArrayHandler(LuaParser* defsParser); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/DefinitionTag.h spring-98.0~14.04~ppa6/rts/Sim/Misc/DefinitionTag.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/DefinitionTag.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/DefinitionTag.h 2014-10-07 20:09:51.000000000 +0000 @@ -44,7 +44,7 @@ { return os << "\"\""; } -}; +} // must be included after "std::ostream& operator<<" definitions for LLVM/Clang compilation #include "System/Util.h" diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/GeometricObjects.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/GeometricObjects.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/GeometricObjects.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/GeometricObjects.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,17 +7,17 @@ #include "Sim/Projectiles/ProjectileHandler.h" #include "Sim/Projectiles/Unsynced/GeoSquareProjectile.h" -CR_BIND(CGeometricObjects, ); -CR_BIND(CGeometricObjects::GeoGroup, ); +CR_BIND(CGeometricObjects, ) +CR_BIND(CGeometricObjects::GeoGroup, ) CR_REG_METADATA(CGeometricObjects, ( CR_MEMBER(geoGroups), CR_MEMBER(toBeDeleted), CR_MEMBER(firstFreeGroup), CR_RESERVED(16) - )); + )) -CR_REG_METADATA_SUB(CGeometricObjects, GeoGroup, (CR_MEMBER(squares))); +CR_REG_METADATA_SUB(CGeometricObjects, GeoGroup, (CR_MEMBER(squares))) CGeometricObjects* geometricObjects; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/GeometricObjects.h spring-98.0~14.04~ppa6/rts/Sim/Misc/GeometricObjects.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/GeometricObjects.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/GeometricObjects.h 2014-10-07 20:09:51.000000000 +0000 @@ -14,12 +14,12 @@ class CGeometricObjects : public boost::noncopyable { - CR_DECLARE_STRUCT(CGeometricObjects); - CR_DECLARE_SUB(GeoGroup); + CR_DECLARE_STRUCT(CGeometricObjects) + CR_DECLARE_SUB(GeoGroup) private: struct GeoGroup { - CR_DECLARE_STRUCT(GeoGroup); + CR_DECLARE_STRUCT(GeoGroup) std::vector squares; }; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/GlobalSynced.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/GlobalSynced.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/GlobalSynced.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/GlobalSynced.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -22,7 +22,7 @@ -CR_BIND(CGlobalSynced, ); +CR_BIND(CGlobalSynced, ) CR_REG_METADATA(CGlobalSynced, ( CR_MEMBER(frameNum), @@ -49,7 +49,7 @@ CR_MEMBER(useLuaGaia), CR_MEMBER(randSeed), CR_MEMBER(initRandSeed) -)); +)) /** diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/GlobalSynced.h spring-98.0~14.04~ppa6/rts/Sim/Misc/GlobalSynced.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/GlobalSynced.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/GlobalSynced.h 2014-10-07 20:09:51.000000000 +0000 @@ -23,7 +23,7 @@ class CGlobalSynced { public: - CR_DECLARE_STRUCT(CGlobalSynced); + CR_DECLARE_STRUCT(CGlobalSynced) CGlobalSynced(); //!< Constructor ~CGlobalSynced(); //!< Destructor diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/GroundBlockingObjectMap.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/GroundBlockingObjectMap.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/GroundBlockingObjectMap.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/GroundBlockingObjectMap.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -10,14 +10,13 @@ #include "Sim/Objects/SolidObjectDef.h" #include "Sim/Path/IPathManager.h" #include "System/creg/STL_Map.h" -#include "lib/gml/gmlmut.h" CGroundBlockingObjectMap* groundBlockingObjectMap; CR_BIND(CGroundBlockingObjectMap, (1)) CR_REG_METADATA(CGroundBlockingObjectMap, ( CR_MEMBER(groundBlockingMap) -)); +)) @@ -39,20 +38,12 @@ return; } - GML_STDMUTEX_LOCK(block); // AddGroundBlockingObject - const int objID = GetObjectID(object); object->SetPhysicalStateBit(CSolidObject::PSTATE_BIT_BLOCKING); object->mapPos = object->GetMapPos(); object->groundBlockPos = object->pos; - if (object->immobile) { - // align position to even-numbered squares - object->mapPos.x &= 0xfffffe; - object->mapPos.y &= 0xfffffe; - } - const int bx = object->mapPos.x, sx = object->xsize; const int bz = object->mapPos.y, sz = object->zsize; const int minXSqr = bx, maxXSqr = bx + sx; @@ -73,19 +64,12 @@ void CGroundBlockingObjectMap::AddGroundBlockingObject(CSolidObject* object, const YardMapStatus& mask) { - GML_STDMUTEX_LOCK(block); // AddGroundBlockingObject - const int objID = GetObjectID(object); object->SetPhysicalStateBit(CSolidObject::PSTATE_BIT_BLOCKING); object->mapPos = object->GetMapPos(); object->groundBlockPos = object->pos; - if (object->immobile) { - object->mapPos.x &= 0xfffffe; - object->mapPos.y &= 0xfffffe; - } - const int bx = object->mapPos.x, sx = object->xsize; const int bz = object->mapPos.y, sz = object->zsize; const int minXSqr = bx, maxXSqr = bx + sx; @@ -113,8 +97,6 @@ void CGroundBlockingObjectMap::RemoveGroundBlockingObject(CSolidObject* object) { - GML_STDMUTEX_LOCK(block); // RemoveGroundBlockingObject - const int objID = GetObjectID(object); const int bx = object->mapPos.x; @@ -146,8 +128,6 @@ * pointer to the top-most / bottom-most blocking object is returned. */ CSolidObject* CGroundBlockingObjectMap::GroundBlockedUnsafe(int mapSquare) const { - GML_STDMUTEX_LOCK(block); // GroundBlockedUnsafe - const BlockingMapCell& cell = groundBlockingMap[mapSquare]; if (cell.empty()) @@ -179,8 +159,6 @@ const int mapSquare = x + z * gs->mapx; - GML_STDMUTEX_LOCK(block); // GroundBlockedUnsafe - if (groundBlockingMap[mapSquare].empty()) return false; @@ -233,8 +211,6 @@ inline bool CGroundBlockingObjectMap::CheckYard(CSolidObject* yardUnit, const YardMapStatus& mask) const { - //GML_STDMUTEX_LOCK(block); //done in GroundBlocked - for (int z = yardUnit->mapPos.y; z < yardUnit->mapPos.y + yardUnit->zsize; ++z) { for (int x = yardUnit->mapPos.x; x < yardUnit->mapPos.x + yardUnit->xsize; ++x) { if (yardUnit->GetGroundBlockingMaskAtPos(float3(x * SQUARE_SIZE, 0.0f, z * SQUARE_SIZE)) & mask) diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/GroundBlockingObjectMap.h spring-98.0~14.04~ppa6/rts/Sim/Misc/GroundBlockingObjectMap.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/GroundBlockingObjectMap.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/GroundBlockingObjectMap.h 2014-10-07 20:09:51.000000000 +0000 @@ -17,7 +17,7 @@ class CGroundBlockingObjectMap { - CR_DECLARE_STRUCT(CGroundBlockingObjectMap); + CR_DECLARE_STRUCT(CGroundBlockingObjectMap) public: CGroundBlockingObjectMap(int numSquares) { diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/InterceptHandler.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/InterceptHandler.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/InterceptHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/InterceptHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -5,7 +5,6 @@ #include "InterceptHandler.h" -#include "Lua/LuaRules.h" #include "Map/Ground.h" #include "Sim/Weapons/Weapon.h" #include "Sim/Projectiles/WeaponProjectiles/WeaponProjectile.h" @@ -13,6 +12,7 @@ #include "Sim/Weapons/WeaponDef.h" #include "Sim/Weapons/PlasmaRepulser.h" #include "Sim/Misc/TeamHandler.h" +#include "System/EventHandler.h" #include "System/float3.h" #include "System/myMath.h" #include "System/creg/STL_List.h" @@ -24,7 +24,7 @@ CR_MEMBER(interceptors), CR_MEMBER(repulsors)//, //CR_MEMBER(interceptables) FIXME -)); +)) CInterceptHandler interceptHandler; @@ -61,7 +61,7 @@ continue; // note: will be called every Update so long as gadget does not return true - if (luaRules != NULL && !luaRules->AllowWeaponInterceptTarget(wOwner, w, p)) + if (!eventHandler.AllowWeaponInterceptTarget(wOwner, w, p)) continue; // there are four cases when an interceptor should fire at a projectile

: @@ -73,7 +73,7 @@ // these checks all need to be evaluated periodically, not just // when a projectile is created and handed to AddInterceptTarget const float weaponDist = w->weaponPos.distance(p->pos); - const float impactDist = ground->LineGroundCol(p->pos, p->pos + p->dir * weaponDist); + const float impactDist = CGround::LineGroundCol(p->pos, p->pos + p->dir * weaponDist); const float3& pImpactPos = p->pos + p->dir * impactDist; const float3& pTargetPos = p->GetTargetPos(); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/LosHandler.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/LosHandler.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/LosHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/LosHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -19,9 +19,9 @@ using std::min; using std::max; -CR_BIND(LosInstance, ); -CR_BIND(CLosHandler, ); -CR_BIND(CLosHandler::DelayedInstance, ); +CR_BIND(LosInstance, ) +CR_BIND(CLosHandler, ) +CR_BIND(CLosHandler::DelayedInstance, ) CR_REG_METADATA(LosInstance,( CR_IGNORED(losSquares), @@ -35,7 +35,7 @@ CR_MEMBER(hashNum), CR_MEMBER(baseHeight), CR_MEMBER(toBeDeleted) -)); +)) void CLosHandler::PostLoad() { @@ -54,11 +54,11 @@ CR_MEMBER(delayQue), CR_RESERVED(8), CR_POSTLOAD(PostLoad) -)); +)) CR_REG_METADATA_SUB(CLosHandler,DelayedInstance, ( CR_MEMBER(instance), - CR_MEMBER(timeoutTime))); + CR_MEMBER(timeoutTime))) ////////////////////////////////////////////////////////////////////// diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/LosHandler.h spring-98.0~14.04~ppa6/rts/Sim/Misc/LosHandler.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/LosHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/LosHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -37,7 +37,7 @@ struct LosInstance : public boost::noncopyable { private: - CR_DECLARE_STRUCT(LosInstance); + CR_DECLARE_STRUCT(LosInstance) /// default constructor for creg LosInstance() @@ -102,9 +102,9 @@ */ class CLosHandler : public boost::noncopyable { - CR_DECLARE_STRUCT(CLosHandler); -// CR_DECLARE_SUB(CPoint); - CR_DECLARE_SUB(DelayedInstance); + CR_DECLARE_STRUCT(CLosHandler) +// CR_DECLARE_SUB(CPoint) + CR_DECLARE_SUB(DelayedInstance) public: void MoveUnit(CUnit* unit, bool redoCurrent); @@ -223,7 +223,7 @@ std::deque toBeDeleted; struct DelayedInstance { - CR_DECLARE_STRUCT(DelayedInstance); + CR_DECLARE_STRUCT(DelayedInstance) LosInstance* instance; int timeoutTime; }; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/LosMap.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/LosMap.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/LosMap.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/LosMap.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -15,24 +15,24 @@ #include -CR_BIND(CLosMap, ); +CR_BIND(CLosMap, ) CR_REG_METADATA(CLosMap, ( CR_MEMBER(size), CR_MEMBER(map), CR_MEMBER(sendReadmapEvents) -)); +)) -CR_BIND(CLosAlgorithm, (int2(), 0.0f, 0.0f, NULL)); +CR_BIND(CLosAlgorithm, (int2(), 0.0f, 0.0f, NULL)) CR_REG_METADATA(CLosAlgorithm, ( CR_MEMBER(size), CR_MEMBER(minMaxAng), CR_MEMBER(extraHeight)//, //CR_MEMBER(heightmap) -)); +)) @@ -200,19 +200,15 @@ int Radius = Table; char* PaintTable = new char[(Radius+1)*Radius]; memset(PaintTable, 0 , (Radius+1)*Radius); - int2 P; - - int x, y, r2; - - P.x = 0; - P.y = Radius; + int2 P(0, Radius); Points.push_back(P); + // DrawLine(0, Radius, Radius); for (float i=Radius; i>=1; i-=0.5f) { - r2 = (int)(i * i); + const int r2 = (int)(i * i); - x = 1; - y = (int) (math::sqrt((float)r2 - 1) + 0.5f); + int x = 1; + int y = (int) (math::sqrt((float)r2 - 1) + 0.5f); while (x < y) { if (!PaintTable[x+y*Radius]) { DrawLine(PaintTable, x, y, Radius); @@ -314,7 +310,7 @@ ////////////////////////////////////////////////////////////////////// -}; // end of anon namespace +} // end of anon namespace ////////////////////////////////////////////////////////////////////// diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/LosMap.h spring-98.0~14.04~ppa6/rts/Sim/Misc/LosMap.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/LosMap.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/LosMap.h 2014-10-07 20:09:51.000000000 +0000 @@ -11,7 +11,7 @@ /// map containing counts of how many units have Line Of Sight (LOS) to each square class CLosMap { - CR_DECLARE_STRUCT(CLosMap); + CR_DECLARE_STRUCT(CLosMap) public: CLosMap() : size(0, 0), sendReadmapEvents(false) {} @@ -46,7 +46,7 @@ /// algorithm to calculate LOS squares using raycasting, taking terrain into account class CLosAlgorithm { - CR_DECLARE_STRUCT(CLosAlgorithm); + CR_DECLARE_STRUCT(CLosAlgorithm) public: CLosAlgorithm(int2 size, float minMaxAng, float extraHeight, const float* heightmap) diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/ModInfo.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/ModInfo.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/ModInfo.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/ModInfo.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -4,7 +4,6 @@ #include "ModInfo.h" #include "Game/GameSetup.h" -#include "Lua/LuaConfig.h" #include "Lua/LuaParser.h" #include "Lua/LuaSyncedRead.h" #include "Sim/Units/Unit.h" @@ -15,10 +14,6 @@ #include "System/Exceptions.h" #include "System/GlobalConfig.h" #include "System/myMath.h" -#include "lib/gml/gml_base.h" - - -CONFIG(bool, EnableUnsafeAndBrokenMT).defaultValue(false).description("Enable unsafe MT modes (very likely to cause crashes / hangs / graphical errors)"); CModInfo modInfo; @@ -54,38 +49,9 @@ { // system const LuaTable& system = root.SubTable("system"); - const size_t numThreads = std::max(0, configHandler->GetInt("MultiThreadCount")); - - bool disableGML = (numThreads == 1); - pathFinderSystem = system.GetInt("pathFinderSystem", PFS_TYPE_DEFAULT) % PFS_NUM_TYPES; - luaThreadingModel = system.GetInt("luaThreadingModel", MT_LUA_SINGLE_BATCH); - - //FIXME: remove unsave modes - if (luaThreadingModel > 2) { - LOG_L(L_WARNING, "Experimental luaThreadingModel %d selected! This is currently unmaintained and may be deprecated and/or removed in the future!", luaThreadingModel); - LOG_L(L_WARNING, "Automaticly disabled to prevent desyncs / crashes / hangs / graphical errors!"); - if (!configHandler->GetBool("EnableUnsafeAndBrokenMT")) { - luaThreadingModel = 2; - } else { - LOG_L(L_WARNING, "MT enforced: expect desyncs / crashes / hangs / graphical errors!"); - } - } - - if (numThreads == 0) { - disableGML |= (Threading::GetAvailableCores() <= 1 ); - disableGML |= (luaThreadingModel == MT_LUA_NONE ); - disableGML |= (luaThreadingModel == MT_LUA_SINGLE ); - disableGML |= (luaThreadingModel == MT_LUA_SINGLE_BATCH); - } - - if (disableGML) { - // single core, or this game did not make any effort to - // specifically support MT ==> disable it by default - GML::Enable(false); - } - GML::SetCheckCallChain(globalConfig->GetMultiThreadLua() == MT_LUA_SINGLE_BATCH); + pfUpdateRate = system.GetFloat("pathFinderUpdateRate", 0.007f); } { diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/ModInfo.h spring-98.0~14.04~ppa6/rts/Sim/Misc/ModInfo.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/ModInfo.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/ModInfo.h 2014-10-07 20:09:51.000000000 +0000 @@ -48,8 +48,8 @@ , airLosMul(1.0f) , requireSonarUnderWater(true) , featureVisibility(FEATURELOS_NONE) - , luaThreadingModel(2) , pathFinderSystem(PFS_TYPE_DEFAULT) + , pfUpdateRate(0.0f) {} @@ -173,11 +173,11 @@ /// feature visibility style: 0 - no LOS for features, 1 - gaia features visible /// 2 - gaia/allied features visible, 3 - all features visible int featureVisibility; - // Lua threading model: Controls which Lua MT optimizations the mod will use by default (see LuaConfig.h for details) - int luaThreadingModel; - // which pathfinder system (DEFAULT/legacy or QTPFS) the mod will use + // Path Finder + /// which pathfinder system (DEFAULT/legacy or QTPFS) the mod will use int pathFinderSystem; + float pfUpdateRate; }; extern CModInfo modInfo; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/NanoPieceCache.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/NanoPieceCache.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/NanoPieceCache.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/NanoPieceCache.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -4,13 +4,13 @@ #include "Sim/Misc/GlobalSynced.h" #include "Sim/Units/Scripts/UnitScript.h" -CR_BIND(NanoPieceCache, ); +CR_BIND(NanoPieceCache, ) CR_REG_METADATA(NanoPieceCache, ( CR_MEMBER(nanoPieces), CR_MEMBER(lastNanoPieceCnt), CR_MEMBER(curBuildPowerMask) -)); +)) int NanoPieceCache::GetNanoPiece(CUnitScript* ownerScript) { assert(UNIT_SLOWUPDATE_RATE == 16); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/NanoPieceCache.h spring-98.0~14.04~ppa6/rts/Sim/Misc/NanoPieceCache.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/NanoPieceCache.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/NanoPieceCache.h 2014-10-07 20:09:51.000000000 +0000 @@ -13,7 +13,7 @@ struct NanoPieceCache { - CR_DECLARE_STRUCT(NanoPieceCache); + CR_DECLARE_STRUCT(NanoPieceCache) public: NanoPieceCache(): lastNanoPieceCnt(0), curBuildPowerMask(0) { diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/QuadField.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/QuadField.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/QuadField.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/QuadField.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,7 +2,6 @@ #include -#include "lib/gml/gmlmut.h" #include "QuadField.h" #include "Sim/Misc/CollisionVolume.h" #include "Sim/Misc/GlobalSynced.h" @@ -16,7 +15,7 @@ #define CELL_IDX_X(wpx) Clamp(int((wpx) / quadSizeX), 0, numQuadsX - 1) #define CELL_IDX_Z(wpz) Clamp(int((wpz) / quadSizeZ), 0, numQuadsZ - 1) -CR_BIND(CQuadField, (1, 1)); +CR_BIND(CQuadField, (1, 1)) CR_REG_METADATA(CQuadField, ( CR_MEMBER(baseQuads), CR_MEMBER(tempQuads), @@ -24,15 +23,15 @@ CR_MEMBER(numQuadsZ), CR_MEMBER(quadSizeX), CR_MEMBER(quadSizeZ) -)); +)) -CR_BIND(CQuadField::Quad, ); +CR_BIND(CQuadField::Quad, ) CR_REG_METADATA_SUB(CQuadField, Quad, ( CR_MEMBER(units), CR_MEMBER(teamUnits), CR_MEMBER(features), CR_MEMBER(projectiles) -)); +)) CQuadField* quadField = NULL; @@ -188,8 +187,6 @@ std::vector CQuadField::GetUnits(const float3& pos, float radius) { - GML_RECMUTEX_LOCK(qnum); // GetUnits - const int tempNum = gs->tempNum++; int* begQuad = &tempQuads[0]; @@ -217,8 +214,6 @@ std::vector CQuadField::GetUnitsExact(const float3& pos, float radius, bool spherical) { - GML_RECMUTEX_LOCK(qnum); // GetUnitsExact - const int tempNum = gs->tempNum++; int* begQuad = &tempQuads[0]; @@ -255,8 +250,6 @@ std::vector CQuadField::GetUnitsExact(const float3& mins, const float3& maxs) { - GML_RECMUTEX_LOCK(qnum); // GetUnitsExact - const std::vector& quads = GetQuadsRectangle(mins, maxs); const int tempNum = gs->tempNum++; @@ -409,7 +402,7 @@ float xn, zn; bool keepgoing = true; - for (int i = 0; i < NUM_TEMP_QUADS && keepgoing; i++) { + for (unsigned int i = 0; i < tempQuads.size() && keepgoing; i++) { *endQuad = ((int)(zp * invQuadSizeZ) * numQuadsX) + (int)(xp * invQuadSizeX); ++endQuad; @@ -454,8 +447,6 @@ } } - GML_RECMUTEX_LOCK(quad); // MovedUnit - std::vector::const_iterator qi; for (qi = unit->quads.begin(); qi != unit->quads.end(); ++qi) { std::list& quadUnits = baseQuads[*qi].units; @@ -480,8 +471,6 @@ void CQuadField::RemoveUnit(CUnit* unit) { - GML_RECMUTEX_LOCK(quad); // RemoveUnit - std::vector::const_iterator qi; for (qi = unit->quads.begin(); qi != unit->quads.end(); ++qi) { std::list& quadUnits = baseQuads[*qi].units; @@ -503,8 +492,6 @@ void CQuadField::AddFeature(CFeature* feature) { - GML_RECMUTEX_LOCK(quad); // AddFeature - const std::vector& newQuads = GetQuads(feature->pos, feature->radius); std::vector::const_iterator qi; @@ -515,8 +502,6 @@ void CQuadField::RemoveFeature(CFeature* feature) { - GML_RECMUTEX_LOCK(quad); // RemoveFeature - const std::vector& quads = GetQuads(feature->pos, feature->radius); std::vector::const_iterator qi; @@ -552,10 +537,10 @@ const CProjectile::QuadFieldCellData& qfcd = p->GetQuadFieldCellData(); - const int2 oldCellCoors = qfcd.GetCoor(0); + const int2& oldCellCoors = qfcd.GetCoor(0); const int2 newCellCoors = { - std::max(0, std::min(int(p->pos.x / quadSizeX), numQuadsX - 1)), - std::max(0, std::min(int(p->pos.z / quadSizeZ), numQuadsZ - 1)) + Clamp(int(p->pos.x / quadSizeX), 0, numQuadsX - 1), + Clamp(int(p->pos.z / quadSizeZ), 0, numQuadsZ - 1) }; if (newCellCoors != oldCellCoors) { @@ -568,8 +553,6 @@ { assert(p->synced); - GML_RECMUTEX_LOCK(quad); // AddProjectile - CProjectile::QuadFieldCellData qfcd; typedef CQuadField::Quad Cell; @@ -616,8 +599,6 @@ { assert(p->synced); - GML_RECMUTEX_LOCK(quad); // RemoveProjectile - CProjectile::QuadFieldCellData& qfcd = p->GetQuadFieldCellData(); typedef CQuadField::Quad Cell; @@ -651,8 +632,6 @@ std::vector CQuadField::GetFeaturesExact(const float3& pos, float radius) { - GML_RECMUTEX_LOCK(qnum); // GetFeaturesExact - const std::vector& quads = GetQuads(pos, radius); const int tempNum = gs->tempNum++; @@ -675,8 +654,6 @@ std::vector CQuadField::GetFeaturesExact(const float3& pos, float radius, bool spherical) { - GML_RECMUTEX_LOCK(qnum); // GetFeaturesExact - const std::vector& quads = GetQuads(pos, radius); const int tempNum = gs->tempNum++; @@ -703,8 +680,6 @@ std::vector CQuadField::GetFeaturesExact(const float3& mins, const float3& maxs) { - GML_RECMUTEX_LOCK(qnum); // GetFeaturesExact - const std::vector& quads = GetQuadsRectangle(mins, maxs); const int tempNum = gs->tempNum++; @@ -735,8 +710,6 @@ std::vector CQuadField::GetProjectilesExact(const float3& pos, float radius) { - GML_RECMUTEX_LOCK(qnum); // GetProjectilesExact - const std::vector& quads = GetQuads(pos, radius); std::vector projectiles; @@ -760,8 +733,6 @@ std::vector CQuadField::GetProjectilesExact(const float3& mins, const float3& maxs) { - GML_RECMUTEX_LOCK(qnum); // GetProjectilesExact - const std::vector& quads = GetQuadsRectangle(mins, maxs); std::vector projectiles; @@ -793,8 +764,6 @@ const unsigned int physicalStateBits, const unsigned int collisionStateBits ) { - GML_RECMUTEX_LOCK(qnum); // GetSolidsExact - const std::vector& quads = GetQuads(pos, radius); const int tempNum = gs->tempNum++; @@ -884,8 +853,6 @@ unsigned int* numUnitsPtr, unsigned int* numFeaturesPtr ) { - GML_RECMUTEX_LOCK(qnum); // GetUnitsAndFeaturesColVol - const int tempNum = gs->tempNum++; // start counting from the previous object-cache sizes diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/QuadField.h spring-98.0~14.04~ppa6/rts/Sim/Misc/QuadField.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/QuadField.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/QuadField.h 2014-10-07 20:09:51.000000000 +0000 @@ -18,8 +18,8 @@ class CQuadField : boost::noncopyable { - CR_DECLARE_STRUCT(CQuadField); - CR_DECLARE_SUB(Quad); + CR_DECLARE_STRUCT(CQuadField) + CR_DECLARE_SUB(Quad) public: static void Resize(unsigned int nqx, unsigned int nqz); @@ -103,7 +103,7 @@ void RemoveProjectile(CProjectile* projectile); struct Quad { - CR_DECLARE_STRUCT(Quad); + CR_DECLARE_STRUCT(Quad) Quad(); std::list units; std::vector< std::list > teamUnits; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/RadarHandler.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/RadarHandler.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/RadarHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/RadarHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -13,7 +13,7 @@ #define SONAR_MAPS #endif -CR_BIND(CRadarHandler, (false)); +CR_BIND(CRadarHandler, (false)) CR_REG_METADATA(CRadarHandler, ( CR_MEMBER(radarErrorSizes), @@ -36,7 +36,7 @@ CR_MEMBER(seismicMaps), CR_MEMBER(commonJammerMap), CR_MEMBER(commonSonarJammerMap) -)); +)) CRadarHandler* radarHandler = NULL; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/RadarHandler.h spring-98.0~14.04~ppa6/rts/Sim/Misc/RadarHandler.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/RadarHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/RadarHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -21,7 +21,7 @@ class CRadarHandler : public boost::noncopyable { - CR_DECLARE_STRUCT(CRadarHandler); + CR_DECLARE_STRUCT(CRadarHandler) public: diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/Resource.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/Resource.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/Resource.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/Resource.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -4,14 +4,14 @@ #include -CR_BIND(CResource, ); +CR_BIND(CResource, ) CR_REG_METADATA(CResource, ( CR_MEMBER(name), CR_MEMBER(optimum), CR_MEMBER(extractorRadius), CR_MEMBER(maxWorth) - )); + )) ////////////////////////////////////////////////////////////////////// // Construction/Destruction diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/Resource.h spring-98.0~14.04~ppa6/rts/Sim/Misc/Resource.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/Resource.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/Resource.h 2014-10-07 20:09:51.000000000 +0000 @@ -9,7 +9,7 @@ class CResource { public: - CR_DECLARE_STRUCT(CResource); + CR_DECLARE_STRUCT(CResource) CResource(); ~CResource(); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/ResourceHandler.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/ResourceHandler.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/ResourceHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/ResourceHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -8,14 +8,14 @@ #include "Map/MetalMap.h" #include "GlobalSynced.h" // for the map size -CR_BIND(CResourceHandler, ); +CR_BIND(CResourceHandler, ) CR_REG_METADATA(CResourceHandler, ( CR_MEMBER(resources), // CR_MEMBER(resourceMapAnalyzers), CR_MEMBER(metalResourceId), CR_MEMBER(energyResourceId) -)); +)) CResourceHandler* CResourceHandler::instance; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/ResourceHandler.h spring-98.0~14.04~ppa6/rts/Sim/Misc/ResourceHandler.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/ResourceHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/ResourceHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -13,7 +13,7 @@ class CResourceHandler : public boost::noncopyable { - CR_DECLARE_STRUCT(CResourceHandler); + CR_DECLARE_STRUCT(CResourceHandler) public: static CResourceHandler* GetInstance(); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/SimObjectIDPool.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/SimObjectIDPool.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/SimObjectIDPool.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/SimObjectIDPool.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -4,12 +4,12 @@ #include "GlobalSynced.h" #include "Sim/Objects/SolidObject.h" -CR_BIND(SimObjectIDPool, ); +CR_BIND(SimObjectIDPool, ) CR_REG_METADATA(SimObjectIDPool, ( CR_MEMBER(liveIdentIndexMap), CR_MEMBER(liveIndexIdentMap), CR_MEMBER(tempIndexIdentMap) -)); +)) void SimObjectIDPool::Expand(unsigned int baseID, unsigned int numIDs) { // allocate new batch of (randomly shuffled) id's diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/SmoothHeightMesh.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/SmoothHeightMesh.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/SmoothHeightMesh.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/SmoothHeightMesh.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -41,7 +41,7 @@ } -SmoothHeightMesh::SmoothHeightMesh(const CGround* ground, float mx, float my, float res, float smoothRad) +SmoothHeightMesh::SmoothHeightMesh(float mx, float my, float res, float smoothRad) : maxx((mx / res) + 1) , maxy((my / res) + 1) , fmaxx(mx) @@ -49,7 +49,7 @@ , resolution(res) , smoothRadius(std::max(1.0f, smoothRad)) { - MakeSmoothMesh(ground); + MakeSmoothMesh(); } SmoothHeightMesh::~SmoothHeightMesh() { @@ -105,7 +105,7 @@ for (int x = 0; x <= maxx; ++x) { const float curx = x * resolution; const float cury = y * resolution; - const float curh = ground->GetHeightAboveWater(curx, cury); + const float curh = CGround::GetHeightAboveWater(curx, cury); if (curh > colsMaxima[x]) { colsMaxima[x] = curh; @@ -128,7 +128,7 @@ for (int x = 0; x <= maxx; ++x) { if (maximaRows[x] == (y - 1)) { const float curx = x * resolution; - const float curh = ground->GetHeightAboveWater(curx, cury); + const float curh = CGround::GetHeightAboveWater(curx, cury); if (curh == colsMaxima[x]) { maximaRows[x] = y; @@ -162,7 +162,7 @@ for (int i = startx; i <= endx; ++i) { assert(i >= 0); assert(i <= maxx); - assert(ground->GetHeightReal(i * resolution, cury) <= colsMaxima[i]); + assert(CGround::GetHeightReal(i * resolution, cury) <= colsMaxima[i]); maxRowHeight = std::max(colsMaxima[i], maxRowHeight); } @@ -170,7 +170,7 @@ #ifndef NDEBUG const float curx = x * resolution; assert(maxRowHeight <= std::max(readMap->GetCurrMaxHeight(), 0.0f)); - assert(maxRowHeight >= ground->GetHeightAboveWater(curx, cury)); + assert(maxRowHeight >= CGround::GetHeightAboveWater(curx, cury)); #ifdef SMOOTHMESH_CORRECTNESS_CHECK // naive algorithm @@ -178,7 +178,7 @@ for (float y1 = cury - smoothRadius; y1 <= cury + smoothRadius; y1 += resolution) { for (float x1 = curx - smoothRadius; x1 <= curx + smoothRadius; x1 += resolution) { - maxRowHeightAlt = std::max(maxRowHeightAlt, ground->GetHeightAboveWater(x1, y1)); + maxRowHeightAlt = std::max(maxRowHeightAlt, CGround::GetHeightAboveWater(x1, y1)); } } @@ -208,7 +208,7 @@ for (int x = 0; x <= maxx; ++x) { #ifdef _DEBUG for (int y1 = std::max(0, y - intrad); y1 <= std::min(maxy, y + intrad); ++y1) { - assert(ground->GetHeightReal(x * resolution, y1 * resolution) <= colsMaxima[x]); + assert(CGround::GetHeightReal(x * resolution, y1 * resolution) <= colsMaxima[x]); } #endif const float curx = x * resolution; @@ -218,7 +218,7 @@ colsMaxima[x] = -std::numeric_limits::max(); for (int y1 = std::max(0, y - intrad + 1); y1 <= std::min(maxy, nextrow); ++y1) { - const float h = ground->GetHeightAboveWater(curx, y1 * resolution); + const float h = CGround::GetHeightAboveWater(curx, y1 * resolution); if (h > colsMaxima[x]) { colsMaxima[x] = h; @@ -230,7 +230,7 @@ } } else if (nextrow <= maxy) { // else, just check if a new maximum has entered the window - const float h = ground->GetHeightAboveWater(curx, nextrowy); + const float h = CGround::GetHeightAboveWater(curx, nextrowy); if (h > colsMaxima[x]) { colsMaxima[x] = h; @@ -243,7 +243,7 @@ #ifdef _DEBUG for (int y1 = std::max(0, y - intrad + 1); y1 <= std::min(maxy, y + intrad + 1); ++y1) { - assert(colsMaxima[x] >= ground->GetHeightReal(curx, y1 * resolution)); + assert(colsMaxima[x] >= CGround::GetHeightReal(curx, y1 * resolution)); } #endif } @@ -284,7 +284,7 @@ smoothed[idx] += mesh[x1 + y * lineSize]; } - const float gh = ground->GetHeightAboveWater(x * resolution, y * resolution); + const float gh = CGround::GetHeightAboveWater(x * resolution, y * resolution); const float sh = smoothed[idx] / (xend - xstart + 1); smoothed[idx] = std::min(readMap->GetCurrMaxHeight(), std::max(gh, sh)); @@ -292,7 +292,7 @@ // non-border case avg += mesh[idx + smoothrad] - mesh[idx - smoothrad - 1]; - const float gh = ground->GetHeightAboveWater(x * resolution, y * resolution); + const float gh = CGround::GetHeightAboveWater(x * resolution, y * resolution); const float sh = recipn * avg; smoothed[idx] = std::min(readMap->GetCurrMaxHeight(), std::max(gh, sh)); @@ -337,7 +337,7 @@ smoothed[idx] += mesh[x + y1 * lineSize]; } - const float gh = ground->GetHeightAboveWater(x * resolution, y * resolution); + const float gh = CGround::GetHeightAboveWater(x * resolution, y * resolution); const float sh = smoothed[idx] / (yend - ystart + 1); smoothed[idx] = std::min(readMap->GetCurrMaxHeight(), std::max(gh, sh)); @@ -345,7 +345,7 @@ // non-border case avg += mesh[x + (y + smoothrad) * lineSize] - mesh[x + (y - smoothrad - 1) * lineSize]; - const float gh = ground->GetHeightAboveWater(x * resolution, y * resolution); + const float gh = CGround::GetHeightAboveWater(x * resolution, y * resolution); const float sh = recipn * avg; smoothed[idx] = std::min(readMap->GetCurrMaxHeight(), std::max(gh, sh)); @@ -379,14 +379,14 @@ } for (int y1 = std::max(0, y - intrad + 1); y1 <= std::min(maxy, y + intrad + 1); ++y1) { for (int x1 = 0; x1 <= maxx; ++x1) { - assert(ground->GetHeightReal(x1 * resolution, y1 * resolution) <= colsMaxima[x1]); + assert(CGround::GetHeightReal(x1 * resolution, y1 * resolution) <= colsMaxima[x1]); } } } -void SmoothHeightMesh::MakeSmoothMesh(const CGround* ground) +void SmoothHeightMesh::MakeSmoothMesh() { ScopedOnceTimer timer("SmoothHeightMesh::MakeSmoothMesh"); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/SmoothHeightMesh.h spring-98.0~14.04~ppa6/rts/Sim/Misc/SmoothHeightMesh.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/SmoothHeightMesh.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/SmoothHeightMesh.h 2014-10-07 20:09:51.000000000 +0000 @@ -13,7 +13,7 @@ class SmoothHeightMesh { public: - SmoothHeightMesh(const CGround* ground, float mx, float my, float res, float smoothRad); + SmoothHeightMesh(float mx, float my, float res, float smoothRad); ~SmoothHeightMesh(); float GetHeight(float x, float y); @@ -32,7 +32,7 @@ const float* GetOriginalMeshData() const { return &origMesh[0]; } private: - void MakeSmoothMesh(const CGround* ground); + void MakeSmoothMesh(); const int maxx, maxy; const float fmaxx, fmaxy; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/TeamBase.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/TeamBase.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/TeamBase.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/TeamBase.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -9,7 +9,7 @@ #include "System/creg/STL_Map.h" -CR_BIND(TeamBase, ); +CR_BIND(TeamBase, ) CR_REG_METADATA(TeamBase, ( CR_MEMBER(leader), CR_MEMBER(color), @@ -19,7 +19,7 @@ CR_MEMBER(side), CR_MEMBER(startPos), CR_MEMBER(customValues) -)); +)) unsigned char TeamBase::teamDefaultColor[10][4] = diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/TeamBase.h spring-98.0~14.04~ppa6/rts/Sim/Misc/TeamBase.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/TeamBase.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/TeamBase.h 2014-10-07 20:09:51.000000000 +0000 @@ -12,7 +12,7 @@ class TeamBase { - CR_DECLARE(TeamBase); + CR_DECLARE(TeamBase) public: typedef std::map customOpts; @@ -38,7 +38,7 @@ // will always be clamped to a team's start-box // (and hence the map) when clients receive them // so this should be redundant - if (!startPos.IsInMap()) + if (!startPos.IsInBounds()) return false; return true; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/Team.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/Team.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/Team.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/Team.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -9,8 +9,6 @@ #include "Game/Players/PlayerHandler.h" #include "Game/GameSetup.h" #include "Game/GlobalUnsynced.h" -#include "Lua/LuaRules.h" -#include "Lua/LuaUI.h" #include "Sim/Units/Unit.h" #include "Sim/Units/UnitDef.h" #include "System/EventHandler.h" @@ -22,7 +20,7 @@ #include "System/creg/STL_Map.h" #include "System/creg/STL_Set.h" -CR_BIND_DERIVED(CTeam, TeamBase, (-1)); +CR_BIND_DERIVED(CTeam, TeamBase, (-1)) CR_REG_METADATA(CTeam, ( CR_MEMBER(teamNum), CR_MEMBER(maxUnits), @@ -66,7 +64,7 @@ CR_MEMBER(modParams), CR_MEMBER(modParamsMap), CR_IGNORED(highlight) -)); +)) ////////////////////////////////////////////////////////////////////// @@ -208,11 +206,11 @@ return; } - if (!luaRules || luaRules->AllowResourceTransfer(teamNum, toTeam, "m", metal)) { + if (eventHandler.AllowResourceTransfer(teamNum, toTeam, "m", metal)) { target->metal += metal; metal = 0; } - if (!luaRules || luaRules->AllowResourceTransfer(teamNum, toTeam, "e", energy)) { + if (eventHandler.AllowResourceTransfer(teamNum, toTeam, "e", energy)) { target->energy += energy; energy = 0; } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/Team.h spring-98.0~14.04~ppa6/rts/Sim/Misc/Team.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/Team.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/Team.h 2014-10-07 20:09:51.000000000 +0000 @@ -19,7 +19,7 @@ class CTeam : public TeamBase, private boost::noncopyable //! cannot allow shallow copying of Teams, contains pointers { - CR_DECLARE(CTeam); + CR_DECLARE(CTeam) public: CTeam(int _teamNum); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/TeamHandler.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/TeamHandler.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/TeamHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/TeamHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -10,14 +10,14 @@ #include "System/Util.h" -CR_BIND(CTeamHandler, ); +CR_BIND(CTeamHandler, ) CR_REG_METADATA(CTeamHandler, ( CR_MEMBER(gaiaTeamID), CR_MEMBER(gaiaAllyTeamID), CR_MEMBER(teams), CR_MEMBER(allyTeams) -)); +)) CTeamHandler* teamHandler = NULL; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/TeamHandler.h spring-98.0~14.04~ppa6/rts/Sim/Misc/TeamHandler.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/TeamHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/TeamHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -15,7 +15,7 @@ /** @brief Handles teams and allyteams */ class CTeamHandler { - CR_DECLARE_STRUCT(CTeamHandler); + CR_DECLARE_STRUCT(CTeamHandler) public: CTeamHandler(); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/TeamStatistics.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/TeamStatistics.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/TeamStatistics.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/TeamStatistics.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -5,7 +5,7 @@ #include "System/Platform/byteorder.h" -CR_BIND(TeamStatistics, ); +CR_BIND(TeamStatistics, ) CR_REG_METADATA(TeamStatistics, ( CR_MEMBER(frame), CR_MEMBER(metalUsed), @@ -27,7 +27,7 @@ CR_MEMBER(unitsCaptured), CR_MEMBER(unitsOutCaptured), CR_MEMBER(unitsKilled) -)); +)) TeamStatistics::TeamStatistics() : frame(0) diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/TeamStatistics.h spring-98.0~14.04~ppa6/rts/Sim/Misc/TeamStatistics.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/TeamStatistics.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/TeamStatistics.h 2014-10-07 20:09:51.000000000 +0000 @@ -12,7 +12,7 @@ struct TeamStatistics { - CR_DECLARE_STRUCT(TeamStatistics); + CR_DECLARE_STRUCT(TeamStatistics) TeamStatistics(); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/Wind.cpp spring-98.0~14.04~ppa6/rts/Sim/Misc/Wind.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Misc/Wind.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/Wind.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ #include "System/creg/STL_Map.h" #include "System/myMath.h" -CR_BIND(CWind, ); +CR_BIND(CWind, ) CR_REG_METADATA(CWind, ( CR_MEMBER(maxWind), @@ -23,7 +23,7 @@ CR_MEMBER(windGens), CR_RESERVED(12) -)); +)) // update all units every 15 secs diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Misc/Wind.h spring-98.0~14.04~ppa6/rts/Sim/Misc/Wind.h --- spring-96.0~14.04~ppa4/rts/Sim/Misc/Wind.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Misc/Wind.h 2014-10-07 20:09:51.000000000 +0000 @@ -12,7 +12,7 @@ class CWind : public boost::noncopyable { - CR_DECLARE_STRUCT(CWind); + CR_DECLARE_STRUCT(CWind) public: CWind(); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/AAirMoveType.cpp spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/AAirMoveType.cpp --- spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/AAirMoveType.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/AAirMoveType.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -12,7 +12,7 @@ #include "Sim/Units/CommandAI/CommandAI.h" #include "Sim/Units/Scripts/UnitScript.h" -CR_BIND_DERIVED_INTERFACE(AAirMoveType, AMoveType); +CR_BIND_DERIVED_INTERFACE(AAirMoveType, AMoveType) CR_REG_METADATA(AAirMoveType, ( CR_ENUM_MEMBER(aircraftState), @@ -37,7 +37,7 @@ CR_MEMBER(lastColWarningType), CR_MEMBER(lastFuelUpdateFrame) -)); +)) AAirMoveType::AAirMoveType(CUnit* unit): AMoveType(unit), @@ -182,8 +182,8 @@ // in mid-air or sink below it // let gravity do the job instead of teleporting const float minHeight = owner->unitDef->canSubmerge? - ground->GetHeightReal(owner->pos.x, owner->pos.z): - ground->GetHeightAboveWater(owner->pos.x, owner->pos.z); + CGround::GetHeightReal(owner->pos.x, owner->pos.z): + CGround::GetHeightAboveWater(owner->pos.x, owner->pos.z); const float curHeight = owner->pos.y; if (curHeight > minHeight) { @@ -326,7 +326,7 @@ bool AAirMoveType::HaveLandedOnPad(const float3& padPos) { const AircraftState landingState = GetLandingState(); - const float landingPadHeight = ground->GetHeightAboveWater(padPos.x, padPos.z); + const float landingPadHeight = CGround::GetHeightAboveWater(padPos.x, padPos.z); reservedLandingPos = padPos; wantedHeight = padPos.y - landingPadHeight; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/AAirMoveType.h spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/AAirMoveType.h --- spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/AAirMoveType.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/AAirMoveType.h 2014-10-07 20:09:51.000000000 +0000 @@ -13,7 +13,7 @@ */ class AAirMoveType : public AMoveType { - CR_DECLARE(AAirMoveType); + CR_DECLARE(AAirMoveType) public: enum AircraftState { diff -Nru spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/ClassicGroundMoveType.cpp spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/ClassicGroundMoveType.cpp --- spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/ClassicGroundMoveType.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/ClassicGroundMoveType.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -62,7 +62,7 @@ #include "Sim/Weapons/WeaponDef.h" #include "Sim/Weapons/Weapon.h" #include "System/EventHandler.h" -#include "System/Sound/SoundChannels.h" +#include "System/Sound/ISoundChannels.h" #include "System/FastMath.h" #include "System/myMath.h" #include "System/type2.h" @@ -147,7 +147,7 @@ } if (OnSlope() && - (!owner->unitDef->floatOnWater || ground->GetHeightAboveWater(owner->midPos.x, owner->midPos.z) > 0)) + (!owner->unitDef->floatOnWater || CGround::GetHeightAboveWater(owner->midPos.x, owner->midPos.z) > 0)) { owner->SetPhysicalStateBit(CSolidObject::PSTATE_BIT_SKIDDING); } @@ -288,12 +288,12 @@ float wh = 0.0f; if (owner->unitDef->floatOnWater) { - wh = ground->GetHeightAboveWater(owner->pos.x, owner->pos.z); + wh = CGround::GetHeightAboveWater(owner->pos.x, owner->pos.z); if (wh == 0.0f) { wh = -owner->unitDef->waterline; } } else { - wh = ground->GetHeightReal(owner->pos.x, owner->pos.z); + wh = CGround::GetHeightReal(owner->pos.x, owner->pos.z); } owner->Move(UpVector * (wh - owner->pos.y), true); } @@ -321,7 +321,7 @@ StartEngine(); if (owner->team == gu->myTeam) { - Channels::General.PlayRandomSample(owner->unitDef->sounds.activate, owner); + Channels::General->PlayRandomSample(owner->unitDef->sounds.activate, owner); } } @@ -417,7 +417,7 @@ owner->updir = UpVector; owner->rightdir = owner->frontdir.cross(owner->updir); } else { - owner->updir = ground->GetNormal(owner->pos.x, owner->pos.z); + owner->updir = CGround::GetNormal(owner->pos.x, owner->pos.z); owner->rightdir = owner->frontdir.cross(owner->updir); owner->rightdir.Normalize(); owner->frontdir = owner->updir.cross(owner->rightdir); @@ -443,7 +443,7 @@ impulse = ZeroVector; } - float3 groundNormal = ground->GetNormal(pos.x, pos.z); + float3 groundNormal = CGround::GetNormal(pos.x, pos.z); float3 skidDir = spd; if (impulse.dot(groundNormal) < 0) @@ -488,9 +488,9 @@ float wh = 0.0f; if (owner->unitDef->floatOnWater) - wh = ground->GetHeightAboveWater(midPos.x, midPos.z); + wh = CGround::GetHeightAboveWater(midPos.x, midPos.z); else - wh = ground->GetHeightReal(midPos.x, midPos.z); + wh = CGround::GetHeightReal(midPos.x, midPos.z); if(wh>midPos.y-owner->relMidPos.y){ skidRotSpeed += (gs->randFloat()-0.5f)*1500; @@ -498,7 +498,7 @@ owner->ClearPhysicalStateBit(CSolidObject::PSTATE_BIT_FLYING); owner->Move(UpVector * (wh + owner->relMidPos.y - spd.y * 0.5f - pos.y), true); - const float impactSpeed = -spd.dot(ground->GetNormal(midPos.x,midPos.z)); + const float impactSpeed = -spd.dot(CGround::GetNormal(midPos.x,midPos.z)); if (impactSpeed > owner->unitDef->minCollisionSpeed && owner->unitDef->minCollisionSpeed >= 0) { owner->DoDamage(DamageArray(impactSpeed * owner->mass * 0.2f), ZeroVector, NULL, -1, -1); @@ -509,8 +509,8 @@ float speedReduction=0.35f; const bool onSlope = - (ground->GetSlope(owner->midPos.x, owner->midPos.z) > owner->moveDef->maxSlope) && - (!owner->unitDef->floatOnWater || ground->GetHeightAboveWater(midPos.x, midPos.z) > 0.0f); + (CGround::GetSlope(owner->midPos.x, owner->midPos.z) > owner->moveDef->maxSlope) && + (!owner->unitDef->floatOnWater || CGround::GetHeightAboveWater(midPos.x, midPos.z) > 0.0f); if (speedf < speedReduction && !onSlope) { owner->SetVelocity(ZeroVector); @@ -524,9 +524,9 @@ ChangeHeading(owner->heading); } else { if (onSlope) { - const float3 dir = ground->GetNormal(midPos.x, midPos.z); - const float3 normalForce = dir*dir.dot(UpVector*mapInfo->map.gravity); - const float3 newForce = UpVector*mapInfo->map.gravity - normalForce; + const float3& dir = CGround::GetNormal(midPos.x, midPos.z); + const float3 normalForce = dir * dir.dot(UpVector * mapInfo->map.gravity); + const float3 newForce = UpVector * mapInfo->map.gravity - normalForce; owner->SetVelocity(spd + newForce); owner->SetVelocity(spd * (1.0f - (0.1f * dir.y))); @@ -550,9 +550,9 @@ float wh = 0.0f; if (owner->unitDef->floatOnWater) - wh = ground->GetHeightAboveWater(pos.x, pos.z); + wh = CGround::GetHeightAboveWater(pos.x, pos.z); else - wh = ground->GetHeightReal(pos.x, pos.z); + wh = CGround::GetHeightReal(pos.x, pos.z); if (wh - pos.y < spd.y + mapInfo->map.gravity){ owner->SetVelocity(spd + (UpVector * mapInfo->map.gravity)); @@ -560,7 +560,7 @@ owner->SetPhysicalStateBit(CSolidObject::PSTATE_BIT_FLYING); owner->SetPhysicalStateBit(CSolidObject::PSTATE_BIT_SKIDDING); } else if (wh - pos.y > spd.y) { - const float3& normal = ground->GetNormal(pos.x, pos.z); + const float3& normal = CGround::GetNormal(pos.x, pos.z); const float dot = spd.dot(normal); if (dot > 0.0f) { @@ -597,9 +597,9 @@ float wh = 0.0f; if (owner->unitDef->floatOnWater) - wh = ground->GetHeightAboveWater(midPos.x, midPos.z); + wh = CGround::GetHeightAboveWater(midPos.x, midPos.z); else - wh = ground->GetHeightReal(midPos.x, midPos.z); + wh = CGround::GetHeightReal(midPos.x, midPos.z); if (wh > midPos.y - owner->relMidPos.y) { owner->Move(UpVector * (wh + owner->relMidPos.y - spd.y * 0.8 - midPos.y), true); @@ -722,7 +722,7 @@ owner->updir = UpVector; owner->rightdir = owner->frontdir.cross(owner->updir); } else { - owner->updir = ground->GetSmoothNormal(owner->pos.x, owner->pos.z); + owner->updir = CGround::GetSmoothNormal(owner->pos.x, owner->pos.z); owner->rightdir = owner->frontdir.cross(owner->updir); owner->rightdir.Normalize(); owner->frontdir = owner->updir.cross(owner->rightdir); @@ -1017,7 +1017,7 @@ StopEngine(); if (owner->team == gu->myTeam) { - Channels::General.PlayRandomSample(owner->unitDef->sounds.arrived, owner); + Channels::General->PlayRandomSample(owner->unitDef->sounds.arrived, owner); } progressState = Done; @@ -1570,7 +1570,7 @@ bool CClassicGroundMoveType::OnSlope(){ return owner->unitDef->slideTolerance >= 1 - && (ground->GetSlope(owner->midPos.x, owner->midPos.z) > + && (CGround::GetSlope(owner->midPos.x, owner->midPos.z) > owner->moveDef->maxSlope*owner->unitDef->slideTolerance); } @@ -1580,11 +1580,11 @@ { float wh = 0.0f; if (owner->unitDef->floatOnWater) { - wh = ground->GetHeightAboveWater(owner->pos.x, owner->pos.z); + wh = CGround::GetHeightAboveWater(owner->pos.x, owner->pos.z); if (wh == 0.0f) wh = -owner->unitDef->waterline; } else { - wh = ground->GetHeightReal(owner->pos.x, owner->pos.z); + wh = CGround::GetHeightReal(owner->pos.x, owner->pos.z); } if (!(owner->IsFalling() || owner->IsFlying())) { diff -Nru spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/GroundMoveType.cpp spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/GroundMoveType.cpp --- spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/GroundMoveType.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/GroundMoveType.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -15,7 +15,6 @@ #include "Sim/Features/Feature.h" #include "Sim/Features/FeatureHandler.h" #include "Sim/Misc/GeometricObjects.h" -#include "Sim/Misc/GroundBlockingObjectMap.h" #include "Sim/Misc/ModInfo.h" #include "Sim/Misc/QuadField.h" #include "Sim/Misc/TeamHandler.h" @@ -35,7 +34,8 @@ #include "System/myMath.h" #include "System/TimeProfiler.h" #include "System/type2.h" -#include "System/Sound/SoundChannels.h" +#include "System/Sound/ISoundChannels.h" +#include "System/Sync/HsiehHash.h" #include "System/Sync/SyncTracer.h" #if 1 @@ -66,7 +66,6 @@ #define MAX_IDLING_SLOWUPDATES 16 #define IGNORE_OBSTACLES 0 #define WAIT_FOR_PATH 1 -#define PLAY_SOUNDS 1 #define UNIT_CMD_QUE_SIZE(u) (u->commandAI->commandQue.size()) #define UNIT_HAS_MOVE_CMD(u) (u->commandAI->commandQue.empty() || u->commandAI->commandQue[0].GetID() == CMD_MOVE) @@ -74,10 +73,22 @@ #define FOOTPRINT_RADIUS(xs, zs, s) ((math::sqrt((xs * xs + zs * zs)) * 0.5f * SQUARE_SIZE) * s) -CR_BIND_DERIVED(CGroundMoveType, AMoveType, (NULL)); +CR_BIND_DERIVED(CGroundMoveType, AMoveType, (NULL)) CR_REG_METADATA(CGroundMoveType, ( CR_IGNORED(pathController), + + CR_MEMBER(currWayPoint), + CR_MEMBER(nextWayPoint), + + CR_MEMBER(waypointDir), + CR_MEMBER(flatFrontDir), + CR_MEMBER(lastAvoidanceDir), + CR_MEMBER(mainHeadingPos), + CR_MEMBER(skidRotVector), + CR_MEMBER(turnRate), + CR_MEMBER(turnSpeed), + CR_MEMBER(turnAccel), CR_MEMBER(accRate), CR_MEMBER(decRate), CR_MEMBER(myGravity), @@ -87,21 +98,19 @@ CR_MEMBER(currentSpeed), CR_MEMBER(deltaSpeed), - CR_MEMBER(pathId), - CR_MEMBER(goalRadius), - - CR_MEMBER(currWayPoint), - CR_MEMBER(nextWayPoint), CR_MEMBER(atGoal), CR_MEMBER(atEndOfPath), CR_MEMBER(currWayPointDist), CR_MEMBER(prevWayPointDist), + CR_MEMBER(goalRadius), CR_MEMBER(numIdlingUpdates), CR_MEMBER(numIdlingSlowUpdates), CR_MEMBER(wantedHeading), + CR_MEMBER(pathID), + CR_MEMBER(nextObstacleAvoidanceFrame), CR_MEMBER(lastPathRequestFrame), @@ -109,26 +118,32 @@ CR_MEMBER(idling), CR_MEMBER(canReverse), CR_MEMBER(useMainHeading), + CR_MEMBER(useRawMovement), - CR_MEMBER(waypointDir), - CR_MEMBER(flatFrontDir), - CR_MEMBER(lastAvoidanceDir), - CR_MEMBER(mainHeadingPos), - - CR_MEMBER(skidRotVector), CR_MEMBER(skidRotSpeed), CR_MEMBER(skidRotAccel), CR_POSTLOAD(PostLoad) -)); +)) CGroundMoveType::CGroundMoveType(CUnit* owner): AMoveType(owner), - pathController(owner ? IPathController::GetInstance(owner) : NULL), + pathController((owner != NULL)? IPathController::GetInstance(owner): NULL), + + currWayPoint(ZeroVector), + nextWayPoint(ZeroVector), + + flatFrontDir(FwdVector), + lastAvoidanceDir(ZeroVector), + mainHeadingPos(ZeroVector), + skidRotVector(UpVector), turnRate(0.1f), + turnSpeed(0.0f), + turnAccel(0.0f), + accRate(0.01f), decRate(0.01f), myGravity(0.0f), @@ -138,29 +153,23 @@ currentSpeed(0.0f), deltaSpeed(0.0f), - pathId(0), - goalRadius(0), - - currWayPoint(ZeroVector), - nextWayPoint(ZeroVector), atGoal(false), atEndOfPath(false), currWayPointDist(0.0f), prevWayPointDist(0.0f), + goalRadius(0.0f), reversing(false), idling(false), canReverse((owner != NULL) && (owner->unitDef->rSpeed > 0.0f)), useMainHeading(false), + useRawMovement(false), - skidRotVector(UpVector), skidRotSpeed(0.0f), skidRotAccel(0.0f), - flatFrontDir(FwdVector), - lastAvoidanceDir(ZeroVector), - mainHeadingPos(ZeroVector), + pathID(0), nextObstacleAvoidanceFrame(0), lastPathRequestFrame(0), @@ -172,13 +181,16 @@ { if (owner == NULL) return; - if (owner->unitDef == NULL) - return; + + assert(owner->unitDef != NULL); + assert(owner->moveDef != NULL); // maxSpeed is set in AMoveType's ctor maxReverseSpeed = owner->unitDef->rSpeed / GAME_SPEED; - turnRate = owner->unitDef->turnRate; + turnRate = std::max(owner->unitDef->turnRate, 1.0f); + turnAccel = turnRate * mix(0.333f, 0.033f, owner->moveDef->speedModClass == MoveDef::Ship); + accRate = std::max(0.01f, owner->unitDef->maxAcc); decRate = std::max(0.01f, owner->unitDef->maxDec); @@ -188,8 +200,8 @@ CGroundMoveType::~CGroundMoveType() { - if (pathId != 0) { - pathManager->DeletePath(pathId); + if (pathID != 0) { + pathManager->DeletePath(pathID); } IPathController::FreeInstance(pathController); @@ -200,8 +212,8 @@ pathController = IPathController::GetInstance(owner); // HACK: re-initialize path after load - if (pathId != 0) { - pathId = pathManager->RequestPath(owner, owner->moveDef, owner->pos, goalPos, goalRadius, true); + if (pathID != 0) { + pathID = pathManager->RequestPath(owner, owner->moveDef, owner->pos, goalPos, goalRadius, true); } } @@ -318,7 +330,7 @@ } } else { if (progressState == Active) { - if (pathId != 0) { + if (pathID != 0) { if (idling) { numIdlingSlowUpdates = std::min(MAX_IDLING_SLOWUPDATES, int(numIdlingSlowUpdates + 1)); } else { @@ -329,7 +341,7 @@ // case A: we have a path but are not moving LOG_L(L_DEBUG, "SlowUpdate: unit %i has pathID %i but %i ETA failures", - owner->id, pathId, numIdlingUpdates); + owner->id, pathID, numIdlingUpdates); if (numIdlingSlowUpdates < MAX_IDLING_SLOWUPDATES) { ReRequestPath(false, true); @@ -359,6 +371,27 @@ } +void CGroundMoveType::StartMovingRaw(const float3 moveGoalPos, float moveGoalRadius) { + goalPos = moveGoalPos * XZVector; + goalRadius = moveGoalRadius; + + currWayPoint = goalPos; + nextWayPoint = goalPos; + + atGoal = ((moveGoalPos * XZVector) == (owner->pos * XZVector)); + atEndOfPath = false; + + useMainHeading = false; + useRawMovement = true; + progressState = Active; + + numIdlingUpdates = 0; + numIdlingSlowUpdates = 0; + + currWayPointDist = 0.0f; + prevWayPointDist = 0.0f; +} + void CGroundMoveType::StartMoving(float3 moveGoalPos, float moveGoalRadius) { #ifdef TRACE_SYNC tracefile << "[" << __FUNCTION__ << "] "; @@ -366,13 +399,14 @@ #endif // set the new goal - goalPos.x = moveGoalPos.x; - goalPos.z = moveGoalPos.z; - goalPos.y = 0.0f; + goalPos = moveGoalPos * XZVector; goalRadius = moveGoalRadius; - atGoal = false; + + atGoal = ((moveGoalPos * XZVector) == (owner->pos * XZVector)); + atEndOfPath = false; useMainHeading = false; + useRawMovement = false; progressState = Active; numIdlingUpdates = 0; @@ -383,6 +417,9 @@ LOG_L(L_DEBUG, "StartMoving: starting engine for unit %i", owner->id); + if (atGoal) + return; + // silently free previous path if unit already had one // // units passing intermediate waypoints will TYPICALLY not cause any @@ -390,11 +427,9 @@ // unless they come to a full stop first ReRequestPath(false, true); - #if (PLAY_SOUNDS == 1) if (owner->team == gu->myTeam) { - Channels::General.PlayRandomSample(owner->unitDef->sounds.activate, owner); + Channels::General->PlayRandomSample(owner->unitDef->sounds.activate, owner); } - #endif } void CGroundMoveType::StopMoving(bool callScript, bool hardStop) { @@ -416,6 +451,8 @@ StopEngine(callScript, hardStop); useMainHeading = false; + // only a new StartMoving call can reset this + // useRawMovement = false; progressState = Done; } @@ -425,7 +462,7 @@ { bool wantReverse = false; - if (pathId == 0) { + if (WantToStop()) { ChangeSpeed(0.0f, false); SetMainHeading(); } else { @@ -438,17 +475,17 @@ { // NOTE: - // uses owner->pos instead of currWayPoint (ie. not the same as atEndOfPath) + // uses owner->pos instead of currWayPoint (ie. not the same as atEndOfPath) // - // if our first command is a build-order, then goalRadius is set to our build-range - // and we cannot increase tolerance safely (otherwise the unit might stop when still - // outside its range and fail to start construction) + // if our first command is a build-order, then goalRadius is set to our build-range + // and we cannot increase tolerance safely (otherwise the unit might stop when still + // outside its range and fail to start construction) const float curGoalDistSq = (owner->pos - goalPos).SqLength2D(); const float minGoalDistSq = (UNIT_HAS_MOVE_CMD(owner))? Square(goalRadius * (numIdlingSlowUpdates + 1)): Square(goalRadius ); - atGoal |= (curGoalDistSq < minGoalDistSq); + atGoal |= (curGoalDistSq <= minGoalDistSq); } if (!atGoal) { @@ -459,7 +496,8 @@ } } - if (!atEndOfPath) { + // atEndOfPath never becomes true when useRawMovement + if (!atEndOfPath && !useRawMovement) { GetNextWayPoint(); } else { if (atGoal) { @@ -467,11 +505,10 @@ } } - // set direction to waypoint AFTER requesting it - waypointDir.x = currWayPoint.x - owner->pos.x; - waypointDir.z = currWayPoint.z - owner->pos.z; - waypointDir.y = 0.0f; - waypointDir.SafeNormalize(); + if (!atGoal) { + // set direction to waypoint AFTER requesting it + waypointDir = ((currWayPoint - owner->pos) * XZVector).SafeNormalize(); + } ASSERT_SYNCED(waypointDir); @@ -489,7 +526,7 @@ ChangeSpeed(maxWantedSpeed, wantReverse); } - pathManager->UpdatePath(owner, pathId); + pathManager->UpdatePath(owner, pathID); return wantReverse; } @@ -505,7 +542,7 @@ } // first calculate the "unrestricted" speed and acceleration - float targetSpeed = wantReverse? maxReverseSpeed: maxSpeed; + float targetSpeed = mix(maxSpeed, maxReverseSpeed, wantReverse); #if (WAIT_FOR_PATH == 1) // don't move until we have an actual path, trying to hide queuing @@ -526,7 +563,7 @@ const float groundSpeedMod = CMoveMath::GetPosSpeedMod(*md, owner->pos, flatFrontDir); const float curGoalDistSq = (owner->pos - goalPos).SqLength2D(); - const float minGoalDistSq = Square(BrakingDistance(currentSpeed)); + const float minGoalDistSq = Square(BrakingDistance(currentSpeed, mix(decRate, accRate, reversing))); const float3& waypointDifFwd = waypointDir; const float3 waypointDifRev = -waypointDifFwd; @@ -539,21 +576,21 @@ if (!fpsMode && turnDeltaHeading != 0) { // only auto-adjust speed for turns when not in FPS mode - const float reqTurnAngle = math::fabs(180.0f * (owner->heading - wantedHeading) / SHORTINT_MAXVALUE); + const float reqTurnAngle = math::fabs(180.0f * short(owner->heading - wantedHeading) / SHORTINT_MAXVALUE); const float maxTurnAngle = (turnRate / SPRING_CIRCLE_DIVS) * 360.0f; - float turnSpeed = (reversing)? maxReverseSpeed: maxSpeed; + float turnLinearSpeed = mix(maxSpeed, maxReverseSpeed, reversing); if (reqTurnAngle != 0.0f) { - turnSpeed *= std::min(maxTurnAngle / reqTurnAngle, 1.0f); + turnLinearSpeed *= std::min(std::max(0.1f, maxTurnAngle / reqTurnAngle), 1.0f); } if (waypointDir.SqLength() > 0.1f) { if (!ud->turnInPlace) { - targetSpeed = std::max(ud->turnInPlaceSpeedLimit, turnSpeed); + targetSpeed = std::max(ud->turnInPlaceSpeedLimit, turnLinearSpeed); } else { if (reqTurnAngle > ud->turnInPlaceAngleLimit) { - targetSpeed = turnSpeed; + targetSpeed = turnLinearSpeed; } } } @@ -567,21 +604,21 @@ // now apply the terrain and command restrictions // NOTE: - // if wantedSpeed > targetSpeed, the unit will - // not accelerate to speed > targetSpeed unless - // its actual max{Reverse}Speed is also changed + // if wantedSpeed > targetSpeed, the unit will + // not accelerate to speed > targetSpeed unless + // its actual max{Reverse}Speed is also changed // - // raise wantedSpeed iff the terrain-modifier is - // larger than 1 (so units still get their speed - // bonus correctly), otherwise leave it untouched + // raise wantedSpeed iff the terrain-modifier is + // larger than 1 (so units still get their speed + // bonus correctly), otherwise leave it untouched // - // disallow changing speed (except to zero) without - // a path if not in FPS mode (FIXME: legacy PFS can - // return path when none should exist, mantis3720) + // disallow changing speed (except to zero) without + // a path if not in FPS mode (FIXME: legacy PFS can + // return path when none should exist, mantis3720) wantedSpeed *= std::max(groundSpeedMod, 1.0f); targetSpeed *= groundSpeedMod; targetSpeed *= (1 - startBraking); - targetSpeed *= (pathId != 0 || fpsMode); + targetSpeed *= ((1 - WantToStop()) || fpsMode); targetSpeed = std::min(targetSpeed, wantedSpeed); } else { targetSpeed = 0.0f; @@ -589,7 +626,7 @@ } deltaSpeed = pathController->GetDeltaSpeed( - pathId, + pathID, targetSpeed, currentSpeed, accRate, @@ -607,14 +644,18 @@ if (owner->IsFlying()) return; if (owner->GetTransporter() != NULL) return; - owner->heading += pathController->GetDeltaHeading(pathId, (wantedHeading = newHeading), owner->heading, turnRate); + #if 0 + owner->heading += pathController->GetDeltaHeading(pathID, (wantedHeading = newHeading), owner->heading, turnRate); + #else + // model rotational inertia (more realistic for ships) + owner->heading += pathController->GetDeltaHeading(pathID, (wantedHeading = newHeading), owner->heading, turnRate, turnAccel, BrakingDistance(turnSpeed, turnAccel), &turnSpeed); + #endif owner->UpdateDirVectors(!owner->upright); owner->UpdateMidAndAimPos(); flatFrontDir = owner->frontdir; - flatFrontDir.y = 0.0f; - flatFrontDir.Normalize(); + flatFrontDir = (flatFrontDir * XZVector).Normalize(); } @@ -650,7 +691,7 @@ // small-charge capacitor // const bool startSkidding = StartSkidding(newSpeed, skidDir); - const bool startFlying = StartFlying(newSpeed, ground->GetNormal(owner->pos.x, owner->pos.z)); + const bool startFlying = StartFlying(newSpeed, CGround::GetNormal(owner->pos.x, owner->pos.z)); if (newSpeed.SqLength2D() >= 0.01f) { skidDir = newSpeed.Normalize2D(); @@ -680,7 +721,7 @@ if (owner->IsFlying()) { const float impactSpeed = pos.IsInBounds()? - -spd.dot(ground->GetNormal(pos.x, pos.z)): + -spd.dot(CGround::GetNormal(pos.x, pos.z)): -spd.dot(UpVector); const float impactDamageMult = impactSpeed * owner->mass * COLLISION_DAMAGE_MULT; const bool doColliderDamage = (modInfo.allowUnitCollisionDamage && impactSpeed > ud->minCollisionSpeed && ud->minCollisionSpeed >= 0.0f); @@ -692,8 +733,8 @@ // deal ground impact damage // TODO: - // bouncing behaves too much like a rubber-ball, - // most impact energy needs to go into the ground + // bouncing behaves too much like a rubber-ball, + // most impact energy needs to go into the ground if (doColliderDamage) { owner->DoDamage(DamageArray(impactDamageMult), ZeroVector, NULL, -CSolidObject::DAMAGE_COLLISION_GROUND, -1); } @@ -727,7 +768,7 @@ const float remTime = std::max(1.0f, speedScale / speedReduction); if (onSlope) { - const float3 normalVector = ground->GetNormal(pos.x, pos.z); + const float3& normalVector = CGround::GetNormal(pos.x, pos.z); const float3 normalForce = normalVector * normalVector.dot(UpVector * mapInfo->map.gravity); const float3 newForce = UpVector * mapInfo->map.gravity - normalForce; @@ -760,7 +801,7 @@ // LHS is always negative, so this becomes true when the // unit is falling back down and will impact the ground // in one frame - const float3& normal = (pos.IsInBounds())? ground->GetNormal(pos.x, pos.z): UpVector; + const float3& normal = (pos.IsInBounds())? CGround::GetNormal(pos.x, pos.z): UpVector; const float dot = spd.dot(normal); if (dot > 0.0f) { @@ -821,9 +862,9 @@ CUnit* collider = owner; // NOTE: - // the QuadField::Get* functions check o->midPos, - // but the quad(s) that objects are stored in are - // derived from o->pos (!) + // the QuadField::Get* functions check o->midPos, + // but the quad(s) that objects are stored in are + // derived from o->pos (!) const float3& pos = collider->pos; const UnitDef* colliderUD = collider->unitDef; @@ -990,8 +1031,8 @@ return desiredDir; #endif - // Obstacle-avoidance-system only needs to be run if the unit wants to move - if (pathId == 0) + // obstacle-avoidance only needs to run if the unit wants to move + if (WantToStop()) return ZeroVector; // Speed-optimizer. Reduces the times this system is run. @@ -1022,6 +1063,7 @@ // now we do the obstacle avoidance proper // avoider always uses its never-rotated MoveDef footprint + // note: should increase radius for smaller turnAccel values const float avoidanceRadius = std::max(currentSpeed, 1.0f) * (avoider->radius * 2.0f); const float avoiderRadius = FOOTPRINT_RADIUS(avoiderMD->xsize, avoiderMD->zsize, 1.0f); @@ -1088,8 +1130,6 @@ // (or not yet fully apart), then the object is on the path of the unit // and they are not collided if (DEBUG_DRAWING_ENABLED) { - GML_RECMUTEX_LOCK(sel); // GetObstacleAvoidanceDir - if (selectedUnitsHandler.selectedUnits.find(owner) != selectedUnitsHandler.selectedUnits.end()) { geometricObjects->AddLine(avoider->pos + (UpVector * 20.0f), avoidee->pos + (UpVector * 20.0f), 3, 1, 4); } @@ -1123,12 +1163,10 @@ // use a weighted combination of the desired- and the avoidance-directions // also linearly smooth it using the vector calculated the previous frame - avoidanceDir = (desiredDir * DESIRED_DIR_WEIGHT + avoidanceVec).SafeNormalize(); - avoidanceDir = lastAvoidanceDir * LAST_DIR_MIX_ALPHA + avoidanceDir * (1.0f - LAST_DIR_MIX_ALPHA); + avoidanceDir = (mix(desiredDir, avoidanceVec, DESIRED_DIR_WEIGHT)).SafeNormalize(); + avoidanceDir = (mix(avoidanceDir, lastAvoidanceDir, LAST_DIR_MIX_ALPHA)).SafeNormalize(); if (DEBUG_DRAWING_ENABLED) { - GML_RECMUTEX_LOCK(sel); // GetObstacleAvoidanceDir - if (selectedUnitsHandler.selectedUnits.find(owner) != selectedUnitsHandler.selectedUnits.end()) { const float3 p0 = owner->pos + ( UpVector * 20.0f); const float3 p1 = p0 + (avoidanceVec * 40.0f); @@ -1147,24 +1185,32 @@ +#if 0 // Calculates an aproximation of the physical 2D-distance between given two objects. +// Old, no longer used since all separation tests are based on FOOTPRINT_RADIUS now. float CGroundMoveType::Distance2D(CSolidObject* object1, CSolidObject* object2, float marginal) { // calculate the distance in (x,z) depending // on the shape of the object footprints - float dist2D; + float dist2D = 0.0f; + + const float xs = ((object1->xsize + object2->xsize) * (SQUARE_SIZE >> 1)); + const float zs = ((object1->zsize + object2->zsize) * (SQUARE_SIZE >> 1)); + if (object1->xsize == object1->zsize || object2->xsize == object2->zsize) { // use xsize as a cylindrical radius. - float3 distVec = (object1->midPos - object2->midPos); - dist2D = distVec.Length2D() - (object1->xsize + object2->xsize) * SQUARE_SIZE / 2 + 2 * marginal; + const float3 distVec = object1->midPos - object2->midPos; + + dist2D = distVec.Length2D() - xs + 2.0f * marginal; } else { // Pytagorean sum of the x and z distance. float3 distVec; + const float xdiff = math::fabs(object1->midPos.x - object2->midPos.x); const float zdiff = math::fabs(object1->midPos.z - object2->midPos.z); - distVec.x = xdiff - (object1->xsize + object2->xsize) * SQUARE_SIZE / 2 + 2 * marginal; - distVec.z = zdiff - (object1->zsize + object2->zsize) * SQUARE_SIZE / 2 + 2 * marginal; + distVec.x = xdiff - xs + 2.0f * marginal; + distVec.z = zdiff - zs + 2.0f * marginal; if (distVec.x > 0.0f && distVec.z > 0.0f) { dist2D = distVec.Length2D(); @@ -1179,25 +1225,33 @@ return dist2D; } +#endif // Creates a path to the goal. -void CGroundMoveType::GetNewPath() +unsigned int CGroundMoveType::GetNewPath() { - assert(pathId == 0); - pathId = pathManager->RequestPath(owner, owner->moveDef, owner->pos, goalPos, goalRadius, true); + unsigned int newPathID = 0; - if (pathId != 0) { + if (useRawMovement) + return newPathID; + // avoid frivolous requests if called from outside StartMoving*() + if ((owner->pos - goalPos).SqLength2D() <= Square(goalRadius)) + return newPathID; + + if ((newPathID = pathManager->RequestPath(owner, owner->moveDef, owner->pos, goalPos, goalRadius, true)) != 0) { atGoal = false; atEndOfPath = false; - currWayPoint = pathManager->NextWayPoint(owner, pathId, 0, owner->pos, 1.25f * SQUARE_SIZE, true); - nextWayPoint = pathManager->NextWayPoint(owner, pathId, 0, currWayPoint, 1.25f * SQUARE_SIZE, true); + currWayPoint = pathManager->NextWayPoint(owner, newPathID, 0, owner->pos, 1.25f * SQUARE_SIZE, true); + nextWayPoint = pathManager->NextWayPoint(owner, newPathID, 0, currWayPoint, 1.25f * SQUARE_SIZE, true); - pathController->SetRealGoalPosition(pathId, goalPos); - pathController->SetTempGoalPosition(pathId, currWayPoint); + pathController->SetRealGoalPosition(newPathID, goalPos); + pathController->SetTempGoalPosition(newPathID, currWayPoint); } else { Fail(false); } + + return newPathID; } bool CGroundMoveType::ReRequestPath(bool callScript, bool forceRequest) { @@ -1215,9 +1269,11 @@ bool CGroundMoveType::CanGetNextWayPoint() { - if (pathId == 0) + assert(!useRawMovement); + + if (pathID == 0) return false; - if (!pathController->AllowSetTempGoalPosition(pathId, nextWayPoint)) + if (!pathController->AllowSetTempGoalPosition(pathID, nextWayPoint)) return false; @@ -1226,19 +1282,17 @@ float3& cwp = (float3&) currWayPoint; float3& nwp = (float3&) nextWayPoint; - if (pathManager->PathUpdated(pathId)) { + if (pathManager->PathUpdated(pathID)) { // path changed while we were following it (eg. due // to terrain deformation) in between two waypoints // but still has the same ID; in this case (which is // specific to QTPFS) we don't go through GetNewPath // - cwp = pathManager->NextWayPoint(owner, pathId, 0, pos, 1.25f * SQUARE_SIZE, true); - nwp = pathManager->NextWayPoint(owner, pathId, 0, cwp, 1.25f * SQUARE_SIZE, true); + cwp = pathManager->NextWayPoint(owner, pathID, 0, pos, 1.25f * SQUARE_SIZE, true); + nwp = pathManager->NextWayPoint(owner, pathID, 0, cwp, 1.25f * SQUARE_SIZE, true); } if (DEBUG_DRAWING_ENABLED) { - GML_RECMUTEX_LOCK(sel); // CanGetNextWayPoint - if (selectedUnitsHandler.selectedUnits.find(owner) != selectedUnitsHandler.selectedUnits.end()) { // plot the vectors to {curr, next}WayPoint const int cwpFigGroupID = geometricObjects->AddLine(pos + (UpVector * 20.0f), cwp + (UpVector * (pos.y + 20.0f)), 8.0f, 1, 4); @@ -1294,7 +1348,7 @@ // if still further than SS elmos from waypoint, disallow skipping // note: can somehow cause units to move in circles near obstacles // (mantis3718) if rectangle is too generous in size - if ((pos - cwp).SqLength() > (SQUARE_SIZE * SQUARE_SIZE)) { + if ((pos - cwp).SqLength() > Square(SQUARE_SIZE) && (pos - cwp).dot(flatFrontDir) >= 0.0f) { return false; } } @@ -1310,7 +1364,7 @@ // trigger Arrived on the next Update (but // only if we have non-temporary waypoints) // atEndOfPath |= (currWayPoint == nextWayPoint); - atEndOfPath |= (curGoalDistSq < minGoalDistSq); + atEndOfPath |= (curGoalDistSq <= minGoalDistSq); } if (atEndOfPath) { @@ -1325,12 +1379,14 @@ void CGroundMoveType::GetNextWayPoint() { + assert(!useRawMovement); + if (CanGetNextWayPoint()) { - pathController->SetTempGoalPosition(pathId, nextWayPoint); + pathController->SetTempGoalPosition(pathID, nextWayPoint); // NOTE: pathfinder implementation should ensure waypoints are not equal currWayPoint = nextWayPoint; - nextWayPoint = pathManager->NextWayPoint(owner, pathId, 0, currWayPoint, 1.25f * SQUARE_SIZE, true); + nextWayPoint = pathManager->NextWayPoint(owner, pathID, 0, currWayPoint, 1.25f * SQUARE_SIZE, true); } if (nextWayPoint.x == -1.0f && nextWayPoint.z == -1.0f) { @@ -1359,9 +1415,8 @@ starting from given speed and applying maximum brake rate. */ -float CGroundMoveType::BrakingDistance(float speed) const +float CGroundMoveType::BrakingDistance(float speed, float rate) const { - const float rate = reversing? accRate: decRate; const float time = speed / std::max(rate, 0.001f); const float dist = 0.5f * rate * time * time; return dist; @@ -1373,10 +1428,10 @@ */ float3 CGroundMoveType::Here() { - const float dist = BrakingDistance(currentSpeed); + const float dist = BrakingDistance(currentSpeed, mix(decRate, accRate, reversing)); const int sign = Sign(int(!reversing)); - const float3 pos2D = float3(owner->pos.x, 0.0f, owner->pos.z); + const float3 pos2D = owner->pos * XZVector; const float3 dir2D = flatFrontDir * dist * sign; return (pos2D + dir2D); @@ -1388,11 +1443,11 @@ void CGroundMoveType::StartEngine(bool callScript) { - if (pathId == 0) - GetNewPath(); + if (pathID == 0) + pathID = GetNewPath(); - if (pathId != 0) { - pathManager->UpdatePath(owner, pathId); + if (pathID != 0) { + pathManager->UpdatePath(owner, pathID); if (callScript) { // makes no sense to call this unless we have a new path @@ -1404,9 +1459,9 @@ } void CGroundMoveType::StopEngine(bool callScript, bool hardStop) { - if (pathId != 0) { - pathManager->DeletePath(pathId); - pathId = 0; + if (pathID != 0) { + pathManager->DeletePath(pathID); + pathID = 0; if (callScript) { owner->script->StopMoving(); @@ -1428,11 +1483,9 @@ if (progressState == Active) { StopEngine(callScript); - #if (PLAY_SOUNDS == 1) if (owner->team == gu->myTeam) { - Channels::General.PlayRandomSample(owner->unitDef->sounds.arrived, owner); + Channels::General->PlayRandomSample(owner->unitDef->sounds.arrived, owner); } - #endif // and the action is done progressState = Done; @@ -1502,7 +1555,11 @@ HandleUnitCollisions(collider, colliderSpeed, colliderRadius, colliderUD, colliderMD); HandleFeatureCollisions(collider, colliderSpeed, colliderRadius, colliderUD, colliderMD); - HandleStaticObjectCollision(collider, collider, colliderMD, colliderRadius, 0.0f, ZeroVector, true, false, true); + + // blocked square collision (very performance hungry process only every 2nd game frame) + if ((collider->id & 1) == (gs->frameNum & 1)) { + HandleStaticObjectCollision(owner, owner, owner->moveDef, colliderRadius, 0.0f, ZeroVector, true, false, true); + } } } @@ -1552,8 +1609,8 @@ // mantis{3614,4217} // we cannot nicely bounce off terrain when checking only the center square // however, testing more squares means CD can (sometimes) disagree with PFS - // --> compromise and assume a 3x3 footprint --> still possible but have to - // ensure we allow only lateral (non-obstructing) bounces + // in narrow passages --> still possible, but have to ensure we allow only + // lateral (non-obstructing) bounces const int xsh = colliderMD->xsizeh * (checkYardMap || (checkTerrain * colliderMD->allowTerrainCollisions)); const int zsh = colliderMD->zsizeh * (checkYardMap || (checkTerrain * colliderMD->allowTerrainCollisions)); @@ -1641,10 +1698,14 @@ if (colliderMD->TestMoveSquare(collider, collider->pos + strafeVec + bounceVec, ZeroVector, checkTerrain, checkYardMap, checkTerrain)) { collider->Move(strafeVec + bounceVec, true); } else { - collider->Move(oldPos, false); + collider->Move(oldPos - collider->pos, wantRequestPath = true); } } + // note: + // in many cases this does not mean we should request a new path + // (and it can be counter-productive to do so since we might not + // even *get* one) wantRequestPath = ((strafeVec + bounceVec) != ZeroVector); } else { const float colRadiusSum = colliderRadius + collideeRadius; @@ -1668,10 +1729,11 @@ // the new speedvector which is constructed from deltaSpeed --> we would simply keep // moving forward through obstacles if not counteracted by this if (collider->frontdir.dot(separationVector) < 0.25f) { - collider->Move(oldPos, false); + collider->Move(oldPos - collider->pos, wantRequestPath = true); } } + // same here wantRequestPath = (penDistance < 0.0f); } @@ -1689,7 +1751,7 @@ const UnitDef* colliderUD, const MoveDef* colliderMD ) { - const float searchRadius = std::max(colliderSpeed, 1.0f) * (colliderRadius * 1.0f); + const float searchRadius = colliderSpeed + (colliderRadius * 2.0f); const std::vector& nearUnits = quadField->GetUnitsExact(collider->pos, searchRadius); std::vector::const_iterator uit; @@ -1880,7 +1942,7 @@ const UnitDef* colliderUD, const MoveDef* colliderMD ) { - const float searchRadius = std::max(colliderSpeed, 1.0f) * (colliderRadius * 1.0f); + const float searchRadius = colliderSpeed + (colliderRadius * 2.0f); const std::vector& nearFeatures = quadField->GetFeaturesExact(collider->pos, searchRadius); std::vector::const_iterator fit; @@ -1973,10 +2035,12 @@ mainHeadingPos = pos; useMainHeading = aggressive; - if (!useMainHeading) return; - if (owner->weapons.empty()) return; + if (!useMainHeading) + return; + if (owner->weapons.empty()) + return; - CWeapon* frontWeapon = owner->weapons.front(); + const CWeapon* frontWeapon = owner->weapons.front(); if (!frontWeapon->weaponDef->waterweapon) { mainHeadingPos.y = std::max(mainHeadingPos.y, 0.0f); @@ -1989,8 +2053,8 @@ if (dir1 == UpVector) return; - dir1.y = 0.0f; dir1.SafeNormalize(); - dir2.y = 0.0f; dir2.SafeNormalize(); + dir1 = (dir1 * XZVector).SafeNormalize(); + dir2 = (dir2 * XZVector).SafeNormalize(); if (dir2 == ZeroVector) return; @@ -2005,11 +2069,11 @@ // NOTE: // by changing the progress-state here (which seems redundant), // SlowUpdate can suddenly request a new path for us even after - // StopMoving (which clears pathId; CAI often calls StopMoving + // StopMoving (which clears pathID; CAI often calls StopMoving // before unit is at goalPos!) // for this reason StopMoving always updates goalPos so internal // GetNewPath's are no-ops (while CAI does not call StartMoving) - if (!frontWeapon->TryTarget(mainHeadingPos, true, 0)) { + if (!frontWeapon->TryTarget(mainHeadingPos, true, NULL)) { progressState = Active; } } @@ -2023,21 +2087,18 @@ * @brief Orients owner so that weapon[0]'s arc includes mainHeadingPos */ void CGroundMoveType::SetMainHeading() { - if (!useMainHeading) return; - if (owner->weapons.empty()) return; + if (!useMainHeading) + return; + if (owner->weapons.empty()) + return; - CWeapon* frontWeapon = owner->weapons.front(); + const CWeapon* frontWeapon = owner->weapons.front(); - float3 dir1 = frontWeapon->mainDir; - float3 dir2 = mainHeadingPos - owner->pos; + const float3 dir1 = (( frontWeapon->mainDir) * XZVector).SafeNormalize(); + const float3 dir2 = ((mainHeadingPos - owner->pos) * XZVector).SafeNormalize(); - dir1.y = 0.0f; - dir1.Normalize(); - dir2.y = 0.0f; - dir2.SafeNormalize(); - - ASSERT_SYNCED(dir1); - ASSERT_SYNCED(dir2); + // ASSERT_SYNCED(dir1); + // ASSERT_SYNCED(dir2); if (dir2 == ZeroVector) return; @@ -2058,7 +2119,7 @@ } } else { if (owner->heading != newHeading) { - if (!frontWeapon->TryTarget(mainHeadingPos, true, 0)) { + if (!frontWeapon->TryTarget(mainHeadingPos, true, NULL)) { progressState = Active; } } @@ -2078,7 +2139,7 @@ // (otherwise the unit could stop on an invalid path location, and be teleported // back) const float slopeMul = mix(ud->slideTolerance, 1.0f, (minSlideTolerance <= 0.0f)); - const float curSlope = ground->GetSlope(pos.x, pos.z); + const float curSlope = CGround::GetSlope(pos.x, pos.z); const float maxSlope = md->maxSlope * slopeMul; return (curSlope > maxSlope); @@ -2089,17 +2150,17 @@ const float3& CGroundMoveType::GetGroundNormal(const float3& p) const { if (owner->IsInWater() && !owner->IsOnGround()) { - // ship or hovercraft; return (ground->GetNormalAboveWater(p)); + // ship or hovercraft; return (CGround::GetNormalAboveWater(p)); return UpVector; } - return (ground->GetNormal(p.x, p.z)); + return (CGround::GetNormal(p.x, p.z)); } float CGroundMoveType::GetGroundHeight(const float3& p) const { // in [minHeight, maxHeight] - const float gh = ground->GetHeightReal(p.x, p.z); + const float gh = CGround::GetHeightReal(p.x, p.z); const float wh = -owner->unitDef->waterline * (gh <= 0.0f); if (owner->unitDef->floatOnWater) { @@ -2120,9 +2181,9 @@ if (modInfo.allowGroundUnitGravity) { if (owner->unitDef->floatOnWater) { - owner->Move(UpVector * (std::max(ground->GetHeightReal(owner->pos.x, owner->pos.z), -owner->unitDef->waterline) - owner->pos.y), true); + owner->Move(UpVector * (std::max(CGround::GetHeightReal(owner->pos.x, owner->pos.z), -owner->unitDef->waterline) - owner->pos.y), true); } else { - owner->Move(UpVector * (std::max(ground->GetHeightReal(owner->pos.x, owner->pos.z), owner->pos.y) - owner->pos.y), true); + owner->Move(UpVector * (std::max(CGround::GetHeightReal(owner->pos.x, owner->pos.z), owner->pos.y) - owner->pos.y), true); } } else { owner->Move(UpVector * (GetGroundHeight(owner->pos) - owner->pos.y), true); @@ -2135,11 +2196,11 @@ const FPSUnitController& selfCon = myPlayer->fpsController; const FPSUnitController& unitCon = owner->fpsControlPlayer->fpsController; const bool wantReverse = (unitCon.back && !unitCon.forward); + float turnSign = 0.0f; - currWayPoint.x = owner->pos.x + owner->frontdir.x * (wantReverse)? -100.0f: 100.0f; - currWayPoint.z = owner->pos.z + owner->frontdir.z * (wantReverse)? -100.0f: 100.0f; - currWayPoint.ClampInBounds(); + currWayPoint = owner->frontdir * XZVector * mix(100.0f, -100.0f, wantReverse); + currWayPoint = (owner->pos + currWayPoint).cClampInBounds(); if (unitCon.forward || unitCon.back) { ChangeSpeed((maxSpeed * unitCon.forward) + (maxReverseSpeed * unitCon.back), wantReverse, true); @@ -2177,7 +2238,7 @@ const float3& gndNormVec = GetGroundNormal(owner->pos); const float3 gndTangVec = gndNormVec.cross(owner->rightdir); - const float3 horSpeed = float3(owner->speed.x, 0.0f, owner->speed.z); + const float3 horSpeed = owner->speed * XZVector; const float3 verSpeed = UpVector * owner->speed.y; if (owner->moveDef->speedModClass != MoveDef::Hover || !modInfo.allowHoverUnitStrafing) { @@ -2238,8 +2299,31 @@ // NOTE: // does not check for structure blockage, coldet handles that // entering of impassable terrain is *also* handled by coldet + // + // the loop below tries to evade "corner" squares that would + // block us from initiating motion and is needed for when we + // are not *currently* moving but want to get underway to our + // first waypoint (HSOC coldet won't help then) + // + // allowing movement through blocked squares when pathID != 0 + // relies on assumption that PFS will not search if start-sqr + // is blocked, so too fragile + // if (!pathController->IgnoreTerrain(*owner->moveDef, owner->pos) && !owner->moveDef->TestMoveSquare(owner, owner->pos, ZeroVector, true, false, true)) { - owner->Move(owner->pos - newSpeedVector, false); + bool updatePos = false; + + for (unsigned int n = 1; n <= SQUARE_SIZE; n++) { + if (!updatePos && (updatePos = owner->moveDef->TestMoveSquare(owner, owner->pos + owner->rightdir * n, ZeroVector, true, false, true))) { + owner->Move(owner->pos + owner->rightdir * n, false); break; + } + if (!updatePos && (updatePos = owner->moveDef->TestMoveSquare(owner, owner->pos - owner->rightdir * n, ZeroVector, true, false, true))) { + owner->Move(owner->pos - owner->rightdir * n, false); break; + } + } + + if (!updatePos) { + owner->Move(owner->pos - newSpeedVector, false); + } } // NOTE: @@ -2271,7 +2355,7 @@ if (decRate <= 0.0f) return false; if (turnRate <= 0.0f) return false; - const float3 waypointDif = float3(goalPos.x - owner->pos.x, 0.0f, goalPos.z - owner->pos.z); // use final WP for ETA + const float3 waypointDif = (goalPos - owner->pos) * XZVector; // use final WP for ETA const float waypointDist = waypointDif.Length(); // in elmos const float waypointFETA = (waypointDist / maxSpeed); // in frames (simplistic) const float waypointRETA = (waypointDist / maxReverseSpeed); // in frames (simplistic) @@ -2299,3 +2383,72 @@ return (fwdETA > revETA); } + + +bool CGroundMoveType::SetMemberValue(unsigned int memberHash, void* memberValue) { + // try the generic members first + if (AMoveType::SetMemberValue(memberHash, memberValue)) + return true; + + #define MEMBER_CHARPTR_HASH(memberName) HsiehHash(memberName, strlen(memberName), 0) + #define MEMBER_LITERAL_HASH(memberName) HsiehHash(memberName, sizeof(memberName) - 1, 0) + + #define MAXREVERSESPEED_MEMBER_IDX 5 + + static const unsigned int boolMemberHashes[] = { + MEMBER_LITERAL_HASH( "atGoal"), + MEMBER_LITERAL_HASH("atEndOfPath"), + }; + static const unsigned int floatMemberHashes[] = { + MEMBER_LITERAL_HASH( "turnRate"), + MEMBER_LITERAL_HASH( "turnAccel"), + MEMBER_LITERAL_HASH( "accRate"), + MEMBER_LITERAL_HASH( "decRate"), + MEMBER_LITERAL_HASH( "myGravity"), + MEMBER_LITERAL_HASH("maxReverseSpeed"), + }; + + #undef MEMBER_CHARPTR_HASH + #undef MEMBER_LITERAL_HASH + + + // unordered_map etc. perform dynallocs, so KISS here + bool* boolMemberPtrs[] = { + &atGoal, + &atEndOfPath, + }; + float* floatMemberPtrs[] = { + &turnRate, + &turnAccel, + + &accRate, + &decRate, + + &myGravity, + &maxReverseSpeed, + }; + + // special cases + if (memberHash == floatMemberHashes[MAXREVERSESPEED_MEMBER_IDX]) { + *(floatMemberPtrs[MAXREVERSESPEED_MEMBER_IDX]) = *(reinterpret_cast(memberValue)) / GAME_SPEED; + return true; + } + + // note: should be calculated via HsiehHash + for (unsigned int n = 0; n < sizeof(boolMemberPtrs) / sizeof(boolMemberPtrs[0]); n++) { + if (memberHash == boolMemberHashes[n]) { + *(boolMemberPtrs[n]) = *(reinterpret_cast(memberValue)); + return true; + } + } + + for (unsigned int n = 0; n < sizeof(floatMemberPtrs) / sizeof(floatMemberPtrs[0]); n++) { + if (memberHash == floatMemberHashes[n]) { + *(floatMemberPtrs[n]) = *(reinterpret_cast(memberValue)); + return true; + } + } + + return false; +} + diff -Nru spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/GroundMoveType.h spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/GroundMoveType.h --- spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/GroundMoveType.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/GroundMoveType.h 2014-10-07 20:09:51.000000000 +0000 @@ -13,7 +13,7 @@ class CGroundMoveType : public AMoveType { - CR_DECLARE(CGroundMoveType); + CR_DECLARE(CGroundMoveType) public: CGroundMoveType(CUnit* owner); @@ -24,6 +24,7 @@ bool Update(); void SlowUpdate(); + void StartMovingRaw(const float3 moveGoalPos, float moveGoalRadius); void StartMoving(float3 pos, float goalRadius); void StartMoving(float3 pos, float goalRadius, float speed) { StartMoving(pos, goalRadius); } void StopMoving(bool callScript = false, bool hardStop = false); @@ -35,8 +36,33 @@ bool CanApplyImpulse(const float3&); void LeaveTransport(); + bool SetMemberValue(unsigned int memberHash, void* memberValue); + bool OnSlope(float minSlideTolerance); bool IsReversing() const { return reversing; } + bool WantToStop() const { return (pathID == 0 && !useRawMovement); } + + + float GetTurnRate() const { return turnRate; } + float GetTurnSpeed() const { return turnSpeed; } + float GetTurnAccel() const { return turnAccel; } + + float GetAccRate() const { return accRate; } + float GetDecRate() const { return decRate; } + float GetMyGravity() const { return myGravity; } + + float GetMaxReverseSpeed() const { return maxReverseSpeed; } + float GetWantedSpeed() const { return wantedSpeed; } + float GetCurrentSpeed() const { return currentSpeed; } + float GetDeltaSpeed() const { return deltaSpeed; } + + float GetCurrWayPointDist() const { return currWayPointDist; } + float GetPrevWayPointDist() const { return prevWayPointDist; } + float GetGoalRadius() const { return goalRadius; } + unsigned int GetPathID() const { return pathID; } + + const SyncedFloat3& GetCurrWayPoint() const { return currWayPoint; } + const SyncedFloat3& GetNextWayPoint() const { return nextWayPoint; } private: float3 GetObstacleAvoidanceDir(const float3& desiredDir); @@ -51,12 +77,13 @@ float Distance2D(CSolidObject* object1, CSolidObject* object2, float marginal = 0.0f); - void GetNewPath(); + unsigned int GetNewPath(); + void GetNextWayPoint(); bool CanGetNextWayPoint(); bool ReRequestPath(bool callScript, bool forceRequest); - float BrakingDistance(float speed) const; + float BrakingDistance(float speed, float rate) const; float3 Here(); void StartEngine(bool callScript); @@ -112,8 +139,19 @@ private: IPathController* pathController; -public: - float turnRate; + SyncedFloat3 currWayPoint; + SyncedFloat3 nextWayPoint; + + float3 waypointDir; + float3 flatFrontDir; + float3 lastAvoidanceDir; + float3 mainHeadingPos; + float3 skidRotVector; /// vector orthogonal to skidDir + + float turnRate; // maximum angular speed (angular units/frame) + float turnSpeed; // current angular speed (angular units/frame) + float turnAccel; // angular acceleration (angular units/frame^2) + float accRate; float decRate; float myGravity; @@ -123,32 +161,24 @@ float currentSpeed; float deltaSpeed; - unsigned int pathId; - float goalRadius; - - SyncedFloat3 currWayPoint; - SyncedFloat3 nextWayPoint; - -private: bool atGoal; bool atEndOfPath; float currWayPointDist; float prevWayPointDist; + float goalRadius; bool reversing; bool idling; bool canReverse; - bool useMainHeading; + bool useMainHeading; /// if true, turn toward mainHeadingPos until weapons[0] can TryTarget() it + bool useRawMovement; /// if true, move towards goal without invoking PFS - float3 skidRotVector; /// vector orthogonal to skidDir float skidRotSpeed; /// rotational speed when skidding (radians / (GAME_SPEED frames)) float skidRotAccel; /// rotational acceleration when skidding (radians / (GAME_SPEED frames^2)) - float3 waypointDir; - float3 flatFrontDir; - float3 lastAvoidanceDir; - float3 mainHeadingPos; + + unsigned int pathID; unsigned int nextObstacleAvoidanceFrame; unsigned int lastPathRequestFrame; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/HoverAirMoveType.cpp spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/HoverAirMoveType.cpp --- spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/HoverAirMoveType.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/HoverAirMoveType.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -16,9 +16,9 @@ #include "Sim/Units/CommandAI/CommandAI.h" #include "System/myMath.h" #include "System/Matrix44f.h" +#include "System/Sync/HsiehHash.h" - -CR_BIND_DERIVED(CHoverAirMoveType, AAirMoveType, (NULL)); +CR_BIND_DERIVED(CHoverAirMoveType, AAirMoveType, (NULL)) CR_REG_METADATA(CHoverAirMoveType, ( CR_MEMBER(bankingAllowed), @@ -50,13 +50,13 @@ CR_MEMBER(lastMoveRate), CR_RESERVED(32) -)); +)) static bool IsUnitBusy(const CUnit* u) { // queued move-commands or an active build-command mean unit has to stay airborne - return (u->commandAI->HasMoreMoveCommands() || u->commandAI->HasBuildCommand()); + return (u->commandAI->HasMoreMoveCommands() || u->commandAI->HasCommand(CMD_LOAD_UNITS) || u->commandAI->HasCommand(-1)); } CHoverAirMoveType::CHoverAirMoveType(CUnit* owner) : @@ -343,8 +343,8 @@ UpdateAirPhysics(); const float altitude = owner->unitDef->canSubmerge? - (pos.y - ground->GetHeightReal(pos.x, pos.z)): - (pos.y - ground->GetHeightAboveWater(pos.x, pos.z)); + (pos.y - CGround::GetHeightReal(pos.x, pos.z)): + (pos.y - CGround::GetHeightAboveWater(pos.x, pos.z)); if (altitude > orgWantedHeight * 0.8f) { SetState(AIRCRAFT_FLYING); @@ -427,8 +427,8 @@ const float goalDistSq2D = goalVec.SqLength2D(); const float gHeight = UseSmoothMesh()? - std::max(smoothGround->GetHeight(pos.x, pos.z), ground->GetApproximateHeight(pos.x, pos.z)): - ground->GetHeightAboveWater(pos.x, pos.z); + std::max(smoothGround->GetHeight(pos.x, pos.z), CGround::GetApproximateHeight(pos.x, pos.z)): + CGround::GetHeightAboveWater(pos.x, pos.z); const bool closeToGoal = (flyState == FLY_ATTACKING)? (goalDistSq2D < ( 400.0f)): @@ -627,8 +627,8 @@ // We have stopped, time to land // NOTE: wantedHeight is interpreted as RELATIVE altitude - const float gh = ground->GetHeightAboveWater(pos.x, pos.z); - const float gah = ground->GetHeightReal(pos.x, pos.z); + const float gh = CGround::GetHeightAboveWater(pos.x, pos.z); + const float gah = CGround::GetHeightReal(pos.x, pos.z); float altitude = (wantedHeight = 0.0f); // can we submerge and are we still above water? @@ -740,6 +740,60 @@ } +void CHoverAirMoveType::UpdateVerticalSpeed(const float4& spd, float curRelHeight, float curVertSpeed) const +{ + float wh = wantedHeight; // wanted RELATIVE height (altitude) + float ws = 0.0f; // wanted vertical speed + + owner->SetVelocity((spd * XZVector) + (UpVector * curVertSpeed)); + + if (lastColWarningType == 2) { + const float3 dir = lastColWarning->midPos - owner->midPos; + const float3 sdir = lastColWarning->speed - spd; + + if (spd.dot(dir + sdir * 20.0f) < 0.0f) { + if (lastColWarning->midPos.y > owner->pos.y) { + wh -= 30.0f; + } else { + wh += 50.0f; + } + } + } + + if (curRelHeight < wh) { + ws = altitudeRate; + + if ((spd.y > 0.0001f) && (((wh - curRelHeight) / spd.y) * accRate * 1.5f) < spd.y) { + ws = 0.0f; + } + } else { + ws = -altitudeRate; + + if ((spd.y < -0.0001f) && (((wh - curRelHeight) / spd.y) * accRate * 0.7f) < -spd.y) { + ws = 0.0f; + } + } + + ws *= (1 - owner->beingBuilt); + // note: don't want this in case unit is built on some raised platform? + wh *= (1 - owner->beingBuilt); + + if (math::fabs(wh - curRelHeight) > 2.0f) { + if (spd.y > ws) { + owner->SetVelocity((spd * XZVector) + (UpVector * std::max(ws, spd.y - accRate * 1.5f))); + } else { + // accelerate upward faster if close to ground + owner->SetVelocity((spd * XZVector) + (UpVector * std::min(ws, spd.y + accRate * ((curRelHeight < 20.0f)? 2.0f: 0.7f)))); + } + } else { + owner->SetVelocity((spd * XZVector) + (UpVector * spd.y * 0.95f)); + } + + // finally update w-component + owner->SetSpeed(spd); +} + + void CHoverAirMoveType::UpdateAirPhysics() { const float3& pos = owner->pos; @@ -784,12 +838,8 @@ // calculated with respect to that (for changing vertical // speed, but not for ground collision) float curAbsHeight = owner->unitDef->canSubmerge? - ground->GetHeightReal(pos.x, pos.z): - ground->GetHeightAboveWater(pos.x, pos.z); - float curRelHeight = 0.0f; - - float wh = wantedHeight; // wanted RELATIVE height (altitude) - float ws = 0.0f; // wanted vertical speed + CGround::GetHeightReal(pos.x, pos.z): + CGround::GetHeightAboveWater(pos.x, pos.z); // always stay above the actual terrain (therefore either the value of // or pos.y must never become smaller than the real @@ -811,56 +861,8 @@ smoothGround->GetHeightAboveWater(pos.x, pos.z); } - // restore original vertical speed - owner->SetVelocity((spd * XZVector) + (UpVector * yspeed)); - - if (lastColWarningType == 2) { - const float3 dir = lastColWarning->midPos - owner->midPos; - const float3 sdir = lastColWarning->speed - spd; - - if (spd.dot(dir + sdir * 20.0f) < 0.0f) { - if (lastColWarning->midPos.y > owner->pos.y) { - wh -= 30.0f; - } else { - wh += 50.0f; - } - } - } - - curRelHeight = pos.y - curAbsHeight; - - { - if (curRelHeight < wh) { - ws = altitudeRate; - - if ((spd.y > 0.0001f) && (((wh - curRelHeight) / spd.y) * accRate * 1.5f) < spd.y) { - ws = 0.0f; - } - } else { - ws = -altitudeRate; - - if ((spd.y < -0.0001f) && (((wh - curRelHeight) / spd.y) * accRate * 0.7f) < -spd.y) { - ws = 0.0f; - } - } - - ws *= (1 - owner->beingBuilt); - // note: don't want this in case unit is built on some raised platform? - wh *= (1 - owner->beingBuilt); - - if (math::fabs(wh - curRelHeight) > 2.0f) { - if (spd.y > ws) { - owner->SetVelocity((spd * XZVector) + (UpVector * std::max(ws, spd.y - accRate * 1.5f))); - } else { - // accelerate upward faster if close to ground - owner->SetVelocity((spd * XZVector) + (UpVector * std::min(ws, spd.y + accRate * ((curRelHeight < 20.0f)? 2.0f: 0.7f)))); - } - } else { - owner->SetVelocity((spd * XZVector) + (UpVector * spd.y * 0.95f)); - } - } - - owner->SetSpeed(spd); + // restore original vertical speed, then compute new + UpdateVerticalSpeed(spd, pos.y - curAbsHeight, yspeed); if (modInfo.allowAircraftToLeaveMap || (pos + spd).IsInBounds()) { owner->Move(spd, true); @@ -964,7 +966,7 @@ case AIRCRAFT_CRASHING: { UpdateAirPhysics(); - if ((ground->GetHeightAboveWater(owner->pos.x, owner->pos.z) + 5.0f + owner->radius) > owner->pos.y) { + if ((CGround::GetHeightAboveWater(owner->pos.x, owner->pos.z) + 5.0f + owner->radius) > owner->pos.y) { owner->ClearPhysicalStateBit(CSolidObject::PSTATE_BIT_CRASHING); owner->KillUnit(NULL, true, false); } else { @@ -1023,7 +1025,7 @@ return false; const UnitDef* ud = owner->unitDef; - const float gah = ground->GetApproximateHeight(pos.x, pos.z); + const float gah = CGround::GetApproximateHeight(pos.x, pos.z); if ((gah < 0.0f) && !(ud->floatOnWater || ud->canSubmerge)) { return false; @@ -1153,5 +1155,92 @@ } return false; +} + + + +bool CHoverAirMoveType::SetMemberValue(unsigned int memberHash, void* memberValue) { + // try the generic members first + if (AMoveType::SetMemberValue(memberHash, memberValue)) + return true; + + #define MEMBER_CHARPTR_HASH(memberName) HsiehHash(memberName, strlen(memberName), 0) + #define MEMBER_LITERAL_HASH(memberName) HsiehHash(memberName, sizeof(memberName) - 1, 0) + + #define DONTLAND_MEMBER_IDX 1 + #define WANTEDHEIGHT_MEMBER_IDX 0 + + static const unsigned int boolMemberHashes[] = { + MEMBER_LITERAL_HASH( "collide"), + MEMBER_LITERAL_HASH( "dontLand"), + MEMBER_LITERAL_HASH( "airStrafe"), + MEMBER_LITERAL_HASH( "useSmoothMesh"), + MEMBER_LITERAL_HASH("bankingAllowed"), + }; + static const unsigned int floatMemberHashes[] = { + MEMBER_LITERAL_HASH( "wantedHeight"), + MEMBER_LITERAL_HASH( "accRate"), + MEMBER_LITERAL_HASH( "decRate"), + MEMBER_LITERAL_HASH( "turnRate"), + MEMBER_LITERAL_HASH( "altitudeRate"), + MEMBER_LITERAL_HASH( "currentBank"), + MEMBER_LITERAL_HASH( "currentPitch"), + MEMBER_LITERAL_HASH( "maxDrift"), + }; + + #undef MEMBER_CHARPTR_HASH + #undef MEMBER_LITERAL_HASH + + + // unordered_map etc. perform dynallocs, so KISS here + bool* boolMemberPtrs[] = { + &collide, + &dontLand, + &airStrafe, + + &useSmoothMesh, + &bankingAllowed + }; + float* floatMemberPtrs[] = { + &wantedHeight, + + &accRate, + &decRate, + + &turnRate, + &altitudeRate, + + ¤tBank, + ¤tPitch, + + &maxDrift + }; + + // special cases + if (memberHash == boolMemberHashes[DONTLAND_MEMBER_IDX]) { + SetAllowLanding(!(*(reinterpret_cast(memberValue)))); + return true; + } + if (memberHash == floatMemberHashes[WANTEDHEIGHT_MEMBER_IDX]) { + SetDefaultAltitude(*(reinterpret_cast(memberValue))); + return true; + } + + // note: should be calculated via HsiehHash + for (unsigned int n = 0; n < sizeof(boolMemberPtrs) / sizeof(boolMemberPtrs[0]); n++) { + if (memberHash == boolMemberHashes[n]) { + *(boolMemberPtrs[n]) = *(reinterpret_cast(memberValue)); + return true; + } + } + + for (unsigned int n = 0; n < sizeof(floatMemberPtrs) / sizeof(floatMemberPtrs[0]); n++) { + if (memberHash == floatMemberHashes[n]) { + *(floatMemberPtrs[n]) = *(reinterpret_cast(memberValue)); + return true; + } + } + + return false; } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/HoverAirMoveType.h spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/HoverAirMoveType.h --- spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/HoverAirMoveType.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/HoverAirMoveType.h 2014-10-07 20:09:51.000000000 +0000 @@ -1,37 +1,15 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ -#ifndef TA_AIR_MOVE_TYPE_H -#define TA_AIR_MOVE_TYPE_H +#ifndef HOVER_AIR_MOVE_TYPE_H +#define HOVER_AIR_MOVE_TYPE_H #include "AAirMoveType.h" +struct float4; + class CHoverAirMoveType: public AAirMoveType { - CR_DECLARE(CHoverAirMoveType); -public: - enum FlyState { - FLY_CRUISING, - FLY_CIRCLING, - FLY_ATTACKING, - FLY_LANDING - } flyState; - - bool bankingAllowed; - bool airStrafe; - /// Set to true on StopMove, to be able to not stop if a new order comes directly after - bool wantToStop; - - /// Used when circling something - float goalDistance; - - float currentBank; - float currentPitch; - - float turnRate; - - float maxDrift; - float maxTurnAngle; - + CR_DECLARE(CHoverAirMoveType) public: CHoverAirMoveType(CUnit* owner); @@ -43,6 +21,8 @@ void KeepPointingTo(float3 pos, float distance, bool aggressive); void StopMoving(bool callScript = false, bool hardStop = false); + bool SetMemberValue(unsigned int memberHash, void* memberValue); + void ForceHeading(short h); void SetGoal(const float3& pos, float distance = 0.0f); void SetState(AircraftState newState); @@ -72,6 +52,8 @@ void UpdateAirPhysics(); void UpdateMoveRate(); + void UpdateVerticalSpeed(const float4& spd, float curRelHeight, float curVertSpeed) const; + bool CanLand(bool busy) const { return (!busy && ((!dontLand && autoLand) || (reservedPad != NULL))); } bool CanLandAt(const float3& pos) const; @@ -81,6 +63,30 @@ bool HandleCollisions(bool checkCollisions); +public: + enum FlyState { + FLY_CRUISING, + FLY_CIRCLING, + FLY_ATTACKING, + FLY_LANDING + } flyState; + + bool bankingAllowed; + bool airStrafe; + /// Set to true on StopMove, to be able to not stop if a new order comes directly after + bool wantToStop; + + /// Used when circling something + float goalDistance; + + float currentBank; + float currentPitch; + + float turnRate; + + float maxDrift; + float maxTurnAngle; + private: float3 wantedSpeed; /// Used to determine banking (since it is the current acceleration) @@ -94,11 +100,6 @@ bool forceHeading; /// Set to true when transporting stuff bool dontLand; - /** - * needed to get transport close enough to what is going to be transported. - * better way ? - */ - bool loadingUnits; /// TODO: Seems odd to use heading in unit, since we have toggled useHeading to false.. short wantedHeading; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/MoveDefHandler.cpp spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/MoveDefHandler.cpp --- spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/MoveDefHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/MoveDefHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -13,8 +13,8 @@ #include "System/myMath.h" #include "System/Util.h" -CR_BIND(MoveDef, ()); -CR_BIND(MoveDefHandler, (NULL)); +CR_BIND(MoveDef, ()) +CR_BIND(MoveDefHandler, (NULL)) CR_REG_METADATA(MoveDef, ( CR_MEMBER(name), @@ -47,13 +47,13 @@ CR_MEMBER(heatMod), CR_MEMBER(flowMod), CR_MEMBER(heatProduced) -)); +)) CR_REG_METADATA(MoveDefHandler, ( CR_MEMBER(moveDefs), CR_MEMBER(moveDefNames), CR_MEMBER(checksum) -)); +)) MoveDefHandler* moveDefHandler; @@ -76,10 +76,10 @@ static MoveDef::SpeedModClass ParseSpeedModClass(const std::string& moveDefName, const LuaTable& moveDefTable) { - const MoveDef::SpeedModClass speedModClass = MoveDef::SpeedModClass(moveDefTable.GetInt("speedModClass", -1)); + const int speedModClass = moveDefTable.GetInt("speedModClass", -1); if (speedModClass != -1) - return Clamp(speedModClass, MoveDef::Tank, MoveDef::Ship); + return Clamp(MoveDef::SpeedModClass(speedModClass), MoveDef::Tank, MoveDef::Ship); // name-based fallbacks if (moveDefName.find( "boat") != string::npos) @@ -120,11 +120,11 @@ break; } - MoveDef* md = new MoveDef(moveDefTable, num); - moveDefs.push_back(md); - moveDefNames[md->name] = md->pathType; + moveDefs.emplace_back(moveDefTable, num); + const MoveDef& md = moveDefs.back(); + moveDefNames[md.name] = md.pathType; - crc << md->GetCheckSum(); + crc << md.GetCheckSum(); } CMoveMath::noHoverWaterMove = (mapInfo->water.damage >= MAX_ALLOWED_WATER_DAMAGE_HMM); @@ -138,22 +138,13 @@ } -MoveDefHandler::~MoveDefHandler() -{ - while (!moveDefs.empty()) { - delete moveDefs.back(); - moveDefs.pop_back(); - } -} - - -MoveDef* MoveDefHandler::GetMoveDefByName(const std::string& name) const +MoveDef* MoveDefHandler::GetMoveDefByName(const std::string& name) { map::const_iterator it = moveDefNames.find(name); if (it == moveDefNames.end()) { return NULL; } - return moveDefs[it->second]; + return &moveDefs[it->second]; } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/MoveDefHandler.h spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/MoveDefHandler.h --- spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/MoveDefHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/MoveDefHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -16,7 +16,7 @@ #pragma pack(push, 1) struct MoveDef { - CR_DECLARE_STRUCT(MoveDef); + CR_DECLARE_STRUCT(MoveDef) MoveDef(); MoveDef(const LuaTable& moveDefTable, int moveDefID); @@ -136,19 +136,18 @@ class LuaParser; class MoveDefHandler { - CR_DECLARE_STRUCT(MoveDefHandler); + CR_DECLARE_STRUCT(MoveDefHandler) public: MoveDefHandler(LuaParser* defsParser); - ~MoveDefHandler(); - MoveDef* GetMoveDefByPathType(unsigned int pathType) { return moveDefs[pathType]; } - MoveDef* GetMoveDefByName(const std::string& name) const; + MoveDef* GetMoveDefByPathType(unsigned int pathType) { return &moveDefs[pathType]; } + MoveDef* GetMoveDefByName(const std::string& name); unsigned int GetNumMoveDefs() const { return moveDefs.size(); } unsigned int GetCheckSum() const { return checksum; } private: - std::vector moveDefs; + std::vector moveDefs; std::map moveDefNames; unsigned int checksum; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/MoveMath/MoveMath.cpp spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/MoveMath/MoveMath.cpp --- spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/MoveMath/MoveMath.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/MoveMath/MoveMath.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -19,8 +19,8 @@ { switch (moveDef.speedModClass) { case MoveDef::Tank: // fall-through - case MoveDef::KBot: { return (readMap->GetCenterHeightMapSynced()[xSqr + zSqr * gs->mapx]); } break; // NOTE: why not just GetHeightReal too? - case MoveDef::Hover: { return (ground->GetHeightAboveWater(xSqr * SQUARE_SIZE, zSqr * SQUARE_SIZE) + 10.0f); } break; + case MoveDef::KBot: { return (CGround::GetHeightReal (xSqr * SQUARE_SIZE, zSqr * SQUARE_SIZE) + 10.0f); } break; + case MoveDef::Hover: { return (CGround::GetHeightAboveWater(xSqr * SQUARE_SIZE, zSqr * SQUARE_SIZE) + 10.0f); } break; case MoveDef::Ship: { return ( 0.0f); } break; } @@ -31,8 +31,8 @@ { switch (moveDef.speedModClass) { case MoveDef::Tank: // fall-through - case MoveDef::KBot: { return (ground->GetHeightReal (pos.x, pos.z) + 10.0f); } break; - case MoveDef::Hover: { return (ground->GetHeightAboveWater(pos.x, pos.z) + 10.0f); } break; + case MoveDef::KBot: { return (CGround::GetHeightReal (pos.x, pos.z) + 10.0f); } break; + case MoveDef::Hover: { return (CGround::GetHeightAboveWater(pos.x, pos.z) + 10.0f); } break; case MoveDef::Ship: { return ( 0.0f); } break; } @@ -188,11 +188,6 @@ // remaining conditions under which obstacle does NOT block unit // only reachable from stand-alone PE invocations or GameHelper // 1. - // unit is ground-following and obstacle is NOT on the - // ground even if by just a millimeter (less arbitrary - // than eg. "obstacle's center-position minus its model - // height > magic value" although causes more clipping) - // 2. // unit is a submarine, obstacle sticks out above-water // (and not itself flagged as a submarine) *OR* unit is // not a submarine and obstacle is (fully under-water or @@ -205,32 +200,22 @@ // will cause stacking for submarines that are *not* // explicitly flagged as such in their MoveDefs // - // note that these conditions can lead to a certain degree of + // note that these condition(s) can lead to a certain degree of // clipping: for full 3D accuracy the height of the MoveDef's // owner would need to be accessible (but the path-estimator // defs aren't tied to any collider instances) --> add extra // "clearance" parameter to MoveDef? // - if (colliderMD.followGround) { - // would be the correct way, but collider is NULL here - // ret |= (collidee->pos.y > (collider->pos.y + collider->height)); - // ret |= ((collidee->pos.y + collidee->height) < collider->pos.y)); - // - // ret = ((collidee->midPos.y - math::fabs(collidee->height)) > ground->GetHeightReal(collidee->pos.x, collidee->pos.z)); + #define IS_SUBMARINE(md) ((md) != NULL && (md)->subMarine) - return (!collidee->IsOnGround()); + if (IS_SUBMARINE(&colliderMD)) { + return (!collidee->IsUnderWater() && !IS_SUBMARINE(collidee->moveDef)); } else { - #define IS_SUBMARINE(md) ((md) != NULL && (md)->subMarine) - - if (IS_SUBMARINE(&colliderMD)) { - return (!collidee->IsUnderWater() && !IS_SUBMARINE(collidee->moveDef)); - } else { - return ( collidee->IsUnderWater() || IS_SUBMARINE(collidee->moveDef)); - } - - #undef IS_SUBMARINE + return ( collidee->IsUnderWater() || IS_SUBMARINE(collidee->moveDef)); } + #undef IS_SUBMARINE + return false; } @@ -255,12 +240,12 @@ CMoveMath::BlockType CMoveMath::SquareIsBlocked(const MoveDef& moveDef, int xSquare, int zSquare, const CSolidObject* collider) { - if (xSquare < 0 || zSquare < 0 || xSquare >= gs->mapx || zSquare >= gs->mapy) + if ((unsigned)xSquare >= gs->mapx || (unsigned)zSquare >= gs->mapy) return BLOCK_IMPASSABLE; BlockType r = BLOCK_NONE; - const BlockingMapCell& c = groundBlockingObjectMap->GetCell(xSquare + zSquare * gs->mapx); + const BlockingMapCell& c = groundBlockingObjectMap->GetCell(zSquare * gs->mapx + xSquare); for (BlockingMapCellIt it = c.begin(); it != c.end(); ++it) { const CSolidObject* collidee = it->second; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/MoveMath/MoveMath.h spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/MoveMath/MoveMath.h --- spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/MoveMath/MoveMath.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/MoveMath/MoveMath.h 2014-10-07 20:09:51.000000000 +0000 @@ -10,7 +10,7 @@ struct MoveDef; class CSolidObject; class CMoveMath { - CR_DECLARE(CMoveMath); + CR_DECLARE(CMoveMath) protected: static float GroundSpeedMod(const MoveDef& moveDef, float height, float slope); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/MoveType.cpp spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/MoveType.cpp --- spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/MoveType.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/MoveType.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -11,8 +11,9 @@ #include "Sim/Units/Unit.h" #include "Sim/Units/UnitDef.h" #include "System/myMath.h" +#include "System/Sync/HsiehHash.h" -CR_BIND_DERIVED_INTERFACE(AMoveType, CObject); +CR_BIND_DERIVED_INTERFACE(AMoveType, CObject) CR_REG_METADATA(AMoveType, ( CR_MEMBER(owner), CR_MEMBER(goalPos), @@ -23,10 +24,11 @@ CR_MEMBER(maxSpeedDef), CR_MEMBER(maxWantedSpeed), CR_MEMBER(repairBelowHealth), + CR_MEMBER(maneuverLeash), CR_MEMBER(useHeading), CR_ENUM_MEMBER(progressState) -)); +)) AMoveType::AMoveType(CUnit* owner): owner(owner), @@ -43,7 +45,8 @@ maxSpeedDef(owner? owner->unitDef->speed / GAME_SPEED : 0.0f), maxWantedSpeed(owner? owner->unitDef->speed / GAME_SPEED : 0.0f), - repairBelowHealth(0.3f) + repairBelowHealth(0.3f), + maneuverLeash(500.0f) { } @@ -54,7 +57,7 @@ if (owner->pos != oldSlowUpdatePos) { oldSlowUpdatePos = owner->pos; - const int newMapSquare = ground->GetSquare(owner->pos); + const int newMapSquare = CGround::GetSquare(owner->pos); const float losHeight = owner->losHeight; const float radarHeight = owner->radarHeight; @@ -65,7 +68,7 @@ // if owner is an aircraft, temporarily add current altitude to emit-heights // otherwise leave them as-is unless owner floats on water and is over water if (!owner->UsingScriptMoveType()) { - const float agh = ground->GetApproximateHeight(owner->pos.x, owner->pos.z); + const float agh = CGround::GetApproximateHeight(owner->pos.x, owner->pos.z); const float alt = owner->pos.y - agh; if (owner->IsInAir() && owner->unitDef->canfly) { @@ -103,8 +106,65 @@ KeepPointingTo(float3(unit->pos), distance, aggressive); } +float AMoveType::CalcStaticTurnRadius() const { + // calculate a rough turn radius (not based on current speed) + const float turnFrames = SPRING_CIRCLE_DIVS / std::max(owner->unitDef->turnRate, 1.0f); + const float turnRadius = (maxSpeedDef * turnFrames) / (PI + PI); + + return turnRadius; +} + bool AMoveType::WantsRepair() const { return (owner->health < (repairBelowHealth * owner->maxHealth)); } bool AMoveType::WantsRefuel() const { return (owner->currentFuel < (repairBelowHealth * owner->unitDef->maxFuel)); } +bool AMoveType::SetMemberValue(unsigned int memberHash, void* memberValue) { + #define MEMBER_CHARPTR_HASH(memberName) HsiehHash(memberName, strlen(memberName), 0) + #define MEMBER_LITERAL_HASH(memberName) HsiehHash(memberName, sizeof(memberName) - 1, 0) + + #define MAXSPEED_MEMBER_IDX 0 + #define MAXWANTEDSPEED_MEMBER_IDX 1 + #define REPAIRBELOWHEALTH_MEMBER_IDX 2 + #define MANEUVERLEASH_MEMBER_IDX 3 + + static const unsigned int floatMemberHashes[] = { + MEMBER_LITERAL_HASH( "maxSpeed"), + MEMBER_LITERAL_HASH( "maxWantedSpeed"), + MEMBER_LITERAL_HASH("repairBelowHealth"), + MEMBER_LITERAL_HASH( "maneuverLeash"), + }; + + #undef MEMBER_CHARPTR_HASH + #undef MEMBER_LITERAL_HASH + + /* + // unordered_map etc. perform dynallocs, so KISS here + float* floatMemberPtrs[] = { + &maxSpeed, + &maxWantedSpeed, + &repairBelowHealth, + }; + */ + + // special cases + if (memberHash == floatMemberHashes[MAXSPEED_MEMBER_IDX]) { + SetMaxSpeed((*reinterpret_cast(memberValue)) / GAME_SPEED); + return true; + } + if (memberHash == floatMemberHashes[MAXWANTEDSPEED_MEMBER_IDX]) { + SetWantedMaxSpeed((*reinterpret_cast(memberValue)) / GAME_SPEED); + return true; + } + if (memberHash == floatMemberHashes[REPAIRBELOWHEALTH_MEMBER_IDX]) { + SetRepairBelowHealth(*reinterpret_cast(memberValue)); + return true; + } + if (memberHash == floatMemberHashes[MANEUVERLEASH_MEMBER_IDX]) { + SetManeuverLeash(*reinterpret_cast(memberValue)); + return true; + } + + return false; +} + diff -Nru spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/MoveTypeFactory.cpp spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/MoveTypeFactory.cpp --- spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/MoveTypeFactory.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/MoveTypeFactory.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -33,7 +33,7 @@ assert(ud->pathType == -1U); assert(unit->moveDef == NULL); - if (!ud->builder && !ud->IsTransportUnit() && ud->IsStrafingAirUnit()) { + if (ud->IsStrafingAirUnit()) { return (new CStrafeAirMoveType(unit)); } else { // flying builders, transports, gunships diff -Nru spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/MoveType.h spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/MoveType.h --- spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/MoveType.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/MoveType.h 2014-10-07 20:09:51.000000000 +0000 @@ -12,12 +12,13 @@ class AMoveType : public CObject { - CR_DECLARE(AMoveType); + CR_DECLARE(AMoveType) public: AMoveType(CUnit* owner); virtual ~AMoveType() {} + virtual void StartMovingRaw(const float3 moveGoalPos, float moveGoalRadius) {} virtual void StartMoving(float3 pos, float goalRadius) = 0; virtual void StartMoving(float3 pos, float goalRadius, float speed) = 0; virtual void KeepPointingTo(float3 pos, float distance, bool aggressive) = 0; @@ -26,6 +27,9 @@ virtual bool CanApplyImpulse(const float3&) { return false; } virtual void LeaveTransport() {} + // generic setter for Lua-writable values + virtual bool SetMemberValue(unsigned int memberHash, void* memberValue); + virtual void SetGoal(const float3& pos, float distance = 0.0f) { goalPos = pos; } // NOTE: @@ -38,6 +42,7 @@ // MoveType classes expects maxSpeed to be != 0 virtual void SetMaxSpeed(float speed) { maxSpeed = std::max(0.001f, speed); } virtual void SetWantedMaxSpeed(float speed) { maxWantedSpeed = speed; } + virtual void SetManeuverLeash(float leashLength) { maneuverLeash = leashLength; } virtual bool Update() = 0; virtual void SlowUpdate(); @@ -59,6 +64,9 @@ float GetMaxSpeedDef() const { return maxSpeedDef; } float GetMaxWantedSpeed() const { return maxWantedSpeed; } float GetRepairBelowHealth() const { return repairBelowHealth; } + float GetManeuverLeash() const { return maneuverLeash; } + + float CalcStaticTurnRadius() const; public: CUnit* owner; @@ -83,6 +91,7 @@ float maxWantedSpeed; // maximum speed (temporarily) set by a CMD_SET_WANTED_MAX_SPEED modifier command float repairBelowHealth; + float maneuverLeash; // maximum distance away a target can be and still be chased }; #endif // MOVETYPE_H diff -Nru spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/ScriptMoveType.cpp spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/ScriptMoveType.cpp --- spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/ScriptMoveType.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/ScriptMoveType.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -3,16 +3,16 @@ #include "ScriptMoveType.h" -#include "Lua/LuaRules.h" #include "Map/Ground.h" #include "Map/MapInfo.h" #include "Sim/Misc/Wind.h" #include "Sim/Units/UnitDef.h" #include "Sim/Units/UnitTypes/Building.h" +#include "System/EventHandler.h" #include "System/Matrix44f.h" #include "System/myMath.h" -CR_BIND_DERIVED(CScriptMoveType, AMoveType, (NULL)); +CR_BIND_DERIVED(CScriptMoveType, AMoveType, (NULL)) CR_REG_METADATA(CScriptMoveType, ( CR_MEMBER(tag), CR_MEMBER(extrapolate), @@ -38,7 +38,7 @@ CR_MEMBER(collideStop), CR_MEMBER(scriptNotify), CR_RESERVED(64) -)); +)) CScriptMoveType::CScriptMoveType(CUnit* owner): @@ -98,7 +98,7 @@ void CScriptMoveType::CheckNotify() { if (scriptNotify) { - if (luaRules && luaRules->MoveCtrlNotify(owner, scriptNotify)) { + if (eventHandler.MoveCtrlNotify(owner, scriptNotify)) { // NOTE: deletes \ owner->DisableScriptMoveType(); } else { @@ -138,7 +138,7 @@ } if (trackGround) { - const float gndMin = ground->GetHeightReal(owner->pos.x, owner->pos.z) + groundOffset; + const float gndMin = CGround::GetHeightReal(owner->pos.x, owner->pos.z) + groundOffset; if (owner->pos.y <= gndMin) { owner->Move(UpVector * (gndMin - owner->pos.y), true); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/ScriptMoveType.h spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/ScriptMoveType.h --- spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/ScriptMoveType.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/ScriptMoveType.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CScriptMoveType : public AMoveType { - CR_DECLARE(CScriptMoveType); + CR_DECLARE(CScriptMoveType) public: CScriptMoveType(CUnit* owner); @@ -25,7 +25,7 @@ void SetRotationVelocity(const float3& rvel); void SetHeading(short heading); void SetNoBlocking(bool state); - + public: // null'ed virtuals void StartMoving(float3, float goalRadius) {} void StartMoving(float3, float goalRadius, float speed) {} @@ -45,7 +45,7 @@ public: int tag; - + bool extrapolate; bool useRelVel; bool useRotVel; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/StaticMoveType.cpp spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/StaticMoveType.cpp --- spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/StaticMoveType.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/StaticMoveType.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -6,10 +6,10 @@ #include "Sim/Units/Unit.h" #include "Sim/Units/UnitDef.h" -CR_BIND_DERIVED(CStaticMoveType, AMoveType, (NULL)); +CR_BIND_DERIVED(CStaticMoveType, AMoveType, (NULL)) CR_REG_METADATA(CStaticMoveType, ( CR_RESERVED(63) -)); +)) void CStaticMoveType::SlowUpdate() { @@ -26,6 +26,6 @@ if (ud->floatOnWater && owner->IsInWater()) { owner->Move(UpVector * (-ud->waterline - owner->pos.y), true); } else { - owner->Move(UpVector * (ground->GetHeightReal(owner->pos.x, owner->pos.z) - owner->pos.y), true); + owner->Move(UpVector * (CGround::GetHeightReal(owner->pos.x, owner->pos.z) - owner->pos.y), true); } } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/StaticMoveType.h spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/StaticMoveType.h --- spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/StaticMoveType.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/StaticMoveType.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CStaticMoveType : public AMoveType { - CR_DECLARE(CStaticMoveType); + CR_DECLARE(CStaticMoveType) public: CStaticMoveType(CUnit* unit) : AMoveType(unit) {} diff -Nru spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/StrafeAirMoveType.cpp spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/StrafeAirMoveType.cpp --- spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/StrafeAirMoveType.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/StrafeAirMoveType.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -18,11 +18,12 @@ #include "Sim/Units/CommandAI/CommandAI.h" #include "Sim/Weapons/Weapon.h" #include "System/myMath.h" +#include "System/Sync/HsiehHash.h" -CR_BIND_DERIVED(CStrafeAirMoveType, AAirMoveType, (NULL)); +CR_BIND_DERIVED(CStrafeAirMoveType, AAirMoveType, (NULL)) CR_REG_METADATA(CStrafeAirMoveType, ( - CR_MEMBER(maneuver), + CR_MEMBER(maneuverState), CR_MEMBER(maneuverSubState), CR_MEMBER(loopbackAttack), @@ -52,13 +53,14 @@ CR_MEMBER(lastElevatorPos), CR_MEMBER(lastAileronPos), - CR_MEMBER(inefficientAttackTime), - CR_MEMBER(exitVector), - CR_RESERVED(63) -)); +)) + +static float TurnRadius(const float rawRadius, const float rawSpeed) { + return (std::min(1000.0f, rawRadius * rawSpeed)); +} static float GetAileronDeflection( const CUnit* owner, @@ -231,7 +233,7 @@ bool attacking ) { float elevator = 0.0f; - float upside = Sign(updir.y >= -0.3f); + float upside = (updir.y >= -0.3f) * 2.0f - 1.0f; if (attacking) { if (spd.w < 1.5f) { @@ -241,7 +243,7 @@ elevator = -upside; } } else { - const float gHeightR = ground->GetHeightAboveWater(pos.x + spd.x * 40.0f, pos.z + spd.z * 40.0f); + const float gHeightR = CGround::GetHeightAboveWater(pos.x + spd.x * 40.0f, pos.z + spd.z * 40.0f); const float hdif = std::max(gHeightR, groundHeight) + 60 - pos.y - frontdir.y * spd.w * 20.0f; const float maxElevatorSpeedf = maxElevator * spd.w; @@ -271,7 +273,7 @@ } } - if (elevator * upside < minPitch) { + if ((elevator * upside) < minPitch) { elevator = minPitch * upside; } } @@ -291,7 +293,7 @@ if (notColliding) { const float maxElevatorSpeedf = maxElevator * 20.0f * spd.w * spd.w; - const float gHeightAW = ground->GetHeightAboveWater(pos.x + spd.x * 40.0f, pos.z + spd.z * 40.0f); + const float gHeightAW = CGround::GetHeightAboveWater(pos.x + spd.x * 40.0f, pos.z + spd.z * 40.0f); const float hdif = std::max(groundHeight, gHeightAW) + wantedHeight - pos.y - frontdir.y * spd.w * 20.0f; if (hdif < -maxElevatorSpeedf && frontdir.y > -maxPitch) { @@ -316,11 +318,35 @@ return elevator; } +static int SelectLoopBackManeuver( + const SyncedFloat3& frontdir, + const SyncedFloat3& rightdir, + const float4& spd, + float turnRadius, + float groundDist +) { + // do not start looping if already banked + if (math::fabs(rightdir.y) > 0.05f) + return CStrafeAirMoveType::MANEUVER_FLY_STRAIGHT; + + if (groundDist > TurnRadius(turnRadius, spd.w)) { + if (math::fabs(frontdir.y) <= 0.2f && gs->randFloat() > 0.3f) { + return CStrafeAirMoveType::MANEUVER_IMMELMAN_INV; + } + } else { + if (frontdir.y > -0.2f && gs->randFloat() > 0.7f) { + return CStrafeAirMoveType::MANEUVER_IMMELMAN; + } + } + + return CStrafeAirMoveType::MANEUVER_FLY_STRAIGHT; +} + CStrafeAirMoveType::CStrafeAirMoveType(CUnit* owner): AAirMoveType(owner), - maneuver(0), + maneuverState(MANEUVER_FLY_STRAIGHT), maneuverSubState(0), loopbackAttack(false), isFighter(false), @@ -336,8 +362,7 @@ turnRadius(150), maxAileron(0.04f), maxElevator(0.02f), - maxRudder(0.01f), - inefficientAttackTime(0) + maxRudder(0.01f) { assert(owner != NULL); assert(owner->unitDef != NULL); @@ -346,6 +371,7 @@ owner->mapSquare += 1; isFighter = owner->unitDef->IsFighterAirUnit(); + loopbackAttack = owner->unitDef->canLoopbackAttack && isFighter; collide = owner->unitDef->collide; wingAngle = owner->unitDef->wingAngle; @@ -388,10 +414,6 @@ lastRudderPos = 0.0f; lastElevatorPos = 0.0f; lastAileronPos = 0.0f; - - exitVector = gs->randVector(); - exitVector.y = math::fabs(exitVector.y); - exitVector.y += 1.0f; } @@ -407,7 +429,7 @@ // otherwise we might fall through the map when stunned // (the kill-on-impact code is not reached in that case) if ((owner->IsStunned() && !owner->IsCrashing()) || owner->beingBuilt) { - UpdateAirPhysics(0.0f * lastRudderPos, lastAileronPos, lastElevatorPos, 0, ZeroVector); + UpdateAirPhysics(0.0f * lastRudderPos, lastAileronPos, lastElevatorPos, 0.0f, ZeroVector); return (HandleCollisions(collide && !owner->beingBuilt && (padStatus == PAD_STATUS_FLYING) && (aircraftState != AIRCRAFT_TAKEOFF))); } @@ -420,24 +442,22 @@ if (aircraftState != AIRCRAFT_CRASHING) { if (owner->UnderFirstPersonControl()) { SetState(AIRCRAFT_FLYING); - inefficientAttackTime = 0; const FPSUnitController& con = owner->fpsControlPlayer->fpsController; - if (con.forward || con.back || con.left || con.right) { - float aileron = 0.0f; - float elevator = 0.0f; - - if (con.forward) { elevator -= 1; } - if (con.back ) { elevator += 1; } - if (con.right ) { aileron += 1; } - if (con.left ) { aileron -= 1; } + float aileron = 0.0f; + float elevator = 0.0f; - UpdateAirPhysics(0, aileron, elevator, 1, owner->frontdir); - maneuver = 0; + if (con.forward) elevator -= 1.0f; + if (con.back ) elevator += 1.0f; + if (con.right ) aileron += 1.0f; + if (con.left ) aileron -= 1.0f; + + UpdateAirPhysics(0.0f, aileron, elevator, 1.0f, owner->frontdir); + maneuverState = MANEUVER_FLY_STRAIGHT; + + return (HandleCollisions(collide && !owner->beingBuilt && (padStatus == PAD_STATUS_FLYING) && (aircraftState != AIRCRAFT_TAKEOFF))); - return (HandleCollisions(collide && !owner->beingBuilt && (padStatus == PAD_STATUS_FLYING) && (aircraftState != AIRCRAFT_TAKEOFF))); - } } if (reservedPad != NULL) { @@ -463,6 +483,7 @@ owner->restTime = 0; const CCommandQueue& cmdQue = owner->commandAI->commandQue; + const bool isAttacking = (!cmdQue.empty() && (cmdQue.front()).GetID() == CMD_ATTACK); const bool keepAttacking = ((owner->attackTarget != NULL && !owner->attackTarget->isDead) || owner->userAttackGround); @@ -476,43 +497,49 @@ */ { if (isAttacking && allowAttack && keepAttacking) { - inefficientAttackTime = std::min(inefficientAttackTime, float(gs->frameNum) - owner->lastFireWeapon); - if (owner->attackTarget != NULL) { SetGoal(owner->attackTarget->pos); } else { SetGoal(owner->attackPos); } - if (maneuver) { + const bool goalInFront = ((goalPos - lastPos).dot(owner->frontdir) > 0.0f); + const bool goalInRange = (goalPos.SqDistance(lastPos) < Square(owner->maxRange * 4.0f)); + + // NOTE: UpdateAttack changes goalPos + if (maneuverState != MANEUVER_FLY_STRAIGHT) { UpdateManeuver(); - inefficientAttackTime = 0; - } else if (isFighter && goalPos.SqDistance(lastPos) < Square(owner->maxRange * 4)) { - inefficientAttackTime++; - UpdateFighterAttack(); - } else { - inefficientAttackTime = 0; + } else if (goalInFront && goalInRange) { UpdateAttack(); + } else { + if (UpdateFlying(wantedHeight, 1.0f) && !goalInFront && loopbackAttack) { + // once yaw and roll are unblocked, semi-randomly decide to turn or loop + const SyncedFloat3& rightdir = owner->rightdir; + const SyncedFloat3& frontdir = owner->frontdir; + + const float altitude = CGround::GetHeightAboveWater(owner->pos.x, owner->pos.z) - lastPos.y; + + if ((maneuverState = SelectLoopBackManeuver(frontdir, rightdir, lastSpd, turnRadius, altitude)) == MANEUVER_IMMELMAN_INV) { + maneuverSubState = 0; + } + } } } else { - inefficientAttackTime = 0; - UpdateFlying(wantedHeight, 1); + UpdateFlying(wantedHeight, 1.0f); } } } break; case AIRCRAFT_LANDED: - inefficientAttackTime = 0; UpdateLanded(); break; case AIRCRAFT_LANDING: - inefficientAttackTime = 0; UpdateLanding(); break; case AIRCRAFT_CRASHING: { // NOTE: the crashing-state can only be set (and unset) by scripts - UpdateAirPhysics(crashRudder, crashAileron, crashElevator, 0, owner->frontdir); + UpdateAirPhysics(crashRudder, crashAileron, crashElevator, 0.0f, owner->frontdir); - if ((ground->GetHeightAboveWater(owner->pos.x, owner->pos.z) + 5.0f + owner->radius) > owner->pos.y) { + if ((CGround::GetHeightAboveWater(owner->pos.x, owner->pos.z) + 5.0f + owner->radius) > owner->pos.y) { owner->ClearPhysicalStateBit(CSolidObject::PSTATE_BIT_CRASHING); owner->KillUnit(NULL, true, false); } @@ -649,73 +676,74 @@ { const float speedf = owner->speed.w; - switch (maneuver) { - case 1: { - // Immelman - int aileron = 0; - int elevator = 0; + switch (maneuverState) { + case MANEUVER_IMMELMAN: { + float aileron = 0.0f; + float elevator = 0.0f; if (owner->updir.y > 0.0f) { if (owner->rightdir.y > maxAileron * speedf) { - aileron = 1; + aileron = 1.0f; } else if (owner->rightdir.y < -maxAileron * speedf) { - aileron = -1; + aileron = -1.0f; } } - if (math::fabs(owner->rightdir.y) < maxAileron * 3.0f * speedf || owner->updir.y < 0.0f) { - elevator = 1; - } - UpdateAirPhysics(0, aileron, elevator, 1, owner->frontdir); + if (math::fabs(owner->rightdir.y) < maxAileron * 3.0f * speedf || owner->updir.y < 0.0f) + elevator = 1.0f; + + UpdateAirPhysics(0.0f, aileron, elevator, 1.0f, owner->frontdir); if ((owner->updir.y < 0.0f && owner->frontdir.y < 0.0f) || speedf < 0.8f) { - maneuver = 0; + maneuverState = MANEUVER_FLY_STRAIGHT; } // [?] some seem to report that the "unlimited altitude" thing is because of these maneuvers - if (owner->pos.y - ground->GetApproximateHeight(owner->pos.x, owner->pos.z) > wantedHeight * 4.0f) { - maneuver = 0; + if ((owner->pos.y - CGround::GetApproximateHeight(owner->pos.x, owner->pos.z)) > (wantedHeight * 4.0f)) { + maneuverState = MANEUVER_FLY_STRAIGHT; } - break; - } + } break; - case 2: { + case MANEUVER_IMMELMAN_INV: { // inverted Immelman - int aileron = 0; - int elevator = 0; + float aileron = 0.0f; + float elevator = 0.0f; if (maneuverSubState == 0) { if (owner->rightdir.y >= 0.0f) { - aileron = -1; + aileron = -1.0f; } else { - aileron = 1; + aileron = 1.0f; } } - if (owner->frontdir.y < -0.7f) { + if (owner->frontdir.y < -0.7f) maneuverSubState = 1; - } - if (maneuverSubState == 1 || owner->updir.y < 0.0f) { - elevator = 1; - } + if (maneuverSubState == 1 || owner->updir.y < 0.0f) + elevator = 1.0f; - UpdateAirPhysics(0, aileron, elevator, 1, owner->frontdir); + UpdateAirPhysics(0.0f, aileron, elevator, 1.0f, owner->frontdir); - if ((owner->updir.y > 0.0f && owner->frontdir.y > 0.0f && maneuverSubState == 1) || speedf < 0.2f) - maneuver = 0; - break; - } + if ((owner->updir.y > 0.0f && owner->frontdir.y > 0.0f && maneuverSubState == 1) || speedf < 0.2f) { + maneuverState = MANEUVER_FLY_STRAIGHT; + } + } break; - default: - UpdateAirPhysics(0, 0, 0, 1, owner->frontdir); - maneuver = 0; - break; + default: { + UpdateAirPhysics(0.0f, 0.0f, 0.0f, 1.0f, owner->frontdir); + maneuverState = MANEUVER_FLY_STRAIGHT; + } break; } } -void CStrafeAirMoveType::UpdateFighterAttack() +void CStrafeAirMoveType::UpdateAttack() { + if (!isFighter) { + UpdateFlying(wantedHeight, 1.0f); + return; + } + const float3& pos = owner->pos; const float4& spd = owner->speed; @@ -732,30 +760,13 @@ CheckForCollision(); } - const CUnit* attackee = owner->attackTarget; - - const bool groundTarget = (attackee == NULL) || attackee->unitDef->IsGroundUnit(); - const bool airTarget = (attackee != NULL) && attackee->unitDef->IsStrafingAirUnit(); // only count "real" aircraft (not gunships) - const bool hasFired = (!owner->weapons.empty() && owner->weapons[0]->reloadStatus > gs->frameNum && owner->weapons[0]->salvoLeft == 0); - - if (groundTarget) { - if (frontdir.dot(goalPos - pos) < 0 && (pos - goalPos).SqLength() < (turnRadius * turnRadius * (loopbackAttack ? 4.0f : 1.0f))) { - SetGoal(goalPos + (pos - goalPos).Normalize2D() * turnRadius * 4.0f); - } else if (loopbackAttack && !airTarget) { - if (frontdir.dot(goalPos - pos) < owner->maxRange * (hasFired ? 1.0f : 0.7f)) - maneuver = 1; - } else if (frontdir.dot(goalPos - pos) < owner->maxRange * 0.7f) { - SetGoal(goalPos + exitVector * ((attackee != NULL) ? attackee->radius + owner->radius + 10.0f : owner->radius + 40.0f)); - } - } - float3 rightDir2D = rightdir; const float3 difGoalPos = (goalPos - oldGoalPos) * SQUARE_SIZE; oldGoalPos = goalPos; goalPos += difGoalPos; - const float gHeightAW = ground->GetHeightAboveWater(pos.x, pos.z); + const float gHeightAW = CGround::GetHeightAboveWater(pos.x, pos.z); const float goalDist = pos.distance(goalPos); const float3 goalDir = (goalDist > 0.0f)? (goalPos - pos) / goalDist: @@ -770,30 +781,21 @@ goalDotRight /= goalDotFront; } - if (goalDir.dot(frontdir) < -0.2f + inefficientAttackTime * 0.002f && frontdir.y > -0.2f && spd.w > 2.0f && gs->randFloat() > 0.996f) - maneuver = 1; - - if (goalDir.dot(frontdir) < -0.2f + inefficientAttackTime * 0.002f && math::fabs(frontdir.y) < 0.2f && gs->randFloat() > 0.996f && gHeightAW + 400 < pos.y) { - maneuver = 2; - maneuverSubState = 0; - } + { + const CUnit* attackee = owner->attackTarget; - const float aileron = GetAileronDeflection (owner, lastColWarning, pos, spd, rightdir, updir, frontdir, goalDir, gHeightAW, wantedHeight, maxAileron, maxBank, goalDotRight, aGoalDotFront, lastColWarningType == 2, true); // roll - const float rudder = GetRudderDeflection (owner, lastColWarning, pos, spd, rightdir, updir, frontdir, goalDir, gHeightAW, wantedHeight, maxRudder, 0.0f, goalDotRight, aGoalDotFront, lastColWarningType == 2, true); // yaw - const float elevator = GetElevatorDeflection(owner, lastColWarning, pos, spd, rightdir, updir, frontdir, goalDir, gHeightAW, wantedHeight, maxElevator, maxPitch, goalDotRight, aGoalDotFront, lastColWarningType == 2, true); // pitch - const float engine = (groundTarget)? 1.0f: std::min(1.0f, (goalDist / owner->maxRange + 1.0f - goalDir.dot(frontdir) * 0.7f)); + const float aileron = GetAileronDeflection (owner, lastColWarning, pos, spd, rightdir, updir, frontdir, goalDir, gHeightAW, wantedHeight, maxAileron, maxBank, goalDotRight, aGoalDotFront, lastColWarningType == 2, true); // roll + const float rudder = GetRudderDeflection (owner, lastColWarning, pos, spd, rightdir, updir, frontdir, goalDir, gHeightAW, wantedHeight, maxRudder, 0.0f, goalDotRight, aGoalDotFront, lastColWarningType == 2, true); // yaw + const float elevator = GetElevatorDeflection(owner, lastColWarning, pos, spd, rightdir, updir, frontdir, goalDir, gHeightAW, wantedHeight, maxElevator, maxPitch, goalDotRight, aGoalDotFront, lastColWarningType == 2, true); // pitch + const float engine = ((attackee == NULL) || attackee->unitDef->IsGroundUnit())? 1.0f: std::min(1.0f, (goalDist / owner->maxRange + 1.0f - goalDir.dot(frontdir) * 0.7f)); - UpdateAirPhysics(rudder, aileron, elevator, engine, owner->frontdir); + UpdateAirPhysics(rudder, aileron, elevator, engine, owner->frontdir); + } } -void CStrafeAirMoveType::UpdateAttack() -{ - UpdateFlying(wantedHeight, 1.0f); -} - -void CStrafeAirMoveType::UpdateFlying(float wantedHeight, float engine) +bool CStrafeAirMoveType::UpdateFlying(float wantedHeight, float engine) { const float3& pos = owner->pos; const float4& spd = owner->speed; @@ -810,8 +812,8 @@ const float3& padPos = (reservedPad->GetUnit())->pos; const float3 padVec = padPos - pos; - if (padVec.dot(frontdir) < -0.1f && padVec.SqLength2D() < Square(std::min(1000.0f, turnRadius * spd.w))) { - SetGoal(pos + frontdir * turnRadius * spd.w); + if (padVec.dot(frontdir) < -0.1f && padVec.SqLength2D() < Square(TurnRadius(turnRadius, spd.w))) { + SetGoal(pos + frontdir * TurnRadius(turnRadius, spd.w)); } else { SetGoal(padPos); } @@ -830,51 +832,51 @@ float gHeight = 0.0f; if (UseSmoothMesh()) { - gHeight = std::max(smoothGround->GetHeight(pos.x, pos.z), ground->GetApproximateHeight(pos.x, pos.z)); + gHeight = std::max(smoothGround->GetHeight(pos.x, pos.z), CGround::GetApproximateHeight(pos.x, pos.z)); } else { - gHeight = ground->GetHeightAboveWater(pos.x, pos.z); + gHeight = CGround::GetHeightAboveWater(pos.x, pos.z); } if (((gs->frameNum + owner->id) & 3) == 0) { CheckForCollision(); } + // RHS is needed for moving targets (when called by UpdateAttack) + const bool allowUnlockYR = (goalDist2D >= TurnRadius(turnRadius, spd.w) || goalVec.dot(owner->frontdir) > 0.0f); + const bool forceUnlockYR = ((gs->frameNum - owner->lastFireWeapon) >= GAME_SPEED * 3); + + // yaw and roll have to be unblocked after a certain time or aircraft + // can fly straight forever if their target is another chasing aircraft float3 rightDir2D = rightdir; - float3 yprMults = OnesVector * (1.0f + 0.0f * float(goalDist2D < (turnRadius * spd.w))); + float3 yprMults = (XZVector * float(allowUnlockYR || forceUnlockYR)) + UpVector; - float otherThreat = 0.0f; float goalDotRight = goalDir2D.dot(rightDir2D.Normalize2D()); const float aGoalDotFront = goalDir2D.dot(frontdir); - const float goalDotFront = aGoalDotFront * 0.5f + 0.501f; - if (goalDotFront != 0.0f) { - goalDotRight /= goalDotFront; - } - - // if goal-position is behind us and goal-distance - // is less than our turning radius, turn the other - // way --> often insufficient for small turn radii, - // also need to fly straight for some distance - #if 1 - if (goalDir2D.dot(frontdir) < -0.1f && goalDist2D < turnRadius) { + // If goal-position is behind us and goal-distance is less + // than our turning radius, turn the other way. + // If goal-distance is half turn radius then turn if + // goal-position is not in front within a 45 degree arc. + // This is to prevent becoming stuck in a small circle + // around goal-position. + if ((goalDist2D < turnRadius * 0.5f && goalDir2D.dot(frontdir) < 0.7f) || (goalDist2D < turnRadius && goalDir2D.dot(frontdir) < -0.1f)) { if (!owner->UnderFirstPersonControl() || owner->fpsControlPlayer->fpsController.mouse2) { goalDotRight *= -1.0f; } } - #endif - + if (lastColWarning != NULL) { const float3 otherDif = lastColWarning->pos - pos; const float otherLength = otherDif.Length(); + const float otherThreat = (otherLength > 0.0f)? + std::max(1200.0f, goalDist2D) / otherLength * 0.036f: + 0.0f; const float3 otherDir = (otherLength > 0.0f)? (otherDif / otherLength): ZeroVector; - otherThreat = (otherLength > 0.0f)? - std::max(1200.0f, goalDist2D) / otherLength * 0.036f: - 0.0f; goalDotRight -= (otherDir.dot(rightdir) * otherThreat); } @@ -883,6 +885,7 @@ const float elevator = GetElevatorDeflection(owner, lastColWarning, pos, spd, rightdir, updir, frontdir, goalDir2D, gHeight, wantedHeight, maxElevator, maxPitch, goalDotRight, aGoalDotFront, lastColWarningType == 2, false); // pitch UpdateAirPhysics(rudder * yprMults.x, aileron * yprMults.z, elevator * yprMults.y, engine, owner->frontdir); + return (allowUnlockYR || forceUnlockYR); } @@ -915,8 +918,8 @@ SyncedFloat3& updir = owner->updir; const float currentHeight = pos.y - (owner->unitDef->canSubmerge? - ground->GetHeightReal(pos.x, pos.z): - ground->GetHeightAboveWater(pos.x, pos.z)); + CGround::GetHeightReal(pos.x, pos.z): + CGround::GetHeightAboveWater(pos.x, pos.z)); const float yawSign = Sign((goalPos - pos).dot(rightdir)); frontdir += (rightdir * yawSign * (maxRudder * spd.y)); @@ -1007,7 +1010,7 @@ owner->Deactivate(); } else { goalPos.ClampInBounds(); - UpdateFlying(wantedHeight, 1); + UpdateFlying(wantedHeight, 1.0f); return; } } @@ -1036,8 +1039,8 @@ owner->UpdateMidAndAimPos(); // see if we are at the reserved (not user-clicked) landing spot - const float gh = ground->GetHeightAboveWater(pos.x, pos.z); - const float gah = ground->GetHeightReal(pos.x, pos.z); + const float gh = CGround::GetHeightAboveWater(pos.x, pos.z); + const float gah = CGround::GetHeightReal(pos.x, pos.z); float altitude = 0.0f; // can we submerge and are we still above water? @@ -1073,7 +1076,7 @@ lastAileronPos = aileron; lastElevatorPos = elevator; - const float gHeight = ground->GetHeightAboveWater(pos.x, pos.z); + const float gHeight = CGround::GetHeightAboveWater(pos.x, pos.z); const float speedf = spd.w; const float3 speeddir = spd / (speedf + 0.1f); @@ -1133,7 +1136,7 @@ if (groundContact && handleContact) { owner->Move(UpVector * (gHeight - (owner->midPos.y - owner->radius) + 0.01f), true); - const float3& gNormal = ground->GetNormal(pos.x, pos.z); + const float3& gNormal = CGround::GetNormal(pos.x, pos.z); const float impactSpeed = -spd.dot(gNormal) * int(1 - owner->IsStunned()); if (impactSpeed > 0.0f) { @@ -1174,13 +1177,11 @@ assert(newState != AIRCRAFT_HOVERING); // once in crashing, we should never change back into another state - if (aircraftState == AIRCRAFT_CRASHING && newState != AIRCRAFT_CRASHING) { + if (aircraftState == AIRCRAFT_CRASHING && newState != AIRCRAFT_CRASHING) return; - } - if (newState == aircraftState) { + if (newState == aircraftState) return; - } // make sure we only go into takeoff mode when landed if (aircraftState == AIRCRAFT_LANDED) { @@ -1235,7 +1236,7 @@ const UnitDef* ud = owner->unitDef; float3 tryPos = owner->pos + owner->frontdir * ((Square(owner->speed.w) * 0.5f) / brakeRate); - tryPos.y = ground->GetHeightReal(tryPos.x, tryPos.z); + tryPos.y = CGround::GetHeightReal(tryPos.x, tryPos.z); if ((tryPos.y < 0.0f) && !(ud->floatOnWater || ud->canSubmerge)) return ret; @@ -1253,7 +1254,7 @@ } // FIXME: better use ud->maxHeightDif? - if (ground->GetSlope(tryPos.x, tryPos.z) > 0.03f) + if (CGround::GetSlope(tryPos.x, tryPos.z) > 0.03f) return ret; return tryPos; @@ -1320,3 +1321,81 @@ } } } + + + +bool CStrafeAirMoveType::SetMemberValue(unsigned int memberHash, void* memberValue) { + // try the generic members first + if (AMoveType::SetMemberValue(memberHash, memberValue)) + return true; + + #define MEMBER_CHARPTR_HASH(memberName) HsiehHash(memberName, strlen(memberName), 0) + #define MEMBER_LITERAL_HASH(memberName) HsiehHash(memberName, sizeof(memberName) - 1, 0) + + static const unsigned int boolMemberHashes[] = { + MEMBER_LITERAL_HASH( "collide"), + MEMBER_LITERAL_HASH( "useSmoothMesh"), + MEMBER_LITERAL_HASH("loopbackAttack"), + }; + static const unsigned int floatMemberHashes[] = { + MEMBER_LITERAL_HASH( "wantedHeight"), + MEMBER_LITERAL_HASH( "turnRadius"), + MEMBER_LITERAL_HASH( "accRate"), + MEMBER_LITERAL_HASH( "decRate"), + MEMBER_LITERAL_HASH( "maxAcc"), // synonym for accRate + MEMBER_LITERAL_HASH( "maxDec"), // synonym for decRate + MEMBER_LITERAL_HASH( "maxBank"), + MEMBER_LITERAL_HASH( "maxPitch"), + MEMBER_LITERAL_HASH( "maxAileron"), + MEMBER_LITERAL_HASH( "maxElevator"), + MEMBER_LITERAL_HASH( "maxRudder"), + MEMBER_LITERAL_HASH( "myGravity"), + }; + + #undef MEMBER_CHARPTR_HASH + #undef MEMBER_LITERAL_HASH + + + // unordered_map etc. perform dynallocs, so KISS here + bool* boolMemberPtrs[] = { + &collide, + &useSmoothMesh, + &loopbackAttack, + }; + float* floatMemberPtrs[] = { + &wantedHeight, + &turnRadius, + + &accRate, // hash("accRate") case + &decRate, // hash("decRate") case + &accRate, // hash( "maxAcc") case + &decRate, // hash( "maxDec") case + + &maxBank, + &maxPitch, + + &maxAileron, + &maxElevator, + &maxRudder, + + &myGravity, + }; + + // note: should be calculated via HsiehHash + for (unsigned int n = 0; n < sizeof(boolMemberPtrs) / sizeof(boolMemberPtrs[0]); n++) { + if (memberHash == boolMemberHashes[n]) { + *(boolMemberPtrs[n]) = *(reinterpret_cast(memberValue)); + return true; + } + } + + for (unsigned int n = 0; n < sizeof(floatMemberPtrs) / sizeof(floatMemberPtrs[0]); n++) { + if (memberHash == floatMemberHashes[n]) { + *(floatMemberPtrs[n]) = *(reinterpret_cast(memberValue)); + return true; + } + } + + return false; +} + diff -Nru spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/StrafeAirMoveType.h spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/StrafeAirMoveType.h --- spring-96.0~14.04~ppa4/rts/Sim/MoveTypes/StrafeAirMoveType.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/MoveTypes/StrafeAirMoveType.h 2014-10-07 20:09:51.000000000 +0000 @@ -1,7 +1,7 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ -#ifndef _AIR_MOVE_TYPE_H_ -#define _AIR_MOVE_TYPE_H_ +#ifndef STRAFE_AIR_MOVE_TYPE_H_ +#define STRAFE_AIR_MOVE_TYPE_H_ #include "AAirMoveType.h" #include @@ -11,23 +11,35 @@ */ class CStrafeAirMoveType: public AAirMoveType { - CR_DECLARE(CStrafeAirMoveType); - CR_DECLARE_SUB(DrawLine); + CR_DECLARE(CStrafeAirMoveType) + CR_DECLARE_SUB(DrawLine) public: + enum { + MANEUVER_FLY_STRAIGHT = 0, + MANEUVER_IMMELMAN = 1, + MANEUVER_IMMELMAN_INV = 2, + }; + CStrafeAirMoveType(CUnit* owner); bool Update(); void SlowUpdate(); + bool SetMemberValue(unsigned int memberHash, void* memberValue); + void UpdateManeuver(); - void UpdateFighterAttack(); void UpdateAttack(); - void UpdateFlying(float wantedHeight, float engine); + bool UpdateFlying(float wantedHeight, float engine); void UpdateLanded(); void UpdateLanding(); - void UpdateAirPhysics(float rudder, float aileron, float elevator, - float engine, const float3& engineVector); + void UpdateAirPhysics( + float rudder, + float aileron, + float elevator, + float engine, + const float3& engineVector + ); void SetState(AircraftState state); void UpdateTakeOff(float wantedHeight); @@ -42,7 +54,7 @@ void Takeoff(); - int maneuver; + int maneuverState; int maneuverSubState; bool loopbackAttack; @@ -75,11 +87,6 @@ float lastElevatorPos; float lastAileronPos; - float inefficientAttackTime; - - /// used by fighters to turn away when closing in on ground targets - float3 exitVector; - private: bool HandleCollisions(bool checkCollisions); }; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Objects/SolidObject.cpp spring-98.0~14.04~ppa6/rts/Sim/Objects/SolidObject.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Objects/SolidObject.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Objects/SolidObject.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -17,7 +17,7 @@ const float CSolidObject::MINIMUM_MASS = 1e0f; // 1.0f const float CSolidObject::MAXIMUM_MASS = 1e6f; -CR_BIND_DERIVED(CSolidObject, CWorldObject, ); +CR_BIND_DERIVED(CSolidObject, CWorldObject, ) CR_REG_METADATA(CSolidObject, ( CR_MEMBER(health), @@ -43,6 +43,8 @@ CR_MEMBER(team), CR_MEMBER(allyteam), + CR_MEMBER(tempNum), + CR_MEMBER(objectDef), CR_MEMBER(moveDef), CR_MEMBER(collisionVolume), @@ -66,7 +68,7 @@ // CR_MEMBER(blockMap), //FIXME add bitwiseenum to creg CR_MEMBER(buildFacing) -)); +)) CSolidObject::CSolidObject(): @@ -96,6 +98,8 @@ team(0), allyteam(0), + tempNum(0), + objectDef(NULL), moveDef(NULL), collisionVolume(NULL), @@ -123,7 +127,7 @@ } void CSolidObject::UpdatePhysicalState(float eps) { - const float gh = ground->GetHeightReal(pos.x, pos.z); + const float gh = CGround::GetHeightReal(pos.x, pos.z); const float wh = std::max(gh, 0.0f); unsigned int ps = physicalState; @@ -229,8 +233,12 @@ return; UnBlock(); - groundBlockingObjectMap->AddGroundBlockingObject(this); - assert(IsBlocking()); + + // only block when `touching` the ground + if ((pos.y - radius) <= CGround::GetHeightAboveWater(pos.x, pos.z)) { + groundBlockingObjectMap->AddGroundBlockingObject(this); + assert(IsBlocking()); + } } @@ -267,7 +275,7 @@ gpos -= float3(mapPos.x * SQUARE_SIZE, 0.0f, mapPos.y * SQUARE_SIZE); // need to revert some of the transformations of CSolidObject::GetMapPos() - gpos.x += SQUARE_SIZE / 2 - (this->xsize >> 1) * SQUARE_SIZE; + gpos.x += SQUARE_SIZE / 2 - (this->xsize >> 1) * SQUARE_SIZE; gpos.z += SQUARE_SIZE / 2 - (this->zsize >> 1) * SQUARE_SIZE; #endif @@ -356,7 +364,7 @@ // the water surface) and neither are tanks / bots due to impulses, // gravity, ... // - const float3 gn = ground->GetSmoothNormal(pos.x, pos.z) * ( useGroundNormal); + const float3 gn = CGround::GetSmoothNormal(pos.x, pos.z) * ( useGroundNormal); const float3 wn = UpVector * (1 - useGroundNormal); if (moveDef == NULL) { @@ -383,10 +391,41 @@ return updir; } + + void CSolidObject::SetHeadingFromDirection() { heading = GetHeadingFromVector(frontdir.x, frontdir.z); } +void CSolidObject::UpdateDirVectors(bool useGroundNormal) +{ + updir = GetWantedUpDir(useGroundNormal); + frontdir = GetVectorFromHeading(heading); + rightdir = (frontdir.cross(updir)).Normalize(); + frontdir = updir.cross(rightdir); +} + + + +void CSolidObject::ForcedSpin(const float3& newDir) { + // new front-direction should be normalized + assert(math::fabsf(newDir.SqLength() - 1.0f) <= float3::NORMALIZE_EPS); + + // if zdir is parallel to world-y, use heading-vector + // (or its inverse) as auxiliary to avoid degeneracies + const float3 zdir = newDir; + const float3 udir = mix(UpVector, (frontdir * Sign(-zdir.y)), (math::fabs(zdir.dot(UpVector)) >= 0.99f)); + const float3 xdir = (zdir.cross(udir)).Normalize(); + const float3 ydir = (xdir.cross(zdir)).Normalize(); + + frontdir = zdir; + rightdir = xdir; + updir = ydir; + + SetHeadingFromDirection(); + UpdateMidAndAimPos(); +} + void CSolidObject::Kill(CUnit* killer, const float3& impulse, bool crushed) { diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Objects/SolidObjectDef.cpp spring-98.0~14.04~ppa6/rts/Sim/Objects/SolidObjectDef.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Objects/SolidObjectDef.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Objects/SolidObjectDef.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ #include "System/EventHandler.h" #include "System/Log/ILog.h" -CR_BIND(SolidObjectDecalDef, ); +CR_BIND(SolidObjectDecalDef, ) CR_REG_METADATA(SolidObjectDecalDef, ( CR_MEMBER(groundDecalTypeName), @@ -25,7 +25,7 @@ CR_MEMBER(trackDecalOffset), CR_MEMBER(trackDecalStrength), CR_MEMBER(trackDecalStretch) -)); +)) SolidObjectDecalDef::SolidObjectDecalDef() : useGroundDecal(false) @@ -60,7 +60,7 @@ trackDecalStretch = table.GetFloat("trackStretch", 1.0f); } -CR_BIND(SolidObjectDef, ); +CR_BIND(SolidObjectDef, ) CR_REG_METADATA(SolidObjectDef, ( CR_MEMBER(id), @@ -88,7 +88,7 @@ CR_MEMBER(modelName), CR_MEMBER(customParams) -)); +)) SolidObjectDef::SolidObjectDef() : id(-1) diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Objects/SolidObject.h spring-98.0~14.04~ppa6/rts/Sim/Objects/SolidObject.h --- spring-96.0~14.04~ppa4/rts/Sim/Objects/SolidObject.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Objects/SolidObject.h 2014-10-07 20:09:51.000000000 +0000 @@ -54,6 +54,8 @@ // {ONGROUND,*WATER} and INAIR are mutually exclusive // {UNDERGROUND,UNDERWATER} are not (and are the only // bits to take radius into account) + // TODO: + // should isDead be on this list for spatial queries? PSTATE_BIT_ONGROUND = (1 << 0), PSTATE_BIT_INWATER = (1 << 1), PSTATE_BIT_UNDERWATER = (1 << 2), @@ -101,7 +103,7 @@ virtual int GetBlockingMapID() const { return -1; } virtual void ForcedMove(const float3& newPos) {} - virtual void ForcedSpin(const float3& newDir) {} + virtual void ForcedSpin(const float3& newDir); virtual void UpdatePhysicalState(float eps); @@ -126,12 +128,18 @@ } - void SetHeadingFromDirection(); void SetDirVectors(const CMatrix44f& matrix) { rightdir.x = -matrix[0]; updir.x = matrix[4]; frontdir.x = matrix[ 8]; rightdir.y = -matrix[1]; updir.y = matrix[5]; frontdir.y = matrix[ 9]; rightdir.z = -matrix[2]; updir.z = matrix[6]; frontdir.z = matrix[10]; } + // update object's from current frontdir + // should always be called after a SetDirVectors() + void SetHeadingFromDirection(); + // update object's local coor-sys from current + // (unlike ForcedSpin which updates from given ) + // NOTE: movetypes call this directly + void UpdateDirVectors(bool useGroundNormal); virtual CMatrix44f GetTransformMatrix(const bool synced = false, const bool error = false) const { // should never get called (should be pure virtual, but cause of CREG we cannot use it) @@ -258,6 +266,8 @@ int team; ///< team that "owns" this object int allyteam; ///< allyteam that this->team is part of + int tempNum; ///< used to check if object has already been processed (in QuadField queries, etc) + const SolidObjectDef* objectDef; ///< points to a UnitDef or to a FeatureDef instance MoveDef* moveDef; ///< mobility information about this object (if NULL, object is either static or aircraft) diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Objects/WorldObject.cpp spring-98.0~14.04~ppa6/rts/Sim/Objects/WorldObject.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Objects/WorldObject.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Objects/WorldObject.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -19,7 +19,7 @@ CR_MEMBER_ENDFLAG(CM_Config), CR_IGNORED(model), //FIXME CR_POSTLOAD(PostLoad) -)); +)) void CWorldObject::SetRadiusAndHeight(S3DModel* model) diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Objects/WorldObject.h spring-98.0~14.04~ppa6/rts/Sim/Objects/WorldObject.h --- spring-96.0~14.04~ppa4/rts/Sim/Objects/WorldObject.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Objects/WorldObject.h 2014-10-07 20:09:51.000000000 +0000 @@ -14,7 +14,7 @@ class CWorldObject: public CObject { public: - CR_DECLARE(CWorldObject); + CR_DECLARE(CWorldObject) CWorldObject() : id(-1) diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/Default/IPathFinder.cpp spring-98.0~14.04~ppa6/rts/Sim/Path/Default/IPathFinder.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Path/Default/IPathFinder.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/Default/IPathFinder.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,202 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include "IPathFinder.h" +#include "PathFinderDef.h" +#include "PathLog.h" +#include "Sim/MoveTypes/MoveDefHandler.h" +#include "Sim/Objects/SolidObject.h" +#include "System/Log/ILog.h" + + +// these give the changes in (x, z) coors +// when moving one step in given direction +// +// NOTE: the choices of +1 for LEFT and UP are *not* arbitrary +// (they are related to GetBlockVertexOffset) and also need to +// be consistent with the PATHOPT_* flags (for PathDir2PathOpt) +int2 IPathFinder::PE_DIRECTION_VECTORS[PATH_DIRECTIONS] = { + int2(+1, 0), // PATHDIR_LEFT + int2(+1, +1), // PATHDIR_LEFT_UP + int2( 0, +1), // PATHDIR_UP + int2(-1, +1), // PATHDIR_RIGHT_UP + int2(-1, 0), // PATHDIR_RIGHT + int2(-1, -1), // PATHDIR_RIGHT_DOWN + int2( 0, -1), // PATHDIR_DOWN + int2(+1, -1), // PATHDIR_LEFT_DOWN +}; + +//FIXME why not use PATHDIR_* consts and merge code with top one +int2 IPathFinder::PF_DIRECTION_VECTORS_2D[PATH_DIRECTIONS << 1] = { + int2(0, 0), + int2(+1 * PATH_NODE_SPACING, 0 * PATH_NODE_SPACING), // PATHOPT_LEFT + int2(-1 * PATH_NODE_SPACING, 0 * PATH_NODE_SPACING), // PATHOPT_RIGHT + int2(0, 0), // PATHOPT_LEFT | PATHOPT_RIGHT + int2( 0 * PATH_NODE_SPACING, +1 * PATH_NODE_SPACING), // PATHOPT_UP + int2(+1 * PATH_NODE_SPACING, +1 * PATH_NODE_SPACING), // PATHOPT_LEFT | PATHOPT_UP + int2(-1 * PATH_NODE_SPACING, +1 * PATH_NODE_SPACING), // PATHOPT_RIGHT | PATHOPT_UP + int2(0, 0), // PATHOPT_LEFT | PATHOPT_RIGHT | PATHOPT_UP + int2( 0 * PATH_NODE_SPACING, -1 * PATH_NODE_SPACING), // PATHOPT_DOWN + int2(+1 * PATH_NODE_SPACING, -1 * PATH_NODE_SPACING), // PATHOPT_LEFT | PATHOPT_DOWN + int2(-1 * PATH_NODE_SPACING, -1 * PATH_NODE_SPACING), // PATHOPT_RIGHT | PATHOPT_DOWN + int2(0, 0), + int2(0, 0), + int2(0, 0), + int2(0, 0), + int2(0, 0), +}; + + + +IPathFinder::IPathFinder(unsigned int _BLOCK_SIZE) + : BLOCK_SIZE(_BLOCK_SIZE) + , BLOCK_PIXEL_SIZE(BLOCK_SIZE * SQUARE_SIZE) + , isEstimator(BLOCK_SIZE != 1) + , mStartBlockIdx(0) + , mGoalBlockIdx(0) + , mGoalHeuristic(0.0f) + , maxBlocksToBeSearched(0) + , testedBlocks(0) + , nbrOfBlocks(gs->mapx / BLOCK_SIZE, gs->mapy / BLOCK_SIZE) + , blockStates(nbrOfBlocks, int2(gs->mapx, gs->mapy)) +{ +} + + +IPathFinder::~IPathFinder() +{ + //ResetSearch(); +} + + +void IPathFinder::ResetSearch() +{ + openBlocks.Clear(); + + while (!dirtyBlocks.empty()) { + blockStates.ClearSquare(dirtyBlocks.back()); + dirtyBlocks.pop_back(); + } + + testedBlocks = 0; +} + + +IPath::SearchResult IPathFinder::GetPath( + const MoveDef& moveDef, + const CPathFinderDef& pfDef, + const CSolidObject* owner, + float3 startPos, + IPath::Path& path, + const unsigned int maxNodes +) { + startPos.ClampInBounds(); + + // Clear the path + path.path.clear(); + path.squares.clear(); + path.pathCost = PATHCOST_INFINITY; + + // initial calculations + if (isEstimator) { + maxBlocksToBeSearched = std::min(MAX_SEARCHED_NODES_PE - 8U, maxNodes); + } else { + maxBlocksToBeSearched = std::min(MAX_SEARCHED_NODES_PF - 8U, maxNodes); + } + mStartBlock.x = startPos.x / BLOCK_PIXEL_SIZE; + mStartBlock.y = startPos.z / BLOCK_PIXEL_SIZE; + mStartBlockIdx = BlockPosToIdx(mStartBlock); + assert((unsigned)mStartBlock.x < nbrOfBlocks.x && (unsigned)mStartBlock.y < nbrOfBlocks.y); + + // Check cache (when there is one) + int2 goalBlock; + goalBlock.x = pfDef.goalSquareX / BLOCK_SIZE; + goalBlock.y = pfDef.goalSquareZ / BLOCK_SIZE; + const CPathCache::CacheItem* ci = GetCache(mStartBlock, goalBlock, pfDef.sqGoalRadius, moveDef.pathType, pfDef.synced); + if (ci != nullptr) { + path = ci->path; + return ci->result; + } + + // Start up a new search + IPath::SearchResult result = InitSearch(moveDef, pfDef, owner); + + // If search was successful, generate new path + if (result == IPath::Ok || result == IPath::GoalOutOfRange) { + FinishSearch(moveDef, pfDef, path); + + // Save to cache + if (result == IPath::Ok) { + // add succesful paths to the cache + AddCache(&path, result, mStartBlock, goalBlock, pfDef.sqGoalRadius, moveDef.pathType, pfDef.synced); + } + + if (LOG_IS_ENABLED(L_DEBUG)) { + LOG_L(L_DEBUG, "%s: Search completed.", (isEstimator) ? "PE" : "PF"); + LOG_L(L_DEBUG, "Tested blocks: %u", testedBlocks); + LOG_L(L_DEBUG, "Open blocks: %u", openBlockBuffer.GetSize()); + LOG_L(L_DEBUG, "Path length: " _STPF_, path.path.size()); + LOG_L(L_DEBUG, "Path cost: %f", path.pathCost); + } + } else { + if (LOG_IS_ENABLED(L_DEBUG)) { + LOG_L(L_DEBUG, "%s: Search failed!", (isEstimator) ? "PE" : "PF"); + LOG_L(L_DEBUG, "Tested blocks: %u", testedBlocks); + LOG_L(L_DEBUG, "Open blocks: %u", openBlockBuffer.GetSize()); + } + } + + return result; +} + + +// set up the starting point of the search +IPath::SearchResult IPathFinder::InitSearch(const MoveDef& moveDef, const CPathFinderDef& pfDef, const CSolidObject* owner) +{ + int2 square = mStartBlock; + if (isEstimator) { + square = blockStates.peNodeOffsets[moveDef.pathType][mStartBlockIdx]; + } + const bool isStartGoal = pfDef.IsGoal(square.x, square.y); + + // although our starting square may be inside the goal radius, the starting coordinate may be outside. + // in this case we do not want to return CantGetCloser, but instead a path to our starting square. + if (isStartGoal && pfDef.startInGoalRadius) + return IPath::CantGetCloser; + + // no, clean the system from last search + ResetSearch(); + + // mark and store the start-block + blockStates.nodeMask[mStartBlockIdx] &= PATHOPT_OBSOLETE; // clear all except PATHOPT_OBSOLETE + blockStates.nodeMask[mStartBlockIdx] |= PATHOPT_OPEN; + blockStates.fCost[mStartBlockIdx] = 0.0f; + blockStates.gCost[mStartBlockIdx] = 0.0f; + blockStates.SetMaxCost(NODE_COST_F, 0.0f); + blockStates.SetMaxCost(NODE_COST_G, 0.0f); + + dirtyBlocks.push_back(mStartBlockIdx); + + // start a new search and + // add the starting block to the open-blocks-queue + openBlockBuffer.SetSize(0); + PathNode* ob = openBlockBuffer.GetNode(openBlockBuffer.GetSize()); + ob->fCost = 0.0f; + ob->gCost = 0.0f; + ob->nodePos = mStartBlock; + ob->nodeNum = mStartBlockIdx; + openBlocks.push(ob); + + // mark starting point as best found position + mGoalBlockIdx = mStartBlockIdx; + mGoalHeuristic = pfDef.Heuristic(square.x, square.y); + + // perform the search + IPath::SearchResult result = DoSearch(moveDef, pfDef, owner); + + // if no improvements are found, then return CantGetCloser instead + if ((mGoalBlockIdx == mStartBlockIdx) && (!isStartGoal || pfDef.startInGoalRadius)) { + return IPath::CantGetCloser; + } + + return result; +} diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/Default/IPathFinder.h spring-98.0~14.04~ppa6/rts/Sim/Path/Default/IPathFinder.h --- spring-96.0~14.04~ppa4/rts/Sim/Path/Default/IPathFinder.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/Default/IPathFinder.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,145 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef IPATH_FINDER_H +#define IPATH_FINDER_H + +#include +#include +#include + +#include "IPath.h" +#include "PathCache.h" +#include "PathConstants.h" +#include "PathDataTypes.h" + +struct MoveDef; +class CPathFinderDef; +class CSolidObject; + + +class IPathFinder { +public: + IPathFinder(unsigned int BLOCK_SIZE); + virtual ~IPathFinder(); + + // size of the memory-region we hold allocated (excluding sizeof(*this)) + // (PathManager stores HeatMap and FlowMap, so we do not need to add them) + size_t GetMemFootPrint() const { return (blockStates.GetMemFootPrint()); } + + PathNodeStateBuffer& GetNodeStateBuffer() { return blockStates; } + + unsigned int GetBlockSize() const { return BLOCK_SIZE; } + int2 GetNumBlocks() const { return nbrOfBlocks; } + int2 BlockIdxToPos(const int idx) const { return int2(idx % nbrOfBlocks.x, idx / nbrOfBlocks.x); } + int BlockPosToIdx(const int2 pos) const { return pos.y * nbrOfBlocks.x + pos.x; } + + + /** + * Gives a path from given starting location to target defined in + * CPathFinderDef, whenever any such are available. + * If no complete path was found, any path leading as "close" to target as + * possible will be created, and SearchResult::OutOfRange will be returned. + * Only when no "closer" position than the given starting location could be + * found no path is created, and SearchResult::CantGetCloser is returned. + * + * @param moveDef defining the footprint of the unit requesting the path. + * @param startPos The starting location of the path. (Projected onto (x,z)) + * @param pfDef Object defining the target/goal of the search. + * Could also be used to put constraints on the searchspace used. + * @param path If any path could be found, it will be generated and put into + * this structure. + * @param exactPath Overrides the return of the "closest" path. + * If this option is true, a path is returned only if it's completed all + * the way to the goal defined in pfDef. All SearchResult::OutOfRange are + * then turned into SearchResult::CantGetCloser. + * @param maxNodes The maximum number of nodes / squares the search is + * allowed to analyze. This restriction could be used in cases where + * CPU-consumption is critical. + */ + IPath::SearchResult GetPath( + const MoveDef& moveDef, + const CPathFinderDef& pfDef, + const CSolidObject* owner, + float3 startPos, + IPath::Path& path, + const unsigned int maxNodes + ); + +protected: + /// + IPath::SearchResult InitSearch(const MoveDef&, const CPathFinderDef&, const CSolidObject* owner); + + /// Clear things up from last search. + void ResetSearch(); + +protected: // pure virtuals + virtual IPath::SearchResult DoSearch(const MoveDef&, const CPathFinderDef&, const CSolidObject* owner) = 0; + + /** + * Test the availability and value of a block, + * and possibly add it to the queue of open blocks. + */ + virtual bool TestBlock( + const MoveDef& moveDef, + const CPathFinderDef& pfDef, + const PathNode* parentSquare, + const CSolidObject* owner, + const unsigned int pathOptDir, + const unsigned int blockStatus, + float speedMod, + bool withinConstraints + ) = 0; + + /** + * Recreates the path found by pathfinder. + * Starting at goalSquare and tracking backwards. + * + * Perform adjustment of waypoints so not all turns are 90 or 45 degrees. + */ + virtual IPath::SearchResult FinishSearch(const MoveDef& moveDef, const CPathFinderDef& pfDef, IPath::Path& path) const = 0; + + + virtual const CPathCache::CacheItem* GetCache( + const int2 strtBlock, + const int2 goalBlock, + float goalRadius, + int pathType, + const bool synced + ) const = 0; + + virtual void AddCache( + const IPath::Path* path, + const IPath::SearchResult result, + const int2 strtBlock, + const int2 goalBlock, + float goalRadius, + int pathType, + const bool synced + ) = 0; + +public: + static int2 PE_DIRECTION_VECTORS[PATH_DIRECTIONS]; + static int2 PF_DIRECTION_VECTORS_2D[PATH_DIRECTIONS << 1]; + + const unsigned int BLOCK_SIZE; + const unsigned int BLOCK_PIXEL_SIZE; + const bool isEstimator; + + int2 mStartBlock; + unsigned int mStartBlockIdx; + unsigned int mGoalBlockIdx; //< set during each search as the square closest to the goal + float mGoalHeuristic; //< heuristic value of goalSquareIdx + + unsigned int maxBlocksToBeSearched; + unsigned int testedBlocks; + + int2 nbrOfBlocks; //< Number of blocks on the axes + + PathNodeBuffer openBlockBuffer; + PathNodeStateBuffer blockStates; + PathPriorityQueue openBlocks; + + std::vector dirtyBlocks; //< List of blocks changed in last search. +}; + +#endif // IPATH_FINDER_H diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/Default/IPath.h spring-98.0~14.04~ppa6/rts/Sim/Path/Default/IPath.h --- spring-96.0~14.04~ppa4/rts/Sim/Path/Default/IPath.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/Default/IPath.h 2014-10-07 20:09:51.000000000 +0000 @@ -21,19 +21,22 @@ struct Path { Path() : desiredGoal(ZeroVector) - , goalRadius(-1.0f) , pathGoal(ZeroVector) + , goalRadius(-1.0f) , pathCost(-1.0f) {} + // Information about the requested path. float3 desiredGoal; - float goalRadius; // Information about the generated path. float3 pathGoal; + path_list_type path; square_list_type squares; + + float goalRadius; float pathCost; }; -}; +} #endif diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathAllocator.cpp spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathAllocator.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathAllocator.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathAllocator.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#include -#include "PathAllocator.h" - -void* PathAllocator::Alloc(unsigned int n) -{ - char* ret = new char[n]; - memset(ret, 0, n); - return ret; -} - -void PathAllocator::Free(void* p, unsigned int) -{ - delete[] ((char*) p); -} diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathAllocator.h spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathAllocator.h --- spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathAllocator.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathAllocator.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#ifndef PATH_ALLOCATOR_HDR -#define PATH_ALLOCATOR_HDR - -struct PathAllocator { - static void* Alloc(unsigned int n); - static void Free(void* p, unsigned int n); -}; - -#endif diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathConstants.h spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathConstants.h --- spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathConstants.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathConstants.h 2014-10-07 20:09:51.000000000 +0000 @@ -4,6 +4,7 @@ #define PATH_CONSTANTS_HDR #include +#include #include "Sim/Misc/GlobalConstants.h" static const float PATHCOST_INFINITY = std::numeric_limits::infinity(); @@ -16,12 +17,15 @@ static const unsigned int MAX_SEARCHED_NODES_PE = MAX_SEARCHED_NODES; // PathManager distance thresholds (to use PF or PE) -static const float DETAILED_DISTANCE = 25.0f; -static const float ESTIMATE_DISTANCE = 55.0f; -static const float MIN_ESTIMATE_DISTANCE = 40.0f; -static const float MIN_DETAILED_DISTANCE = 12.0f; +static const float MAXRES_SEARCH_DISTANCE = 25.0f; +static const float MEDRES_SEARCH_DISTANCE = 55.0f; +static const float MIN_MEDRES_SEARCH_DISTANCE = 40.0f; +static const float MIN_MAXRES_SEARCH_DISTANCE = 12.0f; -static const unsigned int PATHESTIMATOR_VERSION = 53; +// how many recursive refinement attempts NextWayPoint should make +static const unsigned int MAX_PATH_REFINEMENT_DEPTH = 4; + +static const unsigned int PATHESTIMATOR_VERSION = 61; static const unsigned int MEDRES_PE_BLOCKSIZE = 8; static const unsigned int LOWRES_PE_BLOCKSIZE = 32; @@ -34,44 +38,88 @@ static const unsigned int PATH_FLOWMAP_XSCALE = 32; // wrt. gs->mapx static const unsigned int PATH_FLOWMAP_ZSCALE = 32; // wrt. gs->mapy -static const unsigned int PATH_DIRECTIONS = 8; + +// PE-only flags (indices) +enum { + PATHDIR_LEFT = 0, // +x + PATHDIR_LEFT_UP = 1, // +x+z + PATHDIR_UP = 2, // +z + PATHDIR_RIGHT_UP = 3, // -x+z + PATHDIR_RIGHT = 4, // -x + PATHDIR_RIGHT_DOWN = 5, // -x-z + PATHDIR_DOWN = 6, // -z + PATHDIR_LEFT_DOWN = 7, // +x-z + PATH_DIRECTIONS = 8, +}; +static const unsigned int PATHDIR_CARDINALS[4] = {PATHDIR_LEFT, PATHDIR_RIGHT, PATHDIR_UP, PATHDIR_DOWN}; static const unsigned int PATH_DIRECTION_VERTICES = PATH_DIRECTIONS >> 1; static const unsigned int PATH_NODE_SPACING = 2; -// PE-only flags -static const unsigned int PATHDIR_LEFT = 0; // +x -static const unsigned int PATHDIR_LEFT_UP = 1; // +x+z -static const unsigned int PATHDIR_UP = 2; // +z -static const unsigned int PATHDIR_RIGHT_UP = 3; // -x+z -static const unsigned int PATHDIR_RIGHT = 4; // -x -static const unsigned int PATHDIR_RIGHT_DOWN = 5; // -x-z -static const unsigned int PATHDIR_DOWN = 6; // -z -static const unsigned int PATHDIR_LEFT_DOWN = 7; // +x-z - -// PF-only flags -static const unsigned int PATHOPT_LEFT = 1; // +x -static const unsigned int PATHOPT_RIGHT = 2; // -x -static const unsigned int PATHOPT_UP = 4; // +z -static const unsigned int PATHOPT_DOWN = 8; // -z -static const unsigned int PATHOPT_AXIS_DIRS = (PATHOPT_RIGHT | PATHOPT_LEFT | PATHOPT_UP | PATHOPT_DOWN); +// note: because the spacing between nodes is 2 (not 1) we +// must also make sure not to skip across any intermediate +// impassable squares (!) but without reducing the spacing +// factor which would drop performance four-fold --> messy +static_assert(PATH_NODE_SPACING == 2, ""); -static inline unsigned int PathDir2PathOpt(unsigned int pathDir) { - unsigned int pathOpt = 0; +// PF and PE flags (used in nodeMask[]) +enum { + PATHOPT_LEFT = 1, // +x + PATHOPT_RIGHT = 2, // -x + PATHOPT_UP = 4, // +z + PATHOPT_DOWN = 8, // -z + PATHOPT_OPEN = 16, + PATHOPT_CLOSED = 32, + PATHOPT_BLOCKED = 64, + PATHOPT_OBSOLETE = 128, + + PATHOPT_SIZE = 255, // size of PATHOPT bitmask +}; +static const unsigned int PATHOPT_CARDINALS = (PATHOPT_RIGHT | PATHOPT_LEFT | PATHOPT_UP | PATHOPT_DOWN); + + +static inline std::array GetPathDir2PathOpt() +{ + std::array a; + a[PATHDIR_LEFT] = PATHOPT_LEFT; + a[PATHDIR_RIGHT] = PATHOPT_RIGHT; + a[PATHDIR_UP] = PATHOPT_UP; + a[PATHDIR_DOWN] = PATHOPT_DOWN; + a[PATHDIR_LEFT_UP] = (PATHOPT_LEFT | PATHOPT_UP); + a[PATHDIR_RIGHT_UP] = (PATHOPT_RIGHT | PATHOPT_UP); + a[PATHDIR_RIGHT_DOWN] = (PATHOPT_RIGHT | PATHOPT_DOWN); + a[PATHDIR_LEFT_DOWN] = (PATHOPT_LEFT | PATHOPT_DOWN); + return a; +} - switch (pathDir) { - case PATHDIR_LEFT: { pathOpt |= PATHOPT_LEFT; } break; - case PATHDIR_RIGHT: { pathOpt |= PATHOPT_RIGHT; } break; - case PATHDIR_UP: { pathOpt |= PATHOPT_UP; } break; - case PATHDIR_DOWN: { pathOpt |= PATHOPT_DOWN; } break; - case PATHDIR_LEFT_UP: { pathOpt |= (PATHOPT_LEFT | PATHOPT_UP); } break; - case PATHDIR_RIGHT_UP: { pathOpt |= (PATHOPT_RIGHT | PATHOPT_UP); } break; - case PATHDIR_RIGHT_DOWN: { pathOpt |= (PATHOPT_RIGHT | PATHOPT_DOWN); } break; - case PATHDIR_LEFT_DOWN: { pathOpt |= (PATHOPT_LEFT | PATHOPT_DOWN); } break; - } +static inline std::array GetPathOpt2PathDir() +{ + std::array a; + for (auto& i: a) i = 0; + a[PATHOPT_LEFT] = PATHDIR_LEFT; + a[PATHOPT_RIGHT] = PATHDIR_RIGHT; + a[PATHOPT_UP] = PATHDIR_UP; + a[PATHOPT_DOWN] = PATHDIR_DOWN; + a[(PATHOPT_LEFT | PATHOPT_UP)] = PATHDIR_LEFT_UP; + a[(PATHOPT_RIGHT | PATHOPT_UP)] = PATHDIR_RIGHT_UP; + a[(PATHOPT_RIGHT | PATHOPT_DOWN)] = PATHDIR_RIGHT_DOWN; + a[(PATHOPT_LEFT | PATHOPT_DOWN)] = PATHDIR_LEFT_DOWN; + return a; +} + + +// converts a PATHDIR* index to a PATHOPT* bitmask +static inline unsigned int PathDir2PathOpt(unsigned int pathDir) { + static const std::array DIR2OPT = GetPathDir2PathOpt(); + return DIR2OPT[pathDir]; +} - return pathOpt; +// converts a PATHOPT* bitmask to a PATHDIR* index +static inline unsigned int PathOpt2PathDir(unsigned int pathOptDir) { + static const std::array OPT2DIR = GetPathOpt2PathDir(); + return OPT2DIR[pathOptDir]; } + // transition costs between vertices are bi-directional // (cost(A-->B) == cost(A<--B)) so we only need to store // (PATH_DIRECTIONS >> 1) values @@ -83,6 +131,7 @@ case PATHDIR_LEFT_UP: { bvo = PATHDIR_LEFT_UP; } break; case PATHDIR_UP: { bvo = PATHDIR_UP; } break; case PATHDIR_RIGHT_UP: { bvo = PATHDIR_RIGHT_UP; } break; + case PATHDIR_RIGHT: { bvo = int(PATHDIR_LEFT ) - PATH_DIRECTION_VERTICES; } break; case PATHDIR_RIGHT_DOWN: { bvo = int(PATHDIR_LEFT_UP ) - (numBlocks * PATH_DIRECTION_VERTICES) - PATH_DIRECTION_VERTICES; } break; case PATHDIR_DOWN: { bvo = int(PATHDIR_UP ) - (numBlocks * PATH_DIRECTION_VERTICES); } break; @@ -92,14 +141,6 @@ return bvo; } -// PF and PE flags -static const unsigned int PATHOPT_START = 16; -static const unsigned int PATHOPT_OPEN = 32; -static const unsigned int PATHOPT_CLOSED = 64; -static const unsigned int PATHOPT_FORBIDDEN = 128; -static const unsigned int PATHOPT_BLOCKED = 256; -static const unsigned int PATHOPT_OBSOLETE = 512; - enum { NODE_COST_F = 0, NODE_COST_G = 1, diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathDataTypes.h spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathDataTypes.h --- spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathDataTypes.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathDataTypes.h 2014-10-07 20:09:51.000000000 +0000 @@ -66,12 +66,10 @@ PathNodeStateBuffer(const int2& bufRes, const int2& mapRes) : extraCostsOverlaySynced(NULL) , extraCostsOverlayUnsynced(NULL) + , ps(mapRes / bufRes) , br(bufRes) , mr(mapRes) { - ps.x = mapRes.x / bufRes.x; - ps.y = mapRes.y / bufRes.y; - fCost.resize(br.x * br.y, PATHCOST_INFINITY); gCost.resize(br.x * br.y, PATHCOST_INFINITY); nodeMask.resize(br.x * br.y, 0); @@ -81,9 +79,8 @@ //extraCostUnsynced.resize(br.x * br.y, 0.0f); // Note: Full resolution buffer does not need those! - if (bufRes.x != mapRes.x || bufRes.y != mapRes.y) { - peParentNodePos.resize(br.x * br.y, int2(-1, -1)); - peNodeOffsets.resize(br.x * br.y); + if (bufRes != mapRes) { + //peNodeOffsets.resize(); is done in PathEstimator } maxCosts[NODE_COST_F] = 0.0f; @@ -97,8 +94,7 @@ //assert(idx>=0 && idx fCost; std::vector gCost; - /// combination of PATHOPT_{OPEN, ..., OBSOLETE} flags - std::vector nodeMask; - - /// needed for the PE to back-track path to goal - std::vector peParentNodePos; + /// bitmask of PATHOPT_{OPEN, ..., OBSOLETE} flags + std::vector nodeMask; + static_assert(PATHOPT_SIZE <= std::numeric_limits::max(), "nodeMask basic type to small to hold bitmask of PATHOPT"); - /// for the PE, each node (block) maintains the + /// for the PE, maintains an array of the /// best accessible offset (from its own center - /// position) with respect to each movetype + /// position) + /// peNodeOffsets[pathType][blockIdx] std::vector< std::vector > peNodeOffsets; private: diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathEstimator.cpp spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathEstimator.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathEstimator.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathEstimator.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,21 +7,18 @@ #include #include #include +#include #include "minizip/zip.h" -#include "PathAllocator.h" -#include "PathCache.h" #include "PathFinder.h" #include "PathFinderDef.h" #include "PathFlowMap.hpp" #include "PathLog.h" -#include "Map/ReadMap.h" #include "Game/LoadScreen.h" +#include "Sim/Misc/ModInfo.h" #include "Sim/MoveTypes/MoveDefHandler.h" #include "Sim/MoveTypes/MoveMath/MoveMath.h" -#include "Sim/Units/Unit.h" -#include "Sim/Units/UnitDef.h" #include "Net/Protocol/NetProtocol.h" #include "System/ThreadPool.h" #include "System/TimeProfiler.h" @@ -31,72 +28,47 @@ #include "System/FileSystem/DataDirsAccess.h" #include "System/FileSystem/FileSystem.h" #include "System/FileSystem/FileQueryFlags.h" -#include "System/Platform/Watchdog.h" CONFIG(int, MaxPathCostsMemoryFootPrint).defaultValue(512).minimumValue(64).description("Maximum memusage (in MByte) of mutlithreaded pathcache generator at loading time."); + + static const std::string GetPathCacheDir() { return (FileSystem::GetCacheDir() + "/paths/"); } static size_t GetNumThreads() { const size_t numThreads = std::max(0, configHandler->GetInt("PathingThreadCount")); - const size_t numCores = Threading::GetAvailableCores(); + const size_t numCores = Threading::GetLogicalCpuCores(); return ((numThreads == 0)? numCores: numThreads); } -void* CPathEstimator::operator new(size_t size) { return PathAllocator::Alloc(size); } -void CPathEstimator::operator delete(void* p, size_t size) { PathAllocator::Free(p, size); } - -CPathEstimator::CPathEstimator(CPathFinder* pf, unsigned int BSIZE, const std::string& cacheFileName, const std::string& mapFileName): - BLOCK_SIZE(BSIZE), - BLOCK_PIXEL_SIZE(BSIZE * SQUARE_SIZE), - BLOCKS_TO_UPDATE(SQUARES_TO_UPDATE / (BLOCK_SIZE * BLOCK_SIZE) + 1), - nbrOfBlocksX(gs->mapx / BLOCK_SIZE), - nbrOfBlocksZ(gs->mapy / BLOCK_SIZE), - - nextOffsetMessageIdx(0), - nextCostMessageIdx(0), - pathChecksum(0), - offsetBlockNum(nbrOfBlocksX * nbrOfBlocksZ), - costBlockNum(nbrOfBlocksX * nbrOfBlocksZ), - blockStates(int2(nbrOfBlocksX, nbrOfBlocksZ), int2(gs->mapx, gs->mapy)), - - mStartBlockIdx(0), - mGoalHeuristic(0.0f), - blockUpdatePenalty(0) +CPathEstimator::CPathEstimator(IPathFinder* pf, unsigned int BLOCK_SIZE, const std::string& cacheFileName, const std::string& mapFileName) + : IPathFinder(BLOCK_SIZE) + , BLOCKS_TO_UPDATE(SQUARES_TO_UPDATE / (BLOCK_SIZE * BLOCK_SIZE) + 1) + , nextOffsetMessageIdx(0) + , nextCostMessageIdx(0) + , pathChecksum(0) + , offsetBlockNum(nbrOfBlocks.x * nbrOfBlocks.y) + , costBlockNum(nbrOfBlocks.x * nbrOfBlocks.y) + , pathFinder(pf) + , nextPathEstimator(nullptr) + , blockUpdatePenalty(0) { - pathFinder = pf; - - // these give the changes in (x, z) coors - // when moving one step in given direction - // - // NOTE: the choices of +1 for LEFT and UP - // are not arbitrary (they are related to - // GetBlockVertexOffset) and also need to - // be consistent with the PATHOPT_* flags - // (because of PathDir2PathOpt) - directionVectors[PATHDIR_LEFT ] = int2(+1, 0); - directionVectors[PATHDIR_RIGHT ] = int2(-1, 0); - directionVectors[PATHDIR_UP ] = int2( 0, +1); - directionVectors[PATHDIR_DOWN ] = int2( 0, -1); - directionVectors[PATHDIR_LEFT_UP ] = int2(directionVectors[PATHDIR_LEFT ].x, directionVectors[PATHDIR_UP ].y); - directionVectors[PATHDIR_RIGHT_UP ] = int2(directionVectors[PATHDIR_RIGHT].x, directionVectors[PATHDIR_UP ].y); - directionVectors[PATHDIR_RIGHT_DOWN] = int2(directionVectors[PATHDIR_RIGHT].x, directionVectors[PATHDIR_DOWN].y); - directionVectors[PATHDIR_LEFT_DOWN ] = int2(directionVectors[PATHDIR_LEFT ].x, directionVectors[PATHDIR_DOWN].y); - - mGoalSqrOffset.x = BLOCK_SIZE >> 1; - mGoalSqrOffset.y = BLOCK_SIZE >> 1; - vertexCosts.resize(moveDefHandler->GetNumMoveDefs() * blockStates.GetSize() * PATH_DIRECTION_VERTICES, PATHCOST_INFINITY); + if (dynamic_cast(pf) != nullptr) { + dynamic_cast(pf)->nextPathEstimator = this; + } + // load precalculated data if it exists InitEstimator(cacheFileName, mapFileName); } + CPathEstimator::~CPathEstimator() { delete pathCache[0]; pathCache[0] = NULL; @@ -104,6 +76,11 @@ } +const int2* CPathEstimator::GetDirectionVectorsTable() { + return (&PE_DIRECTION_VECTORS[0]); +} + + void CPathEstimator::InitEstimator(const std::string& cacheFileName, const std::string& map) { const unsigned int numThreads = GetNumThreads(); @@ -113,7 +90,8 @@ pathFinders.resize(numThreads); } - pathFinders[0] = pathFinder; + // always use PF for initialization, later PE maybe used + pathFinders[0] = new CPathFinder(); // Not much point in multithreading these... InitBlocks(); @@ -123,7 +101,7 @@ // memory-footprint made by CPathFinder instances within bounds const unsigned int minMemFootPrint = sizeof(CPathFinder) + pathFinder->GetMemFootPrint(); const unsigned int maxMemFootPrint = configHandler->GetInt("MaxPathCostsMemoryFootPrint") * 1024 * 1024; - const unsigned int numExtraThreads = std::min(int(numThreads - 1), std::max(0, int(maxMemFootPrint / minMemFootPrint) - 1)); + const unsigned int numExtraThreads = Clamp(int(maxMemFootPrint / minMemFootPrint) - 1, 0, int(numThreads) - 1); const unsigned int reqMemFootPrint = minMemFootPrint * (numExtraThreads + 1); { @@ -160,31 +138,31 @@ loadscreen->SetLoadMessage("PathCosts: written", true); } - pathCache[0] = new CPathCache(nbrOfBlocksX, nbrOfBlocksZ); - pathCache[1] = new CPathCache(nbrOfBlocksX, nbrOfBlocksZ); -} - + // switch to runtime wanted IPathFinder (maybe PF or PE) + delete pathFinders[0]; + pathFinders[0] = pathFinder; + pathCache[0] = new CPathCache(nbrOfBlocks.x, nbrOfBlocks.y); + pathCache[1] = new CPathCache(nbrOfBlocks.x, nbrOfBlocks.y); +} -void CPathEstimator::InitBlocks() { - for (unsigned int idx = 0; idx < blockStates.GetSize(); idx++) { - const unsigned int blockX = idx % nbrOfBlocksX; - const unsigned int blockZ = idx / nbrOfBlocksX; - const unsigned int blockNr = blockZ * nbrOfBlocksX + blockX; - blockStates.peNodeOffsets[blockNr].resize(moveDefHandler->GetNumMoveDefs()); +void CPathEstimator::InitBlocks() +{ + blockStates.peNodeOffsets.resize(moveDefHandler->GetNumMoveDefs()); + for (unsigned int idx = 0; idx < moveDefHandler->GetNumMoveDefs(); idx++) { + blockStates.peNodeOffsets[idx].resize(nbrOfBlocks.x * nbrOfBlocks.y); } } __FORCE_ALIGN_STACK__ -void CPathEstimator::CalcOffsetsAndPathCosts(unsigned int threadNum) { +void CPathEstimator::CalcOffsetsAndPathCosts(unsigned int threadNum) +{ // reset FPU state for synced computations streflop::streflop_init(); if (threadNum > 0) { - // FIXME: not running any thread on core 0 is a big perf-hit - // Threading::SetAffinity(1 << threadNum); Threading::SetAffinity(~0); Threading::SetThreadName(IntToString(threadNum, "pathhelper%i")); } @@ -208,8 +186,7 @@ void CPathEstimator::CalculateBlockOffsets(unsigned int blockIdx, unsigned int threadNum) { - const unsigned int x = blockIdx % nbrOfBlocksX; - const unsigned int z = blockIdx / nbrOfBlocksX; + const int2 blockPos = BlockIdxToPos(blockIdx); if (threadNum == 0 && blockIdx >= nextOffsetMessageIdx) { nextOffsetMessageIdx = blockIdx + blockStates.GetSize() / 16; @@ -217,16 +194,18 @@ } for (unsigned int i = 0; i < moveDefHandler->GetNumMoveDefs(); i++) { - MoveDef* md = moveDefHandler->GetMoveDefByPathType(i); + const MoveDef* md = moveDefHandler->GetMoveDefByPathType(i); + if (md->udRefCount > 0) { - blockStates.peNodeOffsets[blockIdx][md->pathType] = FindOffset(*md, x, z); + blockStates.peNodeOffsets[md->pathType][blockIdx] = FindOffset(*md, blockPos.x, blockPos.y); } } } -void CPathEstimator::EstimatePathCosts(unsigned int blockIdx, unsigned int threadNum) { - const unsigned int x = blockIdx % nbrOfBlocksX; - const unsigned int z = blockIdx / nbrOfBlocksX; + +void CPathEstimator::EstimatePathCosts(unsigned int blockIdx, unsigned int threadNum) +{ + const int2 blockPos = BlockIdxToPos(blockIdx); if (threadNum == 0 && blockIdx >= nextCostMessageIdx) { nextCostMessageIdx = blockIdx + blockStates.GetSize() / 16; @@ -239,22 +218,20 @@ } for (unsigned int i = 0; i < moveDefHandler->GetNumMoveDefs(); i++) { - MoveDef* md = moveDefHandler->GetMoveDefByPathType(i); + const MoveDef* md = moveDefHandler->GetMoveDefByPathType(i); + if (md->udRefCount > 0) { - CalculateVertices(*md, x, z, threadNum); + CalculateVertices(*md, blockPos, threadNum); } } } - - - - /** * Finds a square accessable by the given MoveDef within the given block */ -int2 CPathEstimator::FindOffset(const MoveDef& moveDef, unsigned int blockX, unsigned int blockZ) { +int2 CPathEstimator::FindOffset(const MoveDef& moveDef, unsigned int blockX, unsigned int blockZ) const +{ // lower corner position of block const unsigned int lowerX = blockX * BLOCK_SIZE; const unsigned int lowerZ = blockZ * BLOCK_SIZE; @@ -265,21 +242,16 @@ float bestCost = std::numeric_limits::max(); float speedMod = CMoveMath::GetPosSpeedMod(moveDef, lowerX, lowerZ); - bool curblock = (speedMod == 0.0f) || CMoveMath::IsBlockedStructure(moveDef, lowerX, lowerZ, NULL); // search for an accessible position within this block - unsigned int x = 0; - unsigned int z = 0; - - while (z < BLOCK_SIZE) { + for (unsigned int z = 0; z < BLOCK_SIZE; ++z) { bool zcurblock = curblock; - while (x < BLOCK_SIZE) { + for (unsigned int x = 0; x < BLOCK_SIZE; ++x) { if (!curblock) { const float dx = x - (float)(BLOCK_SIZE - 1) / 2.0f; const float dz = z - (float)(BLOCK_SIZE - 1) / 2.0f; - const float cost = (dx * dx + dz * dz) + (blockArea / (0.001f + speedMod)); if (cost < bestCost) { @@ -294,17 +266,12 @@ curblock = (speedMod == 0.0f) || (curblock ? CMoveMath::IsBlockedStructure(moveDef, lowerX + x, lowerZ + z, NULL) : CMoveMath::IsBlockedStructureXmax(moveDef, lowerX + x, lowerZ + z, NULL)); - - x += 1; } speedMod = CMoveMath::GetPosSpeedMod(moveDef, lowerX, lowerZ + z); curblock = (speedMod == 0.0f) || (zcurblock ? CMoveMath::IsBlockedStructure(moveDef, lowerX, lowerZ + z, NULL) : CMoveMath::IsBlockedStructureZmax(moveDef, lowerX, lowerZ + z, NULL)); - - x = 0; - z += 1; } // return the offset found @@ -314,11 +281,14 @@ /** * Calculate all vertices connected from the given block - * (always 4 out of 8 vertices connected to the block) */ -void CPathEstimator::CalculateVertices(const MoveDef& moveDef, unsigned int blockX, unsigned int blockZ, unsigned int thread) { - for (unsigned int dir = 0; dir < PATH_DIRECTION_VERTICES; dir++) - CalculateVertex(moveDef, blockX, blockZ, dir, thread); +void CPathEstimator::CalculateVertices(const MoveDef& moveDef, int2 block, unsigned int thread) +{ + // see code comment of GetBlockVertexOffset() for more info why those directions are choosen + CalculateVertex(moveDef, block, PATHDIR_LEFT, thread); + CalculateVertex(moveDef, block, PATHDIR_LEFT_UP, thread); + CalculateVertex(moveDef, block, PATHDIR_UP, thread); + CalculateVertex(moveDef, block, PATHDIR_RIGHT_UP, thread); } @@ -327,109 +297,95 @@ */ void CPathEstimator::CalculateVertex( const MoveDef& moveDef, - unsigned int parentBlockX, - unsigned int parentBlockZ, + int2 parentBlock, unsigned int direction, unsigned int threadNum) { - const unsigned int childBlockX = parentBlockX + directionVectors[direction].x; - const unsigned int childBlockZ = parentBlockZ + directionVectors[direction].y; - - const unsigned int parentBlockNbr = parentBlockZ * nbrOfBlocksX + parentBlockX; + const int2 childBlock = parentBlock + PE_DIRECTION_VECTORS[direction]; + const unsigned int parentBlockNbr = BlockPosToIdx(parentBlock); + const unsigned int childBlockNbr = BlockPosToIdx(childBlock); const unsigned int vertexNbr = moveDef.pathType * blockStates.GetSize() * PATH_DIRECTION_VERTICES + parentBlockNbr * PATH_DIRECTION_VERTICES + direction; // outside map? - if (childBlockX >= nbrOfBlocksX || childBlockZ >= nbrOfBlocksZ) { + if ((unsigned)childBlock.x >= nbrOfBlocks.x || (unsigned)childBlock.y >= nbrOfBlocks.y) { vertexCosts[vertexNbr] = PATHCOST_INFINITY; return; } - // start position - const int2 parentSquare = blockStates.peNodeOffsets[parentBlockNbr][moveDef.pathType]; + // start position within parent block + const int2 parentSquare = blockStates.peNodeOffsets[moveDef.pathType][parentBlockNbr]; - // goal position - const int childBlockNbr = childBlockZ * nbrOfBlocksX + childBlockX; - const int2 childSquare = blockStates.peNodeOffsets[childBlockNbr][moveDef.pathType]; - - const float3& startPos = SquareToFloat3(parentSquare.x, parentSquare.y); - const float3& goalPos = SquareToFloat3(childSquare.x, childSquare.y); - - // PathFinder definition - CRangedGoalWithCircularConstraint pfDef(startPos, goalPos, 0, 1.1f, 2); + // goal position within child block + const int2 childSquare = blockStates.peNodeOffsets[moveDef.pathType][childBlockNbr]; + const float3 startPos = SquareToFloat3(parentSquare.x, parentSquare.y); + const float3 goalPos = SquareToFloat3(childSquare.x, childSquare.y); + + // keep search exactly contained within the two blocks + CRectangularSearchConstraint pfDef(startPos, goalPos, BLOCK_SIZE); + + // we never want to allow searches from + // any blocked starting positions (otherwise PE and PF can disagree) + // note: PE itself should ensure this never happens to begin with? + // + // be more lenient for normal searches so players can "unstuck" units + // + // blocked goal positions are always early-outs (no searching needed) + const bool strtBlocked = ((CMoveMath::IsBlocked(moveDef, startPos, nullptr) & CMoveMath::BLOCK_STRUCTURE) != 0); + const bool goalBlocked = pfDef.IsGoalBlocked(moveDef, CMoveMath::BLOCK_STRUCTURE, nullptr); + if (strtBlocked || goalBlocked) { + vertexCosts[vertexNbr] = PATHCOST_INFINITY; + return; + } - // the path to find + // find path from parent to child block + // + // since CPathFinder::GetPath() is not thread-safe, use + // this thread's "private" CPathFinder instance (rather + // than locking pathFinder->GetPath()) if we are in one + pfDef.testMobile = false; + pfDef.needPath = false; + pfDef.exactPath = true; + pfDef.dirIndependent = true; IPath::Path path; - IPath::SearchResult result; - - // since CPathFinder::GetPath() is not thread-safe, - // use this thread's "private" CPathFinder instance - // (rather than locking pathFinder->GetPath()) if we - // are in one - result = pathFinders[threadNum]->GetPath(moveDef, pfDef, NULL, startPos, path, MAX_SEARCHED_NODES_PF >> 2, false, true, false, true); + IPath::SearchResult result = pathFinders[threadNum]->GetPath(moveDef, pfDef, nullptr, startPos, path, MAX_SEARCHED_NODES_PF >> 2); // store the result - if (result == IPath::Ok) + if (result == IPath::Ok) { vertexCosts[vertexNbr] = path.pathCost; - else + } else { vertexCosts[vertexNbr] = PATHCOST_INFINITY; + } } /** * Mark affected blocks as obsolete */ -void CPathEstimator::MapChanged(unsigned int x1, unsigned int z1, unsigned int x2, unsigned z2) { +void CPathEstimator::MapChanged(unsigned int x1, unsigned int z1, unsigned int x2, unsigned z2) +{ // find the upper and lower corner of the rectangular area - int lowerX, upperX; - int lowerZ, upperZ; - - if (x1 < x2) { - lowerX = (x1 / BLOCK_SIZE) - 1; - upperX = (x2 / BLOCK_SIZE); - } else { - lowerX = (x2 / BLOCK_SIZE) - 1; - upperX = (x1 / BLOCK_SIZE); - } - if (z1 < z2) { - lowerZ = (z1 / BLOCK_SIZE) - 1; - upperZ = (z2 / BLOCK_SIZE); - } else { - lowerZ = (z2 / BLOCK_SIZE) - 1; - upperZ = (z1 / BLOCK_SIZE); - } - - // error-check - upperX = std::min(upperX, int(nbrOfBlocksX - 1)); - upperZ = std::min(upperZ, int(nbrOfBlocksZ - 1)); - lowerX = std::max(lowerX, 0 ); - lowerZ = std::max(lowerZ, 0 ); + const auto mmx = std::minmax(x1, x2); + const auto mmz = std::minmax(z1, z2); + const int lowerX = Clamp(int(mmx.first / BLOCK_SIZE) - 1, 0, int(nbrOfBlocks.x - 1)); + const int upperX = Clamp(int(mmx.second / BLOCK_SIZE) + 1, 0, int(nbrOfBlocks.x - 1)); + const int lowerZ = Clamp(int(mmz.first / BLOCK_SIZE) - 1, 0, int(nbrOfBlocks.y - 1)); + const int upperZ = Clamp(int(mmz.second / BLOCK_SIZE) + 1, 0, int(nbrOfBlocks.y - 1)); // mark the blocks inside the rectangle, enqueue them // from upper to lower because of the placement of the // bi-directional vertices for (int z = upperZ; z >= lowerZ; z--) { for (int x = upperX; x >= lowerX; x--) { - if (!(blockStates.nodeMask[z * nbrOfBlocksX + x] & PATHOPT_OBSOLETE)) { - std::vector::iterator mi; - - for (unsigned int i = 0; i < moveDefHandler->GetNumMoveDefs(); i++) { - const MoveDef* md = moveDefHandler->GetMoveDefByPathType(i); + const int idx = BlockPosToIdx(int2(x,z)); + if ((blockStates.nodeMask[idx] & PATHOPT_OBSOLETE) != 0) + continue; - if (md->udRefCount > 0) { - SingleBlock sb; - sb.blockPos.x = x; - sb.blockPos.y = z; - sb.moveDef = md; - - updatedBlocks.push_back(sb); - blockStates.nodeMask[z * nbrOfBlocksX + x] |= PATHOPT_OBSOLETE; - } - } - } + updatedBlocks.emplace_back(x, z); + blockStates.nodeMask[idx] |= PATHOPT_OBSOLETE; } } } @@ -438,256 +394,136 @@ /** * Update some obsolete blocks using the FIFO-principle */ -void CPathEstimator::Update() { +void CPathEstimator::Update() +{ pathCache[0]->Update(); pathCache[1]->Update(); - static const unsigned int MIN_BLOCKS_TO_UPDATE = std::max(BLOCKS_TO_UPDATE >> 1, 4U); - static const unsigned int MAX_BLOCKS_TO_UPDATE = std::min(BLOCKS_TO_UPDATE << 1, MIN_BLOCKS_TO_UPDATE); - const unsigned int progressiveUpdates = updatedBlocks.size() * 0.007f * ((BLOCK_SIZE >= 16)? 1.0f : 0.6f); - const unsigned int blocksToUpdate = Clamp(progressiveUpdates, MIN_BLOCKS_TO_UPDATE, MAX_BLOCKS_TO_UPDATE); + const auto numMoveDefs = moveDefHandler->GetNumMoveDefs(); + + // determine how many blocks we should update + int blocksToUpdate = 0; + int consumeBlocks = 0; + { + const int progressiveUpdates = updatedBlocks.size() * numMoveDefs * modInfo.pfUpdateRate; + const int MIN_BLOCKS_TO_UPDATE = std::max(BLOCKS_TO_UPDATE >> 1, 4U); + const int MAX_BLOCKS_TO_UPDATE = std::max(BLOCKS_TO_UPDATE << 1, MIN_BLOCKS_TO_UPDATE); + blocksToUpdate = Clamp(progressiveUpdates, MIN_BLOCKS_TO_UPDATE, MAX_BLOCKS_TO_UPDATE); + + blockUpdatePenalty = std::max(0, blockUpdatePenalty - blocksToUpdate); + + if (blockUpdatePenalty > 0) + blocksToUpdate = std::max(0, blocksToUpdate - blockUpdatePenalty); - blockUpdatePenalty = std::max(0, blockUpdatePenalty - int(blocksToUpdate)); + // we have to update blocks for all movedefs (cause PATHOPT_OBSOLETE is per block and not movedef) + consumeBlocks = int(progressiveUpdates != 0) * int(ceil(float(blocksToUpdate) / numMoveDefs)) * numMoveDefs; - if (blockUpdatePenalty >= blocksToUpdate) + blockUpdatePenalty += consumeBlocks; + } + + if (blocksToUpdate == 0) return; if (updatedBlocks.empty()) return; - std::vector v; - v.reserve(blocksToUpdate); + struct SingleBlock { + int2 blockPos; + const MoveDef* moveDef; + SingleBlock(const int2& pos, const MoveDef* md) : blockPos(pos), moveDef(md) {} + }; + std::vector consumedBlocks; + consumedBlocks.reserve(consumeBlocks); - // CalculateVertices (not threadsafe) - for (unsigned int n = 0; !updatedBlocks.empty() && n < blocksToUpdate; ) { - // copy the next block in line - const SingleBlock sb = updatedBlocks.front(); - updatedBlocks.pop_front(); - - // check if it's not already updated - if (blockStates.nodeMask[sb.blockPos.y * nbrOfBlocksX + sb.blockPos.x] & PATHOPT_OBSOLETE) { - // no need to check for duplicates, cause FindOffset is deterministic - // and so even when we compute it multiple times the result will be the same - v.push_back(sb); - - // always process all movedefs of a square in one rush - // needed cause blockStates.nodeMask saves PATHOPT_OBSOLETE just for the square and not the movedefs - // if we wouldn't process them in one rush, it could happen that square changes are missed for `lower` movdefs - for (auto it = updatedBlocks.begin(), E = updatedBlocks.end(); it != E; ++it) { - if ((it->blockPos.x == sb.blockPos.x) && (it->blockPos.y == sb.blockPos.y)) { - v.push_back(sb); - n++; - } else { - updatedBlocks.erase(updatedBlocks.begin(), ++it); - break; - } - } + // get blocks to update + while (!updatedBlocks.empty()) { + int2& pos = updatedBlocks.front(); + const int idx = BlockPosToIdx(pos); - // one stale SingleBlock consumed - n++; + if ((blockStates.nodeMask[idx] & PATHOPT_OBSOLETE) == 0) { + updatedBlocks.pop_front(); + continue; } - } - blockUpdatePenalty += std::max(0, int(v.size()) - int(blocksToUpdate)); + if (consumedBlocks.size() >= blocksToUpdate) { + break; + } + + // issue repathing for all active movedefs + for (unsigned int i = 0; i < numMoveDefs; i++) { + const MoveDef* md = moveDefHandler->GetMoveDefByPathType(i); + if (md->udRefCount > 0) + consumedBlocks.emplace_back(pos, md); + } + + // inform dependent pathEstimator that we change vertex cost of those blocks + if (nextPathEstimator) + nextPathEstimator->MapChanged(pos.x * BLOCK_SIZE, pos.y * BLOCK_SIZE, pos.x * BLOCK_SIZE, pos.y * BLOCK_SIZE); + + updatedBlocks.pop_front(); // must happen _after_ last usage of the `pos` reference! + blockStates.nodeMask[idx] &= ~PATHOPT_OBSOLETE; + } // FindOffset (threadsafe) { SCOPED_TIMER("CPathEstimator::FindOffset"); - for_mt(0, v.size(), [&](const int n) { + for_mt(0, consumedBlocks.size(), [&](const int n) { // copy the next block in line - const SingleBlock sb = v[n]; - - const unsigned int blockX = sb.blockPos.x; - const unsigned int blockZ = sb.blockPos.y; - const unsigned int blockN = blockZ * nbrOfBlocksX + blockX; - + const SingleBlock sb = consumedBlocks[n]; + const int blockN = BlockPosToIdx(sb.blockPos); const MoveDef* currBlockMD = sb.moveDef; - - blockStates.peNodeOffsets[blockN][currBlockMD->pathType] = FindOffset(*currBlockMD, blockX, blockZ); + blockStates.peNodeOffsets[currBlockMD->pathType][blockN] = FindOffset(*currBlockMD, sb.blockPos.x, sb.blockPos.y); }); } // CalculateVertices (not threadsafe) { SCOPED_TIMER("CPathEstimator::CalculateVertices"); - for (unsigned int n = 0; n < v.size(); ++n) { + for (unsigned int n = 0; n < consumedBlocks.size(); ++n) { // copy the next block in line - const SingleBlock sb = v[n]; - - const unsigned int blockX = sb.blockPos.x; - const unsigned int blockZ = sb.blockPos.y; - const unsigned int blockN = blockZ * nbrOfBlocksX + blockX; - - const MoveDef* currBlockMD = sb.moveDef; - const MoveDef* nextBlockMD = NULL; - if ((n + 1) < v.size()) { - nextBlockMD = v[n + 1].moveDef; - } - - CalculateVertices(*currBlockMD, blockX, blockZ); - - // each MapChanged() call adds AT MOST SingleBlock's - // in ascending pathType order per (x, z) PE-block, therefore when the - // next SingleBlock's pathType is less or equal to the current we know - // that all have been processed (for one PE-block) - if (nextBlockMD == NULL || nextBlockMD->pathType <= currBlockMD->pathType) { - blockStates.nodeMask[blockN] &= ~PATHOPT_OBSOLETE; - } + const SingleBlock sb = consumedBlocks[n]; + CalculateVertices(*sb.moveDef, sb.blockPos); } } } -void CPathEstimator::UpdateFull() { - while (!updatedBlocks.empty()) { - Update(); - Watchdog::ClearTimer(); - } -} - - -/** - * Stores data and does some top-administration - */ -IPath::SearchResult CPathEstimator::GetPath( - const MoveDef& moveDef, - const CPathFinderDef& peDef, - float3 start, - IPath::Path& path, - unsigned int maxSearchedBlocks, - bool synced -) { - start.ClampInBounds(); - - // clear the path - path.path.clear(); - path.pathCost = PATHCOST_INFINITY; - - // initial calculations - maxBlocksToBeSearched = std::min(maxSearchedBlocks, MAX_SEARCHED_NODES_PE - 8U); - - int2 startBlock; - startBlock.x = start.x / BLOCK_PIXEL_SIZE; - startBlock.y = start.z / BLOCK_PIXEL_SIZE; - int2 goalBlock; - goalBlock.x = peDef.goalSquareX / BLOCK_SIZE; - goalBlock.y = peDef.goalSquareZ / BLOCK_SIZE; - - mStartBlock = startBlock; - mStartBlockIdx = startBlock.y * nbrOfBlocksX + startBlock.x; - - const CPathCache::CacheItem* ci = pathCache[synced]->GetCachedPath(startBlock, goalBlock, peDef.sqGoalRadius, moveDef.pathType); - - if (ci != NULL) { - // use a cached path if we have one - path = ci->path; - return ci->result; - } - - // oterhwise search - const IPath::SearchResult result = InitSearch(moveDef, peDef, synced); - - // if search successful, generate new path - if (result == IPath::Ok || result == IPath::GoalOutOfRange) { - FinishSearch(moveDef, path); - - if (result == IPath::Ok) { - // add succesful paths to the cache - pathCache[synced]->AddPath(&path, result, startBlock, goalBlock, peDef.sqGoalRadius, moveDef.pathType); - } - - if (LOG_IS_ENABLED(L_DEBUG)) { - LOG_L(L_DEBUG, "PE: Search completed."); - LOG_L(L_DEBUG, "Tested blocks: %u", testedBlocks); - LOG_L(L_DEBUG, "Open blocks: %u", openBlockBuffer.GetSize()); - LOG_L(L_DEBUG, "Path length: " _STPF_, path.path.size()); - LOG_L(L_DEBUG, "Path cost: %f", path.pathCost); - } - } else { - if (LOG_IS_ENABLED(L_DEBUG)) { - LOG_L(L_DEBUG, "PE: Search failed!"); - LOG_L(L_DEBUG, "Tested blocks: %u", testedBlocks); - LOG_L(L_DEBUG, "Open blocks: %u", openBlockBuffer.GetSize()); - } - } - - return result; +const CPathCache::CacheItem* CPathEstimator::GetCache(const int2 strtBlock, const int2 goalBlock, float goalRadius, int pathType, const bool synced) const +{ + return pathCache[synced]->GetCachedPath(strtBlock, goalBlock, goalRadius, pathType); } -// set up the starting point of the search -IPath::SearchResult CPathEstimator::InitSearch(const MoveDef& moveDef, const CPathFinderDef& peDef, bool synced) { - const int2 square = blockStates.peNodeOffsets[mStartBlockIdx][moveDef.pathType]; - const bool isStartGoal = peDef.IsGoal(square.x, square.y); - - // although our starting square may be inside the goal radius, the starting coordinate may be outside. - // in this case we do not want to return CantGetCloser, but instead a path to our starting square. - if (isStartGoal && peDef.startInGoalRadius) - return IPath::CantGetCloser; - - // no, clean the system from last search - ResetSearch(); - - // mark and store the start-block - blockStates.nodeMask[mStartBlockIdx] |= PATHOPT_OPEN; - blockStates.fCost[mStartBlockIdx] = 0.0f; - blockStates.gCost[mStartBlockIdx] = 0.0f; - blockStates.SetMaxCost(NODE_COST_F, 0.0f); - blockStates.SetMaxCost(NODE_COST_G, 0.0f); - - dirtyBlocks.push_back(mStartBlockIdx); - - openBlockBuffer.SetSize(0); - // add the starting block to the open-blocks-queue - PathNode* ob = openBlockBuffer.GetNode(openBlockBuffer.GetSize()); - ob->fCost = 0.0f; - ob->gCost = 0.0f; - ob->nodePos = mStartBlock; - ob->nodeNum = mStartBlockIdx; - openBlocks.push(ob); - - // mark starting point as best found position - mGoalBlock = mStartBlock; - mGoalHeuristic = peDef.Heuristic(square.x, square.y); - - // get the goal square offset - mGoalSqrOffset = peDef.GoalSquareOffset(BLOCK_SIZE); - - // perform the search - IPath::SearchResult result = DoSearch(moveDef, peDef, synced); - - // if no improvements are found, then return CantGetCloser instead - if (mGoalBlock.x == mStartBlock.x && mGoalBlock.y == mStartBlock.y && (!isStartGoal || peDef.startInGoalRadius)) { - return IPath::CantGetCloser; - } - - return result; +void CPathEstimator::AddCache(const IPath::Path* path, const IPath::SearchResult result, const int2 strtBlock, const int2 goalBlock, float goalRadius, int pathType, const bool synced) +{ + pathCache[synced]->AddPath(path, result, strtBlock, goalBlock, goalRadius, pathType); } /** * Performs the actual search. */ -IPath::SearchResult CPathEstimator::DoSearch(const MoveDef& moveDef, const CPathFinderDef& peDef, bool synced) { +IPath::SearchResult CPathEstimator::DoSearch(const MoveDef& moveDef, const CPathFinderDef& peDef, const CSolidObject* owner) +{ bool foundGoal = false; + // get the goal square offset + const int2 goalSqrOffset = peDef.GoalSquareOffset(BLOCK_SIZE); + while (!openBlocks.empty() && (openBlockBuffer.GetSize() < maxBlocksToBeSearched)) { // get the open block with lowest cost PathNode* ob = const_cast(openBlocks.top()); openBlocks.pop(); // check if the block has been marked as unaccessible during its time in the queue - if (blockStates.nodeMask[ob->nodeNum] & (PATHOPT_BLOCKED | PATHOPT_CLOSED | PATHOPT_FORBIDDEN)) + if (blockStates.nodeMask[ob->nodeNum] & (PATHOPT_BLOCKED | PATHOPT_CLOSED)) continue; // no, check if the goal is already reached - const unsigned int xBSquare = blockStates.peNodeOffsets[ob->nodeNum][moveDef.pathType].x; - const unsigned int zBSquare = blockStates.peNodeOffsets[ob->nodeNum][moveDef.pathType].y; - const unsigned int xGSquare = ob->nodePos.x * BLOCK_SIZE + mGoalSqrOffset.x; - const unsigned int zGSquare = ob->nodePos.y * BLOCK_SIZE + mGoalSqrOffset.y; - - if (peDef.IsGoal(xBSquare, zBSquare) || peDef.IsGoal(xGSquare, zGSquare)) { - mGoalBlock = ob->nodePos; + const int2 bSquare = blockStates.peNodeOffsets[moveDef.pathType][ob->nodeNum]; + const int2 gSquare = ob->nodePos * BLOCK_SIZE + goalSqrOffset; + if (peDef.IsGoal(bSquare.x, bSquare.y) || peDef.IsGoal(gSquare.x, gSquare.y)) { + mGoalBlockIdx = ob->nodeNum; mGoalHeuristic = 0.0f; foundGoal = true; break; @@ -696,14 +532,14 @@ // no, test the 8 surrounding blocks // NOTE: each of these calls increments openBlockBuffer.idx by 1, so // maxBlocksToBeSearched is always less than - TestBlock(moveDef, peDef, *ob, PATHDIR_LEFT, synced); - TestBlock(moveDef, peDef, *ob, PATHDIR_LEFT_UP, synced); - TestBlock(moveDef, peDef, *ob, PATHDIR_UP, synced); - TestBlock(moveDef, peDef, *ob, PATHDIR_RIGHT_UP, synced); - TestBlock(moveDef, peDef, *ob, PATHDIR_RIGHT, synced); - TestBlock(moveDef, peDef, *ob, PATHDIR_RIGHT_DOWN, synced); - TestBlock(moveDef, peDef, *ob, PATHDIR_DOWN, synced); - TestBlock(moveDef, peDef, *ob, PATHDIR_LEFT_DOWN, synced); + TestBlock(moveDef, peDef, ob, owner, PATHDIR_LEFT, PATHOPT_OPEN, 1.f, true); + TestBlock(moveDef, peDef, ob, owner, PATHDIR_LEFT_UP, PATHOPT_OPEN, 1.f, true); + TestBlock(moveDef, peDef, ob, owner, PATHDIR_UP, PATHOPT_OPEN, 1.f, true); + TestBlock(moveDef, peDef, ob, owner, PATHDIR_RIGHT_UP, PATHOPT_OPEN, 1.f, true); + TestBlock(moveDef, peDef, ob, owner, PATHDIR_RIGHT, PATHOPT_OPEN, 1.f, true); + TestBlock(moveDef, peDef, ob, owner, PATHDIR_RIGHT_DOWN, PATHOPT_OPEN, 1.f, true); + TestBlock(moveDef, peDef, ob, owner, PATHDIR_DOWN, PATHOPT_OPEN, 1.f, true); + TestBlock(moveDef, peDef, ob, owner, PATHDIR_LEFT_DOWN, PATHOPT_OPEN, 1.f, true); // mark this block as closed blockStates.nodeMask[ob->nodeNum] |= PATHOPT_CLOSED; @@ -731,72 +567,79 @@ * Test the accessability of a block and its value, * possibly also add it to the open-blocks pqueue. */ -void CPathEstimator::TestBlock( +bool CPathEstimator::TestBlock( const MoveDef& moveDef, const CPathFinderDef& peDef, - PathNode& parentOpenBlock, - unsigned int pathDir, - bool synced + const PathNode* parentOpenBlock, + const CSolidObject* /*owner*/, + const unsigned int pathDir, + const unsigned int /*blockStatus*/, + float /*speedMod*/, + bool /*withinConstraints*/ ) { testedBlocks++; // initial calculations of the new block - int2 block; - block.x = parentOpenBlock.nodePos.x + directionVectors[pathDir].x; - block.y = parentOpenBlock.nodePos.y + directionVectors[pathDir].y; + const int2 block = parentOpenBlock->nodePos + PE_DIRECTION_VECTORS[pathDir]; + const unsigned int blockIdx = BlockPosToIdx(block); - const int vertexIdx = - moveDef.pathType * blockStates.GetSize() * PATH_DIRECTION_VERTICES + - parentOpenBlock.nodeNum * PATH_DIRECTION_VERTICES + - GetBlockVertexOffset(pathDir, nbrOfBlocksX); - const unsigned int blockIdx = block.y * nbrOfBlocksX + block.x; - - if (block.x < 0 || block.x >= nbrOfBlocksX || block.y < 0 || block.y >= nbrOfBlocksZ) { - // blocks should never be able to lie outside map - // (due to the infinite vertex-costs at the edges) - return; - } - - if (vertexIdx < 0 || vertexIdx >= vertexCosts.size()) - return; - - if (vertexCosts[vertexIdx] >= PATHCOST_INFINITY) - return; + // bounds-check + if ((unsigned)block.x >= nbrOfBlocks.x) return false; + if ((unsigned)block.y >= nbrOfBlocks.y) return false; // check if the block is unavailable - if (blockStates.nodeMask[blockIdx] & (PATHOPT_FORBIDDEN | PATHOPT_BLOCKED | PATHOPT_CLOSED)) - return; + if (blockStates.nodeMask[blockIdx] & (PATHOPT_BLOCKED | PATHOPT_CLOSED)) + return false; - const int2 square = blockStates.peNodeOffsets[blockIdx][moveDef.pathType]; + // read precached vertex costs + const unsigned int vertexIdx = + moveDef.pathType * blockStates.GetSize() * PATH_DIRECTION_VERTICES + + parentOpenBlock->nodeNum * PATH_DIRECTION_VERTICES + + GetBlockVertexOffset(pathDir, nbrOfBlocks.x); + assert((unsigned)vertexIdx < vertexCosts.size()); + if (vertexCosts[vertexIdx] >= PATHCOST_INFINITY) { + // warning: + // we cannot naively set PATHOPT_BLOCKED here + // cause vertexCosts[] depends on the direction and nodeMask doesn't + // so we would have to save the direction via PATHOPT_LEFT etc. in the nodeMask + // but that's complicated and not worth it. + // Performance gain is low, cause we would just save the vertexCosts[] lookup + //blockStates.nodeMask[blockIdx] |= (PathDir2PathOpt(pathDir) | PATHOPT_BLOCKED); + //dirtyBlocks.push_back(blockIdx); + return false; + } - // check if the block is blocked or out of constraints + // check if the block is out of constraints + const int2 square = blockStates.peNodeOffsets[moveDef.pathType][blockIdx]; if (!peDef.WithinConstraints(square.x, square.y)) { blockStates.nodeMask[blockIdx] |= PATHOPT_BLOCKED; dirtyBlocks.push_back(blockIdx); - return; + return false; } + // evaluate this node (NOTE the max-resolution indexing for {flow,extra}Cost) - const float flowCost = (PathFlowMap::GetInstance())->GetFlowCost(square.x, square.y, moveDef, PathDir2PathOpt(pathDir)); - const float extraCost = blockStates.GetNodeExtraCost(square.x, square.y, synced); - const float nodeCost = vertexCosts[vertexIdx] + flowCost + extraCost; + const float flowCost = (peDef.testMobile) ? (PathFlowMap::GetInstance())->GetFlowCost(square.x, square.y, moveDef, PathDir2PathOpt(pathDir)) : 0.0f; + const float extraCost = blockStates.GetNodeExtraCost(square.x, square.y, peDef.synced); + const float nodeCost = vertexCosts[vertexIdx] + flowCost + extraCost; - const float gCost = parentOpenBlock.gCost + nodeCost; + const float gCost = parentOpenBlock->gCost + nodeCost; const float hCost = peDef.Heuristic(square.x, square.y); const float fCost = gCost + hCost; - + // already in the open set? if (blockStates.nodeMask[blockIdx] & PATHOPT_OPEN) { - // already in the open set + // check if new found path is better or worse than the old one if (blockStates.fCost[blockIdx] <= fCost) - return; + return true; - blockStates.nodeMask[blockIdx] &= ~PATHOPT_AXIS_DIRS; + // no, clear old path data + blockStates.nodeMask[blockIdx] &= ~PATHOPT_CARDINALS; } // look for improvements if (hCost < mGoalHeuristic) { - mGoalBlock = block; + mGoalBlockIdx = blockIdx; mGoalHeuristic = hCost; } @@ -817,53 +660,47 @@ // mark this block as open blockStates.fCost[blockIdx] = fCost; blockStates.gCost[blockIdx] = gCost; - blockStates.nodeMask[blockIdx] |= (pathDir | PATHOPT_OPEN); - blockStates.peParentNodePos[blockIdx] = parentOpenBlock.nodePos; + blockStates.nodeMask[blockIdx] |= (PathDir2PathOpt(pathDir) | PATHOPT_OPEN); dirtyBlocks.push_back(blockIdx); + return true; } /** * Recreate the path taken to the goal */ -void CPathEstimator::FinishSearch(const MoveDef& moveDef, IPath::Path& foundPath) { - int2 block = mGoalBlock; - - while (block.x != mStartBlock.x || block.y != mStartBlock.y) { - const unsigned int blockIdx = block.y * nbrOfBlocksX + block.x; - - // use offset defined by the block - const int2 bsquare = blockStates.peNodeOffsets[blockIdx][moveDef.pathType]; - const float3& pos = SquareToFloat3(bsquare.x, bsquare.y); +IPath::SearchResult CPathEstimator::FinishSearch(const MoveDef& moveDef, const CPathFinderDef& pfDef, IPath::Path& foundPath) const +{ + // set some additional information + foundPath.pathCost = blockStates.fCost[mGoalBlockIdx] - mGoalHeuristic; - foundPath.path.push_back(pos); + if (pfDef.needPath) { + unsigned int blockIdx = mGoalBlockIdx; - // next step backwards - block = blockStates.peParentNodePos[blockIdx]; - } + while (true) { + // use offset defined by the block + const int2 square = blockStates.peNodeOffsets[moveDef.pathType][blockIdx]; + float3 pos(square.x * SQUARE_SIZE, 0.0f, square.y * SQUARE_SIZE); + pos.y = CMoveMath::yLevel(moveDef, square.x, square.y); - if (!foundPath.path.empty()) { - foundPath.pathGoal = foundPath.path.front(); - } + foundPath.path.push_back(pos); - // set some additional information - foundPath.pathCost = blockStates.fCost[mGoalBlock.y * nbrOfBlocksX + mGoalBlock.x] - mGoalHeuristic; -} + if (blockIdx == mStartBlockIdx) + break; + // next step backwards + auto pathDir = PathOpt2PathDir(blockStates.nodeMask[blockIdx] & PATHOPT_CARDINALS); + int2 blockPos = BlockIdxToPos(blockIdx) - PE_DIRECTION_VECTORS[pathDir]; + blockIdx = BlockPosToIdx(blockPos); + } -/** - * Clean lists from last search - */ -void CPathEstimator::ResetSearch() { - openBlocks.Clear(); - - while (!dirtyBlocks.empty()) { - blockStates.ClearSquare(dirtyBlocks.back()); - dirtyBlocks.pop_back(); + if (!foundPath.path.empty()) { + foundPath.pathGoal = foundPath.path.front(); + } } - testedBlocks = 0; + return IPath::Ok; } @@ -874,10 +711,10 @@ bool CPathEstimator::ReadFile(const std::string& cacheFileName, const std::string& map) { const unsigned int hash = Hash(); - char hashString[50]; + char hashString[64] = {0}; sprintf(hashString, "%u", hash); - LOG("[PathEstimator::%s] hash=%s\n", __FUNCTION__, hashString); + LOG("[PathEstimator::%s] hash=%s", __FUNCTION__, hashString); std::string filename = GetPathCacheDir() + map + hashString + "." + cacheFileName + ".zip"; if (!FileSystem::FileExists(filename)) @@ -908,19 +745,19 @@ if (buffer.size() < 4) return false; - unsigned filehash = *((unsigned*)&buffer[0]); + unsigned pos = 0; + unsigned filehash = *((unsigned*)&buffer[pos]); + pos += sizeof(unsigned); if (filehash != hash) return false; - unsigned pos = sizeof(unsigned); - // Read block-center-offset data. - const unsigned blockSize = moveDefHandler->GetNumMoveDefs() * sizeof(int2); - if (buffer.size() < pos + blockSize * blockStates.GetSize()) + const unsigned blockSize = blockStates.GetSize() * sizeof(int2); + if (buffer.size() < pos + blockSize * moveDefHandler->GetNumMoveDefs()) return false; - for (int blocknr = 0; blocknr < blockStates.GetSize(); blocknr++) { - std::memcpy(&blockStates.peNodeOffsets[blocknr][0], &buffer[pos], blockSize); + for (int pathType = 0; pathType < moveDefHandler->GetNumMoveDefs(); ++pathType) { + std::memcpy(&blockStates.peNodeOffsets[pathType][0], &buffer[pos], blockSize); pos += blockSize; } @@ -931,9 +768,9 @@ // File read successful. return true; - } else { - return false; } + + return false; } @@ -950,7 +787,7 @@ char hashString[64] = {0}; sprintf(hashString, "%u", hash); - LOG("[PathEstimator::%s] hash=%s\n", __FUNCTION__, hashString); + LOG("[PathEstimator::%s] hash=%s", __FUNCTION__, hashString); const std::string filename = GetPathCacheDir() + map + hashString + "." + cacheFileName + ".zip"; @@ -966,8 +803,8 @@ zipWriteInFileInZip(file, (void*) &hash, 4); // Write block-center-offsets. - for (int blocknr = 0; blocknr < blockStates.GetSize(); blocknr++) - zipWriteInFileInZip(file, (void*) &blockStates.peNodeOffsets[blocknr][0], moveDefHandler->GetNumMoveDefs() * sizeof(int2)); + for (int pathType = 0; pathType < moveDefHandler->GetNumMoveDefs(); ++pathType) + zipWriteInFileInZip(file, (void*) &blockStates.peNodeOffsets[pathType][0], blockStates.GetSize() * sizeof(int2)); // Write vertices. zipWriteInFileInZip(file, &vertexCosts[0], vertexCosts.size() * sizeof(float)); @@ -993,6 +830,7 @@ /** * Returns a hash-code identifying the dataset of this estimator. + * FIXME: uses checksum of raw heightmap (before Lua has seen it) */ unsigned int CPathEstimator::Hash() const { diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathEstimator.h spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathEstimator.h --- spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathEstimator.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathEstimator.h 2014-10-07 20:09:51.000000000 +0000 @@ -4,10 +4,11 @@ #define PATHESTIMATOR_H #include +#include #include -#include #include "IPath.h" +#include "IPathFinder.h" #include "PathConstants.h" #include "PathDataTypes.h" #include "System/float3.h" @@ -20,13 +21,15 @@ class CPathEstimatorDef; class CPathFinderDef; class CPathCache; +class CSolidObject; + namespace boost { class thread; class barrier; } -class CPathEstimator { +class CPathEstimator: public IPathFinder { public: /** * Creates a new estimator based on a couple of parameters @@ -42,49 +45,9 @@ * name of the corresponding map. * Ex. PE-name "pe" + Mapname "Desert" => "Desert.pe" */ - CPathEstimator(CPathFinder*, unsigned int BSIZE, const std::string& cacheFileName, const std::string& mapFileName); + CPathEstimator(IPathFinder*, unsigned int BSIZE, const std::string& cacheFileName, const std::string& mapFileName); ~CPathEstimator(); - void* operator new(size_t size); - void operator delete(void* p, size_t size); - - - - /** - * Returns an aproximate, low-resolution path from the starting location to - * the goal defined in CPathEstimatorDef, whenever any such are available. - * If no complete paths are found, then a path leading as "close" as - * possible to the goal is returned instead, together with - * SearchResult::OutOfRange. - * Only if no position closer to the goal than the starting location itself - * could be found, no path and SearchResult::CantGetCloser is returned. - * @param moveDef - * Defining the footprint of the unit to use the path. - * - * @param start - * The starting location of the search. - * - * @param peDef - * Object defining the goal of the search. - * Could also be used to add constraints to the search. - * - * @param path - * If a path could be found, it's generated and put into this structure. - * - * @param maxSearchedBlocks - * The maximum number of nodes/blocks the search is allowed to analyze. - * This restriction could be used in cases where CPU-consumption is - * critical. - */ - IPath::SearchResult GetPath( - const MoveDef& moveDef, - const CPathFinderDef& peDef, - float3 start, - IPath::Path& path, - unsigned int maxSearchedBlocks, - bool synced = true - ); - /** * This is called whenever the ground structure of the map changes @@ -94,12 +57,10 @@ */ void MapChanged(unsigned int x1, unsigned int z1, unsigned int x2, unsigned int z2); - /** * called every frame */ void Update(); - void UpdateFull(); /** * Returns a checksum that can be used to check if every player has the same @@ -107,11 +68,38 @@ */ boost::uint32_t GetPathChecksum() const { return pathChecksum; } - unsigned int GetBlockSize() const { return BLOCK_SIZE; } - unsigned int GetNumBlocksX() const { return nbrOfBlocksX; } - unsigned int GetNumBlocksZ() const { return nbrOfBlocksZ; } + static const int2* GetDirectionVectorsTable(); - PathNodeStateBuffer& GetNodeStateBuffer() { return blockStates; } +protected: // IPathFinder impl + IPath::SearchResult DoSearch(const MoveDef&, const CPathFinderDef&, const CSolidObject* owner); + bool TestBlock( + const MoveDef& moveDef, + const CPathFinderDef& pfDef, + const PathNode* parentSquare, + const CSolidObject* owner, + const unsigned int pathOptDir, + const unsigned int blockStatus, + float speedMod, + bool withinConstraints); + IPath::SearchResult FinishSearch(const MoveDef& moveDef, const CPathFinderDef& pfDef, IPath::Path& path) const; + + const CPathCache::CacheItem* GetCache( + const int2 strtBlock, + const int2 goalBlock, + float goalRadius, + int pathType, + const bool synced + ) const; + + void AddCache( + const IPath::Path* path, + const IPath::SearchResult result, + const int2 strtBlock, + const int2 goalBlock, + float goalRadius, + int pathType, + const bool synced + ); private: void InitEstimator(const std::string& cacheFileName, const std::string& map); @@ -121,15 +109,9 @@ void CalculateBlockOffsets(unsigned int, unsigned int); void EstimatePathCosts(unsigned int, unsigned int); - int2 FindOffset(const MoveDef&, unsigned int, unsigned int); - void CalculateVertices(const MoveDef&, unsigned int, unsigned int, unsigned int threadNum = 0); - void CalculateVertex(const MoveDef&, unsigned int, unsigned int, unsigned int, unsigned int threadNum = 0); - - IPath::SearchResult InitSearch(const MoveDef&, const CPathFinderDef&, bool); - IPath::SearchResult DoSearch(const MoveDef&, const CPathFinderDef&, bool); - void TestBlock(const MoveDef&, const CPathFinderDef&, PathNode&, unsigned int pathDir, bool synced); - void FinishSearch(const MoveDef& moveDef, IPath::Path& path); - void ResetSearch(); + int2 FindOffset(const MoveDef&, unsigned int, unsigned int) const; + void CalculateVertices(const MoveDef&, int2, unsigned int threadNum = 0); + void CalculateVertex(const MoveDef&, int2, unsigned int, unsigned int threadNum = 0); bool ReadFile(const std::string& cacheFileName, const std::string& map); void WriteFile(const std::string& cacheFileName, const std::string& map); @@ -139,22 +121,8 @@ friend class CPathManager; friend class CDefaultPathDrawer; - struct SingleBlock { - int2 blockPos; - const MoveDef* moveDef; - }; - - const unsigned int BLOCK_SIZE; - const unsigned int BLOCK_PIXEL_SIZE; const unsigned int BLOCKS_TO_UPDATE; - unsigned int nbrOfBlocksX; /// Number of blocks on the X axis of the map. - unsigned int nbrOfBlocksZ; /// Number of blocks on the Z axis of the map. - unsigned int moveMathOptions; - - unsigned int maxBlocksToBeSearched; - unsigned int testedBlocks; - unsigned int nextOffsetMessageIdx; unsigned int nextCostMessageIdx; @@ -164,27 +132,16 @@ boost::detail::atomic_count costBlockNum; boost::barrier* pathBarrier; - CPathFinder* pathFinder; + IPathFinder* pathFinder; CPathCache* pathCache[2]; /// [0] = !synced, [1] = synced - PathNodeBuffer openBlockBuffer; - PathNodeStateBuffer blockStates; - PathPriorityQueue openBlocks; /// The priority-queue used to select next block to be searched. - - std::vector pathFinders; + std::vector pathFinders; std::vector threads; - std::vector vertexCosts; - std::list dirtyBlocks; /// List of blocks changed in last search. - std::list updatedBlocks; /// Blocks that may need an update due to map changes. - - int2 directionVectors[PATH_DIRECTIONS]; - int2 mStartBlock; - int2 mGoalBlock; - int2 mGoalSqrOffset; + CPathEstimator* nextPathEstimator; - unsigned int mStartBlockIdx; - float mGoalHeuristic; + std::vector vertexCosts; + std::list updatedBlocks; /// Blocks that may need an update due to map changes. int blockUpdatePenalty; }; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathFinder.cpp spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathFinder.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathFinder.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathFinder.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -4,7 +4,6 @@ #include #include -#include "PathAllocator.h" #include "PathFinder.h" #include "PathFinderDef.h" #include "PathFlowMap.hpp" @@ -13,442 +12,313 @@ #include "Map/Ground.h" #include "Map/ReadMap.h" #include "Sim/MoveTypes/MoveDefHandler.h" +#include "Sim/Misc/ModInfo.h" #include "Sim/Misc/GeometricObjects.h" + #define PATHDEBUG 0 using namespace Bitwise; -void* CPathFinder::operator new(size_t size) { return PathAllocator::Alloc(size); } -void CPathFinder::operator delete(void* p, size_t size) { PathAllocator::Free(p, size); } - -const CMoveMath::BlockType squareMobileBlockBits = (CMoveMath::BLOCK_MOBILE | CMoveMath::BLOCK_MOVING | CMoveMath::BLOCK_MOBILE_BUSY); - -CPathFinder::CPathFinder() - : start(ZeroVector) - , startxSqr(0) - , startzSqr(0) - , mStartSquareIdx(0) - , mGoalSquareIdx(0) - , mGoalHeuristic(0.0f) - , exactPath(false) - , testMobile(false) - , needPath(false) - , maxOpenNodes(0) - , testedNodes(0) - , squareStates(int2(gs->mapx, gs->mapy), int2(gs->mapx, gs->mapy)) -{ - directionVectors2D[PATHOPT_LEFT ] = int2(+1 * PATH_NODE_SPACING, 0 ); - directionVectors2D[PATHOPT_RIGHT ] = int2(-1 * PATH_NODE_SPACING, 0 ); - directionVectors2D[PATHOPT_UP ] = int2( 0, +1 * PATH_NODE_SPACING); - directionVectors2D[PATHOPT_DOWN ] = int2( 0, -1 * PATH_NODE_SPACING); - directionVectors2D[PATHOPT_LEFT | PATHOPT_UP ] = int2(directionVectors2D[PATHOPT_LEFT ].x, directionVectors2D[PATHOPT_UP ].y); - directionVectors2D[PATHOPT_RIGHT | PATHOPT_UP ] = int2(directionVectors2D[PATHOPT_RIGHT].x, directionVectors2D[PATHOPT_UP ].y); - directionVectors2D[PATHOPT_RIGHT | PATHOPT_DOWN] = int2(directionVectors2D[PATHOPT_RIGHT].x, directionVectors2D[PATHOPT_DOWN ].y); - directionVectors2D[PATHOPT_LEFT | PATHOPT_DOWN] = int2(directionVectors2D[PATHOPT_LEFT ].x, directionVectors2D[PATHOPT_DOWN ].y); - - directionVectors3D[PATHOPT_RIGHT ].x = directionVectors2D[PATHOPT_RIGHT ].x; - directionVectors3D[PATHOPT_RIGHT ].z = directionVectors2D[PATHOPT_RIGHT ].y; - directionVectors3D[PATHOPT_LEFT ].x = directionVectors2D[PATHOPT_LEFT ].x; - directionVectors3D[PATHOPT_LEFT ].z = directionVectors2D[PATHOPT_LEFT ].y; - directionVectors3D[PATHOPT_UP ].x = directionVectors2D[PATHOPT_UP ].x; - directionVectors3D[PATHOPT_UP ].z = directionVectors2D[PATHOPT_UP ].y; - directionVectors3D[PATHOPT_DOWN ].x = directionVectors2D[PATHOPT_DOWN ].x; - directionVectors3D[PATHOPT_DOWN ].z = directionVectors2D[PATHOPT_DOWN ].y; - directionVectors3D[PATHOPT_RIGHT | PATHOPT_UP ].x = directionVectors2D[PATHOPT_RIGHT | PATHOPT_UP ].x; - directionVectors3D[PATHOPT_RIGHT | PATHOPT_UP ].z = directionVectors2D[PATHOPT_RIGHT | PATHOPT_UP ].y; - directionVectors3D[PATHOPT_LEFT | PATHOPT_UP ].x = directionVectors2D[PATHOPT_LEFT | PATHOPT_UP ].x; - directionVectors3D[PATHOPT_LEFT | PATHOPT_UP ].z = directionVectors2D[PATHOPT_LEFT | PATHOPT_UP ].y; - directionVectors3D[PATHOPT_RIGHT | PATHOPT_DOWN].x = directionVectors2D[PATHOPT_RIGHT | PATHOPT_DOWN].x; - directionVectors3D[PATHOPT_RIGHT | PATHOPT_DOWN].z = directionVectors2D[PATHOPT_RIGHT | PATHOPT_DOWN].y; - directionVectors3D[PATHOPT_LEFT | PATHOPT_DOWN].x = directionVectors2D[PATHOPT_LEFT | PATHOPT_DOWN].x; - directionVectors3D[PATHOPT_LEFT | PATHOPT_DOWN].z = directionVectors2D[PATHOPT_LEFT | PATHOPT_DOWN].y; - - directionVectors3D[PATHOPT_RIGHT ].ANormalize(); - directionVectors3D[PATHOPT_LEFT ].ANormalize(); - directionVectors3D[PATHOPT_UP ].ANormalize(); - directionVectors3D[PATHOPT_DOWN ].ANormalize(); - directionVectors3D[PATHOPT_RIGHT | PATHOPT_UP ].ANormalize(); - directionVectors3D[PATHOPT_LEFT | PATHOPT_UP ].ANormalize(); - directionVectors3D[PATHOPT_RIGHT | PATHOPT_DOWN].ANormalize(); - directionVectors3D[PATHOPT_LEFT | PATHOPT_DOWN].ANormalize(); - - directionCosts[PATHOPT_LEFT ] = 1.0f; // * PATH_NODE_SPACING; - directionCosts[PATHOPT_RIGHT ] = 1.0f; // * PATH_NODE_SPACING; - directionCosts[PATHOPT_UP ] = 1.0f; // * PATH_NODE_SPACING; - directionCosts[PATHOPT_DOWN ] = 1.0f; // * PATH_NODE_SPACING; - directionCosts[PATHOPT_LEFT | PATHOPT_UP ] = 1.4142f; // * PATH_NODE_SPACING; - directionCosts[PATHOPT_RIGHT | PATHOPT_UP ] = 1.4142f; // * PATH_NODE_SPACING; - directionCosts[PATHOPT_RIGHT | PATHOPT_DOWN] = 1.4142f; // * PATH_NODE_SPACING; - directionCosts[PATHOPT_LEFT | PATHOPT_DOWN] = 1.4142f; // * PATH_NODE_SPACING; -} - -CPathFinder::~CPathFinder() -{ - ResetSearch(); -} - -IPath::SearchResult CPathFinder::GetPath( - const MoveDef& moveDef, - const CPathFinderDef& pfDef, - const CSolidObject* owner, - const float3& startPos, - IPath::Path& path, - unsigned int maxNodes, - bool testMobile, - bool exactPath, - bool needPath, - bool synced -) { - // Clear the given path. - path.path.clear(); - path.squares.clear(); - path.pathCost = PATHCOST_INFINITY; - - maxOpenNodes = std::min(MAX_SEARCHED_NODES_PF - 8U, maxNodes); - - this->testMobile = testMobile; - this->exactPath = exactPath; - this->needPath = needPath; - - start = startPos; +const CMoveMath::BlockType squareMobileBlockBits = (CMoveMath::BLOCK_MOBILE | CMoveMath::BLOCK_MOVING | CMoveMath::BLOCK_MOBILE_BUSY); - startxSqr = start.x / SQUARE_SIZE; - startzSqr = start.z / SQUARE_SIZE; +// indexed by PATHOPT* bitmasks +static float3 PF_DIRECTION_VECTORS_3D[PATH_DIRECTIONS << 1]; +static float PF_DIRECTION_COSTS[PATH_DIRECTIONS << 1]; - // Clamp the start position - if (startxSqr >= gs->mapx) startxSqr = gs->mapxm1; - if (startzSqr >= gs->mapy) startzSqr = gs->mapym1; - mStartSquareIdx = startxSqr + startzSqr * gs->mapx; - // Start up the search. - const IPath::SearchResult result = InitSearch(moveDef, pfDef, owner, synced); +CPathFinder::CPathFinder() + : IPathFinder(1) +{ +} - // Respond to the success of the search. - if (result == IPath::Ok || result == IPath::GoalOutOfRange) { - FinishSearch(moveDef, path); - if (LOG_IS_ENABLED(L_DEBUG)) { - LOG_L(L_DEBUG, "Path found."); - LOG_L(L_DEBUG, "Nodes tested: %u", testedNodes); - LOG_L(L_DEBUG, "Open squares: %u", openSquareBuffer.GetSize()); - LOG_L(L_DEBUG, "Path nodes: " _STPF_, path.path.size()); - LOG_L(L_DEBUG, "Path cost: %f", path.pathCost); - } - } else { - if (LOG_IS_ENABLED(L_DEBUG)) { - LOG_L(L_DEBUG, "No path found!"); - LOG_L(L_DEBUG, "Nodes tested: %u", testedNodes); - LOG_L(L_DEBUG, "Open squares: %u", openSquareBuffer.GetSize()); - } +void CPathFinder::InitDirectionVectorsTable() { + for (int i = 0; i < (PATH_DIRECTIONS << 1); ++i) { + PF_DIRECTION_VECTORS_3D[i].x = PF_DIRECTION_VECTORS_2D[i].x; + PF_DIRECTION_VECTORS_3D[i].z = PF_DIRECTION_VECTORS_2D[i].y; + PF_DIRECTION_VECTORS_3D[i].Normalize(); } - - return result; } +void CPathFinder::InitDirectionCostsTable() { + // note: PATH_NODE_SPACING should not affect these + PF_DIRECTION_COSTS[PATHOPT_LEFT ] = 1.0f; + PF_DIRECTION_COSTS[PATHOPT_RIGHT ] = 1.0f; + PF_DIRECTION_COSTS[PATHOPT_UP ] = 1.0f; + PF_DIRECTION_COSTS[PATHOPT_DOWN ] = 1.0f; + PF_DIRECTION_COSTS[PATHOPT_LEFT | PATHOPT_UP ] = 1.4142f; + PF_DIRECTION_COSTS[PATHOPT_RIGHT | PATHOPT_UP ] = 1.4142f; + PF_DIRECTION_COSTS[PATHOPT_RIGHT | PATHOPT_DOWN] = 1.4142f; + PF_DIRECTION_COSTS[PATHOPT_LEFT | PATHOPT_DOWN] = 1.4142f; +} -IPath::SearchResult CPathFinder::InitSearch(const MoveDef& moveDef, const CPathFinderDef& pfDef, const CSolidObject* owner, bool synced) { - if (exactPath) { - // If exact (non-partial) path is required and the goal is blocked, then no search is needed. - if (pfDef.GoalIsBlocked(moveDef, CMoveMath::BLOCK_STRUCTURE, owner)) { - return IPath::CantGetCloser; - } - } else { - // also need a "dead zone" around blocked goal-squares for inexact paths - // otherwise CPU use can become unacceptable even with circular constraint - // (helps only a little because the allowed search radius in this case will - // be much smaller as well) - if (owner != NULL) { - const bool inRange = ((owner->pos - pfDef.goal).SqLength2D() < (owner->sqRadius + pfDef.sqGoalRadius)); - const bool blocked = ((CMoveMath::IsBlocked(moveDef, pfDef.goal, owner) & CMoveMath::BLOCK_STRUCTURE) != 0); - - if (inRange && blocked) { - return IPath::CantGetCloser; - } - } - } - - // start-position is clamped by caller - // NOTE: - // if search starts on odd-numbered square, only odd-numbered nodes are explored - // if search starts on even-numbered square, only even-numbered nodes are explored - const bool isStartGoal = pfDef.IsGoal(startxSqr, startzSqr); - - // although our starting square may be inside the goal radius, the starting coordinate may be outside. - // in this case we do not want to return CantGetCloser, but instead a path to our starting square. - if (isStartGoal && pfDef.startInGoalRadius) - return IPath::CantGetCloser; - - // Clear the system from last search. - ResetSearch(); - - // Marks and store the start-square. - squareStates.nodeMask[mStartSquareIdx] = (PATHOPT_START | PATHOPT_OPEN); - squareStates.fCost[mStartSquareIdx] = 0.0f; - squareStates.gCost[mStartSquareIdx] = 0.0f; - - squareStates.SetMaxCost(NODE_COST_F, 0.0f); - squareStates.SetMaxCost(NODE_COST_G, 0.0f); - - dirtySquares.push_back(mStartSquareIdx); - - // Make the beginning the fest square found. - mGoalSquareIdx = mStartSquareIdx; - mGoalHeuristic = pfDef.Heuristic(startxSqr, startzSqr); - - // Adding the start-square to the queue. - openSquareBuffer.SetSize(0); - PathNode* os = openSquareBuffer.GetNode(openSquareBuffer.GetSize()); - os->fCost = 0.0f; - os->gCost = 0.0f; - os->nodePos.x = startxSqr; - os->nodePos.y = startzSqr; - os->nodeNum = mStartSquareIdx; - openSquares.push(os); - - // perform the search - IPath::SearchResult result = DoSearch(moveDef, pfDef, owner, synced); - - // if no improvements are found, then return CantGetCloser instead - if ((mGoalSquareIdx == mStartSquareIdx && (!isStartGoal || pfDef.startInGoalRadius)) || mGoalSquareIdx == 0) { - return IPath::CantGetCloser; - } +const int2* CPathFinder::GetDirectionVectorsTable2D() { return (&PF_DIRECTION_VECTORS_2D[0]); } +const float3* CPathFinder::GetDirectionVectorsTable3D() { return (&PF_DIRECTION_VECTORS_3D[0]); } - return result; -} -IPath::SearchResult CPathFinder::DoSearch(const MoveDef& moveDef, const CPathFinderDef& pfDef, const CSolidObject* owner, bool synced) { +IPath::SearchResult CPathFinder::DoSearch( + const MoveDef& moveDef, + const CPathFinderDef& pfDef, + const CSolidObject* owner +) { bool foundGoal = false; - while (!openSquares.empty() && (openSquareBuffer.GetSize() < maxOpenNodes)) { + while (!openBlocks.empty() && (openBlockBuffer.GetSize() < maxBlocksToBeSearched)) { // Get the open square with lowest expected path-cost. - PathNode* os = const_cast(openSquares.top()); - openSquares.pop(); + PathNode* openSquare = const_cast(openBlocks.top()); + openBlocks.pop(); // check if this PathNode has become obsolete - if (squareStates.fCost[os->nodeNum] != os->fCost) + if (blockStates.fCost[openSquare->nodeNum] != openSquare->fCost) continue; - const int2 nodePos = os->nodePos; - // Check if the goal is reached. - if (pfDef.IsGoal(nodePos.x, nodePos.y)) { - mGoalSquareIdx = os->nodeNum; + if (pfDef.IsGoal(openSquare->nodePos.x, openSquare->nodePos.y)) { + mGoalBlockIdx = openSquare->nodeNum; mGoalHeuristic = 0.0f; foundGoal = true; break; } - // Test the 8 surrounding squares. - // note: because the spacing between nodes is 2 (not 1) we - // must also make sure not to skip across any intermediate - // impassable squares (!) but without reducing the spacing - // factor which would drop performance four-fold - assert(PATH_NODE_SPACING == 2); - - #define CAN_SKIP_SQUARE(md, x, y, o) (true || (CMoveMath::IsBlocked(md, x, y, o) & CMoveMath::BLOCK_STRUCTURE) == 0) - #define DO_SQUARE_CHECK(md, x, y, o, pfd, sqr, opt, sync) (CAN_SKIP_SQUARE(md, x, y, o) && TestSquare(md, pfd, sqr, o, opt, sync)) - - const bool up = DO_SQUARE_CHECK(moveDef, nodePos.x, nodePos.y - 1, owner, pfDef, os, PATHOPT_UP, synced); - const bool down = DO_SQUARE_CHECK(moveDef, nodePos.x, nodePos.y + 1, owner, pfDef, os, PATHOPT_DOWN, synced); - const bool right = DO_SQUARE_CHECK(moveDef, nodePos.x + 1, nodePos.y, owner, pfDef, os, PATHOPT_RIGHT, synced); - const bool left = DO_SQUARE_CHECK(moveDef, nodePos.x - 1, nodePos.y, owner, pfDef, os, PATHOPT_LEFT, synced); - - if (up) { - // don't search diagonally if there is a blocking object - // (not blocking terrain) in one of the two side squares - if (right) { DO_SQUARE_CHECK(moveDef, nodePos.x + 1, nodePos.y - 1, owner, pfDef, os, PATHOPT_RIGHT | PATHOPT_UP, synced); } - if ( left) { DO_SQUARE_CHECK(moveDef, nodePos.x - 1, nodePos.y - 1, owner, pfDef, os, PATHOPT_LEFT | PATHOPT_UP, synced); } - } - if (down) { - if (right) { DO_SQUARE_CHECK(moveDef, nodePos.x + 1, nodePos.y + 1, owner, pfDef, os, PATHOPT_RIGHT | PATHOPT_DOWN, synced); } - if ( left) { DO_SQUARE_CHECK(moveDef, nodePos.x - 1, nodePos.y + 1, owner, pfDef, os, PATHOPT_LEFT | PATHOPT_DOWN, synced); } - } - #undef DO_SQUARE_CHECK - #undef CAN_SKIP_SQUARE - - // Mark this square as closed. - squareStates.nodeMask[os->nodeNum] |= PATHOPT_CLOSED; + TestNeighborSquares(moveDef, pfDef, openSquare, owner); } if (foundGoal) return IPath::Ok; - // Could not reach the goal. - if (openSquareBuffer.GetSize() >= maxOpenNodes) + // could not reach goal within exploration limit + if (openBlockBuffer.GetSize() >= maxBlocksToBeSearched) return IPath::GoalOutOfRange; - // Search could not reach the goal, due to the unit being locked in. - if (openSquares.empty()) + // could not reach goal from this starting position if nothing to left to explore + if (openBlocks.empty()) return IPath::GoalOutOfRange; // should be unreachable - // LogObject() << "ERROR: CPathFinder::DoSearch() - Unhandled end of search!\n"; return IPath::Error; } - -bool CPathFinder::TestSquare( +void CPathFinder::TestNeighborSquares( const MoveDef& moveDef, const CPathFinderDef& pfDef, - const PathNode* parentOpenSquare, - const CSolidObject* owner, - unsigned int pathOptDir, - bool synced + const PathNode* square, + const CSolidObject* owner ) { - testedNodes++; - - const int2& dirVec2D = directionVectors2D[pathOptDir]; - const float3& dirVec3D = directionVectors3D[pathOptDir]; + unsigned int ngbBlockedState[PATH_DIRECTIONS]; + bool ngbInSearchRadius[PATH_DIRECTIONS]; + float ngbPosSpeedMod[PATH_DIRECTIONS]; + float ngbSpeedMod[PATH_DIRECTIONS]; + + // precompute structure-blocked and within-constraint states for all neighbors + for (unsigned int dir = 0; dir < PATH_DIRECTIONS; dir++) { + const int2 ngbSquareCoors = square->nodePos + PF_DIRECTION_VECTORS_2D[ PathDir2PathOpt(dir) ]; + + ngbBlockedState[dir] = CMoveMath::IsBlockedNoSpeedModCheck(moveDef, ngbSquareCoors.x, ngbSquareCoors.y, owner); + ngbInSearchRadius[dir] = pfDef.WithinConstraints(ngbSquareCoors.x, ngbSquareCoors.y); + + // use the minimum of positional and directional speed-modifiers + // because this agrees more with current assumptions in movetype + // code and the estimators have no directional information + const float posSpeedMod = CMoveMath::GetPosSpeedMod(moveDef, ngbSquareCoors.x, ngbSquareCoors.y); + const float dirSpeedMod = CMoveMath::GetPosSpeedMod(moveDef, ngbSquareCoors.x, ngbSquareCoors.y, PF_DIRECTION_VECTORS_3D[ PathDir2PathOpt(dir) ]); + ngbPosSpeedMod[dir] = posSpeedMod; + // hint: use posSpeedMod for PE! cause it assumes path costs are bidirectional and so it only saves one `cost` for left & right movement + ngbSpeedMod[dir] = (pfDef.dirIndependent) ? posSpeedMod : std::min(posSpeedMod, dirSpeedMod); + } + + // first test squares along the cardinal directions + for (unsigned int dir: PATHDIR_CARDINALS) { + const unsigned int opt = PathDir2PathOpt(dir); - // Calculate the new square. - int2 square; - square.x = parentOpenSquare->nodePos.x + dirVec2D.x; - square.y = parentOpenSquare->nodePos.y + dirVec2D.y; + if ((ngbBlockedState[dir] & CMoveMath::BLOCK_STRUCTURE) != 0) + continue; + if (!ngbInSearchRadius[dir]) + continue; - // Inside map? - if (square.x < 0 || square.y < 0 || square.x >= gs->mapx || square.y >= gs->mapy) { - return false; + TestBlock(moveDef, pfDef, square, owner, opt, ngbBlockedState[dir], ngbSpeedMod[dir], ngbInSearchRadius[dir]); } - const unsigned int sqrIdx = square.x + square.y * gs->mapx; - const unsigned int sqrStatus = squareStates.nodeMask[sqrIdx]; - // Check if the square is unaccessable or used. - if (sqrStatus & (PATHOPT_CLOSED | PATHOPT_FORBIDDEN | PATHOPT_BLOCKED)) { + // next test the diagonal squares + // + // don't search diagonally if there is a blocking object + // (or blocking terrain!) in one of the two side squares + // e.g. do not consider the edge (p, q) passable if X is + // impassable in this situation: + // +---+---+ + // | X | q | + // +---+---+ + // | p | X | + // +---+---+ + // + // if either side-square is merely outside the constrained + // area but the diagonal square is not, we do consider the + // edge passable since we still need to be able to jump to + // diagonally adjacent PE-blocks + // + #define CAN_TEST_SQUARE(dir) ((ngbBlockedState[dir] & CMoveMath::BLOCK_STRUCTURE) == 0 && ngbPosSpeedMod[dir] != 0.0f) + #define TEST_DIAG_SQUARE(BASE_DIR_X, BASE_DIR_Y, BASE_DIR_XY) \ + if (CAN_TEST_SQUARE(BASE_DIR_X) && CAN_TEST_SQUARE(BASE_DIR_Y) && CAN_TEST_SQUARE(BASE_DIR_XY)) { \ + if ((ngbInSearchRadius[BASE_DIR_X] && ngbInSearchRadius[BASE_DIR_Y]) || ngbInSearchRadius[BASE_DIR_XY]) { \ + const unsigned int ngbOpt = PathDir2PathOpt(BASE_DIR_XY); \ + const unsigned int ngbBlk = ngbBlockedState[BASE_DIR_XY]; \ + const unsigned int ngbVis = ngbInSearchRadius[BASE_DIR_XY]; \ + \ + TestBlock(moveDef, pfDef, square, owner, ngbOpt, ngbBlk, ngbSpeedMod[BASE_DIR_XY], ngbVis); \ + } \ + } + + TEST_DIAG_SQUARE(PATHDIR_LEFT, PATHDIR_UP, PATHDIR_LEFT_UP ) + TEST_DIAG_SQUARE(PATHDIR_RIGHT, PATHDIR_UP, PATHDIR_RIGHT_UP ) + TEST_DIAG_SQUARE(PATHDIR_LEFT, PATHDIR_DOWN, PATHDIR_LEFT_DOWN ) + TEST_DIAG_SQUARE(PATHDIR_RIGHT, PATHDIR_DOWN, PATHDIR_RIGHT_DOWN) + + #undef TEST_DIAG_SQUARE + #undef CAN_TEST_SQUARE + + // mark this square as closed + blockStates.nodeMask[square->nodeNum] |= PATHOPT_CLOSED; +} + +bool CPathFinder::TestBlock( + const MoveDef& moveDef, + const CPathFinderDef& pfDef, + const PathNode* parentSquare, + const CSolidObject* owner, + const unsigned int pathOptDir, + const unsigned int blockStatus, + float speedMod, + bool withinConstraints +) { + testedBlocks++; + + // initial calculations of the new block + const int2 square = parentSquare->nodePos + PF_DIRECTION_VECTORS_2D[pathOptDir]; + const unsigned int sqrIdx = BlockPosToIdx(square); + + // bounds-check + if ((unsigned)square.x >= nbrOfBlocks.x) return false; + if ((unsigned)square.y >= nbrOfBlocks.y) return false; + + // check if the square is inaccessable + if (blockStates.nodeMask[sqrIdx] & (PATHOPT_CLOSED | PATHOPT_BLOCKED)) return false; - } - const CMoveMath::BlockType blockStatus = CMoveMath::IsBlockedNoSpeedModCheck(moveDef, square.x, square.y, owner); + // caller has already tested for this + assert((blockStatus & CMoveMath::BLOCK_STRUCTURE) == 0); - // Check if square are out of constraints or blocked by something. - // Doesn't need to be done on open squares, as those are already tested. - if (!(sqrStatus & PATHOPT_OPEN) && - ((blockStatus & CMoveMath::BLOCK_STRUCTURE) || !pfDef.WithinConstraints(square.x, square.y)) - ) { - squareStates.nodeMask[sqrIdx] |= PATHOPT_BLOCKED; - dirtySquares.push_back(sqrIdx); + // check if square is outside search-constraint + // (this has already been done for open squares) + if ((blockStates.nodeMask[sqrIdx] & PATHOPT_OPEN) == 0 && !withinConstraints) { + blockStates.nodeMask[sqrIdx] |= PATHOPT_BLOCKED; + dirtyBlocks.push_back(sqrIdx); return false; } - // Evaluate this square. + // evaluate this square // - // use the minimum of positional and directional speed-modifiers - // because this agrees more with current assumptions in movetype - // code and the estimators have no directional information - float squareSpeedMod = std::min(CMoveMath::GetPosSpeedMod(moveDef, square.x, square.y), CMoveMath::GetPosSpeedMod(moveDef, square.x, square.y, dirVec3D)); - - if (squareSpeedMod == 0.0f) { - squareStates.nodeMask[sqrIdx] |= PATHOPT_FORBIDDEN; - dirtySquares.push_back(sqrIdx); + + if (speedMod == 0.0f) { + blockStates.nodeMask[sqrIdx] |= PATHOPT_BLOCKED; + dirtyBlocks.push_back(sqrIdx); return false; } - if (testMobile && moveDef.avoidMobilesOnPath && (blockStatus & squareMobileBlockBits)) { + if (pfDef.testMobile && moveDef.avoidMobilesOnPath && (blockStatus & squareMobileBlockBits)) { if (blockStatus & CMoveMath::BLOCK_MOBILE_BUSY) { - squareSpeedMod *= moveDef.speedModMults[MoveDef::SPEEDMOD_MOBILE_BUSY_MULT]; + speedMod *= moveDef.speedModMults[MoveDef::SPEEDMOD_MOBILE_BUSY_MULT]; } else if (blockStatus & CMoveMath::BLOCK_MOBILE) { - squareSpeedMod *= moveDef.speedModMults[MoveDef::SPEEDMOD_MOBILE_IDLE_MULT]; + speedMod *= moveDef.speedModMults[MoveDef::SPEEDMOD_MOBILE_IDLE_MULT]; } else { // (blockStatus & CMoveMath::BLOCK_MOVING) - squareSpeedMod *= moveDef.speedModMults[MoveDef::SPEEDMOD_MOBILE_MOVE_MULT]; + speedMod *= moveDef.speedModMults[MoveDef::SPEEDMOD_MOBILE_MOVE_MULT]; } } - const float heatCost = (PathHeatMap::GetInstance())->GetHeatCost(square.x, square.y, moveDef, ((owner != NULL)? owner->id: -1U)); - const float flowCost = (PathFlowMap::GetInstance())->GetFlowCost(square.x, square.y, moveDef, pathOptDir); + const float heatCost = (pfDef.testMobile) ? (PathHeatMap::GetInstance())->GetHeatCost(square.x, square.y, moveDef, ((owner != NULL)? owner->id: -1U)) : 0.0f; + const float flowCost = (pfDef.testMobile) ? (PathFlowMap::GetInstance())->GetFlowCost(square.x, square.y, moveDef, pathOptDir) : 0.0f; + const float extraCost = blockStates.GetNodeExtraCost(square.x, square.y, pfDef.synced); - const float dirMoveCost = (1.0f + heatCost + flowCost) * directionCosts[pathOptDir]; - const float extraCost = squareStates.GetNodeExtraCost(square.x, square.y, synced); - const float nodeCost = (dirMoveCost / squareSpeedMod) + extraCost; + const float dirMoveCost = (1.0f + heatCost + flowCost) * PF_DIRECTION_COSTS[pathOptDir]; + const float nodeCost = (dirMoveCost / speedMod) + extraCost; - const float gCost = parentOpenSquare->gCost + nodeCost; // g + const float gCost = parentSquare->gCost + nodeCost; // g const float hCost = pfDef.Heuristic(square.x, square.y); // h const float fCost = gCost + hCost; // f - - if (squareStates.nodeMask[sqrIdx] & PATHOPT_OPEN) { - // already in the open set - if (squareStates.fCost[sqrIdx] <= fCost) + if (blockStates.nodeMask[sqrIdx] & PATHOPT_OPEN) { + // already in the open set, look for a cost-improvement + if (blockStates.fCost[sqrIdx] <= fCost) return true; - squareStates.nodeMask[sqrIdx] &= ~PATHOPT_AXIS_DIRS; + blockStates.nodeMask[sqrIdx] &= ~PATHOPT_CARDINALS; } - // Look for improvements. - if (!exactPath && hCost < mGoalHeuristic) { - mGoalSquareIdx = sqrIdx; + // if heuristic says this node is closer to goal than previous h-estimate, keep it + if (!pfDef.exactPath && hCost < mGoalHeuristic) { + mGoalBlockIdx = sqrIdx; mGoalHeuristic = hCost; } - // Store this square as open. - openSquareBuffer.SetSize(openSquareBuffer.GetSize() + 1); - assert(openSquareBuffer.GetSize() < MAX_SEARCHED_NODES_PF); + // store and mark this square as open (expanded, but not yet pulled from pqueue) + openBlockBuffer.SetSize(openBlockBuffer.GetSize() + 1); + assert(openBlockBuffer.GetSize() < MAX_SEARCHED_NODES_PF); - PathNode* os = openSquareBuffer.GetNode(openSquareBuffer.GetSize()); + PathNode* os = openBlockBuffer.GetNode(openBlockBuffer.GetSize()); os->fCost = fCost; os->gCost = gCost; os->nodePos = square; os->nodeNum = sqrIdx; - openSquares.push(os); + openBlocks.push(os); - squareStates.SetMaxCost(NODE_COST_F, std::max(squareStates.GetMaxCost(NODE_COST_F), fCost)); - squareStates.SetMaxCost(NODE_COST_G, std::max(squareStates.GetMaxCost(NODE_COST_G), gCost)); + blockStates.SetMaxCost(NODE_COST_F, std::max(blockStates.GetMaxCost(NODE_COST_F), fCost)); + blockStates.SetMaxCost(NODE_COST_G, std::max(blockStates.GetMaxCost(NODE_COST_G), gCost)); - // mark this square as open - squareStates.fCost[sqrIdx] = os->fCost; - squareStates.gCost[sqrIdx] = os->gCost; - squareStates.nodeMask[sqrIdx] |= (PATHOPT_OPEN | pathOptDir); + blockStates.fCost[sqrIdx] = os->fCost; + blockStates.gCost[sqrIdx] = os->gCost; + blockStates.nodeMask[sqrIdx] |= (PATHOPT_OPEN | pathOptDir); - dirtySquares.push_back(sqrIdx); + dirtyBlocks.push_back(sqrIdx); return true; } -void CPathFinder::FinishSearch(const MoveDef& moveDef, IPath::Path& foundPath) { +IPath::SearchResult CPathFinder::FinishSearch(const MoveDef& moveDef, const CPathFinderDef& pfDef, IPath::Path& foundPath) const +{ // backtrack - if (needPath) { - int2 square; - square.x = mGoalSquareIdx % gs->mapx; - square.y = mGoalSquareIdx / gs->mapx; + if (pfDef.needPath) { + int2 square = BlockIdxToPos(mGoalBlockIdx); + unsigned int blockIdx = mGoalBlockIdx; // for path adjustment (cutting corners) std::deque previous; // make sure we don't match anything - previous.push_back(int2(-100, -100)); - previous.push_back(int2(-100, -100)); - previous.push_back(int2(-100, -100)); + previous.push_back(square); + previous.push_back(square); while (true) { - const int sqrIdx = square.y * gs->mapx + square.x; - - if (squareStates.nodeMask[sqrIdx] & PATHOPT_START) - break; - - float3 cs; - cs.x = (square.x/2/* + 0.5f*/) * SQUARE_SIZE * 2 + SQUARE_SIZE; - cs.z = (square.y/2/* + 0.5f*/) * SQUARE_SIZE * 2 + SQUARE_SIZE; - cs.y = CMoveMath::yLevel(moveDef, square.x, square.y); + float3 pos(square.x * SQUARE_SIZE, 0.0f, square.y * SQUARE_SIZE); + pos.y = CMoveMath::yLevel(moveDef, square.x, square.y); // try to cut corners - AdjustFoundPath(moveDef, foundPath, /* inout */ cs, previous, square); + AdjustFoundPath(moveDef, foundPath, pos, previous, square); - foundPath.path.push_back(cs); + foundPath.path.push_back(pos); foundPath.squares.push_back(square); previous.pop_front(); previous.push_back(square); - int2 oldSquare; - oldSquare.x = square.x; - oldSquare.y = square.y; + if (blockIdx == mStartBlockIdx) + break; - square.x -= directionVectors2D[squareStates.nodeMask[sqrIdx] & PATHOPT_AXIS_DIRS].x; - square.y -= directionVectors2D[squareStates.nodeMask[sqrIdx] & PATHOPT_AXIS_DIRS].y; + square -= PF_DIRECTION_VECTORS_2D[blockStates.nodeMask[blockIdx] & PATHOPT_CARDINALS]; + blockIdx = BlockPosToIdx(square); } if (!foundPath.path.empty()) { @@ -457,147 +327,79 @@ } // Adds the cost of the path. - foundPath.pathCost = squareStates.fCost[mGoalSquareIdx]; + foundPath.pathCost = blockStates.fCost[mGoalBlockIdx]; + + return IPath::Ok; } /** Helper function for AdjustFoundPath */ -static inline void FixupPath3Pts(const MoveDef& moveDef, float3& p1, float3& p2, float3& p3, int2 sqr) +static inline void FixupPath3Pts(const MoveDef& moveDef, const float3 p1, float3& p2, const float3 p3) { +#if PATHDEBUG float3 old = p2; - old.y += 10; +#endif p2.x = 0.5f * (p1.x + p3.x); p2.z = 0.5f * (p1.z + p3.z); - p2.y = CMoveMath::yLevel(moveDef, sqr.x, sqr.y); + p2.y = CMoveMath::yLevel(moveDef, p2); #if PATHDEBUG - geometricObjects->AddLine(p3 + float3(0, 5, 0), p2 + float3(0, 10, 0), 5, 10, 600, 0); - geometricObjects->AddLine(p3 + float3(0, 5, 0), old, 5, 10, 600, 0); + geometricObjects->AddLine(old + float3(0, 10, 0), p2 + float3(0, 10, 0), 5, 10, 600, 0); #endif } -void CPathFinder::AdjustFoundPath(const MoveDef& moveDef, IPath::Path& foundPath, float3& nextPoint, - std::deque& previous, int2 square) +void CPathFinder::SmoothMidWaypoint(const int2 testsqr, const int2 prevsqr, const MoveDef& moveDef, IPath::Path& foundPath, const float3 nextPoint) const { -#define COSTMOD 1.39f // (math::sqrt(2) + 1)/math::sqrt(3) -#define TRYFIX3POINTS(dxtest, dytest) \ - do { \ - int testsqr = square.x + (dxtest) + (square.y + (dytest)) * gs->mapx; \ - int p2sqr = previous[2].x + previous[2].y * gs->mapx; \ - if (!(squareStates.nodeMask[testsqr] & (PATHOPT_BLOCKED | PATHOPT_FORBIDDEN)) && \ - squareStates.fCost[testsqr] <= (COSTMOD) * squareStates.fCost[p2sqr]) { \ - float3& p2 = foundPath.path[foundPath.path.size() - 2]; \ - float3& p1 = foundPath.path.back(); \ - float3& p0 = nextPoint; \ - FixupPath3Pts(moveDef, p0, p1, p2, int2(square.x + (dxtest), square.y + (dytest))); \ - } \ - } while (false) - - if (previous[2].x == square.x) { - if (previous[2].y == square.y-2) { - if (previous[1].x == square.x-2 && previous[1].y == square.y-4) { - LOG_L(L_DEBUG, "case N, NW"); - TRYFIX3POINTS(-2, -2); - } - else if (previous[1].x == square.x+2 && previous[1].y == square.y-4) { - LOG_L(L_DEBUG, "case N, NE"); - TRYFIX3POINTS(2, -2); - } - } - else if (previous[2].y == square.y+2) { - if (previous[1].x == square.x+2 && previous[1].y == square.y+4) { - LOG_L(L_DEBUG, "case S, SE"); - TRYFIX3POINTS(2, 2); - } - else if (previous[1].x == square.x-2 && previous[1].y == square.y+4) { - LOG_L(L_DEBUG, "case S, SW"); - TRYFIX3POINTS(-2, 2); - } - } - } - else if (previous[2].x == square.x-2) { - if (previous[2].y == square.y) { - if (previous[1].x == square.x-4 && previous[1].y == square.y-2) { - LOG_L(L_DEBUG, "case W, NW"); - TRYFIX3POINTS(-2, -2); - } - else if (previous[1].x == square.x-4 && previous[1].y == square.y+2) { - LOG_L(L_DEBUG, "case W, SW"); - TRYFIX3POINTS(-2, 2); - } - } - else if (previous[2].y == square.y-2) { - if (previous[1].x == square.x-2 && previous[1].y == square.y-4) { - LOG_L(L_DEBUG, "case NW, N"); - TRYFIX3POINTS(0, -2); - } - else if (previous[1].x == square.x-4 && previous[1].y == square.y-2) { - LOG_L(L_DEBUG, "case NW, W"); - TRYFIX3POINTS(-2, 0); - } - } - else if (previous[2].y == square.y+2) { - if (previous[1].x == square.x-2 && previous[1].y == square.y+4) { - LOG_L(L_DEBUG, "case SW, S"); - TRYFIX3POINTS(0, 2); - } - else if (previous[1].x == square.x-4 && previous[1].y == square.y+2) { - LOG_L(L_DEBUG, "case SW, W"); - TRYFIX3POINTS(-2, 0); - } - } - } - else if (previous[2].x == square.x+2) { - if (previous[2].y == square.y) { - if (previous[1].x == square.x+4 && previous[1].y == square.y-2) { - LOG_L(L_DEBUG, "case NE, E"); - TRYFIX3POINTS(2, -2); - } - else if (previous[1].x == square.x+4 && previous[1].y == square.y+2) { - LOG_L(L_DEBUG, "case SE, E"); - TRYFIX3POINTS(2, 2); - } - } - if (previous[2].y == square.y+2) { - if (previous[1].x == square.x+2 && previous[1].y == square.y+4) { - LOG_L(L_DEBUG, "case SE, S"); - TRYFIX3POINTS(0, 2); - } - else if (previous[1].x == square.x+4 && previous[1].y == square.y+2) { - LOG_L(L_DEBUG, "case SE, E"); - TRYFIX3POINTS(2, 0); - } - - } - else if (previous[2].y == square.y-2) { - if (previous[1].x == square.x+2 && previous[1].y == square.y-4) { - LOG_L(L_DEBUG, "case NE, N"); - TRYFIX3POINTS(0, -2); - } - else if (previous[1].x == square.x+4 && previous[1].y == square.y-2) { - LOG_L(L_DEBUG, "case NE, E"); - TRYFIX3POINTS(0, -2); - } - } + static const float COSTMOD = 1.39f; // (math::sqrt(2) + 1) / math::sqrt(3) + const int tstsqr = BlockPosToIdx(testsqr); + const int prvsqr = BlockPosToIdx(prevsqr); + if ( + ((blockStates.nodeMask[tstsqr] & PATHOPT_BLOCKED) == 0) + && (blockStates.fCost[tstsqr] <= COSTMOD * blockStates.fCost[prvsqr]) + ) { + const float3& p2 = foundPath.path[foundPath.path.size() - 2]; + float3& p1 = foundPath.path.back(); + const float3& p0 = nextPoint; + FixupPath3Pts(moveDef, p0, p1, p2); } -#undef TRYFIX3POINTS -#undef COSTMOD } -void CPathFinder::ResetSearch() +/* + * This function takes the current & the last 2 waypoints and detects when they form + * a "soft" curve. And if so, it takes the mid waypoint of those 3 and smooths it + * between the one before and the current waypoint (so the soft curve gets even smoother). + * Hint: hard curves (e.g. `move North then West`) can't and will not smoothed. Only soft ones + * like `move North then North-West` can. + */ +void CPathFinder::AdjustFoundPath(const MoveDef& moveDef, IPath::Path& foundPath, const float3 nextPoint, + std::deque& previous, int2 curquare) const { - openSquares.Clear(); - - while (!dirtySquares.empty()) { - const unsigned int lsquare = dirtySquares.back(); - - squareStates.nodeMask[lsquare] = 0; - squareStates.fCost[lsquare] = PATHCOST_INFINITY; - squareStates.gCost[lsquare] = PATHCOST_INFINITY; + assert(previous.size() == 2); + const int2& p1 = previous[0]; // two before curquare + const int2& p2 = previous[1]; // one before curquare + + int2 dirNow = (p2 - curquare); + int2 dirPrv = (p1 - curquare) - dirNow; + assert(dirNow.x % PATH_NODE_SPACING == 0); + assert(dirNow.y % PATH_NODE_SPACING == 0); + assert(dirPrv.x % PATH_NODE_SPACING == 0); + assert(dirPrv.y % PATH_NODE_SPACING == 0); + dirNow /= PATH_NODE_SPACING; + dirPrv /= PATH_NODE_SPACING; + + for (unsigned pathDir = PATHDIR_LEFT; pathDir < PATH_DIRECTIONS; ++pathDir) { + // find the pathDir + if (dirNow != PE_DIRECTION_VECTORS[pathDir]) + continue; - dirtySquares.pop_back(); + // only smooth "soft" curves (e.g. `move North-East then North`) + if ( + (dirPrv == PE_DIRECTION_VECTORS[(pathDir-1) % PATH_DIRECTIONS]) + || (dirPrv == PE_DIRECTION_VECTORS[(pathDir+1) % PATH_DIRECTIONS]) + ) { + SmoothMidWaypoint(curquare + (dirPrv * PATH_NODE_SPACING), p2, moveDef, foundPath, nextPoint); + } + break; } - - testedNodes = 0; } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathFinderDef.cpp spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathFinderDef.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathFinderDef.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathFinderDef.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,9 +7,16 @@ #include "Sim/MoveTypes/MoveDefHandler.h" #include "Sim/Misc/GlobalSynced.h" -CPathFinderDef::CPathFinderDef(const float3& goalCenter, float goalRadius, float sqGoalDistance): -goal(goalCenter), -sqGoalRadius(goalRadius * goalRadius) + +CPathFinderDef::CPathFinderDef(const float3& goalCenter, float goalRadius, float sqGoalDistance) +: goal(goalCenter) +, sqGoalRadius(goalRadius * goalRadius) +, constraintDisabled(false) +, testMobile(true) +, needPath(true) +, exactPath(true) +, dirIndependent(false) +, synced(true) { goalSquareX = goalCenter.x / SQUARE_SIZE; goalSquareZ = goalCenter.z / SQUARE_SIZE; @@ -35,8 +42,8 @@ // returns if the goal is inaccessable: this is // true if the goal area is "small" and blocked -bool CPathFinderDef::GoalIsBlocked(const MoveDef& moveDef, const CMoveMath::BlockType& blockMask, const CSolidObject* owner) const { - const float r0 = SQUARE_SIZE * SQUARE_SIZE * 4.0f; // (SQUARE_SIZE*2)^2 +bool CPathFinderDef::IsGoalBlocked(const MoveDef& moveDef, const CMoveMath::BlockType& blockMask, const CSolidObject* owner) const { + const float r0 = SQUARE_SIZE * SQUARE_SIZE * 4.0f; // same as (SQUARE_SIZE*2)^2 const float r1 = ((moveDef.xsize * SQUARE_SIZE) >> 1) * ((moveDef.zsize * SQUARE_SIZE) >> 1) * 1.5f; if (sqGoalRadius >= r0 && sqGoalRadius > r1) @@ -60,16 +67,14 @@ -CRangedGoalWithCircularConstraint::CRangedGoalWithCircularConstraint( +CCircularSearchConstraint::CCircularSearchConstraint( const float3& start, const float3& goal, float goalRadius, float searchSize, - unsigned int extraSize): - CPathFinderDef(goal, goalRadius, start.SqDistance2D(goal)) + unsigned int extraSize +): CPathFinderDef(goal, goalRadius, start.SqDistance2D(goal)) { - disabled = false; - // calculate the center and radius of the constrained area const unsigned int startX = start.x / SQUARE_SIZE; const unsigned int startZ = start.z / SQUARE_SIZE; @@ -87,13 +92,31 @@ searchRadiusSq += extraSize; } -// tests if a square is inside is the circular constrained area -// defined by the start and goal positions (disabled: this only -// saves CPU under certain conditions and destroys admissibility) -bool CRangedGoalWithCircularConstraint::WithinConstraints(unsigned int xSquare, unsigned int zSquare) const -{ - const int dx = halfWayX - xSquare; - const int dz = halfWayZ - zSquare; - return (disabled || ((dx * dx + dz * dz) <= searchRadiusSq)); + +CRectangularSearchConstraint::CRectangularSearchConstraint( + const float3 startPos, + const float3 goalPos, + unsigned int blockSize +): CPathFinderDef(goalPos, 0.0f, startPos.SqDistance2D(goalPos)) +{ + unsigned int startBlockX = startPos.x / SQUARE_SIZE; + unsigned int startBlockZ = startPos.z / SQUARE_SIZE; + unsigned int goalBlockX = goalPos.x / SQUARE_SIZE; + unsigned int goalBlockZ = goalPos.z / SQUARE_SIZE; + startBlockX -= startBlockX % blockSize; + startBlockZ -= startBlockZ % blockSize; + goalBlockX -= goalBlockX % blockSize; + goalBlockZ -= goalBlockZ % blockSize; + + startBlockRect.x1 = startBlockX; + startBlockRect.z1 = startBlockZ; + startBlockRect.x2 = startBlockX + blockSize; + startBlockRect.z2 = startBlockZ + blockSize; + + goalBlockRect.x1 = goalBlockX; + goalBlockRect.z1 = goalBlockZ; + goalBlockRect.x2 = goalBlockX + blockSize; + goalBlockRect.z2 = goalBlockZ + blockSize; } + diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathFinderDef.h spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathFinderDef.h --- spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathFinderDef.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathFinderDef.h 2014-10-07 20:09:51.000000000 +0000 @@ -6,6 +6,7 @@ #include "Sim/MoveTypes/MoveMath/MoveMath.h" #include "System/float3.h" #include "System/type2.h" +#include "System/Rectangle.h" struct MoveDef; class CPathFinderDef { @@ -14,17 +15,28 @@ virtual ~CPathFinderDef() {} virtual bool WithinConstraints(unsigned int xSquare, unsigned int zSquare) const { return true; } - virtual void DisableConstraint(bool) {} + virtual void DisableConstraint(bool b) { constraintDisabled = b; } bool IsGoal(unsigned int xSquare, unsigned int zSquare) const; float Heuristic(unsigned int xSquare, unsigned int zSquare) const; - bool GoalIsBlocked(const MoveDef& moveDef, const CMoveMath::BlockType& blockMask, const CSolidObject* owner) const; + bool IsGoalBlocked(const MoveDef& moveDef, const CMoveMath::BlockType& blockMask, const CSolidObject* owner) const; int2 GoalSquareOffset(unsigned int blockSize) const; +public: + // world-space goal position float3 goal; + float sqGoalRadius; + // if true, do not need to generate any waypoints bool startInGoalRadius; + bool constraintDisabled; + + bool testMobile; + bool needPath; + bool exactPath; + bool dirIndependent; + bool synced; unsigned int goalSquareX; unsigned int goalSquareZ; @@ -32,20 +44,53 @@ -class CRangedGoalWithCircularConstraint : public CPathFinderDef { +class CCircularSearchConstraint: public CPathFinderDef { public: - CRangedGoalWithCircularConstraint(const float3& start, const float3& goal, float goalRadius, float searchSize, unsigned int extraSize); - ~CRangedGoalWithCircularConstraint() {} + CCircularSearchConstraint( + const float3& start, + const float3& goal, + float goalRadius, + float searchSize, + unsigned int extraSize + ); + + // tests if a square is inside is the circular constrained area + // defined by the start and goal positions (note that this only + // saves CPU under certain conditions and destroys admissibility) + bool WithinConstraints(unsigned int xSquare, unsigned int zSquare) const { + const int dx = halfWayX - xSquare; + const int dz = halfWayZ - zSquare; - bool WithinConstraints(unsigned int xSquare, unsigned int zSquare) const; - void DisableConstraint(bool b) { disabled = b; } + return (constraintDisabled || ((dx * dx + dz * dz) <= searchRadiusSq)); + } private: unsigned int halfWayX; unsigned int halfWayZ; unsigned int searchRadiusSq; +}; + - bool disabled; + +class CRectangularSearchConstraint: public CPathFinderDef { +public: + // note: startPos and goalPos are in world-space + CRectangularSearchConstraint( + const float3 startPos, + const float3 goalPos, + unsigned int blockSize + ); + + bool WithinConstraints(unsigned int xSquare, unsigned int zSquare) const { + if (startBlockRect.Inside(int2(xSquare, zSquare))) return true; + if ( goalBlockRect.Inside(int2(xSquare, zSquare))) return true; + return (constraintDisabled); + } + +private: + SRectangle startBlockRect; + SRectangle goalBlockRect; }; #endif + diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathFinder.h spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathFinder.h --- spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathFinder.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathFinder.h 2014-10-07 20:09:51.000000000 +0000 @@ -4,10 +4,11 @@ #define PATH_FINDER_H #include -#include -#include +#include +#include #include "IPath.h" +#include "IPathFinder.h" #include "PathConstants.h" #include "PathDataTypes.h" #include "Sim/Objects/SolidObject.h" @@ -16,75 +17,33 @@ class CPathFinderDef; -class CPathFinder { +class CPathFinder: public IPathFinder { public: CPathFinder(); - ~CPathFinder(); - void* operator new(size_t size); - void operator delete(void* p, size_t size); + static void InitDirectionVectorsTable(); + static void InitDirectionCostsTable(); - /** - * Gives a detailed path from given starting location to target defined in - * CPathFinderDef, whenever any such are available. - * If no complete path was found, any path leading as "close" to target as - * possible will be created, and SearchResult::OutOfRange will be returned. - * Only when no "closer" position than the given starting location could be - * found no path is created, and SearchResult::CantGetCloser is returned. - * Path resolution: 2*SQUARE_SIZE - * - * @param moveDef defining the footprint of the unit requesting the path. - * @param startPos The starting location of the path. (Projected onto (x,z)) - * @param pfDef Object defining the target/goal of the search. - * Could also be used to put constraints on the searchspace used. - * @param path If any path could be found, it will be generated and put into - * this structure. - * @param exactPath Overrides the return of the "closest" path. - * If this option is true, a path is returned only if it's completed all - * the way to the goal defined in pfDef. All SearchResult::OutOfRange are - * then turned into SearchResult::CantGetCloser. - * @param maxNodes The maximum number of nodes / squares the search is - * allowed to analyze. This restriction could be used in cases where - * CPU-consumption is critical. - */ - IPath::SearchResult GetPath( - const MoveDef& moveDef, - const CPathFinderDef& pfDef, - const CSolidObject* owner, - const float3& startPos, - IPath::Path& path, - unsigned int maxNodes, - bool testMobile, - bool exactPath, - bool needPath, - bool synced - ); - - - // size of the memory-region we hold allocated (excluding sizeof(*this)) - // (PathManager stores HeatMap and FlowMap, so we do not need to add them) - unsigned int GetMemFootPrint() const { return (squareStates.GetMemFootPrint()); } + static const int2* GetDirectionVectorsTable2D(); + static const float3* GetDirectionVectorsTable3D(); - PathNodeStateBuffer& GetNodeStateBuffer() { return squareStates; } - -private: - /// Clear things up from last search. - void ResetSearch(); - /// Set up the starting point of the search. - IPath::SearchResult InitSearch(const MoveDef& moveDef, const CPathFinderDef& pfDef, const CSolidObject* owner, bool synced); +protected: // IPathFinder impl /// Performs the actual search. - IPath::SearchResult DoSearch(const MoveDef& moveDef, const CPathFinderDef& pfDef, const CSolidObject* owner, bool synced); + IPath::SearchResult DoSearch(const MoveDef& moveDef, const CPathFinderDef& pfDef, const CSolidObject* owner); + /** * Test the availability and value of a square, * and possibly add it to the queue of open squares. */ - bool TestSquare( + bool TestBlock( const MoveDef& moveDef, const CPathFinderDef& pfDef, - const PathNode* parentOpenSquare, + const PathNode* parentSquare, const CSolidObject* owner, - unsigned int pathOptDir, - bool synced + const unsigned int pathOptDir, + const unsigned int blockStatus, + float speedMod, + bool withinConstraints ); /** * Recreates the path found by pathfinder. @@ -92,43 +51,55 @@ * * Perform adjustment of waypoints so not all turns are 90 or 45 degrees. */ - void FinishSearch(const MoveDef&, IPath::Path&); + IPath::SearchResult FinishSearch(const MoveDef&, const CPathFinderDef&, IPath::Path&) const; + + const CPathCache::CacheItem* GetCache( + const int2 strtBlock, + const int2 goalBlock, + float goalRadius, + int pathType, + const bool synced + ) const { + // only cache in Estimator! (cause of flow & heatmapping etc.) + return nullptr; + } + + void AddCache( + const IPath::Path* path, + const IPath::SearchResult result, + const int2 strtBlock, + const int2 goalBlock, + float goalRadius, + int pathType, + const bool synced + ) { } + +private: + void TestNeighborSquares( + const MoveDef& moveDef, + const CPathFinderDef& pfDef, + const PathNode* parentSquare, + const CSolidObject* owner + ); + /** * Adjusts the found path to cut corners where possible. */ void AdjustFoundPath( const MoveDef&, IPath::Path&, - float3& nextPoint, + const float3 nextPoint, std::deque& previous, int2 square - ); - + ) const; - int2 directionVectors2D[PATH_DIRECTIONS << 1]; - float3 directionVectors3D[PATH_DIRECTIONS << 1]; - float directionCosts[PATH_DIRECTIONS << 1]; - - float3 start; - - unsigned int startxSqr; - unsigned int startzSqr; - unsigned int mStartSquareIdx; - unsigned int mGoalSquareIdx; ///< set during each search as the square closest to the goal - float mGoalHeuristic; ///< heuristic value of goalSquareIdx - - bool exactPath; - bool testMobile; - bool needPath; - - unsigned int maxOpenNodes; - unsigned int testedNodes; - - PathNodeBuffer openSquareBuffer; - PathNodeStateBuffer squareStates; - PathPriorityQueue openSquares; - - std::vector dirtySquares; ///< Squares tested by search. + inline void SmoothMidWaypoint( + const int2 testsqr, + const int2 prvsqr, + const MoveDef& moveDef, + IPath::Path& foundPath, + const float3 nextPoint + ) const; }; #endif // PATH_FINDER_H diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathFlowMap.cpp spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathFlowMap.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathFlowMap.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathFlowMap.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -35,8 +35,8 @@ fBufferIdx = 0; bBufferIdx = 1; - xscale = std::max(1, std::min(gs->mapx, int(scalex))); - zscale = std::max(1, std::min(gs->mapy, int(scalez))); + xscale = Clamp(int(scalex), 1, gs->mapx); + zscale = Clamp(int(scalez), 1, gs->mapy); xsize = gs->mapx / xscale; zsize = gs->mapy / zscale; xfact = SQUARE_SIZE * xscale; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathHeatMap.cpp spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathHeatMap.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathHeatMap.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathHeatMap.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -53,11 +53,7 @@ if (!owner->moveDef->heatMapping) return; - #ifndef USE_GML - static std::vector points; - #else std::vector points; - #endif pm->GetDetailedPathSquares(pathID, points); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathManager.cpp spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathManager.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathManager.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathManager.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -23,35 +23,51 @@ CPathManager::CPathManager(): nextPathID(0) { + CPathFinder::InitDirectionVectorsTable(); + CPathFinder::InitDirectionCostsTable(); + + maxResPF = NULL; + medResPE = NULL; + lowResPE = NULL; + pathFlowMap = PathFlowMap::GetInstance(); pathHeatMap = PathHeatMap::GetInstance(); - - maxResPF = new CPathFinder(); - medResPE = new CPathEstimator(maxResPF, MEDRES_PE_BLOCKSIZE, "pe", mapInfo->map.name); - lowResPE = new CPathEstimator(maxResPF, LOWRES_PE_BLOCKSIZE, "pe2", mapInfo->map.name); - - LOG("[CPathManager] pathing data checksum: %08x", GetPathCheckSum()); - - #ifdef SYNCDEBUG - // clients may have a non-writable cache directory (which causes - // the estimator path-file checksum to remain zero), so we can't - // update the sync-checker with this in normal builds - // NOTE: better to just checksum the in-memory data and broadcast - // that instead of relying on the zip-file CRC? - { SyncedUint tmp(GetPathCheckSum()); } - #endif } CPathManager::~CPathManager() { - delete lowResPE; - delete medResPE; - delete maxResPF; + delete lowResPE; lowResPE = NULL; + delete medResPE; medResPE = NULL; + delete maxResPF; maxResPF = NULL; PathHeatMap::FreeInstance(pathHeatMap); PathFlowMap::FreeInstance(pathFlowMap); } +boost::int64_t CPathManager::Finalize() { + const spring_time t0 = spring_gettime(); + + { + maxResPF = new CPathFinder(); + medResPE = new CPathEstimator(maxResPF, MEDRES_PE_BLOCKSIZE, "pe", mapInfo->map.name); + lowResPE = new CPathEstimator(medResPE, LOWRES_PE_BLOCKSIZE, "pe2", mapInfo->map.name); + + #ifdef SYNCDEBUG + // clients may have a non-writable cache directory (which causes + // the estimator path-file checksum to remain zero), so we can't + // update the sync-checker with this in normal builds + // NOTE: better to just checksum the in-memory data and broadcast + // that instead of relying on the zip-file CRC? + { SyncedUint tmp(GetPathCheckSum()); } + #endif + } + + const spring_time t1 = spring_gettime(); + const spring_time dt = t1 - t0; + + return (dt.toMilliSecsi()); +} + /* @@ -70,17 +86,56 @@ float3 gp(goalPos); gp.ClampInBounds(); // Create an estimator definition. - CRangedGoalWithCircularConstraint* pfDef = new CRangedGoalWithCircularConstraint(sp, gp, goalRadius, 3.0f, 2000); + CCircularSearchConstraint* pfDef = new CCircularSearchConstraint(sp, gp, goalRadius, 3.0f, 2000); // Make request. return (RequestPath(moveDef, sp, gp, pfDef, caller, synced)); } + +void CPathManager::FinalizePath(MultiPath* path, const float3 startPos, const float3 goalPos, const bool cantGetCloser) +{ + IPath::Path* sp = &path->lowResPath; + if (!path->medResPath.path.empty()) { + sp = &path->medResPath; + } + if (!path->maxResPath.path.empty()) { + sp = &path->maxResPath; + } + if (!sp->path.empty()) { + sp->path.back() = startPos; + sp->path.back().y = CMoveMath::yLevel(*path->moveDef, sp->path.back()); + } + + if (!path->maxResPath.path.empty() && !path->medResPath.path.empty()) { + path->medResPath.path.back() = path->maxResPath.path.front(); + } + if (!path->medResPath.path.empty() && !path->lowResPath.path.empty()) { + path->lowResPath.path.back() = path->medResPath.path.front(); + } + + if (cantGetCloser) + return; + + IPath::Path* ep = &path->maxResPath; + if (!path->medResPath.path.empty()) { + ep = &path->medResPath; + } + if (!path->lowResPath.path.empty()) { + ep = &path->lowResPath; + } + if (!ep->path.empty()) { + ep->path.front() = goalPos; + ep->path.front().y = CMoveMath::yLevel(*path->moveDef, ep->path.front()); + } +} + + /* Request a new multipath, store the result and return a handle-id to it. */ unsigned int CPathManager::RequestPath( - const MoveDef* md, + const MoveDef* moveDef, const float3& startPos, const float3& goalPos, CPathFinderDef* pfDef, @@ -89,16 +144,17 @@ ) { SCOPED_TIMER("PathManager::RequestPath"); - // FIXME: this is here only because older code required a non-const version - MoveDef* moveDef = moveDefHandler->GetMoveDefByPathType(md->pathType); + if (!IsFinalized()) + return 0; - assert(md == moveDef); + assert(moveDef == moveDefHandler->GetMoveDefByPathType(moveDef->pathType)); // Creates a new multipath. IPath::SearchResult result = IPath::Error; MultiPath* newPath = new MultiPath(startPos, pfDef, moveDef); newPath->finalGoal = goalPos; newPath->caller = caller; + pfDef->synced = synced; if (caller != NULL) { caller->UnBlock(); @@ -110,10 +166,10 @@ // NOTE: this distance can be far smaller than the actual path length! // NOTE: take height difference into consideration for "special" cases // (unit at top of cliff, goal at bottom or vv.) - const float goalDist2D = pfDef->Heuristic(startPos.x / SQUARE_SIZE, startPos.z / SQUARE_SIZE) + math::fabs(goalPos.y - startPos.y) / SQUARE_SIZE; + const float heuristicGoalDist2D = pfDef->Heuristic(startPos.x / SQUARE_SIZE, startPos.z / SQUARE_SIZE) + math::fabs(goalPos.y - startPos.y) / SQUARE_SIZE; - if (goalDist2D < DETAILED_DISTANCE) { - result = maxResPF->GetPath(*moveDef, *pfDef, caller, startPos, newPath->maxResPath, MAX_SEARCHED_NODES_PF >> 3, true, false, true, synced); + if (heuristicGoalDist2D < MAXRES_SEARCH_DISTANCE) { + result = maxResPF->GetPath(*moveDef, *pfDef, caller, startPos, newPath->maxResPath, MAX_SEARCHED_NODES_PF >> 3); #if (PM_UNCONSTRAINED_MAXRES_FALLBACK_SEARCH == 1) // unnecessary so long as a fallback path exists within the @@ -125,17 +181,18 @@ // fallback (note that this uses the estimators as backup, // unconstrained PF queries are too expensive on average) if (result != IPath::Ok) { - result = medResPE->GetPath(*moveDef, *pfDef, startPos, newPath->medResPath, MAX_SEARCHED_NODES_PE >> 3, synced); + result = medResPE->GetPath(*moveDef, *pfDef, caller, startPos, newPath->medResPath, MAX_SEARCHED_NODES_PE >> 3); } if (result != IPath::Ok) { - result = lowResPE->GetPath(*moveDef, *pfDef, startPos, newPath->lowResPath, MAX_SEARCHED_NODES_PE >> 3, synced); + result = lowResPE->GetPath(*moveDef, *pfDef, caller, startPos, newPath->lowResPath, MAX_SEARCHED_NODES_PE >> 3); } - } else if (goalDist2D < ESTIMATE_DISTANCE) { - result = medResPE->GetPath(*moveDef, *pfDef, startPos, newPath->medResPath, MAX_SEARCHED_NODES_PE >> 3, synced); + } else if (heuristicGoalDist2D < MEDRES_SEARCH_DISTANCE) { + result = medResPE->GetPath(*moveDef, *pfDef, caller, startPos, newPath->medResPath, MAX_SEARCHED_NODES_PE >> 3); // CantGetCloser may be a false positive due to PE approximations and large goalRadius - if (result == IPath::CantGetCloser && (startPos - goalPos).SqLength2D() > pfDef->sqGoalRadius) - result = maxResPF->GetPath(*moveDef, *pfDef, caller, startPos, newPath->maxResPath, MAX_SEARCHED_NODES_PF >> 3, true, false, true, synced); + if (result == IPath::CantGetCloser && (startPos - goalPos).SqLength2D() > pfDef->sqGoalRadius) { + result = maxResPF->GetPath(*moveDef, *pfDef, caller, startPos, newPath->maxResPath, MAX_SEARCHED_NODES_PF >> 3); + } #if (PM_UNCONSTRAINED_MEDRES_FALLBACK_SEARCH == 1) pfDef->DisableConstraint(true); @@ -143,18 +200,18 @@ // fallback if (result != IPath::Ok) { - result = medResPE->GetPath(*moveDef, *pfDef, startPos, newPath->medResPath, MAX_SEARCHED_NODES_PE >> 3, synced); + result = medResPE->GetPath(*moveDef, *pfDef, caller, startPos, newPath->medResPath, MAX_SEARCHED_NODES_PE >> 3); } } else { - result = lowResPE->GetPath(*moveDef, *pfDef, startPos, newPath->lowResPath, MAX_SEARCHED_NODES_PE >> 3, synced); + result = lowResPE->GetPath(*moveDef, *pfDef, caller, startPos, newPath->lowResPath, MAX_SEARCHED_NODES_PE >> 3); // CantGetCloser may be a false positive due to PE approximations and large goalRadius if (result == IPath::CantGetCloser && (startPos - goalPos).SqLength2D() > pfDef->sqGoalRadius) { - result = medResPE->GetPath(*moveDef, *pfDef, startPos, newPath->medResPath, MAX_SEARCHED_NODES_PE >> 3, synced); + result = medResPE->GetPath(*moveDef, *pfDef, caller, startPos, newPath->medResPath, MAX_SEARCHED_NODES_PE >> 3); #if 0 if (result == IPath::CantGetCloser) // Same thing again - result = maxResPF->GetPath(*moveDef, *pfDef, caller, startPos, newPath->maxResPath, MAX_SEARCHED_NODES_PF >> 3, true, false, true, synced); + result = maxResPF->GetPath(*moveDef, *pfDef, caller, startPos, newPath->maxResPath, MAX_SEARCHED_NODES_PF >> 3); #endif } @@ -164,7 +221,7 @@ // fallback if (result != IPath::Ok) { - result = lowResPE->GetPath(*moveDef, *pfDef, startPos, newPath->lowResPath, MAX_SEARCHED_NODES_PE >> 3, synced); + result = lowResPE->GetPath(*moveDef, *pfDef, caller, startPos, newPath->lowResPath, MAX_SEARCHED_NODES_PE >> 3); } } @@ -186,6 +243,7 @@ } } + FinalizePath(newPath, startPos, goalPos, result == IPath::CantGetCloser); newPath->searchResult = result; pathID = Store(newPath); } else { @@ -210,9 +268,11 @@ } -// converts part of a med-res path into a high-res path +// converts part of a med-res path into a max-res path void CPathManager::MedRes2MaxRes(MultiPath& multiPath, const float3& startPos, const CSolidObject* owner, bool synced) const { + assert(IsFinalized()); + IPath::Path& maxResPath = multiPath.maxResPath; IPath::Path& medResPath = multiPath.medResPath; IPath::Path& lowResPath = multiPath.lowResPath; @@ -222,32 +282,29 @@ medResPath.path.pop_back(); - // Remove estimate waypoints until - // the next one is far enough. - while (!medResPath.path.empty() && - medResPath.path.back().SqDistance2D(startPos) < Square(DETAILED_DISTANCE * SQUARE_SIZE)) + // remove med-res waypoints until the next one is far enough + while (!medResPath.path.empty() && (medResPath.path.back()).SqDistance2D(startPos) < Square(MAXRES_SEARCH_DISTANCE * SQUARE_SIZE)) { medResPath.path.pop_back(); + } // get the goal of the detailed search - float3 goalPos; - - if (medResPath.path.empty()) { - goalPos = medResPath.pathGoal; - } else { + float3 goalPos = medResPath.pathGoal; + if (!medResPath.path.empty()) { goalPos = medResPath.path.back(); } // define the search - CRangedGoalWithCircularConstraint rangedGoalPFD(startPos, goalPos, 0.0f, 2.0f, 1000); + CCircularSearchConstraint rangedGoalPFD(startPos, goalPos, 0.0f, 2.0f, 1000); + rangedGoalPFD.synced = synced; // Perform the search. // If this is the final improvement of the path, then use the original goal. IPath::SearchResult result = IPath::Error; if (medResPath.path.empty() && lowResPath.path.empty()) { - result = maxResPF->GetPath(*multiPath.moveDef, *multiPath.peDef, owner, startPos, maxResPath, MAX_SEARCHED_NODES_PF >> 3, true, false, true, synced); + result = maxResPF->GetPath(*multiPath.moveDef, *multiPath.peDef, owner, startPos, maxResPath, MAX_SEARCHED_NODES_PF >> 3); } else { - result = maxResPF->GetPath(*multiPath.moveDef, rangedGoalPFD, owner, startPos, maxResPath, MAX_SEARCHED_NODES_PF >> 3, true, false, true, synced); + result = maxResPF->GetPath(*multiPath.moveDef, rangedGoalPFD, owner, startPos, maxResPath, MAX_SEARCHED_NODES_PF >> 3); } // If no refined path could be found, set goal as desired goal. @@ -259,6 +316,8 @@ // converts part of a low-res path into a med-res path void CPathManager::LowRes2MedRes(MultiPath& multiPath, const float3& startPos, const CSolidObject* owner, bool synced) const { + assert(IsFinalized()); + IPath::Path& medResPath = multiPath.medResPath; IPath::Path& lowResPath = multiPath.lowResPath; @@ -267,14 +326,12 @@ lowResPath.path.pop_back(); - // Remove estimate2 waypoints until - // the next one is far enough - while (!lowResPath.path.empty() && - lowResPath.path.back().SqDistance2D(startPos) < Square(ESTIMATE_DISTANCE * SQUARE_SIZE)) { + // remove low-res waypoints until the next one is far enough + while (!lowResPath.path.empty() && (lowResPath.path.back()).SqDistance2D(startPos) < Square(MEDRES_SEARCH_DISTANCE * SQUARE_SIZE)) { lowResPath.path.pop_back(); } - //Get the goal of the detailed search. + // get the goal of the detailed search float3 goalPos; if (lowResPath.path.empty()) { @@ -284,16 +341,17 @@ } // define the search - CRangedGoalWithCircularConstraint rangedGoalDef(startPos, goalPos, 0.0f, 2.0f, 20); + CCircularSearchConstraint rangedGoalDef(startPos, goalPos, 0.0f, 2.0f, 20); + rangedGoalDef.synced = synced; // Perform the search. - // If there is no estimate2 path left, use original goal. + // If there is no low-res path left, use original goal. IPath::SearchResult result = IPath::Error; if (lowResPath.path.empty()) { - result = medResPE->GetPath(*multiPath.moveDef, *multiPath.peDef, startPos, medResPath, MAX_SEARCHED_NODES_ON_REFINE, synced); + result = medResPE->GetPath(*multiPath.moveDef, *multiPath.peDef, owner, startPos, medResPath, MAX_SEARCHED_NODES_ON_REFINE); } else { - result = medResPE->GetPath(*multiPath.moveDef, rangedGoalDef, startPos, medResPath, MAX_SEARCHED_NODES_ON_REFINE, synced); + result = medResPE->GetPath(*multiPath.moveDef, rangedGoalDef, owner, startPos, medResPath, MAX_SEARCHED_NODES_ON_REFINE); } // If no refined path could be found, set goal as desired goal. @@ -318,57 +376,69 @@ const float3 noPathPoint = -XZVector; - // 0 indicates a no-path id - if (pathID == 0) + if (!IsFinalized()) return noPathPoint; - if (numRetries > 4) + // 0 indicates the null-path ID + if (pathID == 0) return noPathPoint; - // Find corresponding multipath. + // find corresponding multipath entry MultiPath* multiPath = GetMultiPath(pathID); + if (multiPath == NULL) return noPathPoint; - if (callerPos == ZeroVector) { - if (!multiPath->maxResPath.path.empty()) - callerPos = multiPath->maxResPath.path.back(); + if (numRetries > MAX_PATH_REFINEMENT_DEPTH) + return (multiPath->finalGoal); + + IPath::Path& maxResPath = multiPath->maxResPath; + IPath::Path& medResPath = multiPath->medResPath; + IPath::Path& lowResPath = multiPath->lowResPath; + + if ((callerPos == ZeroVector) && !maxResPath.path.empty()) { + callerPos = maxResPath.path.back(); } - // check if detailed path needs bettering - if (!multiPath->medResPath.path.empty() && - (multiPath->medResPath.path.back().SqDistance2D(callerPos) < Square(MIN_DETAILED_DISTANCE * SQUARE_SIZE) || - multiPath->maxResPath.path.size() <= 2)) { - - if (!multiPath->lowResPath.path.empty() && // if so, check if estimated path also needs bettering - (multiPath->lowResPath.path.back().SqDistance2D(callerPos) < Square(MIN_ESTIMATE_DISTANCE * SQUARE_SIZE) || - multiPath->medResPath.path.size() <= 2)) { + assert(multiPath->peDef->synced == synced); + #define EXTEND_PATH_POINTS(curResPts, nxtResPts, dist) ((!curResPts.empty() && (curResPts.back()).SqDistance2D(callerPos) < Square((dist))) || nxtResPts.size() <= 2) + const bool extendMaxResPath = EXTEND_PATH_POINTS(medResPath.path, maxResPath.path, MIN_MAXRES_SEARCH_DISTANCE * SQUARE_SIZE); + const bool extendMedResPath = EXTEND_PATH_POINTS(lowResPath.path, medResPath.path, MIN_MEDRES_SEARCH_DISTANCE * SQUARE_SIZE); + #undef EXTEND_PATH_POINTS + + // check whether the max-res path needs extending through + // recursive refinement of its lower-resolution segments + // if so, check if the med-res path also needs extending + if (extendMaxResPath) { + if (extendMedResPath) { LowRes2MedRes(*multiPath, callerPos, owner, synced); } - if (multiPath->caller) { + if (multiPath->caller != NULL) { multiPath->caller->UnBlock(); } MedRes2MaxRes(*multiPath, callerPos, owner, synced); - if (multiPath->caller) { + if (multiPath->caller != NULL) { multiPath->caller->Block(); } + + FinalizePath(multiPath, callerPos, multiPath->finalGoal, multiPath->searchResult == IPath::CantGetCloser); } float3 waypoint; do { - // get the next waypoint from the high-res path + // get the next waypoint from the max-res path // // if this is not possible, then either we are // at the goal OR the path could not reach all // the way to it (ie. a GoalOutOfRange result) // OR we are stuck on an impassable square - if (multiPath->maxResPath.path.empty()) { - if (multiPath->lowResPath.path.empty() && multiPath->medResPath.path.empty()) { + if (maxResPath.path.empty()) { + if (lowResPath.path.empty() && medResPath.path.empty()) { if (multiPath->searchResult == IPath::Ok) { waypoint = multiPath->finalGoal; break; } else { @@ -380,28 +450,27 @@ break; } } else { - waypoint = multiPath->maxResPath.path.back(); - multiPath->maxResPath.path.pop_back(); + waypoint = maxResPath.path.back(); + maxResPath.path.pop_back(); } - } while (callerPos.SqDistance2D(waypoint) < Square(radius) && waypoint != multiPath->maxResPath.pathGoal); + } while ((callerPos.SqDistance2D(waypoint) < Square(radius)) && (waypoint != maxResPath.pathGoal)); - // indicate this is not a temporary waypoint - // (the default PFS does not queue requests) - waypoint.y = 0.0f; - - return waypoint; + // y=0 indicates this is not a temporary waypoint + // (the default PFS does not queue path-requests) + return (waypoint * XZVector); } // Delete a given multipath from the collection. void CPathManager::DeletePath(unsigned int pathID) { - // 0 indicate a no-path id. if (pathID == 0) return; - const std::map::const_iterator pi = pathMap.find(pathID); + const auto pi = pathMap.find(pathID); + if (pi == pathMap.end()) return; + MultiPath* multiPath = pi->second; pathMap.erase(pathID); delete multiPath; @@ -411,8 +480,14 @@ // Tells estimators about changes in or on the map. void CPathManager::TerrainChange(unsigned int x1, unsigned int z1, unsigned int x2, unsigned int z2, unsigned int /*type*/) { + SCOPED_TIMER("PathManager::TerrainChange"); + + if (!IsFinalized()) + return; + medResPE->MapChanged(x1, z1, x2, z2); - lowResPE->MapChanged(x1, z1, x2, z2); + if (medResPE->nextPathEstimator == nullptr) + lowResPE->MapChanged(x1, z1, x2, z2); // is informed via medResPE } @@ -420,6 +495,7 @@ void CPathManager::Update() { SCOPED_TIMER("PathManager::Update"); + assert(IsFinalized()); pathFlowMap->Update(); pathHeatMap->Update(); @@ -428,17 +504,11 @@ lowResPE->Update(); } - -void CPathManager::UpdateFull() -{ - medResPE->UpdateFull(); - lowResPE->UpdateFull(); -} - - // used to deposit heat on the heat-map as a unit moves along its path void CPathManager::UpdatePath(const CSolidObject* owner, unsigned int pathID) { + assert(IsFinalized()); + pathFlowMap->AddFlow(owner); pathHeatMap->AddHeat(owner, this, pathID); } @@ -451,14 +521,16 @@ points.clear(); MultiPath* multiPath = GetMultiPath(pathID); + if (multiPath == NULL) return; - const IPath::path_list_type& maxResPoints = multiPath->maxResPath.path; + const IPath::Path& path = multiPath->maxResPath; + const IPath::path_list_type& maxResPoints = path.path; points.reserve(maxResPoints.size()); - for (IPath::path_list_type::const_reverse_iterator pvi = maxResPoints.rbegin(); pvi != maxResPoints.rend(); ++pvi) { + for (auto pvi = maxResPoints.rbegin(); pvi != maxResPoints.rend(); ++pvi) { points.push_back(*pvi); } } @@ -468,14 +540,16 @@ points.clear(); MultiPath* multiPath = GetMultiPath(pathID); + if (multiPath == NULL) return; - const IPath::square_list_type& maxResSquares = multiPath->maxResPath.squares; + const IPath::Path& path = multiPath->maxResPath; + const IPath::square_list_type& maxResSquares = path.squares; points.reserve(maxResSquares.size()); - for (IPath::square_list_type::const_reverse_iterator pvi = maxResSquares.rbegin(); pvi != maxResSquares.rend(); ++pvi) { + for (auto pvi = maxResSquares.rbegin(); pvi != maxResSquares.rend(); ++pvi) { points.push_back(*pvi); } } @@ -491,6 +565,7 @@ starts.clear(); MultiPath* multiPath = GetMultiPath(pathID); + if (multiPath == NULL) return; @@ -522,12 +597,16 @@ boost::uint32_t CPathManager::GetPathCheckSum() const { + assert(IsFinalized()); return (medResPE->GetPathChecksum() + lowResPE->GetPathChecksum()); } bool CPathManager::SetNodeExtraCost(unsigned int x, unsigned int z, float cost, bool synced) { + if (!IsFinalized()) + return 0.0f; + if (x >= gs->mapx) { return false; } if (z >= gs->mapy) { return false; } @@ -542,6 +621,9 @@ } bool CPathManager::SetNodeExtraCosts(const float* costs, unsigned int sizex, unsigned int sizez, bool synced) { + if (!IsFinalized()) + return 0.0f; + if (sizex < 1 || sizex > gs->mapx) { return false; } if (sizez < 1 || sizez > gs->mapy) { return false; } @@ -557,6 +639,9 @@ } float CPathManager::GetNodeExtraCost(unsigned int x, unsigned int z, bool synced) const { + if (!IsFinalized()) + return 0.0f; + if (x >= gs->mapx) { return 0.0f; } if (z >= gs->mapy) { return 0.0f; } @@ -566,6 +651,9 @@ } const float* CPathManager::GetNodeExtraCosts(bool synced) const { + if (!IsFinalized()) + return NULL; + const PathNodeStateBuffer& buf = maxResPF->GetNodeStateBuffer(); const float* costs = buf.GetNodeExtraCosts(synced); return costs; @@ -573,8 +661,12 @@ int2 CPathManager::GetNumQueuedUpdates() const { int2 data; - data.x = medResPE->updatedBlocks.size(); - data.y = lowResPE->updatedBlocks.size(); + + if (IsFinalized()) { + data.x = medResPE->updatedBlocks.size(); + data.y = lowResPE->updatedBlocks.size(); + } + return data; } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathManager.h spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathManager.h --- spring-96.0~14.04~ppa4/rts/Sim/Path/Default/PathManager.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/Default/PathManager.h 2014-10-07 20:09:51.000000000 +0000 @@ -26,8 +26,9 @@ unsigned int GetPathFinderType() const { return PFS_TYPE_DEFAULT; } boost::uint32_t GetPathCheckSum() const; + boost::int64_t Finalize(); + void Update(); - void UpdateFull(); void UpdatePath(const CSolidObject*, unsigned int); void DeletePath(unsigned int pathID); @@ -120,9 +121,13 @@ inline MultiPath* GetMultiPath(int pathID) const; unsigned int Store(MultiPath* path); + static void FinalizePath(MultiPath* path, const float3 startPos, const float3 goalPos, const bool cantGetCloser); void LowRes2MedRes(MultiPath& path, const float3& startPos, const CSolidObject* owner, bool synced) const; void MedRes2MaxRes(MultiPath& path, const float3& startPos, const CSolidObject* owner, bool synced) const; + bool IsFinalized() const { return (maxResPF != NULL); } + +private: CPathFinder* maxResPF; CPathEstimator* medResPE; CPathEstimator* lowResPE; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/IPathController.cpp spring-98.0~14.04~ppa6/rts/Sim/Path/IPathController.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Path/IPathController.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/IPathController.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -31,7 +31,7 @@ const float modAccRate = std::min(absSpeedDiff, maxAccRate); const float modDecRate = std::min(absSpeedDiff, maxDecRate); - const float deltaSpeed = (rawSpeedDiff < 0.0f)? -modDecRate: modAccRate; + const float deltaSpeed = mix(modAccRate, -modDecRate, (rawSpeedDiff < 0.0f)); // no acceleration changes if not on ground // @@ -42,6 +42,7 @@ return (deltaSpeed * (1 - owner->IsInAir())); } +#if 1 short GMTDefaultPathController::GetDeltaHeading( unsigned int pathID, short newHeading, @@ -59,6 +60,46 @@ // no orientation changes if not on ground return (deltaHeading * (1 - owner->IsInAir())); } +#endif + + + +static float TurnAccelerationSign(float turnBrakeDist, short curDeltaHeading, short newDeltaHeading) { + const bool b0 = (turnBrakeDist >= std::abs(curDeltaHeading)); + const bool b1 = (std::abs(newDeltaHeading) <= std::abs(curDeltaHeading)); + const bool b2 = (Sign(curDeltaHeading) != Sign(newDeltaHeading)); + + return (mix(1.0f, -1.0f, b0 && (b1 || b2))); +} + +short GMTDefaultPathController::GetDeltaHeading( + unsigned int pathID, + short newHeading, + short oldHeading, + float maxTurnSpeed, + float maxTurnAccel, + float turnBrakeDist, + float* curTurnSpeed +) const { + // negative --> RH turn, positive --> LH turn + // add lookahead term to avoid micro-overshoots + const short curDeltaHeading = newHeading - short(oldHeading + (*curTurnSpeed) * (maxTurnAccel / maxTurnSpeed)); + + const float minTurnAccel = std::min(float(std::abs(curDeltaHeading)), maxTurnAccel); + const float rawTurnAccel = Clamp(Sign(curDeltaHeading) * maxTurnAccel, -minTurnAccel, minTurnAccel); + const float newTurnSpeed = Clamp((*curTurnSpeed) + rawTurnAccel * (1 - owner->IsInAir()), -maxTurnSpeed, maxTurnSpeed); + + // predict the new angular difference + const short newDeltaHeading = newHeading - short(oldHeading + newTurnSpeed); + + // flip acceleration sign when overshooting + const float modTurnAccel = rawTurnAccel * TurnAccelerationSign(turnBrakeDist, curDeltaHeading, newDeltaHeading); + + (*curTurnSpeed) += (modTurnAccel * (1 - owner->IsInAir())); + (*curTurnSpeed) = Clamp((*curTurnSpeed) * 0.99f, -maxTurnSpeed, maxTurnSpeed); + + return (*curTurnSpeed); +} bool GMTDefaultPathController::IgnoreTerrain(const MoveDef& md, const float3& pos) const { return (owner->IsInAir()); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/IPathController.hpp spring-98.0~14.04~ppa6/rts/Sim/Path/IPathController.hpp --- spring-96.0~14.04~ppa4/rts/Sim/Path/IPathController.hpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/IPathController.hpp 2014-10-07 20:09:51.000000000 +0000 @@ -34,12 +34,24 @@ // if a unit has a path to follow (and is not stunned, // being built, etc) this gets called every sim-frame + #if 1 virtual short GetDeltaHeading( unsigned int pathID, short newHeading, short oldHeading, float maxTurnRate ) const = 0; + #endif + + virtual short GetDeltaHeading( + unsigned int pathID, + short newHeading, + short oldHeading, + float maxTurnSpeed, + float maxTurnAccel, + float turnBrakeDist, + float* curTurnSpeed + ) const = 0; virtual bool AllowSetTempGoalPosition(unsigned int pathID, const float3& pos) const = 0; virtual void SetTempGoalPosition(unsigned int pathID, const float3& pos) = 0; @@ -72,12 +84,24 @@ bool isReversing ) const; + #if 1 short GetDeltaHeading( unsigned int pathID, short newHeading, short oldHeading, float maxTurnRate ) const; + #endif + + short GetDeltaHeading( + unsigned int pathID, + short newHeading, + short oldHeading, + float maxTurnSpeed, + float maxTurnAccel, + float turnBrakeDist, + float* curTurnSpeed + ) const; bool AllowSetTempGoalPosition(unsigned int pathID, const float3& pos) const { return true; } void SetTempGoalPosition(unsigned int pathID, const float3& pos) { realGoalPos = pos; } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/IPathManager.h spring-98.0~14.04~ppa6/rts/Sim/Path/IPathManager.h --- spring-96.0~14.04~ppa4/rts/Sim/Path/IPathManager.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/IPathManager.h 2014-10-07 20:09:51.000000000 +0000 @@ -21,6 +21,8 @@ virtual unsigned int GetPathFinderType() const = 0; virtual boost::uint32_t GetPathCheckSum() const { return 0; } + virtual boost::int64_t Finalize() { return 0; } + /** * returns if a path was changed after RequestPath returned its pathID * this can happen eg. if a PathManager reacts to TerrainChange events @@ -29,7 +31,6 @@ virtual bool PathUpdated(unsigned int pathID) { return false; } virtual void Update() {} - virtual void UpdateFull() {} virtual void UpdatePath(const CSolidObject* owner, unsigned int pathID) {} /** diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/QTPFS/NodeHeap.hpp spring-98.0~14.04~ppa6/rts/Sim/Path/QTPFS/NodeHeap.hpp --- spring-96.0~14.04~ppa4/rts/Sim/Path/QTPFS/NodeHeap.hpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/QTPFS/NodeHeap.hpp 2014-10-07 20:09:51.000000000 +0000 @@ -291,7 +291,7 @@ size_t cur_idx; // index of first free (unused) slot size_t max_idx; // index of last free (unused) slot }; -}; +} #endif diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/QTPFS/Node.hpp spring-98.0~14.04~ppa6/rts/Sim/Path/QTPFS/Node.hpp --- spring-96.0~14.04~ppa4/rts/Sim/Path/QTPFS/Node.hpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/QTPFS/Node.hpp 2014-10-07 20:09:51.000000000 +0000 @@ -205,7 +205,7 @@ // float3's are also more convenient to work with (so we take the memory hit) std::vector netpoints; }; -}; +} #endif diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/QTPFS/NodeLayer.hpp spring-98.0~14.04~ppa6/rts/Sim/Path/QTPFS/NodeLayer.hpp --- spring-96.0~14.04~ppa4/rts/Sim/Path/QTPFS/NodeLayer.hpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/QTPFS/NodeLayer.hpp 2014-10-07 20:09:51.000000000 +0000 @@ -122,7 +122,7 @@ float maxRelSpeedMod; float avgRelSpeedMod; }; -}; +} #endif diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/QTPFS/PathCache.hpp spring-98.0~14.04~ppa6/rts/Sim/Path/QTPFS/PathCache.hpp --- spring-96.0~14.04~ppa4/rts/Sim/Path/QTPFS/PathCache.hpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/QTPFS/PathCache.hpp 2014-10-07 20:09:51.000000000 +0000 @@ -57,7 +57,7 @@ std::vector numCacheHits; std::vector numCacheMisses; }; -}; +} #endif diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/QTPFS/PathEnums.hpp spring-98.0~14.04~ppa6/rts/Sim/Path/QTPFS/PathEnums.hpp --- spring-96.0~14.04~ppa4/rts/Sim/Path/QTPFS/PathEnums.hpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/QTPFS/PathEnums.hpp 2014-10-07 20:09:51.000000000 +0000 @@ -45,7 +45,7 @@ PATH_TYPE_LIVE = 1, PATH_TYPE_DEAD = 2, }; -}; +} #endif diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/QTPFS/Path.hpp spring-98.0~14.04~ppa6/rts/Sim/Path/QTPFS/Path.hpp --- spring-96.0~14.04~ppa4/rts/Sim/Path/QTPFS/Path.hpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/QTPFS/Path.hpp 2014-10-07 20:09:51.000000000 +0000 @@ -119,7 +119,7 @@ // object that requested this path (NULL if none) const CSolidObject* owner; }; -}; +} #endif diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/QTPFS/PathManager.cpp spring-98.0~14.04~ppa6/rts/Sim/Path/QTPFS/PathManager.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Path/QTPFS/PathManager.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/QTPFS/PathManager.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -22,7 +22,6 @@ #include "System/FileSystem/ArchiveScanner.h" #include "System/FileSystem/FileSystem.h" #include "System/Log/ILog.h" -#include "System/Platform/Watchdog.h" #include "System/Rectangle.h" #include "System/TimeProfiler.h" #include "System/Util.h" @@ -84,7 +83,7 @@ static size_t GetNumThreads() { const size_t numThreads = std::max(0, configHandler->GetInt("PathingThreadCount")); - const size_t numCores = Threading::GetAvailableCores(); + const size_t numCores = Threading::GetLogicalCpuCores(); return ((numThreads == 0)? numCores: numThreads); } @@ -98,17 +97,6 @@ QTNode::InitStatic(); NodeLayer::InitStatic(); PathManager::InitStatic(); - - pmLoadThread = boost::thread(boost::bind(&PathManager::Load, this)); - pmLoadScreen.Loop(); - pmLoadThread.join(); - - #ifdef QTPFS_ENABLE_THREADED_UPDATE - mutexThreadUpdate = new boost::mutex(); - condThreadUpdate = new boost::condition_variable(); - condThreadUpdated = new boost::condition_variable(); - updateThread = new boost::thread(boost::bind(&PathManager::ThreadUpdate, this)); - #endif } QTPFS::PathManager::~PathManager() { @@ -155,6 +143,28 @@ #endif } +boost::int64_t QTPFS::PathManager::Finalize() { + const spring_time t0 = spring_gettime(); + + { + pmLoadThread = boost::thread(boost::bind(&PathManager::Load, this)); + pmLoadScreen.Loop(); + pmLoadThread.join(); + + #ifdef QTPFS_ENABLE_THREADED_UPDATE + mutexThreadUpdate = new boost::mutex(); + condThreadUpdate = new boost::condition_variable(); + condThreadUpdated = new boost::condition_variable(); + updateThread = new boost::thread(boost::bind(&PathManager::ThreadUpdate, this)); + #endif + } + + const spring_time t1 = spring_gettime(); + const spring_time dt = t1 - t0; + + return (dt.toMilliSecsi()); +} + void QTPFS::PathManager::InitStatic() { LAYERS_PER_UPDATE = std::max(1u, mapInfo->pfs.qtpfs_constants.layersPerUpdate); MAX_TEAM_SEARCHES = std::max(1u, mapInfo->pfs.qtpfs_constants.maxTeamSearches); @@ -194,11 +204,13 @@ } // NOTE: - // should be sufficient in theory, because if either - // the map or the mod changes then the checksum does - // (should!) as well and we get a cache-miss - // this value is also combined with the tree-sums to - // make it depend on the tesselation code specifics + // should be sufficient in theory, because if either + // the map or the mod changes then the checksum does + // (should!) as well and we get a cache-miss + // this value is also combined with the tree-sums to + // make it depend on the tesselation code specifics + // FIXME: + // assumption is invalid now (Lua inits before we do) pfsCheckSum = mapCheckSum ^ modCheckSum; for (unsigned int layerNum = 0; layerNum < nodeLayers.size(); layerNum++) { @@ -226,7 +238,7 @@ { const std::string sumStr = "pfs-checksum: " + IntToString(pfsCheckSum, "%08x") + ", "; const std::string memStr = "mem-footprint: " + IntToString(GetMemFootPrint()) + "MB"; - pmLoadScreen.AddLoadMessage("[PathManager] " + sumStr + memStr); + pmLoadScreen.AddLoadMessage("[" + std::string(__FUNCTION__) + "] " + sumStr + memStr); pmLoadScreen.SetLoading(false); } } @@ -404,6 +416,8 @@ void QTPFS::PathManager::UpdateNodeLayer(unsigned int layerNum, const SRectangle& r) { const MoveDef* md = moveDefHandler->GetMoveDefByPathType(layerNum); + if (!IsFinalized()) + return; if (md->udRefCount == 0) return; @@ -621,7 +635,10 @@ void QTPFS::PathManager::TerrainChange(unsigned int x1, unsigned int z1, unsigned int x2, unsigned int z2, unsigned int type) { SCOPED_TIMER("PathManager::TerrainChange"); - // if type is TERRAINCHANGE_OBJECT_INSERTED or TERRAINCHANGE_OBJECT_INSERTED_YM, + if (!IsFinalized()) + return; + + // if type is TERRAINCHANGE_OBJECT_INSERTED or TERRAINCHANGE_OBJECT_INSERTED_YM, // this rectangle covers the yardmap of a CSolidObject* and will be tesselated to // maximum depth automatically numTerrainChanges += 1; @@ -662,20 +679,6 @@ #endif } -void QTPFS::PathManager::UpdateFull() { - assert(gs->frameNum == 0); - - #ifdef QTPFS_STAGGERED_LAYER_UPDATES - for (unsigned int layerNum = 0; layerNum < nodeLayers.size(); layerNum++) { - assert((pathCaches[layerNum].GetDeadPaths()).empty()); - assert((pathSearches[layerNum]).empty()); - - ExecQueuedNodeLayerUpdates(layerNum, true); - Watchdog::ClearTimer(); - } - #endif -} - __FORCE_ALIGN_STACK__ void QTPFS::PathManager::ThreadUpdate() { #ifdef QTPFS_ENABLE_THREADED_UPDATE @@ -973,6 +976,10 @@ bool synced) { SCOPED_TIMER("PathManager::RequestPath"); + + if (!IsFinalized()) + return 0; + return (QueueSearch(NULL, object, moveDef, sourcePoint, targetPoint, radius, synced)); } @@ -1012,6 +1019,8 @@ const PathTypeMap::const_iterator pathTypeIt = pathTypes.find(pathID); const float3 noPathPoint = -XZVector; + if (!IsFinalized()) + return noPathPoint; if (!synced) return noPathPoint; @@ -1110,6 +1119,8 @@ ) const { const PathTypeMap::const_iterator pathTypeIt = pathTypes.find(pathID); + if (!IsFinalized()) + return; if (pathTypeIt == pathTypes.end()) return; @@ -1132,9 +1143,11 @@ int2 data; #ifdef QTPFS_STAGGERED_LAYER_UPDATES - for (unsigned int layerNum = 0; layerNum < nodeLayers.size(); layerNum++) { - data.x += (nodeLayers[layerNum].HaveQueuedUpdate()); - data.y += (nodeLayers[layerNum].NumQueuedUpdates()); + if (IsFinalized()) { + for (unsigned int layerNum = 0; layerNum < nodeLayers.size(); layerNum++) { + data.x += (nodeLayers[layerNum].HaveQueuedUpdate()); + data.y += (nodeLayers[layerNum].NumQueuedUpdates()); + } } #endif diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/QTPFS/PathManager.hpp spring-98.0~14.04~ppa6/rts/Sim/Path/QTPFS/PathManager.hpp --- spring-96.0~14.04~ppa4/rts/Sim/Path/QTPFS/PathManager.hpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/QTPFS/PathManager.hpp 2014-10-07 20:09:51.000000000 +0000 @@ -36,11 +36,12 @@ unsigned int GetPathFinderType() const { return PFS_TYPE_QTPFS; } boost::uint32_t GetPathCheckSum() const { return pfsCheckSum; } + boost::int64_t Finalize(); + bool PathUpdated(unsigned int pathID); void TerrainChange(unsigned int x1, unsigned int z1, unsigned int x2, unsigned int z2, unsigned int type); void Update(); - void UpdateFull(); void UpdatePath(const CSolidObject* owner, unsigned int pathID); void DeletePath(unsigned int pathID); @@ -133,6 +134,8 @@ unsigned int pathType ); + bool IsFinalized() const { return (!nodeTrees.empty()); } + std::string GetCacheDirName(boost::uint32_t mapCheckSum, boost::uint32_t modCheckSum) const; void Serialize(const std::string& cacheFileDir); @@ -170,7 +173,7 @@ boost::condition_variable* condThreadUpdated; #endif }; -}; +} #endif diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Path/QTPFS/PathSearch.hpp spring-98.0~14.04~ppa6/rts/Sim/Path/QTPFS/PathSearch.hpp --- spring-96.0~14.04~ppa4/rts/Sim/Path/QTPFS/PathSearch.hpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Path/QTPFS/PathSearch.hpp 2014-10-07 20:09:51.000000000 +0000 @@ -50,7 +50,7 @@ // sim-frame at which the search was executed unsigned int searchFrame; }; - }; + } // NOTE: @@ -184,7 +184,7 @@ bool haveFullPath; bool havePartPath; }; -}; +} #endif diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/ExpGenSpawner.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/ExpGenSpawner.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/ExpGenSpawner.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/ExpGenSpawner.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -3,7 +3,7 @@ #include "ExpGenSpawner.h" #include "ExplosionGenerator.h" -CR_BIND_DERIVED(CExpGenSpawner, CProjectile, ); +CR_BIND_DERIVED(CExpGenSpawner, CProjectile, ) CR_REG_METADATA(CExpGenSpawner, ( @@ -13,7 +13,7 @@ CR_MEMBER(explosionGenerator), CR_MEMBER_ENDFLAG(CM_Config), CR_RESERVED(8) -)); +)) CExpGenSpawner::CExpGenSpawner() : CProjectile(), @@ -27,7 +27,7 @@ void CExpGenSpawner::Update() { - if (deleteMe |= ((delay--) <= 0)) { + if ((deleteMe |= ((delay--) <= 0))) { explosionGenerator->Explosion(pos, dir, damage, 0.0f, 0.0f, owner(), NULL); } } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/ExpGenSpawner.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/ExpGenSpawner.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/ExpGenSpawner.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/ExpGenSpawner.h 2014-10-07 20:09:51.000000000 +0000 @@ -10,7 +10,7 @@ //! spawns a given explosion-generator after \ frames class CExpGenSpawner : public CProjectile { - CR_DECLARE(CExpGenSpawner); + CR_DECLARE(CExpGenSpawner) public: CExpGenSpawner(); ~CExpGenSpawner() {} diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/ExplosionGenerator.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/ExplosionGenerator.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/ExplosionGenerator.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/ExplosionGenerator.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -38,15 +38,15 @@ #include "System/Util.h" -CR_BIND_DERIVED_INTERFACE(CExpGenSpawnable, CWorldObject); -CR_REG_METADATA(CExpGenSpawnable, ); +CR_BIND_DERIVED_INTERFACE(CExpGenSpawnable, CWorldObject) +CR_REG_METADATA(CExpGenSpawnable, ) -CR_BIND_INTERFACE(IExplosionGenerator); +CR_BIND_INTERFACE(IExplosionGenerator) CR_REG_METADATA(IExplosionGenerator, ( CR_MEMBER(generatorID) -)); +)) -CR_BIND_DERIVED(CStdExplosionGenerator, IExplosionGenerator, ); +CR_BIND_DERIVED(CStdExplosionGenerator, IExplosionGenerator, ) CR_BIND(CCustomExplosionGenerator::ProjectileSpawnInfo, ) CR_REG_METADATA_SUB(CCustomExplosionGenerator, ProjectileSpawnInfo, ( @@ -54,7 +54,7 @@ CR_MEMBER(code), CR_MEMBER(count), CR_MEMBER(flags) -)); +)) CR_BIND(CCustomExplosionGenerator::GroundFlashInfo, ) CR_REG_METADATA_SUB(CCustomExplosionGenerator, GroundFlashInfo, ( @@ -65,25 +65,25 @@ CR_MEMBER(ttl), CR_MEMBER(flags), CR_MEMBER(color) -)); +)) CR_BIND(CCustomExplosionGenerator::ExpGenParams, ) CR_REG_METADATA_SUB(CCustomExplosionGenerator, ExpGenParams, ( CR_MEMBER(projectiles), CR_MEMBER(groundFlash), CR_MEMBER(useDefaultExplosions) -)); +)) -CR_BIND_DERIVED(CCustomExplosionGenerator, CStdExplosionGenerator, ); +CR_BIND_DERIVED(CCustomExplosionGenerator, CStdExplosionGenerator, ) CR_REG_METADATA(CCustomExplosionGenerator, ( CR_MEMBER(expGenParams) -)); +)) CExplosionGeneratorHandler* explGenHandler = NULL; -CExpGenSpawnable::CExpGenSpawnable(): CWorldObject() { GML_EXPGEN_CHECK() } -CExpGenSpawnable::CExpGenSpawnable(const float3& pos, const float3& spd): CWorldObject(pos, spd) { GML_EXPGEN_CHECK() } +CExpGenSpawnable::CExpGenSpawnable(): CWorldObject() {} +CExpGenSpawnable::CExpGenSpawnable(const float3& pos, const float3& spd): CWorldObject(pos, spd) {} @@ -101,16 +101,35 @@ return flags; } -unsigned int CCustomExplosionGenerator::GetFlagsFromHeight(float height, float altitude) +unsigned int CCustomExplosionGenerator::GetFlagsFromHeight(float height, float groundHeight) { unsigned int flags = 0; + const float waterDist = std::abs(height); + const float altitude = height - groundHeight; + // note: ranges do not overlap, although code in // *ExplosionGenerator::Explosion assumes they can - if (height > 0.0f && altitude >= 20.0f) { flags |= CCustomExplosionGenerator::SPW_AIR; } - else if (height > 0.0f && altitude >= -1.0f) { flags |= CCustomExplosionGenerator::SPW_GROUND; } - else if (height > -5.0f && altitude >= -1.0f) { flags |= CCustomExplosionGenerator::SPW_WATER; } - else if (height <= -5.0f && altitude >= -1.0f) { flags |= CCustomExplosionGenerator::SPW_UNDERWATER; } + if (altitude < -1.0f) { + /* underground! don't spawn CEG! */ + } else + if (height >= 5.0f) { // above water + if (altitude >= 20.0f) { + flags |= CCustomExplosionGenerator::SPW_AIR; // air + } else { + flags |= CCustomExplosionGenerator::SPW_GROUND; // ground + } + } else + if (waterDist < 5.0f) { // water surface + if (groundHeight > -2.0f) { + flags |= CCustomExplosionGenerator::SPW_GROUND; // shallow water (use ground fx) + } else { + flags |= CCustomExplosionGenerator::SPW_WATER; // water (surface) + } + } else + /*if (height <= -5.0f) */ { // under water + flags |= CCustomExplosionGenerator::SPW_UNDERWATER; // underwater + } return flags; } @@ -355,20 +374,12 @@ CUnit* owner, CUnit* hit ) { - bool ret = false; - if (expGenID == EXPGEN_ID_INVALID) - return ret; + return false; assert(expGenID < explosionGenerators.size()); - if (expGenID == EXPGEN_ID_STANDARD) { - ret = explosionGenerators[EXPGEN_ID_STANDARD]->Explosion(pos, dir, damage, radius, gfxMod, owner, hit); - } else { - ret = explosionGenerators[expGenID]->Explosion(pos, dir, damage, radius, gfxMod, owner, hit); - } - - return ret; + return explosionGenerators[expGenID]->Explosion(pos, dir, damage, radius, gfxMod, owner, hit); } @@ -382,12 +393,12 @@ CUnit* owner, CUnit* hit ) { - const float groundHeight = ground->GetHeightReal(pos.x, pos.z); + const float groundHeight = CGround::GetHeightReal(pos.x, pos.z); const float altitude = pos.y - groundHeight; float3 camVect = camera->GetPos() - pos; - const unsigned int flags = CCustomExplosionGenerator::GetFlagsFromHeight(pos.y, altitude); + const unsigned int flags = CCustomExplosionGenerator::GetFlagsFromHeight(pos.y, groundHeight); const bool airExplosion = ((flags & CCustomExplosionGenerator::SPW_AIR ) != 0); const bool groundExplosion = ((flags & CCustomExplosionGenerator::SPW_GROUND ) != 0); const bool waterExplosion = ((flags & CCustomExplosionGenerator::SPW_WATER ) != 0); @@ -431,7 +442,7 @@ (-0.1f + gu->RandFloat() * 0.2f) ); - const float h = ground->GetApproximateHeight(npos.x, npos.z); + const float h = CGround::GetApproximateHeight(npos.x, npos.z); const float time = (40.0f + smokeDamageSQRT * 15.0f) * (0.8f + gu->RandFloat() * 0.7f); float3 npos = pos + gu->RandVector() * smokeDamage; @@ -584,11 +595,11 @@ if (radius > 40.0f && damage > 12.0f) { CSpherePartProjectile::CreateSphere( - pos, - std::min(0.7f, damage * 0.02f), + owner, 5.0f + int(sqrtDmg * 0.7f), + std::min(0.7f, damage * 0.02f), (8.0f + damage * 2.5f) / (9.0f + sqrtDmg * 0.7f) * 0.5f, - owner + pos ); } @@ -804,7 +815,7 @@ switch (basicType->id) { case creg::crInt: code.push_back(OP_STOREI); break; - case creg::crBool: code.push_back(OP_STOREI); break; + case creg::crBool: code.push_back(OP_STOREC); break; case creg::crFloat: code.push_back(OP_STOREF); break; case creg::crUChar: code.push_back(OP_STOREC); break; default: break; @@ -996,10 +1007,9 @@ CUnit* owner, CUnit* hit ) { - const float groundHeight = ground->GetHeightReal(pos.x, pos.z); - const float altitude = pos.y - groundHeight; + const float groundHeight = CGround::GetHeightReal(pos.x, pos.z); - unsigned int flags = GetFlagsFromHeight(pos.y, altitude); + unsigned int flags = GetFlagsFromHeight(pos.y, groundHeight); const bool groundExplosion = ((flags & CCustomExplosionGenerator::SPW_GROUND) != 0); if (hit) flags |= SPW_UNIT; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/ExplosionGenerator.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/ExplosionGenerator.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/ExplosionGenerator.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/ExplosionGenerator.h 2014-10-07 20:09:51.000000000 +0000 @@ -21,13 +21,13 @@ class CExpGenSpawnable: public CWorldObject { - CR_DECLARE(CExpGenSpawnable); + CR_DECLARE(CExpGenSpawnable) public: CExpGenSpawnable(); CExpGenSpawnable(const float3& pos, const float3& spd); virtual ~CExpGenSpawnable() {} - virtual void Init(CUnit* owner, const float3& offset) = 0; + virtual void Init(const CUnit* owner, const float3& offset) = 0; }; @@ -105,7 +105,7 @@ // Base explosion generator class class IExplosionGenerator { - CR_DECLARE(IExplosionGenerator); + CR_DECLARE(IExplosionGenerator) IExplosionGenerator(): generatorID(CExplosionGeneratorHandler::EXPGEN_ID_INVALID) {} virtual ~IExplosionGenerator() {} @@ -134,7 +134,7 @@ // has no internal state so we never need to allocate instances class CStdExplosionGenerator: public IExplosionGenerator { - CR_DECLARE(CStdExplosionGenerator); + CR_DECLARE(CStdExplosionGenerator) public: CStdExplosionGenerator(): IExplosionGenerator() {} @@ -156,14 +156,14 @@ // result of an explosion as a series of new projectiles class CCustomExplosionGenerator: public IExplosionGenerator { - CR_DECLARE(CCustomExplosionGenerator); - CR_DECLARE_SUB(ProjectileSpawnInfo); - CR_DECLARE_SUB(GroundFlashInfo); - CR_DECLARE_SUB(ExpGenParams); + CR_DECLARE(CCustomExplosionGenerator) + CR_DECLARE_SUB(ProjectileSpawnInfo) + CR_DECLARE_SUB(GroundFlashInfo) + CR_DECLARE_SUB(ExpGenParams) protected: struct ProjectileSpawnInfo { - CR_DECLARE_STRUCT(ProjectileSpawnInfo); + CR_DECLARE_STRUCT(ProjectileSpawnInfo) ProjectileSpawnInfo() : projectileClass(NULL) @@ -189,7 +189,7 @@ // TODO: Handle ground flashes with more flexibility like the projectiles struct GroundFlashInfo { - CR_DECLARE_STRUCT(GroundFlashInfo); + CR_DECLARE_STRUCT(GroundFlashInfo) GroundFlashInfo() : flashSize(0.0f) @@ -211,7 +211,7 @@ }; struct ExpGenParams { - CR_DECLARE_STRUCT(ExpGenParams); + CR_DECLARE_STRUCT(ExpGenParams) std::vector projectiles; @@ -225,7 +225,7 @@ static bool OutputProjectileClassInfo(); static unsigned int GetFlagsFromTable(const LuaTable& table); - static unsigned int GetFlagsFromHeight(float height, float altitude); + static unsigned int GetFlagsFromHeight(float height, float groundHeight); /// @throws content_error/runtime_error on errors bool Load(CExplosionGeneratorHandler* handler, const std::string& tag); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/FireProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/FireProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/FireProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/FireProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -16,10 +16,9 @@ #include "Sim/Projectiles/ProjectileHandler.h" #include "Sim/Units/Unit.h" #include "System/creg/STL_List.h" -#include "lib/gml/gmlcnf.h" -CR_BIND_DERIVED(CFireProjectile, CProjectile, (ZeroVector,ZeroVector,NULL,0,0,0,0)); -CR_BIND(CFireProjectile::SubParticle, ); +CR_BIND_DERIVED(CFireProjectile, CProjectile, (ZeroVector,ZeroVector,NULL,0,0,0,0)) +CR_BIND(CFireProjectile::SubParticle, ) CR_REG_METADATA(CFireProjectile,( CR_SETFLAG(CF_Synced), @@ -32,7 +31,7 @@ CR_MEMBER(subParticles2), CR_MEMBER(subParticles), CR_RESERVED(16) - )); + )) CR_REG_METADATA_SUB(CFireProjectile, SubParticle, ( CR_MEMBER(pos), @@ -42,20 +41,7 @@ CR_MEMBER(rotSpeed), CR_MEMBER(smokeType), CR_RESERVED(8) - )); - -#if defined(USE_GML) && GML_ENABLE_SIM - typedef CFireProjectile::part_list_type part_list_type; // the creg define dislikes "::" in the name - - CR_BIND_TEMPLATE(part_list_type, ); - CR_REG_METADATA(part_list_type, ( - CR_MEMBER(elements), - CR_MEMBER(front), - CR_MEMBER(back), - CR_MEMBER(csize), - CR_MEMBER(msize) - )); -#endif + )) CFireProjectile::CFireProjectile( const float3& pos, @@ -165,12 +151,7 @@ size_t sz2 = subParticles2.size(); size_t sz = subParticles.size(); va->EnlargeArrays(sz2 * 4 + sz * 8, 0, VA_SIZE_TC); -#if defined(USE_GML) && GML_ENABLE_SIM - size_t temp = 0; - for(part_list_type::iterator pi = subParticles2.begin(); temp < sz2; ++pi, ++temp) { -#else for(part_list_type::iterator pi = subParticles2.begin(); pi != subParticles2.end(); ++pi) { -#endif float age = pi->age+ageSpeed*globalRendering->timeOffset; float size = pi->maxSize*(age); float rot = pi->rotSpeed*age; @@ -191,18 +172,8 @@ va->AddVertexQTC(interPos + dir1 + dir2, projectileDrawer->explotex->xend, projectileDrawer->explotex->yend, col); va->AddVertexQTC(interPos - dir1 + dir2, projectileDrawer->explotex->xstart, projectileDrawer->explotex->yend, col); } -#if defined(USE_GML) && GML_ENABLE_SIM - temp = 0; - for (part_list_type::iterator pi = subParticles.begin(); temp < sz; ++pi, ++temp) { - int smokeType = *(volatile int *)&pi->smokeType; - if (smokeType < 0 || smokeType >= projectileDrawer->smoketex.size()) { - continue; - } - const AtlasedTexture *at = projectileDrawer->smoketex[smokeType]; -#else for (part_list_type::iterator pi = subParticles.begin(); pi != subParticles.end(); ++pi) { const AtlasedTexture* at = projectileDrawer->smoketex[pi->smokeType]; -#endif float age = pi->age+ageSpeed * globalRendering->timeOffset; float size = pi->maxSize * fastmath::apxsqrt(age); float rot = pi->rotSpeed * age; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/FireProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/FireProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/FireProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/FireProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -5,13 +5,12 @@ #include "Projectile.h" #include -#include "lib/gml/gmlcnf.h" class CFireProjectile : public CProjectile { - CR_DECLARE(CFireProjectile); - CR_DECLARE_SUB(SubParticle); + CR_DECLARE(CFireProjectile) + CR_DECLARE_SUB(SubParticle) public: CFireProjectile( const float3& pos, @@ -36,7 +35,7 @@ float ageSpeed; struct SubParticle { - CR_DECLARE_STRUCT(SubParticle); + CR_DECLARE_STRUCT(SubParticle) float3 pos; float3 posDif; @@ -46,11 +45,7 @@ int smokeType; }; -#if defined(USE_GML) && GML_ENABLE_SIM - typedef gmlCircularQueue part_list_type; -#else typedef std::list part_list_type; -#endif part_list_type subParticles; part_list_type subParticles2; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/FlareProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/FlareProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/FlareProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/FlareProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -12,7 +12,7 @@ #include "Sim/Units/UnitDef.h" #include "Sim/Units/Unit.h" -CR_BIND_DERIVED(CFlareProjectile, CProjectile, (ZeroVector, ZeroVector, 0, 0)); +CR_BIND_DERIVED(CFlareProjectile, CProjectile, (ZeroVector, ZeroVector, 0, 0)) CR_REG_METADATA(CFlareProjectile,( CR_SETFLAG(CF_Synced), @@ -25,7 +25,7 @@ CR_MEMBER(subSpeed), CR_MEMBER(alphaFalloff), CR_RESERVED(8) - )); + )) CFlareProjectile::CFlareProjectile(const float3& pos, const float3& speed, CUnit* owner, int activateFrame): //! these are synced, but neither weapon nor piece diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/FlareProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/FlareProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/FlareProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/FlareProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -8,7 +8,7 @@ class CFlareProjectile : public CProjectile { - CR_DECLARE(CFlareProjectile); + CR_DECLARE(CFlareProjectile) public: CFlareProjectile(const float3& pos, const float3& speed, CUnit* owner, int activateFrame); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/PieceProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/PieceProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/PieceProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/PieceProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -28,7 +28,7 @@ #define SMOKE_TIME 40 #define NUM_TRAIL_PARTS (sizeof(fireTrailPoints) / sizeof(fireTrailPoints[0])) -CR_BIND_DERIVED(CPieceProjectile, CProjectile, (NULL, NULL, ZeroVector, ZeroVector, 0, 0)); +CR_BIND_DERIVED(CPieceProjectile, CProjectile, (NULL, NULL, ZeroVector, ZeroVector, 0, 0)) CR_REG_METADATA(CPieceProjectile,( CR_SETFLAG(CF_Synced), @@ -49,7 +49,7 @@ CR_MEMBER(drawTrail), CR_RESERVED(36) -)); +)) CPieceProjectile::CPieceProjectile( CUnit* owner, @@ -97,7 +97,7 @@ castShadow = true; - if (pos.y - ground->GetApproximateHeight(pos.x, pos.z) > 10) { + if (pos.y - CGround::GetApproximateHeight(pos.x, pos.z) > 10) { useAirLos = true; } @@ -159,7 +159,7 @@ void CPieceProjectile::Collision() { - const float3& norm = ground->GetNormal(pos.x, pos.z); + const float3& norm = CGround::GetNormal(pos.x, pos.z); const float ns = speed.dot(norm); SetVelocityAndSpeed(speed - (norm * ns * 1.6f)); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/PieceProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/PieceProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/PieceProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/PieceProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -22,7 +22,7 @@ class CPieceProjectile: public CProjectile { - CR_DECLARE(CPieceProjectile); + CR_DECLARE(CPieceProjectile) public: CPieceProjectile( diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Projectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Projectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Projectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Projectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -10,7 +10,7 @@ #include "Sim/Units/UnitHandler.h" #include "System/Matrix44f.h" -CR_BIND_DERIVED(CProjectile, CExpGenSpawnable, ); +CR_BIND_DERIVED(CProjectile, CExpGenSpawnable, ) CR_REG_METADATA(CProjectile, ( @@ -23,16 +23,17 @@ CR_MEMBER(checkCol), CR_MEMBER(ignoreWater), CR_MEMBER(deleteMe), + CR_MEMBER(castShadow), + CR_MEMBER(drawSorted), CR_MEMBER_BEGINFLAG(CM_Config), CR_MEMBER(dir), CR_MEMBER_ENDFLAG(CM_Config), CR_MEMBER(drawPos), - CR_MEMBER(lastProjUpdate), CR_MEMBER(mygravity), - CR_IGNORED(tempdist), + CR_IGNORED(sortDist), CR_MEMBER(ownerID), CR_MEMBER(teamID), @@ -42,7 +43,7 @@ CR_MEMBER(collisionFlags), CR_MEMBER(qfCellData) -)); +)) CR_BIND(CProjectile::QuadFieldCellData, ) @@ -65,7 +66,9 @@ , checkCol(true) , ignoreWater(false) , deleteMe(false) + , castShadow(false) + , drawSorted(true) , mygravity(mapInfo? mapInfo->map.gravity: 0.0f) @@ -76,13 +79,12 @@ , projectileType(-1u) , collisionFlags(0) { - GML::GetTicks(lastProjUpdate); } CProjectile::CProjectile( const float3& pos, const float3& spd, - CUnit* owner, + const CUnit* owner, bool isSynced, bool isWeapon, bool isPiece, @@ -98,7 +100,9 @@ , checkCol(true) , ignoreWater(false) , deleteMe(false) + , castShadow(false) + , drawSorted(true) , dir(ZeroVector) // set via Init() , mygravity(mapInfo? mapInfo->map.gravity: 0.0f) @@ -112,7 +116,6 @@ { SetRadiusAndHeight(1.7f, 0.0f); Init(owner, ZeroVector); - GML::GetTicks(lastProjUpdate); } void CProjectile::Detach() { @@ -128,7 +131,7 @@ assert(!synced || detached); } -void CProjectile::Init(CUnit* owner, const float3& offset) +void CProjectile::Init(const CUnit* owner, const float3& offset) { if (owner != NULL) { // must be set before the AddProjectile call @@ -208,10 +211,6 @@ // owner (unlikely however unless ID's get recycled very rapidly) CUnit* unit = unitHandler->GetUnit(ownerID); - // make volatile - if (GML::SimEnabled()) - return (*(CUnit* volatile*) &unit); - return unit; } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/ProjectileFunctors.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/ProjectileFunctors.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/ProjectileFunctors.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/ProjectileFunctors.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -14,8 +14,8 @@ bool ProjectileDistanceComparator::operator() (const CProjectile* arg1, const CProjectile* arg2) const { - if (arg1->tempdist != arg2->tempdist) // strict ordering required - return (arg1->tempdist > arg2->tempdist); + if (arg1->GetSortDist() != arg2->GetSortDist()) // strict ordering required + return (arg1->GetSortDist() > arg2->GetSortDist()); return (arg1 > arg2); } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Projectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Projectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Projectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Projectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -3,7 +3,7 @@ #ifndef PROJECTILE_H #define PROJECTILE_H -#include "lib/gml/gml_base.h" +#include #ifdef _MSC_VER #pragma warning(disable:4291) @@ -21,7 +21,7 @@ class CProjectile: public CExpGenSpawnable { - CR_DECLARE(CProjectile); + CR_DECLARE(CProjectile) /// used only by creg CProjectile(); @@ -30,7 +30,7 @@ CProjectile( const float3& pos, const float3& spd, - CUnit* owner, + const CUnit* owner, bool isSynced, bool isWeapon, bool isPiece, @@ -43,7 +43,7 @@ virtual void Collision(CUnit* unit); virtual void Collision(CFeature* feature); virtual void Update(); - virtual void Init(CUnit* owner, const float3& offset); + virtual void Init(const CUnit* owner, const float3& offset); virtual void Draw() {} virtual void DrawOnMinimap(CVertexArray& lines, CVertexArray& points); @@ -108,6 +108,9 @@ // UNSYNCED ONLY CMatrix44f GetTransformMatrix(bool offsetPos) const; + float GetSortDist() const { return sortDist; } + void SetSortDist(float d) { sortDist = d; } + public: static bool inArray; static CVertexArray* va; @@ -122,15 +125,16 @@ bool checkCol; bool ignoreWater; bool deleteMe; + bool castShadow; + bool drawSorted; float3 dir; float3 drawPos; - unsigned lastProjUpdate; float mygravity; - float tempdist; ///< temp distance used for sorting when rendering + float sortDist; ///< distance used for z-sorting when rendering protected: unsigned int ownerID; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/ProjectileHandler.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/ProjectileHandler.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/ProjectileHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/ProjectileHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -25,7 +25,6 @@ #include "System/TimeProfiler.h" #include "System/creg/STL_Map.h" #include "System/creg/STL_List.h" -#include "lib/gml/gmlmut.h" // reserve 5% of maxNanoParticles for important stuff such as capture and reclaim other teams' units #define NORMAL_NANO_PRIO 0.95f @@ -44,14 +43,14 @@ CR_REG_METADATA(ProjectileContainer, ( CR_MEMBER(cont), CR_POSTLOAD(PostLoad) -)); +)) CR_BIND_TEMPLATE(GroundFlashContainer, ) CR_REG_METADATA(GroundFlashContainer, ( CR_MEMBER(cont), CR_POSTLOAD(PostLoad) -)); +)) -CR_BIND(CProjectileHandler, ); +CR_BIND(CProjectileHandler, ) CR_REG_METADATA(CProjectileHandler, ( CR_MEMBER(syncedProjectiles), CR_MEMBER(unsyncedProjectiles), @@ -78,7 +77,7 @@ CR_SERIALIZER(Serialize), CR_POSTLOAD(PostLoad) -)); +)) @@ -222,7 +221,6 @@ quadField->MovedProjectile(p); PROJECTILE_SANITY_CHECK(p); - GML::GetTicks(p->lastProjUpdate); ++pci; } @@ -237,14 +235,12 @@ { SCOPED_TIMER("ProjectileHandler::Update"); - GML::UpdateTicks(); UpdateProjectileContainer(syncedProjectiles, true); UpdateProjectileContainer(unsyncedProjectiles, false); { - GML_STDMUTEX_LOCK(rproj); // Update syncedRenderProjectileIDs.delay_delete(); syncedRenderProjectileIDs.delay_add(); @@ -276,7 +272,6 @@ } { - GML_STDMUTEX_LOCK(rflash); // Update groundFlashes.delay_delete(); groundFlashes.delay_add(); @@ -299,7 +294,6 @@ #undef UPDATE_FLYING_PIECES { - GML_STDMUTEX_LOCK(rpiece); // Update flyingPieces3DO.delay_delete(); flyingPieces3DO.delay_add(); @@ -498,7 +492,7 @@ // NOTE: don't add p->radius to groundHeight, or most // projectiles will collide with the ground too early - const float groundHeight = ground->GetHeightReal(p->pos.x, p->pos.z); + const float groundHeight = CGround::GetHeightReal(p->pos.x, p->pos.z); const bool belowGround = (p->pos.y < groundHeight); const bool insideWater = (p->pos.y <= 0.0f && !belowGround); const bool ignoreWater = p->ignoreWater; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/ProjectileHandler.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/ProjectileHandler.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/ProjectileHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/ProjectileHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -8,7 +8,6 @@ #include #include -#include "lib/gml/gmlcnf.h" #include "lib/gml/ThreadSafeContainers.h" #include "Sim/Projectiles/ProjectileFunctors.h" @@ -37,18 +36,14 @@ typedef ThreadListSim, std::set, CProjectile*, ProjectileDetacher> ProjectileContainer; typedef ThreadListSimRender, std::set, CGroundFlash*> GroundFlashContainer; -#if defined(USE_GML) && GML_ENABLE_SIM -typedef ThreadListSimRender, std::set, FlyingPiece*> FlyingPieceContainer; -#else typedef ThreadListSimRender, void, FlyingPiece*> FlyingPieceContainer; -#endif typedef ThreadMapRender ProjectileRenderMap; class CProjectileHandler { - CR_DECLARE_STRUCT(CProjectileHandler); + CR_DECLARE_STRUCT(CProjectileHandler) public: CProjectileHandler(); @@ -57,8 +52,7 @@ void PostLoad(); inline const ProjectileMapValPair* GetMapPairBySyncedID(int id) const { - const bool renderAccess = (GML::SimEnabled() && !Threading::IsSimThread()); - const ProjectileMap& projectileIDs = renderAccess ? syncedRenderProjectileIDs.get_render_map() : syncedProjectileIDs; + const ProjectileMap& projectileIDs = syncedProjectileIDs; const ProjectileMap::const_iterator it = projectileIDs.find(id); if (it == projectileIDs.end()) @@ -71,8 +65,7 @@ if (UNSYNCED_PROJ_NOEVENT) return NULL; // unsynced projectiles have no IDs if UNSYNCED_PROJ_NOEVENT - const bool renderAccess = (GML::SimEnabled() && !Threading::IsSimThread()); - const ProjectileMap& projectileIDs = renderAccess ? unsyncedRenderProjectileIDs.get_render_map() : unsyncedProjectileIDs; + const ProjectileMap& projectileIDs = unsyncedProjectileIDs; const ProjectileMap::const_iterator it = projectileIDs.find(id); if (it == projectileIDs.end()) diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/ProjectileParams.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/ProjectileParams.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/ProjectileParams.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/ProjectileParams.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,65 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef PROJECTILE_PARAMS_H +#define PROJECTILE_PARAMS_H + +#include "System/float3.h" + +class CWorldObject; +class CUnit; +struct S3DModel; +struct WeaponDef; + +// parameters used to spawn weapon-projectiles +struct ProjectileParams { + ProjectileParams() + : target(NULL) + , owner(NULL) + , model(NULL) + , weaponDef(NULL) + + , ownerID(-1u) + , teamID(-1u) + , weaponID(-1u) + , cegID(-1u) + + , ttl(0) + , gravity(0.0f) + , tracking(0.0f) + , maxRange(0.0f) + + , startAlpha(0.0f) + , endAlpha(1.0f) + { + } + + float3 pos; + float3 end; + float3 speed; + float3 spread; + float3 error; + + // unit, feature or weapon projectile to intercept + CWorldObject* target; + CUnit* owner; + S3DModel* model; + + const WeaponDef* weaponDef; + + unsigned int ownerID; + unsigned int teamID; + unsigned int weaponID; + unsigned int cegID; + + int ttl; + float gravity; + float tracking; + float maxRange; + + // BeamLaser-specific junk + float startAlpha; + float endAlpha; +}; + +#endif + diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/BitmapMuzzleFlame.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/BitmapMuzzleFlame.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/BitmapMuzzleFlame.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/BitmapMuzzleFlame.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -9,7 +9,7 @@ #include "Rendering/Textures/TextureAtlas.h" #include "Sim/Projectiles/ProjectileHandler.h" -CR_BIND_DERIVED(CBitmapMuzzleFlame, CProjectile, ); +CR_BIND_DERIVED(CBitmapMuzzleFlame, CProjectile, ) CR_REG_METADATA(CBitmapMuzzleFlame, ( @@ -26,7 +26,7 @@ CR_MEMBER(ttl), CR_MEMBER(frontOffset), CR_MEMBER_ENDFLAG(CM_Config) -)); +)) CBitmapMuzzleFlame::CBitmapMuzzleFlame() : CProjectile() @@ -88,7 +88,7 @@ deleteMe |= ((ttl--) == 0); } -void CBitmapMuzzleFlame::Init(CUnit* owner, const float3& offset) +void CBitmapMuzzleFlame::Init(const CUnit* owner, const float3& offset) { CProjectile::Init(owner, offset); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/BitmapMuzzleFlame.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/BitmapMuzzleFlame.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/BitmapMuzzleFlame.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/BitmapMuzzleFlame.h 2014-10-07 20:09:51.000000000 +0000 @@ -10,7 +10,7 @@ class CBitmapMuzzleFlame : public CProjectile { - CR_DECLARE(CBitmapMuzzleFlame); + CR_DECLARE(CBitmapMuzzleFlame) public: CBitmapMuzzleFlame(); @@ -18,7 +18,7 @@ void Draw(); void Update(); - void Init(CUnit* owner, const float3& offset); + void Init(const CUnit* owner, const float3& offset); private: AtlasedTexture* sideTexture; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/BubbleProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/BubbleProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/BubbleProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/BubbleProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -9,7 +9,7 @@ #include "Rendering/Textures/TextureAtlas.h" #include "Sim/Projectiles/ProjectileHandler.h" -CR_BIND_DERIVED(CBubbleProjectile, CProjectile, (NULL, ZeroVector, ZeroVector, 0.0f, 0.0f, 0.0f, 0.0f)); +CR_BIND_DERIVED(CBubbleProjectile, CProjectile, (NULL, ZeroVector, ZeroVector, 0.0f, 0.0f, 0.0f, 0.0f)) CR_REG_METADATA(CBubbleProjectile, ( CR_MEMBER(ttl), @@ -18,7 +18,7 @@ CR_MEMBER(startSize), CR_MEMBER(sizeExpansion), CR_RESERVED(8) -)); +)) CBubbleProjectile::CBubbleProjectile( diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/BubbleProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/BubbleProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/BubbleProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/BubbleProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CBubbleProjectile : public CProjectile { - CR_DECLARE(CBubbleProjectile); + CR_DECLARE(CBubbleProjectile) public: CBubbleProjectile( CUnit* owner, diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/DirtProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/DirtProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/DirtProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/DirtProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -10,7 +10,7 @@ #include "Rendering/GL/VertexArray.h" #include "Rendering/Textures/TextureAtlas.h" -CR_BIND_DERIVED(CDirtProjectile, CProjectile, ); +CR_BIND_DERIVED(CDirtProjectile, CProjectile, ) CR_REG_METADATA(CDirtProjectile, ( @@ -24,7 +24,7 @@ CR_MEMBER(texture), CR_MEMBER_ENDFLAG(CM_Config), CR_RESERVED(8) -)); +)) ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -76,7 +76,7 @@ alpha = std::max(alpha - alphaFalloff, 0.0f); size += sizeExpansion; - if (ground->GetApproximateHeight(pos.x, pos.z, false) - 40.0f > pos.y) { + if (CGround::GetApproximateHeight(pos.x, pos.z, false) - 40.0f > pos.y) { deleteMe = true; } if (alpha <= 0.0f) { diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/DirtProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/DirtProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/DirtProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/DirtProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -9,7 +9,7 @@ class CDirtProjectile : public CProjectile { - CR_DECLARE(CDirtProjectile); + CR_DECLARE(CDirtProjectile) public: CDirtProjectile(); CDirtProjectile( diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/ExploSpikeProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/ExploSpikeProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/ExploSpikeProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/ExploSpikeProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -9,7 +9,7 @@ #include "Rendering/GL/VertexArray.h" #include "Rendering/Textures/TextureAtlas.h" -CR_BIND_DERIVED(CExploSpikeProjectile, CProjectile, ); +CR_BIND_DERIVED(CExploSpikeProjectile, CProjectile, ) CR_REG_METADATA(CExploSpikeProjectile, ( @@ -22,7 +22,7 @@ CR_MEMBER(color), CR_MEMBER_ENDFLAG(CM_Config), CR_RESERVED(8) -)); +)) CExploSpikeProjectile::CExploSpikeProjectile() : CProjectile() @@ -96,15 +96,12 @@ #undef let } -void CExploSpikeProjectile::Init(CUnit* owner, const float3& offset) +void CExploSpikeProjectile::Init(const CUnit* owner, const float3& offset) { CProjectile::Init(owner, offset); lengthGrowth = dir.Length() * (0.5f + gu->RandFloat() * 0.4f); dir /= lengthGrowth; - checkCol = false; - useAirLos = true; - SetRadiusAndHeight(length + lengthGrowth * alpha / alphaDecay, 0.0f); } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/ExploSpikeProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/ExploSpikeProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/ExploSpikeProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/ExploSpikeProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CExploSpikeProjectile : public CProjectile { - CR_DECLARE(CExploSpikeProjectile); + CR_DECLARE(CExploSpikeProjectile) /// used only by creg CExploSpikeProjectile(); @@ -26,7 +26,7 @@ void Draw(); void Update(); - void Init(CUnit* owner, const float3& offset); + void Init(const CUnit* owner, const float3& offset); private: float length; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/FlyingPiece.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/FlyingPiece.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/FlyingPiece.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/FlyingPiece.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -27,7 +27,7 @@ transMat.LoadIdentity(); transMat.Rotate(rotAngle, rotAxis); - return (pos.y >= ground->GetApproximateHeight(pos.x, pos.z - 10.0f, false)); + return (pos.y >= CGround::GetApproximateHeight(pos.x, pos.z - 10.0f, false)); } void FlyingPiece::InitCommon(const float3& _pos, const float3& _speed, int _team) @@ -49,6 +49,7 @@ *lastTeam = team; va->DrawArrayTN(GL_QUADS); //switch to GL_TRIANGLES? + va = GetVertexArray(); va->Initialize(); unitDrawer->SetTeamColour(team); } @@ -92,6 +93,7 @@ } va->DrawArrayTN(GL_QUADS); + va = GetVertexArray(); va->Initialize(); texturehandlerS3O->SetS3oTexture(texture); } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/FlyingPiece.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/FlyingPiece.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/FlyingPiece.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/FlyingPiece.h 2014-10-07 20:09:51.000000000 +0000 @@ -3,11 +3,7 @@ #ifndef FLYING_PIECE_H #define FLYING_PIECE_H -#include "lib/gml/gmlcnf.h" - -#if !(defined(USE_GML) && GML_ENABLE_SIM) #include "System/MemPool.h" -#endif #include "System/float3.h" #include "System/Matrix44f.h" @@ -27,10 +23,8 @@ size_t GetTeam() const { return team; } size_t GetTexture() const { return texture; } - #if !(defined(USE_GML) && GML_ENABLE_SIM) inline void* operator new(size_t size) { return mempool.Alloc(size); } inline void operator delete(void* p, size_t size) { mempool.Free(p, size); } - #endif protected: void InitCommon(const float3& _pos, const float3& _speed, int _team); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/GenericParticleProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/GenericParticleProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/GenericParticleProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/GenericParticleProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ #include "Rendering/Textures/ColorMap.h" #include "Sim/Projectiles/ProjectileHandler.h" -CR_BIND_DERIVED(CGenericParticleProjectile, CProjectile, (NULL, ZeroVector, ZeroVector)); +CR_BIND_DERIVED(CGenericParticleProjectile, CProjectile, (NULL, ZeroVector, ZeroVector)) CR_REG_METADATA(CGenericParticleProjectile,( CR_MEMBER(gravity), @@ -21,9 +21,9 @@ CR_MEMBER(sizeGrowth), CR_MEMBER(sizeMod), CR_RESERVED(8) -)); +)) -CGenericParticleProjectile::CGenericParticleProjectile(CUnit* owner, const float3& pos, const float3& speed) +CGenericParticleProjectile::CGenericParticleProjectile(const CUnit* owner, const float3& pos, const float3& speed) : CProjectile(pos, speed, owner, false, false, false) , gravity(ZeroVector) diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/GenericParticleProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/GenericParticleProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/GenericParticleProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/GenericParticleProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -10,11 +10,11 @@ class CGenericParticleProjectile : public CProjectile { - CR_DECLARE(CGenericParticleProjectile); + CR_DECLARE(CGenericParticleProjectile) public: CGenericParticleProjectile( - CUnit* owner, + const CUnit* owner, const float3& pos, const float3& speed ); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/GeoSquareProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/GeoSquareProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/GeoSquareProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/GeoSquareProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ #include "Rendering/GL/VertexArray.h" #include "Rendering/Textures/TextureAtlas.h" -CR_BIND_DERIVED(CGeoSquareProjectile, CProjectile, (ZeroVector, ZeroVector, ZeroVector, ZeroVector, 0, 0)); +CR_BIND_DERIVED(CGeoSquareProjectile, CProjectile, (ZeroVector, ZeroVector, ZeroVector, ZeroVector, 0, 0)) CR_REG_METADATA(CGeoSquareProjectile,( CR_MEMBER(p1), @@ -21,7 +21,7 @@ CR_MEMBER(b), CR_MEMBER(a), CR_RESERVED(8) - )); + )) CGeoSquareProjectile::CGeoSquareProjectile(const float3& p1, const float3& p2, const float3& v1, const float3& v2, float w1, float w2) : CProjectile((p1 + p2) * 0.5f, ZeroVector, NULL, false, false, false), diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/GeoSquareProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/GeoSquareProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/GeoSquareProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/GeoSquareProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CGeoSquareProjectile : public CProjectile { - CR_DECLARE(CGeoSquareProjectile); + CR_DECLARE(CGeoSquareProjectile) public: CGeoSquareProjectile( const float3& p1, const float3& p2, diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/GeoThermSmokeProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/GeoThermSmokeProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/GeoThermSmokeProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/GeoThermSmokeProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -6,12 +6,12 @@ #include "Sim/Projectiles/ProjectileHandler.h" #include "Sim/Misc/Wind.h" -CR_BIND_DERIVED(CGeoThermSmokeProjectile, CSmokeProjectile, (ZeroVector, ZeroVector, 1, NULL)); +CR_BIND_DERIVED(CGeoThermSmokeProjectile, CSmokeProjectile, (ZeroVector, ZeroVector, 1, NULL)) CR_REG_METADATA(CGeoThermSmokeProjectile, ( CR_MEMBER(geo), CR_RESERVED(8) -)); +)) CGeoThermSmokeProjectile::CGeoThermSmokeProjectile( const float3& pos, diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/GfxProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/GfxProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/GfxProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/GfxProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -10,7 +10,7 @@ #include "Sim/Misc/GlobalSynced.h" #include "Sim/Projectiles/ProjectileHandler.h" -CR_BIND_DERIVED(CGfxProjectile, CProjectile, ); +CR_BIND_DERIVED(CGfxProjectile, CProjectile, ) CR_REG_METADATA(CGfxProjectile, ( @@ -20,7 +20,7 @@ CR_MEMBER(color), CR_MEMBER_ENDFLAG(CM_Config), CR_RESERVED(8) -)); +)) ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -30,7 +30,9 @@ { creationTime = lifeTime = 0; color[0] = color[1] = color[2] = color[3] = 255; + checkCol = false; + drawSorted = false; } CGfxProjectile::CGfxProjectile(const float3& pos, const float3& speed, int lifeTime, const float3& color): @@ -39,6 +41,8 @@ lifeTime(lifeTime) { checkCol = false; + drawSorted = false; + this->color[0] = (unsigned char) (color[0] * 255); this->color[1] = (unsigned char) (color[1] * 255); this->color[2] = (unsigned char) (color[2] * 255); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/GfxProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/GfxProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/GfxProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/GfxProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CGfxProjectile : public CProjectile { - CR_DECLARE(CGfxProjectile); + CR_DECLARE(CGfxProjectile) public: CGfxProjectile(); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/HeatCloudProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/HeatCloudProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/HeatCloudProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/HeatCloudProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -8,7 +8,7 @@ #include "Rendering/GL/VertexArray.h" #include "Rendering/Textures/TextureAtlas.h" -CR_BIND_DERIVED(CHeatCloudProjectile, CProjectile, ); +CR_BIND_DERIVED(CHeatCloudProjectile, CProjectile, ) CR_REG_METADATA(CHeatCloudProjectile, ( @@ -23,7 +23,7 @@ CR_MEMBER(texture), CR_MEMBER_ENDFLAG(CM_Config), CR_RESERVED(8) -)); +)) ////////////////////////////////////////////////////////////////////// // Construction/Destruction diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/HeatCloudProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/HeatCloudProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/HeatCloudProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/HeatCloudProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -9,7 +9,7 @@ class CHeatCloudProjectile : public CProjectile { - CR_DECLARE(CHeatCloudProjectile); + CR_DECLARE(CHeatCloudProjectile) public: CHeatCloudProjectile(); /// projectile starts at size 0 and ends at size \ diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/MuzzleFlame.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/MuzzleFlame.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/MuzzleFlame.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/MuzzleFlame.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -9,7 +9,7 @@ #include "Rendering/Textures/TextureAtlas.h" -CR_BIND_DERIVED(CMuzzleFlame, CProjectile, (ZeroVector, ZeroVector, ZeroVector, 0)); +CR_BIND_DERIVED(CMuzzleFlame, CProjectile, (ZeroVector, ZeroVector, ZeroVector, 0)) CR_REG_METADATA(CMuzzleFlame,( CR_SERIALIZER(creg_Serialize), // randSmokeDir @@ -19,7 +19,7 @@ CR_MEMBER(numSmoke), CR_MEMBER(randSmokeDir), CR_RESERVED(8) - )); + )) void CMuzzleFlame::creg_Serialize(creg::ISerializer& s) { diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/MuzzleFlame.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/MuzzleFlame.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/MuzzleFlame.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/MuzzleFlame.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CMuzzleFlame : public CProjectile { - CR_DECLARE(CMuzzleFlame); + CR_DECLARE(CMuzzleFlame) void creg_Serialize(creg::ISerializer& s); public: diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/RepulseGfx.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/RepulseGfx.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/RepulseGfx.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/RepulseGfx.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -8,7 +8,7 @@ #include "Rendering/Textures/TextureAtlas.h" #include "Sim/Units/Unit.h" -CR_BIND_DERIVED(CRepulseGfx, CProjectile, (NULL, NULL, 0.0f, ZeroVector)); +CR_BIND_DERIVED(CRepulseGfx, CProjectile, (NULL, NULL, 0.0f, ZeroVector)) CR_REG_METADATA(CRepulseGfx,( CR_MEMBER(repulsed), @@ -17,7 +17,7 @@ CR_MEMBER(color), CR_MEMBER(difs), CR_RESERVED(8) - )); + )) CRepulseGfx::CRepulseGfx(CUnit* owner, CProjectile* repulsed, float maxDist, const float3& color): CProjectile(repulsed? repulsed->pos: ZeroVector, repulsed? repulsed->speed: ZeroVector, owner, false, false, false), diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/RepulseGfx.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/RepulseGfx.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/RepulseGfx.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/RepulseGfx.h 2014-10-07 20:09:51.000000000 +0000 @@ -9,7 +9,7 @@ class CRepulseGfx : public CProjectile { - CR_DECLARE(CRepulseGfx); + CR_DECLARE(CRepulseGfx) public: CRepulseGfx( CUnit* owner, diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/ShieldProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/ShieldProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/ShieldProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/ShieldProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,7 +2,6 @@ #include "ShieldProjectile.h" #include "Game/Camera.h" -#include "Lua/LuaRules.h" #include "Rendering/GlobalRendering.h" #include "Rendering/ProjectileDrawer.h" #include "Rendering/GL/VertexArray.h" @@ -10,18 +9,19 @@ #include "Sim/Units/Unit.h" #include "Sim/Weapons/PlasmaRepulser.h" #include "Sim/Weapons/WeaponDef.h" +#include "System/EventHandler.h" #include "System/myMath.h" -CR_BIND_DERIVED(ShieldProjectile, CProjectile, (NULL)); +CR_BIND_DERIVED(ShieldProjectile, CProjectile, (NULL)) CR_REG_METADATA(ShieldProjectile, ( CR_MEMBER(shield), CR_MEMBER(shieldTexture), CR_MEMBER(lastAllowDrawingUpdate), CR_MEMBER(allowDrawing), CR_MEMBER(shieldSegments) -)); +)) -CR_BIND_DERIVED(ShieldSegmentProjectile, CProjectile, (NULL, NULL, ZeroVector, 0, 0)); +CR_BIND_DERIVED(ShieldSegmentProjectile, CProjectile, (NULL, NULL, ZeroVector, 0, 0)) CR_REG_METADATA(ShieldSegmentProjectile, ( CR_MEMBER(shieldProjectile), CR_MEMBER(segmentPos), @@ -31,7 +31,7 @@ CR_MEMBER(segmentSize), CR_MEMBER(segmentAlpha), CR_MEMBER(usePerlinTex) -)); +)) static std::vector spherevertices; static std::map > spheretexcoords; @@ -96,7 +96,7 @@ } bool ShieldProjectile::AllowDrawing() { - // call luaRules->DrawShield only once per shield & frame + // call eventHandler.DrawShield only once per shield & frame if (lastAllowDrawingUpdate == globalRendering->drawFrame) return allowDrawing; @@ -110,8 +110,8 @@ //FIXME if Lua wants to draw the shield itself, we should draw all GL_QUADS in the `va` vertexArray first. // but doing so for each shield might reduce the performance. - // so might use a branch-prediction? -> save last return value and if it is true draw `va` before calling luaRules->DrawShield() - if (luaRules && luaRules->DrawShield(shield->owner, shield)) + // so might use a branch-predicion? -> save last return value and if it is true draw `va` before calling eventHandler.DrawShield() ??FIXME + if (eventHandler.DrawShield(shield->owner, shield)) return allowDrawing; const CUnit* owner = shield->owner; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/ShieldProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/ShieldProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/ShieldProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/ShieldProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -11,13 +11,12 @@ class CPlasmaRepulser; struct WeaponDef; -class CVertexArray; struct AtlasedTexture; class ShieldSegmentProjectile; class ShieldProjectile: public CProjectile { - CR_DECLARE(ShieldProjectile); + CR_DECLARE(ShieldProjectile) public: ShieldProjectile(CPlasmaRepulser*); ~ShieldProjectile(); @@ -30,7 +29,7 @@ shield = NULL; } - inline CPlasmaRepulser* GetShield() const { return GML::SimEnabled() ? *(CPlasmaRepulser* volatile*)&shield : shield; } + inline CPlasmaRepulser* GetShield() const { return shield; } const AtlasedTexture* GetShieldTexture() const { return shieldTexture; } private: @@ -47,7 +46,7 @@ class ShieldSegmentProjectile: public CProjectile { - CR_DECLARE(ShieldSegmentProjectile); + CR_DECLARE(ShieldSegmentProjectile) public: ShieldSegmentProjectile( ShieldProjectile* shieldProjectile, diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/SimpleParticleSystem.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/SimpleParticleSystem.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/SimpleParticleSystem.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/SimpleParticleSystem.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -12,7 +12,7 @@ #include "System/float3.h" #include "System/Log/ILog.h" -CR_BIND_DERIVED(CSimpleParticleSystem, CProjectile, ); +CR_BIND_DERIVED(CSimpleParticleSystem, CProjectile, ) CR_REG_METADATA(CSimpleParticleSystem, ( @@ -38,9 +38,9 @@ CR_MEMBER_ENDFLAG(CM_Config), CR_MEMBER(particles), CR_RESERVED(16) -)); +)) -CR_BIND(CSimpleParticleSystem::Particle, ); +CR_BIND(CSimpleParticleSystem::Particle, ) CR_REG_METADATA_SUB(CSimpleParticleSystem, Particle, ( @@ -52,7 +52,7 @@ CR_MEMBER(sizeGrowth), CR_MEMBER(sizeMod), CR_RESERVED(8) -)); +)) CSimpleParticleSystem::CSimpleParticleSystem() : CProjectile() @@ -152,7 +152,7 @@ } } -void CSimpleParticleSystem::Init(CUnit* owner, const float3& offset) +void CSimpleParticleSystem::Init(const CUnit* owner, const float3& offset) { CProjectile::Init(owner, offset); @@ -191,20 +191,20 @@ -CR_BIND_DERIVED(CSphereParticleSpawner, CSimpleParticleSystem, ); +CR_BIND_DERIVED(CSphereParticleSpawner, CSimpleParticleSystem, ) CR_REG_METADATA(CSphereParticleSpawner, ( CR_MEMBER_BEGINFLAG(CM_Config), CR_MEMBER_ENDFLAG(CM_Config) -)); +)) CSphereParticleSpawner::CSphereParticleSpawner(): CSimpleParticleSystem() { } -void CSphereParticleSpawner::Init(CUnit* owner, const float3& offset) +void CSphereParticleSpawner::Init(const CUnit* owner, const float3& offset) { const float3 up = emitVector; const float3 right = up.cross(float3(up.y, up.z, -up.x)); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/SimpleParticleSystem.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/SimpleParticleSystem.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/SimpleParticleSystem.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/SimpleParticleSystem.h 2014-10-07 20:09:51.000000000 +0000 @@ -12,8 +12,8 @@ class CSimpleParticleSystem : public CProjectile { - CR_DECLARE(CSimpleParticleSystem); - CR_DECLARE_SUB(Particle); + CR_DECLARE(CSimpleParticleSystem) + CR_DECLARE_SUB(Particle) public: CSimpleParticleSystem(); @@ -21,7 +21,7 @@ virtual void Draw(); virtual void Update(); - virtual void Init(CUnit* owner, const float3& offset); + virtual void Init(const CUnit* owner, const float3& offset); protected: float3 emitVector; @@ -49,7 +49,7 @@ struct Particle { - CR_DECLARE_STRUCT(Particle); + CR_DECLARE_STRUCT(Particle) float3 pos; float3 speed; @@ -71,14 +71,14 @@ */ class CSphereParticleSpawner : public CSimpleParticleSystem { - CR_DECLARE(CSphereParticleSpawner); + CR_DECLARE(CSphereParticleSpawner) public: CSphereParticleSpawner(); void Draw() {} void Update() {} - virtual void Init(CUnit* owner, const float3& offset); + void Init(const CUnit* owner, const float3& offset); }; #endif // SIMPLE_PARTICLE_SYSTEM_H diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/SmokeProjectile2.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/SmokeProjectile2.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/SmokeProjectile2.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/SmokeProjectile2.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -12,7 +12,7 @@ #include "Rendering/Textures/TextureAtlas.h" #include "Sim/Misc/Wind.h" -CR_BIND_DERIVED(CSmokeProjectile2, CProjectile, ); +CR_BIND_DERIVED(CSmokeProjectile2, CProjectile, ) CR_REG_METADATA(CSmokeProjectile2, ( @@ -28,7 +28,7 @@ CR_MEMBER(age), CR_MEMBER(textureNum), CR_RESERVED(8) -)); +)) ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -69,7 +69,7 @@ ageSpeed = 1 / ttl; checkCol = false; castShadow = true; - if ((pos.y - ground->GetApproximateHeight(pos.x, pos.z, false)) > 10) { + if ((pos.y - CGround::GetApproximateHeight(pos.x, pos.z, false)) > 10) { useAirLos = true; } glowFalloff = 4.5f + gu->RandFloat() * 6; @@ -78,11 +78,11 @@ -void CSmokeProjectile2::Init(CUnit* owner, const float3& offset) +void CSmokeProjectile2::Init(const CUnit* owner, const float3& offset) { textureNum = (int) (gu->RandInt() % projectileDrawer->smoketex.size()); - if (offset.y - ground->GetApproximateHeight(offset.x, offset.z, false) > 10) { + if (offset.y - CGround::GetApproximateHeight(offset.x, offset.z, false) > 10) { useAirLos = true; } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/SmokeProjectile2.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/SmokeProjectile2.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/SmokeProjectile2.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/SmokeProjectile2.h 2014-10-07 20:09:51.000000000 +0000 @@ -10,7 +10,7 @@ class CSmokeProjectile2 : public CProjectile { - CR_DECLARE(CSmokeProjectile2); + CR_DECLARE(CSmokeProjectile2) public: CSmokeProjectile2(); @@ -27,7 +27,7 @@ void Update(); void Draw(); - void Init(CUnit* owner, const float3& offset); + void Init(const CUnit* owner, const float3& offset); private: float color; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/SmokeProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/SmokeProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/SmokeProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/SmokeProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -12,7 +12,7 @@ #include "Rendering/Textures/TextureAtlas.h" #include "Sim/Misc/Wind.h" -CR_BIND_DERIVED(CSmokeProjectile, CProjectile, ); +CR_BIND_DERIVED(CSmokeProjectile, CProjectile, ) CR_REG_METADATA(CSmokeProjectile, ( @@ -25,7 +25,7 @@ CR_MEMBER_ENDFLAG(CM_Config), CR_MEMBER(age), CR_MEMBER(textureNum) -)); +)) ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -67,7 +67,7 @@ castShadow = true; textureNum = (int) (gu->RandInt() % projectileDrawer->smoketex.size()); - if ((pos.y - ground->GetApproximateHeight(pos.x, pos.z, false)) > 10) { + if ((pos.y - CGround::GetApproximateHeight(pos.x, pos.z, false)) > 10) { useAirLos = true; } @@ -78,11 +78,11 @@ -void CSmokeProjectile::Init(CUnit* owner, const float3& offset) +void CSmokeProjectile::Init(const CUnit* owner, const float3& offset) { textureNum = (int) (gu->RandInt() % projectileDrawer->smoketex.size()); - if (offset.y - ground->GetApproximateHeight(offset.x, offset.z, false) > 10.0f) { + if (offset.y - CGround::GetApproximateHeight(offset.x, offset.z, false) > 10.0f) { useAirLos = true; } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/SmokeProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/SmokeProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/SmokeProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/SmokeProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -26,7 +26,7 @@ void Update(); void Draw(); - void Init(CUnit* owner, const float3& offset); + void Init(const CUnit* owner, const float3& offset); private: float color; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/SmokeTrailProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/SmokeTrailProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/SmokeTrailProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/SmokeTrailProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -12,7 +12,7 @@ #include "Sim/Misc/Wind.h" #include "System/myMath.h" -CR_BIND_DERIVED(CSmokeTrailProjectile, CProjectile, (NULL, ZeroVector, ZeroVector, ZeroVector, ZeroVector, false, false, 0.0f, 0, 0.0f, false, NULL, NULL)); +CR_BIND_DERIVED(CSmokeTrailProjectile, CProjectile, (NULL, ZeroVector, ZeroVector, ZeroVector, ZeroVector, false, false, 0.0f, 0, 0.0f, false, NULL, NULL)) CR_REG_METADATA(CSmokeTrailProjectile,( CR_MEMBER(pos1), @@ -34,14 +34,14 @@ CR_MEMBER(drawCallbacker), CR_MEMBER(texture), CR_RESERVED(4) -)); +)) ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CSmokeTrailProjectile::CSmokeTrailProjectile( - CUnit* owner, + const CUnit* owner, const float3& pos1, const float3& pos2, const float3& dir1, @@ -70,17 +70,11 @@ firstSegment(firstSegment), lastSegment(lastSegment), drawCallbacker(drawCallback), - texture(texture) + texture(texture == NULL ? projectileDrawer->smoketrailtex : texture) { checkCol = false; castShadow = true; - // if no custom texture is defined, use the default texture - // Note that this will crash anyway (no idea why) so never have a null texture! - if (texture == NULL) { - texture = projectileDrawer->smoketrailtex; - } - if (!drawTrail) { const float dist = pos1.distance(pos2); dirpos1 = pos1 - dir1 * dist * 0.33f; @@ -96,7 +90,7 @@ } SetRadiusAndHeight(pos1.distance(pos2), 0.0f); - if ((pos.y - ground->GetApproximateHeight(pos.x, pos.z)) > 10) { + if ((pos.y - CGround::GetApproximateHeight(pos.x, pos.z)) > 10) { useAirLos = true; } } @@ -199,7 +193,7 @@ } } - CProjectile* callbacker = GML::SimEnabled()? *(CProjectile* volatile*) &drawCallbacker: drawCallbacker; + CProjectile* callbacker = drawCallbacker; if (callbacker != NULL) { callbacker->DrawCallback(); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/SmokeTrailProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/SmokeTrailProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/SmokeTrailProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/SmokeTrailProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -9,10 +9,10 @@ class CSmokeTrailProjectile : public CProjectile { - CR_DECLARE(CSmokeTrailProjectile); + CR_DECLARE(CSmokeTrailProjectile) public: CSmokeTrailProjectile( - CUnit* owner, + const CUnit* owner, const float3& pos1, const float3& pos2, const float3& dir1, diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/SpherePartProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/SpherePartProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/SpherePartProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/SpherePartProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -10,7 +10,7 @@ using std::min; -CR_BIND_DERIVED(CSpherePartProjectile, CProjectile, (NULL, ZeroVector, 0, 0, 0.0f, 0.0f, 0, ZeroVector)); +CR_BIND_DERIVED(CSpherePartProjectile, CProjectile, (NULL, ZeroVector, 0, 0, 0.0f, 0.0f, 0, ZeroVector)) CR_REG_METADATA(CSpherePartProjectile, ( CR_MEMBER(centerPos), @@ -26,10 +26,10 @@ CR_MEMBER(texx), CR_MEMBER(texy), CR_RESERVED(16) -)); +)) CSpherePartProjectile::CSpherePartProjectile( - CUnit* owner, + const CUnit* owner, const float3& centerPos, int xpart, int ypart, @@ -67,9 +67,6 @@ texy = projectileDrawer->sphereparttex->ystart + (projectileDrawer->sphereparttex->yend - projectileDrawer->sphereparttex->ystart) * 0.5f; } -CSpherePartProjectile::~CSpherePartProjectile() -{ -} void CSpherePartProjectile::Update() { @@ -114,7 +111,7 @@ } -void CSpherePartProjectile::CreateSphere(float3 pos, float alpha, int ttl, float expansionSpeed , CUnit* owner, float3 color) +void CSpherePartProjectile::CreateSphere(const CUnit* owner, int ttl, float alpha, float expansionSpeed, float3 pos, float3 color) { for (int y = 0; y < 16; y += 4) { for (int x = 0; x < 32; x += 4) { @@ -132,11 +129,7 @@ { } -CSpherePartSpawner::~CSpherePartSpawner() -{ -} - -CR_BIND_DERIVED(CSpherePartSpawner, CProjectile, ); +CR_BIND_DERIVED(CSpherePartSpawner, CProjectile, ) CR_REG_METADATA(CSpherePartSpawner, ( @@ -146,11 +139,12 @@ CR_MEMBER(expansionSpeed), CR_MEMBER(color), CR_MEMBER_ENDFLAG(CM_Config) -)); +)) -void CSpherePartSpawner::Init(CUnit* owner, const float3& offset) +void CSpherePartSpawner::Init(const CUnit* owner, const float3& offset) { CProjectile::Init(owner, offset); deleteMe = true; - CSpherePartProjectile::CreateSphere(pos, alpha, ttl, expansionSpeed, owner, color); + CSpherePartProjectile::CreateSphere(owner, ttl, alpha, expansionSpeed, pos, color); } + diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/SpherePartProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/SpherePartProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/SpherePartProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/SpherePartProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,11 +7,11 @@ class CSpherePartProjectile : public CProjectile { - CR_DECLARE(CSpherePartProjectile); + CR_DECLARE(CSpherePartProjectile) public: CSpherePartProjectile( - CUnit* owner, + const CUnit* owner, const float3& centerPos, int xpart, int ypart, @@ -20,13 +20,18 @@ int ttl, const float3& color ); - ~CSpherePartProjectile(); void Draw(); void Update(); - static void CreateSphere(float3 pos, float alpha, int ttl, - float expansionSpeed , CUnit* owner, - float3 color = float3(0.8, 0.8, 0.6)); + + static void CreateSphere( + const CUnit* owner, + int ttl, + float alpha, + float expansionSpeed, + float3 pos, + float3 color = float3(0.8, 0.8, 0.6) + ); private: float3 centerPos; @@ -49,13 +54,12 @@ /// This class makes a sphere-part-projectile via the explosion-generator class CSpherePartSpawner : CProjectile { - CR_DECLARE(CSpherePartSpawner); + CR_DECLARE(CSpherePartSpawner) public: CSpherePartSpawner(); - ~CSpherePartSpawner(); - void Init(CUnit* owner, const float3& offset); + void Init(const CUnit* owner, const float3& offset); private: float alpha; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/TracerProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/TracerProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/TracerProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/TracerProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -14,7 +14,7 @@ CR_MEMBER(length), CR_MEMBER_ENDFLAG(CM_Config), CR_RESERVED(8) -)); +)) ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -36,12 +36,12 @@ SetRadiusAndHeight(1.0f, 0.0f); checkCol = false; - // Projectile::Init has been called, so .w is defined + // Projectile::Init has been called by base ctor, so .w is defined // FIXME: constant, assumes |speed| never changes after creation speedf = this->speed.w; } -void CTracerProjectile::Init(CUnit* owner, const float3& offset) +void CTracerProjectile::Init(const CUnit* owner, const float3& offset) { CProjectile::Init(owner, offset); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/TracerProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/TracerProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/TracerProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/TracerProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -8,7 +8,7 @@ class CTracerProjectile : public CProjectile { public: - CR_DECLARE(CTracerProjectile); + CR_DECLARE(CTracerProjectile) CTracerProjectile(); CTracerProjectile( @@ -20,7 +20,7 @@ void Draw(); void Update(); - void Init(CUnit* owner, const float3& offset); + void Init(const CUnit* owner, const float3& offset); private: float speedf; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/WakeProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/WakeProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/WakeProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/WakeProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -10,7 +10,7 @@ #include "Rendering/GL/VertexArray.h" #include "Rendering/Textures/TextureAtlas.h" -CR_BIND_DERIVED(CWakeProjectile, CProjectile, (NULL, ZeroVector, ZeroVector, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f)); +CR_BIND_DERIVED(CWakeProjectile, CProjectile, (NULL, ZeroVector, ZeroVector, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f)) CR_REG_METADATA(CWakeProjectile,( CR_MEMBER(alpha), @@ -22,7 +22,7 @@ CR_MEMBER(rotation), CR_MEMBER(rotSpeed), CR_RESERVED(8) - )); + )) ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -37,15 +37,14 @@ float alpha, float alphaFalloff, float fadeupTime -): - CProjectile(pos, speed, owner, false, false, false), - - alpha(0.0f), - alphaFalloff(alphaFalloff), - alphaAdd(alpha / fadeupTime), - alphaAddTime((int)fadeupTime), - size(startSize), - sizeExpansion(sizeExpansion) +) +: CProjectile(pos, speed, owner, false, false, false) +, alpha(0.0f) +, alphaFalloff(alphaFalloff) +, alphaAdd(alpha / fadeupTime) +, alphaAddTime((int)fadeupTime) +, size(startSize) +, sizeExpansion(sizeExpansion) { this->pos.y = 0.0f; this->speed.y = 0.0f; @@ -53,7 +52,7 @@ rotSpeed = (gu->RandFloat() - 0.5f) * PI*2*0.01f; checkCol = false; if (water->BlockWakeProjectiles()) { - alpha = 0; + this->alpha = 0; alphaAddTime = 0; size = 0; } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/WakeProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/WakeProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/WakeProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/WakeProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CWakeProjectile : public CProjectile { - CR_DECLARE(CWakeProjectile); + CR_DECLARE(CWakeProjectile) public: CWakeProjectile( CUnit* owner, @@ -19,7 +19,6 @@ float alphaFalloff, float fadeupTime ); - ~CWakeProjectile() {} void Update(); void Draw(); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/WreckProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/WreckProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/WreckProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/WreckProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -11,11 +11,11 @@ #include "Rendering/Textures/TextureAtlas.h" #include "Sim/Projectiles/ProjectileHandler.h" -CR_BIND_DERIVED(CWreckProjectile, CProjectile, (NULL, ZeroVector, ZeroVector, 0.0f)); +CR_BIND_DERIVED(CWreckProjectile, CProjectile, (NULL, ZeroVector, ZeroVector, 0.0f)) CR_REG_METADATA(CWreckProjectile, CR_RESERVED(8) -); +) ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -44,7 +44,7 @@ CSmokeProjectile* hp = new CSmokeProjectile(owner(), pos, ZeroVector, 50, 4, 0.3f, 0.5f); hp->size += 0.1f; } - if (pos.y + 0.3f < ground->GetApproximateHeight(pos.x, pos.z)) { + if (pos.y + 0.3f < CGround::GetApproximateHeight(pos.x, pos.z)) { deleteMe = true; } } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/WreckProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/WreckProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/Unsynced/WreckProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/Unsynced/WreckProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CWreckProjectile : public CProjectile { - CR_DECLARE(CWreckProjectile); + CR_DECLARE(CWreckProjectile) public: CWreckProjectile(CUnit* owner, float3 pos, float3 speed, float temperature); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/BeamLaserProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/BeamLaserProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/BeamLaserProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/BeamLaserProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,8 +7,9 @@ #include "Rendering/Textures/TextureAtlas.h" #include "Sim/Projectiles/ProjectileHandler.h" #include "Sim/Weapons/WeaponDef.h" +#include //memset -CR_BIND_DERIVED(CBeamLaserProjectile, CWeaponProjectile, (ProjectileParams())); +CR_BIND_DERIVED(CBeamLaserProjectile, CWeaponProjectile, (ProjectileParams())) CR_REG_METADATA(CBeamLaserProjectile,( CR_SETFLAG(CF_Synced), @@ -22,7 +23,7 @@ CR_MEMBER(decay), CR_MEMBER(midtexx), CR_RESERVED(16) -)); +)) CBeamLaserProjectile::CBeamLaserProjectile(const ProjectileParams& params): CWeaponProjectile(params) diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/BeamLaserProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/BeamLaserProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/BeamLaserProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/BeamLaserProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CBeamLaserProjectile: public CWeaponProjectile { - CR_DECLARE(CBeamLaserProjectile); + CR_DECLARE(CBeamLaserProjectile) public: CBeamLaserProjectile(const ProjectileParams& params); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/EmgProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/EmgProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/EmgProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/EmgProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -10,14 +10,14 @@ #include "Sim/Weapons/WeaponDef.h" #include "System/Sync/SyncTracer.h" -CR_BIND_DERIVED(CEmgProjectile, CWeaponProjectile, (ProjectileParams())); +CR_BIND_DERIVED(CEmgProjectile, CWeaponProjectile, (ProjectileParams())) CR_REG_METADATA(CEmgProjectile,( CR_SETFLAG(CF_Synced), CR_MEMBER(intensity), CR_MEMBER(color), CR_RESERVED(8) -)); +)) CEmgProjectile::CEmgProjectile(const ProjectileParams& params): CWeaponProjectile(params) { diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/EmgProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/EmgProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/EmgProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/EmgProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CEmgProjectile : public CWeaponProjectile { - CR_DECLARE(CEmgProjectile); + CR_DECLARE(CEmgProjectile) public: CEmgProjectile(const ProjectileParams& params); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/ExplosiveProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/ExplosiveProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/ExplosiveProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/ExplosiveProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -14,14 +14,14 @@ #include "System/Sync/SyncTracer.h" #endif -CR_BIND_DERIVED(CExplosiveProjectile, CWeaponProjectile, (ProjectileParams())); +CR_BIND_DERIVED(CExplosiveProjectile, CWeaponProjectile, (ProjectileParams())) CR_REG_METADATA(CExplosiveProjectile, ( CR_SETFLAG(CF_Synced), CR_MEMBER(areaOfEffect), CR_MEMBER(invttl), CR_MEMBER(curTime) -)); +)) ////////////////////////////////////////////////////////////////////// // Construction/Destruction diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/ExplosiveProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/ExplosiveProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/ExplosiveProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/ExplosiveProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CExplosiveProjectile : public CWeaponProjectile { - CR_DECLARE(CExplosiveProjectile); + CR_DECLARE(CExplosiveProjectile) public: CExplosiveProjectile(const ProjectileParams& params); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/FireBallProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/FireBallProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/FireBallProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/FireBallProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -11,14 +11,14 @@ #include "Sim/Weapons/WeaponDef.h" #include "System/creg/STL_Deque.h" -CR_BIND_DERIVED(CFireBallProjectile, CWeaponProjectile, (ProjectileParams())); -CR_BIND(CFireBallProjectile::Spark, ); +CR_BIND_DERIVED(CFireBallProjectile, CWeaponProjectile, (ProjectileParams())) +CR_BIND(CFireBallProjectile::Spark, ) CR_REG_METADATA(CFireBallProjectile,( CR_SETFLAG(CF_Synced), CR_MEMBER(sparks), CR_RESERVED(8) -)); +)) CR_REG_METADATA_SUB(CFireBallProjectile,Spark,( CR_MEMBER(pos), @@ -26,21 +26,7 @@ CR_MEMBER(size), CR_MEMBER(ttl), CR_RESERVED(8) -)); - -#if defined(USE_GML) && GML_ENABLE_SIM - typedef CFireBallProjectile::spark_list_type spark_list_type; // the creg define dislikes "::" in the name - - CR_BIND_TEMPLATE(spark_list_type, ); - CR_REG_METADATA(spark_list_type, ( - CR_MEMBER(elements), - CR_MEMBER(front), - CR_MEMBER(back), - CR_MEMBER(csize), - CR_MEMBER(msize) - )); -#endif - +)) CFireBallProjectile::CFireBallProjectile(const ProjectileParams& params): CWeaponProjectile(params) { diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/FireBallProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/FireBallProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/FireBallProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/FireBallProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -5,12 +5,11 @@ #include "WeaponProjectile.h" #include -#include "lib/gml/gmlcnf.h" class CFireBallProjectile : public CWeaponProjectile { - CR_DECLARE(CFireBallProjectile); - CR_DECLARE_SUB(Spark); + CR_DECLARE(CFireBallProjectile) + CR_DECLARE_SUB(Spark) public: CFireBallProjectile(const ProjectileParams& params); @@ -20,18 +19,14 @@ void Collision(); struct Spark { - CR_DECLARE_STRUCT(Spark); + CR_DECLARE_STRUCT(Spark) float3 pos; float3 speed; float size; int ttl; }; -#if defined(USE_GML) && GML_ENABLE_SIM - typedef gmlCircularQueue spark_list_type; -#else typedef std::deque spark_list_type; -#endif private: spark_list_type sparks; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/FlameProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/FlameProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/FlameProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/FlameProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -10,7 +10,7 @@ #include "Sim/Projectiles/ProjectileHandler.h" #include "Sim/Weapons/WeaponDef.h" -CR_BIND_DERIVED(CFlameProjectile, CWeaponProjectile, (ProjectileParams())); +CR_BIND_DERIVED(CFlameProjectile, CWeaponProjectile, (ProjectileParams())) CR_REG_METADATA(CFlameProjectile,( CR_SETFLAG(CF_Synced), @@ -19,7 +19,7 @@ CR_MEMBER(physLife), CR_MEMBER(invttl), CR_RESERVED(16) -)); +)) CFlameProjectile::CFlameProjectile(const ProjectileParams& params):CWeaponProjectile(params) @@ -41,7 +41,7 @@ void CFlameProjectile::Collision() { - const float3 norm = ground->GetNormal(pos.x, pos.z); + const float3& norm = CGround::GetNormal(pos.x, pos.z); const float ns = speed.dot(norm); SetVelocityAndSpeed(speed - (norm * ns)); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/FlameProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/FlameProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/FlameProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/FlameProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CFlameProjectile : public CWeaponProjectile { - CR_DECLARE(CFlameProjectile); + CR_DECLARE(CFlameProjectile) public: CFlameProjectile(const ProjectileParams& params); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/LargeBeamLaserProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/LargeBeamLaserProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/LargeBeamLaserProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/LargeBeamLaserProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -8,8 +8,9 @@ #include "Sim/Projectiles/ProjectileHandler.h" #include "Sim/Weapons/WeaponDef.h" #include "System/myMath.h" +#include //memset -CR_BIND_DERIVED(CLargeBeamLaserProjectile, CWeaponProjectile, (ProjectileParams())); +CR_BIND_DERIVED(CLargeBeamLaserProjectile, CWeaponProjectile, (ProjectileParams())) CR_REG_METADATA(CLargeBeamLaserProjectile,( CR_SETFLAG(CF_Synced), @@ -24,7 +25,7 @@ CR_MEMBER(beamtex), CR_MEMBER(sidetex), CR_RESERVED(16) -)); +)) CLargeBeamLaserProjectile::CLargeBeamLaserProjectile(const ProjectileParams& params): CWeaponProjectile(params) , thickness(0.0f) diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/LargeBeamLaserProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/LargeBeamLaserProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/LargeBeamLaserProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/LargeBeamLaserProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -8,7 +8,7 @@ class CLargeBeamLaserProjectile : public CWeaponProjectile { - CR_DECLARE(CLargeBeamLaserProjectile); + CR_DECLARE(CLargeBeamLaserProjectile) public: CLargeBeamLaserProjectile(const ProjectileParams& params); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/LaserProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/LaserProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/LaserProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/LaserProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -13,7 +13,7 @@ #include "System/Sync/SyncTracer.h" #endif -CR_BIND_DERIVED(CLaserProjectile, CWeaponProjectile, (ProjectileParams())); +CR_BIND_DERIVED(CLaserProjectile, CWeaponProjectile, (ProjectileParams())) CR_REG_METADATA(CLaserProjectile,( CR_SETFLAG(CF_Synced), @@ -26,7 +26,7 @@ CR_MEMBER(stayTime), CR_MEMBER(intensityFalloff), CR_MEMBER(midtexx) -)); +)) CLaserProjectile::CLaserProjectile(const ProjectileParams& params): CWeaponProjectile(params) , speedf(0.0f) diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/LaserProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/LaserProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/LaserProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/LaserProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -8,7 +8,7 @@ class CLaserProjectile : public CWeaponProjectile { - CR_DECLARE(CLaserProjectile); + CR_DECLARE(CLaserProjectile) public: CLaserProjectile(const ProjectileParams& params); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/LightningProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/LightningProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/LightningProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/LightningProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -13,14 +13,14 @@ #include "System/Sync/SyncTracer.h" #endif -CR_BIND_DERIVED(CLightningProjectile, CWeaponProjectile, (ProjectileParams())); +CR_BIND_DERIVED(CLightningProjectile, CWeaponProjectile, (ProjectileParams())) CR_REG_METADATA(CLightningProjectile,( CR_SETFLAG(CF_Synced), CR_MEMBER(color), CR_MEMBER(displacements), CR_MEMBER(displacements2) -)); +)) CLightningProjectile::CLightningProjectile(const ProjectileParams& params): CWeaponProjectile(params) { diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/LightningProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/LightningProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/LightningProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/LightningProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -9,7 +9,7 @@ class CLightningProjectile : public CWeaponProjectile { - CR_DECLARE(CLightningProjectile); + CR_DECLARE(CLightningProjectile) public: CLightningProjectile(const ProjectileParams& params); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/MissileProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/MissileProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/MissileProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/MissileProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -3,7 +3,6 @@ #include "Game/Camera.h" #include "Game/GameHelper.h" -#include "Game/TraceRay.h" #include "Map/Ground.h" #include "MissileProjectile.h" #include "Rendering/GlobalRendering.h" @@ -22,7 +21,7 @@ const float CMissileProjectile::SMOKE_TIME = 60.0f; -CR_BIND_DERIVED(CMissileProjectile, CWeaponProjectile, (ProjectileParams())); +CR_BIND_DERIVED(CMissileProjectile, CWeaponProjectile, (ProjectileParams())) CR_REG_METADATA(CMissileProjectile,( CR_SETFLAG(CF_Synced), @@ -45,7 +44,7 @@ CR_MEMBER(extraHeight), CR_MEMBER(extraHeightDecay), CR_MEMBER(extraHeightTime) -)); +)) CMissileProjectile::CMissileProjectile(const ProjectileParams& params): CWeaponProjectile(params) , maxSpeed(0.0f) @@ -65,10 +64,10 @@ , wobbleTime(1) , oldSmoke(pos) + , oldDir(dir) { projectileType = WEAPON_MISSILE_PROJECTILE; - oldDir = dir; if (model != NULL) { SetRadiusAndHeight(model); @@ -146,6 +145,8 @@ void CMissileProjectile::Update() { + const CUnit* own = owner(); + if (--ttl > 0) { if (!luaMoveCtrl) { float3 targetVel; @@ -163,14 +164,14 @@ targetPos = so->aimPos; targetVel = so->speed; - if (owner() != NULL && pos.SqDistance(so->aimPos) > Square(150.0f)) { + if (own != NULL && pos.SqDistance(so->aimPos) > Square(150.0f)) { // if we have an owner and our target is a unit, // set target-position to its error-position for // our owner's allyteam - const CUnit* u = dynamic_cast(so); + const CUnit* tgt = dynamic_cast(so); - if (u != NULL) { - targetPos = u->GetErrorPos(owner()->allyteam, true); + if (tgt != NULL) { + targetPos = tgt->GetErrorPos(own->allyteam, true); } } } @@ -180,26 +181,8 @@ } - if (isWobbling) { - if ((--wobbleTime) == 0) { - float3 newWob = gs->randVector(); - wobbleDif = (newWob - wobbleDir) * (1.0f / 16); - wobbleTime = 16; - } - - wobbleDir += wobbleDif; - dir = (dir + wobbleDir * weaponDef->wobble * (owner()? (1.0f - owner()->limExperience * 0.5f): 1)).Normalize(); - } - - if (isDancing) { - if ((--danceTime) <= 0) { - danceMove = gs->randVector() * weaponDef->dance - danceCenter; - danceCenter += danceMove; - danceTime = 8; - } - - pos += danceMove; - } + UpdateWobble(); + UpdateDance(); const float3 orgTargPos = targetPos; const float3 targetDir = (targetPos - pos).SafeNormalize(); @@ -267,7 +250,7 @@ if (weaponDef->visuals.smokeTrail && !(age & 7)) { CSmokeTrailProjectile* tp = new CSmokeTrailProjectile( - owner(), + own, pos, oldSmoke, dir, oldDir, age == 8, @@ -298,6 +281,38 @@ UpdateGroundBounce(); } +void CMissileProjectile::UpdateWobble() { + if (!isWobbling) + return; + + if ((--wobbleTime) <= 0) { + wobbleDif = (gs->randVector() - wobbleDir) * (1.0f / 16); + wobbleTime = 16; + } + + float wobbleFact = weaponDef->wobble; + + if (owner() != NULL) + wobbleFact *= CUnit::ExperienceScale(owner()->limExperience, weaponDef->ownerExpAccWeight); + + wobbleDir += wobbleDif; + dir = (dir + wobbleDir * wobbleFact).Normalize(); +} + +void CMissileProjectile::UpdateDance() { + if (!isDancing) + return; + + if ((--danceTime) <= 0) { + danceMove = gs->randVector() * weaponDef->dance - danceCenter; + danceCenter += danceMove; + danceTime = 8; + } + + SetPosition(pos + danceMove); +} + + void CMissileProjectile::UpdateGroundBounce() { if (luaMoveCtrl) return; @@ -396,8 +411,12 @@ va->AddVertexQTC(drawPos - camera->right * fsize+camera->up * fsize, weaponDef->visuals.texture1->xstart, weaponDef->visuals.texture1->yend, col); } -int CMissileProjectile::ShieldRepulse(CPlasmaRepulser* shield, float3 shieldPos, float shieldForce, float shieldMaxSpeed) -{ +int CMissileProjectile::ShieldRepulse( + CPlasmaRepulser* shield, + float3 shieldPos, + float shieldForce, + float shieldMaxSpeed +) { if (luaMoveCtrl) return 0; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/MissileProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/MissileProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/MissileProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/MissileProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -9,7 +9,7 @@ class CMissileProjectile : public CWeaponProjectile { - CR_DECLARE(CMissileProjectile); + CR_DECLARE(CMissileProjectile) protected: void UpdateGroundBounce(); public: @@ -22,10 +22,17 @@ void Update(); void Draw(); - int ShieldRepulse(CPlasmaRepulser* shield, float3 shieldPos, - float shieldForce, float shieldMaxSpeed); + int ShieldRepulse( + CPlasmaRepulser* shield, + float3 shieldPos, + float shieldForce, + float shieldMaxSpeed + ); private: + void UpdateWobble(); + void UpdateDance(); + float maxSpeed; float areaOfEffect; float extraHeight; @@ -49,7 +56,7 @@ float3 oldSmoke; float3 oldDir; - + /// the smokes life-time in frames static const float SMOKE_TIME; }; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/StarburstProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/StarburstProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/StarburstProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/StarburstProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -23,8 +23,7 @@ static const float SMOKE_TIME = 70.0f; static const float TRACER_PARTS_STEP = 2.0f; - -static const size_t MAX_NUM_AGEMODS = 32; +static const unsigned int MAX_NUM_AGEMODS = 32; CR_BIND(CStarburstProjectile::TracerPart, ) CR_REG_METADATA_SUB(CStarburstProjectile, TracerPart, ( @@ -33,10 +32,10 @@ CR_MEMBER(speedf), CR_MEMBER(ageMods), CR_MEMBER(numAgeMods) -)); +)) -CR_BIND_DERIVED(CStarburstProjectile, CWeaponProjectile, (ProjectileParams())); +CR_BIND_DERIVED(CStarburstProjectile, CWeaponProjectile, (ProjectileParams())) CR_REG_METADATA(CStarburstProjectile, ( CR_SETFLAG(CF_Synced), CR_MEMBER(tracking), @@ -57,21 +56,22 @@ CR_MEMBER(aimError), CR_MEMBER(curTracerPart), CR_MEMBER(tracerParts) -)); +)) CStarburstProjectile::CStarburstProjectile(const ProjectileParams& params): CWeaponProjectile(params) - , tracking(0.0f) + , tracking(params.tracking) , maxGoodDif(0.0f) , maxSpeed(0.0f) , acceleration(0.f) , areaOfEffect(0.0f) - , distanceToTravel(0.0f) + , distanceToTravel(params.maxRange) , uptime(0) , age(0) , oldSmoke(pos) + , aimError(params.error) , drawTrail(true) , doturn(true) @@ -83,9 +83,6 @@ { projectileType = WEAPON_STARBURST_PROJECTILE; - tracking = params.tracking; - distanceToTravel = params.maxRange; - aimError = params.error; if (weaponDef != NULL) { maxSpeed = weaponDef->projectilespeed; @@ -108,13 +105,13 @@ drawTrail = (camDist >= 200.0f); drawRadius = maxSpeed * 8.0f; - for (int a = 0; a < NUM_TRACER_PARTS; ++a) { + for (unsigned int a = 0; a < NUM_TRACER_PARTS; ++a) { tracerParts[a].dir = dir; tracerParts[a].pos = pos; tracerParts[a].speedf = speed.w; tracerParts[a].ageMods.resize(MAX_NUM_AGEMODS, 1.0f); - tracerParts[a].numAgeMods = std::min(MAX_NUM_AGEMODS, (size_t)std::floor((speed.w + 0.6f) / TRACER_PARTS_STEP)); + tracerParts[a].numAgeMods = std::min(MAX_NUM_AGEMODS, static_cast((speed.w + 0.6f) / TRACER_PARTS_STEP)); } castShadow = true; @@ -138,7 +135,7 @@ CStarburstProjectile::~CStarburstProjectile() { // UNSYNCED - for (int a = 0; a < NUM_TRACER_PARTS; ++a) { + for (unsigned int a = 0; a < NUM_TRACER_PARTS; ++a) { tracerParts[a].ageMods.clear(); } } @@ -269,7 +266,7 @@ { const unsigned int newTracerPart = (curTracerPart + 1) % NUM_TRACER_PARTS; - curTracerPart = GML::SimEnabled() ? *(volatile size_t*)&newTracerPart : newTracerPart; + curTracerPart = newTracerPart; TracerPart* tracerPart = &tracerParts[curTracerPart]; tracerPart->pos = pos; tracerPart->dir = dir; @@ -283,7 +280,7 @@ } if (tracerPart->numAgeMods != newsize) { - tracerPart->numAgeMods = GML::SimEnabled() ? *(volatile size_t*)&newsize : newsize; + tracerPart->numAgeMods = newsize; } } @@ -332,7 +329,7 @@ inArray = true; if (weaponDef->visuals.smokeTrail) { - const int curNumParts = GML::SimEnabled() ? *(volatile int*) &numParts : numParts; + const int curNumParts = numParts; va->EnlargeArrays(4 + (4 * curNumParts), 0, VA_SIZE_TC); @@ -402,16 +399,17 @@ unsigned char col[4]; - size_t part = GML::SimEnabled() ? *(volatile size_t*)&curTracerPart : curTracerPart; + unsigned int part = curTracerPart; - for (int a = 0; a < NUM_TRACER_PARTS; ++a) { + for (unsigned int a = 0; a < NUM_TRACER_PARTS; ++a) { const TracerPart* tracerPart = &tracerParts[part]; const float3& opos = tracerPart->pos; const float3& odir = tracerPart->dir; const float ospeed = tracerPart->speedf; float aa = 0; - size_t numAgeMods = GML::SimEnabled() ? *(volatile size_t*)&tracerPart->numAgeMods : tracerPart->numAgeMods; + unsigned int numAgeMods = tracerPart->numAgeMods; + for (int num = 0; num < numAgeMods; aa += TRACER_PARTS_STEP, ++num) { const float ageMod = tracerPart->ageMods[num]; const float age2 = (a + (aa / (ospeed + 0.01f))) * 0.2f; @@ -441,7 +439,8 @@ #undef wt3 } - part = (part == 0) ? NUM_TRACER_PARTS - 1 : part - 1; + // unsigned, so LHS will wrap around to UINT_MAX + part = std::min(part - 1, NUM_TRACER_PARTS - 1); } // draw the engine flare diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/StarburstProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/StarburstProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/StarburstProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/StarburstProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -11,8 +11,8 @@ class CStarburstProjectile : public CWeaponProjectile { - CR_DECLARE(CStarburstProjectile); - CR_DECLARE_SUB(TracerPart); + CR_DECLARE(CStarburstProjectile) + CR_DECLARE_SUB(TracerPart) public: CStarburstProjectile(const ProjectileParams& params); @@ -52,20 +52,19 @@ int numParts; int missileAge; - size_t curTracerPart; - - static const int NUM_TRACER_PARTS = 5; + unsigned int curTracerPart; struct TracerPart { - CR_DECLARE_STRUCT(TracerPart); + CR_DECLARE_STRUCT(TracerPart) float3 pos; float3 dir; float speedf; std::vector ageMods; - size_t numAgeMods; + unsigned int numAgeMods; }; + static const unsigned int NUM_TRACER_PARTS = 5; TracerPart tracerParts[NUM_TRACER_PARTS]; }; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/TorpedoProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/TorpedoProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/TorpedoProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/TorpedoProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -19,7 +19,7 @@ #include "System/Sync/SyncTracer.h" #endif -CR_BIND_DERIVED(CTorpedoProjectile, CWeaponProjectile, (ProjectileParams())); +CR_BIND_DERIVED(CTorpedoProjectile, CWeaponProjectile, (ProjectileParams())) CR_REG_METADATA(CTorpedoProjectile,( CR_SETFLAG(CF_Synced), @@ -29,7 +29,7 @@ CR_MEMBER(nextBubble), CR_MEMBER(texx), CR_MEMBER(texy) -)); +)) CTorpedoProjectile::CTorpedoProjectile(const ProjectileParams& params): CWeaponProjectile(params) , tracking(0.0f) diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/TorpedoProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/TorpedoProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/TorpedoProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/TorpedoProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CTorpedoProjectile : public CWeaponProjectile { - CR_DECLARE(CTorpedoProjectile); + CR_DECLARE(CTorpedoProjectile) public: CTorpedoProjectile(const ProjectileParams& params); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/WeaponProjectile.cpp spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/WeaponProjectile.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/WeaponProjectile.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/WeaponProjectile.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -4,6 +4,7 @@ #include "Rendering/Colors.h" #include "Rendering/GL/VertexArray.h" #include "Sim/Projectiles/ProjectileHandler.h" +#include "Sim/Projectiles/ProjectileParams.h" #include "Sim/Projectiles/WeaponProjectiles/WeaponProjectile.h" #include "Sim/Weapons/WeaponDefHandler.h" #include "Sim/Features/Feature.h" @@ -13,9 +14,7 @@ #include "Map/Ground.h" #include "System/Matrix44f.h" - - -CR_BIND_DERIVED(CWeaponProjectile, CProjectile, ); +CR_BIND_DERIVED(CWeaponProjectile, CProjectile, ) CR_REG_METADATA(CWeaponProjectile,( CR_SETFLAG(CF_Synced), @@ -28,7 +27,7 @@ CR_MEMBER(bounces), CR_MEMBER(weaponDefID), CR_POSTLOAD(PostLoad) -)); +)) @@ -148,19 +147,7 @@ float3 impactPos, float3 impactDir ) { - const DamageArray& damageArray = (weaponDef->dynDamageExp <= 0.0f)? - weaponDef->damages: - weaponDefHandler->DynamicDamages( - weaponDef->damages, - startPos, - impactPos, - (weaponDef->dynDamageRange > 0.0f)? - weaponDef->dynDamageRange: - weaponDef->range, - weaponDef->dynDamageExp, weaponDef->dynDamageMin, - weaponDef->dynDamageInverted - ); - + const DamageArray& damageArray = CWeaponDefHandler::DynamicDamages(weaponDef, startPos, impactPos); const CGameHelper::ExplosionParams params = { impactPos, impactDir.SafeNormalize(), @@ -253,6 +240,13 @@ if (po == NULL) return; + // we are the interceptor, point us toward the interceptee pos each frame + // (normally not needed, subclasses handle it directly in their Update()'s + // *until* our owner dies) + if (owner() == NULL) { + targetPos = po->pos + po->speed; + } + if (hitscan) { if (ClosestPointOnLine(startPos, targetPos, po->pos).SqDistance(po->pos) < Square(weaponDef->collisionSize)) { po->Collision(); @@ -270,36 +264,50 @@ void CWeaponProjectile::UpdateGroundBounce() { - if (luaMoveCtrl) + // projectile is not allowed to bounce on either surface + if (!weaponDef->groundBounce && !weaponDef->waterBounce) return; - if (ttl <= 0 && weaponDef->numBounce < 0) + // max bounce already reached? + if ((bounces + 1) > weaponDef->numBounce) return; - if (!weaponDef->groundBounce && !weaponDef->waterBounce) + if (luaMoveCtrl) + return; + if (ttl <= 0) return; - float wh = 0.0f; - - if (!weaponDef->waterBounce) { - wh = ground->GetHeightReal(pos.x, pos.z); - } else if (weaponDef->groundBounce) { - wh = ground->GetHeightAboveWater(pos.x, pos.z); + // water or ground bounce? + float3 normal; + bool bounced = false; + const float distWaterHit = (pos.y > 0.0f && speed.y < 0.0f) ? (pos.y / -speed.y) : -1.0f; + const bool intersectWater = (distWaterHit >= 0.0f) && (distWaterHit <= 1.0f); + if (intersectWater && weaponDef->waterBounce) { + pos += speed * distWaterHit; + pos.y = 0.5f; + normal = CGround::GetNormalAboveWater(pos.x, pos.z); + bounced = true; + } else { + const float distGroundHit = CGround::LineGroundCol(pos, pos + speed); //TODO use traj one for traj weapons? + const bool intersectGround = (distGroundHit >= 0.0f); + if (intersectGround && weaponDef->groundBounce) { + static const float dontTouchSurface = 0.99f; + pos += dir * distGroundHit * dontTouchSurface; + normal = CGround::GetNormal(pos.x, pos.z); + bounced = true; + } } - if (pos.y >= wh) - return; - if (weaponDef->numBounce >= 0 && (bounces += 1) > weaponDef->numBounce) + if (!bounced) return; - const float3& normal = ground->GetNormal(pos.x, pos.z); - const float dot = speed.dot(normal); + // spawn CEG before bouncing, otherwise we might be too + // far up in the air if it has the (under)water flag set + explGenHandler->GenExplosion(weaponDef->bounceExplosionGeneratorID, pos, normal, speed.w, 1.0f, 1.0f, owner(), NULL); - SetPosition(pos - speed); - CWorldObject::SetVelocity(speed - (speed + normal * math::fabs(dot)) * (1 - weaponDef->bounceSlip)); - CWorldObject::SetVelocity(speed + (normal * (math::fabs(dot))) * (1 + weaponDef->bounceRebound)); - SetPosition(pos + speed); + ++bounces; + const float dot = math::fabs(speed.dot(normal)); + CWorldObject::SetVelocity(speed - (speed + normal * dot) * (1 - weaponDef->bounceSlip )); + CWorldObject::SetVelocity( speed + normal * dot * (1 + weaponDef->bounceRebound)); SetVelocityAndSpeed(speed); - - explGenHandler->GenExplosion(weaponDef->bounceExplosionGeneratorID, pos, normal, speed.w, 1.0f, 1.0f, owner(), NULL); } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/WeaponProjectileFactory.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/WeaponProjectileFactory.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/WeaponProjectileFactory.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/WeaponProjectileFactory.h 2014-10-07 20:09:51.000000000 +0000 @@ -4,8 +4,6 @@ #define WEAPONPROJECTILE_FACTORY_H struct ProjectileParams; -struct ProjectileExtParams { -}; class WeaponProjectileFactory { public: diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/WeaponProjectile.h spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/WeaponProjectile.h --- spring-96.0~14.04~ppa4/rts/Sim/Projectiles/WeaponProjectiles/WeaponProjectile.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Projectiles/WeaponProjectiles/WeaponProjectile.h 2014-10-07 20:09:51.000000000 +0000 @@ -4,61 +4,14 @@ #define WEAPON_PROJECTILE_H #include "Sim/Projectiles/Projectile.h" +#include "Sim/Projectiles/ProjectileParams.h" // easier to include this here #include "WeaponProjectileTypes.h" struct WeaponDef; -struct S3DModel; +struct ProjectileParams; class CVertexArray; class CPlasmaRepulser; -class CWeaponProjectile; -struct ProjectileParams { - ProjectileParams() - : target(NULL) - , owner(NULL) - , model(NULL) - , weaponDef(NULL) - - , ownerID(-1u) - , teamID(-1u) - , cegID(-1u) - - , ttl(0) - , gravity(0.0f) - , tracking(0.0f) - , maxRange(0.0f) - - , startAlpha(0.0f) - , endAlpha(1.0f) - { - } - - float3 pos; - float3 end; - float3 speed; - float3 spread; - float3 error; - - // unit, feature or weapon projectile to intercept - CWorldObject* target; - CUnit* owner; - S3DModel* model; - - const WeaponDef* weaponDef; - - unsigned int ownerID; - unsigned int teamID; - unsigned int cegID; - - int ttl; - float gravity; - float tracking; - float maxRange; - - // BeamLaser-specific junk - float startAlpha; - float endAlpha; -}; /** @@ -67,7 +20,7 @@ */ class CWeaponProjectile : public CProjectile { - CR_DECLARE(CWeaponProjectile); + CR_DECLARE(CWeaponProjectile) public: CWeaponProjectile(); CWeaponProjectile(const ProjectileParams& params); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/AirCAI.cpp spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/AirCAI.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/AirCAI.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/AirCAI.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -35,7 +35,7 @@ -CR_BIND_DERIVED(CAirCAI, CMobileCAI, ); +CR_BIND_DERIVED(CAirCAI, CMobileCAI, ) CR_REG_METADATA(CAirCAI, ( CR_MEMBER(basePos), CR_MEMBER(baseDir), @@ -46,7 +46,7 @@ CR_MEMBER(lastPC1), CR_MEMBER(lastPC2), CR_RESERVED(16) -)); +)) CAirCAI::CAirCAI() : CMobileCAI() @@ -76,21 +76,6 @@ possibleCommands.push_back(c); } - if (owner->unitDef->canLoopbackAttack) { - c.params.clear(); - c.id = CMD_LOOPBACKATTACK; - c.action = "loopbackattack"; - c.type = CMDTYPE_ICON_MODE; - c.name = "Loopback"; - c.mouseicon = c.name; - c.params.push_back("0"); - c.params.push_back("Normal"); - c.params.push_back("Loopback"); - c.tooltip = "Loopback attack: Sets if the aircraft should loopback after an attack instead of overflying target"; - possibleCommands.push_back(c); - nonQueingCommands.insert(CMD_LOOPBACKATTACK); - } - basePos = owner->pos; goalPos = owner->pos; } @@ -158,27 +143,6 @@ selectedUnitsHandler.PossibleCommandChange(owner); return; } - - if (c.GetID() == CMD_LOOPBACKATTACK) { - if (c.params.empty()) - return; - - switch ((int) c.params[0]) { - case 0: { airMT->loopbackAttack = false; break; } - case 1: { airMT->loopbackAttack = true; break; } - } - - for (unsigned int n = 0; n < possibleCommands.size(); n++) { - if (possibleCommands[n].id != CMD_LOOPBACKATTACK) - continue; - - possibleCommands[n].params[0] = IntToString(int(c.params[0]), "%d"); - break; - } - - selectedUnitsHandler.PossibleCommandChange(owner); - return; - } } if (!(c.options & SHIFT_KEY) @@ -617,7 +581,7 @@ if (enemyUnitIDs.empty()) { float3 attackPos = pos + (gs->randVector() * radius); - attackPos.y = ground->GetHeightAboveWater(attackPos.x, attackPos.z); + attackPos.y = CGround::GetHeightAboveWater(attackPos.x, attackPos.z); owner->AttackGround(attackPos, (ac.options & INTERNAL_ORDER) == 0, false); SetGoal(attackPos, owner->pos); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/AirCAI.h spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/AirCAI.h --- spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/AirCAI.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/AirCAI.h 2014-10-07 20:09:51.000000000 +0000 @@ -14,7 +14,7 @@ class CAirCAI : public CMobileCAI { public: - CR_DECLARE(CAirCAI); + CR_DECLARE(CAirCAI) CAirCAI(CUnit* owner); CAirCAI(); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/BuilderCAI.cpp spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/BuilderCAI.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/BuilderCAI.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/BuilderCAI.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -10,7 +10,6 @@ #include "Game/GameHelper.h" #include "Game/SelectedUnitsHandler.h" #include "Game/GlobalUnsynced.h" -#include "Lua/LuaRules.h" #include "Map/Ground.h" #include "Map/MapDamage.h" #include "Sim/Features/Feature.h" @@ -36,7 +35,7 @@ #include "System/creg/STL_Map.h" -CR_BIND_DERIVED(CBuilderCAI ,CMobileCAI , ); +CR_BIND_DERIVED(CBuilderCAI ,CMobileCAI , ) CR_REG_METADATA(CBuilderCAI , ( CR_MEMBER(buildOptions), @@ -55,7 +54,7 @@ CR_MEMBER(lastPC2), CR_MEMBER(lastPC3), CR_POSTLOAD(PostLoad) -)); +)) // not adding to members, should repopulate itself CUnitSet CBuilderCAI::reclaimers; @@ -621,7 +620,7 @@ return; } - if (luaRules && !luaRules->AllowUnitCreation(build.def, owner, &build)) { + if (!eventHandler.AllowUnitCreation(build.def, owner, &build)) { StopMove(); // cancel KeepPointingTo FinishCommand(); return; @@ -1268,7 +1267,7 @@ FinishCommand(); } } else if (owner->unitDef->canRestore) { - const float3 pos(c.params[0], ground->GetHeightReal(c.params[0], c.params[2]), c.params[2]); + const float3 pos(c.params[0], CGround::GetHeightReal(c.params[0], c.params[2]), c.params[2]); const float radius = std::min(c.params[3], 200.0f); if (MoveInBuildRange(pos, radius * 0.7f)) { diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/BuilderCAI.h spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/BuilderCAI.h --- spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/BuilderCAI.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/BuilderCAI.h 2014-10-07 20:09:51.000000000 +0000 @@ -23,7 +23,7 @@ class CBuilderCAI : public CMobileCAI { public: - CR_DECLARE(CBuilderCAI); + CR_DECLARE(CBuilderCAI) CBuilderCAI(CUnit* owner); CBuilderCAI(); ~CBuilderCAI(); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/CommandAI.cpp spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/CommandAI.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/CommandAI.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/CommandAI.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -9,11 +9,11 @@ #include "Game/GlobalUnsynced.h" #include "Game/SelectedUnitsHandler.h" #include "Game/WaitCommandsAI.h" -#include "Lua/LuaRules.h" #include "Map/Ground.h" #include "Map/MapDamage.h" #include "Sim/Features/Feature.h" #include "Sim/Features/FeatureHandler.h" +#include "Sim/Misc/ModInfo.h" #include "Sim/Misc/TeamHandler.h" #include "Sim/MoveTypes/MoveType.h" #include "Sim/Units/BuildInfo.h" @@ -24,6 +24,7 @@ #include "Sim/Weapons/WeaponDef.h" #include "System/EventHandler.h" #include "System/myMath.h" +#include "System/Log/ILog.h" #include "System/Util.h" #include "System/creg/STL_Set.h" #include "System/creg/STL_Deque.h" @@ -41,14 +42,14 @@ static const int TARGET_LOST_TIMER = 4; static const float COMMAND_CANCEL_DIST = 17.0f; -CR_BIND(CCommandQueue, ); +CR_BIND(CCommandQueue, ) CR_REG_METADATA(CCommandQueue, ( CR_MEMBER(queue), CR_ENUM_MEMBER(queueType), CR_MEMBER(tagCounter) -)); +)) -CR_BIND_DERIVED(CCommandAI, CObject, ); +CR_BIND_DERIVED(CCommandAI, CObject, ) CR_REG_METADATA(CCommandAI, ( CR_MEMBER(stockpileWeapon), @@ -71,7 +72,7 @@ CR_MEMBER(targetLostTimer), CR_POSTLOAD(PostLoad) -)); +)) CCommandAI::CCommandAI(): stockpileWeapon(0), @@ -368,11 +369,17 @@ // TODO: // extend the check to commands for which // position is not stored in params[0..2] - if (c.params.size() >= 3) { - return ((c.GetPos(0)).IsInBounds()); + if (c.params.size() < 3) { + return true; + } + if ((c.GetPos(0)).IsInBounds()) { + return true; } + const float3 pos = c.GetPos(0); + LOG_L(L_DEBUG, "Dropped command %d: outside of map (x:%f y:%f z:%f)", c.GetID(), pos.x, pos.y, pos.z); + + return false; - return true; } static inline bool AdjustGroundAttackCommand(const Command& c, bool fromSynced, bool aiOrder) @@ -413,8 +420,8 @@ // Command& cc = const_cast(c); - cc.params[1] = std::min(cPos.y, ground->GetHeightAboveWater(cPos.x, cPos.z, true || fromSynced)); - // cc.params[1] = ground->GetHeightReal(cPos.x, cPos.z, true || fromSynced); + cc.params[1] = std::min(cPos.y, CGround::GetHeightAboveWater(cPos.x, cPos.z, true || fromSynced)); + // cc.params[1] = CGround::GetHeightReal(cPos.x, cPos.z, true || fromSynced); return true; #endif @@ -440,7 +447,9 @@ case CMD_MANUALFIRE: case CMD_UNLOAD_UNIT: case CMD_UNLOAD_UNITS: { - if (!IsCommandInMap(c)) { return false; } + if (!IsCommandInMap(c)) { + return false; + } } break; default: { @@ -596,7 +605,7 @@ void CCommandAI::GiveCommand(const Command& c, bool fromSynced) { - if (luaRules && !luaRules->AllowCommand(owner, c, fromSynced)) { + if (!eventHandler.AllowCommand(owner, c, fromSynced)) { return; } eventHandler.UnitCommand(owner, c); @@ -923,8 +932,6 @@ } } - // FIXME: handle CMD_LOOPBACKATTACK, etc... - CCommandQueue::iterator insertIt = queue->begin(); if (c.options & ALT_KEY) { @@ -1350,7 +1357,7 @@ return; } - if (luaRules && !luaRules->CommandFallback(owner, c)) { + if (!eventHandler.CommandFallback(owner, c)) { return; // luaRules wants the command to stay at the front } @@ -1425,17 +1432,14 @@ { assert(!commandQue.empty()); - const Command cmd = commandQue.front(); - const int cmdID = cmd.GetID(); - const int cmdTag = cmd.tag; - const unsigned char cmdOpts = cmd.options; + const Command cmd = commandQue.front(); //cppcheck false positive, copy is needed here const bool dontRepeat = (cmd.options & INTERNAL_ORDER); if (repeatOrders && !dontRepeat - && (cmdID != CMD_STOP) - && (cmdID != CMD_PATROL) - && (cmdID != CMD_SET_WANTED_MAX_SPEED)){ + && (cmd.GetID() != CMD_STOP) + && (cmd.GetID() != CMD_PATROL) + && (cmd.GetID() != CMD_SET_WANTED_MAX_SPEED)){ commandQue.push_back(cmd); } @@ -1561,11 +1565,13 @@ } -bool CCommandAI::HasBuildCommand() const { +bool CCommandAI::HasCommand(int cmdID) const { if (commandQue.empty()) return false; + if (cmdID < 0) + return ((commandQue.front()).IsBuildCommand()); - return ((commandQue.front()).IsBuildCommand()); + return ((commandQue.front()).GetID() == cmdID); } bool CCommandAI::HasMoreMoveCommands() const diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/CommandAI.h spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/CommandAI.h --- spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/CommandAI.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/CommandAI.h 2014-10-07 20:09:51.000000000 +0000 @@ -17,7 +17,7 @@ class CCommandAI : public CObject { - CR_DECLARE(CCommandAI); + CR_DECLARE(CCommandAI) public: CCommandAI(CUnit* owner); @@ -58,7 +58,7 @@ */ virtual void StopAttackingAllyTeam(int ally); - bool HasBuildCommand() const; + bool HasCommand(int cmdID) const; bool HasMoreMoveCommands() const; int CancelCommands(const Command& c, CCommandQueue& queue, bool& first); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/Command.cpp spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/Command.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/Command.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/Command.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,7 +2,7 @@ #include "Command.h" -CR_BIND(Command, ); +CR_BIND(Command, ) CR_REG_METADATA(Command, ( CR_MEMBER(aiCommandId), CR_MEMBER(options), @@ -10,9 +10,9 @@ CR_MEMBER(tag), CR_MEMBER(timeOut), CR_MEMBER(id) -)); +)) -CR_BIND(CommandDescription, ); +CR_BIND(CommandDescription, ) CR_REG_METADATA(CommandDescription, ( CR_MEMBER(id), CR_MEMBER(type), @@ -27,4 +27,4 @@ CR_MEMBER(onlyTexture), CR_MEMBER(params), CR_RESERVED(32) -)); +)) diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/Command.h spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/Command.h --- spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/Command.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/Command.h 2014-10-07 20:09:51.000000000 +0000 @@ -9,7 +9,6 @@ #include "System/creg/creg_cond.h" #include "System/float3.h" #include "System/SafeVector.h" -#include "lib/gml/gmlcnf.h" // ID's lower than 0 are reserved for build options (cmd -x = unitdefs[x]) #define CMD_STOP 0 @@ -52,7 +51,6 @@ #define CMD_RESURRECT 125 #define CMD_CAPTURE 130 #define CMD_AUTOREPAIRLEVEL 135 -#define CMD_LOOPBACKATTACK 140 #define CMD_IDLEMODE 145 #define CMD_FAILED 150 @@ -114,13 +112,9 @@ struct Command { private: - CR_DECLARE_STRUCT(Command); + CR_DECLARE_STRUCT(Command) /* TODO check if usage of System/MemPool.h for this struct improves performance - #if !(defined(USE_GML) && GML_ENABLE_SIM) - inline void* operator new(size_t size) { return mempool.Alloc(size); } - inline void operator delete(void* p, size_t size) { mempool.Free(p, size); } - #endif */ public: @@ -353,7 +347,7 @@ struct CommandDescription { private: - CR_DECLARE_STRUCT(CommandDescription); + CR_DECLARE_STRUCT(CommandDescription) public: CommandDescription(): diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/CommandQueue.h spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/CommandQueue.h --- spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/CommandQueue.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/CommandQueue.h 2014-10-07 20:09:51.000000000 +0000 @@ -3,8 +3,6 @@ #ifndef _COMMAND_QUEUE_H #define _COMMAND_QUEUE_H -#include "lib/gml/gmlmut.h" - #include #include "Command.h" @@ -15,7 +13,7 @@ friend class CFactoryCAI; // see CommandAI.cpp for further creg stuff for this class - CR_DECLARE_STRUCT(CCommandQueue); + CR_DECLARE_STRUCT(CCommandQueue) public: enum QueueType { @@ -49,33 +47,23 @@ inline void pop_back() { - GML_STDMUTEX_LOCK(cai); // pop_back - queue.pop_back(); } inline void pop_front() { - GML_STDMUTEX_LOCK(cai); // pop_front - queue.pop_front(); } inline iterator erase(iterator pos) { - GML_STDMUTEX_LOCK(cai); // erase - return queue.erase(pos); } inline iterator erase(iterator first, iterator last) { - GML_STDMUTEX_LOCK(cai); // erase - return queue.erase(first, last); } inline void clear() { - GML_STDMUTEX_LOCK(cai); // clear - queue.clear(); } @@ -128,8 +116,6 @@ inline void CCommandQueue::push_back(const Command& cmd) { - GML_STDMUTEX_LOCK(cai); // push_back - queue.push_back(cmd); queue.back().tag = GetNextTag(); } @@ -137,8 +123,6 @@ inline void CCommandQueue::push_front(const Command& cmd) { - GML_STDMUTEX_LOCK(cai); // push_front - queue.push_front(cmd); queue.front().tag = GetNextTag(); } @@ -149,7 +133,6 @@ { Command tmpCmd = cmd; tmpCmd.tag = GetNextTag(); - GML_STDMUTEX_LOCK(cai); // insert return queue.insert(pos, tmpCmd); } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/FactoryCAI.cpp spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/FactoryCAI.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/FactoryCAI.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/FactoryCAI.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -21,22 +21,22 @@ #include "System/EventHandler.h" #include "System/Exceptions.h" -CR_BIND_DERIVED(CFactoryCAI ,CCommandAI , ); +CR_BIND_DERIVED(CFactoryCAI ,CCommandAI , ) CR_REG_METADATA(CFactoryCAI , ( CR_MEMBER(newUnitCommands), CR_MEMBER(buildOptions), CR_RESERVED(16), CR_POSTLOAD(PostLoad) -)); +)) -CR_BIND(CFactoryCAI::BuildOption, ); +CR_BIND(CFactoryCAI::BuildOption, ) CR_REG_METADATA_SUB(CFactoryCAI,BuildOption , ( CR_MEMBER(name), CR_MEMBER(fullName), CR_MEMBER(numQued) -)); +)) static std::string GetUnitDefBuildOptionToolTip(const UnitDef* ud, bool disabled) { std::string tooltip; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/FactoryCAI.h spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/FactoryCAI.h --- spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/FactoryCAI.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/FactoryCAI.h 2014-10-07 20:09:51.000000000 +0000 @@ -16,8 +16,8 @@ class CFactoryCAI : public CCommandAI { public: - CR_DECLARE(CFactoryCAI); - CR_DECLARE_SUB(BuildOption); + CR_DECLARE(CFactoryCAI) + CR_DECLARE_SUB(BuildOption) struct BuildOption { CR_DECLARE_STRUCT(BuildOption) diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/MobileCAI.cpp spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/MobileCAI.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/MobileCAI.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/MobileCAI.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -43,7 +43,7 @@ -CR_BIND_DERIVED(CMobileCAI ,CCommandAI , ); +CR_BIND_DERIVED(CMobileCAI ,CCommandAI , ) CR_REG_METADATA(CMobileCAI, ( CR_MEMBER(goalPos), CR_MEMBER(goalRadius), @@ -68,7 +68,7 @@ CR_MEMBER(slowGuard), CR_MEMBER(moveDir), CR_RESERVED(16) -)); +)) CMobileCAI::CMobileCAI(): CCommandAI(), @@ -687,7 +687,7 @@ if (tempOrder && orderTarget) { const float3& closestPos = ClosestPointOnLine(commandPos1, commandPos2, owner->pos); const float curTargetDist = LinePointDist(closestPos, commandPos2, orderTarget->pos); - const float maxTargetDist = (500 * owner->moveState + owner->maxRange); + const float maxTargetDist = (owner->moveType->GetManeuverLeash() * owner->moveState + owner->maxRange); if (owner->moveState < MOVESTATE_ROAM && curTargetDist > maxTargetDist) { StopMove(); @@ -1169,11 +1169,9 @@ void CMobileCAI::CalculateCancelDistance() { - // calculate a rough turn radius - const float turnFrames = SPRING_CIRCLE_DIVS / std::max(owner->unitDef->turnRate, 1.0f); - const float turnRadius = ((owner->unitDef->speed / GAME_SPEED) * turnFrames) / (PI + PI); - const float tmp = turnRadius + (SQUARE_SIZE << 1); + const float tmp = owner->moveType->CalcStaticTurnRadius() + (SQUARE_SIZE << 1); // clamp it a bit because the units don't have to turn at max speed - cancelDistance = std::min(std::max(tmp * tmp, 1024.f), 2048.f); + cancelDistance = Clamp(tmp * tmp, 1024.0f, 2048.0f); } + diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/MobileCAI.h spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/MobileCAI.h --- spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/MobileCAI.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/MobileCAI.h 2014-10-07 20:09:51.000000000 +0000 @@ -14,7 +14,7 @@ class CMobileCAI : public CCommandAI { public: - CR_DECLARE(CMobileCAI); + CR_DECLARE(CMobileCAI) CMobileCAI(CUnit* owner); CMobileCAI(); virtual ~CMobileCAI() {} diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/TransportCAI.cpp spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/TransportCAI.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/TransportCAI.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/TransportCAI.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,6 @@ #include "Game/GlobalUnsynced.h" #include "Map/Ground.h" #include "Sim/Misc/TeamHandler.h" -#include "Sim/Misc/ModInfo.h" #include "Sim/Misc/QuadField.h" #include "Sim/Units/BuildInfo.h" #include "Sim/Units/UnitHandler.h" @@ -24,7 +23,7 @@ #define AIRTRANSPORT_DOCKING_RADIUS 16 #define AIRTRANSPORT_DOCKING_ANGLE 50 -CR_BIND_DERIVED(CTransportCAI,CMobileCAI , ); +CR_BIND_DERIVED(CTransportCAI,CMobileCAI , ) CR_REG_METADATA(CTransportCAI, ( CR_MEMBER(toBeTransportedUnitId), @@ -37,7 +36,7 @@ CR_MEMBER(approachVector), CR_MEMBER(endDropPos), CR_RESERVED(16) -)); +)) CTransportCAI::CTransportCAI() : CMobileCAI() @@ -220,7 +219,7 @@ SetGoal(wantedPos, owner->pos, 1.0f); am->ForceHeading(trans->GetTransporteeWantedHeading(unit)); - am->SetWantedAltitude(wantedPos.y - ground->GetHeightAboveWater(wantedPos.x, wantedPos.z)); + am->SetWantedAltitude(wantedPos.y - CGround::GetHeightAboveWater(wantedPos.x, wantedPos.z)); am->maxDrift = 1.0f; // FIXME: kill the hardcoded constants, use the command's radius @@ -377,7 +376,7 @@ pos.y -= unitToUnload->radius; // don't unload unit on too-steep slopes - if (moveDef != NULL && ground->GetSlope(pos.x, pos.z) > moveDef->maxSlope) + if (moveDef != NULL && CGround::GetSlope(pos.x, pos.z) > moveDef->maxSlope) continue; const std::vector& units = quadField->GetSolidsExact(pos, spread, 0xFFFFFFFF, CSolidObject::CSTATE_BIT_SOLIDOBJECTS); @@ -399,7 +398,7 @@ { if (!static_cast(owner)->CanLoadUnloadAtPos(pos, unitToUnload)) return false; - if (unitToUnload->moveDef != NULL && ground->GetSlope(pos.x, pos.z) > unitToUnload->moveDef->maxSlope) + if (unitToUnload->moveDef != NULL && CGround::GetSlope(pos.x, pos.z) > unitToUnload->moveDef->maxSlope) return false; const float radius = std::max(1.0f, math::ceil(unitToUnload->radius / SQUARE_SIZE)) * SQUARE_SIZE; @@ -418,7 +417,7 @@ if (!ownerTrans->CanLoadUnloadAtPos(pos, unitToUnload)) return false; - if (unitToUnload->moveDef != NULL && ground->GetSlope(pos.x, pos.z) > unitToUnload->moveDef->maxSlope) + if (unitToUnload->moveDef != NULL && CGround::GetSlope(pos.x, pos.z) > unitToUnload->moveDef->maxSlope) return false; const float radius = std::max(1.0f, math::ceil(unitToUnload->radius / SQUARE_SIZE)) * SQUARE_SIZE; @@ -468,7 +467,7 @@ // remaining spots while (ti != transportees.end() && startpos.SqDistance(nextPos) < startpos.SqDistance(endpos)) { nextPos += (dir * (ti->unit->radius)); - nextPos.y = ground->GetHeightAboveWater(nextPos.x, nextPos.z); + nextPos.y = CGround::GetHeightAboveWater(nextPos.x, nextPos.z); // check landing spot is ok for landing on if (!SpotIsClear(nextPos, ti->unit)) @@ -684,7 +683,7 @@ // handle air transports differently SetGoal(wantedPos, owner->pos); - am->SetWantedAltitude(wantedPos.y - ground->GetHeightAboveWater(wantedPos.x, wantedPos.z)); + am->SetWantedAltitude(wantedPos.y - CGround::GetHeightAboveWater(wantedPos.x, wantedPos.z)); am->ForceHeading(static_cast(owner)->GetTransporteeWantedHeading(transportee)); am->maxDrift = 1.0f; @@ -760,7 +759,7 @@ CUnit* transportee = (transportees.front()).unit; if (am != NULL) { - pos.y = ground->GetHeightAboveWater(pos.x, pos.z); + pos.y = CGround::GetHeightAboveWater(pos.x, pos.z); am->maxDrift = 1.0f; // if near target or passed it accidentally, drop unit @@ -844,7 +843,7 @@ if (am != NULL) { // lower to ground - startingDropPos.y = ground->GetHeightAboveWater(startingDropPos.x, startingDropPos.z); + startingDropPos.y = CGround::GetHeightAboveWater(startingDropPos.x, startingDropPos.z); const float3 wantedPos = startingDropPos + UpVector * transportee->model->height; SetGoal(wantedPos, owner->pos); @@ -859,7 +858,7 @@ isFirstIteration = false; // once at ground - if (owner->pos.y - ground->GetHeightAboveWater(wantedPos.x, wantedPos.z) < SQUARE_SIZE) { + if (owner->pos.y - CGround::GetHeightAboveWater(wantedPos.x, wantedPos.z) < SQUARE_SIZE) { // nail it to the ground before it tries jumping up, only to land again... am->SetState(am->AIRCRAFT_LANDED); // call this so that other animations such as opening doors may be started diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/TransportCAI.h spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/TransportCAI.h --- spring-96.0~14.04~ppa4/rts/Sim/Units/CommandAI/TransportCAI.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/CommandAI/TransportCAI.h 2014-10-07 20:09:51.000000000 +0000 @@ -22,7 +22,7 @@ class CTransportCAI : public CMobileCAI { public: - CR_DECLARE(CTransportCAI); + CR_DECLARE(CTransportCAI) CTransportCAI(CUnit* owner); CTransportCAI(); ~CTransportCAI(); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/Groups/Group.cpp spring-98.0~14.04~ppa6/rts/Sim/Units/Groups/Group.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Units/Groups/Group.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/Groups/Group.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,6 @@ #include "System/EventHandler.h" #include "System/creg/STL_Set.h" #include "System/float3.h" -#include "lib/gml/gmlmut.h" CR_BIND(CGroup, (0, NULL)) CR_REG_METADATA(CGroup, ( @@ -15,7 +14,7 @@ CR_MEMBER(units), CR_MEMBER(handler), CR_POSTLOAD(PostLoad) -)); +)) ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -47,8 +46,6 @@ bool CGroup::AddUnit(CUnit* unit) { - GML_RECMUTEX_LOCK(group); // AddUnit - units.insert(unit); handler->PushGroupChange(id); @@ -57,8 +54,6 @@ void CGroup::RemoveUnit(CUnit* unit) { - GML_RECMUTEX_LOCK(group); // RemoveUnit - units.erase(unit); handler->PushGroupChange(id); } @@ -81,8 +76,6 @@ void CGroup::ClearUnits() { - GML_RECMUTEX_LOCK(group); // ClearUnits - while (!units.empty()) { (*units.begin())->SetGroup(0); } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/Groups/Group.h spring-98.0~14.04~ppa6/rts/Sim/Units/Groups/Group.h --- spring-96.0~14.04~ppa4/rts/Sim/Units/Groups/Group.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/Groups/Group.h 2014-10-07 20:09:51.000000000 +0000 @@ -20,7 +20,7 @@ */ class CGroup { - CR_DECLARE_STRUCT(CGroup); + CR_DECLARE_STRUCT(CGroup) public: CGroup(int id, CGroupHandler* groupHandler); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/Groups/GroupHandler.cpp spring-98.0~14.04~ppa6/rts/Sim/Units/Groups/GroupHandler.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Units/Groups/GroupHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/Groups/GroupHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,21 +1,15 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ #include -#include +#include -#include "lib/gml/gmlmut.h" #include "GroupHandler.h" #include "Group.h" #include "Game/SelectedUnitsHandler.h" -#include "Game/UI/MouseHandler.h" -#include "Game/Camera/CameraController.h" #include "Game/CameraHandler.h" -#include "Sim/Units/Unit.h" #include "System/creg/STL_Set.h" #include "System/Log/ILog.h" -#include "System/TimeProfiler.h" #include "System/Input/KeyInput.h" -#include "System/FileSystem/FileSystem.h" #include "System/EventHandler.h" std::vector grouphandlers; @@ -27,7 +21,7 @@ CR_MEMBER(freeGroups), CR_MEMBER(firstUnusedGroup), CR_MEMBER(changedGroups) -)); +)) ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -52,8 +46,6 @@ void CGroupHandler::Update() { { - GML_RECMUTEX_LOCK(group); // Update - for (std::vector::iterator gi = groups.begin(); gi != groups.end(); ++gi) { if ((*gi) != NULL) { // Update may invoke RemoveGroup, but this will only NULL the element, so there will be no iterator invalidation here @@ -64,8 +56,6 @@ std::set grpChg; { - GML_STDMUTEX_LOCK(grpchg); // Update - if (changedGroups.empty()) return; @@ -77,31 +67,27 @@ } } -void CGroupHandler::GroupCommand(int num) +bool CGroupHandler::GroupCommand(int num) { - GML_RECMUTEX_LOCK(grpsel); // GroupCommand - std::string cmd = ""; - if (keyInput->IsKeyPressed(SDLK_LCTRL)) { - if (!keyInput->IsKeyPressed(SDLK_LSHIFT)) { + if (KeyInput::GetKeyModState(KMOD_CTRL)) { + if (!KeyInput::GetKeyModState(KMOD_SHIFT)) { cmd = "set"; } else { cmd = "add"; } - } else if (keyInput->IsKeyPressed(SDLK_LSHIFT)) { + } else if (KeyInput::GetKeyModState(KMOD_SHIFT)) { cmd = "selectadd"; - } else if (keyInput->IsKeyPressed(SDLK_LALT)) { + } else if (KeyInput::GetKeyModState(KMOD_ALT)) { cmd = "selecttoggle"; } - GroupCommand(num, cmd); + return GroupCommand(num, cmd); } -void CGroupHandler::GroupCommand(int num, const std::string& cmd) +bool CGroupHandler::GroupCommand(int num, const std::string& cmd) { - GML_RECMUTEX_LOCK(grpsel); // GroupCommand - CGroup* group = groups[num]; if ((cmd == "set") || (cmd == "add")) { @@ -120,7 +106,7 @@ for (ui = group->units.begin(); ui != group->units.end(); ++ui) { selectedUnitsHandler.AddUnit(*ui); } - return; + return true; } else if (cmd == "selectclear") { // do not select the group, just remove its members from the current selection @@ -128,7 +114,7 @@ for (ui = group->units.begin(); ui != group->units.end(); ++ui) { selectedUnitsHandler.RemoveUnit(*ui); } - return; + return true; } else if (cmd == "selecttoggle") { // do not select the group, just toggle its members with the current selection @@ -141,22 +127,24 @@ selectedUnitsHandler.RemoveUnit(*ui); } } - return; + return true; } - if ((selectedUnitsHandler.IsGroupSelected(num)) && !group->units.empty()) { + if (group->units.empty()) + return false; + + if (selectedUnitsHandler.IsGroupSelected(num)) { const float3 groupCenter = group->CalculateCenter(); camHandler->CameraTransition(0.5f); camHandler->GetCurrentController().SetPos(groupCenter); } selectedUnitsHandler.SelectGroup(num); + return true; } CGroup* CGroupHandler::CreateNewGroup() { - GML_RECMUTEX_LOCK(group); // GroupCommand - if (freeGroups.empty()) { CGroup* group = new CGroup(firstUnusedGroup++, this); groups.push_back(group); @@ -172,8 +160,6 @@ void CGroupHandler::RemoveGroup(CGroup* group) { - GML_RECMUTEX_LOCK(grpsel); // RemoveGroup - if (group->id < FIRST_SPECIAL_GROUP) { LOG_L(L_WARNING, "Trying to remove hot-key group %i", group->id); return; @@ -188,8 +174,6 @@ void CGroupHandler::PushGroupChange(int id) { - GML_STDMUTEX_LOCK(grpchg); // PushGroupChange - changedGroups.insert(id); } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/Groups/GroupHandler.h spring-98.0~14.04~ppa6/rts/Sim/Units/Groups/GroupHandler.h --- spring-96.0~14.04~ppa4/rts/Sim/Units/Groups/GroupHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/Groups/GroupHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -21,7 +21,7 @@ */ class CGroupHandler { private: - CR_DECLARE_STRUCT(CGroupHandler); + CR_DECLARE_STRUCT(CGroupHandler) CGroupHandler(int teamId); ~CGroupHandler(); @@ -40,8 +40,8 @@ void Update(); - void GroupCommand(int num); - void GroupCommand(int num, const std::string& cmd); + bool GroupCommand(int num); + bool GroupCommand(int num, const std::string& cmd); CGroup* CreateNewGroup(); void RemoveGroup(CGroup* group); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/Scripts/CobInstance.cpp spring-98.0~14.04~ppa6/rts/Sim/Units/Scripts/CobInstance.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Units/Scripts/CobInstance.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/Scripts/CobInstance.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -37,7 +37,7 @@ #include "Sim/Weapons/Weapon.h" #include "System/Util.h" #include "System/myMath.h" -#include "System/Sound/SoundChannels.h" +#include "System/Sound/ISoundChannels.h" #include "System/Sync/SyncTracer.h" #endif // _CONSOLE @@ -612,7 +612,7 @@ void CCobInstance::PlayUnitSound(int snr, int attr) { - Channels::UnitReply.PlaySample(script.sounds[snr], unit->pos, unit->speed, attr); + Channels::UnitReply->PlaySample(script.sounds[snr], unit->pos, unit->speed, attr); } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/Scripts/CobThread.cpp spring-98.0~14.04~ppa6/rts/Sim/Units/Scripts/CobThread.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Units/Scripts/CobThread.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/Scripts/CobThread.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -6,7 +6,6 @@ #include "CobInstance.h" #include "CobEngine.h" #include "UnitScriptLog.h" -#include "Lua/LuaRules.h" #include "Sim/Misc/GlobalConstants.h" #include "Sim/Misc/GlobalSynced.h" @@ -80,21 +79,18 @@ int CCobThread::CheckStack(unsigned int size, bool warn) { - if ((unsigned)size > stack.size()) { + if (size <= stack.size()) + return size; + + if (warn) { static char msg[512]; static const char* fmt = "stack-size mismatch: need %u but have %lu arguments " "(too many passed to function or too few returned?)"; - - if (warn) { - SNPRINTF(msg, sizeof(msg), fmt, size, stack.size()); - ShowError(msg); - } - - return stack.size(); + SNPRINTF(msg, sizeof(msg), fmt, size, stack.size()); + ShowError(msg); } - - return size; + return stack.size(); } int CCobThread::GetStackVal(int pos) diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/Scripts/CobThread.h spring-98.0~14.04~ppa6/rts/Sim/Units/Scripts/CobThread.h --- spring-96.0~14.04~ppa4/rts/Sim/Units/Scripts/CobThread.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/Scripts/CobThread.h 2014-10-07 20:09:51.000000000 +0000 @@ -13,6 +13,8 @@ class CCobFile; class CCobInstance; +using std::vector; + class CCobThread : public CObject, public CUnitScript::IAnimListener { diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/Scripts/LuaUnitScript.cpp spring-98.0~14.04~ppa6/rts/Sim/Units/Scripts/LuaUnitScript.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Units/Scripts/LuaUnitScript.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/Scripts/LuaUnitScript.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -12,10 +12,10 @@ #include "Lua/LuaConfig.h" #include "Lua/LuaCallInCheck.h" #include "Lua/LuaHandleSynced.h" +#include "Lua/LuaUtils.h" #include "Sim/Units/UnitHandler.h" #include "Sim/Units/Unit.h" #include "Sim/Weapons/PlasmaRepulser.h" -#include "Lua/LuaHelper.h" using std::map; @@ -405,33 +405,6 @@ return RawRunCallIn(scriptIndex[id], inArgs, outArgs); } -bool CLuaUnitScript::RawRunCallIn(int functionId, int inArgs, int outArgs) -{ - CUnit* oldActiveUnit = activeUnit; - CUnitScript* oldActiveScript = activeScript; - - activeUnit = unit; - activeScript = this; - - std::string err; - const int error = handle->RunCallIn(inArgs, outArgs, err); - - activeUnit = oldActiveUnit; - activeScript = oldActiveScript; - - if (error != 0) { - const string& fname = GetScriptName(functionId); - - LOG_L(L_ERROR, "%s::RunCallIn: error = %i, %s::%s, %s", - handle->GetName().c_str(), error, "CLuaUnitScript", - fname.c_str(), err.c_str()); - RemoveCallIn(fname); - - return false; - } - return true; -} - int CLuaUnitScript::RunQueryCallIn(int fn) { @@ -879,6 +852,34 @@ } +bool CLuaUnitScript::RawRunCallIn(int functionId, int inArgs, int outArgs) +{ + CUnit* oldActiveUnit = activeUnit; + CUnitScript* oldActiveScript = activeScript; + + activeUnit = unit; + activeScript = this; + + std::string err; + const int error = handle->RunCallIn(L, inArgs, outArgs, err); + + activeUnit = oldActiveUnit; + activeScript = oldActiveScript; + + if (error != 0) { + const string& fname = GetScriptName(functionId); + + LOG_L(L_ERROR, "%s::RunCallIn: error = %i, %s::%s, %s", + handle->GetName().c_str(), error, "CLuaUnitScript", + fname.c_str(), err.c_str()); + RemoveCallIn(fname); + + return false; + } + return true; +} + + void CLuaUnitScript::Destroy() { Call(LUAFN_Destroy); } void CLuaUnitScript::StartMoving(bool reversing) { Call(LUAFN_StartMoving, reversing * 1.0f); } void CLuaUnitScript::StopMoving() { Call(LUAFN_StopMoving); } @@ -1165,7 +1166,7 @@ const int val = luaL_checkint(L, arg++); int param; if (args == 1) { - param = luaL_checkint(L, arg++); + param = lua_isboolean(L, arg) ? int(lua_toboolean(L, arg++)) : luaL_checkint(L, arg++); } else { const int x = luaL_checkint(L, arg++); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/Scripts/UnitScript.cpp spring-98.0~14.04~ppa6/rts/Sim/Units/Scripts/UnitScript.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Units/Scripts/UnitScript.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/Scripts/UnitScript.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -42,7 +42,7 @@ #include "System/myMath.h" #include "System/Log/ILog.h" #include "System/Util.h" -#include "System/Sound/SoundChannels.h" +#include "System/Sound/ISoundChannels.h" #include "System/Sync/SyncTracer.h" #endif @@ -527,7 +527,7 @@ // Make sure wakes are only emitted on water if ((sfxType >= SFX_WAKE) && (sfxType <= SFX_REVERSE_WAKE_2)) { - if (ground->GetApproximateHeight(unit->pos.x, unit->pos.z) > 0.0f) { + if (CGround::GetApproximateHeight(unit->pos.x, unit->pos.z) > 0.0f) { return; } } @@ -782,7 +782,7 @@ const float l2 = 3 + math::sqrt(l - 3); baseSpeed *= (l2 / l); } - if (unit->pos.y - ground->GetApproximateHeight(unit->pos.x, unit->pos.z) > 15) { + if (unit->pos.y - CGround::GetApproximateHeight(unit->pos.x, unit->pos.z) > 15) { explSpeed.y = (0.5f - gs->randFloat()) * 6.0f; } @@ -952,9 +952,9 @@ case HYPOT: return int(math::hypot((float)p1, (float)p2)); case GROUND_HEIGHT: - return int(ground->GetHeightAboveWater(UNPACKX(p1), UNPACKZ(p1)) * COBSCALE); + return int(CGround::GetHeightAboveWater(UNPACKX(p1), UNPACKZ(p1)) * COBSCALE); case GROUND_WATER_HEIGHT: - return int(ground->GetHeightReal(UNPACKX(p1), UNPACKZ(p1)) * COBSCALE); + return int(CGround::GetHeightReal(UNPACKX(p1), UNPACKZ(p1)) * COBSCALE); case BUILD_PERCENT_LEFT: return int((1.0f - unit->buildProgress) * 100); @@ -1155,9 +1155,9 @@ break; } if (p4 == 0) { - Channels::General.PlaySample(script->sounds[p1], unit->pos, unit->speed, float(p2) / COBSCALE); + Channels::General->PlaySample(script->sounds[p1], unit->pos, unit->speed, float(p2) / COBSCALE); } else { - Channels::General.PlaySample(script->sounds[p1], float(p2) / COBSCALE); + Channels::General->PlaySample(script->sounds[p1], float(p2) / COBSCALE); } return 0; } @@ -1245,90 +1245,100 @@ return 1; } + + case WEAPON_RELOADSTATE: { const int np1 = -p1; - if (p1 > 0 && static_cast(p1) <= unit->weapons.size()) { - return unit->weapons[p1-1]->reloadStatus; - } - else if (np1 > 0 && static_cast(np1) <= unit->weapons.size()) { - const int old = unit->weapons[np1 - 1]->reloadStatus; - unit->weapons[np1 - 1]->reloadStatus = p2; + + if (p1 > 0 && static_cast(p1) <= unit->weapons.size()) + return unit->weapons[p1 - 1]->reloadStatus; + + if (np1 > 0 && static_cast(np1) <= unit->weapons.size()) { + CWeapon* w = unit->weapons[np1 - 1]; + const int old = w->reloadStatus; + w->reloadStatus = p2; return old; } - else { - return -1; - } + + return -1; } case WEAPON_RELOADTIME: { const int np1 = -p1; - if (p1 > 0 && static_cast(p1) <= unit->weapons.size()) { - return unit->weapons[p1-1]->reloadTime; - } - else if (np1 > 0 && static_cast(np1) <= unit->weapons.size()) { - const int old = unit->weapons[np1 - 1]->reloadTime; - unit->weapons[np1 - 1]->reloadTime = p2; + + if (p1 > 0 && static_cast(p1) <= unit->weapons.size()) + return unit->weapons[p1 - 1]->reloadTime; + + if (np1 > 0 && static_cast(np1) <= unit->weapons.size()) { + CWeapon* w = unit->weapons[np1 - 1]; + const int old = w->reloadTime; + w->reloadTime = p2; return old; } - else { - return -1; - } + + return -1; } case WEAPON_ACCURACY: { const int np1 = -p1; - if (p1 > 0 && static_cast(p1) <= unit->weapons.size()) { - return int(unit->weapons[p1-1]->accuracy * COBSCALE); - } - else if (np1 > 0 && static_cast(np1) <= unit->weapons.size()) { - const int old = unit->weapons[np1 - 1]->accuracy * COBSCALE; - unit->weapons[np1 - 1]->accuracy = float(p2) / COBSCALE; + + if (p1 > 0 && static_cast(p1) <= unit->weapons.size()) + return int(unit->weapons[p1 - 1]->accuracyError * COBSCALE); + + if (np1 > 0 && static_cast(np1) <= unit->weapons.size()) { + CWeapon* w = unit->weapons[np1 - 1]; + const int old = w->accuracyError * COBSCALE; + w->accuracyError = float(p2) / COBSCALE; return old; } - else { - return -1; - } + + return -1; } case WEAPON_SPRAY: { const int np1 = -p1; - if (p1 > 0 && static_cast(p1) <= unit->weapons.size()) { - return int(unit->weapons[p1-1]->sprayAngle * COBSCALE); - } - else if (np1 > 0 && static_cast(np1) <= unit->weapons.size()) { - const int old = unit->weapons[np1 - 1]->sprayAngle * COBSCALE; - unit->weapons[np1 - 1]->sprayAngle = float(p2) / COBSCALE; + + if (p1 > 0 && static_cast(p1) <= unit->weapons.size()) + return int(unit->weapons[p1 - 1]->sprayAngle * COBSCALE); + + if (np1 > 0 && static_cast(np1) <= unit->weapons.size()) { + CWeapon* w = unit->weapons[np1 - 1]; + const int old = w->sprayAngle * COBSCALE; + w->sprayAngle = float(p2) / COBSCALE; return old; } - else { - return -1; - } + + return -1; } case WEAPON_RANGE: { const int np1 = -p1; - if (p1 > 0 && static_cast(p1) <= unit->weapons.size()) { + + if (p1 > 0 && static_cast(p1) <= unit->weapons.size()) return int(unit->weapons[p1 - 1]->range * COBSCALE); - } - else if (np1 > 0 && static_cast(np1) <= unit->weapons.size()) { - const int old = unit->weapons[np1 - 1]->range * COBSCALE; - unit->weapons[np1 - 1]->range = float(p2) / COBSCALE; + + if (np1 > 0 && static_cast(np1) <= unit->weapons.size()) { + CWeapon* w = unit->weapons[np1 - 1]; + const int old = w->range * COBSCALE; + w->range = float(p2) / COBSCALE; return old; } - else { - return -1; - } + + return -1; } case WEAPON_PROJECTILE_SPEED: { const int np1 = -p1; - if (p1 > 0 && static_cast(p1) <= unit->weapons.size()) { - return int(unit->weapons[p1-1]->projectileSpeed * COBSCALE); - } - else if (np1 > 0 && static_cast(np1) <= unit->weapons.size()) { - const int old = unit->weapons[np1 - 1]->projectileSpeed * COBSCALE; - unit->weapons[np1 - 1]->projectileSpeed = float(p2) / COBSCALE; + + if (p1 > 0 && static_cast(p1) <= unit->weapons.size()) + return int(unit->weapons[p1 - 1]->projectileSpeed * COBSCALE); + + if (np1 > 0 && static_cast(np1) <= unit->weapons.size()) { + CWeapon* w = unit->weapons[np1 - 1]; + const int old = w->projectileSpeed * COBSCALE; + w->projectileSpeed = float(p2) / COBSCALE; return old; } - else { - return -1; - } + + return -1; } + + case GAME_FRAME: { return gs->frameNum; } @@ -1652,7 +1662,7 @@ const LocalModelPiece* smp = GetScriptLocalModelPiece(scriptPieceNum); return (smp->GetLModelPieceIndex()); -}; +} int CUnitScript::ModelToScript(int lmodelPieceNum) const { const LocalModel* lm = unit->localModel; @@ -1663,5 +1673,5 @@ const LocalModelPiece* lmp = lm->GetPiece(lmodelPieceNum); return (lmp->GetScriptPieceIndex()); -}; +} diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/Unit.cpp spring-98.0~14.04~ppa6/rts/Sim/Units/Unit.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Units/Unit.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/Unit.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,7 +1,5 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ -#include "lib/gml/gml.h" - #include "UnitDef.h" #include "Unit.h" #include "UnitHandler.h" @@ -28,7 +26,6 @@ #include "Game/GlobalUnsynced.h" #include "Game/SelectedUnitsHandler.h" #include "Game/Players/Player.h" -#include "Lua/LuaRules.h" #include "Map/Ground.h" #include "Map/MapInfo.h" #include "Map/ReadMap.h" @@ -57,17 +54,16 @@ #include "Sim/Weapons/Weapon.h" #include "Sim/Weapons/WeaponDefHandler.h" #include "Sim/Weapons/WeaponLoader.h" +#include "System/EventBatchHandler.h" #include "System/EventHandler.h" #include "System/Log/ILog.h" #include "System/Matrix44f.h" #include "System/myMath.h" #include "System/creg/STL_List.h" -#include "System/Sound/SoundChannels.h" +#include "System/Sound/ISoundChannels.h" #include "System/Sync/SyncedPrimitive.h" #include "System/Sync/SyncTracer.h" -#define PLAY_SOUNDS 1 - // See end of source for member bindings ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -157,7 +153,6 @@ lastMuzzleFlameSize(0.0f), armorType(0), category(0), - tempNum(0), mapSquare(-1), losRadius(0), airLosRadius(0), @@ -202,6 +197,7 @@ buildTime(100.0f), metalStorage(0.0f), energyStorage(0.0f), + harvestStorage(0.0f), lastAttackedPieceFrame(-1), lastAttackFrame(-200), lastFireWeapon(0), @@ -247,7 +243,6 @@ stunned(false) { - GML::GetTicks(lastUnitUpdate); } CUnit::~CUnit() @@ -369,7 +364,7 @@ if (collisionVolume->DefaultToFootPrint()) collisionVolume->InitBox(float3(xsize * SQUARE_SIZE, model->height, zsize * SQUARE_SIZE)); - mapSquare = ground->GetSquare((params.pos).cClampInMap()); + mapSquare = CGround::GetSquare((params.pos).cClampInMap()); heading = GetHeadingFromFacing(buildFacing); frontdir = GetVectorFromHeading(heading); @@ -487,7 +482,7 @@ UpdatePosErrorParams(true, true); if (unitDef->floatOnWater && IsInWater()) { - Move(UpVector * (std::max(ground->GetHeightReal(pos.x, pos.z), -unitDef->waterline) - pos.y), true); + Move(UpVector * (std::max(CGround::GetHeightReal(pos.x, pos.z), -unitDef->waterline) - pos.y), true); } if (unitDef->canmove || unitDef->builder) { @@ -553,37 +548,6 @@ } -void CUnit::ForcedSpin(const float3& newDir) -{ - assert(math::fabsf(newDir.SqLength() - 1.0f) <= float3::NORMALIZE_EPS); - - updir = UpVector; - if (updir == newDir) { - //FIXME perhaps save the old right,up,front directions, so we can - // reconstruct the old upvector and generate a better assumption for updir - updir -= GetVectorFromHeading(heading); - } - frontdir = newDir; - rightdir = newDir.cross(updir).Normalize(); - updir = rightdir.cross(newDir); - heading = GetHeadingFromVector(newDir.x, newDir.z); - - UpdateMidAndAimPos(); - ForcedMove(pos); -} - - - -// NOTE: movetypes call this directly -void CUnit::UpdateDirVectors(bool useGroundNormal) -{ - updir = GetWantedUpDir(useGroundNormal); - frontdir = GetVectorFromHeading(heading); - rightdir = (frontdir.cross(updir)).Normalize(); - frontdir = updir.cross(rightdir); -} - - float3 CUnit::GetErrorVector(int allyteam) const { @@ -1006,40 +970,41 @@ haveTarget = false; - if (!dontFire) { - for (vector::iterator wi = weapons.begin(); wi != weapons.end(); ++wi) { - CWeapon* w = *wi; - - w->SlowUpdate(); - - // NOTE: - // pass w->haveUserTarget so we do not interfere with - // user targets; w->haveUserTarget can only be true if - // either 1) ::AttackUnit was called with a (non-NULL) - // target-unit which the CAI did *not* auto-select, or - // 2) ::AttackGround was called with any user-selected - // position and all checks succeeded - if (haveManualFireRequest == (unitDef->canManualFire && w->weaponDef->manualfire)) { - if (attackTarget != NULL) { - w->AttackUnit(attackTarget, w->haveUserTarget); - } else if (userAttackGround) { - // this implies a user-order - w->AttackGround(attackPos, true); - } - } + if (dontFire) + return; + + for (vector::iterator wi = weapons.begin(); wi != weapons.end(); ++wi) { + CWeapon* w = *wi; - if (lastAttacker == NULL) - continue; - if ((lastAttackFrame + 200) <= gs->frameNum) - continue; - if (w->targetType != Target_None) - continue; - if (fireState == FIRESTATE_HOLDFIRE) - continue; + w->SlowUpdate(); - // return fire at our last attacker if allowed - w->AttackUnit(lastAttacker, false); + // NOTE: + // pass w->haveUserTarget so we do not interfere with + // user targets; w->haveUserTarget can only be true if + // either 1) ::AttackUnit was called with a (non-NULL) + // target-unit which the CAI did *not* auto-select, or + // 2) ::AttackGround was called with any user-selected + // position and all checks succeeded + if (haveManualFireRequest == (unitDef->canManualFire && w->weaponDef->manualfire)) { + if (attackTarget != NULL) { + w->AttackUnit(attackTarget, w->haveUserTarget); + } else if (userAttackGround) { + // this implies a user-order + w->AttackGround(attackPos, true); + } } + + if (lastAttacker == NULL) + continue; + if ((lastAttackFrame + 200) <= gs->frameNum) + continue; + if (w->targetType != Target_None) + continue; + if (fireState == FIRESTATE_HOLDFIRE) + continue; + + // return fire at our last attacker if allowed + w->AttackUnit(lastAttacker, false); } } @@ -1141,8 +1106,8 @@ restTime = 0; // bleeding != resting } - if (luaRules != NULL) { - luaRules->UnitPreDamaged(this, attacker, baseDamage, weaponDefID, projectileID, isParalyzer, &baseDamage, &impulseMult); + if (eventHandler.UnitPreDamaged(this, attacker, baseDamage, weaponDefID, projectileID, isParalyzer, &baseDamage, &impulseMult)) { + return; } script->HitByWeapon(-(float3(impulse * impulseMult)).SafeNormalize2D(), weaponDefID, /*inout*/ baseDamage); @@ -1177,17 +1142,14 @@ const float baseHealth = (modInfo.paralyzeOnMaxHealth? maxHealth: health); const float paralysisDecayRate = baseHealth * CUnit::empDecline; const float sumParalysisDamage = paralysisDecayRate * damages.paralyzeDamageTime; - const float maxParalysisDamage = baseHealth + sumParalysisDamage - paralyzeDamage; + const float maxParalysisDamage = std::max(baseHealth + sumParalysisDamage - paralyzeDamage, 0.0f); if (baseDamage > 0.0f) { // clamp the dealt paralysis-damage to [0, maxParalysisDamage] baseDamage = Clamp(baseDamage, 0.0f, maxParalysisDamage); - if (IsStunned()) { - // no attacker gains experience from a stunned target - experienceMod = 0.0f; - } - + // no attacker gains experience from a stunned target + experienceMod *= (1 - IsStunned()); // increase the current level of paralysis-damage paralyzeDamage += baseDamage; @@ -1195,11 +1157,8 @@ SetStunned(true); } } else { - if (paralyzeDamage <= 0.0f) { - // no experience from healing a non-stunned target - experienceMod = 0.0f; - } - + // no experience from healing a non-stunned target + experienceMod *= (paralyzeDamage > 0.0f); // decrease ("heal") the current level of paralysis-damage paralyzeDamage += baseDamage; paralyzeDamage = std::max(paralyzeDamage, 0.0f); @@ -1256,7 +1215,7 @@ return; } - const float3& groundNormal = ground->GetNormal(pos.x, pos.z); + const float3& groundNormal = CGround::GetNormal(pos.x, pos.z); const float groundImpulseScale = std::min(0.0f, impulse.dot(groundNormal)); const float3 modImpulse = impulse - (groundNormal * groundImpulseScale * IsOnGround()); @@ -1315,6 +1274,10 @@ void CUnit::AddExperience(float exp) { + if (exp == 0.0f) + return; + + assert(exp > 0.0f); const float oldExp = experience; experience += exp; @@ -1389,7 +1352,7 @@ if (unitHandler->unitsByDefs[newteam][unitDef->id].size() >= unitDef->maxThisUnit) return false; - if (luaRules && !luaRules->AllowUnitTransfer(this, newteam, type == ChangeCaptured)) + if (!eventHandler.AllowUnitTransfer(this, newteam, type == ChangeCaptured)) return false; // do not allow old player to keep controlling the unit @@ -1708,7 +1671,7 @@ return; } - const float height = ground->GetApproximateHeight(pos.x, pos.z); + const float height = CGround::GetApproximateHeight(pos.x, pos.z); // water if (height < -5.0f) { @@ -1731,8 +1694,6 @@ bool CUnit::SetGroup(CGroup* newGroup, bool fromFactory) { - GML_RECMUTEX_LOCK(grpsel); // SetGroup - // factory is not necessarily selected if (fromFactory && !selectedUnitsHandler.AutoAddBuiltUnitsToFactoryGroup()) return false; @@ -1779,36 +1740,34 @@ const float metalCostStep = metalCost * step; const float energyCostStep = energyCost * step; - const bool buildAllowed = (luaRules == NULL || luaRules->AllowUnitBuildStep(builder, this, step)); - const bool canExecBuild = (builderTeam->metal >= metalCostStep && builderTeam->energy >= energyCostStep); - - if (buildAllowed && canExecBuild) { - if (builder->UseMetal(metalCostStep)) { - // FIXME AllowUnitBuildStep may have changed the storages!!! so the checks can be invalid! - // TODO add a builder->UseResources(SResources(metalCostStep, energyCostStep)) - // - if (builder->UseEnergy(energyCostStep)) { - health += (maxHealth * step); - health = std::min(health, maxHealth); - buildProgress += step; - - if (buildProgress >= 1.0f) { - FinishedBuilding(false); - } - } else { - // refund already-deducted metal if *energy* cost cannot be - builder->UseMetal(-metalCostStep); - } - } - - return true; - } else { + if (builderTeam->metal < metalCostStep || builderTeam->energy < energyCostStep) { // update the energy and metal required counts builderTeam->metalPull += metalCostStep; builderTeam->energyPull += energyCostStep; + return false; } - return false; + if (!eventHandler.AllowUnitBuildStep(builder, this, step)) + return false; + + if (builder->UseMetal(metalCostStep)) { + // FIXME eventHandler.AllowUnitBuildStep() may have changed the storages!!! so the checks can be invalid! + // TODO add a builder->UseResources(SResources(metalCostStep, energyCostStep)) + if (builder->UseEnergy(energyCostStep)) { + health += (maxHealth * step); + health = std::min(health, maxHealth); + buildProgress += step; + + if (buildProgress >= 1.0f) { + FinishedBuilding(false); + } + } else { + // refund already-deducted metal if *energy* cost cannot be + builder->UseMetal(-metalCostStep); + } + } + + return true; } else if (health < maxHealth) { // repair @@ -1816,7 +1775,13 @@ const float energyUse = (energyCost * step); const float energyUseScaled = energyUse * modInfo.repairEnergyCostFactor; - if (luaRules != NULL && !luaRules->AllowUnitBuildStep(builder, this, step)) + if ((builderTeam->energy < energyUseScaled)) { + // update the energy and metal required counts + builderTeam->energyPull += energyUseScaled; + return false; + } + + if (!eventHandler.AllowUnitBuildStep(builder, this, step)) return false; if (!builder->UseEnergy(energyUseScaled)) { @@ -1838,11 +1803,16 @@ const float step = std::max(amount / buildTime, -buildProgress); const float energyRefundStep = energyCost * step; - const float metalRefundStep = metalCost * step; - const float metalRefundStepScaled = metalRefundStep * modInfo.reclaimUnitEfficiency; + const float metalRefundStep = metalCost * step; + const float metalRefundStepScaled = metalRefundStep * modInfo.reclaimUnitEfficiency; const float energyRefundStepScaled = energyRefundStep * modInfo.reclaimUnitEnergyCostFactor; - if (luaRules != NULL && !luaRules->AllowUnitBuildStep(builder, this, step)) + if (builderTeam->energy < -energyRefundStepScaled) { + builderTeam->energyPull += -energyRefundStepScaled; + return false; + } + + if (!eventHandler.AllowUnitBuildStep(builder, this, step)) return false; restTime = 0; @@ -1863,35 +1833,22 @@ if (modInfo.reclaimUnitMethod == 0) { // gradual reclamation of invested metal - builder->AddMetal(-metalRefundStepScaled, false); + if (!builder->AddHarvestedMetal(-metalRefundStepScaled)) { + eventHandler.UnitHarvestStorageFull(this); + return false; + } // turn reclaimee into nanoframe (even living units) beingBuilt = true; } else { // lump reclamation of invested metal - // NOTE: - // because the nanoframe is also decaying on its OWN - // (which reduces buildProgress and returns resources) - // *while* we are reclaiming it, the final lump has to - // subtract the amount already returned through decay - // - // this also means that in lump-reclaim mode only health - // is reduced since we need buildProgress to calculate a - // proper refund if (buildProgress <= 0.0f || health <= 0.0f) { - builder->AddMetal((metalCost * buildProgress) * modInfo.reclaimUnitEfficiency, false); + builder->AddHarvestedMetal((metalCost * buildProgress) * modInfo.reclaimUnitEfficiency); } } - if (beingBuilt) { - if (buildProgress <= 0.0f || health <= 0.0f) { - KillUnit(NULL, false, true); - return false; - } - } else { - if (health <= 0.0f) { - KillUnit(NULL, false, true); - return false; - } + if (buildProgress <= 0.0f || health <= 0.0f) { + KillUnit(NULL, false, true); + return false; } return true; @@ -1957,10 +1914,12 @@ isDead = true; deathSpeed = speed; + // TODO: add UnitPreDestroyed, call these later eventHandler.UnitDestroyed(this, attacker); eoh->UnitDestroyed(*this, attacker); + // Will be called in the destructor again, but this can not hurt - this->SetGroup(NULL); + SetGroup(NULL); blockHeightChanges = false; @@ -2087,6 +2046,22 @@ } +bool CUnit::AddHarvestedMetal(float metal) +{ + if (unitDef->harvestStorage <= 0.0f) { + AddMetal(metal, false); + return true; + } + + if (harvestStorage >= unitDef->harvestStorage) + return false; + + //FIXME what do with exceeding metal? + harvestStorage = std::min(harvestStorage + metal, unitDef->harvestStorage); + return true; +} + + void CUnit::Activate() { @@ -2102,11 +2077,9 @@ radarHandler->MoveUnit(this); - #if (PLAY_SOUNDS == 1) if (losStatus[gu->myAllyTeam] & LOS_INLOS) { - Channels::General.PlayRandomSample(unitDef->sounds.activate, this); + Channels::General->PlayRandomSample(unitDef->sounds.activate, this); } - #endif } void CUnit::Deactivate() @@ -2123,11 +2096,9 @@ radarHandler->RemoveUnit(this); - #if (PLAY_SOUNDS == 1) if (losStatus[gu->myAllyTeam] & LOS_INLOS) { - Channels::General.PlayRandomSample(unitDef->sounds.deactivate, this); + Channels::General->PlayRandomSample(unitDef->sounds.deactivate, this); } - #endif } @@ -2143,28 +2114,33 @@ void CUnit::IncomingMissile(CMissileProjectile* missile) { - if (unitDef->canDropFlare) { - incomingMissiles.push_back(missile); - AddDeathDependence(missile, DEPENDENCE_INCOMING); + if (!unitDef->canDropFlare) + return; - if (lastFlareDrop < (gs->frameNum - unitDef->flareReloadTime * 30)) { - new CFlareProjectile(pos, speed, this, (int) (gs->frameNum + unitDef->flareDelay * (1 + gs->randFloat()) * 15)); - lastFlareDrop = gs->frameNum; - } - } + incomingMissiles.push_back(missile); + AddDeathDependence(missile, DEPENDENCE_INCOMING); + + if (lastFlareDrop >= (gs->frameNum - unitDef->flareReloadTime * GAME_SPEED)) + return; + + new CFlareProjectile(pos, speed, this, (int) (gs->frameNum + unitDef->flareDelay * (1 + gs->randFloat()) * 15)); + lastFlareDrop = gs->frameNum; } -void CUnit::TempHoldFire() +void CUnit::TempHoldFire(int cmdID) { + if (weapons.empty()) + return; + if (!eventHandler.AllowBuilderHoldFire(this, cmdID)) + return; + + // block the SlowUpdateWeapons cycle dontFire = true; - AttackUnit(NULL, false, false); -} -void CUnit::ReleaseTempHoldFire() -{ - dontFire = false; + // clear current target (if any) + AttackUnit(NULL, false, false); } @@ -2279,13 +2255,7 @@ } } -#ifdef USE_GML - #define LOD_MUTEX CR_MEMBER_UN(lodmutex), -#else - #define LOD_MUTEX -#endif - -CR_BIND_DERIVED(CUnit, CSolidObject, ); +CR_BIND_DERIVED(CUnit, CSolidObject, ) CR_REG_METADATA(CUnit, ( CR_MEMBER(unitDef), CR_MEMBER(unitDefID), @@ -2355,8 +2325,6 @@ CR_MEMBER(quads), CR_MEMBER(los), - CR_MEMBER(tempNum), - CR_MEMBER(mapSquare), CR_MEMBER(losRadius), @@ -2422,6 +2390,7 @@ CR_MEMBER(metalStorage), CR_MEMBER(energyStorage), + CR_MEMBER(harvestStorage), CR_MEMBER(lastAttacker), CR_MEMBER(lastAttackedPiece), @@ -2494,8 +2463,6 @@ CR_MEMBER_UN(lastDrawFrame), CR_MEMBER(lastUnitUpdate), - LOD_MUTEX - CR_MEMBER_UN(tooltip), CR_MEMBER(stunned), @@ -2512,4 +2479,4 @@ // CR_MEMBER(model), CR_POSTLOAD(PostLoad) -)); +)) diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/UnitDef.cpp spring-98.0~14.04~ppa6/rts/Sim/Units/UnitDef.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Units/UnitDef.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/UnitDef.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -81,6 +81,7 @@ , tidalGenerator(0.0f) , metalStorage(0.0f) , energyStorage(0.0f) + , harvestStorage(0.0f) , autoHeal(0.0f) , idleAutoHeal(0.0f) , idleTime(0) @@ -269,6 +270,7 @@ metalStorage = udTable.GetFloat("metalStorage", 0.0f); energyStorage = udTable.GetFloat("energyStorage", 0.0f); + harvestStorage = udTable.GetFloat("harvestStorage", 0.0f); extractsMetal = udTable.GetFloat("extractsMetal", 0.0f); windGenerator = udTable.GetFloat("windGenerator", 0.0f); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/UnitDef.h spring-98.0~14.04~ppa6/rts/Sim/Units/UnitDef.h --- spring-96.0~14.04~ppa4/rts/Sim/Units/UnitDef.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/UnitDef.h 2014-10-07 20:09:51.000000000 +0000 @@ -62,8 +62,8 @@ bool IsExtractorUnit() const { return (extractsMetal > 0.0f && extractRange > 0.0f); } bool IsGroundUnit() const { return (pathType != -1U && !canfly); } bool IsAirUnit() const { return (pathType == -1U && canfly); } - bool IsStrafingAirUnit() const { return (IsAirUnit() && !hoverAttack); } - bool IsHoveringAirUnit() const { return (IsAirUnit() && hoverAttack); } + bool IsStrafingAirUnit() const { return (IsAirUnit() && !(IsBuilderUnit() || IsTransportUnit() || hoverAttack)); } + bool IsHoveringAirUnit() const { return (IsAirUnit() && (IsBuilderUnit() || IsTransportUnit() || hoverAttack)); } bool IsFighterAirUnit() const { return (IsStrafingAirUnit() && !weapons.empty() && !HasBomberWeapon()); } bool IsBomberAirUnit() const { return (IsStrafingAirUnit() && !weapons.empty() && HasBomberWeapon()); } @@ -104,6 +104,7 @@ float tidalGenerator; float metalStorage; float energyStorage; + float harvestStorage; float autoHeal; ///< amount autohealed float idleAutoHeal; ///< amount autohealed only during idling diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/UnitDefHandler.cpp spring-98.0~14.04~ppa6/rts/Sim/Units/UnitDefHandler.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Units/UnitDefHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/UnitDefHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -92,7 +92,8 @@ // force-initialize the real* members newDef->SetNoCost(true); newDef->SetNoCost(noCost); - } catch (const content_error&) { + } catch (const content_error& err) { + LOG_L(L_ERROR, "%s", err.what()); delete newDef; return 0; } @@ -291,7 +292,7 @@ !LoadBuildPic("unitpics/" + unitDef->name + ".png", bitmap) && !LoadBuildPic("unitpics/" + unitDef->name + ".pcx", bitmap) && !LoadBuildPic("unitpics/" + unitDef->name + ".bmp", bitmap)) { - bitmap.Alloc(1, 1); // last resort + bitmap.AllocDummy(SColor(255, 0, 0, 255)); } } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/UnitDefImage.h spring-98.0~14.04~ppa6/rts/Sim/Units/UnitDefImage.h --- spring-96.0~14.04~ppa4/rts/Sim/Units/UnitDefImage.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/UnitDefImage.h 2014-10-07 20:09:51.000000000 +0000 @@ -8,7 +8,7 @@ struct UnitDefImage { - CR_DECLARE_STRUCT(UnitDefImage); + CR_DECLARE_STRUCT(UnitDefImage) UnitDefImage(): imageSizeX(-1), imageSizeY(-1), textureID(0) { } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/Unit.h spring-98.0~14.04~ppa6/rts/Sim/Units/Unit.h --- spring-96.0~14.04~ppa4/rts/Sim/Units/Unit.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/Unit.h 2014-10-07 20:09:51.000000000 +0000 @@ -3,11 +3,6 @@ #ifndef UNIT_H #define UNIT_H -#include "lib/gml/gml_base.h" // for GML_ENABLE_SIM -#ifdef USE_GML - #include -#endif - #include #include #include @@ -105,7 +100,6 @@ void Deactivate(); void ForcedMove(const float3& newPos); - void ForcedSpin(const float3& newDir); void EnableScriptMoveType(); void DisableScriptMoveType(); @@ -135,6 +129,8 @@ void AddMetal(float metal, bool useIncomeMultiplier = true); bool UseEnergy(float energy); void AddEnergy(float energy, bool useIncomeMultiplier = true); + bool AddHarvestedMetal(float metal); + /// push the new wind to the script void UpdateWind(float x, float z, float strength); void SetMetalStorage(float newStorage); @@ -147,7 +143,6 @@ void CalculateTerrainType(); void UpdateTerrainType(); void UpdatePhysicalState(float eps); - void UpdateDirVectors(bool useGroundNormal); float3 GetErrorVector(int allyteam) const; float3 GetErrorPos(int allyteam, bool aiming = false) const { return (aiming? aimPos: midPos) + GetErrorVector(allyteam); } @@ -180,17 +175,16 @@ void SetTransporter(CTransportUnit* trans) { transporter = trans; } inline CTransportUnit* GetTransporter() const { - // In MT transporter may suddenly be changed to NULL by sim - if (GML::SimEnabled()) - return (*(CTransportUnit* volatile*) &transporter); return transporter; } public: virtual void KillUnit(CUnit* attacker, bool selfDestruct, bool reclaimed, bool showDeathSequence = true); virtual void IncomingMissile(CMissileProjectile* missile); - void TempHoldFire(); - void ReleaseTempHoldFire(); + + void TempHoldFire(int cmdID); + void ReleaseTempHoldFire() { dontFire = false; } + /// start this unit in free fall from parent unit void Drop(const float3& parentPos, const float3& parentDir, CUnit* parent); void PostLoad(); @@ -203,15 +197,22 @@ public: static void SetExpMultiplier(float value) { expMultiplier = value; } - static float GetExpMultiplier() { return expMultiplier; } static void SetExpPowerScale(float value) { expPowerScale = value; } - static float GetExpPowerScale() { return expPowerScale; } static void SetExpHealthScale(float value) { expHealthScale = value; } - static float GetExpHealthScale() { return expHealthScale; } static void SetExpReloadScale(float value) { expReloadScale = value; } - static float GetExpReloadScale() { return expReloadScale; } static void SetExpGrade(float value) { expGrade = value; } - static float GetExpGrade() { return expGrade; } + + static float GetExpMultiplier() { return expMultiplier; } + static float GetExpPowerScale() { return expPowerScale; } + static float GetExpHealthScale() { return expHealthScale; } + static float GetExpReloadScale() { return expReloadScale; } + static float GetExpGrade() { return expGrade; } + + static float ExperienceScale(const float limExperience, const float experienceWeight) { + // limExperience ranges from 0.0 to 0.9999..., experienceWeight + // should be in [0, 1] and have no effect on accuracy when zero + return (1.0f - (limExperience * experienceWeight)); + } static void SetSpawnFeature(bool b) { spawnFeature = b; } @@ -347,9 +348,9 @@ /// tells weapons that support it to try to use a high trajectory bool useHighTrajectory; - /// used by landed gunships to block weapon updates + /// used by landed gunships to block weapon Update()'s bool dontUseWeapons; - /// temp variable that can be set when building etc to stop units to turn away to fire + /// used by builders to prevent weapon SlowUpdate()'s and Attack{Unit,Ground}()'s bool dontFire; /// the script has finished exectuting the killed function and the unit can be deleted @@ -375,9 +376,6 @@ /// what categories the unit is part of (bitfield) unsigned int category; - /// used to see if something has operated on the unit before - int tempNum; - int mapSquare; int losRadius; @@ -440,6 +438,8 @@ float metalStorage; float energyStorage; + /// per unit metal storage (gets filled on reclaim and needs then to be unloaded at some storage building -> 2nd part is lua's job) + float harvestStorage; /// frame in which lastAttackedPiece was hit int lastAttackedPieceFrame; @@ -530,10 +530,6 @@ int lastDrawFrame; unsigned int lastUnitUpdate; -#ifdef USE_GML - boost::recursive_mutex lodmutex; -#endif - std::string tooltip; private: diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/UnitHandler.cpp spring-98.0~14.04~ppa6/rts/Sim/Units/UnitHandler.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Units/UnitHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/UnitHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,8 +2,6 @@ #include -#include "lib/gml/gmlmut.h" -#include "lib/gml/gml_base.h" #include "UnitHandler.h" #include "Unit.h" #include "UnitDefHandler.h" @@ -29,7 +27,7 @@ CUnitHandler* unitHandler = NULL; -CR_BIND(CUnitHandler, ); +CR_BIND(CUnitHandler, ) CR_REG_METADATA(CUnitHandler, ( CR_MEMBER(units), CR_MEMBER(unitsByDefs), @@ -40,7 +38,7 @@ CR_MEMBER(maxUnits), CR_MEMBER(maxUnitRadius), CR_POSTLOAD(PostLoad) -)); +)) @@ -150,8 +148,6 @@ delTeam = delUnit->team; delType = delUnit->unitDef->id; - GML_STDMUTEX_LOCK(dque); // DeleteUnitNow - teamHandler->Team(delTeam)->RemoveUnit(delUnit, CTeam::RemoveDied); activeUnits.erase(usi); @@ -184,22 +180,12 @@ void CUnitHandler::Update() { { - GML_STDMUTEX_LOCK(runit); // Update - if (!unitsToBeRemoved.empty()) { - GML_RECMUTEX_LOCK(obj); // Update - while (!unitsToBeRemoved.empty()) { eventHandler.DeleteSyncedObjects(); // the unit destructor may invoke eventHandler, so we need to call these for every unit to clear invaild references from the batching systems - GML_RECMUTEX_LOCK(unit); // Update - eventHandler.DeleteSyncedUnits(); - GML_RECMUTEX_LOCK(proj); // Update - projectile drawing may access owner() and lead to crash - GML_RECMUTEX_LOCK(sel); // Update - unit is removed from selectedUnits in ~CObject, which is too late. - GML_RECMUTEX_LOCK(quad); // Update - make sure unit does not get partially deleted before before being removed from the quadfield - CUnit* delUnit = unitsToBeRemoved.back(); unitsToBeRemoved.pop_back(); @@ -210,8 +196,6 @@ eventHandler.UpdateUnits(); } - GML::UpdateTicks(); - #define MAPPOS_SANITY_CHECK(unit) \ if (unit->unitDef->IsGroundUnit()) { \ assert(unit->pos.x >= -(float3::maxxpos * 16.0f)); \ @@ -232,8 +216,8 @@ { SCOPED_TIMER("Unit::MoveType::Update"); - std::list::iterator usi; - for (usi = activeUnits.begin(); usi != activeUnits.end(); ++usi) { + + for (auto usi = activeUnits.begin(); usi != activeUnits.end(); ++usi) { CUnit* unit = *usi; AMoveType* moveType = unit->moveType; @@ -249,15 +233,14 @@ } UNIT_SANITY_CHECK(unit); - GML::GetTicks(unit->lastUnitUpdate); } } { // Delete dead units - std::list::iterator usi; - for (usi = activeUnits.begin(); usi != activeUnits.end(); ++usi) { + for (auto usi = activeUnits.begin(); usi != activeUnits.end(); ++usi) { CUnit* unit = *usi; + if (unit->deathScriptFinished) { // there are many ways to fiddle with "deathScriptFinished", so a unit may // arrive here without having been properly killed (and isDead still false), @@ -271,8 +254,8 @@ { SCOPED_TIMER("Unit::UpdatePieceMatrices"); - std::list::iterator usi; - for (usi = activeUnits.begin(); usi != activeUnits.end(); ++usi) { + + for (auto usi = activeUnits.begin(); usi != activeUnits.end(); ++usi) { // UnitScript only applies piece-space transforms so // we apply the forward kinematics update separately // (only if we have any dirty pieces) @@ -283,8 +266,8 @@ { SCOPED_TIMER("Unit::Update"); - std::list::iterator usi; - for (usi = activeUnits.begin(); usi != activeUnits.end(); ++usi) { + + for (auto usi = activeUnits.begin(); usi != activeUnits.end(); ++usi) { CUnit* unit = *usi; UNIT_SANITY_CHECK(unit); unit->Update(); @@ -301,7 +284,7 @@ } // stagger the SlowUpdate's - int n = (activeUnits.size() / UNIT_SLOWUPDATE_RATE) + 1; + unsigned int n = (activeUnits.size() / UNIT_SLOWUPDATE_RATE) + 1; for (; activeSlowUpdateUnit != activeUnits.end() && n != 0; ++activeSlowUpdateUnit) { CUnit* unit = *activeSlowUpdateUnit; @@ -319,16 +302,12 @@ void CUnitHandler::AddBuilderCAI(CBuilderCAI* b) { - GML_STDMUTEX_LOCK(cai); // AddBuilderCAI - // called from CBuilderCAI --> owner is already valid builderCAIs[b->owner->id] = b; } void CUnitHandler::RemoveBuilderCAI(CBuilderCAI* b) { - GML_STDMUTEX_LOCK(cai); // RemoveBuilderCAI - // called from ~CUnit --> owner is still valid assert(b->owner != NULL); builderCAIs.erase(b->owner->id); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/UnitLoader.cpp spring-98.0~14.04~ppa6/rts/Sim/Units/UnitLoader.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Units/UnitLoader.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/UnitLoader.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -60,9 +60,6 @@ UnitLoadParams& params = const_cast(cparams); { - GML_RECMUTEX_LOCK(sel); // LoadUnit - for anti deadlock purposes. - GML_RECMUTEX_LOCK(quad); // LoadUnit - make sure other threads cannot access an incomplete unit - const UnitDef* ud = params.unitDef; if (ud == NULL) @@ -211,19 +208,20 @@ const int sqSize = math::ceil(math::sqrt((float) numRequestedUnits)); const float sqHalfMapSize = sqSize / 2 * 10 * SQUARE_SIZE; - pos.x = std::max(sqHalfMapSize, std::min(pos.x, float3::maxxpos - sqHalfMapSize - 1)); - pos.z = std::max(sqHalfMapSize, std::min(pos.z, float3::maxzpos - sqHalfMapSize - 1)); + pos.x = Clamp(pos.x, sqHalfMapSize, float3::maxxpos - sqHalfMapSize - 1); + pos.z = Clamp(pos.z, sqHalfMapSize, float3::maxzpos - sqHalfMapSize - 1); for (int a = 1; a <= numRequestedUnits; ++a) { Watchdog::ClearPrimaryTimers(); // the other thread may be waiting for a mutex held by this one, triggering hang detection const float px = pos.x + (a % sqSize - sqSize / 2) * 10 * SQUARE_SIZE; const float pz = pos.z + (a / sqSize - sqSize / 2) * 10 * SQUARE_SIZE; + const UnitDef* ud = unitDefHandler->GetUnitDefByID(a); const UnitLoadParams unitParams = { - unitDefHandler->GetUnitDefByID(a), + ud, NULL, - float3(px, ground->GetHeightReal(px, pz), pz), + float3(px, CGround::GetHeightReal(px, pz), pz), ZeroVector, -1, @@ -284,7 +282,7 @@ unitDef, NULL, - float3(px, ground->GetHeightReal(px, pz), pz), + float3(px, CGround::GetHeightReal(px, pz), pz), ZeroVector, -1, @@ -323,7 +321,7 @@ for (int x = 0; x < squareSize && total > 0; ++x) { const float px = squarePos.x + x * xsize * SQUARE_SIZE; const float pz = squarePos.z + z * zsize * SQUARE_SIZE; - const float3 featurePos = float3(px, ground->GetHeightReal(px, pz), pz); + const float3 featurePos = float3(px, CGround::GetHeightReal(px, pz), pz); Watchdog::ClearPrimaryTimers(); FeatureLoadParams params = { @@ -360,10 +358,11 @@ void CUnitLoader::FlattenGround(const CUnit* unit) { const UnitDef* unitDef = unit->unitDef; - const float groundheight = ground->GetHeightReal(unit->pos.x, unit->pos.z); + const float groundheight = CGround::GetHeightReal(unit->pos.x, unit->pos.z); if (mapDamage->disabled) return; if (!unitDef->levelGround) return; + if (unitDef->IsAirUnit()) return; if (!unitDef->IsImmobileUnit()) return; if (unitDef->floatOnWater && groundheight <= 0.0f) return; @@ -390,10 +389,11 @@ void CUnitLoader::RestoreGround(const CUnit* unit) { const UnitDef* unitDef = unit->unitDef; - const float groundheight = ground->GetHeightReal(unit->pos.x, unit->pos.z); + const float groundheight = CGround::GetHeightReal(unit->pos.x, unit->pos.z); if (mapDamage->disabled) return; if (!unitDef->levelGround) return; + if (unitDef->IsAirUnit()) return; if (!unitDef->IsImmobileUnit()) return; if (unitDef->floatOnWater && groundheight <= 0.0f) return; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/UnitTypes/Builder.cpp spring-98.0~14.04~ppa6/rts/Sim/Units/UnitTypes/Builder.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Units/UnitTypes/Builder.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/UnitTypes/Builder.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -6,7 +6,6 @@ #include "Building.h" #include "Game/GameHelper.h" #include "Game/GlobalUnsynced.h" -#include "Lua/LuaRules.h" #include "Map/Ground.h" #include "Map/MapDamage.h" #include "Map/ReadMap.h" @@ -26,14 +25,12 @@ #include "Sim/Units/UnitLoader.h" #include "System/EventHandler.h" #include "System/Log/ILog.h" -#include "System/Sound/SoundChannels.h" - -#define PLAY_SOUNDS 1 +#include "System/Sound/ISoundChannels.h" using std::min; using std::max; -CR_BIND_DERIVED(CBuilder, CUnit, ); +CR_BIND_DERIVED(CBuilder, CUnit, ) CR_REG_METADATA(CBuilder, ( CR_MEMBER(range3D), @@ -60,7 +57,7 @@ CR_ENUM_MEMBER(terraformType), CR_MEMBER(nanoPieceCache), CR_POSTLOAD(PostLoad) -)); +)) ////////////////////////////////////////////////////////////////////// @@ -199,7 +196,7 @@ mapDamage->RecalcArea(tx1, tx2, tz1, tz2); curBuild->groundLevelled = true; - if (luaRules && luaRules->TerraformComplete(this, curBuild)) { + if (eventHandler.TerraformComplete(this, curBuild)) { StopBuild(); } } @@ -373,7 +370,7 @@ // Corpse has been restored, begin resurrection const float step = resurrectSpeed / ud->buildTime; - const bool resurrectAllowed = (luaRules == NULL || luaRules->AllowFeatureBuildStep(this, curResurrect, step)); + const bool resurrectAllowed = eventHandler.AllowFeatureBuildStep(this, curResurrect, step); const bool canExecResurrect = (resurrectAllowed && UseEnergy(ud->energy * step * modInfo.resurrectEnergyCostFactor)); if (canExecResurrect) { @@ -457,7 +454,7 @@ const float captureFraction = captureProgressTemp - curCapture->captureProgress; const float energyUseScaled = curCapture->energyCost * captureFraction * modInfo.captureEnergyCostFactor; - const bool captureAllowed = (luaRules == NULL || luaRules->AllowUnitBuildStep(this, curCapture, captureProgressStep)); + const bool captureAllowed = (eventHandler.AllowUnitBuildStep(this, curCapture, captureProgressStep)); const bool canExecCapture = (captureAllowed && UseEnergy(energyUseScaled)); if (canExecCapture) { @@ -505,7 +502,7 @@ return; StopBuild(false); - TempHoldFire(); + TempHoldFire(CMD_REPAIR); curBuild = target; AddDeathDependence(curBuild, DEPENDENCE_BUILD); @@ -543,7 +540,7 @@ } StopBuild(false); - TempHoldFire(); + TempHoldFire(CMD_RECLAIM); reclaimingUnit = (recUnit != NULL); curReclaim = target; @@ -559,7 +556,7 @@ return; StopBuild(false); - TempHoldFire(); + TempHoldFire(CMD_RESURRECT); curResurrect = target; @@ -574,7 +571,7 @@ return; StopBuild(false); - TempHoldFire(); + TempHoldFire(CMD_CAPTURE); curCapture = target; @@ -586,7 +583,7 @@ void CBuilder::StartRestore(float3 centerPos, float radius) { StopBuild(false); - TempHoldFire(); + TempHoldFire(CMD_RESTORE); terraforming=true; terraformType=Terraform_Restore; @@ -644,6 +641,7 @@ bool CBuilder::StartBuild(BuildInfo& buildInfo, CFeature*& feature, bool& waitStance) { StopBuild(false); + TempHoldFire(-1); buildInfo.pos = CGameHelper::Pos2BuildPos(buildInfo, true); @@ -700,11 +698,12 @@ CUnit* buildee = unitLoader->LoadUnit(buildeeParams); // floating structures don't terraform the seabed - const float groundheight = ground->GetHeightReal(buildee->pos.x, buildee->pos.z); + const float groundheight = CGround::GetHeightReal(buildee->pos.x, buildee->pos.z); const bool onWater = (buildeeDef->floatOnWater && groundheight <= 0.0f); if (mapDamage->disabled || !buildeeDef->levelGround || onWater || - (buildeeDef->canmove && (buildeeDef->speed > 0.0f))) { + buildeeDef->IsAirUnit() || !buildeeDef->IsImmobileUnit() + ) { // skip the terraforming job buildee->terraformLeft = 0; buildee->groundLevelled = true; @@ -773,23 +772,23 @@ void CBuilder::DependentDied(CObject *o) { if (o == curBuild) { - curBuild = 0; + curBuild = nullptr; StopBuild(); } if (o == curReclaim) { - curReclaim = 0; + curReclaim = nullptr; StopBuild(); } if (o == helpTerraform) { - helpTerraform = 0; + helpTerraform = nullptr; StopBuild(); } if (o == curResurrect) { - curResurrect = 0; + curResurrect = nullptr; StopBuild(); } if (o == curCapture) { - curCapture = 0; + curCapture = nullptr; StopBuild(); } CUnit::DependentDied(o); @@ -810,11 +809,9 @@ script->StartBuilding(ClampRad(h - heading * TAANG2RAD), p - pitch); } - #if (PLAY_SOUNDS == 1) if ((!silent || inBuildStance) && losStatus[gu->myAllyTeam] & LOS_INLOS) { - Channels::General.PlayRandomSample(unitDef->sounds.build, pos); + Channels::General->PlayRandomSample(unitDef->sounds.build, pos); } - #endif return inBuildStance; } @@ -838,11 +835,6 @@ { const int modelNanoPiece = nanoPieceCache.GetNanoPiece(script); -#ifdef USE_GML - if (GML::Enabled() && ((gs->frameNum - lastDrawFrame) > 20)) - return; -#endif - if (localModel == NULL || !localModel->HasPiece(modelNanoPiece)) return; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/UnitTypes/Builder.h spring-98.0~14.04~ppa6/rts/Sim/Units/UnitTypes/Builder.h --- spring-96.0~14.04~ppa4/rts/Sim/Units/UnitTypes/Builder.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/UnitTypes/Builder.h 2014-10-07 20:09:51.000000000 +0000 @@ -32,9 +32,9 @@ inline float f3SqLen(const float3& a) const { return range3D ? a.SqLength() : a.SqLength2D(); } - + public: - CR_DECLARE(CBuilder); + CR_DECLARE(CBuilder) CBuilder(); virtual ~CBuilder(); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/UnitTypes/Building.cpp spring-98.0~14.04~ppa6/rts/Sim/Units/UnitTypes/Building.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Units/UnitTypes/Building.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/UnitTypes/Building.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -9,12 +9,12 @@ #include "Sim/Units/UnitLoader.h" #include "System/myMath.h" -CR_BIND_DERIVED(CBuilding, CUnit, ); +CR_BIND_DERIVED(CBuilding, CUnit, ) CR_REG_METADATA(CBuilding, ( CR_RESERVED(8), CR_POSTLOAD(PostLoad) -)); +)) ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -45,14 +45,16 @@ void CBuilding::ForcedMove(const float3& newPos) { + // heading might have changed if building was dropped from transport + // (always needs to be axis-aligned because yardmaps are not rotated) heading = GetHeadingFromFacing(buildFacing); - frontdir = GetVectorFromHeading(heading); + UpdateDirVectors(false); SetVelocity(ZeroVector); - Move(CGameHelper::Pos2BuildPos(BuildInfo(unitDef, newPos, buildFacing), true), false); - UpdateMidAndAimPos(); - CUnit::ForcedMove(pos); + // update quadfield, etc. + CUnit::ForcedMove(CGameHelper::Pos2BuildPos(BuildInfo(unitDef, newPos, buildFacing), true)); unitLoader->FlattenGround(this); } + diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/UnitTypes/Building.h spring-98.0~14.04~ppa6/rts/Sim/Units/UnitTypes/Building.h --- spring-96.0~14.04~ppa4/rts/Sim/Units/UnitTypes/Building.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/UnitTypes/Building.h 2014-10-07 20:09:51.000000000 +0000 @@ -11,7 +11,7 @@ class CBuilding : public CUnit { public: - CR_DECLARE(CBuilding); + CR_DECLARE(CBuilding) CBuilding(); virtual ~CBuilding() {} diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/UnitTypes/ExtractorBuilding.cpp spring-98.0~14.04~ppa6/rts/Sim/Units/UnitTypes/ExtractorBuilding.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Units/UnitTypes/ExtractorBuilding.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/UnitTypes/ExtractorBuilding.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -15,7 +15,7 @@ #include "System/creg/STL_List.h" #include "System/myMath.h" -CR_BIND_DERIVED(CExtractorBuilding, CBuilding, ); +CR_BIND_DERIVED(CExtractorBuilding, CBuilding, ) CR_REG_METADATA(CExtractorBuilding, ( CR_MEMBER(extractionRange), @@ -24,15 +24,15 @@ CR_MEMBER(neighbours), CR_RESERVED(16), CR_POSTLOAD(PostLoad) -)); +)) -CR_BIND(CExtractorBuilding::MetalSquareOfControl, ); +CR_BIND(CExtractorBuilding::MetalSquareOfControl, ) CR_REG_METADATA_SUB(CExtractorBuilding,MetalSquareOfControl, ( CR_MEMBER(x), CR_MEMBER(z), CR_MEMBER(extractionDepth) -)); +)) // TODO: How are class statics incorporated into creg? float CExtractorBuilding::maxExtractionRange = 0.0f; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/UnitTypes/ExtractorBuilding.h spring-98.0~14.04~ppa6/rts/Sim/Units/UnitTypes/ExtractorBuilding.h --- spring-96.0~14.04~ppa4/rts/Sim/Units/UnitTypes/ExtractorBuilding.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/UnitTypes/ExtractorBuilding.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,8 +7,8 @@ class CExtractorBuilding : public CBuilding { public: - CR_DECLARE(CExtractorBuilding); - CR_DECLARE_SUB(MetalSquareOfControl); + CR_DECLARE(CExtractorBuilding) + CR_DECLARE_SUB(MetalSquareOfControl) CExtractorBuilding(); virtual ~CExtractorBuilding(); @@ -28,7 +28,7 @@ protected: struct MetalSquareOfControl { - CR_DECLARE_STRUCT(MetalSquareOfControl); + CR_DECLARE_STRUCT(MetalSquareOfControl) int x; int z; float extractionDepth; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/UnitTypes/Factory.cpp spring-98.0~14.04~ppa6/rts/Sim/Units/UnitTypes/Factory.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Units/UnitTypes/Factory.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/UnitTypes/Factory.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -4,7 +4,6 @@ #include "Factory.h" #include "Game/GameHelper.h" #include "Game/WaitCommandsAI.h" -#include "Lua/LuaRules.h" #include "Map/Ground.h" #include "Map/ReadMap.h" #include "Sim/Misc/GroundBlockingObjectMap.h" @@ -21,15 +20,12 @@ #include "System/EventHandler.h" #include "System/Matrix44f.h" #include "System/myMath.h" -#include "System/Sound/SoundChannels.h" +#include "System/Sound/ISoundChannels.h" #include "System/Sync/SyncTracer.h" -#define PLAY_SOUNDS 1 -#if (PLAY_SOUNDS == 1) #include "Game/GlobalUnsynced.h" -#endif -CR_BIND_DERIVED(CFactory, CBuilding, ); +CR_BIND_DERIVED(CFactory, CBuilding, ) CR_REG_METADATA(CFactory, ( CR_MEMBER(buildSpeed), @@ -43,7 +39,7 @@ CR_MEMBER(finishedBuildCommand), CR_MEMBER(nanoPieceCache), CR_POSTLOAD(PostLoad) -)); +)) ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -207,11 +203,9 @@ curBuild = buildee; curBuildDef = NULL; - #if (PLAY_SOUNDS == 1) if (losStatus[gu->myAllyTeam] & LOS_INLOS) { - Channels::General.PlayRandomSample(unitDef->sounds.build, buildPos); + Channels::General->PlayRandomSample(unitDef->sounds.build, buildPos); } - #endif } void CFactory::UpdateBuild(CUnit* buildee) { @@ -256,8 +250,6 @@ if (unitDef->fullHealthFactory && buildee->health < buildee->maxHealth) { return; } { - GML_RECMUTEX_LOCK(group); // FinishBuild - if (group && buildee->group == 0) { buildee->SetGroup(group, true); } @@ -296,7 +288,7 @@ return FACTORY_SKIP_BUILD_ORDER; if (teamHandler->Team(team)->AtUnitLimit()) return FACTORY_KEEP_BUILD_ORDER; - if (luaRules && !luaRules->AllowUnitCreation(buildeeDef, this, NULL)) + if (!eventHandler.AllowUnitCreation(buildeeDef, this, NULL)) return FACTORY_SKIP_BUILD_ORDER; finishedBuildFunc = buildFunc; @@ -343,8 +335,9 @@ const float searchRadius = radius * 4.0f + unit->radius * 4.0f; const int numSteps = 36; + const float3 exitPos = pos + frontdir*(radius + unit->radius); float3 foundPos = pos + frontdir * searchRadius; - float3 tempPos = foundPos; + const float3 tempPos = foundPos; for (int x = 0; x < numSteps; ++x) { const float a = searchRadius * math::cos(x * PI / (numSteps * 0.5f)); @@ -352,7 +345,7 @@ float3 testPos = pos + frontdir * a + rightdir * b; - if (!testPos.IsInMap()) + if (!testPos.IsInBounds()) continue; // don't pick spots behind the factory (because // units will want to path through it when open @@ -360,7 +353,7 @@ if ((testPos - pos).dot(frontdir) < 0.0f) continue; - testPos.y = ground->GetHeightAboveWater(testPos.x, testPos.z); + testPos.y = CGround::GetHeightAboveWater(testPos.x, testPos.z); if (quadField->GetSolidsExact(testPos, unit->radius * 1.5f, 0xFFFFFFFF, CSolidObject::CSTATE_BIT_SOLIDOBJECTS).empty()) { foundPos = testPos; break; @@ -380,16 +373,15 @@ foundPos.x = pos.x + frontdir.x * a + rightdir.x * b; foundPos.z = pos.z + frontdir.z * a + rightdir.z * b; foundPos.y += 1.0f; - } while ((!foundPos.IsInMap() || (foundPos - pos).dot(frontdir) < 0.0f) && (foundPos.y < 100.0f)); + } while ((!foundPos.IsInBounds() || (foundPos - pos).dot(frontdir) < 0.0f) && (foundPos.y < 100.0f)); - foundPos.y = ground->GetHeightAboveWater(foundPos.x, foundPos.z); + foundPos.y = CGround::GetHeightAboveWater(foundPos.x, foundPos.z); } // first queue a temporary waypoint outside the factory // (otherwise units will try to turn before exiting when // foundPos lies behind exit and cause jams / get stuck) // we assume this temporary point is not itself blocked - // (redundant now foundPos always lies in front of us) // // NOTE: // MobileCAI::AutoGenerateTarget inserts a _third_ @@ -400,12 +392,12 @@ // (and should also be more than CMD_CANCEL_DIST // elmos distant from foundPos) // - // Command c0(CMD_MOVE, tempPos); - Command c1(CMD_MOVE, SHIFT_KEY | INTERNAL_ORDER, foundPos); - Command c2(CMD_MOVE, SHIFT_KEY, foundPos + frontdir * 20.0f); - // unit->commandAI->GiveCommand(c0); + if (!unit->unitDef->canfly && exitPos.IsInBounds()) { + Command c0(CMD_MOVE, SHIFT_KEY, exitPos); + unit->commandAI->GiveCommand(c0); + } + Command c1(CMD_MOVE, SHIFT_KEY, foundPos); unit->commandAI->GiveCommand(c1); - unit->commandAI->GiveCommand(c2); } void CFactory::AssignBuildeeOrders(CUnit* unit) { @@ -447,7 +439,7 @@ } } - c.PushPos(tmpPos); + c.PushPos(tmpPos.cClampInBounds()); } else { // dummy rallypoint for aircraft c.PushPos(unit->pos); @@ -490,11 +482,6 @@ { const int modelNanoPiece = nanoPieceCache.GetNanoPiece(script); -#ifdef USE_GML - if (GML::Enabled() && ((gs->frameNum - lastDrawFrame) > 20)) - return; -#endif - if (localModel == NULL || !localModel->HasPiece(modelNanoPiece)) return; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/UnitTypes/Factory.h spring-98.0~14.04~ppa6/rts/Sim/Units/UnitTypes/Factory.h --- spring-96.0~14.04~ppa4/rts/Sim/Units/UnitTypes/Factory.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/UnitTypes/Factory.h 2014-10-07 20:09:51.000000000 +0000 @@ -17,7 +17,7 @@ class CFactory : public CBuilding { public: - CR_DECLARE(CFactory); + CR_DECLARE(CFactory) CFactory(); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/UnitTypes/TransportUnit.cpp spring-98.0~14.04~ppa6/rts/Sim/Units/UnitTypes/TransportUnit.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Units/UnitTypes/TransportUnit.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/UnitTypes/TransportUnit.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -15,13 +15,14 @@ #include "Sim/Units/UnitTypes/Building.h" #include "Sim/Misc/DamageArray.h" #include "Sim/Misc/LosHandler.h" +#include "Sim/Misc/ModInfo.h" #include "Sim/Misc/TeamHandler.h" #include "Sim/Misc/QuadField.h" #include "System/EventHandler.h" #include "System/myMath.h" #include "System/creg/STL_List.h" -CR_BIND_DERIVED(CTransportUnit, CUnit, ); +CR_BIND_DERIVED(CTransportUnit, CUnit, ) CR_REG_METADATA(CTransportUnit, ( CR_MEMBER(transportedUnits), @@ -29,9 +30,9 @@ CR_MEMBER(transportMassUsed), CR_RESERVED(16), CR_POSTLOAD(PostLoad) -)); +)) -CR_BIND(CTransportUnit::TransportedUnit,); +CR_BIND(CTransportUnit::TransportedUnit,) CR_REG_METADATA_SUB(CTransportUnit,TransportedUnit,( CR_MEMBER(unit), @@ -39,7 +40,7 @@ CR_MEMBER(size), CR_MEMBER(mass), CR_RESERVED(8) -)); +)) @@ -154,7 +155,7 @@ // if this transporter uses the piece-underneath-ground // method to "hide" transportees, place transportee near // the transporter's place of death - if (transportee->pos.y < ground->GetHeightReal(transportee->pos.x, transportee->pos.z)) { + if (transportee->pos.y < CGround::GetHeightReal(transportee->pos.x, transportee->pos.z)) { const float r1 = transportee->radius + radius; const float r2 = r1 * std::max(unitDef->unloadSpread, 1.0f); @@ -164,7 +165,7 @@ float3 pos = transportee->pos; pos.x += (gs->randFloat() * 2.0f * r2 - r2); pos.z += (gs->randFloat() * 2.0f * r2 - r2); - pos.y = ground->GetHeightReal(pos.x, pos.z); + pos.y = CGround::GetHeightReal(pos.x, pos.z); if (!pos.IsInBounds()) continue; @@ -452,7 +453,7 @@ if (unit->GetTransporter() != NULL) { // if unit is being transported, set // to the altitude at which to UNload the transportee - wantedHeight = ground->GetHeightReal(wantedPos.x, wantedPos.z); + wantedHeight = CGround::GetHeightReal(wantedPos.x, wantedPos.z); isAllowedHeight = transporteeUnitDef->CheckTerrainConstraints(transporteeMoveDef, wantedHeight, &clampedHeight); if (isAllowedHeight) { diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Units/UnitTypes/TransportUnit.h spring-98.0~14.04~ppa6/rts/Sim/Units/UnitTypes/TransportUnit.h --- spring-96.0~14.04~ppa4/rts/Sim/Units/UnitTypes/TransportUnit.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Units/UnitTypes/TransportUnit.h 2014-10-07 20:09:51.000000000 +0000 @@ -9,11 +9,11 @@ class CTransportUnit : public CUnit { public: - CR_DECLARE(CTransportUnit); - CR_DECLARE_SUB(TransportedUnit); + CR_DECLARE(CTransportUnit) + CR_DECLARE_SUB(TransportedUnit) struct TransportedUnit { - CR_DECLARE_STRUCT(TransportedUnit); + CR_DECLARE_STRUCT(TransportedUnit) CUnit* unit; int piece; int size; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/BeamLaser.cpp spring-98.0~14.04~ppa6/rts/Sim/Weapons/BeamLaser.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/BeamLaser.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/BeamLaser.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -20,7 +20,7 @@ #define SWEEPFIRE_ENABLED 1 -CR_BIND_DERIVED(CBeamLaser, CWeapon, (NULL, NULL)); +CR_BIND_DERIVED(CBeamLaser, CWeapon, (NULL, NULL)) CR_REG_METADATA(CBeamLaser,( CR_MEMBER(color), @@ -28,7 +28,7 @@ CR_MEMBER(salvoDamageMult), CR_MEMBER(sweepFireState) -)); +)) CR_BIND(CBeamLaser::SweepFireState, ) CR_REG_METADATA_SUB(CBeamLaser, SweepFireState, ( @@ -43,7 +43,7 @@ CR_MEMBER(sweepCurrDst), CR_MEMBER(sweepStartAngle), CR_MEMBER(sweepFiring) -)); +)) @@ -79,10 +79,11 @@ -CBeamLaser::CBeamLaser(CUnit* owner, const WeaponDef* def): CWeapon(owner, def) +CBeamLaser::CBeamLaser(CUnit* owner, const WeaponDef* def) + : CWeapon(owner, def) + , color(def->visuals.color) + , salvoDamageMult(1.0f) { - color = def->visuals.color; - salvoDamageMult = 1.0f; sweepFireState.SetDamageAllies((collisionFlags & Collision::NOFRIENDLIES) == 0); } @@ -248,7 +249,7 @@ dir.Normalize2D(); const float3 tgtPos = float3(dir.x * sweepFireState.GetTargetDist2D(), 0.0f, dir.z * sweepFireState.GetTargetDist2D()); - const float tgtHgt = ground->GetHeightReal(weaponMuzzlePos.x + tgtPos.x, weaponMuzzlePos.z + tgtPos.z); + const float tgtHgt = CGround::GetHeightReal(weaponMuzzlePos.x + tgtPos.x, weaponMuzzlePos.z + tgtPos.z); // NOTE: INTENTIONALLY NOT NORMALIZED HERE dir = (tgtPos + UpVector * (tgtHgt - weaponMuzzlePos.y)); @@ -340,7 +341,7 @@ if (shieldLength < beamLength) { beamLength = shieldLength; - tryAgain = hitShield->BeamIntercepted(this, salvoDamageMult); + tryAgain = hitShield->BeamIntercepted(this, curPos, salvoDamageMult); } else { tryAgain = false; } @@ -380,23 +381,10 @@ } if (curLength < maxLength) { - const DamageArray& baseDamages = (weaponDef->dynDamageExp <= 0.0f)? - weaponDef->damages: - weaponDefHandler->DynamicDamages( - weaponDef->damages, - weaponMuzzlePos, - curPos, - (weaponDef->dynDamageRange > 0.0f)? - weaponDef->dynDamageRange: - weaponDef->range, - weaponDef->dynDamageExp, - weaponDef->dynDamageMin, - weaponDef->dynDamageInverted - ); - // make it possible to always hit with some minimal intensity (melee weapons have use for that) const float hitIntensity = std::max(minIntensity, 1.0f - curLength / (actualRange * 2.0f)); + const DamageArray& baseDamages = CWeaponDefHandler::DynamicDamages(weaponDef, weaponMuzzlePos, curPos); const DamageArray damages = baseDamages * (hitIntensity * salvoDamageMult); const CGameHelper::ExplosionParams params = { hitPos, diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/BeamLaser.h spring-98.0~14.04~ppa6/rts/Sim/Weapons/BeamLaser.h --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/BeamLaser.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/BeamLaser.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,8 +7,8 @@ class CBeamLaser: public CWeapon { - CR_DECLARE(CBeamLaser); - CR_DECLARE_SUB(SweepFireState); + CR_DECLARE(CBeamLaser) + CR_DECLARE_SUB(SweepFireState) public: CBeamLaser(CUnit* owner, const WeaponDef* def); @@ -34,7 +34,7 @@ struct SweepFireState { public: - CR_DECLARE_STRUCT(SweepFireState); + CR_DECLARE_STRUCT(SweepFireState) SweepFireState() { sweepInitDst = 0.0f; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/BombDropper.cpp spring-98.0~14.04~ppa6/rts/Sim/Weapons/BombDropper.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/BombDropper.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/BombDropper.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -11,14 +11,14 @@ #include "Sim/Units/UnitDef.h" #include "System/myMath.h" -CR_BIND_DERIVED(CBombDropper, CWeapon, (NULL, NULL, false)); +CR_BIND_DERIVED(CBombDropper, CWeapon, (NULL, NULL, false)) CR_REG_METADATA(CBombDropper,( CR_MEMBER(dropTorpedoes), CR_MEMBER(torpMoveRange), CR_MEMBER(tracking), CR_RESERVED(16) -)); +)) ////////////////////////////////////////////////////////////////////// // Construction/Destruction diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/BombDropper.h spring-98.0~14.04~ppa6/rts/Sim/Weapons/BombDropper.h --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/BombDropper.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/BombDropper.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CBombDropper: public CWeapon { - CR_DECLARE(CBombDropper); + CR_DECLARE(CBombDropper) public: CBombDropper(CUnit* owner, const WeaponDef* def, bool useTorps); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/Cannon.cpp spring-98.0~14.04~ppa6/rts/Sim/Weapons/Cannon.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/Cannon.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/Cannon.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -13,29 +13,28 @@ #include "System/myMath.h" #include "System/FastMath.h" -CR_BIND_DERIVED(CCannon, CWeapon, (NULL, NULL)); +CR_BIND_DERIVED(CCannon, CWeapon, (NULL, NULL)) CR_REG_METADATA(CCannon,( CR_MEMBER(highTrajectory), - CR_MEMBER(selfExplode), CR_MEMBER(rangeFactor), CR_MEMBER(lastDiff), CR_MEMBER(lastDir), CR_MEMBER(gravity), CR_RESERVED(32) -)); +)) ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// -CCannon::CCannon(CUnit* owner, const WeaponDef* def): CWeapon(owner, def) +CCannon::CCannon(CUnit* owner, const WeaponDef* def) + : CWeapon(owner, def) + , rangeFactor(1.0f) + , lastDir(-UpVector) + , highTrajectory(false) + , gravity(0.0f) { - lastDir = -UpVector; - highTrajectory = false; - rangeFactor = 1.0f; - gravity = 0.0f; - selfExplode = def->selfExplode; } void CCannon::Init() @@ -109,18 +108,16 @@ const float linear = dir.y; const float quadratic = gravity / (projectileSpeed * projectileSpeed) * 0.5f; const float groundDist = ((avoidFlags & Collision::NOGROUND) == 0)? - ground->TrajectoryGroundCol(weaponMuzzlePos, flatDir, flatLength - 10, linear, quadratic): + CGround::TrajectoryGroundCol(weaponMuzzlePos, flatDir, flatLength - 10, linear, quadratic): -1.0f; + const float spread = (AccuracyExperience() + SprayAngleExperience()) * 0.6f * 0.9f; if (groundDist > 0.0f) { return false; } - const float spread = (AccuracyExperience() + SprayAngleExperience()) * 0.6f * 0.9f; - const float modFlatLength = flatLength - 30.0f; - //FIXME add a forcedUserTarget (a forced fire mode enabled with meta key or something) and skip the test below then - if (TraceRay::TestTrajectoryCone(weaponMuzzlePos, flatDir, modFlatLength, + if (TraceRay::TestTrajectoryCone(weaponMuzzlePos, flatDir, flatLength, dir.y, quadratic, spread, owner->allyteam, avoidFlags, owner)) { return false; } @@ -144,7 +141,7 @@ if (weaponDef->flighttime > 0) { ttl = weaponDef->flighttime; - } else if (selfExplode) { + } else if (weaponDef->selfExplode) { ttl = (predict + gs->randFloat() * 2.5f - 0.5f); } else if ((weaponDef->groundBounce || weaponDef->waterBounce) && weaponDef->numBounce > 0) { ttl = (predict * (1 + weaponDef->numBounce * weaponDef->bounceRebound)); @@ -174,7 +171,7 @@ { if (owner->UnderFirstPersonControl()) { // mostly prevents firing longer than max range using fps mode - pos.y = ground->GetHeightAboveWater(pos.x, pos.z); + pos.y = CGround::GetHeightAboveWater(pos.x, pos.z); } // NOTE: this calls back into our derived TryTarget diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/Cannon.h spring-98.0~14.04~ppa6/rts/Sim/Weapons/Cannon.h --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/Cannon.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/Cannon.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CCannon: public CWeapon { - CR_DECLARE(CCannon); + CR_DECLARE(CCannon) protected: /// this is used to keep range true to range tag float rangeFactor; @@ -32,8 +32,6 @@ /// indicates high trajectory on/off state bool highTrajectory; - /// burnblow tag. defines flakker-like behaviour - bool selfExplode; /// projectile gravity float gravity; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/DGunWeapon.cpp spring-98.0~14.04~ppa6/rts/Sim/Weapons/DGunWeapon.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/DGunWeapon.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/DGunWeapon.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -6,11 +6,11 @@ #include "Sim/Projectiles/WeaponProjectiles/WeaponProjectileFactory.h" #include "Sim/Units/Unit.h" -CR_BIND_DERIVED(CDGunWeapon, CWeapon, (NULL, NULL)); +CR_BIND_DERIVED(CDGunWeapon, CWeapon, (NULL, NULL)) CR_REG_METADATA(CDGunWeapon,( CR_RESERVED(8) -)); +)) CDGunWeapon::CDGunWeapon(CUnit* owner, const WeaponDef* def): CWeapon(owner, def) { diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/DGunWeapon.h spring-98.0~14.04~ppa6/rts/Sim/Weapons/DGunWeapon.h --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/DGunWeapon.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/DGunWeapon.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CDGunWeapon: public CWeapon { - CR_DECLARE(CDGunWeapon); + CR_DECLARE(CDGunWeapon) public: CDGunWeapon(CUnit* owner, const WeaponDef* def); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/EmgCannon.cpp spring-98.0~14.04~ppa6/rts/Sim/Weapons/EmgCannon.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/EmgCannon.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/EmgCannon.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,7 +2,6 @@ #include "EmgCannon.h" #include "WeaponDef.h" -#include "Game/TraceRay.h" #include "Sim/Misc/Team.h" #include "Map/Ground.h" #include "Sim/Projectiles/WeaponProjectiles/WeaponProjectileFactory.h" @@ -10,11 +9,11 @@ #include "Sim/Units/UnitDef.h" #include "System/Sync/SyncTracer.h" -CR_BIND_DERIVED(CEmgCannon, CWeapon, (NULL, NULL)); +CR_BIND_DERIVED(CEmgCannon, CWeapon, (NULL, NULL)) CR_REG_METADATA(CEmgCannon,( CR_RESERVED(8) -)); +)) CEmgCannon::CEmgCannon(CUnit* owner, const WeaponDef* def): CWeapon(owner, def) { diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/EmgCannon.h spring-98.0~14.04~ppa6/rts/Sim/Weapons/EmgCannon.h --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/EmgCannon.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/EmgCannon.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CEmgCannon: public CWeapon { - CR_DECLARE(CEmgCannon); + CR_DECLARE(CEmgCannon) public: CEmgCannon(CUnit* owner, const WeaponDef* def); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/FlameThrower.cpp spring-98.0~14.04~ppa6/rts/Sim/Weapons/FlameThrower.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/FlameThrower.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/FlameThrower.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,18 +2,17 @@ #include "FlameThrower.h" #include "WeaponDef.h" -#include "Game/TraceRay.h" #include "Map/Ground.h" #include "Sim/Projectiles/WeaponProjectiles/WeaponProjectileFactory.h" #include "Sim/Units/Unit.h" -CR_BIND_DERIVED(CFlameThrower, CWeapon, (NULL, NULL)); +CR_BIND_DERIVED(CFlameThrower, CWeapon, (NULL, NULL)) CR_REG_METADATA(CFlameThrower,( CR_MEMBER(color), CR_MEMBER(color2), CR_RESERVED(8) -)); +)) CFlameThrower::CFlameThrower(CUnit* owner, const WeaponDef* def): CWeapon(owner, def) { diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/FlameThrower.h spring-98.0~14.04~ppa6/rts/Sim/Weapons/FlameThrower.h --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/FlameThrower.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/FlameThrower.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CFlameThrower: public CWeapon { - CR_DECLARE(CFlameThrower); + CR_DECLARE(CFlameThrower) public: CFlameThrower(CUnit* owner, const WeaponDef* def); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/LaserCannon.cpp spring-98.0~14.04~ppa6/rts/Sim/Weapons/LaserCannon.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/LaserCannon.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/LaserCannon.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,22 +2,23 @@ #include "LaserCannon.h" #include "WeaponDef.h" -#include "Game/TraceRay.h" #include "Map/Ground.h" #include "Sim/Projectiles/WeaponProjectiles/WeaponProjectileFactory.h" #include "Sim/Units/Unit.h" #include "Sim/Units/UnitDef.h" +#include "System/myMath.h" -CR_BIND_DERIVED(CLaserCannon, CWeapon, (NULL, NULL)); +CR_BIND_DERIVED(CLaserCannon, CWeapon, (NULL, NULL)) CR_REG_METADATA(CLaserCannon,( CR_MEMBER(color), CR_RESERVED(8) -)); +)) -CLaserCannon::CLaserCannon(CUnit* owner, const WeaponDef* def): CWeapon(owner, def) +CLaserCannon::CLaserCannon(CUnit* owner, const WeaponDef* def) + : CWeapon(owner, def) + , color(def->visuals.color) { - color = def->visuals.color; } @@ -71,7 +72,7 @@ ProjectileParams params = GetProjectileParams(); params.pos = weaponMuzzlePos; params.speed = dir * projectileSpeed; - params.ttl = std::min(ttlreq, ttlmax); + params.ttl = mix(std::max(ttlreq, ttlmax), std::min(ttlreq, ttlmax), weaponDef->selfExplode); WeaponProjectileFactory::LoadProjectile(params); } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/LaserCannon.h spring-98.0~14.04~ppa6/rts/Sim/Weapons/LaserCannon.h --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/LaserCannon.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/LaserCannon.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CLaserCannon: public CWeapon { - CR_DECLARE(CLaserCannon); + CR_DECLARE(CLaserCannon) public: CLaserCannon(CUnit* owner, const WeaponDef* def); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/LightningCannon.cpp spring-98.0~14.04~ppa6/rts/Sim/Weapons/LightningCannon.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/LightningCannon.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/LightningCannon.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -14,16 +14,17 @@ #include "Sim/Units/Unit.h" -CR_BIND_DERIVED(CLightningCannon, CWeapon, (NULL, NULL)); +CR_BIND_DERIVED(CLightningCannon, CWeapon, (NULL, NULL)) CR_REG_METADATA(CLightningCannon,( CR_MEMBER(color), CR_RESERVED(8) -)); +)) -CLightningCannon::CLightningCannon(CUnit* owner, const WeaponDef* def): CWeapon(owner, def) +CLightningCannon::CLightningCannon(CUnit* owner, const WeaponDef* def) + : CWeapon(owner, def) + , color(def->visuals.color) { - color = def->visuals.color; } @@ -69,27 +70,14 @@ if (shieldLength < boltLength) { boltLength = shieldLength; - hitShield->BeamIntercepted(this); + hitShield->BeamIntercepted(this, curPos); } if (hitUnit != NULL) { hitUnit->SetLastAttackedPiece(hitColQuery.GetHitPiece(), gs->frameNum); } - const DamageArray& damageArray = (weaponDef->dynDamageExp <= 0.0f)? - weaponDef->damages: - weaponDefHandler->DynamicDamages( - weaponDef->damages, - weaponMuzzlePos, - targetPos, - (weaponDef->dynDamageRange > 0.0f)? - weaponDef->dynDamageRange: - weaponDef->range, - weaponDef->dynDamageExp, - weaponDef->dynDamageMin, - weaponDef->dynDamageInverted - ); - + const DamageArray& damageArray = CWeaponDefHandler::DynamicDamages(weaponDef, weaponMuzzlePos, targetPos); const CGameHelper::ExplosionParams params = { curPos + curDir * boltLength, // hitPos (same as hitColQuery.GetHitPos() if no water or shield in way) curDir, @@ -114,7 +102,7 @@ ProjectileParams pparams = GetProjectileParams(); pparams.pos = curPos; pparams.end = curPos + curDir * (boltLength + 10.0f); - pparams.ttl = 10; + pparams.ttl = weaponDef->beamLaserTTL; WeaponProjectileFactory::LoadProjectile(pparams); } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/LightningCannon.h spring-98.0~14.04~ppa6/rts/Sim/Weapons/LightningCannon.h --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/LightningCannon.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/LightningCannon.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CLightningCannon: public CWeapon { - CR_DECLARE(CLightningCannon); + CR_DECLARE(CLightningCannon) public: CLightningCannon(CUnit* owner, const WeaponDef* def); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/MeleeWeapon.cpp spring-98.0~14.04~ppa6/rts/Sim/Weapons/MeleeWeapon.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/MeleeWeapon.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/MeleeWeapon.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -4,11 +4,11 @@ #include "WeaponDef.h" #include "Sim/Units/Unit.h" -CR_BIND_DERIVED(CMeleeWeapon, CWeapon, (NULL, NULL)); +CR_BIND_DERIVED(CMeleeWeapon, CWeapon, (NULL, NULL)) CR_REG_METADATA(CMeleeWeapon,( CR_RESERVED(8) -)); +)) ////////////////////////////////////////////////////////////////////// // Construction/Destruction diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/MeleeWeapon.h spring-98.0~14.04~ppa6/rts/Sim/Weapons/MeleeWeapon.h --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/MeleeWeapon.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/MeleeWeapon.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CMeleeWeapon: public CWeapon { - CR_DECLARE(CMeleeWeapon); + CR_DECLARE(CMeleeWeapon) public: CMeleeWeapon(CUnit* owner, const WeaponDef* def); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/MissileLauncher.cpp spring-98.0~14.04~ppa6/rts/Sim/Weapons/MissileLauncher.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/MissileLauncher.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/MissileLauncher.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -8,11 +8,11 @@ #include "Sim/Units/Unit.h" #include "Sim/Units/UnitDef.h" -CR_BIND_DERIVED(CMissileLauncher, CWeapon, (NULL, NULL)); +CR_BIND_DERIVED(CMissileLauncher, CWeapon, (NULL, NULL)) CR_REG_METADATA(CMissileLauncher,( CR_RESERVED(8) -)); +)) CMissileLauncher::CMissileLauncher(CUnit* owner, const WeaponDef* def): CWeapon(owner, def) { @@ -91,15 +91,13 @@ const float linear = dir.y + weaponDef->trajectoryHeight; const float quadratic = -weaponDef->trajectoryHeight / flatLength; const float groundDist = ((avoidFlags & Collision::NOGROUND) == 0)? - ground->TrajectoryGroundCol(weaponMuzzlePos, flatDir, flatLength - 30, linear, quadratic): + CGround::TrajectoryGroundCol(weaponMuzzlePos, flatDir, flatLength, linear, quadratic): -1.0f; - // FIXME: _WHY_ the 30-elmo subtraction? - const float modFlatLength = flatLength - 30.0f; if (groundDist > 0.0f) return false; - if (TraceRay::TestTrajectoryCone(weaponMuzzlePos, flatDir, modFlatLength, + if (TraceRay::TestTrajectoryCone(weaponMuzzlePos, flatDir, flatLength, linear, quadratic, 0, owner->allyteam, avoidFlags, owner)) { return false; } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/MissileLauncher.h spring-98.0~14.04~ppa6/rts/Sim/Weapons/MissileLauncher.h --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/MissileLauncher.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/MissileLauncher.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CMissileLauncher: public CWeapon { - CR_DECLARE(CMissileLauncher); + CR_DECLARE(CMissileLauncher) public: CMissileLauncher(CUnit* owner, const WeaponDef* def); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/NoWeapon.cpp spring-98.0~14.04~ppa6/rts/Sim/Weapons/NoWeapon.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/NoWeapon.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/NoWeapon.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,7 +2,7 @@ #include "NoWeapon.h" -CR_BIND_DERIVED(CNoWeapon, CWeapon, (NULL, NULL)); +CR_BIND_DERIVED(CNoWeapon, CWeapon, (NULL, NULL)) CNoWeapon::CNoWeapon(CUnit* owner, const WeaponDef* def) : CWeapon(owner, def) { diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/NoWeapon.h spring-98.0~14.04~ppa6/rts/Sim/Weapons/NoWeapon.h --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/NoWeapon.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/NoWeapon.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CNoWeapon: public CWeapon { - CR_DECLARE(CNoWeapon); + CR_DECLARE(CNoWeapon) public: CNoWeapon(CUnit* owner, const WeaponDef* def); @@ -17,7 +17,7 @@ private: bool TestTarget(const float3& pos, bool userTarget, const CUnit* unit) const { return false; } - void FireImpl() {} + void FireImpl(bool scriptCall) {} }; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/PlasmaRepulser.cpp spring-98.0~14.04~ppa6/rts/Sim/Weapons/PlasmaRepulser.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/PlasmaRepulser.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/PlasmaRepulser.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -3,7 +3,6 @@ #include "System/creg/STL_List.h" #include "System/creg/STL_Set.h" #include "PlasmaRepulser.h" -#include "Lua/LuaRules.h" #include "Sim/Misc/GlobalSynced.h" #include "Sim/Misc/InterceptHandler.h" #include "Sim/Misc/TeamHandler.h" @@ -14,9 +13,11 @@ #include "Sim/Units/Scripts/UnitScript.h" #include "Sim/Units/Unit.h" #include "Sim/Weapons/WeaponDef.h" +#include "Sim/Weapons/WeaponDefHandler.h" +#include "System/EventHandler.h" #include "System/myMath.h" -CR_BIND_DERIVED(CPlasmaRepulser, CWeapon, (NULL, NULL)); +CR_BIND_DERIVED(CPlasmaRepulser, CWeapon, (NULL, NULL)) CR_REG_METADATA(CPlasmaRepulser, ( CR_MEMBER(radius), @@ -27,7 +28,7 @@ CR_MEMBER(isEnabled), CR_MEMBER(shieldProjectile), CR_MEMBER(repulsedProjectiles) -)); +)) CPlasmaRepulser::CPlasmaRepulser(CUnit* owner, const WeaponDef* def): CWeapon(owner, def), @@ -109,12 +110,15 @@ continue; } - if (luaRules && luaRules->ShieldPreDamaged(pro, this, owner, weaponDef->shieldRepulser)) { + if (eventHandler.ShieldPreDamaged(pro, this, owner, weaponDef->shieldRepulser)) { // gadget handles the collision event, don't touch the projectile continue; } - if (curPower < proWD->damages[0]) { + const DamageArray& damageArray = CWeaponDefHandler::DynamicDamages(proWD, pro->GetStartPos(), pro->pos); + const float shieldDamage = damageArray[weaponDef->shieldArmorType]; + + if (curPower < shieldDamage) { // shield does not have enough power, don't touch the projectile continue; } @@ -138,15 +142,19 @@ owner->UseEnergy(weaponDef->shieldEnergyUse); if (weaponDef->shieldPower != 0) { - //FIXME some weapons do range dependent damage! (mantis #2345) - curPower -= proWD->damages[0]; + curPower -= shieldDamage; } } else { //FIXME why do all weapons except LASERs do only (1 / GAME_SPEED) damage??? + // because they go inside and take time to get pushed back + // during that time they deal damage every frame + // so in total they do their nominal damage each second + // on the other hand lasers get insta-bounced in 1 frame + // regardless of shield pushing power owner->UseEnergy(weaponDef->shieldEnergyUse / GAME_SPEED); if (weaponDef->shieldPower != 0) { - curPower -= proWD->damages[0] / GAME_SPEED; + curPower -= shieldDamage / GAME_SPEED; } } @@ -169,8 +177,7 @@ // kill the projectile if (owner->UseEnergy(weaponDef->shieldEnergyUse)) { if (weaponDef->shieldPower != 0) { - //FIXME some weapons do range dependent damage! (mantis #2345) - curPower -= proWD->damages[0]; + curPower -= shieldDamage; } pro->Collision(owner); @@ -250,7 +257,9 @@ return -1.0f; } - if (emitter->weaponDef->damages[0] > curPower) { + const DamageArray& damageArray = CWeaponDefHandler::DynamicDamages(emitter->weaponDef, start, weaponPos); + + if (damageArray[weaponDef->shieldArmorType] > curPower) { return -1.0f; } if (weaponDef->smartShield && teamHandler->AlliedTeams(emitter->owner->team, owner->team)) { @@ -290,11 +299,12 @@ } -bool CPlasmaRepulser::BeamIntercepted(CWeapon* emitter, float damageMultiplier) +bool CPlasmaRepulser::BeamIntercepted(CWeapon* emitter, float3 start, float damageMultiplier) { + const DamageArray& damageArray = CWeaponDefHandler::DynamicDamages(emitter->weaponDef, start, weaponPos); + if (weaponDef->shieldPower > 0) { - //FIXME some weapons do range dependent damage! (mantis #2345) - curPower -= emitter->weaponDef->damages[0] * damageMultiplier; + curPower -= damageArray[weaponDef->shieldArmorType] * damageMultiplier; } return weaponDef->shieldRepulser; } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/PlasmaRepulser.h spring-98.0~14.04~ppa6/rts/Sim/Weapons/PlasmaRepulser.h --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/PlasmaRepulser.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/PlasmaRepulser.h 2014-10-07 20:09:51.000000000 +0000 @@ -12,7 +12,7 @@ class CPlasmaRepulser: public CWeapon { - CR_DECLARE(CPlasmaRepulser); + CR_DECLARE(CPlasmaRepulser) public: CPlasmaRepulser(CUnit* owner, const WeaponDef* def); ~CPlasmaRepulser(); @@ -26,7 +26,7 @@ void NewProjectile(CWeaponProjectile* p); float NewBeam(CWeapon* emitter, float3 start, float3 dir, float length, float3& newDir); - bool BeamIntercepted(CWeapon* emitter, float damageMultiplier = 1.0f); // returns true if we are a repulsing shield + bool BeamIntercepted(CWeapon* emitter, float3 start, float damageMultiplier = 1.0f); // returns true if we are a repulsing shield void SetEnabled(bool b) { isEnabled = b; } void SetCurPower(float p) { curPower = p; } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/Rifle.cpp spring-98.0~14.04~ppa6/rts/Sim/Weapons/Rifle.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/Rifle.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/Rifle.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -13,11 +13,11 @@ #include "System/Sync/SyncTracer.h" #include "System/myMath.h" -CR_BIND_DERIVED(CRifle, CWeapon, (NULL, NULL)); +CR_BIND_DERIVED(CRifle, CWeapon, (NULL, NULL)) CR_REG_METADATA(CRifle,( CR_RESERVED(8) -)); +)) ////////////////////////////////////////////////////////////////////// // Construction/Destruction diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/Rifle.h spring-98.0~14.04~ppa6/rts/Sim/Weapons/Rifle.h --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/Rifle.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/Rifle.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CRifle: public CWeapon { - CR_DECLARE(CRifle); + CR_DECLARE(CRifle) public: CRifle(CUnit* owner, const WeaponDef* def); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/StarburstLauncher.cpp spring-98.0~14.04~ppa6/rts/Sim/Weapons/StarburstLauncher.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/StarburstLauncher.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/StarburstLauncher.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,13 +7,13 @@ #include "Sim/Projectiles/WeaponProjectiles/WeaponProjectileFactory.h" #include "Sim/Units/Unit.h" -CR_BIND_DERIVED(CStarburstLauncher, CWeapon, (NULL, NULL)); +CR_BIND_DERIVED(CStarburstLauncher, CWeapon, (NULL, NULL)) CR_REG_METADATA(CStarburstLauncher, ( CR_MEMBER(uptime), CR_MEMBER(tracking), CR_RESERVED(8) -)); +)) CStarburstLauncher::CStarburstLauncher(CUnit* owner, const WeaponDef* def): CWeapon(owner, def) { diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/StarburstLauncher.h spring-98.0~14.04~ppa6/rts/Sim/Weapons/StarburstLauncher.h --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/StarburstLauncher.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/StarburstLauncher.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CStarburstLauncher: public CWeapon { - CR_DECLARE(CStarburstLauncher); + CR_DECLARE(CStarburstLauncher) public: CStarburstLauncher(CUnit* owner, const WeaponDef* def); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/TorpedoLauncher.cpp spring-98.0~14.04~ppa6/rts/Sim/Weapons/TorpedoLauncher.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/TorpedoLauncher.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/TorpedoLauncher.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,18 +2,17 @@ #include "TorpedoLauncher.h" #include "WeaponDef.h" -#include "Game/TraceRay.h" #include "Map/Ground.h" #include "Sim/Projectiles/WeaponProjectiles/WeaponProjectileFactory.h" #include "Sim/Units/UnitDef.h" #include "Sim/Units/Unit.h" -CR_BIND_DERIVED(CTorpedoLauncher, CWeapon, (NULL, NULL)); +CR_BIND_DERIVED(CTorpedoLauncher, CWeapon, (NULL, NULL)) CR_REG_METADATA(CTorpedoLauncher,( CR_MEMBER(tracking), CR_RESERVED(8) -)); +)) CTorpedoLauncher::CTorpedoLauncher(CUnit* owner, const WeaponDef* def): CWeapon(owner, def) { diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/TorpedoLauncher.h spring-98.0~14.04~ppa6/rts/Sim/Weapons/TorpedoLauncher.h --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/TorpedoLauncher.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/TorpedoLauncher.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ class CTorpedoLauncher: public CWeapon { - CR_DECLARE(CTorpedoLauncher); + CR_DECLARE(CTorpedoLauncher) public: CTorpedoLauncher(CUnit* owner, const WeaponDef* def); diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/Weapon.cpp spring-98.0~14.04~ppa6/rts/Sim/Weapons/Weapon.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/Weapon.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/Weapon.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -6,7 +6,6 @@ #include "Game/GameHelper.h" #include "Game/TraceRay.h" #include "Game/Players/Player.h" -#include "Lua/LuaRules.h" #include "Map/Ground.h" #include "Sim/Misc/CollisionHandler.h" #include "Sim/Misc/CollisionVolume.h" @@ -24,10 +23,10 @@ #include "System/float3.h" #include "System/myMath.h" #include "System/Sync/SyncTracer.h" -#include "System/Sound/SoundChannels.h" +#include "System/Sound/ISoundChannels.h" #include "System/Log/ILog.h" -CR_BIND_DERIVED(CWeapon, CObject, (NULL, NULL)); +CR_BIND_DERIVED(CWeapon, CObject, (NULL, NULL)) CR_REG_METADATA(CWeapon, ( CR_MEMBER(owner), @@ -42,7 +41,7 @@ CR_MEMBER(nextSalvo), CR_MEMBER(predict), CR_MEMBER(targetUnit), - CR_MEMBER(accuracy), + CR_MEMBER(accuracyError), CR_MEMBER(projectileSpeed), CR_MEMBER(predictSpeedMod), CR_MEMBER(metalFireCost), @@ -102,7 +101,7 @@ CR_MEMBER(errorVectorAdd), CR_MEMBER(targetPos), CR_MEMBER(targetBorderPos) -)); +)) ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -123,7 +122,7 @@ range(1), heightMod(0), projectileSpeed(1), - accuracy(0), + accuracyError(0), sprayAngle(0), salvoDelay(0), salvoSize(1), @@ -231,9 +230,9 @@ return; if (weaponDef->waterweapon) { - tgtPos.y = std::max(tgtPos.y, ground->GetHeightReal(tgtPos.x, tgtPos.z)); + tgtPos.y = std::max(tgtPos.y, CGround::GetHeightReal(tgtPos.x, tgtPos.z)); } else { - tgtPos.y = std::max(tgtPos.y, ground->GetHeightAboveWater(tgtPos.x, tgtPos.z)); + tgtPos.y = std::max(tgtPos.y, CGround::GetHeightAboveWater(tgtPos.x, tgtPos.z)); } } @@ -312,7 +311,7 @@ // never target below terrain // never target below water if not a water-weapon targetPos = (targetBorder == 0.0f)? tmpTargetPos: targetBorderPos; - targetPos.y = std::max(targetPos.y, ground->GetApproximateHeight(targetPos.x, targetPos.z) + 2.0f); + targetPos.y = std::max(targetPos.y, CGround::GetApproximateHeight(targetPos.x, targetPos.z) + 2.0f); targetPos.y = std::max(targetPos.y, targetPos.y * weaponDef->waterweapon); } @@ -448,7 +447,7 @@ salvoLeft = salvoSize; nextSalvo = gs->frameNum; - salvoError = gs->randVector() * (owner->IsMoving()? weaponDef->movingAccuracy: accuracy); + salvoError = gs->randVector() * (owner->IsMoving()? weaponDef->movingAccuracy: accuracyError); if (targetType == Target_Pos || (targetType == Target_Unit && !(targetUnit->losStatus[owner->allyteam] & LOS_INLOS))) { // area firing stuff is too effective at radar firing... @@ -463,7 +462,7 @@ if (!weaponDef->stockpile && TryTarget(targetPos, haveUserTarget, targetUnit)) { // update the energy and metal required counts const int minPeriod = std::max(1, (int)(reloadTime / owner->reloadSpeed)); - const float averageFactor = 1.0f / (float)minPeriod; + const float averageFactor = 1.0f / minPeriod; ownerTeam->energyPull += (averageFactor * energyFireCost); ownerTeam->metalPull += (averageFactor * metalFireCost); @@ -573,7 +572,7 @@ weaponMuzzlePos = owner->GetObjectSpacePos(relWeaponMuzzlePos); - if (weaponMuzzlePos.y < ground->GetHeightReal(weaponMuzzlePos.x, weaponMuzzlePos.z)) { + if (weaponMuzzlePos.y < CGround::GetHeightReal(weaponMuzzlePos.x, weaponMuzzlePos.z)) { // hope that we are underground because we are a popup weapon and will come above ground later weaponMuzzlePos = owner->pos + UpVector * 10; } @@ -604,7 +603,7 @@ weaponPos = owner->GetObjectSpacePos(relWeaponPos); weaponMuzzlePos = owner->GetObjectSpacePos(relWeaponMuzzlePos); - if (weaponMuzzlePos.y < ground->GetHeightReal(weaponMuzzlePos.x, weaponMuzzlePos.z)) { + if (weaponMuzzlePos.y < CGround::GetHeightReal(weaponMuzzlePos.x, weaponMuzzlePos.z)) { // hope that we are underground because we are a popup weapon and will come above ground later weaponMuzzlePos = owner->pos + UpVector * 10; } @@ -652,7 +651,7 @@ targetType = Target_Unit; targetUnit = newTargetUnit; targetPos = (targetBorder == 0.0f)? newTargetPos: targetBorderPos; - targetPos.y = std::max(targetPos.y, ground->GetApproximateHeight(targetPos.x, targetPos.z) + 2.0f); + targetPos.y = std::max(targetPos.y, CGround::GetApproximateHeight(targetPos.x, targetPos.z) + 2.0f); AddDeathDependence(targetUnit, DEPENDENCE_TARGETUNIT); avoidTarget = false; @@ -682,12 +681,10 @@ bool CWeapon::AllowWeaponTargetCheck() { - if (luaRules != NULL) { - const int checkAllowed = luaRules->AllowWeaponTargetCheck(owner->id, weaponNum, weaponDef->id); + const int checkAllowed = eventHandler.AllowWeaponTargetCheck(owner->id, weaponNum, weaponDef->id); - if (checkAllowed >= 0) { - return checkAllowed; - } + if (checkAllowed >= 0) { + return checkAllowed; } if (weaponDef->noAutoTarget) { return false; } @@ -760,7 +757,7 @@ prevTargetUnit = nextTargetUnit; nextTargetPos = nextTargetUnit->aimPos + (errorVector * weaponError); - const float appHeight = ground->GetApproximateHeight(nextTargetPos.x, nextTargetPos.z) + 2.0f; + const float appHeight = CGround::GetApproximateHeight(nextTargetPos.x, nextTargetPos.z) + 2.0f; if (nextTargetPos.y < appHeight) { nextTargetPos.y = appHeight; @@ -825,7 +822,7 @@ weaponMuzzlePos = owner->GetObjectSpacePos(relWeaponMuzzlePos); weaponPos = owner->GetObjectSpacePos(relWeaponPos); - if (weaponMuzzlePos.y < ground->GetHeightReal(weaponMuzzlePos.x, weaponMuzzlePos.z)) { + if (weaponMuzzlePos.y < CGround::GetHeightReal(weaponMuzzlePos.x, weaponMuzzlePos.z)) { // hope that we are underground because we are a popup weapon and will come above ground later weaponMuzzlePos = owner->pos + UpVector * 10; } @@ -868,14 +865,15 @@ targetType = Target_None; if (slavedTo->targetType == Target_Unit) { - const float3 tp = - slavedTo->targetUnit->GetErrorPos(owner->allyteam, true) + - errorVector * (MoveErrorExperience() * GAME_SPEED * slavedTo->targetUnit->speed.w); + const float errorScale = (MoveErrorExperience() * GAME_SPEED * slavedTo->targetUnit->speed.w); + + const float3 errorPos = slavedTo->targetUnit->GetErrorPos(owner->allyteam, true); + const float3 targetErrPos = errorPos + errorVector * errorScale; - if (TryTarget(tp, false, slavedTo->targetUnit)) { + if (TryTarget(targetErrPos, false, slavedTo->targetUnit)) { targetType = Target_Unit; targetUnit = slavedTo->targetUnit; - targetPos = tp; + targetPos = targetErrPos; AddDeathDependence(targetUnit, DEPENDENCE_TARGETUNIT); } @@ -1194,7 +1192,7 @@ const float errorScale = (MoveErrorExperience() * GAME_SPEED * unit->speed.w); float3 tempTargetPos = errorPos + errorVector * errorScale; - tempTargetPos.y = std::max(tempTargetPos.y, ground->GetApproximateHeight(tempTargetPos.x, tempTargetPos.z) + 2.0f); + tempTargetPos.y = std::max(tempTargetPos.y, CGround::GetApproximateHeight(tempTargetPos.x, tempTargetPos.z) + 2.0f); return tempTargetPos; } @@ -1203,7 +1201,7 @@ const float errorScale = (MoveErrorExperience() * GAME_SPEED * unit->speed.w); float3 tempTargetPos = errorPos + errorVector * errorScale; - tempTargetPos.y = std::max(tempTargetPos.y, ground->GetApproximateHeight(tempTargetPos.x, tempTargetPos.z) + 2.0f); + tempTargetPos.y = std::max(tempTargetPos.y, CGround::GetApproximateHeight(tempTargetPos.x, tempTargetPos.z) + 2.0f); const short weaponHeading = GetHeadingFromVector(mainDir.x, mainDir.z); const short enemyHeading = GetHeadingFromVector(tempTargetPos.x - weaponPos.x, tempTargetPos.z - weaponPos.z); @@ -1289,7 +1287,7 @@ FireImpl(scriptCall); if (fireSoundId > 0 && (!weaponDef->soundTrigger || salvoLeft == salvoSize - 1)) { - Channels::Battle.PlaySample(fireSoundId, owner, fireSoundVolume); + Channels::Battle->PlaySample(fireSoundId, owner, fireSoundVolume); } } @@ -1324,7 +1322,10 @@ // if ((interceptTarget != NULL) && ((p->pos - weaponPos).SqLength() >= (interceptTarget->pos - weaponPos).SqLength())) // continue; - // keep targetPos in sync with the incoming projectile's position + // trigger us to auto-fire at this incoming projectile + // we do not really need to set targetPos here since it + // will be read from params.target (GetProjectileParams) + // when our subclass Fire()'s interceptTarget = p; targetType = Target_Intercept; targetPos = p->pos + p->speed; @@ -1342,6 +1343,7 @@ params.target = targetUnit; } + params.weaponID = weaponNum; params.owner = owner; params.weaponDef = weaponDef; @@ -1367,12 +1369,23 @@ } } -float CWeapon::ExperienceScale() const + +float CWeapon::ExperienceErrorScale() const { - return (1.0f - owner->limExperience * weaponDef->ownerExpAccWeight); + // accuracy (error) is increased (decreased) with experience + // scale is 1.0f - (limExperience * expAccWeight), such that + // for weight=0 scale is 1 and for weight=1 scale is 1 - exp + // (lower is better) + // + // for accWeight=0.00 and {0.25, 0.50, 0.75, 1.0} exp, scale=(1.0 - {0.25*0.00, 0.5*0.00, 0.75*0.00, 1.0*0.00}) = {1.0000, 1.000, 1.0000, 1.00} + // for accWeight=0.25 and {0.25, 0.50, 0.75, 1.0} exp, scale=(1.0 - {0.25*0.25, 0.5*0.25, 0.75*0.25, 1.0*0.25}) = {0.9375, 0.875, 0.8125, 0.75} + // for accWeight=0.50 and {0.25, 0.50, 0.75, 1.0} exp, scale=(1.0 - {0.25*0.50, 0.5*0.50, 0.75*0.50, 1.0*0.50}) = {0.8750, 0.750, 0.6250, 0.50} + // for accWeight=1.00 and {0.25, 0.50, 0.75, 1.0} exp, scale=(1.0 - {0.25*1.00, 0.5*1.00, 0.75*1.00, 1.0*0.75}) = {0.7500, 0.500, 0.2500, 0.25} + return (CUnit::ExperienceScale(owner->limExperience, weaponDef->ownerExpAccWeight)); } float CWeapon::MoveErrorExperience() const { - return weaponDef->targetMoveError*(1.0f - owner->limExperience); + return (ExperienceErrorScale() * weaponDef->targetMoveError); } + diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/WeaponDef.cpp spring-98.0~14.04~ppa6/rts/Sim/Weapons/WeaponDef.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/WeaponDef.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/WeaponDef.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -15,7 +15,7 @@ #include "System/myMath.h" #include "System/Log/ILog.h" -CR_BIND(WeaponDef, ); +CR_BIND(WeaponDef, ) @@ -50,7 +50,7 @@ WEAPONTAG(bool, noSelfDamage).defaultValue(false); WEAPONTAG(bool, noExplode).defaultValue(false); WEAPONTAG(bool, selfExplode).externalName("burnblow").defaultValue(false); -WEAPONTAG(float, damageAreaOfEffect).externalName("areaOfEffect").defaultValue(8.0f).scaleValue(0.5f); +WEAPONTAG(float, damageAreaOfEffect).fallbackName("areaOfEffect").defaultValue(8.0f).scaleValue(0.5f); WEAPONTAG(float, edgeEffectiveness).defaultValue(0.0f).maximumValue(0.999f); WEAPONTAG(float, collisionSize).defaultValue(0.05f); @@ -75,7 +75,7 @@ WEAPONTAG(float, impulseBoost, damages.impulseBoost).defaultValue(0.0f); WEAPONTAG(float, craterMult, damages.craterMult).fallbackName("impulseFactor").defaultValue(1.0f); WEAPONTAG(float, craterBoost, damages.craterBoost).defaultValue(0.0f); -WEAPONTAG(float, craterAreaOfEffect).externalName("areaOfEffect").defaultValue(8.0f).scaleValue(0.5f); +WEAPONTAG(float, craterAreaOfEffect).fallbackName("areaOfEffect").defaultValue(8.0f).scaleValue(0.5f); // Water WEAPONTAG(bool, waterweapon).defaultValue(false); @@ -106,7 +106,7 @@ WEAPONTAG(float, proximityPriority).defaultValue(1.0f); // Target Error -TAGFUNCTION(AccuracyToSin, float, math::sin(x * PI / 0xafff)); // should really be tan but TA seem to cap it somehow, should also be 7fff or ffff theoretically but neither seems good +TAGFUNCTION(AccuracyToSin, float, math::sin(x * PI / 0xafff)) // should really be tan but TA seem to cap it somehow, should also be 7fff or ffff theoretically but neither seems good WEAPONTAG(float, accuracy).defaultValue(0.0f).tagFunction(AccuracyToSin); WEAPONTAG(float, sprayAngle).defaultValue(0.0f).tagFunction(AccuracyToSin); WEAPONTAG(float, movingAccuracy).externalName("accuracy").defaultValue(0.0f).tagFunction(AccuracyToSin); @@ -195,8 +195,8 @@ .defaultValue(float3(0.5f, 0.5f, 1.0f)).description("The RGB colour the shield transitions to as its hit-points are regenerated towards its maximum power."); WEAPONTAG(float, shieldAlpha).externalName("shield.alpha").fallbackName("shieldAlpha") .defaultValue(0.2f).description("The alpha transparency of the shield whilst it is visible."); - - +WEAPONTAG(std::string, shieldArmorTypeName).externalName("shield.armorType").fallbackName("shieldArmorType") + .defaultValue("default").description("Specifies the armorclass of the shield; you can input either an armorclass name OR a unitdef name to share that unit's armorclass"); // Unsynced (= Visuals) WEAPONTAG(std::string, model, visuals.modelName).defaultValue(""); @@ -293,6 +293,7 @@ LOG_L(L_WARNING, "WeaponDef (%s) The \"isShield\" tag has been removed. Use the weaponType=\"Shield\" tag instead!", name.c_str()); shieldRechargeDelay = int(wdTable.GetFloat("rechargeDelay", 0) * GAME_SPEED); + shieldArmorType = damageArrayHandler->GetTypeFromName(shieldArmorTypeName); flighttime = int(wdTable.GetFloat("flighttime", 0.0f) * 32); //FIXME may be smarter to merge the collideXYZ tags with avoidXYZ and removing the collisionFlags tag (and move the code into CWeapon)? @@ -326,6 +327,15 @@ } else if (type == "BeamLaser" || type == "LightningCannon") { heightmod = wdTable.GetFloat("heightMod", 1.0f); } + + if (type == "LaserCannon") { + // for lasers we want this to be true by default: it sets + // projectile ttl values to the minimum required to hit a + // target which prevents them overshooting (lasers travel + // many elmos per frame and ttl's are rounded) at maximum + // range + selfExplode = wdTable.GetBool("burnblow", true); + } } // setup the default damages diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/WeaponDef.h spring-98.0~14.04~ppa6/rts/Sim/Weapons/WeaponDef.h --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/WeaponDef.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/WeaponDef.h 2014-10-07 20:09:51.000000000 +0000 @@ -18,7 +18,7 @@ struct WeaponDef { private: - CR_DECLARE_STRUCT(WeaponDef); + CR_DECLARE_STRUCT(WeaponDef) public: WeaponDef(); @@ -51,9 +51,9 @@ float range; float heightmod; - float accuracy; ///< inaccuracy of whole burst - float sprayAngle; ///< inaccuracy of individual shots inside burst - float movingAccuracy; ///< inaccuracy while owner moving + float accuracy; ///< INaccuracy (!) of whole burst + float sprayAngle; ///< INaccuracy of individual shots inside burst + float movingAccuracy; ///< INaccuracy (!) while owner moving float ownerExpAccWeight; ///< if 0, accuracy is not increased with owner experience (max. 1) float targetMoveError; ///< fraction of targets move speed that is used as error offset float leadLimit; ///< maximum distance the weapon will lead the target @@ -165,6 +165,8 @@ float3 shieldGoodColor; // color when shield at full power float3 shieldBadColor; // color when shield is empty float shieldAlpha; // shield alpha value + int shieldArmorType; // armor type for the damage table + std::string shieldArmorTypeName; // name of the armor type unsigned int shieldInterceptType; // type of shield (bitfield) unsigned int interceptedByShieldType; // weapon can be affected by shields where (shieldInterceptType & interceptedByShieldType) is not zero diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/WeaponDefHandler.cpp spring-98.0~14.04~ppa6/rts/Sim/Weapons/WeaponDefHandler.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/WeaponDefHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/WeaponDefHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -66,35 +66,46 @@ -DamageArray CWeaponDefHandler::DynamicDamages(const DamageArray& damages, const float3 startPos, const float3 curPos, const float range, const float exp, const float damageMin, const bool inverted) -{ +DamageArray CWeaponDefHandler::DynamicDamages( + const WeaponDef* weaponDef, + const float3 startPos, + const float3 curPos +) { + const DamageArray& damages = weaponDef->damages; + + if (weaponDef->dynDamageExp <= 0.0f) + return damages; + DamageArray dynDamages(damages); + const float range = (weaponDef->dynDamageRange > 0.0f)? weaponDef->dynDamageRange: weaponDef->range; + const float damageMin = weaponDef->dynDamageMin; + const float travDist = std::min(range, curPos.distance2D(startPos)); - const float damageMod = 1.0f - math::pow(1.0f / range * travDist, exp); + const float damageMod = 1.0f - math::pow(1.0f / range * travDist, weaponDef->dynDamageExp); const float ddmod = damageMin / damages[0]; // get damage mod from first damage type - if (inverted) { - for(int i = 0; i < damageArrayHandler->GetNumTypes(); ++i) { + if (weaponDef->dynDamageInverted) { + for (int i = 0; i < damageArrayHandler->GetNumTypes(); ++i) { dynDamages[i] = damages[i] - damageMod * damages[i]; - if (damageMin > 0) + if (damageMin > 0.0f) dynDamages[i] = std::max(damages[i] * ddmod, dynDamages[i]); // to prevent div by 0 dynDamages[i] = std::max(0.0001f, dynDamages[i]); } - } - else { - for(int i = 0; i < damageArrayHandler->GetNumTypes(); ++i) { + } else { + for (int i = 0; i < damageArrayHandler->GetNumTypes(); ++i) { dynDamages[i] = damageMod * damages[i]; - if (damageMin > 0) + if (damageMin > 0.0f) dynDamages[i] = std::max(damages[i] * ddmod, dynDamages[i]); // div by 0 dynDamages[i] = std::max(0.0001f, dynDamages[i]); } } + return dynDamages; } diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/WeaponDefHandler.h spring-98.0~14.04~ppa6/rts/Sim/Weapons/WeaponDefHandler.h --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/WeaponDefHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/WeaponDefHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -24,9 +24,7 @@ const WeaponDef* GetWeaponDef(std::string weaponname) const; const WeaponDef* GetWeaponDefByID(int weaponDefId) const; - static DamageArray DynamicDamages(const DamageArray& damages, const float3 startPos, - const float3 curPos, const float range, const float exp, - const float damageMin, const bool inverted); + static DamageArray DynamicDamages(const WeaponDef* weaponDef, const float3 startPos, const float3 curPos); public: std::vector weaponDefs; diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/Weapon.h spring-98.0~14.04~ppa6/rts/Sim/Weapons/Weapon.h --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/Weapon.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/Weapon.h 2014-10-07 20:09:51.000000000 +0000 @@ -7,10 +7,11 @@ #include "System/Object.h" #include "Sim/Misc/DamageArray.h" -#include "Sim/Projectiles/WeaponProjectiles/WeaponProjectile.h" +#include "Sim/Projectiles/ProjectileParams.h" #include "System/float3.h" class CUnit; +class CWeaponProjectile; struct WeaponDef; enum TargetType { @@ -22,7 +23,7 @@ class CWeapon : public CObject { - CR_DECLARE(CWeapon); + CR_DECLARE(CWeapon) public: CWeapon(CUnit* owner, const WeaponDef* def); virtual ~CWeapon(); @@ -73,11 +74,11 @@ void Fire(bool scriptCall); void HoldFire(); - float ExperienceScale() const; - float AccuracyExperience() const { return (accuracy * ExperienceScale()); } - float SprayAngleExperience() const { return (sprayAngle * ExperienceScale()); } - float3 SalvoErrorExperience() const { return (salvoError * ExperienceScale()); } + float ExperienceErrorScale() const; float MoveErrorExperience() const; + float AccuracyExperience() const { return (accuracyError * ExperienceErrorScale()); } + float SprayAngleExperience() const { return (sprayAngle * ExperienceErrorScale()); } + float3 SalvoErrorExperience() const { return (salvoError * ExperienceErrorScale()); } void StopAttackingAllyTeam(int ally); void UpdateInterceptTarget(); @@ -123,7 +124,7 @@ float heightMod; // how much extra range the weapon gain per height difference float projectileSpeed; - float accuracy; // inaccuracy of whole salvo + float accuracyError; // inaccuracy of whole salvo float sprayAngle; // inaccuracy of individual shots inside salvo int salvoDelay; // delay between shots in a salvo diff -Nru spring-96.0~14.04~ppa4/rts/Sim/Weapons/WeaponLoader.cpp spring-98.0~14.04~ppa6/rts/Sim/Weapons/WeaponLoader.cpp --- spring-96.0~14.04~ppa4/rts/Sim/Weapons/WeaponLoader.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/Sim/Weapons/WeaponLoader.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -115,7 +115,7 @@ weapon->damageAreaOfEffect = weaponDef->damageAreaOfEffect; weapon->craterAreaOfEffect = weaponDef->craterAreaOfEffect; - weapon->accuracy = weaponDef->accuracy; + weapon->accuracyError = weaponDef->accuracy; weapon->sprayAngle = weaponDef->sprayAngle; weapon->stockpileTime = int(weaponDef->stockpileTime * GAME_SPEED); Binary files /tmp/IxIUFi0MJo/spring-96.0~14.04~ppa4/rts/spring.ico and /tmp/wvabDhzUKy/spring-98.0~14.04~ppa6/rts/spring.ico differ Binary files /tmp/IxIUFi0MJo/spring-96.0~14.04~ppa4/rts/spring.new.ico and /tmp/wvabDhzUKy/spring-98.0~14.04~ppa6/rts/spring.new.ico differ diff -Nru spring-96.0~14.04~ppa4/rts/System/bitops.h spring-98.0~14.04~ppa6/rts/System/bitops.h --- spring-96.0~14.04~ppa4/rts/System/bitops.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/bitops.h 2014-10-07 20:09:51.000000000 +0000 @@ -63,13 +63,13 @@ /** * quote from GCC doc "Returns one plus the index of the least significant 1-bit of x, or if x is zero, returns zero." */ -static inline int bits_ffs(unsigned int x) +static inline unsigned bits_ffs(unsigned int x) { #ifdef __GNUC__ return __builtin_ffs(x); #else if (x == 0) return 0; - int i = 1; + unsigned i = 1; while (!(x & 0x1)) { x = x >> 1; ++i; @@ -78,6 +78,8 @@ #endif } + + /** * @brief Make even number macro * @param n Number to make even diff -Nru spring-96.0~14.04~ppa4/rts/System/CMakeLists.txt spring-98.0~14.04~ppa6/rts/System/CMakeLists.txt --- spring-96.0~14.04~ppa4/rts/System/CMakeLists.txt 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -2,7 +2,7 @@ # This list was created using this *nix shell command: # > find . -name "*.cpp" -or -name "*.c" | sort # Then Sound/ stuff was removed, because it is now a separate static lib. -SET(sources_engine_System_common +MakeGlobalVar(sources_engine_System_common "${CMAKE_CURRENT_SOURCE_DIR}/AIScriptHandler.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Config/ConfigHandler.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Config/ConfigLocater.cpp" @@ -35,10 +35,12 @@ "${CMAKE_CURRENT_SOURCE_DIR}/Option.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Platform/Clipboard.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Platform/CmdLineParams.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/Platform/CpuID.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Platform/errorhandler.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Platform/Misc.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Platform/SharedLib.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Platform/ScopedFileLock.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/Platform/SDL1_keysym.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Platform/Threading.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Platform/Watchdog.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Platform/WindowManagerHelper.cpp" @@ -61,19 +63,22 @@ "${CMAKE_CURRENT_SOURCE_DIR}/TimeProfiler.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/TimeUtil.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/UnsyncedRNG.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/UriParser.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Util.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/type2.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/float3.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/float4.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/myMath.cpp" ) -SET(sources_engine_System_creg + + +MakeGlobalVar(sources_engine_System_creg "${CMAKE_CURRENT_SOURCE_DIR}/creg/Serializer.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/creg/VarTypes.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/creg/creg.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/creg/creg_runtime_tests.cpp" ) -SET(sources_engine_System_FileSystem +MakeGlobalVar(sources_engine_System_FileSystem "${CMAKE_CURRENT_SOURCE_DIR}/FileSystem/ArchiveLoader.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/FileSystem/ArchiveScanner.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/FileSystem/CacheDir.cpp" @@ -86,8 +91,9 @@ "${CMAKE_CURRENT_SOURCE_DIR}/FileSystem/FileSystemInitializer.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/FileSystem/SimpleParser.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/FileSystem/VFSHandler.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/FileSystem/RapidHandler.cpp" ) -SET(sources_engine_System_Log +MakeGlobalVar(sources_engine_System_Log "${CMAKE_CURRENT_SOURCE_DIR}/Log/Backend.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Log/DefaultFilter.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Log/DefaultFormatter.cpp" @@ -95,43 +101,44 @@ "${CMAKE_CURRENT_SOURCE_DIR}/Log/LogSinkHandler.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Log/LogUtil.c" ) -SET(sources_engine_System_Log_sinkStream +MakeGlobalVar(sources_engine_System_Log_sinkStream "${CMAKE_CURRENT_SOURCE_DIR}/Log/StreamSink.cpp" ) -SET(sources_engine_System_Log_sinkConsole +MakeGlobalVar(sources_engine_System_Log_sinkConsole "${CMAKE_CURRENT_SOURCE_DIR}/Log/ConsoleSink.cpp" ) -SET(sources_engine_System_Log_sinkFile +MakeGlobalVar(sources_engine_System_Log_sinkFile "${CMAKE_CURRENT_SOURCE_DIR}/Log/FileSink.cpp" ) -SET(sources_engine_System_Log_sinkOutputDebugString +MakeGlobalVar(sources_engine_System_Log_sinkOutputDebugString "${CMAKE_CURRENT_SOURCE_DIR}/Log/OutputDebugStringSink.cpp" ) -SET(sources_engine_System_Platform_Linux +MakeGlobalVar(sources_engine_System_Platform_Linux "${CMAKE_CURRENT_SOURCE_DIR}/Platform/Linux/CrashHandler.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/Platform/Linux/myX11.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Platform/Linux/SoLib.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Platform/Linux/thread_backtrace.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Platform/Linux/MessageBox.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/Platform/Linux/WindowManagerHelper.cpp" ) -SET(sources_engine_System_Platform_Mac +MakeGlobalVar(sources_engine_System_Platform_Mac "${CMAKE_CURRENT_SOURCE_DIR}/Platform/Linux/SoLib.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Platform/Mac/MessageBox.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Platform/Mac/CrashHandler.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Platform/Linux/thread_backtrace.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/Platform/Mac/WindowManagerHelper.cpp" ) -SET(sources_engine_System_Platform_Windows +MakeGlobalVar(sources_engine_System_Platform_Windows "${CMAKE_CURRENT_SOURCE_DIR}/Platform/Win/CrashHandler.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Platform/Win/DllLib.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Platform/Win/MessageBox.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Platform/Win/seh.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Platform/Win/WinVersion.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/Platform/Win/wsdl.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/Platform/Win/WindowManagerHelper.cpp" ) ### only use the target platform related directory IF (APPLE) - SET(sources_engine_System + MakeGlobalVar(sources_engine_System ${sources_engine_System_common} ${sources_engine_System_creg} ${sources_engine_System_FileSystem} @@ -141,7 +148,7 @@ ${sources_engine_System_Platform_Mac} ) ELSEIF (UNIX) - SET(sources_engine_System + MakeGlobalVar(sources_engine_System ${sources_engine_System_common} ${sources_engine_System_creg} ${sources_engine_System_FileSystem} @@ -151,7 +158,7 @@ ${sources_engine_System_Platform_Linux} ) ELSEIF (WIN32) - SET(sources_engine_System + MakeGlobalVar(sources_engine_System ${sources_engine_System_common} ${sources_engine_System_creg} ${sources_engine_System_FileSystem} @@ -162,7 +169,7 @@ ${sources_engine_System_Platform_Windows} ) ELSE () - SET(sources_engine_System + MakeGlobalVar(sources_engine_System ${sources_engine_System_common} ${sources_engine_System_creg} ${sources_engine_System_FileSystem} @@ -172,17 +179,5 @@ ) ENDIF () -MakeGlobal(sources_engine_System_common) -MakeGlobal(sources_engine_System_creg) -MakeGlobal(sources_engine_System_FileSystem) -MakeGlobal(sources_engine_System_Log) -MakeGlobal(sources_engine_System_Log_sinkStream) -MakeGlobal(sources_engine_System_Log_sinkConsole) -MakeGlobal(sources_engine_System_Log_sinkFile) -MakeGlobal(sources_engine_System_Log_sinkOutputDebugString) -MakeGlobal(sources_engine_System_Platform_Linux) -MakeGlobal(sources_engine_System_Platform_Mac) -MakeGlobal(sources_engine_System_Platform_Windows) -MakeGlobal(sources_engine_System) Add_Subdirectory(FileSystem) Add_Subdirectory(Net) diff -Nru spring-96.0~14.04~ppa4/rts/System/Color.h spring-98.0~14.04~ppa6/rts/System/Color.h --- spring-96.0~14.04~ppa4/rts/System/Color.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Color.h 2014-10-07 20:09:51.000000000 +0000 @@ -23,6 +23,18 @@ , b((unsigned char)(b * 255.0f)) , a((unsigned char)(a * 255.0f)) {} + SColor(const float* f) + : r(f[0] * 255.0f) + , g(f[1] * 255.0f) + , b(f[2] * 255.0f) + , a(f[3] * 255.0f) + {} + SColor(const unsigned char* u) + : r(u[0]) + , g(u[1]) + , b(u[2]) + , a(u[3]) + {} /// individual color channel values in the range [0, 255] struct { boost::uint8_t r, g, b, a; }; diff -Nru spring-96.0~14.04~ppa4/rts/System/Config/ConfigHandler.cpp spring-98.0~14.04~ppa6/rts/System/Config/ConfigHandler.cpp --- spring-96.0~14.04~ppa4/rts/System/Config/ConfigHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Config/ConfigHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -28,6 +28,7 @@ ConfigHandler* configHandler = NULL; + /******************************************************************************/ class ConfigHandlerImpl : public ConfigHandler @@ -47,18 +48,28 @@ void EnableWriting(bool write) { writingEnabled = write; } protected: - void AddObserver(ConfigNotifyCallback observer); + struct NamedConfigNotifyCallback { + NamedConfigNotifyCallback(ConfigNotifyCallback c, void* h) + : callback(c) + , holder(h) + {} + ConfigNotifyCallback callback; + void* holder; + }; + +protected: + void AddObserver(ConfigNotifyCallback observer, void* holder); + void RemoveObserver(void* holder); private: void RemoveDefaults(); OverlayConfigSource* overlay; FileConfigSource* writableSource; - DefaultConfigSource* defaultSource; vector sources; // observer related - list observers; + list observers; boost::mutex observerMutex; StringMap changedValues; bool writingEnabled; @@ -114,6 +125,7 @@ ConfigHandlerImpl::~ConfigHandlerImpl() { + assert(observers.empty()); //all observers have to be deregistered by RemoveObserver() for_each_source(it) { delete (*it); } @@ -133,6 +145,7 @@ void ConfigHandlerImpl::RemoveDefaults() { StringMap defaults = sources.back()->GetData(); + vector::const_reverse_iterator rsource = sources.rbegin(); for (; rsource != sources.rend(); ++rsource) { FileConfigSource* source = dynamic_cast (*rsource); @@ -271,8 +284,8 @@ for (StringMap::const_iterator ut = changedValues.begin(); ut != changedValues.end(); ++ut) { const string& key = ut->first; const string& value = ut->second; - for (list::const_iterator it = observers.begin(); it != observers.end(); ++it) { - (*it)(key, value); + for (list::const_iterator it = observers.begin(); it != observers.end(); ++it) { + (it->callback)(key, value); } } changedValues.clear(); @@ -292,11 +305,22 @@ return data; } -void ConfigHandlerImpl::AddObserver(ConfigNotifyCallback observer) { +void ConfigHandlerImpl::AddObserver(ConfigNotifyCallback observer, void* holder) { + boost::mutex::scoped_lock lck(observerMutex); + observers.emplace_back(observer, holder); +} + +void ConfigHandlerImpl::RemoveObserver(void* holder) { boost::mutex::scoped_lock lck(observerMutex); - observers.push_back(observer); + for (list::iterator it = observers.begin(); it != observers.end(); ++it) { + if (it->holder == holder) { + observers.erase(it); + return; + } + } } + /******************************************************************************/ void ConfigHandler::Instantiate(const std::string configSource, const bool safemode) diff -Nru spring-96.0~14.04~ppa4/rts/System/Config/ConfigHandler.h spring-98.0~14.04~ppa6/rts/System/Config/ConfigHandler.h --- spring-96.0~14.04~ppa4/rts/System/Config/ConfigHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Config/ConfigHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -51,8 +51,15 @@ void NotifyOnChange(T* observer) { // issues: still needs to call configHandler->Get() on startup, automate it - AddObserver(boost::bind(&T::ConfigNotify, observer, _1, _2)); - }; + AddObserver(boost::bind(&T::ConfigNotify, observer, _1, _2), (void*)observer); + } + + template + void RemoveObserver(T* observer) + { + RemoveObserver((void*)observer); + } + /// @see SetString template @@ -137,7 +144,8 @@ protected: typedef boost::function ConfigNotifyCallback; - virtual void AddObserver(ConfigNotifyCallback observer) = 0; + virtual void AddObserver(ConfigNotifyCallback observer, void* holder) = 0; + virtual void RemoveObserver(void* holder) = 0; private: /// @see GetString diff -Nru spring-96.0~14.04~ppa4/rts/System/Config/ConfigLocater.h spring-98.0~14.04~ppa6/rts/System/Config/ConfigLocater.h --- spring-96.0~14.04~ppa4/rts/System/Config/ConfigLocater.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Config/ConfigLocater.h 2014-10-07 20:09:51.000000000 +0000 @@ -11,6 +11,6 @@ * @brief Get the names of the default configuration files */ void GetDefaultLocations(std::vector& locations); -}; +} #endif // CONFIG_LOCATER_H diff -Nru spring-96.0~14.04~ppa4/rts/System/Config/ConfigSource.cpp spring-98.0~14.04~ppa6/rts/System/Config/ConfigSource.cpp --- spring-96.0~14.04~ppa4/rts/System/Config/ConfigSource.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Config/ConfigSource.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -156,7 +156,7 @@ } else { // neither a comment nor an empty line nor a key=value line - LOG_L(L_ERROR, "ConfigSource: Error: Can not parse line: %s\n", line); + LOG_L(L_ERROR, "ConfigSource: Error: Can not parse line: %s", line); } } } diff -Nru spring-96.0~14.04~ppa4/rts/System/CRC.cpp spring-98.0~14.04~ppa6/rts/System/CRC.cpp --- spring-96.0~14.04~ppa4/rts/System/CRC.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/CRC.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -4,7 +4,7 @@ extern "C" { #include "lib/7z/7zCrc.h" -}; +} static bool crcTableInitialized; @@ -28,6 +28,12 @@ } +unsigned int CRC::GetCRC(const void* data, unsigned int size) +{ + return CrcUpdate(0, data, size); +} + + CRC& CRC::Update(const void* data, unsigned int size) { crc = CrcUpdate(crc, data, size); diff -Nru spring-96.0~14.04~ppa4/rts/System/CRC.h spring-98.0~14.04~ppa6/rts/System/CRC.h --- spring-96.0~14.04~ppa4/rts/System/CRC.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/CRC.h 2014-10-07 20:09:51.000000000 +0000 @@ -22,6 +22,8 @@ /** @brief Get the final CRC digest. */ unsigned int GetDigest() const; + static unsigned int GetCRC(const void* data, unsigned int size); + /** @brief Update CRC over the data. */ CRC& Update(const void* data, unsigned int size); /** @brief Update CRC over the 4 bytes of data. */ diff -Nru spring-96.0~14.04~ppa4/rts/System/creg/creg.h spring-98.0~14.04~ppa6/rts/System/creg/creg.h --- spring-96.0~14.04~ppa4/rts/System/creg/creg.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/creg/creg.h 2014-10-07 20:09:51.000000000 +0000 @@ -27,7 +27,7 @@ crInt, crUInt, crShort, crUShort, crChar, crUChar, - crInt64, + crInt64, crUInt64, crFloat, crDouble, crBool, @@ -331,30 +331,13 @@ } size_t GetSize() { return size; } }; -}; +} #include "TypeDeduction.h" -// detect if c++11 -#if __cplusplus <= 199711L - template - size_t alignof_() { - return (sizeof(t) > sizeof(int*)) ? sizeof(int*) : sizeof(t); - } - #define alignof(t) alignof_() - template - size_t alignofv(const T& v) { - return alignof(T); - } - - template - size_t alignofv(T& v) { - return alignof(T); - } -#else - #define alignofv(v) alignof(v) -#endif +//FIXME: defined cause gcc4.8 still doesn't support c++11's offsetof for non-static members +#define offsetof_creg(type, member) (std::size_t)(((char*)&null->member) - ((char*)null)) namespace creg { @@ -500,7 +483,7 @@ Type::memberRegistrator=this; \ } \ void RegisterMembers(creg::Class* class_) { \ - TClass* null=(Type*)0; \ + Type* null=nullptr; \ (void)null; /*suppress compiler warning if this isn't used*/ \ Members; } \ } static TClass##mreg; @@ -515,9 +498,10 @@ TSubClass##MemberRegistrator() { \ Type::memberRegistrator=this; \ } \ - void RegisterMembers(creg::Class* class_) { \ - Type* null=(Type*)0; \ - Members; } \ + void RegisterMembers(creg::Class* class_) { \ + Type* null=nullptr; \ + (void)null; \ + Members; } \ } static TSuperClass##TSubClass##mreg; /** @def CR_MEMBER @@ -537,19 +521,19 @@ * For enumerated type members, @see CR_ENUM_MEMBER */ #define CR_MEMBER(Member) \ - class_->AddMember( #Member, creg::GetType(null->Member), (unsigned int)(((char*)&null->Member)-((char*)0)), alignofv(null->Member)) + class_->AddMember( #Member, creg::GetType(null->Member), offsetof_creg(Type, Member), alignof(decltype(Type::Member))) /** @def CR_ENUM_MEMBER * Registers a class/struct member variable with an enumerated type */ #define CR_ENUM_MEMBER(Member) \ - class_->AddMember( #Member, creg::IType::CreateEnumeratedType(sizeof(null->Member)), (unsigned int)(((char*)&null->Member)-((char*)0)), alignofv(null->Member)) + class_->AddMember( #Member, creg::IType::CreateEnumeratedType(sizeof(Type::Member)), offsetof_creg(Type, Member), alignof(decltype(Type::Member))) /** @def CR_IGNORED * Registers a member variable that isn't saved/loaded */ #define CR_IGNORED(Member) \ - class_->AddMember( #Member, new creg::IgnoredType(sizeof(null->Member)), (unsigned int)(((char*)&null->Member)-((char*)0)), alignofv(null->Member)) + class_->AddMember( #Member, new creg::IgnoredType(sizeof(Type::Member)), offsetof_creg(Type, Member), alignof(decltype(Type::Member))) /** @def CR_MEMBER_UN @@ -630,6 +614,6 @@ */ #define CR_POSTLOAD(PostLoadFunc) \ (class_->postLoadProc = (void(creg::_DummyStruct::*)())&Type::PostLoadFunc) -}; +} #endif // _CREG_H diff -Nru spring-96.0~14.04~ppa4/rts/System/creg/creg_runtime_tests.cpp spring-98.0~14.04~ppa6/rts/System/creg/creg_runtime_tests.cpp --- spring-96.0~14.04~ppa4/rts/System/creg/creg_runtime_tests.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/creg/creg_runtime_tests.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -111,7 +111,7 @@ if (cregSize != classSize) { brokenClasses++; - LOG_L(L_WARNING, " Missing member(s) in class %s, real size %u, creg size %u", className.c_str(), classSize, cregSize); + LOG_L(L_WARNING, " Missing member(s) in class %s, real size %i, creg size %i", className.c_str(), int(classSize), int(cregSize)); /*for (std::vector::const_iterator jt = classMembers.begin(); jt != classMembers.end(); ++jt) { const std::string memberName = (*jt)->name; const size_t memberOffset = (*jt)->offset; @@ -317,4 +317,4 @@ res &= TestCregClasses4(); return res; } -}; +} diff -Nru spring-96.0~14.04~ppa4/rts/System/creg/creg_runtime_tests.h spring-98.0~14.04~ppa6/rts/System/creg/creg_runtime_tests.h --- spring-96.0~14.04~ppa4/rts/System/creg/creg_runtime_tests.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/creg/creg_runtime_tests.h 2014-10-07 20:09:51.000000000 +0000 @@ -5,7 +5,7 @@ namespace creg { bool RuntimeTest(); -}; +} #endif // _CREG_RUNTIME_TESTS_H diff -Nru spring-96.0~14.04~ppa4/rts/System/creg/Serializer.cpp spring-98.0~14.04~ppa6/rts/System/creg/Serializer.cpp --- spring-96.0~14.04~ppa4/rts/System/creg/Serializer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/creg/Serializer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -417,8 +417,8 @@ stream->write((const char*)&ph, sizeof(PackageHeader)); LOG_SL(LOG_SECTION_CREG_SERIALIZER, L_DEBUG, - "Checksum: %X\nNumber of objects saved: %d\nNumber of classes involved: %d", - ph.metadataChecksum, objects.size(), classRefs.size()); + "Checksum: %X\nNumber of objects saved: %i\nNumber of classes involved: %i", + ph.metadataChecksum, int(objects.size()), int(classRefs.size())); stream->seekp(endOffset); ptrToId.clear(); @@ -660,8 +660,8 @@ rootCls = classRefs[objects[1].classRef]; LOG_SL(LOG_SECTION_CREG_SERIALIZER, L_DEBUG, - "SaveGame loaded.\nNumber of objects loaded: %d\nNumber of classes involved: %d\n", - objects.size(), classRefs.size()); + "SaveGame loaded.\nNumber of objects loaded: %i\nNumber of classes involved: %i\n", + int(objects.size()), int(classRefs.size())); s->seekg(endOffset); unfixedPointers.clear(); diff -Nru spring-96.0~14.04~ppa4/rts/System/creg/Serializer.h spring-98.0~14.04~ppa6/rts/System/creg/Serializer.h --- spring-96.0~14.04~ppa4/rts/System/creg/Serializer.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/creg/Serializer.h 2014-10-07 20:09:51.000000000 +0000 @@ -183,7 +183,7 @@ void LoadPackage(std::istream* s, void*& root, Class*& rootCls); }; -}; +} #endif diff -Nru spring-96.0~14.04~ppa4/rts/System/creg/STL_Deque.h spring-98.0~14.04~ppa6/rts/System/creg/STL_Deque.h --- spring-96.0~14.04~ppa4/rts/System/creg/STL_Deque.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/creg/STL_Deque.h 2014-10-07 20:09:51.000000000 +0000 @@ -19,7 +19,7 @@ return boost::shared_ptr(new DynamicArrayType< std::deque >(elemtype.Get())); } }; -}; +} #endif // USING_CREG diff -Nru spring-96.0~14.04~ppa4/rts/System/creg/STL_List.h spring-98.0~14.04~ppa6/rts/System/creg/STL_List.h --- spring-96.0~14.04~ppa4/rts/System/creg/STL_List.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/creg/STL_List.h 2014-10-07 20:09:51.000000000 +0000 @@ -52,7 +52,7 @@ return boost::shared_ptr(new ListType< std::list >(elemtype.Get())); } }; -}; +} #endif // USING_CREG diff -Nru spring-96.0~14.04~ppa4/rts/System/creg/STL_Map.h spring-98.0~14.04~ppa6/rts/System/creg/STL_Map.h --- spring-96.0~14.04~ppa4/rts/System/creg/STL_Map.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/creg/STL_Map.h 2014-10-07 20:09:51.000000000 +0000 @@ -153,7 +153,7 @@ return boost::shared_ptr(new PairType >(first.Get(), second.Get())); } }; -}; +} #endif // USING_CREG diff -Nru spring-96.0~14.04~ppa4/rts/System/creg/STL_Set.h spring-98.0~14.04~ppa6/rts/System/creg/STL_Set.h --- spring-96.0~14.04~ppa4/rts/System/creg/STL_Set.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/creg/STL_Set.h 2014-10-07 20:09:51.000000000 +0000 @@ -92,7 +92,7 @@ return boost::shared_ptr(new SetType >(elemtype.Get())); } }; -}; +} #endif // USING_CREG diff -Nru spring-96.0~14.04~ppa4/rts/System/creg/TypeDeduction.h spring-98.0~14.04~ppa6/rts/System/creg/TypeDeduction.h --- spring-96.0~14.04~ppa4/rts/System/creg/TypeDeduction.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/creg/TypeDeduction.h 2014-10-07 20:09:51.000000000 +0000 @@ -34,14 +34,14 @@ enum {Yes=1, No=0 }; \ }; -CREG_SUPPORT_BASIC_TYPE(boost::int64_t, crInt64) CREG_SUPPORT_BASIC_TYPE(int, crInt) CREG_SUPPORT_BASIC_TYPE(unsigned int, crUInt) CREG_SUPPORT_BASIC_TYPE(short, crShort) CREG_SUPPORT_BASIC_TYPE(unsigned short, crUShort) CREG_SUPPORT_BASIC_TYPE(char, crChar) CREG_SUPPORT_BASIC_TYPE(unsigned char, crUChar) -CREG_SUPPORT_BASIC_TYPE(unsigned long, crUInt) +CREG_SUPPORT_BASIC_TYPE(boost::int64_t, crInt64) +CREG_SUPPORT_BASIC_TYPE(boost::uint64_t, crUInt64) CREG_SUPPORT_BASIC_TYPE(float, crFloat) CREG_SUPPORT_BASIC_TYPE(double, crDouble) CREG_SUPPORT_BASIC_TYPE(bool, crBool) @@ -125,7 +125,7 @@ DeduceType deduce; return deduce.Get(); } -}; +} #endif // _TYPE_DEDUCTION_H diff -Nru spring-96.0~14.04~ppa4/rts/System/creg/VarTypes.cpp spring-98.0~14.04~ppa6/rts/System/creg/VarTypes.cpp --- spring-96.0~14.04~ppa4/rts/System/creg/VarTypes.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/creg/VarTypes.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -44,6 +44,7 @@ case crChar: return "char"; case crUChar: return "uchar"; case crInt64: return "int64"; + case crUInt64: return "uint64"; case crFloat: return "float"; case crDouble: return "double"; case crBool: return "bool"; @@ -72,6 +73,7 @@ case crChar: return sizeof(char); case crUChar: return sizeof(unsigned char); case crInt64: return sizeof(boost::int64_t); + case crUInt64: return sizeof(boost::uint64_t); case crFloat: return sizeof(float); case crDouble: return sizeof(double); case crBool: return sizeof(bool); diff -Nru spring-96.0~14.04~ppa4/rts/System/creg/VarTypes.h spring-98.0~14.04~ppa6/rts/System/creg/VarTypes.h --- spring-96.0~14.04~ppa4/rts/System/creg/VarTypes.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/creg/VarTypes.h 2014-10-07 20:09:51.000000000 +0000 @@ -45,7 +45,7 @@ size_t GetSize(); }; -}; +} #endif diff -Nru spring-96.0~14.04~ppa4/rts/System/EventBatchHandler.cpp spring-98.0~14.04~ppa6/rts/System/EventBatchHandler.cpp --- spring-96.0~14.04~ppa4/rts/System/EventBatchHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/EventBatchHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -10,12 +10,66 @@ #include "Rendering/ProjectileDrawer.h" #endif -#include "lib/gml/gmlcnf.h" #include "Rendering/Textures/S3OTextureHandler.h" #include "System/Platform/Threading.h" +EventBatchHandler* EventBatchHandler::ebh = nullptr; boost::int64_t EventBatchHandler::eventSequenceNumber = 0; + +EventBatchHandler::EventBatchHandler() + : CEventClient("[EventBatchHandler]", 0, true) +{ + autoLinkEvents = true; + RegisterLinkedEvents(this); + eventHandler.AddClient(this); +} + + +void EventBatchHandler::CreateInstance() +{ + ebh = new EventBatchHandler(); +} + + +void EventBatchHandler::DeleteInstance() +{ + delete ebh; + ebh = nullptr; +} + +void EventBatchHandler::UnitMoved(const CUnit* unit) { EnqueueUnitMovedEvent(unit, unit->pos); } +void EventBatchHandler::UnitEnteredRadar(const CUnit* unit, int at) { EnqueueUnitLOSStateChangeEvent(unit, at, unit->losStatus[at]); } +void EventBatchHandler::UnitEnteredLos(const CUnit* unit, int at) { EnqueueUnitLOSStateChangeEvent(unit, at, unit->losStatus[at]); } +void EventBatchHandler::UnitLeftRadar(const CUnit* unit, int at) { EnqueueUnitLOSStateChangeEvent(unit, at, unit->losStatus[at]); } +void EventBatchHandler::UnitLeftLos(const CUnit* unit, int at) { EnqueueUnitLOSStateChangeEvent(unit, at, unit->losStatus[at]); } +void EventBatchHandler::UnitCloaked(const CUnit* unit) { EnqueueUnitCloakStateChangeEvent(unit, 1); } +void EventBatchHandler::UnitDecloaked(const CUnit* unit) { EnqueueUnitCloakStateChangeEvent(unit, 0); } + +void EventBatchHandler::FeatureCreated(const CFeature* feature) { GetFeatureCreatedDestroyedEventBatch().enqueue(feature); } +void EventBatchHandler::FeatureDestroyed(const CFeature* feature) { GetFeatureCreatedDestroyedEventBatch().dequeue(feature); } +void EventBatchHandler::FeatureMoved(const CFeature* feature, const float3& oldpos) { EnqueueFeatureMovedEvent(feature, oldpos, feature->pos); } +void EventBatchHandler::ProjectileCreated(const CProjectile* proj) +{ + if (proj->synced) { + GetSyncedProjectileCreatedDestroyedBatch().insert(proj); + } else { + GetUnsyncedProjectileCreatedDestroyedBatch().insert(proj); + } +} +void EventBatchHandler::ProjectileDestroyed(const CProjectile* proj) +{ + if (proj->synced) { + GetSyncedProjectileCreatedDestroyedBatch().erase_delete(proj); + } else { + GetUnsyncedProjectileCreatedDestroyedBatch().erase_delete(proj); + } +} + + + + + void EventBatchHandler::ProjectileCreatedDestroyedEvent::Add(const CProjectile* p) { eventHandler.RenderProjectileCreated(p); } void EventBatchHandler::ProjectileCreatedDestroyedEvent::Remove(const CProjectile* p) { eventHandler.RenderProjectileDestroyed(p); } void EventBatchHandler::ProjectileCreatedDestroyedEvent::Delete(const CProjectile* p) { delete p; } @@ -37,10 +91,7 @@ void EventBatchHandler::FeatureCreatedDestroyedEvent::Remove(const CFeature* f) { eventHandler.RenderFeatureDestroyed(f); } void EventBatchHandler::FeatureMovedEvent::Add(const FAP& f) { eventHandler.RenderFeatureMoved(f.feat, f.oldpos, f.newpos); } -EventBatchHandler* EventBatchHandler::GetInstance() { - static EventBatchHandler ebh; - return &ebh; -} + void EventBatchHandler::UpdateUnits() { unitCreatedDestroyedEventBatch.delay(); @@ -49,8 +100,6 @@ unitMovedEventBatch.delay(); } void EventBatchHandler::UpdateDrawUnits() { - GML_STDMUTEX_LOCK(runit); // UpdateDrawUnits - unitCreatedDestroyedEventBatch.execute(); unitCloakStateChangedEventBatch.execute(); unitLOSStateChangedEventBatch.execute(); @@ -72,8 +121,6 @@ featureMovedEventBatch.delay(); } void EventBatchHandler::UpdateDrawFeatures() { - GML_STDMUTEX_LOCK(rfeat); // UpdateDrawFeatures - featureCreatedDestroyedEventBatch.execute(); featureMovedEventBatch.execute(); } @@ -91,8 +138,6 @@ unsyncedProjectileCreatedDestroyedEventBatch.delay_add(); } void EventBatchHandler::UpdateDrawProjectiles() { - GML_STDMUTEX_LOCK(rproj); // UpdateDrawProjectiles - projectileHandler->GetSyncedRenderProjectileIDs().delete_delayed(); syncedProjectileCreatedDestroyedEventBatch.delete_delayed(); @@ -112,25 +157,10 @@ } void EventBatchHandler::UpdateObjects() { - { - GML_STDMUTEX_LOCK(runit); // UpdateObjects - - UpdateUnits(); - } - { - GML_STDMUTEX_LOCK(rfeat); // UpdateObjects - - UpdateFeatures(); - } - { - GML_STDMUTEX_LOCK(rproj); // UpdateObjects - - UpdateProjectiles(); - } + UpdateUnits(); + UpdateFeatures(); + UpdateProjectiles(); } void EventBatchHandler::LoadedModelRequested() { - // Make sure the requested model is available to the calling thread - if (GML::SimEnabled() && GML::ShareLists() && !GML::IsSimThread()) - texturehandlerS3O->UpdateDraw(); } diff -Nru spring-96.0~14.04~ppa4/rts/System/EventBatchHandler.h spring-98.0~14.04~ppa6/rts/System/EventBatchHandler.h --- spring-96.0~14.04~ppa4/rts/System/EventBatchHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/EventBatchHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -3,6 +3,7 @@ #ifndef EVENT_BATCH_HANDLER_HDR #define EVENT_BATCH_HANDLER_HDR +#include "EventClient.h" #include "lib/gml/ThreadSafeContainers.h" #include "Sim/Projectiles/ProjectileHandler.h" // for UNSYNCED_PROJ_NOEVENT @@ -10,10 +11,43 @@ class CFeature; class CProjectile; -struct EventBatchHandler { +class EventBatchHandler : public CEventClient { +public: // EventClient + bool GetFullRead() const { return true; } + int GetReadAllyTeam() const { return CEventClient::AllAccessTeam; } + + void UnitMoved(const CUnit* unit); + void UnitEnteredRadar(const CUnit* unit, int at); + void UnitEnteredLos(const CUnit* unit, int at); + void UnitLeftRadar(const CUnit* unit, int at); + void UnitLeftLos(const CUnit* unit, int at); + void UnitCloaked(const CUnit* unit); + void UnitDecloaked(const CUnit* unit); + + void FeatureCreated(const CFeature* feature); + void FeatureDestroyed(const CFeature* feature); + void FeatureMoved(const CFeature* feature, const float3& oldpos); + void ProjectileCreated(const CProjectile* proj); + void ProjectileDestroyed(const CProjectile* proj); + + //FIXME check them in EventHandler to see what needs to be fixed + //void UnsyncedProjectileCreated(const CProjectile* proj) + //void UnsyncedProjectileDestroyed(const CProjectile* proj) + //void LoadedModelRequested() + +public: + static EventBatchHandler* GetInstance() { assert(ebh); return ebh; } + static void CreateInstance(); + static void DeleteInstance(); + + EventBatchHandler(); + virtual ~EventBatchHandler() {} + private: + static EventBatchHandler* ebh; static boost::int64_t eventSequenceNumber; +private: struct ProjectileCreatedDestroyedEvent { static void Add(const CProjectile*); static void Remove(const CProjectile*); @@ -167,8 +201,6 @@ FeatureMovedEventBatch featureMovedEventBatch; public: - static EventBatchHandler* GetInstance(); - void UpdateUnits(); void UpdateDrawUnits(); void DeleteSyncedUnits(); diff -Nru spring-96.0~14.04~ppa4/rts/System/EventClient.cpp spring-98.0~14.04~ppa6/rts/System/EventClient.cpp --- spring-96.0~14.04~ppa4/rts/System/EventClient.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/EventClient.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -11,6 +11,7 @@ : name(_name) , order(_order) , synced_(_synced) + , autoLinkEvents(false) { // Note: virtual functions aren't available in the ctor! //RegisterLinkedEvents(this); @@ -19,13 +20,81 @@ CEventClient::~CEventClient() { - //! No, we can't autobind all clients in the ctor. - //! eventHandler.AddClient() calls CEventClient::WantsEvent() that is - //! virtual and so not available during the initialization. + // No, we can't autobind all clients in the ctor. + // eventHandler.AddClient() calls CEventClient::WantsEvent() that is + // virtual and so not available during the initialization. eventHandler.RemoveClient(this); } +bool CEventClient::WantsEvent(const std::string& eventName) +{ + if (!autoLinkEvents) + return false; + + assert(!autoLinkedEvents.empty()); + + if (autoLinkedEvents[eventName]) { + //LOG("\"%s\" autolinks \"%s\"", GetName().c_str(), eventName.c_str()); + return true; + } + + return false; +} + + +/******************************************************************************/ +/******************************************************************************/ +// +// Synced +// + +bool CEventClient::CommandFallback(const CUnit* unit, const Command& cmd) { return false; } +bool CEventClient::AllowCommand(const CUnit* unit, const Command& cmd, bool fromSynced) { return true; } + +bool CEventClient::AllowUnitCreation(const UnitDef* unitDef, const CUnit* builder, const BuildInfo* buildInfo) { return true; } +bool CEventClient::AllowUnitTransfer(const CUnit* unit, int newTeam, bool capture) { return true; } +bool CEventClient::AllowUnitBuildStep(const CUnit* builder, const CUnit* unit, float part) { return true; } +bool CEventClient::AllowFeatureCreation(const FeatureDef* featureDef, int allyTeamID, const float3& pos) { return true; } +bool CEventClient::AllowFeatureBuildStep(const CUnit* builder, const CFeature* feature, float part) { return true; } +bool CEventClient::AllowResourceLevel(int teamID, const string& type, float level) { return true; } +bool CEventClient::AllowResourceTransfer(int oldTeam, int newTeam, const string& type, float amount) { return true; } +bool CEventClient::AllowDirectUnitControl(int playerID, const CUnit* unit) { return true; } +bool CEventClient::AllowBuilderHoldFire(const CUnit* unit, int action) { return true; } +bool CEventClient::AllowStartPosition(int playerID, unsigned char readyState, const float3& clampedPos, const float3& rawPickPos) { return true; } + +bool CEventClient::TerraformComplete(const CUnit* unit, const CUnit* build) { return false; } +bool CEventClient::MoveCtrlNotify(const CUnit* unit, int data) { return false; } + +int CEventClient::AllowWeaponTargetCheck(unsigned int attackerID, unsigned int attackerWeaponNum, unsigned int attackerWeaponDefID) { return -1; } +bool CEventClient::AllowWeaponTarget( + unsigned int attackerID, + unsigned int targetID, + unsigned int attackerWeaponNum, + unsigned int attackerWeaponDefID, + float* targetPriority +) { return true; } +bool CEventClient::AllowWeaponInterceptTarget(const CUnit* interceptorUnit, const CWeapon* interceptorWeapon, const CProjectile* interceptorTarget) { return true; } +bool CEventClient::UnitPreDamaged( + const CUnit* unit, + const CUnit* attacker, + float damage, + int weaponDefID, + int projectileID, + bool paralyzer, + float* newDamage, + float* impulseMult) { return false; } +bool CEventClient::FeaturePreDamaged( + const CFeature* feature, + const CUnit* attacker, + float damage, + int weaponDefID, + int projectileID, + float* newDamage, + float* impulseMult) { return false; } +bool CEventClient::ShieldPreDamaged(const CProjectile*, const CWeapon*, const CUnit*, bool) { return false; } +bool CEventClient::SyncedActionFallback(const string& line, int playerID) { return false; } + /******************************************************************************/ /******************************************************************************/ // @@ -52,13 +121,28 @@ void CEventClient::DrawScreenEffects() {} void CEventClient::DrawScreen() {} void CEventClient::DrawInMiniMap() {} +void CEventClient::DrawInMiniMapBackground() {} + +bool CEventClient::DrawUnit(const CUnit* unit) { return false; } +bool CEventClient::DrawFeature(const CFeature* feature) { return false; } +bool CEventClient::DrawShield(const CUnit* unit, const CWeapon* weapon) { return false; } +bool CEventClient::DrawProjectile(const CProjectile* projectile) { return false; } + +void CEventClient::GameProgress(int gameFrame) {} + +void CEventClient::DrawLoadScreen() {} +void CEventClient::LoadProgress(const std::string& msg, const bool replace_lastline) {} + +void CEventClient::CollectGarbage() {} +void CEventClient::DbgTimingInfo(DbgTimingInfoType type, const spring_time start, const spring_time end) {} // from LuaUI -bool CEventClient::KeyPress(unsigned short key, bool isRepeat) { return false; } -bool CEventClient::KeyRelease(unsigned short key) { return false; } +bool CEventClient::KeyPress(int key, bool isRepeat) { return false; } +bool CEventClient::KeyRelease(int key) { return false; } +bool CEventClient::TextInput(const std::string& utf8) { return false; } bool CEventClient::MouseMove(int x, int y, int dx, int dy, int button) { return false; } bool CEventClient::MousePress(int x, int y, int button) { return false; } -int CEventClient::MouseRelease(int x, int y, int button) { return -1; } // FIXME - bool / void? +void CEventClient::MouseRelease(int x, int y, int button) { } bool CEventClient::MouseWheel(bool up, float value) { return false; } bool CEventClient::JoystickEvent(const std::string& event, int val1, int val2) { return false; } bool CEventClient::IsAbove(int x, int y) { return false; } diff -Nru spring-96.0~14.04~ppa4/rts/System/EventClient.h spring-98.0~14.04~ppa6/rts/System/EventClient.h --- spring-96.0~14.04~ppa4/rts/System/EventClient.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/EventClient.h 2014-10-07 20:09:51.000000000 +0000 @@ -3,10 +3,13 @@ #ifndef EVENT_CLIENT_H #define EVENT_CLIENT_H -#include "System/float3.h" #include #include #include +#include + +#include "System/float3.h" +#include "System/Misc/SpringTime.h" #ifdef __APPLE__ // defined in X11/X.h @@ -25,6 +28,9 @@ struct Command; class IArchive; struct SRectangle; +struct UnitDef; +struct BuildInfo; +struct FeatureDef; #ifndef zipFile // might be defined through zip.h already @@ -32,6 +38,15 @@ #endif +enum DbgTimingInfoType { + TIMING_VIDEO, + TIMING_SIM, + TIMING_GC, + TIMING_SWAP, + TIMING_UNSYNCED +}; + + class CEventClient { public: @@ -50,7 +65,7 @@ * Used by the eventHandler to register * call-ins when an EventClient is being added. */ - virtual bool WantsEvent(const std::string& eventName) = 0; + virtual bool WantsEvent(const std::string& eventName); // used by the eventHandler to route certain event types virtual int GetReadAllyTeam() const { return NoAccessTeam; } @@ -59,12 +74,35 @@ return (GetFullRead() || (GetReadAllyTeam() == allyTeam)); } + public: + friend class CEventHandler; + + typedef void (*eventFuncPtr)(); + + std::map autoLinkedEvents; + + template + void RegisterLinkedEvents(T* foo) { + // old way needed gcc's pmf extension to cast member functions + //autoLinkedEvents[#eventname] = (reinterpret_cast(&T::eventname) != reinterpret_cast(&CEventClient::eventname)); + + // new way, works everywhere + #define SETUP_EVENT(eventname, props) \ + autoLinkedEvents[#eventname] = (typeid(&T::eventname) != typeid(&CEventClient::eventname)); + + #include "Events.def" + #undef SETUP_EVENT + } + private: const std::string name; const int order; const bool synced_; protected: + bool autoLinkEvents; + + protected: CEventClient(const std::string& name, int order, bool synced); virtual ~CEventClient(); @@ -107,6 +145,7 @@ int projectileID, bool paralyzer) {} virtual void UnitExperience(const CUnit* unit, float oldExperience) {} + virtual void UnitHarvestStorageFull(const CUnit* unit) {} virtual void UnitSeismicPing(const CUnit* unit, int allyTeam, const float3& pos, float strength) {} @@ -145,7 +184,7 @@ float damage, int weaponDefID, int projectileID) {} - virtual void FeatureMoved(const CFeature* feature) {} + virtual void FeatureMoved(const CFeature* feature, const float3& oldpos) {} virtual void RenderFeatureCreated(const CFeature* feature) {} virtual void RenderFeatureDestroyed(const CFeature* feature) {} @@ -161,6 +200,56 @@ const CWeapon* weapon, int oldCount) {} virtual bool Explosion(int weaponID, int projectileID, const float3& pos, const CUnit* owner) { return false; } + + virtual bool CommandFallback(const CUnit* unit, const Command& cmd); + virtual bool AllowCommand(const CUnit* unit, const Command& cmd, bool fromSynced); + + virtual bool AllowUnitCreation(const UnitDef* unitDef, const CUnit* builder, const BuildInfo* buildInfo); + virtual bool AllowUnitTransfer(const CUnit* unit, int newTeam, bool capture); + virtual bool AllowUnitBuildStep(const CUnit* builder, const CUnit* unit, float part); + virtual bool AllowFeatureCreation(const FeatureDef* featureDef, int allyTeamID, const float3& pos); + virtual bool AllowFeatureBuildStep(const CUnit* builder, const CFeature* feature, float part); + virtual bool AllowResourceLevel(int teamID, const string& type, float level); + virtual bool AllowResourceTransfer(int oldTeam, int newTeam, const string& type, float amount); + virtual bool AllowDirectUnitControl(int playerID, const CUnit* unit); + virtual bool AllowBuilderHoldFire(const CUnit* unit, int action); + virtual bool AllowStartPosition(int playerID, unsigned char readyState, const float3& clampedPos, const float3& rawPickPos); + + virtual bool TerraformComplete(const CUnit* unit, const CUnit* build); + virtual bool MoveCtrlNotify(const CUnit* unit, int data); + + virtual int AllowWeaponTargetCheck(unsigned int attackerID, unsigned int attackerWeaponNum, unsigned int attackerWeaponDefID); + virtual bool AllowWeaponTarget( + unsigned int attackerID, + unsigned int targetID, + unsigned int attackerWeaponNum, + unsigned int attackerWeaponDefID, + float* targetPriority + ); + virtual bool AllowWeaponInterceptTarget(const CUnit* interceptorUnit, const CWeapon* interceptorWeapon, const CProjectile* interceptorTarget); + + virtual bool UnitPreDamaged( + const CUnit* unit, + const CUnit* attacker, + float damage, + int weaponDefID, + int projectileID, + bool paralyzer, + float* newDamage, + float* impulseMult); + + virtual bool FeaturePreDamaged( + const CFeature* feature, + const CUnit* attacker, + float damage, + int weaponDefID, + int projectileID, + float* newDamage, + float* impulseMult); + + virtual bool ShieldPreDamaged(const CProjectile*, const CWeapon*, const CUnit*, bool); + + virtual bool SyncedActionFallback(const string& line, int playerID); /// @} /** @@ -172,11 +261,12 @@ virtual void Update(); virtual void UnsyncedHeightMapUpdate(const SRectangle& rect); - virtual bool KeyPress(unsigned short key, bool isRepeat); - virtual bool KeyRelease(unsigned short key); + virtual bool KeyPress(int key, bool isRepeat); + virtual bool KeyRelease(int key); + virtual bool TextInput(const std::string& utf8); virtual bool MouseMove(int x, int y, int dx, int dy, int button); virtual bool MousePress(int x, int y, int button); - virtual int MouseRelease(int x, int y, int button); // FIXME - bool / void? + virtual void MouseRelease(int x, int y, int button); virtual bool MouseWheel(bool up, float value); virtual bool JoystickEvent(const std::string& event, int val1, int val2); virtual bool IsAbove(int x, int y); @@ -217,13 +307,20 @@ virtual void DrawScreenEffects(); virtual void DrawScreen(); virtual void DrawInMiniMap(); + virtual void DrawInMiniMapBackground(); + + virtual bool DrawUnit(const CUnit* unit); + virtual bool DrawFeature(const CFeature* feature); + virtual bool DrawShield(const CUnit* unit, const CWeapon* weapon); + virtual bool DrawProjectile(const CProjectile* projectile); - virtual void GameProgress(int gameFrame) {} + virtual void GameProgress(int gameFrame); - virtual void DrawLoadScreen() {} - virtual void LoadProgress(const std::string& msg, const bool replace_lastline) {} + virtual void DrawLoadScreen(); + virtual void LoadProgress(const std::string& msg, const bool replace_lastline); - virtual void CollectGarbage() {} + virtual void CollectGarbage(); + virtual void DbgTimingInfo(DbgTimingInfoType type, const spring_time start, const spring_time end); /// @} }; diff -Nru spring-96.0~14.04~ppa4/rts/System/EventHandler.cpp spring-98.0~14.04~ppa6/rts/System/EventHandler.cpp --- spring-96.0~14.04~ppa4/rts/System/EventHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/EventHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,12 +1,10 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ #include "System/EventHandler.h" +#include "System/EventBatchHandler.h" #include "Lua/LuaCallInCheck.h" #include "Lua/LuaOpenGL.h" // FIXME -- should be moved -#include "Lua/LuaRules.h" -#include "Lua/LuaGaia.h" -#include "Lua/LuaUI.h" // FIXME -- should be moved #include "System/Config/ConfigHandler.h" #include "System/Platform/Threading.h" @@ -37,16 +35,20 @@ mouseOwner = NULL; // Setup all events - #define SETUP_EVENT(name, props) SetupEvent(#name, &list ## name, props) - #define SETUP_UNMANAGED_EVENT(name, props) SetupEvent(#name, NULL, props) + #define SETUP_EVENT(name, props) SetupEvent(#name, &list ## name, props); + #define SETUP_UNMANAGED_EVENT(name, props) SetupEvent(#name, NULL, props); #include "Events.def" #undef SETUP_EVENT #undef SETUP_UNMANAGED_EVENT + + // helper event client (alwayss create) + EventBatchHandler::CreateInstance(); } CEventHandler::~CEventHandler() { + EventBatchHandler::DeleteInstance(); } @@ -60,9 +62,9 @@ EventMap::const_iterator it; for (it = eventMap.begin(); it != eventMap.end(); ++it) { const EventInfo& ei = it->second; - if (ei.HasPropBit(MANAGED_BIT) && (ei.GetList() != NULL)) { + if (ei.HasPropBit(MANAGED_BIT)) { if (ec->WantsEvent(it->first)) { - ListInsert(*ei.GetList(), ec); + InsertEvent(ec, it->first); } } } @@ -80,8 +82,8 @@ EventMap::const_iterator it; for (it = eventMap.begin(); it != eventMap.end(); ++it) { const EventInfo& ei = it->second; - if (ei.HasPropBit(MANAGED_BIT) && (ei.GetList() != NULL)) { - ListRemove(*ei.GetList(), ec); + if (ei.HasPropBit(MANAGED_BIT)) { + RemoveEvent(ec, it->first); } } } @@ -192,6 +194,192 @@ /******************************************************************************/ /******************************************************************************/ +#define CONTROL_ITERATE_DEF_TRUE(name, ...) \ + bool result = true; \ + for (int i = 0; i < list##name.size(); ) { \ + CEventClient* ec = list##name[i]; \ + result &= ec->name(__VA_ARGS__); \ + if (i < list##name.size() && ec == list##name[i]) \ + ++i; /* the call-in may remove itself from the list */ \ + } \ + return result; + +#define CONTROL_ITERATE_DEF_FALSE(name, ...) \ + bool result = false; \ + for (int i = 0; i < list##name.size(); ) { \ + CEventClient* ec = list##name[i]; \ + result |= ec->name(__VA_ARGS__); \ + if (i < list##name.size() && ec == list##name[i]) \ + ++i; /* the call-in may remove itself from the list */ \ + } \ + return result; + + +bool CEventHandler::CommandFallback(const CUnit* unit, const Command& cmd) +{ + CONTROL_ITERATE_DEF_TRUE(CommandFallback, unit, cmd) +} + + +bool CEventHandler::AllowCommand(const CUnit* unit, const Command& cmd, bool fromSynced) +{ + CONTROL_ITERATE_DEF_TRUE(AllowCommand, unit, cmd, fromSynced) +} + + +bool CEventHandler::AllowUnitCreation(const UnitDef* unitDef, const CUnit* builder, const BuildInfo* buildInfo) +{ + CONTROL_ITERATE_DEF_TRUE(AllowUnitCreation, unitDef, builder, buildInfo) +} + + +bool CEventHandler::AllowUnitTransfer(const CUnit* unit, int newTeam, bool capture) +{ + CONTROL_ITERATE_DEF_TRUE(AllowUnitTransfer, unit, newTeam, capture) +} + + +bool CEventHandler::AllowUnitBuildStep(const CUnit* builder, const CUnit* unit, float part) +{ + CONTROL_ITERATE_DEF_TRUE(AllowUnitBuildStep, builder, unit, part) +} + + +bool CEventHandler::AllowFeatureCreation(const FeatureDef* featureDef, int allyTeamID, const float3& pos) +{ + CONTROL_ITERATE_DEF_TRUE(AllowFeatureCreation, featureDef, allyTeamID, pos) +} + + +bool CEventHandler::AllowFeatureBuildStep(const CUnit* builder, const CFeature* feature, float part) +{ + CONTROL_ITERATE_DEF_TRUE(AllowFeatureBuildStep, builder, feature, part) +} + + +bool CEventHandler::AllowResourceLevel(int teamID, const string& type, float level) +{ + CONTROL_ITERATE_DEF_TRUE(AllowResourceLevel, teamID, type, level) +} + + +bool CEventHandler::AllowResourceTransfer(int oldTeam, int newTeam, const string& type, float amount) +{ + CONTROL_ITERATE_DEF_TRUE(AllowResourceTransfer, oldTeam, newTeam, type, amount) +} + + +bool CEventHandler::AllowDirectUnitControl(int playerID, const CUnit* unit) +{ + CONTROL_ITERATE_DEF_TRUE(AllowDirectUnitControl, playerID, unit) +} + + +bool CEventHandler::AllowBuilderHoldFire(const CUnit* unit, int action) +{ + CONTROL_ITERATE_DEF_TRUE(AllowBuilderHoldFire, unit, action) +} + + +bool CEventHandler::AllowStartPosition(int playerID, unsigned char readyState, const float3& clampedPos, const float3& rawPickPos) +{ + CONTROL_ITERATE_DEF_TRUE(AllowStartPosition, playerID, readyState, clampedPos, rawPickPos) +} + + + +bool CEventHandler::TerraformComplete(const CUnit* unit, const CUnit* build) +{ + CONTROL_ITERATE_DEF_FALSE(TerraformComplete, unit, build) +} + + +bool CEventHandler::MoveCtrlNotify(const CUnit* unit, int data) +{ + CONTROL_ITERATE_DEF_FALSE(MoveCtrlNotify, unit, data) +} + + +int CEventHandler::AllowWeaponTargetCheck(unsigned int attackerID, unsigned int attackerWeaponNum, unsigned int attackerWeaponDefID) +{ + int result = -1; + for (int i = 0; i < listAllowWeaponTargetCheck.size(); ) { + CEventClient* ec = listAllowWeaponTargetCheck[i]; + int result2 = ec->AllowWeaponTargetCheck(attackerID, attackerWeaponNum, attackerWeaponDefID); + if (result2 > result) result = result2; + if (i < listAllowWeaponTargetCheck.size() && ec == listAllowWeaponTargetCheck[i]) + ++i; /* the call-in may remove itself from the list */ + } + return result; +} + + +bool CEventHandler::AllowWeaponTarget( + unsigned int attackerID, + unsigned int targetID, + unsigned int attackerWeaponNum, + unsigned int attackerWeaponDefID, + float* targetPriority +) { + CONTROL_ITERATE_DEF_TRUE(AllowWeaponTarget, attackerID, targetID, attackerWeaponNum, attackerWeaponDefID, targetPriority) +} + + +bool CEventHandler::AllowWeaponInterceptTarget(const CUnit* interceptorUnit, const CWeapon* interceptorWeapon, const CProjectile* interceptorTarget) +{ + CONTROL_ITERATE_DEF_TRUE(AllowWeaponInterceptTarget, interceptorUnit, interceptorWeapon, interceptorTarget) +} + + +bool CEventHandler::UnitPreDamaged( + const CUnit* unit, + const CUnit* attacker, + float damage, + int weaponDefID, + int projectileID, + bool paralyzer, + float* newDamage, + float* impulseMult +) { + CONTROL_ITERATE_DEF_FALSE(UnitPreDamaged, unit, attacker, damage, weaponDefID, projectileID, paralyzer, newDamage, impulseMult) +} + + +bool CEventHandler::FeaturePreDamaged( + const CFeature* feature, + const CUnit* attacker, + float damage, + int weaponDefID, + int projectileID, + float* newDamage, + float* impulseMult +) { + CONTROL_ITERATE_DEF_FALSE(FeaturePreDamaged, feature, attacker, damage, weaponDefID, projectileID, newDamage, impulseMult) +} + + +bool CEventHandler::ShieldPreDamaged(const CProjectile* proj, const CWeapon* w, const CUnit* u, bool repulsor) +{ + CONTROL_ITERATE_DEF_FALSE(ShieldPreDamaged, proj, w, u, repulsor) +} + + +bool CEventHandler::SyncedActionFallback(const string& line, int playerID) +{ + for (int i = 0; i < listSyncedActionFallback.size(); ) { + CEventClient* ec = listSyncedActionFallback[i]; + if (ec->SyncedActionFallback(line, playerID)) + return true; + if (i < listSyncedActionFallback.size() && ec == listSyncedActionFallback[i]) + ++i; /* the call-in may remove itself from the list */ + } + return false; +} + + +/******************************************************************************/ +/******************************************************************************/ + #define ITERATE_EVENTCLIENTLIST(name, ...) \ for (int i = 0; i < list##name.size(); ) { \ CEventClient* ec = list##name[i]; \ @@ -200,6 +388,7 @@ ++i; /* the call-in may remove itself from the list */ \ } + void CEventHandler::Save(zipFile archive) { ITERATE_EVENTCLIENTLIST(Save, archive); @@ -275,43 +464,41 @@ /******************************************************************************/ /******************************************************************************/ +void CEventHandler::UnitHarvestStorageFull(const CUnit* unit) +{ + const int unitAllyTeam = unit->allyteam; + const int count = listUnitHarvestStorageFull.size(); + for (int i = 0; i < count; i++) { + CEventClient* ec = listUnitHarvestStorageFull[i]; + if (ec->CanReadAllyTeam(unitAllyTeam)) { + ec->UnitHarvestStorageFull(unit); + } + } +} + +/******************************************************************************/ +/******************************************************************************/ + void CEventHandler::CollectGarbage() { ITERATE_EVENTCLIENTLIST(CollectGarbage); } -void CEventHandler::Load(IArchive* archive) +void CEventHandler::DbgTimingInfo(DbgTimingInfoType type, const spring_time start, const spring_time end) { - ITERATE_EVENTCLIENTLIST(Load, archive); + ITERATE_EVENTCLIENTLIST(DbgTimingInfo, type, start, end); } -#ifdef USE_GML - #define GML_DRAW_CALLIN_SELECTOR() if(!globalConfig->enableDrawCallIns) return -#else - #define GML_DRAW_CALLIN_SELECTOR() -#endif - -#define GML_CALLIN_MUTEXES() \ - GML_THRMUTEX_LOCK(feat, GML_DRAW); \ - GML_THRMUTEX_LOCK(unit, GML_DRAW)/*; \ - GML_THRMUTEX_LOCK(proj, GML_DRAW)*/ - - -#define EVENTHANDLER_CHECK(name, ...) \ - const int count = list ## name.size(); \ - if (count <= 0) \ - return __VA_ARGS__; \ - GML_CALLIN_MUTEXES() +void CEventHandler::Load(IArchive* archive) +{ + ITERATE_EVENTCLIENTLIST(Load, archive); +} void CEventHandler::Update() { - GML_DRAW_CALLIN_SELECTOR(); - - EVENTHANDLER_CHECK(Update); - ITERATE_EVENTCLIENTLIST(Update); } @@ -319,44 +506,20 @@ void CEventHandler::UpdateUnits() { eventBatchHandler->UpdateUnits(); } void CEventHandler::UpdateDrawUnits() { eventBatchHandler->UpdateDrawUnits(); } -void CEventHandler::DeleteSyncedUnits() { - eventBatchHandler->DeleteSyncedUnits(); - - if (luaUI) luaUI->ExecuteUnitEventBatch(); -} +void CEventHandler::DeleteSyncedUnits() { eventBatchHandler->DeleteSyncedUnits(); } void CEventHandler::UpdateFeatures() { eventBatchHandler->UpdateFeatures(); } void CEventHandler::UpdateDrawFeatures() { eventBatchHandler->UpdateDrawFeatures(); } -void CEventHandler::DeleteSyncedFeatures() { - eventBatchHandler->DeleteSyncedFeatures(); - - if (luaUI) luaUI->ExecuteFeatEventBatch(); -} +void CEventHandler::DeleteSyncedFeatures() { eventBatchHandler->DeleteSyncedFeatures(); } void CEventHandler::UpdateProjectiles() { eventBatchHandler->UpdateProjectiles(); } void CEventHandler::UpdateDrawProjectiles() { eventBatchHandler->UpdateDrawProjectiles(); } -inline void ExecuteAllCallsFromSynced() { -#if (LUA_MT_OPT & LUA_MUTEX) - bool exec; - do { // these calls can be chained, need to purge them all - exec = false; - if (luaRules && luaRules->ExecuteCallsFromSynced()) - exec = true; - if (luaGaia && luaGaia->ExecuteCallsFromSynced()) - exec = true; - - if (luaUI && luaUI->ExecuteCallsFromSynced()) - exec = true; - } while (exec); -#endif -} +inline void ExecuteAllCallsFromSynced() { } //FIXME delete void CEventHandler::DeleteSyncedProjectiles() { ExecuteAllCallsFromSynced(); eventBatchHandler->DeleteSyncedProjectiles(); - - if (luaUI) luaUI->ExecuteProjEventBatch(); } void CEventHandler::UpdateObjects() { @@ -370,15 +533,11 @@ void CEventHandler::SunChanged(const float3& sunDir) { - EVENTHANDLER_CHECK(SunChanged); - ITERATE_EVENTCLIENTLIST(SunChanged, sunDir); } void CEventHandler::ViewResize() { - EVENTHANDLER_CHECK(ViewResize); - ITERATE_EVENTCLIENTLIST(ViewResize); } @@ -392,10 +551,8 @@ #define DRAW_CALLIN(name) \ void CEventHandler:: Draw ## name () \ { \ - GML_DRAW_CALLIN_SELECTOR(); \ - \ - EVENTHANDLER_CHECK(Draw ## name); \ - \ + if (listDraw ## name.empty()) \ + return; \ LuaOpenGL::EnableDraw ## name (); \ listDraw ## name [0]->Draw ## name (); \ \ @@ -419,64 +576,78 @@ DRAW_CALLIN(ScreenEffects) DRAW_CALLIN(Screen) DRAW_CALLIN(InMiniMap) +DRAW_CALLIN(InMiniMapBackground) +#define DRAW_ENTITY_CALLIN(name, args, args2) \ + bool CEventHandler:: Draw ## name args \ + { \ + bool skipEngineDrawing = false; \ + for (int i = 0; i < listDraw ## name.size(); ) { \ + CEventClient* ec = listDraw ## name [i]; \ + skipEngineDrawing |= ec-> Draw ## name args2 ; \ + if (i < listDraw ## name.size() && ec == listDraw ## name [i]) \ + ++i; \ + } \ + return skipEngineDrawing; \ + } + +DRAW_ENTITY_CALLIN(Unit, (const CUnit* unit), (unit)) +DRAW_ENTITY_CALLIN(Feature, (const CFeature* feature), (feature)) +DRAW_ENTITY_CALLIN(Shield, (const CUnit* unit, const CWeapon* weapon), (unit, weapon)) +DRAW_ENTITY_CALLIN(Projectile, (const CProjectile* projectile), (projectile)) + /******************************************************************************/ /******************************************************************************/ -bool CEventHandler::CommandNotify(const Command& cmd) -{ - EVENTHANDLER_CHECK(CommandNotify, false); +#define CONTROL_REVERSE_ITERATE_DEF_TRUE(name, ...) \ + for (int i = list##name.size() - 1; i >= 0; --i) { \ + CEventClient* ec = list##name[i]; \ + if (ec->name(__VA_ARGS__)) \ + return true; \ + } - // reverse order, user has the override - for (int i = (count - 1); i >= 0; i--) { - CEventClient* ec = listCommandNotify[i]; - if (ec->CommandNotify(cmd)) { - return true; - } +#define CONTROL_REVERSE_ITERATE_STRING(name, ...) \ + for (int i = list##name.size() - 1; i >= 0; --i) { \ + CEventClient* ec = list##name[i]; \ + const std::string& str = ec->name(__VA_ARGS__); \ + if (!str.empty()) \ + return str; \ } + +bool CEventHandler::CommandNotify(const Command& cmd) +{ + CONTROL_REVERSE_ITERATE_DEF_TRUE(CommandNotify, cmd) return false; } -bool CEventHandler::KeyPress(unsigned short key, bool isRepeat) +bool CEventHandler::KeyPress(int key, bool isRepeat) { - EVENTHANDLER_CHECK(KeyPress, false); - - // reverse order, user has the override - for (int i = (count - 1); i >= 0; i--) { - CEventClient* ec = listKeyPress[i]; - if (ec->KeyPress(key, isRepeat)) { - return true; - } - } + CONTROL_REVERSE_ITERATE_DEF_TRUE(KeyPress, key, isRepeat) return false; } -bool CEventHandler::KeyRelease(unsigned short key) +bool CEventHandler::KeyRelease(int key) { - EVENTHANDLER_CHECK(KeyRelease, false); + CONTROL_REVERSE_ITERATE_DEF_TRUE(KeyRelease, key) + return false; +} - // reverse order, user has the override - for (int i = (count - 1); i >= 0; i--) { - CEventClient* ec = listKeyRelease[i]; - if (ec->KeyRelease(key)) { - return true; - } - } + +bool CEventHandler::TextInput(const std::string& utf8) +{ + CONTROL_REVERSE_ITERATE_DEF_TRUE(TextInput, utf8) return false; } bool CEventHandler::MousePress(int x, int y, int button) { - EVENTHANDLER_CHECK(MousePress, false); - - // reverse order, user has the override - for (int i = (count - 1); i >= 0; i--) { + for (int i = listMousePress.size() - 1; i >= 0; --i) { CEventClient* ec = listMousePress[i]; - if (ec->MousePress(x, y, button)) { + if (ec->MousePress(x,y,button)) { if (!mouseOwner) mouseOwner = ec; return true; @@ -486,19 +657,11 @@ } -// return a cmd index, or -1 -int CEventHandler::MouseRelease(int x, int y, int button) +void CEventHandler::MouseRelease(int x, int y, int button) { - if (mouseOwner == NULL) { - return -1; - } - else - { - GML_CALLIN_MUTEXES(); - - const int retval = mouseOwner->MouseRelease(x, y, button); + if (mouseOwner) { + mouseOwner->MouseRelease(x, y, button); mouseOwner = NULL; - return retval; } } @@ -509,94 +672,54 @@ return false; } - GML_CALLIN_MUTEXES(); - return mouseOwner->MouseMove(x, y, dx, dy, button); } bool CEventHandler::MouseWheel(bool up, float value) { - EVENTHANDLER_CHECK(MouseWheel, false); - - // reverse order, user has the override - for (int i = (count - 1); i >= 0; i--) { - CEventClient* ec = listMouseWheel[i]; - if (ec->MouseWheel(up, value)) { - return true; - } - } + CONTROL_REVERSE_ITERATE_DEF_TRUE(MouseWheel, up, value) return false; } bool CEventHandler::JoystickEvent(const std::string& event, int val1, int val2) { - EVENTHANDLER_CHECK(JoystickEvent, false); - - // reverse order, user has the override - for (int i = (count - 1); i >= 0; i--) { - CEventClient* ec = listMouseWheel[i]; - if (ec->JoystickEvent(event, val1, val2)) { - return true; - } - } + CONTROL_REVERSE_ITERATE_DEF_TRUE(JoystickEvent, event, val1, val2) return false; } bool CEventHandler::IsAbove(int x, int y) { - EVENTHANDLER_CHECK(IsAbove, false); - - // reverse order, user has the override - for (int i = (count - 1); i >= 0; i--) { - CEventClient* ec = listIsAbove[i]; - if (ec->IsAbove(x, y)) { - return true; - } - } + CONTROL_REVERSE_ITERATE_DEF_TRUE(IsAbove, x, y) return false; } string CEventHandler::GetTooltip(int x, int y) { - EVENTHANDLER_CHECK(GetTooltip, ""); - - // reverse order, user has the override - for (int i = (count - 1); i >= 0; i--) { - CEventClient* ec = listGetTooltip[i]; - const string tt = ec->GetTooltip(x, y); - if (!tt.empty()) { - return tt; - } - } + CONTROL_REVERSE_ITERATE_STRING(GetTooltip, x, y) return ""; } bool CEventHandler::AddConsoleLine(const std::string& msg, const std::string& section, int level) { - EVENTHANDLER_CHECK(AddConsoleLine, false); + if (listAddConsoleLine.empty()) + return false; ITERATE_EVENTCLIENTLIST(AddConsoleLine, msg, section, level); - return true; } void CEventHandler::LastMessagePosition(const float3& pos) { - EVENTHANDLER_CHECK(LastMessagePosition); - ITERATE_EVENTCLIENTLIST(LastMessagePosition, pos); } bool CEventHandler::GroupChanged(int groupID) { - EVENTHANDLER_CHECK(GroupChanged, false); - ITERATE_EVENTCLIENTLIST(GroupChanged, groupID); - return false; } @@ -605,15 +728,7 @@ bool CEventHandler::GameSetup(const string& state, bool& ready, const map& playerStates) { - EVENTHANDLER_CHECK(GameSetup, false); - - // reverse order, user has the override - for (int i = (count - 1); i >= 0; i--) { - CEventClient* ec = listGameSetup[i]; - if (ec->GameSetup(state, ready, playerStates)) { - return true; - } - } + CONTROL_REVERSE_ITERATE_DEF_TRUE(GameSetup, state, ready, playerStates) return false; } @@ -622,16 +737,7 @@ const CFeature* feature, const float3* groundPos) { - EVENTHANDLER_CHECK(WorldTooltip, ""); - - // reverse order, user has the override - for (int i = (count - 1); i >= 0; i--) { - CEventClient* ec = listWorldTooltip[i]; - const string tt = ec->WorldTooltip(unit, feature, groundPos); - if (!tt.empty()) { - return tt; - } - } + CONTROL_REVERSE_ITERATE_STRING(WorldTooltip, unit, feature, groundPos) return ""; } @@ -640,18 +746,30 @@ const float3* pos0, const float3* pos1, const string* label) { - EVENTHANDLER_CHECK(MapDrawCmd, false); - - // reverse order, user has the override - for (int i = (count - 1); i >= 0; i--) { - CEventClient* ec = listMapDrawCmd[i]; - if (ec->MapDrawCmd(playerID, type, pos0, pos1, label)) { - return true; - } - } + CONTROL_REVERSE_ITERATE_DEF_TRUE(MapDrawCmd, playerID, type, pos0, pos1, label) return false; } + +/******************************************************************************/ +/******************************************************************************/ + +void CEventHandler::UnsyncedProjectileCreated(const CProjectile* proj) { + //FIXME no real event + (eventBatchHandler->GetUnsyncedProjectileCreatedDestroyedBatch()).insert(proj); +} + +void CEventHandler::UnsyncedProjectileDestroyed(const CProjectile* proj) { + //FIXME no real event + (eventBatchHandler->GetUnsyncedProjectileCreatedDestroyedBatch()).erase_delete(proj); +} + +void CEventHandler::LoadedModelRequested() { + //FIXME no real event + eventBatchHandler->LoadedModelRequested(); +} + + /******************************************************************************/ /******************************************************************************/ diff -Nru spring-96.0~14.04~ppa4/rts/System/EventHandler.h spring-98.0~14.04~ppa6/rts/System/EventHandler.h --- spring-96.0~14.04~ppa4/rts/System/EventHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/EventHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -8,13 +8,14 @@ #include #include "System/EventClient.h" -#include "System/EventBatchHandler.h" #include "Sim/Units/Unit.h" #include "Sim/Features/Feature.h" #include "Sim/Projectiles/Projectile.h" class CWeapon; struct Command; +struct BuildInfo; + class CEventHandler { @@ -35,6 +36,18 @@ bool IsUnsynced(const std::string& ciName) const; bool IsController(const std::string& ciName) const; + public: // EventBatchHandler + void UpdateUnits(); + void UpdateDrawUnits(); + void DeleteSyncedUnits(); + void UpdateFeatures(); + void UpdateDrawFeatures(); + void DeleteSyncedFeatures(); + void UpdateProjectiles(); + void UpdateDrawProjectiles(); + void DeleteSyncedProjectiles(); + void UpdateObjects(); + void DeleteSyncedObjects(); public: /** * @name Synced_events @@ -63,15 +76,19 @@ void UnitTaken(const CUnit* unit, int oldTeam, int newTeam); void UnitGiven(const CUnit* unit, int oldTeam, int newTeam); + //FIXME no events void RenderUnitCreated(const CUnit* unit, int cloaked); void RenderUnitDestroyed(const CUnit* unit); void RenderUnitCloakChanged(const CUnit* unit, int cloaked); void RenderUnitLOSChanged(const CUnit* unit, int allyTeam, int newStatus); void RenderUnitMoved(const CUnit* unit, const float3& newpos); - - void UpdateUnits(); - void UpdateDrawUnits(); - void DeleteSyncedUnits(); + void RenderFeatureCreated(const CFeature* feature); + void RenderFeatureDestroyed(const CFeature* feature); + void RenderFeatureMoved(const CFeature* feature, const float3& oldpos, const float3& newpos); + void RenderProjectileCreated(const CProjectile* proj); + void RenderProjectileDestroyed(const CProjectile* proj); + void UnsyncedProjectileCreated(const CProjectile* proj); + void UnsyncedProjectileDestroyed(const CProjectile* proj); void UnitIdle(const CUnit* unit); void UnitCommand(const CUnit* unit, const Command& command); @@ -84,6 +101,7 @@ int projectileID, bool paralyzer); void UnitExperience(const CUnit* unit, float oldExperience); + void UnitHarvestStorageFull(const CUnit* unit); void UnitSeismicPing(const CUnit* unit, int allyTeam, const float3& pos, float strength); @@ -118,34 +136,63 @@ int projectileID); void FeatureMoved(const CFeature* feature, const float3& oldpos); - void RenderFeatureCreated(const CFeature* feature); - void RenderFeatureDestroyed(const CFeature* feature); - void RenderFeatureMoved(const CFeature* feature, const float3& oldpos, const float3& newpos); - - void UpdateFeatures(); - void UpdateDrawFeatures(); - void DeleteSyncedFeatures(); - void ProjectileCreated(const CProjectile* proj, int allyTeam); void ProjectileDestroyed(const CProjectile* proj, int allyTeam); - void RenderProjectileCreated(const CProjectile* proj); - void RenderProjectileDestroyed(const CProjectile* proj); + bool Explosion(int weaponDefID, int projectileID, const float3& pos, const CUnit* owner); - void UnsyncedProjectileCreated(const CProjectile* proj); - void UnsyncedProjectileDestroyed(const CProjectile* proj); + void StockpileChanged(const CUnit* unit, + const CWeapon* weapon, int oldCount); - void UpdateProjectiles(); - void UpdateDrawProjectiles(); - void DeleteSyncedProjectiles(); + bool CommandFallback(const CUnit* unit, const Command& cmd); + bool AllowCommand(const CUnit* unit, const Command& cmd, bool fromSynced); - void UpdateObjects(); - void DeleteSyncedObjects(); + bool AllowUnitCreation(const UnitDef* unitDef, const CUnit* builder, const BuildInfo* buildInfo); + bool AllowUnitTransfer(const CUnit* unit, int newTeam, bool capture); + bool AllowUnitBuildStep(const CUnit* builder, const CUnit* unit, float part); + bool AllowFeatureCreation(const FeatureDef* featureDef, int allyTeamID, const float3& pos); + bool AllowFeatureBuildStep(const CUnit* builder, const CFeature* feature, float part); + bool AllowResourceLevel(int teamID, const string& type, float level); + bool AllowResourceTransfer(int oldTeam, int newTeam, const string& type, float amount); + bool AllowDirectUnitControl(int playerID, const CUnit* unit); + bool AllowBuilderHoldFire(const CUnit* unit, int action); + bool AllowStartPosition(int playerID, unsigned char readyState, const float3& clampedPos, const float3& rawPickPos); + + bool TerraformComplete(const CUnit* unit, const CUnit* build); + bool MoveCtrlNotify(const CUnit* unit, int data); + + int AllowWeaponTargetCheck(unsigned int attackerID, unsigned int attackerWeaponNum, unsigned int attackerWeaponDefID); + bool AllowWeaponTarget( + unsigned int attackerID, + unsigned int targetID, + unsigned int attackerWeaponNum, + unsigned int attackerWeaponDefID, + float* targetPriority + ); + bool AllowWeaponInterceptTarget(const CUnit* interceptorUnit, const CWeapon* interceptorWeapon, const CProjectile* interceptorTarget); - bool Explosion(int weaponDefID, int projectileID, const float3& pos, const CUnit* owner); + bool UnitPreDamaged( + const CUnit* unit, + const CUnit* attacker, + float damage, + int weaponDefID, + int projectileID, + bool paralyzer, + float* newDamage, + float* impulseMult); - void StockpileChanged(const CUnit* unit, - const CWeapon* weapon, int oldCount); + bool FeaturePreDamaged( + const CFeature* feature, + const CUnit* attacker, + float damage, + int weaponDefID, + int projectileID, + float* newDamage, + float* impulseMult); + + bool ShieldPreDamaged(const CProjectile*, const CWeapon*, const CUnit*, bool); + + bool SyncedActionFallback(const string& line, int playerID); /// @} public: @@ -158,11 +205,12 @@ void UnsyncedHeightMapUpdate(const SRectangle& rect); void Update(); - bool KeyPress(unsigned short key, bool isRepeat); - bool KeyRelease(unsigned short key); + bool KeyPress(int key, bool isRepeat); + bool KeyRelease(int key); + bool TextInput(const std::string& utf8); bool MouseMove(int x, int y, int dx, int dy, int button); bool MousePress(int x, int y, int button); - int MouseRelease(int x, int y, int button); // return a cmd index, or -1 + void MouseRelease(int x, int y, int button); bool MouseWheel(bool up, float value); bool JoystickEvent(const std::string& event, int val1, int val2); bool IsAbove(int x, int y); @@ -204,6 +252,12 @@ void DrawScreenEffects(); void DrawScreen(); void DrawInMiniMap(); + void DrawInMiniMapBackground(); + + bool DrawUnit(const CUnit* unit); + bool DrawFeature(const CFeature* feature); + bool DrawShield(const CUnit* unit, const CWeapon* weapon); + bool DrawProjectile(const CProjectile* projectile); /// @brief this UNSYNCED event is generated every GameServer::gameProgressFrameInterval /// it skips network queuing and caching and can be used to calculate the current catchup @@ -211,9 +265,11 @@ void GameProgress(int gameFrame); void CollectGarbage(); + void DbgTimingInfo(DbgTimingInfoType type, const spring_time start, const spring_time end); /// @} - inline void LoadedModelRequested(); + //FIXME no real event + void LoadedModelRequested(); private: typedef vector EventClientList; @@ -258,125 +314,11 @@ EventClientList handles; - // synced - EventClientList listLoad; - - EventClientList listGamePreload; - EventClientList listGameStart; - EventClientList listGameOver; - EventClientList listGamePaused; - EventClientList listGameFrame; - EventClientList listGameID; - EventClientList listTeamDied; - EventClientList listTeamChanged; - EventClientList listPlayerChanged; - EventClientList listPlayerAdded; - EventClientList listPlayerRemoved; - - EventClientList listUnitCreated; - EventClientList listUnitFinished; - EventClientList listUnitFromFactory; - EventClientList listUnitDestroyed; - EventClientList listUnitTaken; - EventClientList listUnitGiven; - - EventClientList listUnitIdle; - EventClientList listUnitCommand; - EventClientList listUnitCmdDone; - EventClientList listUnitDamaged; - EventClientList listUnitExperience; - - EventClientList listUnitSeismicPing; - EventClientList listUnitEnteredRadar; - EventClientList listUnitEnteredLos; - EventClientList listUnitLeftRadar; - EventClientList listUnitLeftLos; - - EventClientList listUnitEnteredWater; - EventClientList listUnitEnteredAir; - EventClientList listUnitLeftWater; - EventClientList listUnitLeftAir; - - EventClientList listUnitLoaded; - EventClientList listUnitUnloaded; - - EventClientList listUnitCloaked; - EventClientList listUnitDecloaked; - - EventClientList listRenderUnitCreated; - EventClientList listRenderUnitDestroyed; - EventClientList listRenderUnitCloakChanged; - EventClientList listRenderUnitLOSChanged; - - EventClientList listUnitUnitCollision; - EventClientList listUnitFeatureCollision; - EventClientList listUnitMoved; - EventClientList listUnitMoveFailed; - - EventClientList listRenderUnitMoved; - - EventClientList listFeatureCreated; - EventClientList listFeatureDestroyed; - EventClientList listFeatureDamaged; - EventClientList listFeatureMoved; - - EventClientList listRenderFeatureCreated; - EventClientList listRenderFeatureDestroyed; - EventClientList listRenderFeatureMoved; - - EventClientList listProjectileCreated; - EventClientList listProjectileDestroyed; - - EventClientList listRenderProjectileCreated; - EventClientList listRenderProjectileDestroyed; - - EventClientList listExplosion; - - EventClientList listStockpileChanged; - - // unsynced - EventClientList listSave; - - EventClientList listUnsyncedHeightMapUpdate; - EventClientList listUpdate; - - EventClientList listKeyPress; - EventClientList listKeyRelease; - EventClientList listMouseMove; - EventClientList listMousePress; - EventClientList listMouseRelease; - EventClientList listMouseWheel; - EventClientList listJoystickEvent; - EventClientList listIsAbove; - EventClientList listGetTooltip; - - EventClientList listDefaultCommand; - EventClientList listConfigCommand; - EventClientList listCommandNotify; - EventClientList listAddConsoleLine; - EventClientList listLastMessagePosition; - EventClientList listGroupChanged; - EventClientList listGameSetup; - EventClientList listWorldTooltip; - EventClientList listMapDrawCmd; - - EventClientList listSunChanged; - - EventClientList listViewResize; - - EventClientList listDrawGenesis; - EventClientList listDrawWorld; - EventClientList listDrawWorldPreUnit; - EventClientList listDrawWorldShadow; - EventClientList listDrawWorldReflection; - EventClientList listDrawWorldRefraction; - EventClientList listDrawScreenEffects; - EventClientList listDrawScreen; - EventClientList listDrawInMiniMap; - - EventClientList listGameProgress; - - EventClientList listCollectGarbage; + #define SETUP_EVENT(name, props) EventClientList list ## name; + #define SETUP_UNMANAGED_EVENT(name, props) + #include "Events.def" + #undef SETUP_EVENT + #undef SETUP_UNMANAGED_EVENT }; @@ -389,34 +331,59 @@ // Inlined call-in loops // +#define ITERATE_EVENTCLIENTLIST(name, ...) \ + for (int i = 0; i < list##name.size(); ) { \ + CEventClient* ec = list##name[i]; \ + ec->name(__VA_ARGS__); \ + if (i < list##name.size() && ec == list##name[i]) \ + ++i; /* the call-in may remove itself from the list */ \ + } + +#define ITERATE_ALLYTEAM_EVENTCLIENTLIST(name, allyTeam, ...) \ + for (int i = 0; i < list##name.size(); ) { \ + CEventClient* ec = list##name[i]; \ + if (ec->CanReadAllyTeam(allyTeam)) { \ + ec->name(__VA_ARGS__); \ + } \ + if (i < list##name.size() && ec == list##name[i]) \ + ++i; /* the call-in may remove itself from the list */ \ + } + +#define ITERATE_UNIT_ALLYTEAM_EVENTCLIENTLIST(name, unit, ...) \ + const auto unitAllyTeam = unit->allyteam; \ + for (int i = 0; i < list##name.size(); ) { \ + CEventClient* ec = list##name[i]; \ + if (ec->CanReadAllyTeam(unitAllyTeam)) { \ + ec->name(unit, __VA_ARGS__); \ + } \ + if (i < list##name.size() && ec == list##name[i]) \ + ++i; /* the call-in may remove itself from the list */ \ + } + inline void CEventHandler::UnitCreated(const CUnit* unit, const CUnit* builder) { -// (eventBatchHandler->GetUnitCreatedDestroyedBatch()).enqueue(unit); - - const int unitAllyTeam = unit->allyteam; - const int count = listUnitCreated.size(); - - for (int i = 0; i < count; i++) { - CEventClient* ec = listUnitCreated[i]; - if (ec->CanReadAllyTeam(unitAllyTeam)) { - ec->UnitCreated(unit, builder); - } - } + ITERATE_UNIT_ALLYTEAM_EVENTCLIENTLIST(UnitCreated, unit, builder) } +inline void CEventHandler::UnitDestroyed(const CUnit* unit, + const CUnit* attacker) +{ + ITERATE_UNIT_ALLYTEAM_EVENTCLIENTLIST(UnitDestroyed, unit, attacker) +} #define UNIT_CALLIN_NO_PARAM(name) \ inline void CEventHandler:: name (const CUnit* unit) \ { \ - const int unitAllyTeam = unit->allyteam; \ - const int count = list ## name.size(); \ - for (int i = 0; i < count; i++) { \ - CEventClient* ec = list ## name [i]; \ - if (ec->CanReadAllyTeam(unitAllyTeam)) { \ - ec-> name (unit); \ - } \ - } \ + const auto unitAllyTeam = unit->allyteam; \ + for (int i = 0; i < list##name.size(); ) { \ + CEventClient* ec = list##name[i]; \ + if (ec->CanReadAllyTeam(unitAllyTeam)) { \ + ec->name(unit); \ + } \ + if (i < list##name.size() && ec == list##name[i]) \ + ++i; /* the call-in may remove itself from the list */ \ + } \ } UNIT_CALLIN_NO_PARAM(UnitFinished) @@ -426,51 +393,22 @@ UNIT_CALLIN_NO_PARAM(UnitEnteredAir) UNIT_CALLIN_NO_PARAM(UnitLeftWater) UNIT_CALLIN_NO_PARAM(UnitLeftAir) - -inline void CEventHandler::UnitMoved(const CUnit* unit) -{ - eventBatchHandler->EnqueueUnitMovedEvent(unit, unit->pos); - - const int unitAllyTeam = unit->allyteam; - const int count = listUnitMoved.size(); - for (int i = 0; i < count; i++) { - CEventClient* ec = listUnitMoved[i]; - if (ec->CanReadAllyTeam(unitAllyTeam)) { - ec->UnitMoved(unit); - } - } -} - +UNIT_CALLIN_NO_PARAM(UnitMoved) #define UNIT_CALLIN_INT_PARAMS(name) \ inline void CEventHandler:: Unit ## name (const CUnit* unit, int p1, int p2) \ { \ - const int unitAllyTeam = unit->allyteam; \ - const int count = listUnit ## name.size(); \ - for (int i = 0; i < count; i++) { \ - CEventClient* ec = listUnit ## name [i]; \ - if (ec->CanReadAllyTeam(unitAllyTeam)) { \ - ec-> Unit ## name (unit, p1, p2); \ - } \ - } \ + ITERATE_UNIT_ALLYTEAM_EVENTCLIENTLIST(Unit ## name, unit, p1, p2) \ } UNIT_CALLIN_INT_PARAMS(Taken) UNIT_CALLIN_INT_PARAMS(Given) - #define UNIT_CALLIN_LOS_PARAM(name) \ inline void CEventHandler:: Unit ## name (const CUnit* unit, int at) \ { \ - eventBatchHandler->EnqueueUnitLOSStateChangeEvent(unit, at, unit->losStatus[at]); \ - const int count = listUnit ## name.size(); \ - for (int i = 0; i < count; i++) { \ - CEventClient* ec = listUnit ## name [i]; \ - if (ec->CanReadAllyTeam(at)) { \ - ec-> Unit ## name (unit, at); \ - } \ - } \ + ITERATE_ALLYTEAM_EVENTCLIENTLIST(Unit ## name, at, unit, at) \ } UNIT_CALLIN_LOS_PARAM(EnteredRadar) @@ -484,130 +422,22 @@ const CUnit* factory, bool userOrders) { - const int unitAllyTeam = unit->allyteam; - const int count = listUnitFromFactory.size(); - for (int i = 0; i < count; i++) { - CEventClient* ec = listUnitFromFactory[i]; - if (ec->CanReadAllyTeam(unitAllyTeam)) { - ec->UnitFromFactory(unit, factory, userOrders); - } - } + ITERATE_UNIT_ALLYTEAM_EVENTCLIENTLIST(UnitFromFactory, unit, factory, userOrders) } -inline void CEventHandler::UnitDestroyed(const CUnit* unit, - const CUnit* attacker) -{ -// (eventBatchHandler->GetUnitCreatedDestroyedBatch()).dequeue_synced(unit); - - const int unitAllyTeam = unit->allyteam; - const int count = listUnitDestroyed.size(); - for (int i = 0; i < count; i++) { - CEventClient* ec = listUnitDestroyed[i]; - if (ec->CanReadAllyTeam(unitAllyTeam)) { - ec->UnitDestroyed(unit, attacker); - } - } -} - -inline void CEventHandler::RenderUnitCreated(const CUnit* unit, int cloaked) -{ - const int count = listRenderUnitCreated.size(); - for (int i = 0; i < count; i++) { - CEventClient* ec = listRenderUnitCreated[i]; - if (ec->CanReadAllyTeam(unit->allyteam)) { - ec->RenderUnitCreated(unit, cloaked); - } - } -} - -inline void CEventHandler::RenderUnitDestroyed(const CUnit* unit) -{ - const int count = listRenderUnitDestroyed.size(); - for (int i = 0; i < count; i++) { - CEventClient* ec = listRenderUnitDestroyed[i]; - if (ec->CanReadAllyTeam(unit->allyteam)) { - ec->RenderUnitDestroyed(unit); - } - } -} - -inline void CEventHandler::RenderUnitCloakChanged(const CUnit* unit, int cloaked) -{ - const int count = listRenderUnitCloakChanged.size(); - for (int i = 0; i < count; i++) { - CEventClient* ec = listRenderUnitCloakChanged[i]; - if (ec->CanReadAllyTeam(unit->allyteam)) { - ec->RenderUnitCloakChanged(unit, cloaked); - } - } -} - -inline void CEventHandler::RenderUnitLOSChanged(const CUnit* unit, int allyTeam, int newStatus) -{ - const int count = listRenderUnitLOSChanged.size(); - for (int i = 0; i < count; i++) { - CEventClient* ec = listRenderUnitLOSChanged[i]; - if (ec->CanReadAllyTeam(unit->allyteam)) { - ec->RenderUnitLOSChanged(unit, allyTeam, newStatus); - } - } -} - -inline void CEventHandler::UnitCloaked(const CUnit* unit) -{ - eventBatchHandler->EnqueueUnitCloakStateChangeEvent(unit, 1); - - const int unitAllyTeam = unit->allyteam; - const int count = listUnitCloaked.size(); - for (int i = 0; i < count; i++) { - CEventClient* ec = listUnitCloaked[i]; - if (ec->CanReadAllyTeam(unitAllyTeam)) { - ec->UnitCloaked(unit); - } - } -} - -inline void CEventHandler::UnitDecloaked(const CUnit* unit) -{ - eventBatchHandler->EnqueueUnitCloakStateChangeEvent(unit, 0); - - const int unitAllyTeam = unit->allyteam; - const int count = listUnitDecloaked.size(); - for (int i = 0; i < count; i++) { - CEventClient* ec = listUnitDecloaked[i]; - if (ec->CanReadAllyTeam(unitAllyTeam)) { - ec->UnitDecloaked(unit); - } - } -} - +UNIT_CALLIN_NO_PARAM(UnitCloaked) +UNIT_CALLIN_NO_PARAM(UnitDecloaked) inline void CEventHandler::UnitUnitCollision(const CUnit* collider, const CUnit* collidee) { - const int colliderAllyTeam = collider->allyteam; - const int clientCount = listUnitUnitCollision.size(); - - for (int i = 0; i < clientCount; i++) { - CEventClient* ec = listUnitUnitCollision[i]; - if (ec->CanReadAllyTeam(colliderAllyTeam)) { - ec->UnitUnitCollision(collider, collidee); - } - } + ITERATE_EVENTCLIENTLIST(UnitUnitCollision, collider, collidee) } inline void CEventHandler::UnitFeatureCollision(const CUnit* collider, const CFeature* collidee) { - const int colliderAllyTeam = collider->allyteam; - const int clientCount = listUnitFeatureCollision.size(); - - for (int i = 0; i < clientCount; i++) { - CEventClient* ec = listUnitFeatureCollision[i]; - if (ec->CanReadAllyTeam(colliderAllyTeam)) { - ec->UnitFeatureCollision(collider, collidee); - } - } + ITERATE_EVENTCLIENTLIST(UnitFeatureCollision, collider, collidee) } @@ -615,28 +445,15 @@ inline void CEventHandler::UnitCommand(const CUnit* unit, const Command& command) { - const int unitAllyTeam = unit->allyteam; - const int count = listUnitCommand.size(); - for (int i = 0; i < count; i++) { - CEventClient* ec = listUnitCommand[i]; - if (ec->CanReadAllyTeam(unitAllyTeam)) { - ec->UnitCommand(unit, command); - } - } + ITERATE_UNIT_ALLYTEAM_EVENTCLIENTLIST(UnitCommand, unit, command) } + inline void CEventHandler::UnitCmdDone(const CUnit* unit, const Command& command) { - const int unitAllyTeam = unit->allyteam; - const int count = listUnitCmdDone.size(); - for (int i = 0; i < count; i++) { - CEventClient* ec = listUnitCmdDone[i]; - if (ec->CanReadAllyTeam(unitAllyTeam)) { - ec->UnitCmdDone(unit, command); - } - } + ITERATE_UNIT_ALLYTEAM_EVENTCLIENTLIST(UnitCmdDone, unit, command) } @@ -648,29 +465,14 @@ int projectileID, bool paralyzer) { - const int unitAllyTeam = unit->allyteam; - const int count = listUnitDamaged.size(); - - for (int i = 0; i < count; i++) { - CEventClient* ec = listUnitDamaged[i]; - if (ec->CanReadAllyTeam(unitAllyTeam)) { - ec->UnitDamaged(unit, attacker, damage, weaponDefID, projectileID, paralyzer); - } - } + ITERATE_UNIT_ALLYTEAM_EVENTCLIENTLIST(UnitDamaged, unit, attacker, damage, weaponDefID, projectileID, paralyzer) } inline void CEventHandler::UnitExperience(const CUnit* unit, float oldExperience) { - const int unitAllyTeam = unit->allyteam; - const int count = listUnitExperience.size(); - for (int i = 0; i < count; i++) { - CEventClient* ec = listUnitExperience[i]; - if (ec->CanReadAllyTeam(unitAllyTeam)) { - ec->UnitExperience(unit, oldExperience); - } - } + ITERATE_UNIT_ALLYTEAM_EVENTCLIENTLIST(UnitExperience, unit, oldExperience) } @@ -679,13 +481,7 @@ const float3& pos, float strength) { - const int count = listUnitSeismicPing.size(); - for (int i = 0; i < count; i++) { - CEventClient* ec = listUnitSeismicPing[i]; - if (ec->CanReadAllyTeam(allyTeam)) { - ec->UnitSeismicPing(unit, allyTeam, pos, strength); - } - } + ITERATE_UNIT_ALLYTEAM_EVENTCLIENTLIST(UnitSeismicPing, unit, allyTeam, pos, strength) } @@ -720,20 +516,8 @@ } } - -inline void CEventHandler::RenderUnitMoved(const CUnit* unit, const float3& newpos) -{ - const int count = listRenderUnitMoved.size(); - for (int i = 0; i < count; i++) { - CEventClient* ec = listRenderUnitMoved[i]; - ec->RenderUnitMoved(unit, newpos); - } -} - inline void CEventHandler::FeatureCreated(const CFeature* feature) { - (eventBatchHandler->GetFeatureCreatedDestroyedEventBatch()).enqueue(feature); - const int featureAllyTeam = feature->allyteam; const int count = listFeatureCreated.size(); for (int i = 0; i < count; i++) { @@ -746,8 +530,6 @@ inline void CEventHandler::FeatureDestroyed(const CFeature* feature) { - (eventBatchHandler->GetFeatureCreatedDestroyedEventBatch()).dequeue(feature); - const int featureAllyTeam = feature->allyteam; const int count = listFeatureDestroyed.size(); for (int i = 0; i < count; i++) { @@ -778,57 +560,19 @@ inline void CEventHandler::FeatureMoved(const CFeature* feature, const float3& oldpos) { - eventBatchHandler->EnqueueFeatureMovedEvent(feature, oldpos, feature->pos); - const int featureAllyTeam = feature->allyteam; const int count = listFeatureMoved.size(); for (int i = 0; i < count; i++) { CEventClient* ec = listFeatureMoved[i]; if ((featureAllyTeam < 0) || ec->CanReadAllyTeam(featureAllyTeam)) { - ec->FeatureMoved(feature); + ec->FeatureMoved(feature, oldpos); } } } - -inline void CEventHandler::RenderFeatureCreated(const CFeature* feature) -{ - const int count = listRenderFeatureCreated.size(); - for (int i = 0; i < count; i++) { - CEventClient* ec = listRenderFeatureCreated[i]; - ec->RenderFeatureCreated(feature); - } -} - -inline void CEventHandler::RenderFeatureDestroyed(const CFeature* feature) -{ - const int count = listRenderFeatureDestroyed.size(); - for (int i = 0; i < count; i++) { - CEventClient* ec = listRenderFeatureDestroyed[i]; - ec->RenderFeatureDestroyed(feature); - } -} - -inline void CEventHandler::RenderFeatureMoved(const CFeature* feature, const float3& oldpos, const float3& newpos) -{ - const int count = listRenderFeatureMoved.size(); - for (int i = 0; i < count; i++) { - CEventClient* ec = listRenderFeatureMoved[i]; - ec->RenderFeatureMoved(feature, oldpos, newpos); - } -} - - - inline void CEventHandler::ProjectileCreated(const CProjectile* proj, int allyTeam) { - if (proj->synced) { - (eventBatchHandler->GetSyncedProjectileCreatedDestroyedBatch()).insert(proj); - } else { - (eventBatchHandler->GetUnsyncedProjectileCreatedDestroyedBatch()).insert(proj); - } - const int count = listProjectileCreated.size(); for (int i = 0; i < count; i++) { CEventClient* ec = listProjectileCreated[i]; @@ -842,12 +586,6 @@ inline void CEventHandler::ProjectileDestroyed(const CProjectile* proj, int allyTeam) { - if (proj->synced) { - (eventBatchHandler->GetSyncedProjectileCreatedDestroyedBatch()).erase_delete(proj); - } else { - (eventBatchHandler->GetUnsyncedProjectileCreatedDestroyedBatch()).erase_delete(proj); - } - const int count = listProjectileDestroyed.size(); for (int i = 0; i < count; i++) { CEventClient* ec = listProjectileDestroyed[i]; @@ -859,41 +597,9 @@ } -inline void CEventHandler::UnsyncedProjectileCreated(const CProjectile* proj) { - (eventBatchHandler->GetUnsyncedProjectileCreatedDestroyedBatch()).insert(proj); -} - -inline void CEventHandler::UnsyncedProjectileDestroyed(const CProjectile* proj) { - (eventBatchHandler->GetUnsyncedProjectileCreatedDestroyedBatch()).erase_delete(proj); -} - - -inline void CEventHandler::RenderProjectileCreated(const CProjectile* proj) -{ - const int count = listRenderProjectileCreated.size(); - for (int i = 0; i < count; i++) { - CEventClient* ec = listRenderProjectileCreated[i]; - ec->RenderProjectileCreated(proj); - } -} - -inline void CEventHandler::RenderProjectileDestroyed(const CProjectile* proj) -{ - const int count = listRenderProjectileDestroyed.size(); - for (int i = 0; i < count; i++) { - CEventClient* ec = listRenderProjectileDestroyed[i]; - ec->RenderProjectileDestroyed(proj); - } -} - - inline void CEventHandler::UnsyncedHeightMapUpdate(const SRectangle& rect) { - const int count = listUnsyncedHeightMapUpdate.size(); - for (int i = 0; i < count; i++) { - CEventClient* ec = listUnsyncedHeightMapUpdate[i]; - ec->UnsyncedHeightMapUpdate(rect); - } + ITERATE_EVENTCLIENTLIST(UnsyncedHeightMapUpdate, rect) } @@ -917,15 +623,7 @@ const CWeapon* weapon, int oldCount) { - const int unitAllyTeam = unit->allyteam; - const int count = listStockpileChanged.size(); - for (int i = 0; i < count; i++) { - CEventClient* ec = listStockpileChanged[i]; - //const int ecAllyTeam = ec->GetReadAllyTeam(); - if (ec->CanReadAllyTeam(unitAllyTeam)) { - ec->StockpileChanged(unit, weapon, oldCount); - } - } + ITERATE_UNIT_ALLYTEAM_EVENTCLIENTLIST(StockpileChanged, unit, weapon, oldCount) } @@ -944,9 +642,65 @@ return false; } -inline void CEventHandler::LoadedModelRequested() { - eventBatchHandler->LoadedModelRequested(); + + +inline void CEventHandler::RenderUnitCreated(const CUnit* unit, int cloaked) +{ + ITERATE_EVENTCLIENTLIST(RenderUnitCreated, unit, cloaked) +} + +inline void CEventHandler::RenderUnitDestroyed(const CUnit* unit) +{ + ITERATE_EVENTCLIENTLIST(RenderUnitDestroyed, unit) +} + +inline void CEventHandler::RenderUnitCloakChanged(const CUnit* unit, int cloaked) +{ + ITERATE_EVENTCLIENTLIST(RenderUnitCloakChanged, unit, cloaked) +} + +inline void CEventHandler::RenderUnitLOSChanged(const CUnit* unit, int allyTeam, int newStatus) +{ + ITERATE_EVENTCLIENTLIST(RenderUnitLOSChanged, unit, allyTeam, newStatus) +} + +inline void CEventHandler::RenderUnitMoved(const CUnit* unit, const float3& newpos) +{ + ITERATE_EVENTCLIENTLIST(RenderUnitMoved, unit, newpos) +} + +inline void CEventHandler::RenderFeatureCreated(const CFeature* feature) +{ + ITERATE_EVENTCLIENTLIST(RenderFeatureCreated, feature) +} + +inline void CEventHandler::RenderFeatureDestroyed(const CFeature* feature) +{ + ITERATE_EVENTCLIENTLIST(RenderFeatureDestroyed, feature) +} + +inline void CEventHandler::RenderFeatureMoved(const CFeature* feature, const float3& oldpos, const float3& newpos) +{ + ITERATE_EVENTCLIENTLIST(RenderFeatureMoved, feature, oldpos, newpos) +} + +inline void CEventHandler::RenderProjectileCreated(const CProjectile* proj) +{ + ITERATE_EVENTCLIENTLIST(RenderProjectileCreated, proj) +} + +inline void CEventHandler::RenderProjectileDestroyed(const CProjectile* proj) +{ + ITERATE_EVENTCLIENTLIST(RenderProjectileDestroyed, proj) } + +#undef ITERATE_EVENTCLIENTLIST +#undef ITERATE_ALLYTEAM_EVENTCLIENTLIST +#undef ITERATE_UNIT_ALLYTEAM_EVENTCLIENTLIST +#undef UNIT_CALLIN_NO_PARAM +#undef UNIT_CALLIN_INT_PARAMS +#undef UNIT_CALLIN_LOS_PARAM + #endif /* EVENT_HANDLER_H */ diff -Nru spring-96.0~14.04~ppa4/rts/System/Events.def spring-98.0~14.04~ppa6/rts/System/Events.def --- spring-96.0~14.04~ppa4/rts/System/Events.def 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Events.def 2014-10-07 20:09:51.000000000 +0000 @@ -23,160 +23,178 @@ #endif // synced call-ins - SETUP_EVENT(Load, MANAGED_BIT); + SETUP_EVENT(Load, MANAGED_BIT) - SETUP_EVENT(GamePreload, MANAGED_BIT); - SETUP_EVENT(GameStart, MANAGED_BIT); - SETUP_EVENT(GameOver, MANAGED_BIT); - SETUP_EVENT(GamePaused, MANAGED_BIT); - SETUP_EVENT(GameFrame, MANAGED_BIT); - SETUP_EVENT(TeamDied, MANAGED_BIT); - SETUP_EVENT(TeamChanged, MANAGED_BIT); - SETUP_EVENT(PlayerChanged, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(PlayerAdded, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(PlayerRemoved, MANAGED_BIT | UNSYNCED_BIT); - - SETUP_EVENT(UnitCreated, MANAGED_BIT); - SETUP_EVENT(UnitFinished, MANAGED_BIT); - SETUP_EVENT(UnitFromFactory, MANAGED_BIT); - SETUP_EVENT(UnitDestroyed, MANAGED_BIT); - SETUP_EVENT(UnitTaken, MANAGED_BIT); - SETUP_EVENT(UnitGiven, MANAGED_BIT); - - SETUP_EVENT(UnitIdle, MANAGED_BIT); - SETUP_EVENT(UnitCommand, MANAGED_BIT); - SETUP_EVENT(UnitCmdDone, MANAGED_BIT); - SETUP_EVENT(UnitDamaged, MANAGED_BIT); - SETUP_EVENT(UnitExperience, MANAGED_BIT); - - SETUP_EVENT(UnitSeismicPing, MANAGED_BIT); - SETUP_EVENT(UnitEnteredRadar, MANAGED_BIT); - SETUP_EVENT(UnitEnteredLos, MANAGED_BIT); - SETUP_EVENT(UnitLeftRadar, MANAGED_BIT); - SETUP_EVENT(UnitLeftLos, MANAGED_BIT); - - SETUP_EVENT(UnitEnteredWater, MANAGED_BIT); - SETUP_EVENT(UnitEnteredAir, MANAGED_BIT); - SETUP_EVENT(UnitLeftWater, MANAGED_BIT); - SETUP_EVENT(UnitLeftAir, MANAGED_BIT); - - SETUP_EVENT(UnitLoaded, MANAGED_BIT); - SETUP_EVENT(UnitUnloaded, MANAGED_BIT); - SETUP_EVENT(UnitCloaked, MANAGED_BIT); - SETUP_EVENT(UnitDecloaked, MANAGED_BIT); - - SETUP_EVENT(UnitUnitCollision, MANAGED_BIT); - SETUP_EVENT(UnitFeatureCollision, MANAGED_BIT); - SETUP_EVENT(UnitMoved, MANAGED_BIT); - SETUP_EVENT(UnitMoveFailed, MANAGED_BIT); - - SETUP_EVENT(FeatureCreated, MANAGED_BIT); - SETUP_EVENT(FeatureDestroyed, MANAGED_BIT); - SETUP_EVENT(FeatureDamaged, MANAGED_BIT); - SETUP_EVENT(FeatureMoved, MANAGED_BIT); + SETUP_EVENT(GamePreload, MANAGED_BIT) + SETUP_EVENT(GameStart, MANAGED_BIT) + SETUP_EVENT(GameOver, MANAGED_BIT) + SETUP_EVENT(GamePaused, MANAGED_BIT) + SETUP_EVENT(GameFrame, MANAGED_BIT) + SETUP_EVENT(TeamDied, MANAGED_BIT) + SETUP_EVENT(TeamChanged, MANAGED_BIT) + SETUP_EVENT(PlayerChanged, MANAGED_BIT | UNSYNCED_BIT) + SETUP_EVENT(PlayerAdded, MANAGED_BIT | UNSYNCED_BIT) + SETUP_EVENT(PlayerRemoved, MANAGED_BIT | UNSYNCED_BIT) + + SETUP_EVENT(UnitCreated, MANAGED_BIT) + SETUP_EVENT(UnitFinished, MANAGED_BIT) + SETUP_EVENT(UnitFromFactory, MANAGED_BIT) + SETUP_EVENT(UnitDestroyed, MANAGED_BIT) + SETUP_EVENT(UnitTaken, MANAGED_BIT) + SETUP_EVENT(UnitGiven, MANAGED_BIT) + + SETUP_EVENT(UnitIdle, MANAGED_BIT) + SETUP_EVENT(UnitCommand, MANAGED_BIT) + SETUP_EVENT(UnitCmdDone, MANAGED_BIT) + SETUP_EVENT(UnitDamaged, MANAGED_BIT) + SETUP_EVENT(UnitExperience, MANAGED_BIT) + SETUP_EVENT(UnitHarvestStorageFull, MANAGED_BIT) + + SETUP_EVENT(UnitSeismicPing, MANAGED_BIT) + SETUP_EVENT(UnitEnteredRadar, MANAGED_BIT) + SETUP_EVENT(UnitEnteredLos, MANAGED_BIT) + SETUP_EVENT(UnitLeftRadar, MANAGED_BIT) + SETUP_EVENT(UnitLeftLos, MANAGED_BIT) + + SETUP_EVENT(UnitEnteredWater, MANAGED_BIT) + SETUP_EVENT(UnitEnteredAir, MANAGED_BIT) + SETUP_EVENT(UnitLeftWater, MANAGED_BIT) + SETUP_EVENT(UnitLeftAir, MANAGED_BIT) + + SETUP_EVENT(UnitLoaded, MANAGED_BIT) + SETUP_EVENT(UnitUnloaded, MANAGED_BIT) + SETUP_EVENT(UnitCloaked, MANAGED_BIT) + SETUP_EVENT(UnitDecloaked, MANAGED_BIT) + + SETUP_EVENT(UnitUnitCollision, MANAGED_BIT) + SETUP_EVENT(UnitFeatureCollision, MANAGED_BIT) + SETUP_EVENT(UnitMoved, MANAGED_BIT) + SETUP_EVENT(UnitMoveFailed, MANAGED_BIT) + + SETUP_EVENT(FeatureCreated, MANAGED_BIT) + SETUP_EVENT(FeatureDestroyed, MANAGED_BIT) + SETUP_EVENT(FeatureDamaged, MANAGED_BIT) + SETUP_EVENT(FeatureMoved, MANAGED_BIT) - SETUP_EVENT(ProjectileCreated, MANAGED_BIT); - SETUP_EVENT(ProjectileDestroyed, MANAGED_BIT); + SETUP_EVENT(ProjectileCreated, MANAGED_BIT) + SETUP_EVENT(ProjectileDestroyed, MANAGED_BIT) - SETUP_EVENT(Explosion, MANAGED_BIT); + SETUP_EVENT(Explosion, MANAGED_BIT | CONTROL_BIT) - SETUP_EVENT(StockpileChanged, MANAGED_BIT); + SETUP_EVENT(StockpileChanged, MANAGED_BIT) // unsynced call-ins - SETUP_EVENT(Save, MANAGED_BIT | UNSYNCED_BIT); + SETUP_EVENT(Save, MANAGED_BIT | UNSYNCED_BIT) - SETUP_EVENT(UnsyncedHeightMapUpdate, MANAGED_BIT | UNSYNCED_BIT); + SETUP_EVENT(UnsyncedHeightMapUpdate, MANAGED_BIT | UNSYNCED_BIT) - SETUP_EVENT(Update, MANAGED_BIT | UNSYNCED_BIT); + SETUP_EVENT(Update, MANAGED_BIT | UNSYNCED_BIT) - SETUP_EVENT(KeyPress, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(KeyRelease, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(MouseMove, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(MousePress, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(MouseRelease, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(MouseWheel, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(JoystickEvent, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(IsAbove, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(GetTooltip, MANAGED_BIT | UNSYNCED_BIT); - - SETUP_EVENT(LastMessagePosition, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(DefaultCommand, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(CommandNotify, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(AddConsoleLine, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(GroupChanged, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(GameSetup, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(WorldTooltip, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(MapDrawCmd, MANAGED_BIT | UNSYNCED_BIT); - - SETUP_EVENT(SunChanged, MANAGED_BIT | UNSYNCED_BIT); //FIXME make synced? (whole dynSun code needs to then) - - SETUP_EVENT(ViewResize, MANAGED_BIT | UNSYNCED_BIT); - - SETUP_EVENT(DrawGenesis, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(DrawWorld, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(DrawWorldPreUnit, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(DrawWorldShadow, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(DrawWorldReflection, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(DrawWorldRefraction, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(DrawScreenEffects, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(DrawScreen, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(DrawInMiniMap, MANAGED_BIT | UNSYNCED_BIT); - - SETUP_EVENT(RenderUnitCreated, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(RenderUnitDestroyed, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(RenderUnitCloakChanged, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(RenderUnitLOSChanged, MANAGED_BIT | UNSYNCED_BIT); - - SETUP_EVENT(RenderFeatureCreated, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(RenderFeatureDestroyed, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(RenderFeatureMoved, MANAGED_BIT | UNSYNCED_BIT); - - SETUP_EVENT(RenderProjectileCreated, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(RenderProjectileDestroyed, MANAGED_BIT | UNSYNCED_BIT); - - SETUP_EVENT(GameProgress, MANAGED_BIT | UNSYNCED_BIT); - SETUP_EVENT(GameID, MANAGED_BIT); - - SETUP_EVENT(RenderUnitMoved, MANAGED_BIT | UNSYNCED_BIT); + SETUP_EVENT(KeyPress, MANAGED_BIT | UNSYNCED_BIT | CONTROL_BIT) + SETUP_EVENT(KeyRelease, MANAGED_BIT | UNSYNCED_BIT | CONTROL_BIT) + SETUP_EVENT(TextInput, MANAGED_BIT | UNSYNCED_BIT | CONTROL_BIT) + SETUP_EVENT(MouseMove, MANAGED_BIT | UNSYNCED_BIT | CONTROL_BIT) + SETUP_EVENT(MousePress, MANAGED_BIT | UNSYNCED_BIT | CONTROL_BIT) + SETUP_EVENT(MouseRelease, MANAGED_BIT | UNSYNCED_BIT) + SETUP_EVENT(MouseWheel, MANAGED_BIT | UNSYNCED_BIT | CONTROL_BIT) + SETUP_EVENT(JoystickEvent, MANAGED_BIT | UNSYNCED_BIT | CONTROL_BIT) + SETUP_EVENT(IsAbove, MANAGED_BIT | UNSYNCED_BIT | CONTROL_BIT) + SETUP_EVENT(GetTooltip, MANAGED_BIT | UNSYNCED_BIT | CONTROL_BIT) + + SETUP_EVENT(LastMessagePosition, MANAGED_BIT | UNSYNCED_BIT) + SETUP_EVENT(DefaultCommand, MANAGED_BIT | UNSYNCED_BIT | CONTROL_BIT) + SETUP_EVENT(CommandNotify, MANAGED_BIT | UNSYNCED_BIT | CONTROL_BIT) + SETUP_EVENT(AddConsoleLine, MANAGED_BIT | UNSYNCED_BIT) + SETUP_EVENT(GroupChanged, MANAGED_BIT | UNSYNCED_BIT) + SETUP_EVENT(GameSetup, MANAGED_BIT | UNSYNCED_BIT | CONTROL_BIT) + SETUP_EVENT(WorldTooltip, MANAGED_BIT | UNSYNCED_BIT) + SETUP_EVENT(MapDrawCmd, MANAGED_BIT | UNSYNCED_BIT | CONTROL_BIT) + + SETUP_EVENT(SunChanged, MANAGED_BIT | UNSYNCED_BIT) //FIXME make synced? (whole dynSun code needs to then) + + SETUP_EVENT(ViewResize, MANAGED_BIT | UNSYNCED_BIT) + + SETUP_EVENT(DrawGenesis, MANAGED_BIT | UNSYNCED_BIT) + SETUP_EVENT(DrawWorld, MANAGED_BIT | UNSYNCED_BIT) + SETUP_EVENT(DrawWorldPreUnit, MANAGED_BIT | UNSYNCED_BIT) + SETUP_EVENT(DrawWorldShadow, MANAGED_BIT | UNSYNCED_BIT) + SETUP_EVENT(DrawWorldReflection, MANAGED_BIT | UNSYNCED_BIT) + SETUP_EVENT(DrawWorldRefraction, MANAGED_BIT | UNSYNCED_BIT) + SETUP_EVENT(DrawScreenEffects, MANAGED_BIT | UNSYNCED_BIT) + SETUP_EVENT(DrawScreen, MANAGED_BIT | UNSYNCED_BIT) + SETUP_EVENT(DrawInMiniMap, MANAGED_BIT | UNSYNCED_BIT) + SETUP_EVENT(DrawInMiniMapBackground, MANAGED_BIT | UNSYNCED_BIT) + + SETUP_EVENT(RenderUnitCreated, MANAGED_BIT | UNSYNCED_BIT) + SETUP_EVENT(RenderUnitDestroyed, MANAGED_BIT | UNSYNCED_BIT) + SETUP_EVENT(RenderUnitCloakChanged, MANAGED_BIT | UNSYNCED_BIT) + SETUP_EVENT(RenderUnitLOSChanged, MANAGED_BIT | UNSYNCED_BIT) + + SETUP_EVENT(RenderFeatureCreated, MANAGED_BIT | UNSYNCED_BIT) + SETUP_EVENT(RenderFeatureDestroyed, MANAGED_BIT | UNSYNCED_BIT) + SETUP_EVENT(RenderFeatureMoved, MANAGED_BIT | UNSYNCED_BIT) + + SETUP_EVENT(RenderProjectileCreated, MANAGED_BIT | UNSYNCED_BIT) + SETUP_EVENT(RenderProjectileDestroyed, MANAGED_BIT | UNSYNCED_BIT) + + SETUP_EVENT(GameProgress, MANAGED_BIT | UNSYNCED_BIT) + SETUP_EVENT(GameID, MANAGED_BIT) + + SETUP_EVENT(RenderUnitMoved, MANAGED_BIT | UNSYNCED_BIT) + + SETUP_EVENT(SyncedActionFallback, MANAGED_BIT | CONTROL_BIT) + + SETUP_EVENT(CommandFallback, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowCommand, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowUnitCreation, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowUnitTransfer, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowUnitBuildStep, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowFeatureCreation, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowFeatureBuildStep, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowResourceLevel, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowResourceTransfer, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowDirectUnitControl, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowBuilderHoldFire, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowStartPosition, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(TerraformComplete, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(MoveCtrlNotify, MANAGED_BIT | CONTROL_BIT) + + SETUP_EVENT(AllowWeaponTargetCheck, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowWeaponTarget, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(AllowWeaponInterceptTarget, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(UnitPreDamaged, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(FeaturePreDamaged, MANAGED_BIT | CONTROL_BIT) + SETUP_EVENT(ShieldPreDamaged, MANAGED_BIT | CONTROL_BIT) + + SETUP_EVENT(DrawUnit, MANAGED_BIT | UNSYNCED_BIT | CONTROL_BIT) + SETUP_EVENT(DrawFeature, MANAGED_BIT | UNSYNCED_BIT | CONTROL_BIT) + SETUP_EVENT(DrawShield, MANAGED_BIT | UNSYNCED_BIT | CONTROL_BIT) + SETUP_EVENT(DrawProjectile, MANAGED_BIT | UNSYNCED_BIT | CONTROL_BIT) // unmanaged call-ins - SETUP_UNMANAGED_EVENT(Shutdown, 0); - SETUP_UNMANAGED_EVENT(RecvLuaMsg, 0); + SETUP_UNMANAGED_EVENT(Shutdown, 0) + SETUP_UNMANAGED_EVENT(RecvLuaMsg, 0) + SETUP_UNMANAGED_EVENT(GotChatMsg, CONTROL_BIT) - SETUP_UNMANAGED_EVENT(DrawUnit, UNSYNCED_BIT); - SETUP_UNMANAGED_EVENT(DrawFeature, UNSYNCED_BIT); - SETUP_UNMANAGED_EVENT(RecvSkirmishAIMessage, UNSYNCED_BIT); + SETUP_UNMANAGED_EVENT(RecvSkirmishAIMessage, UNSYNCED_BIT) // LuaUI - SETUP_UNMANAGED_EVENT(ConfigureLayout, UNSYNCED_BIT | CONTROL_BIT); - - // LuaRules - SETUP_UNMANAGED_EVENT(CommandFallback, CONTROL_BIT); - SETUP_UNMANAGED_EVENT(AllowCommand, CONTROL_BIT); - SETUP_UNMANAGED_EVENT(AllowUnitCreation, CONTROL_BIT); - SETUP_UNMANAGED_EVENT(AllowUnitTransfer, CONTROL_BIT); - SETUP_UNMANAGED_EVENT(AllowUnitBuildStep, CONTROL_BIT); - SETUP_UNMANAGED_EVENT(AllowFeatureCreation, CONTROL_BIT); - SETUP_UNMANAGED_EVENT(AllowFeatureBuildStep, CONTROL_BIT); - SETUP_UNMANAGED_EVENT(AllowResourceLevel, CONTROL_BIT); - SETUP_UNMANAGED_EVENT(AllowResourceTransfer, CONTROL_BIT); - SETUP_UNMANAGED_EVENT(AllowDirectUnitControl, CONTROL_BIT); - SETUP_UNMANAGED_EVENT(AllowStartPosition, CONTROL_BIT); - SETUP_UNMANAGED_EVENT(TerraformComplete, CONTROL_BIT); - SETUP_UNMANAGED_EVENT(MoveCtrlNotify, CONTROL_BIT); - SETUP_UNMANAGED_EVENT(UnitPreDamaged, CONTROL_BIT); - SETUP_UNMANAGED_EVENT(FeaturePreDamaged, CONTROL_BIT); - SETUP_UNMANAGED_EVENT(ShieldPreDamaged, CONTROL_BIT); - SETUP_UNMANAGED_EVENT(AllowWeaponTargetCheck, CONTROL_BIT); - SETUP_UNMANAGED_EVENT(AllowWeaponTarget, CONTROL_BIT); + SETUP_UNMANAGED_EVENT(ConfigureLayout, UNSYNCED_BIT | CONTROL_BIT) // LuaIntro - SETUP_UNMANAGED_EVENT(DrawLoadScreen, UNSYNCED_BIT); - SETUP_UNMANAGED_EVENT(LoadProgress, UNSYNCED_BIT); + SETUP_UNMANAGED_EVENT(DrawLoadScreen, UNSYNCED_BIT) + SETUP_UNMANAGED_EVENT(LoadProgress, UNSYNCED_BIT) // System - SETUP_EVENT(CollectGarbage, MANAGED_BIT | UNSYNCED_BIT); + SETUP_EVENT(CollectGarbage, MANAGED_BIT) + SETUP_EVENT(DbgTimingInfo, MANAGED_BIT | UNSYNCED_BIT) // informs about video-/sim-frame start & end times -#pragma pop_macro("SETUP_EVENT") -#pragma pop_macro("SETUP_UNMANAGED_EVENT") +#ifndef SETUP_EVENT + #pragma pop_macro("SETUP_EVENT") +#endif + +#ifndef SETUP_UNMANAGED_EVENT + #pragma pop_macro("SETUP_UNMANAGED_EVENT") +#endif + diff -Nru spring-96.0~14.04~ppa4/rts/System/Exceptions.h spring-98.0~14.04~ppa6/rts/System/Exceptions.h --- spring-96.0~14.04~ppa4/rts/System/Exceptions.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Exceptions.h 2014-10-07 20:09:51.000000000 +0000 @@ -6,14 +6,6 @@ #include -/** @brief Compile time assertion - @param condition Condition to test for. - @param message Message to include in the compile error if the assert fails. - This must be a valid C++ symbol. */ -#define COMPILE_TIME_ASSERT(condition, message) \ - typedef int _compile_time_assertion_failed__ ## message [(condition) ? 1 : -1] - - /** * user_error * thrown when a enduser config is broken/invalid. @@ -59,4 +51,16 @@ unsupported_error(const std::string& msg) : std::runtime_error(msg) {}; }; + +/** + * network_error + * thrown when udp socket can't be bound or hostname can't be resolved + */ +class network_error : public std::runtime_error +{ +public: + network_error(const std::string& msg) : std::runtime_error(msg) {}; +}; + + #endif diff -Nru spring-96.0~14.04~ppa4/rts/System/FileSystem/Archives/IArchive.h spring-98.0~14.04~ppa6/rts/System/FileSystem/Archives/IArchive.h --- spring-96.0~14.04~ppa4/rts/System/FileSystem/Archives/IArchive.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/FileSystem/Archives/IArchive.h 2014-10-07 20:09:51.000000000 +0000 @@ -88,6 +88,11 @@ * @return true if cost is ~ relative to its file-size */ virtual bool HasLowReadingCost(unsigned int fid) const; + + /** + * @return true if archive type can be packed solid (which is VERY slow when reading) + */ + virtual bool CheckForSolid() const { return false; } /** * Fetches the CRC32 hash of a file by its ID. */ diff -Nru spring-96.0~14.04~ppa4/rts/System/FileSystem/Archives/SevenZipArchive.cpp spring-98.0~14.04~ppa6/rts/System/FileSystem/Archives/SevenZipArchive.cpp --- spring-96.0~14.04~ppa4/rts/System/FileSystem/Archives/SevenZipArchive.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/FileSystem/Archives/SevenZipArchive.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -127,7 +127,7 @@ WRes wres = InFile_Open(&archiveStream.file, name.c_str()); if (wres) { boost::system::error_code e(wres, boost::system::get_system_category()); - LOG_L(L_ERROR, "Error opening %s: %s (%i)", + LOG_L(L_ERROR, "Error opening \"%s\": %s (%i)", name.c_str(), e.message().c_str(), e.value()); return; } @@ -145,7 +145,7 @@ isOpen = true; } else { isOpen = false; - LOG_L(L_ERROR, "Error opening %s: %s", name.c_str(), GetErrorStr(res)); + LOG_L(L_ERROR, "Error opening \"%s\": %s", name.c_str(), GetErrorStr(res)); return; } diff -Nru spring-96.0~14.04~ppa4/rts/System/FileSystem/Archives/SevenZipArchive.h spring-98.0~14.04~ppa6/rts/System/FileSystem/Archives/SevenZipArchive.h --- spring-96.0~14.04~ppa4/rts/System/FileSystem/Archives/SevenZipArchive.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/FileSystem/Archives/SevenZipArchive.h 2014-10-07 20:09:51.000000000 +0000 @@ -6,7 +6,7 @@ extern "C" { #include "lib/7z/7zFile.h" #include "lib/7z/7z.h" -}; +} #include "ArchiveFactory.h" #include "BufferedArchive.h" @@ -21,6 +21,7 @@ class CSevenZipArchiveFactory : public IArchiveFactory { public: CSevenZipArchiveFactory(); + bool CheckForSolid() const { return true; } private: IArchive* DoCreateArchive(const std::string& filePath) const; }; diff -Nru spring-96.0~14.04~ppa4/rts/System/FileSystem/Archives/ZipArchive.cpp spring-98.0~14.04~ppa6/rts/System/FileSystem/Archives/ZipArchive.cpp --- spring-96.0~14.04~ppa4/rts/System/FileSystem/Archives/ZipArchive.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/FileSystem/Archives/ZipArchive.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -27,7 +27,7 @@ { zip = unzOpen(archiveName.c_str()); if (!zip) { - LOG_L(L_ERROR, "Error opening %s", archiveName.c_str()); + LOG_L(L_ERROR, "Error opening \"%s\"", archiveName.c_str()); return; } diff -Nru spring-96.0~14.04~ppa4/rts/System/FileSystem/ArchiveScanner.cpp spring-98.0~14.04~ppa6/rts/System/FileSystem/ArchiveScanner.cpp --- spring-96.0~14.04~ppa4/rts/System/FileSystem/ArchiveScanner.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/FileSystem/ArchiveScanner.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -44,7 +44,7 @@ * but mapping them all, every time to make the list is) */ -const int INTERNAL_VER = 9; +const int INTERNAL_VER = 10; CArchiveScanner* archiveScanner = NULL; @@ -86,25 +86,24 @@ return; } - std::vector::const_iterator key; - for (key = keys.begin(); key != keys.end(); ++key) { - const std::string& keyLower = StringToLower(*key); + for (std::string& key: keys) { + const std::string keyLower = StringToLower(key); if (!ArchiveData::IsReservedKey(keyLower)) { if (keyLower == "modtype") { - SetInfoItemValueInteger(*key, archiveTable.GetInt(*key, 0)); + SetInfoItemValueInteger(key, archiveTable.GetInt(key, 0)); continue; } - const int luaType = archiveTable.GetType(*key); + const int luaType = archiveTable.GetType(key); switch (luaType) { case LuaTable::STRING: { - SetInfoItemValueString(*key, archiveTable.GetString(*key, "")); + SetInfoItemValueString(key, archiveTable.GetString(key, "")); } break; case LuaTable::NUMBER: { - SetInfoItemValueFloat(*key, archiveTable.GetFloat(*key, 0.0f)); + SetInfoItemValueFloat(key, archiveTable.GetFloat(key, 0.0f)); } break; case LuaTable::BOOLEAN: { - SetInfoItemValueBool(*key, archiveTable.GetBool(*key, false)); + SetInfoItemValueBool(key, archiveTable.GetBool(key, false)); } break; default: { // just ignore unsupported types (most likely to be lua-tables) @@ -226,15 +225,14 @@ const std::map::iterator ii = info.find(keyLower); if (ii == info.end()) { // add a new info-item - InfoItem infoItem; + InfoItem& infoItem = info[keyLower]; infoItem.key = key; infoItem.valueType = INFO_VALUE_TYPE_INTEGER; infoItem.value.typeInteger = 0; - - info[keyLower] = infoItem; + return infoItem; } - return info[keyLower]; + return ii->second; } void CArchiveScanner::ArchiveData::SetInfoItemValueString(const std::string& key, const std::string& value) @@ -342,19 +340,18 @@ CArchiveScanner::CArchiveScanner() : isDirty(false) { - std::ostringstream file; - // the "cache" dir is created in DataDirLocater - file << FileSystem::GetCacheDir(); - file << FileSystem::GetNativePathSeparator(); - file << "ArchiveCache.lua"; - - cachefile = file.str(); - ReadCacheData(dataDirLocater.GetWriteDirPath() + GetFilename()); + const std:: string cacheFolder = dataDirLocater.GetWriteDirPath() + FileSystem::EnsurePathSepAtEnd(FileSystem::GetCacheBaseDir()); + cachefile = cacheFolder + IntToString(INTERNAL_VER, "ArchiveCache%i.lua"); + ReadCacheData(GetFilepath()); + if (archiveInfos.empty()) { + // when versioned ArchiveCache%i.lua is missing or empty, try old unversioned filename + ReadCacheData(cacheFolder + "ArchiveCache.lua"); + } const std::vector& datadirs = dataDirLocater.GetDataDirPaths(); std::vector scanDirs; - for (std::vector::const_reverse_iterator d = datadirs.rbegin(); d != datadirs.rend(); ++d) { + for (auto d = datadirs.rbegin(); d != datadirs.rend(); ++d) { scanDirs.push_back(*d + "maps"); scanDirs.push_back(*d + "base"); scanDirs.push_back(*d + "games"); @@ -362,19 +359,19 @@ } // ArchiveCache has been parsed at this point --> archiveInfos is populated ScanDirs(scanDirs, true); - WriteCacheData(dataDirLocater.GetWriteDirPath() + GetFilename()); + WriteCacheData(GetFilepath()); } CArchiveScanner::~CArchiveScanner() { if (isDirty) { - WriteCacheData(dataDirsAccess.LocateFile(GetFilename(), FileQueryFlags::WRITE)); + WriteCacheData(GetFilepath()); } } -const std::string& CArchiveScanner::GetFilename() const +const std::string& CArchiveScanner::GetFilepath() const { return cachefile; } @@ -382,21 +379,60 @@ void CArchiveScanner::ScanDirs(const std::vector& scanDirs, bool doChecksum) { - // add the archives - std::vector::const_iterator dir; - for (dir = scanDirs.begin(); dir != scanDirs.end(); ++dir) { - if (FileSystem::DirExists(*dir)) { - LOG("Scanning: %s", dir->c_str()); - Scan(*dir, doChecksum); + isDirty = true; + + // scan for all archives + std::list foundArchives; + for (const std::string& dir: scanDirs) { + if (FileSystem::DirExists(dir)) { + LOG("Scanning: %s", dir.c_str()); + ScanDir(dir, &foundArchives); + } + } + + // check for duplicates reached by links + //XXX too slow also ScanArchive() skips duplicates itself, too + /*for (auto it = foundArchives.begin(); it != foundArchives.end(); ++it) { + auto jt = it; + ++jt; + while (jt != foundArchives.end()) { + std::string f1 = StringToLower(FileSystem::GetFilename(*it)); + std::string f2 = StringToLower(FileSystem::GetFilename(*jt)); + if ((f1 == f2) || FileSystem::ComparePaths(*it, *jt)) { + jt = foundArchives.erase(jt); + } else { + ++jt; + } + } + }*/ + + // Create archiveInfos etc. when not being in cache already + for (const std::string& archive: foundArchives) { + ScanArchive(archive, doChecksum); + #if !defined(DEDICATED) && !defined(UNITSYNC) + Watchdog::ClearTimer(WDT_MAIN); + #endif + } + + // Now we'll have to parse the replaces-stuff found in the mods + for (auto& aii: archiveInfos) { + for (std::string& replaceName: aii.second.archiveData.GetReplaces()) { + // Overwrite the info for this archive with a replaced pointer + const std::string lcname = StringToLower(replaceName); + ArchiveInfo& ai = archiveInfos[lcname]; + ai.path = ""; + ai.origName = lcname; + ai.modified = 1; + ai.archiveData = ArchiveData(); + ai.updated = true; + ai.replaced = aii.first; } } } -void CArchiveScanner::Scan(const std::string& curPath, bool doChecksum) +void CArchiveScanner::ScanDir(const std::string& curPath, std::list* foundArchives) { - isDirty = true; - // check recursive dirs when NOT being sdd's! std::list subDirs; subDirs.push_back(curPath); @@ -406,78 +442,81 @@ const std::vector& found = dataDirsAccess.FindFiles(subDirs.front(), "*", FileQueryFlags::INCLUDE_DIRS); subDirs.pop_front(); - for (auto f: found) { - std::string fullName = f; - - // Strip - const char lastFullChar = fullName[fullName.size() - 1]; - if ((lastFullChar == '/') || (lastFullChar == '\\')) { - fullName = fullName.substr(0, fullName.size() - 1); - } - - const std::string fpath = FileSystem::GetDirectory(fullName); - const std::string lcfpath = StringToLower(fpath); + for (std::string fullName: found) { + FileSystem::EnsureNoPathSepAtEnd(fullName); + const std::string lcfpath = StringToLower(FileSystem::GetDirectory(fullName)); // Exclude archivefiles found inside directory archives (.sdd) if (lcfpath.find(".sdd") != std::string::npos) { continue; } - // Exclude archivefiles found inside hidden directories - if ((lcfpath.find("/hidden/") != std::string::npos) || - (lcfpath.find("\\hidden\\") != std::string::npos)) { - continue; - } - - #if !defined(DEDICATED) && !defined(UNITSYNC) - Watchdog::ClearTimer(WDT_MAIN); - #endif // !defined(DEDICATED) && !defined(UNITSYNC) - // Is this an archive we should look into? if (archiveLoader.IsArchiveFile(fullName)) { - ScanArchive(fullName, doChecksum); + foundArchives->push_front(fullName); // push by reversed order! } else if (FileSystem::DirExists(fullName)) { subDirs.push_back(fullName); } } } +} - // Now we'll have to parse the replaces-stuff found in the mods - for (auto aii: archiveInfos) { - for (auto i: aii.second.archiveData.GetReplaces()) { - const std::string lcname = StringToLower(i); - auto ar = archiveInfos.find(lcname); - - // If it's not there, we will create a new entry - if (ar == archiveInfos.end()) { - ArchiveInfo tmp; - archiveInfos[lcname] = tmp; - ar = archiveInfos.find(lcname); - } +static void AddDependency(std::vector& deps, const std::string& dependency) +{ + auto it = std::find(deps.begin(), deps.end(), dependency); + if (it != deps.end()) return; + deps.push_back(dependency); +} - // Overwrite the info for this archive with a replaced pointer - ar->second.path = ""; - ar->second.origName = lcname; - ar->second.modified = 1; - - ArchiveData empty; - ar->second.archiveData = empty; - ar->second.updated = true; - ar->second.replaced = aii.first; +bool CArchiveScanner::CheckCompression(const IArchive* ar,const std::string& fullName, std::string& error) +{ + if (!ar->CheckForSolid()) + return true; + for (unsigned fid = 0; fid != ar->NumFiles(); ++fid) { + std::string name; + int size; + ar->FileInfo(fid, name, size); + const std::string lowerName = StringToLower(name); + const auto metaFileClass = CArchiveScanner::GetMetaFileClass(lowerName); + if ((metaFileClass == 0) || ar->HasLowReadingCost(fid)) + continue; + + // is a meta-file and not cheap to read + if (metaFileClass == 1) { + // 1st class + error = "Unpacking/reading cost for meta file " + name + + " is too high, please repack the archive (make sure to use a non-solid algorithm, if applicable)"; + return false; + } else if (metaFileClass == 2) { + // 2nd class + LOG_SL(LOG_SECTION_ARCHIVESCANNER, L_WARNING, + "Archive %s: The cost for reading a 2nd-class meta-file is too high: %s", + fullName.c_str(), name.c_str()); } + } + return true; } -static void AddDependency(std::vector& deps, const std::string& dependency) +std::string CArchiveScanner::SearchMapFile(const IArchive* ar, std::string& error) { - for (std::vector::iterator it = deps.begin(); it != deps.end(); ++it) { - if (*it == dependency) { - return; + assert(ar!=NULL); + + // check for smf/sm3 and if the uncompression of important files is too costy + for (unsigned fid = 0; fid != ar->NumFiles(); ++fid) { + std::string name; + int size; + ar->FileInfo(fid, name, size); + const std::string lowerName = StringToLower(name); + const std::string ext = FileSystem::GetExtension(lowerName); + + if ((ext == "smf") || (ext == "sm3")) { + return name; } - } - deps.push_back(dependency); + } + return ""; } void CArchiveScanner::ScanArchive(const std::string& fullName, bool doChecksum) @@ -486,10 +525,6 @@ const std::string fpath = FileSystem::GetDirectory(fullName); const std::string lcfn = StringToLower(fn); - // Cache variables - std::map::iterator aii; - bool cached = false; - // Stat file struct stat info = {0}; int statfailed = stat(fullName.c_str(), &info); @@ -497,7 +532,7 @@ // If stat fails, assume the archive is not broken nor cached if (!statfailed) { // Determine whether this archive has earlier be found to be broken - auto bai = brokenArchives.find(lcfn); + std::map::iterator bai = brokenArchives.find(lcfn); if (bai != brokenArchives.end()) { if ((unsigned)info.st_mtime == bai->second.modified && fpath == bai->second.path) { bai->second.updated = true; @@ -506,16 +541,26 @@ } // Determine whether to rely on the cached info or not - if ((aii = archiveInfos.find(lcfn)) != archiveInfos.end()) { + std::map::iterator aii = archiveInfos.find(lcfn); + if (aii != archiveInfos.end()) { // This archive may have been obsoleted, do not process it if so if (!aii->second.replaced.empty()) { return; } if ((unsigned)info.st_mtime == aii->second.modified && fpath == aii->second.path) { + // cache found update checksum if wanted aii->second.updated = true; - cached = true; + if (doChecksum && (aii->second.checksum == 0)) { + aii->second.checksum = GetCRC(fullName); + } + return; } else { + if (aii->second.updated) { + LOG_L(L_ERROR, "Found a \"%s\" already in \"%s\", ignoring one in \"%s\"", aii->first.c_str(), aii->second.path.c_str(), fpath.c_str()); + return; + } + // If we are here, we could have invalid info in the cache // Force a reread if it is a directory archive (.sdd), as // st_mtime only reflects changes to the directory itself, @@ -525,26 +570,16 @@ } } - // Time to parse the info we are interested in - if (cached) { - // If cached is true, aii will point to the archive - if (doChecksum && (aii->second.checksum == 0)) { - aii->second.checksum = GetCRC(fullName); - } - return; - } - boost::scoped_ptr ar(archiveLoader.OpenArchive(fullName)); if (!ar || !ar->IsOpen()) { - LOG("Unable to open archive: %s", fullName.c_str()); + LOG_L(L_WARNING, "Unable to open archive: %s", fullName.c_str()); // record it as broken, so we don't need to look inside everytime - BrokenArchive ba; + BrokenArchive& ba = brokenArchives[lcfn]; ba.path = fpath; ba.modified = info.st_mtime; ba.updated = true; ba.problem = "Unable to open archive"; - brokenArchives[lcfn] = ba; return; } @@ -554,125 +589,86 @@ const bool hasModinfo = ar->FileExists("modinfo.lua"); const bool hasMapinfo = ar->FileExists("mapinfo.lua"); - // check for smf/sm3 and if the uncompression of important files is too costy - for (unsigned fid = 0; fid != ar->NumFiles(); ++fid) { - std::string name; - int size; - ar->FileInfo(fid, name, size); - const std::string lowerName = StringToLower(name); - const std::string ext = FileSystem::GetExtension(lowerName); - if ((ext == "smf") || (ext == "sm3")) { - mapfile = name; + ArchiveInfo ai; + auto& ad = ai.archiveData; + if (hasMapinfo) { + ScanArchiveLua(ar.get(), "mapinfo.lua", ai, error); + if (ad.GetMapFile().empty()) { + LOG_L(L_WARNING, "%s: mapfile isn't set in mapinfo.lua, please set it for faster loading!", fullName.c_str()); + mapfile = SearchMapFile(ar.get(), error); } + } else if (hasModinfo) { + ScanArchiveLua(ar.get(), "modinfo.lua", ai, error); + } else { + mapfile = SearchMapFile(ar.get(), error); + } + CheckCompression(ar.get(), fullName, error); - const unsigned char metaFileClass = GetMetaFileClass(lowerName); - if ((metaFileClass != 0) && !(ar->HasLowReadingCost(fid))) { - // is a meta-file and not cheap to read - if (metaFileClass == 1) { - // 1st class - error = "Unpacking/reading cost for meta file " + name - + " is too high, please repack the archive (make sure to use a non-solid algorithm, if applicable)"; - break; - } else if (metaFileClass == 2) { - // 2nd class - LOG_SL(LOG_SECTION_ARCHIVESCANNER, L_WARNING, - "Archive %s: The cost for reading a 2nd-class meta-file is too high: %s", - fullName.c_str(), name.c_str()); - } - } + if (!error.empty()) { + // for some reason, the archive is marked as broken + LOG_L(L_WARNING, "Failed to scan %s (%s)", fullName.c_str(), error.c_str()); + + // record it as broken, so we don't need to look inside everytime + BrokenArchive& ba = brokenArchives[lcfn]; + ba.path = fpath; + ba.modified = info.st_mtime; + ba.updated = true; + ba.problem = error; + return; } - ArchiveInfo ai; if (hasMapinfo || !mapfile.empty()) { // it is a map - if (hasMapinfo) { - ScanArchiveLua(ar.get(), "mapinfo.lua", ai, error); - } else if (hasModinfo) { - // backwards-compat for modinfo.lua in maps - ScanArchiveLua(ar.get(), "modinfo.lua", ai, error); - } - - if (ai.archiveData.GetName().empty()) { + if (ad.GetName().empty()) { // FIXME The name will never be empty, if version is set (see HACK in ArchiveData) - ai.archiveData.SetInfoItemValueString("name_pure", FileSystem::GetBasename(mapfile)); - ai.archiveData.SetInfoItemValueString("name", FileSystem::GetBasename(mapfile)); + ad.SetInfoItemValueString("name_pure", FileSystem::GetBasename(mapfile)); + ad.SetInfoItemValueString("name", FileSystem::GetBasename(mapfile)); } - if (ai.archiveData.GetMapFile().empty()) { - ai.archiveData.SetInfoItemValueString("mapfile", mapfile); + if (ad.GetMapFile().empty()) { + ad.SetInfoItemValueString("mapfile", mapfile); } - AddDependency(ai.archiveData.GetDependencies(), "Map Helper v1"); - ai.archiveData.SetInfoItemValueInteger("modType", modtype::map); + AddDependency(ad.GetDependencies(), "Map Helper v1"); + ad.SetInfoItemValueInteger("modType", modtype::map); - LOG_S(LOG_SECTION_ARCHIVESCANNER, "Found new map: %s", - ai.archiveData.GetNameVersioned().c_str()); + LOG_S(LOG_SECTION_ARCHIVESCANNER, "Found new map: %s", ad.GetNameVersioned().c_str()); } else if (hasModinfo) { - // it is a mod - ScanArchiveLua(ar.get(), "modinfo.lua", ai, error); - if (ai.archiveData.GetModType() == modtype::primary) { - AddDependency(ai.archiveData.GetDependencies(), "Spring content v1"); + // it is a game + if (ad.GetModType() == modtype::primary) { + AddDependency(ad.GetDependencies(), "Spring content v1"); } - LOG_S(LOG_SECTION_ARCHIVESCANNER, "Found new game: %s", - ai.archiveData.GetNameVersioned().c_str()); + LOG_S(LOG_SECTION_ARCHIVESCANNER, "Found new game: %s", ad.GetNameVersioned().c_str()); } else { // neither a map nor a mod: error error = "missing modinfo.lua/mapinfo.lua"; } - if (!error.empty()) { - // for some reason, the archive is marked as broken - LOG_L(L_WARNING, "Failed to scan %s (%s)", - fullName.c_str(), error.c_str()); - - // record it as broken, so we don't need to look inside everytime - BrokenArchive ba; - ba.path = fpath; - ba.modified = info.st_mtime; - ba.updated = true; - ba.problem = error; - brokenArchives[lcfn] = ba; - return; - } - ai.path = fpath; ai.modified = info.st_mtime; ai.origName = fn; ai.updated = true; - - // Optionally calculate a checksum for the file - // To prevent reading all files in all directory (.sdd) archives - // every time this function is called, directory archive checksums - // are calculated on the fly. - if (doChecksum) { - ai.checksum = GetCRC(fullName); - } else { - ai.checksum = 0; - } - + ai.checksum = (doChecksum) ? GetCRC(fullName) : 0; archiveInfos[lcfn] = ai; } bool CArchiveScanner::ScanArchiveLua(IArchive* ar, const std::string& fileName, ArchiveInfo& ai, std::string& err) { std::vector buf; - if (!ar->GetFile(fileName, buf)) { + if (!ar->GetFile(fileName, buf) || buf.empty()) { + err = "Error reading " + fileName + " from " + ar->GetArchiveName(); return false; } - const std::string cleanbuf((char*)(&buf[0]), buf.size()); - LuaParser p(cleanbuf, SPRING_VFS_MOD); - + LuaParser p(std::string((char*)(&buf[0]), buf.size()), SPRING_VFS_MOD); if (!p.Execute()) { err = "Error in " + fileName + ": " + p.GetErrorLog(); return false; } - const LuaTable& archiveTable = p.GetRoot(); - try { - ai.archiveData = CArchiveScanner::ArchiveData(archiveTable, false); + ai.archiveData = CArchiveScanner::ArchiveData(p.GetRoot(), false); if (!ai.archiveData.IsValid(err)) { err = "Error in " + fileName + ": " + err; @@ -690,12 +686,9 @@ { IFileFilter* ignore = IFileFilter::Create(); std::vector buf; - if (ar->GetFile("springignore.txt", buf)) { + if (ar->GetFile("springignore.txt", buf) || buf.empty()) { // this automatically splits lines - if (!buf.empty()) { - const std::string cleanbuf((char*)(&buf[0]), buf.size()); - ignore->AddRule(cleanbuf); - } + ignore->AddRule(std::string((char*)(&buf[0]), buf.size())); } return ignore; } @@ -749,8 +742,8 @@ std::vector crcs; crcs.reserve(files.size()); CRCPair crcp; - for (std::list::iterator it = files.begin(); it != files.end(); ++it) { - crcp.filename = &(*it); + for (std::string& f: files) { + crcp.filename = &f; crcs.push_back(crcp); } @@ -761,7 +754,7 @@ // current (2011) packing libraries support multithreading :/ for_mt(0, crcs.size(), [&](const int i) { CRCPair& crcp = crcs[i]; - const unsigned int nameCRC = CRC().Update(crcp.filename->data(), crcp.filename->size()).GetDigest(); + const unsigned int nameCRC = CRC::GetCRC(crcp.filename->data(), crcp.filename->size()); const unsigned fid = ar->FindFile(*crcp.filename); const unsigned int dataCRC = ar->GetCrc32(fid); crcp.nameCRC = nameCRC; @@ -772,23 +765,19 @@ }); // Add file CRCs to the main archive CRC - for (std::vector::iterator it = crcs.begin(); it != crcs.end(); ++it) { - crc.Update(it->nameCRC); - crc.Update(it->dataCRC); + for (CRCPair& crcp: crcs) { + crc.Update(crcp.nameCRC); + crc.Update(crcp.dataCRC); #if !defined(DEDICATED) && !defined(UNITSYNC) Watchdog::ClearTimer(); #endif } - unsigned int digest = crc.GetDigest(); - // A value of 0 is used to indicate no crc.. so never return that // Shouldn't happen all that often - if (digest == 0) { - return 4711; - } else { - return digest; - } + unsigned int digest = crc.GetDigest(); + if (digest == 0) digest = 4711; + return digest; } void CArchiveScanner::ReadCacheData(const std::string& filename) @@ -799,14 +788,11 @@ } LuaParser p(filename, SPRING_VFS_RAW, SPRING_VFS_BASE); - if (!p.Execute()) { - LOG_L(L_ERROR, "Failed to parse archive cache: %s", - p.GetErrorLog().c_str()); + LOG_L(L_ERROR, "Failed to parse archive cache: %s", p.GetErrorLog().c_str()); return; } const LuaTable archiveCache = p.GetRoot(); - const LuaTable archives = archiveCache.SubTable("archives"); // Do not load old version caches const int ver = archiveCache.GetInt("internalVer", (INTERNAL_VER + 1)); @@ -814,12 +800,14 @@ return; } + const LuaTable archives = archiveCache.SubTable("archives"); for (int i = 1; archives.KeyExists(i); ++i) { const LuaTable curArchive = archives.SubTable(i); const LuaTable archived = curArchive.SubTable("archivedata"); - ArchiveInfo ai; + std::string name = curArchive.GetString("name", ""); - ai.origName = curArchive.GetString("name", ""); + ArchiveInfo& ai = archiveInfos[StringToLower(name)]; + ai.origName = name; ai.path = curArchive.GetString("path", ""); // do not use LuaTable.GetInt() for 32-bit integers, the Spring lua @@ -835,25 +823,19 @@ } else if (ai.archiveData.GetModType() == modtype::primary) { AddDependency(ai.archiveData.GetDependencies(), "Spring content v1"); } - - std::string lcname = StringToLower(ai.origName); - archiveInfos[lcname] = ai; } const LuaTable brokenArchives = archiveCache.SubTable("brokenArchives"); - for (int i = 1; brokenArchives.KeyExists(i); ++i) { const LuaTable curArchive = brokenArchives.SubTable(i); - BrokenArchive ba; std::string name = curArchive.GetString("name", ""); + StringToLowerInPlace(name); + BrokenArchive& ba = this->brokenArchives[name]; ba.path = curArchive.GetString("path", ""); ba.modified = strtoul(curArchive.GetString("modified", "0").c_str(), 0, 10); ba.updated = false; ba.problem = curArchive.GetString("problem", "unknown"); - - StringToLowerInPlace(name); - this->brokenArchives[name] = ba; } isDirty = false; @@ -864,27 +846,18 @@ if (str.empty()) { return; } - if (str.find_first_of("\\\"") == std::string::npos) { - fprintf(out, "%s\"%s\",\n", prefix, str.c_str()); - } else { + if ( (str.find_first_of("\\\"") != std::string::npos) || (str.find_first_of("\n") != std::string::npos )) { fprintf(out, "%s[[%s]],\n", prefix, str.c_str()); + } else { + fprintf(out, "%s\"%s\",\n", prefix, str.c_str()); } } void FilterDep(std::vector& deps, const std::string& exclude) { - bool clean = true; - do { - clean = true; - for (std::vector::iterator it = deps.begin(); it != deps.end(); ++it) { - if (*it == exclude) { - deps.erase(it); - clean = false; - break; - } - } - } while (!clean); -}; + auto it = std::remove_if(deps.begin(), deps.end(), [&](const std::string& dep) { return (dep == exclude); }); + deps.erase(it, deps.end()); +} void CArchiveScanner::WriteCacheData(const std::string& filename) { @@ -1016,16 +989,16 @@ std::vector ret; for (std::map::const_iterator i = archiveInfos.begin(); i != archiveInfos.end(); ++i) { - if (!(i->second.archiveData.GetName().empty()) && (i->second.archiveData.GetModType() == modtype::primary)) { + const ArchiveData& aid = i->second.archiveData; + if ((!aid.GetName().empty()) && (aid.GetModType() == modtype::primary)) { // Add the archive the mod is in as the first dependency - ArchiveData md = i->second.archiveData; + ArchiveData md = aid; md.GetDependencies().insert(md.GetDependencies().begin(), i->second.origName); ret.push_back(md); } } sortByName(ret); - return ret; } @@ -1035,24 +1008,40 @@ std::vector ret; for (std::map::const_iterator i = archiveInfos.begin(); i != archiveInfos.end(); ++i) { - if (!(i->second.archiveData.GetName().empty()) && ((i->second.archiveData.GetModType() == modtype::primary) || (i->second.archiveData.GetModType() == modtype::hidden))) { + const ArchiveData& aid = i->second.archiveData; + if ((!aid.GetName().empty()) && ((aid.GetModType() & (modtype::primary | modtype::hidden)) != 0)) { // Add the archive the mod is in as the first dependency - ArchiveData md = i->second.archiveData; + ArchiveData md = aid; md.GetDependencies().insert(md.GetDependencies().begin(), i->second.origName); ret.push_back(md); } } sortByName(ret); - return ret; } -std::vector CArchiveScanner::GetArchives(const std::string& root, int depth) const +std::vector CArchiveScanner::GetAllArchives() const +{ + std::vector ret; + + for (const auto& pair: archiveInfos) { + const ArchiveData& aid = pair.second.archiveData; + + // Add the archive the mod is in as the first dependency + ArchiveData md = aid; + md.GetDependencies().insert(md.GetDependencies().begin(), pair.second.origName); + ret.push_back(md); + } + + sortByName(ret); + return ret; +} + +std::vector CArchiveScanner::GetAllArchivesUsedBy(const std::string& root, int depth) const { - LOG_S(LOG_SECTION_ARCHIVESCANNER, "GetArchives: %s (depth %u)", - root.c_str(), depth); + LOG_S(LOG_SECTION_ARCHIVESCANNER, "GetArchives: %s (depth %u)", root.c_str(), depth); // Protect against circular dependencies // (worst case depth is if all archives form one huge dependency chain) if ((unsigned)depth > archiveInfos.size()) { @@ -1065,9 +1054,7 @@ if (aii == archiveInfos.end()) { #ifdef UNITSYNC // unresolved dep, add it, so unitsync still shows this file - if (!ret.empty()) { - ret.push_back(lcname); - } + ret.push_back(lcname); return ret; #else throw content_error("Archive \"" + lcname + "\" not found"); @@ -1079,24 +1066,22 @@ // FIXME instead of this, call this function recursively, to get the propper error handling aii = archiveInfos.find(aii->second.replaced); if (aii == archiveInfos.end()) { +#ifdef UNITSYNC + // unresolved dep, add it, so unitsync still shows this file + ret.push_back(lcname); + return ret; +#else throw content_error("Unknown error parsing archive replacements"); +#endif } } - ret.push_back(aii->second.path + aii->second.origName); - // add depth-first - for (std::vector::const_iterator i = aii->second.archiveData.GetDependencies().begin(); i != aii->second.archiveData.GetDependencies().end(); ++i) { - const std::vector& deps = GetArchives(*i, depth + 1); - - for (std::vector::const_iterator j = deps.begin(); j != deps.end(); ++j) { - if (std::find(ret.begin(), ret.end(), *j) == ret.end()) { - // add only if this dependency is not already somewhere - // in the chain (which can happen if ArchiveCache.lua has - // not been written yet) so its checksum is not XOR'ed - // with the running one multiple times (Get*Checksum()) - ret.push_back(*j); - } + ret.push_back(aii->second.path + aii->second.origName); + for (const std::string& dep: aii->second.archiveData.GetDependencies()) { + const std::vector& deps = GetAllArchivesUsedBy(dep, depth + 1); + for (const std::string& depSub: deps) { + AddDependency(ret, depSub); } } @@ -1125,8 +1110,7 @@ return aii->second.archiveData.GetMapFile(); } } - LOG_SL(LOG_SECTION_ARCHIVESCANNER, L_WARNING, - "map file of %s not found", s.c_str()); + LOG_SL(LOG_SECTION_ARCHIVESCANNER, L_WARNING, "map file of %s not found", s.c_str()); return s; } @@ -1137,26 +1121,23 @@ std::map::const_iterator aii = archiveInfos.find(lcname); if (aii == archiveInfos.end()) { - LOG_SL(LOG_SECTION_ARCHIVESCANNER, L_WARNING, - "%s checksum: not found (0)", name.c_str()); + LOG_SL(LOG_SECTION_ARCHIVESCANNER, L_WARNING, "%s checksum: not found (0)", name.c_str()); return 0; } - LOG_S(LOG_SECTION_ARCHIVESCANNER,"%s checksum: %d/%u", - name.c_str(), aii->second.checksum, aii->second.checksum); + LOG_S(LOG_SECTION_ARCHIVESCANNER,"%s checksum: %d/%u", name.c_str(), aii->second.checksum, aii->second.checksum); return aii->second.checksum; } unsigned int CArchiveScanner::GetArchiveCompleteChecksum(const std::string& name) const { - const std::vector &ars = GetArchives(name); + const std::vector& ars = GetAllArchivesUsedBy(name); unsigned int checksum = 0; for (unsigned int a = 0; a < ars.size(); a++) { checksum ^= GetSingleArchiveChecksum(ars[a]); } - LOG_S(LOG_SECTION_ARCHIVESCANNER, "archive checksum %s: %d/%u", - name.c_str(), checksum, checksum); + LOG_S(LOG_SECTION_ARCHIVESCANNER, "archive checksum %s: %d/%u", name.c_str(), checksum, checksum); return checksum; } @@ -1181,12 +1162,10 @@ std::string CArchiveScanner::GetArchivePath(const std::string& name) const { const std::string lcname = StringToLower(FileSystem::GetFilename(name)); - std::map::const_iterator aii = archiveInfos.find(lcname); if (aii == archiveInfos.end()) { return ""; } - return aii->second.path; } @@ -1208,7 +1187,6 @@ if (aii != archiveInfos.end()) { return aii->second.archiveData.GetNameVersioned(); } - return archiveName; } @@ -1220,7 +1198,6 @@ return md; } } - return ArchiveData(); } @@ -1229,7 +1206,8 @@ return GetArchiveData(NameFromArchive(archive)); } -unsigned char CArchiveScanner::GetMetaFileClass(const std::string& filePath) { +unsigned char CArchiveScanner::GetMetaFileClass(const std::string& filePath) +{ unsigned char metaFileClass = 0; diff -Nru spring-96.0~14.04~ppa4/rts/System/FileSystem/ArchiveScanner.h spring-98.0~14.04~ppa6/rts/System/FileSystem/ArchiveScanner.h --- spring-96.0~14.04~ppa4/rts/System/FileSystem/ArchiveScanner.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/FileSystem/ArchiveScanner.h 2014-10-07 20:09:51.000000000 +0000 @@ -5,6 +5,7 @@ #include #include +#include #include #include "System/Info.h" @@ -29,7 +30,7 @@ static const int primary = 1; static const int hidden = 0; static const int map = 3; -}; +} class CArchiveScanner { @@ -73,6 +74,7 @@ void SetInfoItemValueBool(const std::string& key, bool value); bool IsValid(std::string& error) const; + bool IsEmpty() const { return info.empty(); } static bool IsReservedKey(const std::string& keyLower); static std::string GetKeyDescription(const std::string& keyLower); @@ -98,21 +100,17 @@ CArchiveScanner(); ~CArchiveScanner(); - const std::string& GetFilename() const; +public: + const std::string& GetFilepath() const; + std::vector GetMaps() const; std::vector GetPrimaryMods() const; std::vector GetAllMods() const; - std::vector GetArchives(const std::string& root) const { - return GetArchives(root, 0); - } -private: - std::vector GetArchives(const std::string& root, int depth) const; -public: - /** - * Returns the (human-readable) map names. - */ - std::vector GetMaps() const; + std::vector GetAllArchives() const; + std::vector GetAllArchivesUsedBy(const std::string& root, int depth = 0) const; + +public: /// checksum of the given archive (without dependencies) unsigned int GetSingleArchiveChecksum(const std::string& name) const; /// Calculate checksum of the given archive and all its dependencies @@ -128,25 +126,6 @@ ArchiveData GetArchiveData(const std::string& name) const; ArchiveData GetArchiveDataByArchive(const std::string& archive) const; - /** - * Returns a value > 0 if the file is rated as a meta-file. - * First class means, it is essential for the archive, and will be read by - * pretty much every software that scanns through archives. - * Second class means, it is not essential for the archive, but it may be - * read by certain tools that generate spezialized indices while scanning - * through archives. - * Examples: - * "objects3d/ddm.s3o" -> 0 - * "ModInfo.lua" -> 1 - * "maps/dsd.smf" -> 1 - * "LuaAI.lua" -> 2 - * "sides/arm.bmp" -> 2 - * @param filePath file path, relative to archive-root - * @return 0 if the file is not a meta-file, - * 1 if the file is a first class meta-file, - * 2 if the file is a second class meta-file - */ - static unsigned char GetMetaFileClass(const std::string& filePath); private: struct ArchiveInfo @@ -178,11 +157,18 @@ private: void ScanDirs(const std::vector& dirs, bool checksum = false); - void Scan(const std::string& curPath, bool doChecksum); + void ScanDir(const std::string& curPath, std::list* foundArchives); /// scan mapinfo / modinfo lua files bool ScanArchiveLua(IArchive* ar, const std::string& fileName, ArchiveInfo& ai, std::string& err); + /** + * scan archive for map file + * @return file name if found, empty string if not + */ + std::string SearchMapFile(const IArchive* ar, std::string& error); + + void ReadCacheData(const std::string& filename); void WriteCacheData(const std::string& filename); @@ -194,6 +180,27 @@ */ unsigned int GetCRC(const std::string& filename); + /** + * Returns a value > 0 if the file is rated as a meta-file. + * First class means, it is essential for the archive, and will be read by + * pretty much every software that scans through archives. + * Second class means, it is not essential for the archive, but it may be + * read by certain tools that generate spezialized indices while scanning + * through archives. + * Examples: + * "objects3d/ddm.s3o" -> 0 + * "ModInfo.lua" -> 1 + * "maps/dsd.smf" -> 1 + * "LuaAI.lua" -> 2 + * "sides/arm.bmp" -> 2 + * @param filePath file path, relative to archive-root + * @return 0 if the file is not a meta-file, + * 1 if the file is a first class meta-file, + * 2 if the file is a second class meta-file + */ + static unsigned char GetMetaFileClass(const std::string& filePath); + static bool CheckCompression(const IArchive* ar,const std::string& fullName, std::string& error); + private: std::map archiveInfos; std::map brokenArchives; diff -Nru spring-96.0~14.04~ppa4/rts/System/FileSystem/DataDirsAccess.cpp spring-98.0~14.04~ppa6/rts/System/FileSystem/DataDirsAccess.cpp --- spring-96.0~14.04~ppa4/rts/System/FileSystem/DataDirsAccess.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/FileSystem/DataDirsAccess.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -20,16 +20,8 @@ return std::vector(); } - if (dir.empty()) { - dir = "./"; - } else { - const char lastChar = dir[dir.length() - 1]; - if ((lastChar != '/') && (lastChar != '\\')) { - dir += '/'; - } - } - FileSystem::FixSlashes(dir); + FileSystem::EnsurePathSepAtEnd(dir); if (flags & FileQueryFlags::ONLY_DIRS) { flags |= FileQueryFlags::INCLUDE_DIRS; @@ -53,7 +45,7 @@ std::string dir2 = FileSystem::RemoveLocalPathPrefix(dir); const std::vector& datadirs = dataDirLocater.GetDataDirs(); - for (std::vector::const_reverse_iterator d = datadirs.rbegin(); d != datadirs.rend(); ++d) { + for (auto d = datadirs.crbegin(); d != datadirs.crend(); ++d) { FindFilesSingleDir(matches, d->path, dir2, pattern, flags); } return matches; @@ -67,8 +59,8 @@ } const std::vector& datadirs = dataDirLocater.GetDataDirs(); - for (std::vector::const_iterator d = datadirs.begin(); d != datadirs.end(); ++d) { - std::string fn(d->path + file); + for (const DataDir& d: datadirs) { + std::string fn(d.path + file); // does the file exist, and is it readable? if (FileSystem::IsReadableFile(fn)) { return fn; @@ -115,18 +107,16 @@ return LocateFileInternal(file); } -std::string DataDirsAccess::LocateDir(std::string _dir, int flags) const +std::string DataDirsAccess::LocateDir(std::string dir, int flags) const { - if (!FileSystem::CheckFile(_dir)) { + if (!FileSystem::CheckFile(dir)) { return ""; } - // if it's an absolute path, don't look for it in the data directories - if (FileSystem::IsAbsolutePath(_dir)) { - return _dir; + if (FileSystem::IsAbsolutePath(dir)) { + return dir; } - std::string dir = _dir; FileSystem::FixSlashes(dir); if (flags & FileQueryFlags::WRITE) { @@ -138,9 +128,8 @@ return writeableDir; } else { const std::vector& datadirs = dataDirLocater.GetDataDirPaths(); - std::vector::const_iterator dd; - for (dd = datadirs.begin(); dd != datadirs.end(); ++dd) { - std::string dirPath((*dd) + dir); + for (const std::string& dd: datadirs) { + std::string dirPath(dd + dir); if (FileSystem::DirExists(dirPath)) { return dirPath; } @@ -148,21 +137,19 @@ return dir; } } -std::vector DataDirsAccess::LocateDirs(const std::string& _dir) const +std::vector DataDirsAccess::LocateDirs(std::string dir) const { std::vector found; - if (!FileSystem::CheckFile(_dir) || FileSystem::IsAbsolutePath(_dir)) { + if (!FileSystem::CheckFile(dir) || FileSystem::IsAbsolutePath(dir)) { return found; } - std::string dir = _dir; FileSystem::FixSlashes(dir); const std::vector& datadirs = dataDirLocater.GetDataDirPaths(); - std::vector::const_iterator dd; - for (dd = datadirs.begin(); dd != datadirs.end(); ++dd) { - std::string dirPath((*dd) + dir); + for (const std::string& dd: datadirs) { + std::string dirPath(dd + dir); if (FileSystem::DirExists(dirPath)) { found.push_back(dirPath); } @@ -179,22 +166,21 @@ static const std::string pattern = "*"; // list of all occurences of the relative path in the data directories - const std::vector &rootDirs = LocateDirs(relPath); + const std::vector& rootDirs = LocateDirs(relPath); // list of subdirs in all occurences of the relative path in the data directories std::vector mainDirs; // find all subdirectories in the rootDirs - std::vector::const_iterator dir; - for (dir = rootDirs.begin(); dir != rootDirs.end(); ++dir) { - const std::vector& localMainDirs = CFileHandler::SubDirs(*dir, pattern, SPRING_VFS_RAW); + for (const std::string& dir: rootDirs) { + const std::vector& localMainDirs = CFileHandler::SubDirs(dir, pattern, SPRING_VFS_RAW); mainDirs.insert(mainDirs.end(), localMainDirs.begin(), localMainDirs.end()); } //found.insert(found.end(), mainDirs.begin(), mainDirs.end()); // and add all subdriectories of these - for (dir = mainDirs.begin(); dir != mainDirs.end(); ++dir) { - const std::vector& subDirs = CFileHandler::SubDirs(*dir, pattern, SPRING_VFS_RAW); + for (const std::string& dir: mainDirs) { + const std::vector& subDirs = CFileHandler::SubDirs(dir, pattern, SPRING_VFS_RAW); found.insert(found.end(), subDirs.begin(), subDirs.end()); } diff -Nru spring-96.0~14.04~ppa4/rts/System/FileSystem/DataDirsAccess.h spring-98.0~14.04~ppa6/rts/System/FileSystem/DataDirsAccess.h --- spring-96.0~14.04~ppa4/rts/System/FileSystem/DataDirsAccess.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/FileSystem/DataDirsAccess.h 2014-10-07 20:09:51.000000000 +0000 @@ -52,7 +52,7 @@ std::string LocateFile(std::string file, int flags = 0) const; std::string LocateDir(std::string dir, int flags = 0) const; - std::vector LocateDirs(const std::string& dir) const; + std::vector LocateDirs(std::string dir) const; std::vector FindDirsInDirectSubDirs(const std::string& relPath) const; /** diff -Nru spring-96.0~14.04~ppa4/rts/System/FileSystem/FileHandler.cpp spring-98.0~14.04~ppa6/rts/System/FileSystem/FileHandler.cpp --- spring-96.0~14.04~ppa4/rts/System/FileSystem/FileHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/FileSystem/FileHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -12,7 +12,6 @@ #include #include -#include "lib/gml/gmlmut.h" #include "FileQueryFlags.h" #include "FileSystem.h" @@ -33,8 +32,6 @@ CFileHandler::CFileHandler(const char* fileName, const char* modes) : filePos(0), fileSize(-1) { - GML_RECMUTEX_LOCK(file); // CFileHandler - Open(fileName, modes); } @@ -42,15 +39,12 @@ CFileHandler::CFileHandler(const string& fileName, const string& modes) : filePos(0), fileSize(-1) { - GML_RECMUTEX_LOCK(file); // CFileHandler - Open(fileName, modes); } CFileHandler::~CFileHandler() { - GML_RECMUTEX_LOCK(file); // ~CFileHandler ifs.close(); } @@ -186,8 +180,6 @@ int CFileHandler::Read(void* buf, int length) { - GML_RECMUTEX_LOCK(file); // Read - if (ifs.is_open()) { ifs.read(static_cast(buf), length); return ifs.gcount(); @@ -208,10 +200,24 @@ } -void CFileHandler::Seek(int length, std::ios_base::seekdir where) +int CFileHandler::ReadString(void* buf, int length) { - GML_RECMUTEX_LOCK(file); // Seek + assert(buf != nullptr); + assert(length > 0); + const int pos = GetPos(); + const int rlen = Read(buf, length); + if (rlen < length) ((char*)buf)[rlen] = 0; + const int slen = strlen((const char*)buf); + if (rlen > 0) { + const int send = pos + slen + 1; + Seek(send, std::ios_base::beg); + } + return slen; +} + +void CFileHandler::Seek(int length, std::ios_base::seekdir where) +{ if (ifs.is_open()) { // Status bits must be cleared before seeking, otherwise it might fail @@ -239,8 +245,6 @@ bool CFileHandler::Eof() const { - GML_RECMUTEX_LOCK(file); // Eof - if (ifs.is_open()) { return ifs.eof(); } @@ -259,8 +263,6 @@ int CFileHandler::GetPos() { - GML_RECMUTEX_LOCK(file); // GetPos - if (ifs.is_open()) { return ifs.tellg(); } else { @@ -271,8 +273,6 @@ bool CFileHandler::LoadStringData(string& data) { - GML_RECMUTEX_LOCK(file); // LoadStringData - if (!FileExists()) { return false; } @@ -293,8 +293,6 @@ std::vector CFileHandler::FindFiles(const string& path, const string& pattern) { - GML_RECMUTEX_LOCK(file); // FindFiles - #ifndef TOOLS std::vector found = dataDirsAccess.FindFiles(path, pattern); boost::regex regexpattern(FileSystem::ConvertGlobToRegex(pattern), @@ -322,8 +320,6 @@ std::vector CFileHandler::DirList(const string& path, const string& pattern, const string& modes) { - GML_RECMUTEX_LOCK(file); // DirList - const string pat = pattern.empty() ? "*" : pattern; std::set fileSet; @@ -410,8 +406,6 @@ std::vector CFileHandler::SubDirs(const string& path, const string& pattern, const string& modes) { - GML_RECMUTEX_LOCK(file); // SubDirs - const string pat = pattern.empty() ? "*" : pattern; std::set dirSet; diff -Nru spring-96.0~14.04~ppa4/rts/System/FileSystem/FileHandler.h spring-98.0~14.04~ppa6/rts/System/FileSystem/FileHandler.h --- spring-96.0~14.04~ppa4/rts/System/FileSystem/FileHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/FileSystem/FileHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -30,6 +30,7 @@ void Open(const std::string& fileName, const std::string& modes = SPRING_VFS_RAW_FIRST); int Read(void* buf, int length); + int ReadString(void* buf, int length); //< stops after the first 0 char void Seek(int pos, std::ios_base::seekdir where = std::ios_base::beg); static bool FileExists(const std::string& filePath, const std::string& modes); diff -Nru spring-96.0~14.04~ppa4/rts/System/FileSystem/FileSystem.cpp spring-98.0~14.04~ppa6/rts/System/FileSystem/FileSystem.cpp --- spring-96.0~14.04~ppa4/rts/System/FileSystem/FileSystem.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/FileSystem/FileSystem.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -269,6 +269,12 @@ return FileSystem::DeleteFile(FileSystem::GetNormalizedPath(file)); } +const std::string& FileSystem::GetCacheBaseDir() +{ + static const std::string cacheBaseDir = "cache"; + return cacheBaseDir; +} + const std::string& FileSystem::GetCacheDir() { // cache-dir versioning must not be too finegrained, @@ -278,10 +284,8 @@ // same directory as any previous development build // (regardless of branch), so keep caches separate static const std::string cacheType[2] = {"dev-", "rel-"}; - static const std::string cacheBaseDir = "cache"; static const std::string cacheVersion = SpringVersion::GetMajor() + cacheType[SpringVersion::IsRelease()] + SpringVersion::GetBranch(); - static const std::string cacheDir = cacheBaseDir + GetNativePathSeparator() + cacheVersion; - + static const std::string cacheDir = EnsurePathSepAtEnd(GetCacheBaseDir()) + cacheVersion; return cacheDir; } diff -Nru spring-96.0~14.04~ppa4/rts/System/FileSystem/FileSystem.h spring-98.0~14.04~ppa6/rts/System/FileSystem/FileSystem.h --- spring-96.0~14.04~ppa4/rts/System/FileSystem/FileSystem.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/FileSystem/FileSystem.h 2014-10-07 20:09:51.000000000 +0000 @@ -125,6 +125,7 @@ static bool CheckFile(const std::string& file); // static bool CheckDir(const std::string& dir) const; + static const std::string& GetCacheBaseDir(); static const std::string& GetCacheDir(); }; diff -Nru spring-96.0~14.04~ppa4/rts/System/FileSystem/RapidHandler.cpp spring-98.0~14.04~ppa6/rts/System/FileSystem/RapidHandler.cpp --- spring-96.0~14.04~ppa4/rts/System/FileSystem/RapidHandler.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/FileSystem/RapidHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,85 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include +#include +#include + +#include "DataDirsAccess.h" +#include "DataDirLocater.h" +#include "FileQueryFlags.h" +#include "System/Log/ILog.h" + +#include +#include //strnlen + +class RapidEntry{ +public: + RapidEntry(const std::string& line) { + value.resize(entries); + size_t pos = 0, start = 0; + for(size_t i=0; i value; + +}; + + +static int bufsize = 4096; + +static std::string GetNameFromFile(const std::string& tag, const std::string& name) +{ + gzFile in = gzopen(name.c_str(), "rb"); + if (in == NULL) { + LOG_L(L_ERROR, "couldn't open %s", name.c_str()); + return ""; + } + + char buf[bufsize]; + while (gzgets(in, buf, bufsize)!=NULL){ + size_t len = strnlen(buf, bufsize); + if (len <= 2) continue; //line to short/invalid, skip + if (buf[len-1] == '\n') len--; + if (buf[len-1] == '\r') len--; + + RapidEntry ent(std::string(buf, len)); + if (ent.GetTag() == tag) { + return ent.GetName(); + } + } + gzclose(in); + return ""; +} + +std::string GetRapidName(const std::string& tag) +{ + std::string res; + const std::vector& dirs = dataDirLocater.GetDataDirs(); + for(DataDir dir: dirs) { + std::string path = dir.path + "rapid"; //TODO: does GetDataDirs() ensure paths to end with a delimn? + std::vector files = dataDirsAccess.FindFiles(path, "versions.gz", FileQueryFlags::RECURSE); + for(const std::string file: files) { + printf("%s\n", file.c_str()); + res = GetNameFromFile(tag, file); + if (!res.empty()) + return res; + } + } + return res; +} + diff -Nru spring-96.0~14.04~ppa4/rts/System/FileSystem/RapidHandler.h spring-98.0~14.04~ppa6/rts/System/FileSystem/RapidHandler.h --- spring-96.0~14.04~ppa4/rts/System/FileSystem/RapidHandler.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/FileSystem/RapidHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,10 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include + +/* + * searches for the name of an archive by the rapid tag in /rapid/.../versions.gz + * @param tag of the rapid tag to search for, for example ba:stable + * @return name of the rapid tag, empty string if not found, for example "Balanced Annihilation v8.00" + */ +std::string GetRapidName(const std::string& tag); diff -Nru spring-96.0~14.04~ppa4/rts/System/FileSystem/VFSHandler.cpp spring-98.0~14.04~ppa6/rts/System/FileSystem/VFSHandler.cpp --- spring-96.0~14.04~ppa4/rts/System/FileSystem/VFSHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/FileSystem/VFSHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -80,7 +80,7 @@ bool CVFSHandler::AddArchiveWithDeps(const std::string& archiveName, bool override, const std::string& type) { - const std::vector &ars = archiveScanner->GetArchives(archiveName); + const std::vector &ars = archiveScanner->GetAllArchivesUsedBy(archiveName); if (ars.empty()) throw content_error("Could not find any archives for '" + archiveName + "'."); diff -Nru spring-96.0~14.04~ppa4/rts/System/float3.cpp spring-98.0~14.04~ppa6/rts/System/float3.cpp --- spring-96.0~14.04~ppa4/rts/System/float3.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/float3.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -5,8 +5,8 @@ #include "System/myMath.h" #include // std::min, std::max, std::fabs -CR_BIND(float3, ); -CR_REG_METADATA(float3, (CR_MEMBER(x), CR_MEMBER(y), CR_MEMBER(z))); +CR_BIND(float3, ) +CR_REG_METADATA(float3, (CR_MEMBER(x), CR_MEMBER(y), CR_MEMBER(z))) //! gets initialized later when the map is loaded float float3::maxxpos = -1.0f; diff -Nru spring-96.0~14.04~ppa4/rts/System/float3.h spring-98.0~14.04~ppa6/rts/System/float3.h --- spring-96.0~14.04~ppa4/rts/System/float3.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/float3.h 2014-10-07 20:09:51.000000000 +0000 @@ -24,7 +24,7 @@ class float3 { public: - CR_DECLARE_STRUCT(float3); + CR_DECLARE_STRUCT(float3) /* void* operator new(size_t size) { return mempool.Alloc(size); } void* operator new(size_t n, void* p) { return p; } // cp visual void operator delete(void* p, size_t size) { mempool.Free(p, size); } @@ -717,9 +717,9 @@ * Defines constant upwards vector * (0, 1, 0) */ -const float3 UpVector(0.0f, 1.0f, 0.0f); -const float3 FwdVector(0.0f, 0.0f, 1.0f); -const float3 RgtVector(1.0f, 0.0f, 0.0f); +static const float3 UpVector(0.0f, 1.0f, 0.0f); +static const float3 FwdVector(0.0f, 0.0f, 1.0f); +static const float3 RgtVector(1.0f, 0.0f, 0.0f); /** * @brief zero vector @@ -727,12 +727,12 @@ * Defines constant zero vector * (0, 0, 0) */ -const float3 ZeroVector(0.0f, 0.0f, 0.0f); -const float3 OnesVector(1.0f, 1.0f, 1.0f); +static const float3 ZeroVector(0.0f, 0.0f, 0.0f); +static const float3 OnesVector(1.0f, 1.0f, 1.0f); -const float3 XYVector(1.0f, 1.0f, 0.0f); -const float3 XZVector(1.0f, 0.0f, 1.0f); -const float3 YZVector(0.0f, 1.0f, 1.0f); +static const float3 XYVector(1.0f, 1.0f, 0.0f); +static const float3 XZVector(1.0f, 0.0f, 1.0f); +static const float3 YZVector(0.0f, 1.0f, 1.0f); #endif /* FLOAT3_H */ diff -Nru spring-96.0~14.04~ppa4/rts/System/float4.cpp spring-98.0~14.04~ppa6/rts/System/float4.cpp --- spring-96.0~14.04~ppa4/rts/System/float4.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/float4.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -4,9 +4,9 @@ #include "System/creg/creg_cond.h" -CR_BIND(float4, ); +CR_BIND(float4, ) CR_REG_METADATA(float4, - (CR_MEMBER(x), CR_MEMBER(y), CR_MEMBER(z), CR_MEMBER(w))); + (CR_MEMBER(x), CR_MEMBER(y), CR_MEMBER(z), CR_MEMBER(w))) float4::float4(): float3(), w(0.0f) { diff -Nru spring-96.0~14.04~ppa4/rts/System/float4.h spring-98.0~14.04~ppa6/rts/System/float4.h --- spring-96.0~14.04~ppa4/rts/System/float4.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/float4.h 2014-10-07 20:09:51.000000000 +0000 @@ -11,7 +11,7 @@ an array of 4 floats. */ struct float4 : public float3 { - CR_DECLARE_STRUCT(float4); + CR_DECLARE_STRUCT(float4) union { struct { float w; }; diff -Nru spring-96.0~14.04~ppa4/rts/System/GlobalConfig.cpp spring-98.0~14.04~ppa6/rts/System/GlobalConfig.cpp --- spring-96.0~14.04~ppa4/rts/System/GlobalConfig.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/GlobalConfig.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -4,9 +4,7 @@ #include "Rendering/TeamHighlight.h" #include "System/Config/ConfigHandler.h" #include "System/GlobalConfig.h" -#include "Sim/Misc/ModInfo.h" #include "Lua/LuaConfig.h" -#include "lib/gml/gml_base.h" CONFIG(int, NetworkLossFactor) .defaultValue(netcode::UDPConnection::MIN_LOSS_FACTOR) @@ -62,11 +60,6 @@ CONFIG(bool, EnableDrawCallIns).defaultValue(true); -CONFIG(int, MultiThreadLua) - .defaultValue(MT_LUA_DEFAULT) - .minimumValue(MT_LUA_FIRST) - .maximumValue(MT_LUA_LAST); - GlobalConfig* globalConfig = NULL; GlobalConfig::GlobalConfig() @@ -95,27 +88,9 @@ useNetMessageSmoothingBuffer = configHandler->GetBool("UseNetMessageSmoothingBuffer"); luaWritableConfigFile = configHandler->GetBool("LuaWritableConfigFile"); -#if defined(USE_GML) && GML_ENABLE_SIM - enableDrawCallIns = configHandler->GetBool("EnableDrawCallIns"); -#endif -#if (defined(USE_GML) && GML_ENABLE_SIM) || defined(USE_LUA_MT) - multiThreadLua = configHandler->GetInt("MultiThreadLua"); -#endif - teamHighlight = configHandler->GetInt("TeamHighlight"); } - -int GlobalConfig::GetMultiThreadLua() -{ -#if (defined(USE_GML) && GML_ENABLE_SIM) || defined(USE_LUA_MT) - return (!GML::Enabled()) ? MT_LUA_NONE : std::max((int)MT_LUA_FIRSTACTIVE, std::min((multiThreadLua == MT_LUA_DEFAULT) ? modInfo.luaThreadingModel : multiThreadLua, (int)MT_LUA_LAST)); -#else - return MT_LUA_NONE; -#endif -} - - void GlobalConfig::Instantiate() { Deallocate(); diff -Nru spring-96.0~14.04~ppa4/rts/System/GlobalConfig.h spring-98.0~14.04~ppa6/rts/System/GlobalConfig.h --- spring-96.0~14.04~ppa4/rts/System/GlobalConfig.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/GlobalConfig.h 2014-10-07 20:09:51.000000000 +0000 @@ -2,7 +2,6 @@ #ifndef _GLOBAL_CONFIG_H #define _GLOBAL_CONFIG_H -#include "lib/gml/gmlcnf.h" class GlobalConfig { @@ -16,7 +15,7 @@ /** * @brief network loss factor * - * Network loss factor, a higher factor will reconfigure the protocol + * Network loss factor, a higher factor will reconfigure the protocol * to resend data more frequently, i.e. waste bandwidth to reduce lag */ int networkLossFactor; @@ -101,19 +100,6 @@ */ bool luaWritableConfigFile; -#if (defined(USE_GML) && GML_ENABLE_SIM) || defined(USE_LUA_MT) - /** - * @brief multiThreadLua - * - * LuaHandle threading mode for Spring MT - * - * See LuaConfig.h and ModInfo::luaThreadingModel - */ - int multiThreadLua; - bool enableDrawCallIns; -#endif - - int GetMultiThreadLua(); /** * @brief teamHighlight * diff -Nru spring-96.0~14.04~ppa4/rts/System/Input/Joystick.cpp spring-98.0~14.04~ppa6/rts/System/Input/Joystick.cpp --- spring-96.0~14.04~ppa4/rts/System/Input/Joystick.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Input/Joystick.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -41,22 +41,25 @@ } Joystick::Joystick() + : myStick(nullptr) { const int numSticks = SDL_NumJoysticks(); LOG("Joysticks found: %i", numSticks); + if (numSticks <= 0) + return; const int stickNum = configHandler->GetInt("JoystickUse"); - myStick = SDL_JoystickOpen(stickNum); + myStick = SDL_JoystickOpen(stickNum); if (myStick) { - LOG("Using joystick %i: %s", stickNum, SDL_JoystickName(stickNum)); + LOG("Using joystick %i: %s", stickNum, SDL_JoystickName(myStick)); inputCon = input.AddHandler(boost::bind(&Joystick::HandleEvent, this, _1)); } else { - LOG_L(L_WARNING, "Joystick %i not found", stickNum); + LOG_L(L_ERROR, "Joystick %i not found", stickNum); } } @@ -89,6 +92,12 @@ eventHandler.JoystickEvent("JoyButtonUp", event.jbutton.button, event.jbutton.state); break; } + case SDL_JOYDEVICEADDED: //TODO + LOG("Joystick has been added"); + break; + case SDL_JOYDEVICEREMOVED: + LOG("Joystick has been removed"); + break; default: { } diff -Nru spring-96.0~14.04~ppa4/rts/System/Input/KeyInput.cpp spring-98.0~14.04~ppa6/rts/System/Input/KeyInput.cpp --- spring-96.0~14.04~ppa4/rts/System/Input/KeyInput.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Input/KeyInput.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,71 +1,101 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ -#include #include -#include -#include +#include +#include +#include #include "KeyInput.h" -KeyInput* keyInput = NULL; - -KeyInput* KeyInput::GetInstance() { - if (keyInput == NULL) { - keyInput = new KeyInput(); - } - - return keyInput; -} - -void KeyInput::FreeInstance(KeyInput* keyInp) { - delete keyInp; keyInput = NULL; -} - - - -KeyInput::KeyInput() { - keys.resize(SDLK_LAST, 0); - - // Initialize keyboard - SDL_EnableUNICODE(1); - SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); - SDL_SetModState(KMOD_NONE); -} - +#include "System/Log/ILog.h" /** - * Tests SDL keystates and sets values in key array - */ -void KeyInput::Update(boost::uint16_t currKeyUnicodeChar, boost::int8_t fakeMetaKey) -{ - int numKeys = 0; +* @brief keys +* +* Array of possible keys, and which are being pressed +*/ +static std::map keys; +static SDL_Keymod keyMods; - const SDLMod keyMods = SDL_GetModState(); - const boost::uint8_t* keyStates = SDL_GetKeyState(&numKeys); - assert(numKeys <= SDLK_LAST); - memcpy(&keys[0], keyStates, sizeof(boost::uint8_t) * numKeys); +namespace KeyInput { + bool IsKeyPressed(int idx) { + auto it = keys.find(idx); + if (it != keys.end()) + return (it->second != 0); + return false; + } - keys[SDLK_LALT] = (keyMods & KMOD_ALT) ? 1 : 0; - keys[SDLK_LCTRL] = (keyMods & KMOD_CTRL) ? 1 : 0; - keys[SDLK_LMETA] = (keyMods & KMOD_META) ? 1 : 0; - keys[SDLK_LSHIFT] = (keyMods & KMOD_SHIFT) ? 1 : 0; + void SetKeyModState(int mod, bool pressed) { + if (pressed) { + keyMods = SDL_Keymod(keyMods | mod); + } else { + keyMods = SDL_Keymod(keyMods & ~mod); + } + } - if (fakeMetaKey >= 0) { - keys[SDLK_LMETA] |= keys[fakeMetaKey]; + bool GetKeyModState(int mod) { + return (keyMods & mod); } - currentKeyUnicodeChar = currKeyUnicodeChar; -} + /** + * Tests SDL keystates and sets values in key array + */ + void Update(int currKeycode, int fakeMetaKey) + { + int numKeys = 0; + auto state = SDL_GetKeyboardState(&numKeys); + for (int i = 0; i < numKeys; ++i) { + auto scancode = (SDL_Scancode)i; + auto keycode = SDL_GetKeyFromScancode(scancode); + keys[keycode] = (state[scancode] != 0); + } + + keyMods = SDL_GetModState(); + SetKeyModState(KMOD_GUI, keys[fakeMetaKey]); + + keys[SDLK_LALT] = GetKeyModState(KMOD_ALT); + keys[SDLK_LCTRL] = GetKeyModState(KMOD_CTRL); + keys[SDLK_LGUI] = GetKeyModState(KMOD_GUI); + keys[SDLK_LSHIFT] = GetKeyModState(KMOD_SHIFT); + } -boost::uint16_t KeyInput::GetNormalizedKeySymbol(boost::uint16_t sym) const { + const std::map& GetPressedKeys() + { + return keys; + } + + int GetNormalizedKeySymbol(int sym) + { + if (sym <= SDLK_DELETE) { + sym = tolower(sym); + } + else if (sym == SDLK_RSHIFT) { sym = SDLK_LSHIFT; } + else if (sym == SDLK_RCTRL) { sym = SDLK_LCTRL; } + else if (sym == SDLK_RGUI) { sym = SDLK_LGUI; } + else if (sym == SDLK_RALT) { sym = SDLK_LALT; } - if (sym <= SDLK_DELETE) { - sym = tolower(sym); + return sym; } - else if (sym == SDLK_RSHIFT) { sym = SDLK_LSHIFT; } - else if (sym == SDLK_RCTRL) { sym = SDLK_LCTRL; } - else if (sym == SDLK_RMETA) { sym = SDLK_LMETA; } - else if (sym == SDLK_RALT) { sym = SDLK_LALT; } - return sym; -} + void ReleaseAllKeys() + { + for (auto key: keys) { + auto keycode = (SDL_Keycode)key.first; + auto scancode = SDL_GetScancodeFromKey(keycode); + + if (keycode == SDLK_NUMLOCKCLEAR || keycode == SDLK_CAPSLOCK || keycode == SDLK_SCROLLLOCK) + continue; + + if (!KeyInput::IsKeyPressed(keycode)) + continue; + + SDL_Event event; + event.type = event.key.type = SDL_KEYUP; + event.key.state = SDL_RELEASED; + event.key.keysym.sym = keycode; + event.key.keysym.mod = 0; + event.key.keysym.scancode = scancode; + SDL_PushEvent(&event); + } + } +} // namespace KeyInput diff -Nru spring-96.0~14.04~ppa4/rts/System/Input/KeyInput.h spring-98.0~14.04~ppa6/rts/System/Input/KeyInput.h --- spring-96.0~14.04~ppa4/rts/System/Input/KeyInput.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Input/KeyInput.h 2014-10-07 20:09:51.000000000 +0000 @@ -3,43 +3,18 @@ #ifndef KEYBOARD_INPUT_H #define KEYBOARD_INPUT_H -#include -#include +#include -class KeyInput { -public: - static KeyInput* GetInstance(); - static void FreeInstance(KeyInput*); +namespace KeyInput { + void Update(int currKeycode, int fakeMetaKey); + void ReleaseAllKeys(); + + bool IsKeyPressed(int idx); + void SetKeyModState(int mod, bool pressed); + bool GetKeyModState(int mod); + const std::map& GetPressedKeys(); - KeyInput(); - ~KeyInput() { keys.clear(); } - - void Update(boost::uint16_t currKeyUnicodeChar, boost::int8_t fakeMetaKey); - - void SetKeyState(boost::uint16_t idx, boost::uint8_t state) { keys[idx] = state; } - boost::uint8_t GetKeyState(boost::uint16_t idx) const { return keys[idx]; } - - boost::uint16_t GetNormalizedKeySymbol(boost::uint16_t sym) const; - boost::uint16_t GetCurrentKeyUnicodeChar() const { return currentKeyUnicodeChar; } - - bool IsKeyPressed(boost::uint16_t idx) const { return (keys[idx] != 0); } - -private: - /** - * @brief keys - * - * Array of possible keys, and which are being pressed - */ - std::vector keys; - - /** - * @brief currentKeyUnicodeChar - * - * Unicode character for the current KeyPressed or KeyReleased - */ - boost::uint16_t currentKeyUnicodeChar; -}; - -extern KeyInput* keyInput; + int GetNormalizedKeySymbol(int key); +} #endif diff -Nru spring-96.0~14.04~ppa4/rts/System/Input/MouseInput.cpp spring-98.0~14.04~ppa6/rts/System/Input/MouseInput.cpp --- spring-96.0~14.04~ppa4/rts/System/Input/MouseInput.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Input/MouseInput.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -30,14 +30,7 @@ #include #include -#ifdef _WIN32 - #include - #include "System/Platform/Win/wsdl.h" -#endif -#if defined(_X11) && !defined(HEADLESS) - #include - #include -#endif +#include IMouseInput* mouseInput = NULL; @@ -52,52 +45,46 @@ bool IMouseInput::HandleSDLMouseEvent(const SDL_Event& event) { switch (event.type) { - case SDL_ACTIVEEVENT: { - if (event.active.state & (SDL_APPACTIVE | SDL_APPMOUSEFOCUS)) { - if (event.active.gain == 0) { //! mouse left window (set mouse pos internally to window center to prevent endless scrolling) - mousepos.x = globalRendering->viewSizeX / 2; - mousepos.y = globalRendering->viewSizeY / 2; - if (mouse) { - mouse->MouseMove(mousepos.x, mousepos.y, 0, 0); - } - } - } - break; - } case SDL_MOUSEMOTION: { mousepos = int2(event.motion.x, event.motion.y); if (mouse) { mouse->MouseMove(mousepos.x, mousepos.y, event.motion.xrel, event.motion.yrel); } - break; - } + } break; case SDL_MOUSEBUTTONDOWN: { mousepos = int2(event.button.x, event.button.y); if (mouse) { - if (event.button.button == SDL_BUTTON_WHEELUP) { - mouse->MouseWheel(1.0f); - } else if (event.button.button == SDL_BUTTON_WHEELDOWN) { - mouse->MouseWheel(-1.0f); - } else { - mouse->MousePress(event.button.x, event.button.y, event.button.button); - } + mouse->MousePress(mousepos.x, mousepos.y, event.button.button); } - break; - } + } break; case SDL_MOUSEBUTTONUP: { mousepos = int2(event.button.x, event.button.y); if (mouse) { - mouse->MouseRelease(event.button.x, event.button.y, event.button.button); + mouse->MouseRelease(mousepos.x, mousepos.y, event.button.button); } - break; - } + } break; + case SDL_MOUSEWHEEL: { + if (mouse) { + mouse->MouseWheel(event.wheel.y); + } + } break; + case SDL_WINDOWEVENT: { + if (event.window.event == SDL_WINDOWEVENT_LEAVE) { + // mouse left window (set mouse pos internally to window center to prevent endless scrolling) + mousepos.x = globalRendering->viewSizeX / 2; + mousepos.y = globalRendering->viewSizeY / 2; + if (mouse) { + mouse->MouseMove(mousepos.x, mousepos.y, 0, 0); + } + } + } break; } return false; } ////////////////////////////////////////////////////////////////////// -#ifdef WIN32 +#if defined(WIN32) && !defined (HEADLESS) class CWin32MouseInput : public IMouseInput { @@ -110,41 +97,7 @@ static LRESULT CALLBACK SpringWndProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam) { - if (mouse) { - switch (msg) { - case WM_XBUTTONDOWN: - { - if ((short)LOWORD(wParam) & MK_XBUTTON1) - mouse->MousePress((short)LOWORD(lParam), (short)HIWORD(lParam), 4); - if ((short)LOWORD(wParam) & MK_XBUTTON2) - mouse->MousePress((short)LOWORD(lParam), (short)HIWORD(lParam), 5); - } return 0; - case WM_XBUTTONUP: - { - if ((short)LOWORD(wParam) & MK_XBUTTON1) - mouse->MouseRelease((short)LOWORD(lParam), (short)HIWORD(lParam), 4); - if ((short)LOWORD(wParam) & MK_XBUTTON2) - mouse->MouseRelease((short)LOWORD(lParam), (short)HIWORD(lParam), 5); - } return 0; - } - } - switch (msg) { - case WM_MOUSEMOVE: - return wsdl::OnMouseMotion(wnd, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)wParam); - - case WM_MOUSEWHEEL: - return wsdl::OnMouseWheel(wnd, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (int)(short)HIWORD(wParam), (UINT)(short)LOWORD(wParam)); - - //! can't use message crackers: they do not provide for passing uMsg - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_RBUTTONDOWN: - case WM_RBUTTONUP: - case WM_MBUTTONDOWN: - case WM_MBUTTONUP: - return wsdl::OnMouseButton(wnd, msg, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)wParam); - case WM_SETCURSOR: { if (inst->hCursor!=NULL) { @@ -155,20 +108,6 @@ } } } break; - - case WM_ACTIVATE: - { - wsdl::ResetMouseButtons(); - // wsdl::OnActivate(wnd, LOWORD(wParam), NULL, HIWORD(lParam)); - // FIXME: move to SpringApp somehow and use GLContext.h instead! - if (globalRendering->fullScreen) { - if (LOWORD(wParam) == WA_INACTIVE) { - FBO::GLContextLost(); - } else if (LOWORD(wParam) == WA_ACTIVE) { - FBO::GLContextReinit(); - } - } - } break; } return CallWindowProc((WNDPROC)inst->sdl_wndproc, wnd, msg, wParam, lParam); } @@ -180,35 +119,35 @@ void InstallWndCallback() { - sdl_wndproc = GetWindowLongPtr(wnd, GWLP_WNDPROC); - SetWindowLongPtr(wnd,GWLP_WNDPROC,(LONG_PTR)SpringWndProc); + SDL_SysWMinfo info; + SDL_VERSION(&info.version); + if(!SDL_GetWindowWMInfo(globalRendering->window, &info)) + return; + + wnd = info.info.win.window; + + LONG_PTR cur_wndproc = GetWindowLongPtr(wnd, GWLP_WNDPROC); + if (cur_wndproc != (LONG_PTR)SpringWndProc) { + sdl_wndproc = GetWindowLongPtr(wnd, GWLP_WNDPROC); + SetWindowLongPtr(wnd,GWLP_WNDPROC,(LONG_PTR)SpringWndProc); + } } CWin32MouseInput() { inst = this; - hCursor = NULL; - sdl_wndproc = 0; - - SDL_SysWMinfo info; - SDL_VERSION(&info.version); - if(!SDL_GetWMInfo(&info)) - return; - - wnd = info.window; - wsdl::Init(wnd); - + wnd = 0; InstallWndCallback(); } ~CWin32MouseInput() { - //! reinstall the SDL window proc + // reinstall the SDL window proc SetWindowLongPtr(wnd, GWLP_WNDPROC, sdl_wndproc); } }; -CWin32MouseInput* CWin32MouseInput::inst = 0; +CWin32MouseInput* CWin32MouseInput::inst = NULL; #endif void IMouseInput::SetPos(int2 pos) @@ -217,56 +156,25 @@ return; } - mousepos = pos; - int2 curpos; -#ifndef WIN32 // seems SDL_GetMouseState isn't always updated on windows when cursor is hidden? (2012 - untested) - SDL_GetMouseState(&curpos.x, &curpos.y); - if (pos.x == curpos.x && pos.y == curpos.y) { + if (pos.x == mousepos.x && pos.y == mousepos.y) { // calling SDL_WarpMouse at 300fps eats ~5% cpu usage, so only update when needed return; } -#endif -#ifdef WIN32 - wsdl::SDL_WarpMouse(pos.x, pos.y); -#else - SDL_WarpMouse(pos.x, pos.y); + mousepos = pos; - #if defined(_X11) && !defined(HEADLESS) - // SDL Workaround! - // SDL_WarpMouse has a bug on Linux in fullscreen mode & SDL_ShowCursor(SDL_DISABLE). - // It just won't move the real X11 cursor pos (instead it seems to update some SDL internal vars only). - // But we use SDL_ShowCursor for MiddleClickScroll and want that the cursor spawns - // at screen center when calling SDL_ShowCursor(SDL_ENABLE), so we call X11 here to - // force cursor pos update even when the cursor is hidden. - if (globalRendering->fullScreen) { - SDL_SysWMinfo info; - SDL_VERSION(&info.version); - if(SDL_GetWMInfo(&info)) { - info.info.x11.lock_func(); - Display* display = info.info.x11.display; - Window& window = info.info.x11.window; - - if (display && window != None) - XWarpPointer(display, None, window, 0, 0, 0, 0, pos.x, pos.y); - info.info.x11.unlock_func(); - } - } - #endif -#endif + SDL_WarpMouseInWindow(globalRendering->window, pos.x, pos.y); // SDL_WarpMouse generates SDL_MOUSEMOTION events // in `middle click scrolling` those SDL generated ones would point into - // the oppossite direction the user moved the mouse, and so events would + // the opposite direction the user moved the mouse, and so events would // cancel each other -> camera wouldn't move at all // so we need to catch those SDL generated events and delete them - // first we need to gather the motion events - SDL_PumpEvents(); - // delete all SDL_MOUSEMOTION in the queue + SDL_PumpEvents(); static SDL_Event events[100]; - SDL_PeepEvents(&events[0], 100, SDL_GETEVENT, SDL_MOUSEMOTIONMASK); + SDL_PeepEvents(&events[0], 100, SDL_GETEVENT, SDL_MOUSEMOTION, SDL_MOUSEMOTION); } @@ -274,7 +182,7 @@ IMouseInput* IMouseInput::GetInstance() { if (mouseInput == NULL) { -#ifdef WIN32 +#if defined(WIN32) && !defined(HEADLESS) mouseInput = new CWin32MouseInput; #else mouseInput = new IMouseInput; diff -Nru spring-96.0~14.04~ppa4/rts/System/Input/MouseInput.h spring-98.0~14.04~ppa6/rts/System/Input/MouseInput.h --- spring-96.0~14.04~ppa4/rts/System/Input/MouseInput.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Input/MouseInput.h 2014-10-07 20:09:51.000000000 +0000 @@ -17,6 +17,8 @@ IMouseInput (); virtual ~IMouseInput() {} + virtual void InstallWndCallback() {} + virtual int2 GetPos() { return mousepos; } void SetPos(int2 pos); diff -Nru spring-96.0~14.04~ppa4/rts/System/LoadSave/CregLoadSaveHandler.cpp spring-98.0~14.04~ppa6/rts/System/LoadSave/CregLoadSaveHandler.cpp --- spring-96.0~14.04~ppa4/rts/System/LoadSave/CregLoadSaveHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/LoadSave/CregLoadSaveHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -43,7 +43,7 @@ class CGameStateCollector { - CR_DECLARE_STRUCT(CGameStateCollector); + CR_DECLARE_STRUCT(CGameStateCollector) public: CGameStateCollector() {} @@ -51,10 +51,10 @@ void Serialize(creg::ISerializer& s); }; -CR_BIND(CGameStateCollector, ); +CR_BIND(CGameStateCollector, ) CR_REG_METADATA(CGameStateCollector, ( CR_SERIALIZER(Serialize) -)); +)) static void WriteString(std::ostream& s, const std::string& str) { @@ -152,8 +152,7 @@ /// this just loads the mapname and some other early stuff void CCregLoadSaveHandler::LoadGameStartInfo(const std::string& file) { - const std::string file2 = FindSaveFile(file); - ifs = new std::ifstream(dataDirsAccess.LocateFile(file2).c_str(), std::ios::in|std::ios::binary); + ifs = new std::ifstream(dataDirsAccess.LocateFile(FindSaveFile(file)), std::ios::in|std::ios::binary); // in case these contained values alredy // (this is the case when loading a game through the spring menu eg), diff -Nru spring-96.0~14.04~ppa4/rts/System/LoadSave/DemoRecorder.cpp spring-98.0~14.04~ppa6/rts/System/LoadSave/DemoRecorder.cpp --- spring-96.0~14.04~ppa4/rts/System/LoadSave/DemoRecorder.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/LoadSave/DemoRecorder.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -15,13 +15,15 @@ #include #include #include -#include + CDemoRecorder::CDemoRecorder(const std::string& mapName, const std::string& modName, bool serverDemo): demoStream(std::ios::binary | std::ios::out) { SetName(mapName, modName, serverDemo); SetFileHeader(); + + file.open(demoName.c_str(), std::ios::binary | std::ios::out); } CDemoRecorder::~CDemoRecorder() @@ -31,7 +33,7 @@ WritePlayerStats(); WriteTeamStats(); WriteFileHeader(true); - WriteDemoFile(dataDirsAccess.LocateFile(demoName, FileQueryFlags::WRITE), demoStream.str()); + WriteDemoFile(); } void CDemoRecorder::SetFileHeader() @@ -50,16 +52,14 @@ demoStream.seekp(WriteFileHeader(false) + sizeof(DemoFileHeader)); } -void CDemoRecorder::WriteDemoFile(const std::string& name, const std::string& data) +void CDemoRecorder::WriteDemoFile() { - std::ofstream file; - // using operator<<(basic_stringbuf*) requires the stream to be opened with std::ios::in // stringbuf::{eback(), egptr(), gptr()} are protected so we cannot access them directly // (plus data is not guaranteed to be stored contiguously) ==> the only clean OO solution // that avoids str()'s copy would be to supply our own stringbuffer backend to demoStream // which is slightly overdoing it - file.open(name.c_str(), std::ios::binary | std::ios::out); + const std::string data = demoStream.str(); file.write(data.c_str(), data.size()); file.flush(); file.close(); @@ -68,7 +68,7 @@ void CDemoRecorder::WriteSetupText(const std::string& text) { int length = text.length(); - while (text.c_str()[length - 1] == '\0') { + while (text[length - 1] == '\0') { --length; } @@ -110,14 +110,13 @@ oss << SpringVersion::GetSync(); buf << oss.str() << ".sdf"; - unsigned int n = 0; - + int n = 0; while (FileSystem::FileExists(buf.str()) && (n < 99)) { buf.str(""); // clears content buf << oss.str() << "_" << n++ << ".sdf"; } - demoName = buf.str(); + demoName = dataDirsAccess.LocateFile(buf.str(), FileQueryFlags::WRITE); } void CDemoRecorder::SetGameID(const unsigned char* buf) @@ -144,7 +143,11 @@ /** @brief Set (overwrite) the CPlayer::Statistics for player playerNum */ void CDemoRecorder::SetPlayerStats(int playerNum, const PlayerStatistics& stats) { - assert((unsigned)playerNum < playerStats.size()); + // player who sent the NETMSG_PLAYERSTAT might be a spectator + // that joined later (only statistics for the original players + // are saved) + if (playerNum >= playerStats.size()) + return; playerStats[playerNum] = stats; } diff -Nru spring-96.0~14.04~ppa4/rts/System/LoadSave/DemoRecorder.h spring-98.0~14.04~ppa6/rts/System/LoadSave/DemoRecorder.h --- spring-96.0~14.04~ppa4/rts/System/LoadSave/DemoRecorder.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/LoadSave/DemoRecorder.h 2014-10-07 20:09:51.000000000 +0000 @@ -4,6 +4,7 @@ #define DEMO_RECORDER #include +#include #include #include @@ -43,8 +44,10 @@ void WritePlayerStats(); void WriteTeamStats(); void WriteWinnerList(); - void WriteDemoFile(const std::string& name, const std::string& data); + void WriteDemoFile(); +private: + std::ofstream file; std::stringstream demoStream; std::vector playerStats; std::vector< std::vector > teamStats; diff -Nru spring-96.0~14.04~ppa4/rts/System/LoadSave/LoadSaveHandler.cpp spring-98.0~14.04~ppa6/rts/System/LoadSave/LoadSaveHandler.cpp --- spring-96.0~14.04~ppa4/rts/System/LoadSave/LoadSaveHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/LoadSave/LoadSaveHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -6,6 +6,7 @@ #include "CregLoadSaveHandler.h" #include "LuaLoadSaveHandler.h" #include "System/Config/ConfigHandler.h" +#include "System/FileSystem/FileSystem.h" CONFIG(bool, UseCREGSaveLoad).defaultValue(false); @@ -25,15 +26,11 @@ } -std::string ILoadSaveHandler::FindSaveFile(const std::string& name) +std::string ILoadSaveHandler::FindSaveFile(const std::string& file) { - std::string name2 = name; -#ifdef _WIN32 - if (name2.find(":\\")==std::string::npos) - name2 = "Saves\\" + name2; -#else - if (name2.find("/")==std::string::npos) - name2 = "Saves/" + name2; -#endif - return name2; + if (!FileSystem::IsAbsolutePath(file)) { + return FileSystem::EnsurePathSepAtEnd("Saves") + file; + } + + return file; } diff -Nru spring-96.0~14.04~ppa4/rts/System/LoadSave/LoadSaveHandler.h spring-98.0~14.04~ppa6/rts/System/LoadSave/LoadSaveHandler.h --- spring-96.0~14.04~ppa4/rts/System/LoadSave/LoadSaveHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/LoadSave/LoadSaveHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -12,7 +12,7 @@ static ILoadSaveHandler* Create(); protected: - std::string FindSaveFile(const std::string& file); + static std::string FindSaveFile(const std::string& file); public: virtual ~ILoadSaveHandler(); diff -Nru spring-96.0~14.04~ppa4/rts/System/LoadSave/LuaLoadSaveHandler.cpp spring-98.0~14.04~ppa6/rts/System/LoadSave/LuaLoadSaveHandler.cpp --- spring-96.0~14.04~ppa4/rts/System/LoadSave/LuaLoadSaveHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/LoadSave/LuaLoadSaveHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -173,14 +173,12 @@ void CLuaLoadSaveHandler::LoadGameStartInfo(const std::string& file) { - const std::string realfile = dataDirsAccess.LocateFile(FindSaveFile(file)).c_str(); - filename = file; - loadfile = archiveLoader.OpenArchive(realfile, "sdz"); + const std::string realfile = dataDirsAccess.LocateFile(FindSaveFile(file)); - if (!loadfile->IsOpen()) { - LOG_L(L_ERROR, "Unable to open save file \"%s\"", filename.c_str()); - return; + loadfile = archiveLoader.OpenArchive(realfile, "sdz"); + if (!loadfile || !loadfile->IsOpen()) { + throw content_error("Unable to open savegame \"" + filename + "\""); } scriptText = LoadEntireFile(FILE_STARTSCRIPT); diff -Nru spring-96.0~14.04~ppa4/rts/System/Log/Backend.cpp spring-98.0~14.04~ppa6/rts/System/Log/Backend.cpp --- spring-96.0~14.04~ppa4/rts/System/Log/Backend.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Log/Backend.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -4,7 +4,7 @@ #include #include -#include +#include #ifdef __cplusplus @@ -14,58 +14,23 @@ extern char* log_formatter_format(const char* section, int level, const char* fmt, va_list arguments); namespace { - std::vector& log_formatter_getSinks() { - static std::vector sinks; + std::set& log_formatter_getSinks() { + static std::set sinks; return sinks; } - std::vector& log_formatter_getCleanupFuncs() { - static std::vector cleanupFuncs; + std::set& log_formatter_getCleanupFuncs() { + static std::set cleanupFuncs; return cleanupFuncs; } } -// LogSinkHandler::AddSink --> log_backend_registerSink -// FileSinkRegistrator --> log_backend_registerSink -// -void log_backend_registerSink(log_sink_ptr sink) { - log_formatter_getSinks().push_back(sink); -} - -// NOTE: LogSinkHandler is statically deinited! -// -// ~LogSinkHandler --> log_backend_unregisterSink -// LogSinkHandler::RemoveSink --> log_backend_unregisterSink -// -void log_backend_unregisterSink(log_sink_ptr sink) { - std::vector& sinks = log_formatter_getSinks(); - std::vector::iterator si; - - for (si = sinks.begin(); si != sinks.end(); ++si) { - if (*si == sink) { - sinks.erase(si); - break; - } - } -} - +void log_backend_registerSink(log_sink_ptr sink) { log_formatter_getSinks().insert(sink); } +void log_backend_unregisterSink(log_sink_ptr sink) { log_formatter_getSinks().erase(sink); } -void log_backend_registerCleanup(log_cleanup_ptr cleanupFunc) { - log_formatter_getCleanupFuncs().push_back(cleanupFunc); -} - -void log_backend_unregisterCleanup(log_cleanup_ptr cleanupFunc) { - std::vector& cleanupFuncs = log_formatter_getCleanupFuncs(); - std::vector::iterator si; - - for (si = cleanupFuncs.begin(); si != cleanupFuncs.end(); ++si) { - if (*si == cleanupFunc) { - cleanupFuncs.erase(si); - break; - } - } -} +void log_backend_registerCleanup(log_cleanup_ptr cleanupFunc) { log_formatter_getCleanupFuncs().insert(cleanupFunc); } +void log_backend_unregisterCleanup(log_cleanup_ptr cleanupFunc) { log_formatter_getCleanupFuncs().erase(cleanupFunc); } /** * @name logging_backend @@ -76,7 +41,7 @@ /// Eventually formats and routes the record to all sinks void log_backend_record(const char* section, int level, const char* fmt, va_list arguments) { - const std::vector& sinks = log_formatter_getSinks(); + const std::set& sinks = log_formatter_getSinks(); if (sinks.empty()) { static bool warned = false; @@ -103,7 +68,7 @@ /// Passes on a cleanup request to all sinks void log_backend_cleanup() { - const std::vector& cleanupFuncs = log_formatter_getCleanupFuncs(); + const std::set& cleanupFuncs = log_formatter_getCleanupFuncs(); for (auto si = cleanupFuncs.begin(); si != cleanupFuncs.end(); ++si) { (*si)(); diff -Nru spring-96.0~14.04~ppa4/rts/System/Log/DefaultFilter.cpp spring-98.0~14.04~ppa6/rts/System/Log/DefaultFilter.cpp --- spring-96.0~14.04~ppa4/rts/System/Log/DefaultFilter.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Log/DefaultFilter.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -78,7 +78,7 @@ #else return LOG_LEVEL_INFO; } else { - return LOG_LEVEL_WARNING; + return LOG_LEVEL_NOTICE; #endif } } @@ -274,7 +274,7 @@ const char* log_filter_section_getSectionCString(const char* section_cstr_tmp) { - static std::unordered_map> cache; + static std::unordered_map> cache; const auto str = std::string(section_cstr_tmp); const auto it = cache.find(str); @@ -287,6 +287,6 @@ strcpy(§ion_cstr[0], section_cstr_tmp); section_cstr[str.size()] = '\0'; - cache[str].reset(section_cstr); + cache[str].reset(const_cast(section_cstr)); return section_cstr; } diff -Nru spring-96.0~14.04~ppa4/rts/System/Log/DefaultFormatter.cpp spring-98.0~14.04~ppa6/rts/System/Log/DefaultFormatter.cpp --- spring-96.0~14.04~ppa4/rts/System/Log/DefaultFormatter.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Log/DefaultFormatter.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -77,6 +77,7 @@ // ******************************************************************************************* +/* static void log_formatter_createPrefix_xorgStyle( char** buffer, size_t* bufferSize, @@ -89,7 +90,9 @@ SNPRINTF(*buffer, *bufferSize, "(%c%c) %*.*s - ", levelChar, levelChar, SECTION_SIZE_MIN, SECTION_SIZE_MAX, prepSection); } +*/ +/* static void log_formatter_createPrefix_testing( char** buffer, size_t* bufferSize, @@ -101,6 +104,7 @@ SNPRINTF(*buffer, *bufferSize, "%s %s: ", levelStr, prepSection); } +*/ static void log_formatter_createPrefix_default( char** buffer, @@ -116,7 +120,7 @@ STRCAT_T(*buffer, *bufferSize, prepSection); STRCAT_T(*buffer, *bufferSize, "] "); } - if (level != LOG_LEVEL_INFO) { + if (level != LOG_LEVEL_INFO && level != LOG_LEVEL_NOTICE) { const char* levelStr = log_util_levelToString(level); STRCAT_T(*buffer, *bufferSize, levelStr); STRCAT_T(*buffer, *bufferSize, ": "); diff -Nru spring-96.0~14.04~ppa4/rts/System/Log/FileSink.cpp spring-98.0~14.04~ppa6/rts/System/Log/FileSink.cpp --- spring-96.0~14.04~ppa4/rts/System/Log/FileSink.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Log/FileSink.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -20,11 +20,11 @@ struct LogFileDetails { LogFileDetails(FILE* outStream = NULL, const std::string& sections = "", - int minLevel = LOG_LEVEL_ALL, bool flush = true) + int minLevel = LOG_LEVEL_ALL, int flushLevel = LOG_LEVEL_ERROR) : outStream(outStream) , sections(sections) , minLevel(minLevel) - , flush(flush) + , flushLevel(flushLevel) {} FILE* GetOutStream() const { @@ -36,15 +36,15 @@ || (sections.find("," + std::string(section) + ",") != std::string::npos))); } - bool FlushOnWrite() const { - return flush; + bool FlushOnWrite(int level) const { + return (level >= flushLevel); } private: FILE* outStream; std::string sections; int minLevel; - bool flush; + int flushLevel; }; typedef std::map logFiles_t; @@ -131,19 +131,12 @@ for (auto lfi = logFiles.begin(); lfi != logFiles.end(); ++lfi) { if (lfi->second.IsLogging(section, level) && (lfi->second.GetOutStream() != NULL)) { - log_file_writeToFile(lfi->second.GetOutStream(), record, lfi->second.FlushOnWrite()); + log_file_writeToFile(lfi->second.GetOutStream(), record, lfi->second.FlushOnWrite(level)); } } } /** - * Flushes the buffer of a single log file. - */ - void log_file_flushFile(FILE* outStream) { - fflush(outStream); - } - - /** * Flushes the buffers of the individual log files. */ void log_file_flushFiles() { @@ -151,7 +144,7 @@ for (auto lfi = logFiles.begin(); lfi != logFiles.end(); ++lfi) { if (lfi->second.GetOutStream() != NULL) { - log_file_flushFile(lfi->second.GetOutStream()); + fflush(lfi->second.GetOutStream()); } } } @@ -182,7 +175,7 @@ extern "C" { #endif -void log_file_addLogFile(const char* filePath, const char* sections, int minLevel, bool flush) { +void log_file_addLogFile(const char* filePath, const char* sections, int minLevel, int flushLevel) { assert(filePath != NULL); logFiles_t& logFiles = log_file_getLogFiles(); @@ -202,7 +195,7 @@ setvbuf(tmpStream, NULL, _IOFBF, (BUFSIZ < 8192) ? BUFSIZ : 8192); // limit buffer to 8kB const std::string sectionsStr = (sections == NULL) ? "" : sections; - logFiles[filePathStr] = LogFileDetails(tmpStream, sectionsStr, minLevel, flush); + logFiles[filePathStr] = LogFileDetails(tmpStream, sectionsStr, minLevel, flushLevel); } void log_file_removeLogFile(const char* filePath) { diff -Nru spring-96.0~14.04~ppa4/rts/System/Log/FileSink.h spring-98.0~14.04~ppa6/rts/System/Log/FileSink.h --- spring-96.0~14.04~ppa4/rts/System/Log/FileSink.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Log/FileSink.h 2014-10-07 20:09:51.000000000 +0000 @@ -31,7 +31,7 @@ * ",,". */ void log_file_addLogFile(const char* filePath, const char* sections = NULL, - int minLevel = LOG_LEVEL_ALL, bool flush = false); + int minLevel = LOG_LEVEL_ALL, int flushLevel = LOG_LEVEL_ERROR); void log_file_removeLogFile(const char* filePath); diff -Nru spring-96.0~14.04~ppa4/rts/System/Log/ILog.h spring-98.0~14.04~ppa6/rts/System/Log/ILog.h --- spring-96.0~14.04~ppa4/rts/System/Log/ILog.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Log/ILog.h 2014-10-07 20:09:51.000000000 +0000 @@ -11,7 +11,8 @@ * Aims: * - Support a fixed set of severities levels: * * L_DEBUG : fine-grained information that is most useful to debug - * * L_INFO : informational messages that highlight runtime progress of + * * L_INFO : same as L_NOTICE just that it is surpressed on RELEASE builds when a non-default logSection is set + * * L_NOTICE : default log level (always outputed) * * L_WARNING : potentially harmful situations * * L_ERROR : errors that might still allow the application to keep running * * L_FATAL : very severe errors that will lead the application to abort @@ -139,7 +140,7 @@ _LOG_REGISTER_SECTION_SUB(section, _UNIQUE_IDENT(SectionRegistrator)) #define _LOG_REGISTER_SECTION_GLOBAL(section) \ namespace { \ - _LOG_REGISTER_SECTION(section); \ + _LOG_REGISTER_SECTION(section) \ } // namespace #else // defined(__cplusplus) /* @@ -182,43 +183,11 @@ /// Redirect to runtime processing #define _LOG_RECORD(section, level, fmt, ...) log_frontend_record(section, LOG_LEVE##level, fmt, ##__VA_ARGS__) -// per level compile-time filters -#if _LOG_IS_ENABLED_LEVEL_STATIC(L_DEBUG) - #define _LOG_FILTER_L_DEBUG(section, fmt, ...) _LOG_RECORD(section, L_DEBUG, fmt, ##__VA_ARGS__) -#else - #define _LOG_FILTER_L_DEBUG(section, fmt, ...) -#endif - -#if _LOG_IS_ENABLED_LEVEL_STATIC(L_INFO) - #define _LOG_FILTER_L_INFO(section, fmt, ...) _LOG_RECORD(section, L_INFO, fmt, ##__VA_ARGS__) -#else - #define _LOG_FILTER_L_INFO(section, fmt,...) - #warning log messages of level INFO are not compiled into the binary -#endif - -#if _LOG_IS_ENABLED_LEVEL_STATIC(L_WARNING) - #define _LOG_FILTER_L_WARNING(section, fmt, ...) _LOG_RECORD(section, L_WARNING, fmt, ##__VA_ARGS__) -#else - #define _LOG_FILTER_L_WARNING(section, fmt, ...) - #warning log messages of level WARNING are not compiled into the binary -#endif - -#if _LOG_IS_ENABLED_LEVEL_STATIC(L_ERROR) - #define _LOG_FILTER_L_ERROR(section, fmt, ...) _LOG_RECORD(section, L_ERROR, fmt, ##__VA_ARGS__) -#else - #define _LOG_FILTER_L_ERROR(section, fmt, ##__VA_ARGS__) - #warning log messages of level ERROR are not compiled into the binary -#endif - -#if _LOG_IS_ENABLED_LEVEL_STATIC(L_FATAL) - #define _LOG_FILTER_L_FATAL(section, fmt, ...) _LOG_RECORD(section, L_FATAL, fmt, ##__VA_ARGS__) -#else - #define _LOG_FILTER_L_FATAL(section, fmt, ...) - #warning log messages of level FATAL are not compiled into the binary -#endif +/// per level compile-time filter +#define _LOG_FILTER(section, level, fmt, ...) if (_LOG_IS_ENABLED_LEVEL_STATIC(level)) _LOG_RECORD(section, level, fmt, ##__VA_ARGS__) /// Registers the section and connects to the filter macro -#define _LOG_SECTION(section, level, fmt, ...) _LOG_FILTER_##level(section, fmt, ##__VA_ARGS__) +#define _LOG_SECTION(section, level, fmt, ...) _LOG_FILTER(section, level, fmt, ##__VA_ARGS__) /// Uses the section defined in LOG_SECTION #define _LOG_SECTION_DEFINED(level, fmt, ...) _LOG_SECTION(LOG_SECTION_CURRENT, level, fmt, ##__VA_ARGS__) @@ -271,7 +240,7 @@ * NOTE: This is supported in C++ only, not in C. */ #define LOG_REGISTER_SECTION_GLOBAL(section) \ - _LOG_REGISTER_SECTION_GLOBAL(section); + _LOG_REGISTER_SECTION_GLOBAL(section) /** * Returns whether logging for the current section and the supplied level is @@ -340,7 +309,7 @@ * @see LOG_IS_ENABLED() */ #define LOG(fmt, ...) \ - _LOG(L_INFO, fmt, ##__VA_ARGS__) + _LOG(DEFAULT_LOG_LEVEL_SHORT, fmt, ##__VA_ARGS__) /** * Registers a log message with a specifiable level. diff -Nru spring-96.0~14.04~ppa4/rts/System/Log/Level.h spring-98.0~14.04~ppa6/rts/System/Log/Level.h --- spring-96.0~14.04~ppa4/rts/System/Log/Level.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Log/Level.h 2014-10-07 20:09:51.000000000 +0000 @@ -14,13 +14,17 @@ #define LOG_LEVEL_ALL 0 -#define LOG_LEVEL_DEBUG 20 -#define LOG_LEVEL_INFO 30 -#define LOG_LEVEL_WARNING 40 -#define LOG_LEVEL_ERROR 50 -#define LOG_LEVEL_FATAL 60 +#define LOG_LEVEL_DEBUG 20 +#define LOG_LEVEL_INFO 30 +#define LOG_LEVEL_NOTICE 35 +#define LOG_LEVEL_WARNING 40 +#define LOG_LEVEL_ERROR 50 +#define LOG_LEVEL_FATAL 60 -#define LOG_LEVEL_NONE 255 +#define LOG_LEVEL_NONE 255 + +#define DEFAULT_LOG_LEVEL_SHORT L_NOTICE +#define DEFAULT_LOG_LEVEL LOG_LEVEL_NOTICE ///@} diff -Nru spring-96.0~14.04~ppa4/rts/System/Log/LogSinkHandler.cpp spring-98.0~14.04~ppa6/rts/System/Log/LogSinkHandler.cpp --- spring-96.0~14.04~ppa4/rts/System/Log/LogSinkHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Log/LogSinkHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,11 +1,9 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ #include "LogSinkHandler.h" - #include "Backend.h" #include -#include #include @@ -26,18 +24,12 @@ log_backend_registerSink(&log_sink_record_logSinkHandler); } - sinks.push_back(logSink); + sinks.insert(logSink); } void LogSinkHandler::RemoveSink(ILogSink* logSink) { assert(logSink != NULL); - - for (auto lsi = sinks.begin(); lsi != sinks.end(); ++lsi) { - if (*lsi == logSink) { - sinks.erase(lsi); - break; - } - } + sinks.erase(logSink); if (sinks.empty()) { log_backend_unregisterSink(&log_sink_record_logSinkHandler); diff -Nru spring-96.0~14.04~ppa4/rts/System/Log/LogSinkHandler.h spring-98.0~14.04~ppa6/rts/System/Log/LogSinkHandler.h --- spring-96.0~14.04~ppa4/rts/System/Log/LogSinkHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Log/LogSinkHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -4,7 +4,7 @@ #define LOG_SINK_HANDLER_H #include -#include +#include /** @@ -55,7 +55,7 @@ const std::string& text) const; private: - std::vector sinks; + std::set sinks; /** * Whether log records are passed on to registered sinks, or dismissed. */ diff -Nru spring-96.0~14.04~ppa4/rts/System/Log/LogUtil.c spring-98.0~14.04~ppa6/rts/System/Log/LogUtil.c --- spring-96.0~14.04~ppa4/rts/System/Log/LogUtil.c 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Log/LogUtil.c 2014-10-07 20:09:51.000000000 +0000 @@ -10,6 +10,7 @@ switch (level) { case LOG_LEVEL_DEBUG: return "Debug"; case LOG_LEVEL_INFO: return "Info"; + case LOG_LEVEL_NOTICE: return "Notice"; case LOG_LEVEL_WARNING: return "Warning"; case LOG_LEVEL_ERROR: return "Error"; case LOG_LEVEL_FATAL: return "Fatal"; @@ -22,6 +23,7 @@ switch (level) { case LOG_LEVEL_DEBUG: return 'D'; case LOG_LEVEL_INFO: return 'I'; + case LOG_LEVEL_NOTICE: return 'N'; case LOG_LEVEL_WARNING: return 'W'; case LOG_LEVEL_ERROR: return 'E'; case LOG_LEVEL_FATAL: return 'F'; @@ -29,6 +31,17 @@ } } +int log_util_getNearestLevel(int level) { + + if (level >= LOG_LEVEL_FATAL) return LOG_LEVEL_FATAL; + if (level >= LOG_LEVEL_ERROR) return LOG_LEVEL_ERROR; + if (level >= LOG_LEVEL_WARNING) return LOG_LEVEL_WARNING; + if (level >= LOG_LEVEL_NOTICE) return LOG_LEVEL_NOTICE; + if (level >= LOG_LEVEL_INFO) return LOG_LEVEL_INFO; + if (level >= LOG_LEVEL_DEBUG) return LOG_LEVEL_DEBUG; + return DEFAULT_LOG_LEVEL; +} + const char* log_util_prepareSection(const char* section) { // make sure we always have a string for printing diff -Nru spring-96.0~14.04~ppa4/rts/System/Log/LogUtil.h spring-98.0~14.04~ppa6/rts/System/Log/LogUtil.h --- spring-96.0~14.04~ppa4/rts/System/Log/LogUtil.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Log/LogUtil.h 2014-10-07 20:09:51.000000000 +0000 @@ -11,6 +11,8 @@ char log_util_levelToChar(int level); +int log_util_getNearestLevel(int level); + /** * Ensure we have a non-NULL section. */ diff -Nru spring-96.0~14.04~ppa4/rts/System/Log/Section.h spring-98.0~14.04~ppa6/rts/System/Log/Section.h --- spring-96.0~14.04~ppa4/rts/System/Log/Section.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Log/Section.h 2014-10-07 20:09:51.000000000 +0000 @@ -16,9 +16,11 @@ /** * Helpers */ +//FIXME move all 3 funcs into a .c to not enforce including string.h? + // first check if both c-strings share the same memory location // if not check if both c-strings have the same content -static int LOG_SECTION_EQUAL(const char* s1, const char* s2) { +static inline int LOG_SECTION_EQUAL(const char* s1, const char* s2) { if (s1 == s2) return 1; if (s1 == NULL || s2 == NULL) @@ -26,7 +28,7 @@ return (strcmp(s1, s2) == 0); } -static int LOG_SECTION_COMPARE(const char* s1, const char* s2) { +static inline int LOG_SECTION_COMPARE(const char* s1, const char* s2) { if (s1 == NULL) return 1; if (s2 == NULL) @@ -34,7 +36,7 @@ return (strcmp(s1, s2) > 0); } -static int LOG_SECTION_IS_DEFAULT(const char* s) { +static inline int LOG_SECTION_IS_DEFAULT(const char* s) { return (LOG_SECTION_EQUAL(s, LOG_SECTION_DEFAULT)); } diff -Nru spring-96.0~14.04~ppa4/rts/System/LogOutput.cpp spring-98.0~14.04~ppa6/rts/System/LogOutput.cpp --- spring-96.0~14.04~ppa4/rts/System/LogOutput.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/LogOutput.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,7 +2,6 @@ #include "System/LogOutput.h" -#include "lib/gml/gmlmut.h" #include "System/Util.h" #include "Game/GameVersion.h" #include "System/Config/ConfigHandler.h" @@ -11,6 +10,7 @@ #include "System/Log/FileSink.h" #include "System/Log/ILog.h" #include "System/Log/Level.h" +#include "System/Log/LogUtil.h" #include "System/Platform/Misc.h" #include @@ -35,14 +35,8 @@ CONFIG(std::string, LogSections).defaultValue("") .description("Comma seperated list of enabled logsections, see infolog.txt / console output for possible values"); -/* -LogFlush defaults to true, because there should be pretty low performance gains as most -fwrite implementations cache on their own. Also disabling this causes stack-traces to -be cut off. BEFORE letting it default to false again, verify that it really increases -performance as the drawbacks really suck. -*/ -CONFIG(bool, LogFlush).defaultValue(true) - .description("Instantly write to the logfile, use only for debugging as it will cause a slowdown"); +CONFIG(int, LogFlushLevel).defaultValue(LOG_LEVEL_ERROR) + .description("Flush the logfile when level of message is above LogFlushLevel. i.e. ERROR is flushed as default, WARNING isn't."); /******************************************************************************/ /******************************************************************************/ @@ -85,7 +79,11 @@ enabledSections = StringToLower(enabledSections); enabledSections = StringStrip(enabledSections, " \t\n\r"); - // always starts with a ',' + // make the last "section:level" substring findable + if (!enabledSections.empty() && enabledSections.back() != ',') + enabledSections += ","; + + // n=1 because always starts with a ',' (if non-empty) for (size_t n = 1; n < enabledSections.size(); ) { const size_t k = enabledSections.find(",", n); @@ -104,7 +102,7 @@ #if defined(DEBUG) sectionLevelMap[logSec] = LOG_LEVEL_DEBUG; #else - sectionLevelMap[logSec] = LOG_LEVEL_INFO; + sectionLevelMap[logSec] = DEFAULT_LOG_LEVEL; #endif } @@ -141,15 +139,6 @@ // environment and the ones specified in the configuration file. const std::map& enabledSections = GetEnabledSections(); - // NOTE: negative keys so iteration order is FATAL(-60) ... DEBUG(-20) - const std::map logLevelNames = { - {-LOG_LEVEL_FATAL, "LOG_LEVEL_FATAL" }, - {-LOG_LEVEL_ERROR, "LOG_LEVEL_ERROR" }, - {-LOG_LEVEL_WARNING, "LOG_LEVEL_WARNING"}, - {-LOG_LEVEL_INFO, "LOG_LEVEL_INFO" }, - {-LOG_LEVEL_DEBUG, "LOG_LEVEL_DEBUG" }, - }; - std::stringstream availableLogSectionsStr; std::stringstream enabledLogSectionsStr; @@ -179,17 +168,16 @@ continue; // find the nearest lower known log-level (in descending order) - for (auto logLevelIt = logLevelNames.begin(); logLevelIt != logLevelNames.end(); ++logLevelIt) { - const int logLevel = -(logLevelIt->first); + const int logLevel = log_util_getNearestLevel(sectionLevel); - if (sectionLevel >= logLevel) { - log_filter_section_setMinLevel(*si, logLevel); + // levels can't go lower than this + if (logLevel < 0) + continue; - enabledLogSectionsStr << ((numEnabledSections > 0)? ", ": ""); - enabledLogSectionsStr << *si << "(" << logLevelIt->second << ")"; - break; - } - } + log_filter_section_setMinLevel(*si, logLevel); + + enabledLogSectionsStr << ((numEnabledSections > 0)? ", ": ""); + enabledLogSectionsStr << *si << "(" << log_util_levelToString(logLevel) << ")"; numEnabledSections++; } @@ -219,13 +207,10 @@ CLogOutput::~CLogOutput() { - GML_STDMUTEX_LOCK_NOPROF(log); // End } void CLogOutput::SetFileName(std::string fname) { - GML_STDMUTEX_LOCK_NOPROF(log); // SetFileName - assert(!IsInitialized()); fileName = fname; } @@ -270,7 +255,7 @@ if (configHandler->GetBool("RotateLogFiles")) RotateLogFile(); - log_file_addLogFile(filePath.c_str(), NULL, LOG_LEVEL_ALL, configHandler->GetBool("LogFlush")); + log_file_addLogFile(filePath.c_str(), NULL, LOG_LEVEL_ALL, configHandler->GetInt("LogFlushLevel")); InitializeLogSections(); LOG("LogOutput initialized."); @@ -281,16 +266,17 @@ void CLogOutput::LogSystemInfo() { LOG("Spring %s", SpringVersion::GetFull().c_str()); - LOG("Build date/time: %s", SpringVersion::GetBuildTime().c_str()); - LOG("Build environment: %s", SpringVersion::GetBuildEnvironment().c_str()); - LOG("Compiler: %s", SpringVersion::GetCompiler().c_str()); - LOG("OS: %s", Platform::GetOS().c_str()); - - if (Platform::Is64Bit()) - LOG("OS: 64bit native mode"); - else if (Platform::Is32BitEmulation()) - LOG("OS: emulated 32bit mode"); - else - LOG("OS: 32bit native mode"); + LOG("Build Date & Time: %s", SpringVersion::GetBuildTime().c_str()); + LOG("Build Environment: %s", SpringVersion::GetBuildEnvironment().c_str()); + LOG("Compiler Version: %s", SpringVersion::GetCompiler().c_str()); + LOG("Operating System: %s", Platform::GetOS().c_str()); + + if (Platform::Is64Bit()) { + LOG("Word Size: 64-bit (native mode)"); + } else if (Platform::Is32BitEmulation()) { + LOG("Word Size: 32-bit (emulated)"); + } else { + LOG("Word Size: 32-bit (native mode)"); + } } diff -Nru spring-96.0~14.04~ppa4/rts/System/LogOutput.h spring-98.0~14.04~ppa6/rts/System/LogOutput.h --- spring-96.0~14.04~ppa4/rts/System/LogOutput.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/LogOutput.h 2014-10-07 20:09:51.000000000 +0000 @@ -3,11 +3,6 @@ #ifndef LOG_OUTPUT_H #define LOG_OUTPUT_H -#include "lib/gml/gmlcnf.h" -#if defined(USE_GML) && GML_ENABLE_SIM -#include -#endif - #include #include @@ -84,9 +79,6 @@ std::string fileName; std::string filePath; -#if defined(USE_GML) && GML_ENABLE_SIM - boost::mutex logmutex; -#endif }; diff -Nru spring-96.0~14.04~ppa4/rts/System/Main.cpp spring-98.0~14.04~ppa6/rts/System/Main.cpp --- spring-96.0~14.04~ppa4/rts/System/Main.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Main.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -9,8 +9,6 @@ #include "System/SpringApp.h" -#include "lib/gml/gml_base.h" -#include "lib/gml/gmlmut.h" #include "System/Exceptions.h" #include "System/FileSystem/FileSystem.h" #include "System/Platform/errorhandler.h" @@ -18,11 +16,6 @@ #include "System/Platform/Misc.h" #include "System/Log/ILog.h" -#if !defined(__APPLE__) || !defined(HEADLESS) - // SDL_main.h contains a macro that replaces the main function on some OS, see SDL_main.h for details - #include -#endif - #ifdef WIN32 #include "lib/SOP/SOP.hpp" // NvOptimus @@ -49,16 +42,6 @@ Threading::DetectCores(); Threading::SetMainThread(); -#ifdef USE_GML - GML::ThreadNumber(GML_DRAW_THREAD_NUM); - #if GML_ENABLE_TLS_CHECK - // XXX how does this check relate to TLS??? and how does it relate to the line above??? - if (GML::ThreadNumber() != GML_DRAW_THREAD_NUM) { - ErrorMessageBox("Thread Local Storage test failed", "GML error:", MBF_OK | MBF_EXCL); - } - #endif -#endif - // run try { SpringApp app(argc, argv); @@ -69,8 +52,7 @@ Threading::Error* err = Threading::GetThreadError(); if (err != NULL) { - LOG_L(L_ERROR, "[%s] ret=%d err=\"%s\"", __FUNCTION__, ret, err->message.c_str()); - ErrorMessageBox("[" + std::string(__FUNCTION__) + "] error: " + err->message, err->caption, err->flags, true); + ErrorMessageBox(" error: " + err->message, err->caption, err->flags, true); } return ret; diff -Nru spring-96.0~14.04~ppa4/rts/System/maindefines.h spring-98.0~14.04~ppa6/rts/System/maindefines.h --- spring-96.0~14.04~ppa4/rts/System/maindefines.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/maindefines.h 2014-10-07 20:09:51.000000000 +0000 @@ -12,21 +12,21 @@ #include #if !defined __cplusplus && !defined bool -// include the bool type (defines: bool, true, false) +/* include the bool type (defines: bool, true, false) */ #if defined _MSC_VER #include "System/booldefines.h" #else #include #endif -#endif // !defined __cplusplus && !defined bool +#endif /* !defined __cplusplus && !defined bool */ -// define if we have a X11 enviroment (:= linux/freebsd) +/* define if we have a X11 enviroment (:= linux/freebsd) */ #if !defined(__APPLE__) && !defined(_WIN32) //FIXME move this check to cmake, which has FindX11.cmake? #define _X11 #endif -// define a common indicator for 32bit or 64bit-ness +/* define a common indicator for 32bit or 64bit-ness */ #if defined _WIN64 || defined __LP64__ || defined __ppc64__ || defined __ILP64__ || defined __SILP64__ || defined __LLP64__ || defined(__sparcv9) #define __arch64__ #define __archBits__ 64 @@ -35,26 +35,28 @@ #define __archBits__ 32 #endif -// define a cross-platform/-compiler compatible "%z" format replacement for -// printf() style functions. -// "%z" being the propper way for size_t typed values, -// but support for it has not yet spread wide enough. +/* + define a cross-platform/-compiler compatible "%z" format replacement for + printf() style functions. + "%z" being the propper way for size_t typed values, + but support for it has not yet spread wide enough. +*/ #if defined __arch64__ #define __SIZE_T_PRINTF_FORMAT__ "%lu" #else #define __SIZE_T_PRINTF_FORMAT__ "%u" #endif -// a shorter form +/* a shorter form */ #define _STPF_ __SIZE_T_PRINTF_FORMAT__ #ifdef _MSC_VER - // Microsoft Visual C++ 7.0: MSC_VER = 1300 - // Microsoft Visual C++ 7.1: MSC_VER = 1310 + /* Microsoft Visual C++ 7.0: MSC_VER = 1300 + Microsoft Visual C++ 7.1: MSC_VER = 1310 */ #if _MSC_VER > 1310 // >= Visual Studio 2005 #define PRINTF printf_s #define FPRINTF fprintf_s - #define SNPRINTF _snprintf // sprintf_s misbehaves in debug mode, triggering breakpoints - #define VSNPRINTF _vsnprintf // vsprintf_s misbehaves in debug mode, triggering breakpoints + #define SNPRINTF _snprintf /* sprintf_s misbehaves in debug mode, triggering breakpoints */ + #define VSNPRINTF _vsnprintf /* vsprintf_s misbehaves in debug mode, triggering breakpoints */ #define STRCPY strcpy #define STRCPYS strcpy_s #define STRNCPY strncpy @@ -62,7 +64,7 @@ #define STRCATS strcat_s #define STRNCAT strncat #define FOPEN fopen_s - #else // Visual Studio 2003 + #else /* Visual Studio 2003 */ #define PRINTF _printf #define FPRINTF _fprintf #define SNPRINTF _snprintf @@ -76,8 +78,8 @@ #define FOPEN _fopen #endif #define STRCASECMP stricmp -#else // _MSC_VER - // assuming GCC +#else /* _MSC_VER */ + /* assuming GCC */ #define PRINTF printf #define FPRINTF fprintf #define SNPRINTF snprintf @@ -90,11 +92,11 @@ #define STRNCAT strncat #define FOPEN fopen #define STRCASECMP strcasecmp -#endif // _MSC_VER +#endif /* _MSC_VER */ #define FREE(x) free(x); x = NULL; -// define a platform independent path separator C-string and char +/* define a platform independent path separator C-string and char */ #ifndef sPS #define sPS_WIN32 "\\" #define sPS_POSIX "/" @@ -104,49 +106,49 @@ #else // _WIN32 #define sPS sPS_POSIX #endif // _WIN32 -#endif // sPS +#endif /* sPS */ #ifndef cPS #define cPS_WIN32 '\\' #define cPS_POSIX '/' #ifdef _WIN32 #define cPS cPS_WIN32 - #else // _WIN32 + #else /* _WIN32 */ #define cPS cPS_POSIX - #endif // _WIN32 -#endif // cPS + #endif /* _WIN32 */ +#endif /* cPS */ -// define a platform independent path delimitter C-string and char +/* define a platform independent path delimitter C-string and char */ #ifndef sPD #define sPD_WIN32 ";" #define sPD_POSIX ":" #ifdef _WIN32 #define sPD sPD_WIN32 - #else // _WIN32 + #else /* _WIN32 */ #define sPD sPD_POSIX - #endif // _WIN32 -#endif // sPD + #endif /* _WIN32 */ +#endif /* sPD */ #ifndef cPD #define cPD_WIN32 ';' #define cPD_POSIX ':' #ifdef _WIN32 #define cPD cPD_WIN32 - #else // _WIN32 + #else /* _WIN32 */ #define cPD cPD_POSIX - #endif // _WIN32 -#endif // cPD + #endif /* _WIN32 */ +#endif /* cPD */ -// WORKAROUND (2013) a pthread stack alignment problem, else SSE code would crash -// more info: http://www.peterstock.co.uk/games/mingw_sse/ (TLDR: mingw-32 aligns -// thread stacks to 4 bytes but we want 16-byte alignment) -// +/* WORKAROUND (2013) a pthread stack alignment problem, else SSE code would crash + more info: http://www.peterstock.co.uk/games/mingw_sse/ (TLDR: mingw-32 aligns + thread stacks to 4 bytes but we want 16-byte alignment) +*/ #if (defined(__MINGW32__) && defined(__GNUC__) && (__GNUC__ == 4)) #define __FORCE_ALIGN_STACK__ __attribute__ ((force_align_arg_pointer)) #else #define __FORCE_ALIGN_STACK__ #endif -#endif // MAIN_DEFINES_H +#endif /* MAIN_DEFINES_H */ diff -Nru spring-96.0~14.04~ppa4/rts/System/Matrix44f.cpp spring-98.0~14.04~ppa6/rts/System/Matrix44f.cpp --- spring-96.0~14.04~ppa4/rts/System/Matrix44f.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Matrix44f.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -4,9 +4,9 @@ #include #include -CR_BIND(CMatrix44f, ); +CR_BIND(CMatrix44f, ) -CR_REG_METADATA(CMatrix44f, CR_MEMBER(m)); +CR_REG_METADATA(CMatrix44f, CR_MEMBER(m)) CMatrix44f::CMatrix44f() diff -Nru spring-96.0~14.04~ppa4/rts/System/Matrix44f.h spring-98.0~14.04~ppa6/rts/System/Matrix44f.h --- spring-96.0~14.04~ppa4/rts/System/Matrix44f.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Matrix44f.h 2014-10-07 20:09:51.000000000 +0000 @@ -9,7 +9,7 @@ class CMatrix44f { public: - CR_DECLARE_STRUCT(CMatrix44f); + CR_DECLARE_STRUCT(CMatrix44f) CMatrix44f(); CMatrix44f(const CMatrix44f& mat); diff -Nru spring-96.0~14.04~ppa4/rts/System/Misc/RectangleOptimizer.cpp spring-98.0~14.04~ppa6/rts/System/Misc/RectangleOptimizer.cpp --- spring-96.0~14.04~ppa4/rts/System/Misc/RectangleOptimizer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Misc/RectangleOptimizer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -6,12 +6,12 @@ #include -CR_BIND(CRectangleOptimizer, ); +CR_BIND(CRectangleOptimizer, ) CR_REG_METADATA(CRectangleOptimizer, ( CR_MEMBER(maxAreaPerRect), CR_MEMBER(rectangles), CR_MEMBER(needsUpdate) -)); +)) unsigned CRectangleOptimizer::statsTotalSize = 0; unsigned CRectangleOptimizer::statsOptSize = 0; diff -Nru spring-96.0~14.04~ppa4/rts/System/Misc/RectangleOptimizer.h spring-98.0~14.04~ppa6/rts/System/Misc/RectangleOptimizer.h --- spring-96.0~14.04~ppa4/rts/System/Misc/RectangleOptimizer.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Misc/RectangleOptimizer.h 2014-10-07 20:09:51.000000000 +0000 @@ -16,7 +16,7 @@ */ class CRectangleOptimizer { - CR_DECLARE_STRUCT(CRectangleOptimizer); + CR_DECLARE_STRUCT(CRectangleOptimizer) public: CRectangleOptimizer(); diff -Nru spring-96.0~14.04~ppa4/rts/System/Misc/SpringTime.cpp spring-98.0~14.04~ppa6/rts/System/Misc/SpringTime.cpp --- spring-96.0~14.04~ppa4/rts/System/Misc/SpringTime.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Misc/SpringTime.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -12,11 +12,11 @@ #include "System/creg/Serializer.h" //FIXME always use class even in non-debug! for creg! -CR_BIND(spring_time, ); +CR_BIND(spring_time, ) CR_REG_METADATA(spring_time,( CR_IGNORED(x), CR_SERIALIZER(Serialize) -)); +)) #endif #endif @@ -34,7 +34,7 @@ #define _GLIBCXX_USE_SCHED_YIELD // workaround a gcc <4.8 bug #include #include - namespace this_thread { using namespace std::this_thread; }; + namespace this_thread { using namespace std::this_thread; } #endif #define USE_NATIVE_WINDOWS_CLOCK (defined(WIN32) && !defined(FORCE_CHRONO_TIMERS)) diff -Nru spring-96.0~14.04~ppa4/rts/System/Misc/SpringTime.h spring-98.0~14.04~ppa6/rts/System/Misc/SpringTime.h --- spring-96.0~14.04~ppa4/rts/System/Misc/SpringTime.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Misc/SpringTime.h 2014-10-07 20:09:51.000000000 +0000 @@ -19,7 +19,7 @@ #define SPRINGTIME_USING_STDCHRONO #undef gt #include - namespace chrono { using namespace std::chrono; }; + namespace chrono { using namespace std::chrono; } #else #define SPRINGTIME_USING_BOOST #undef gt @@ -29,6 +29,8 @@ + + namespace spring_clock { // NOTE: // 1e-x are double-precision literals but T can be float @@ -57,14 +59,16 @@ // number of ticks since clock epoch boost::int64_t GetTicks(); const char* GetName(); -}; +} // class Timer struct spring_time { private: - CR_DECLARE_STRUCT(spring_time); + CR_DECLARE_STRUCT(spring_time) + + typedef boost::int64_t int64; public: spring_time(): x(0) {} @@ -72,18 +76,20 @@ spring_time& operator+=(const spring_time st) { x += st.x; return *this; } spring_time& operator-=(const spring_time st) { x -= st.x; return *this; } + spring_time& operator%=(const spring_time mt) { x %= mt.x; return *this; } spring_time operator-(const spring_time st) const { return spring_time_native(x - st.x); } spring_time operator+(const spring_time st) const { return spring_time_native(x + st.x); } + spring_time operator%(const spring_time mt) const { return spring_time_native(x % mt.x); } bool operator<(const spring_time st) const { return (x < st.x); } bool operator>(const spring_time st) const { return (x > st.x); } bool operator<=(const spring_time st) const { return (x <= st.x); } bool operator>=(const spring_time st) const { return (x >= st.x); } // short-hands - boost::int64_t toSecsi() const { return (toSecs ()); } - boost::int64_t toMilliSecsi() const { return (toMilliSecs()); } - boost::int64_t toMicroSecsi() const { return (toMicroSecs()); } - boost::int64_t toNanoSecsi() const { return (toNanoSecs ()); } + int64 toSecsi() const { return (toSecs ()); } + int64 toMilliSecsi() const { return (toMilliSecs()); } + int64 toMicroSecsi() const { return (toMicroSecs()); } + int64 toNanoSecsi() const { return (toNanoSecs ()); } float toSecsf() const { return (toSecs ()); } float toMilliSecsf() const { return (toMilliSecs()); } @@ -110,24 +116,24 @@ static void setstarttime(const spring_time t) { assert(xs == 0); xs = t.x; assert(xs != 0); } - static spring_time fromNanoSecs (const boost::int64_t ns) { return spring_time_native(spring_clock::FromNanoSecs( ns)); } - static spring_time fromMicroSecs(const boost::int64_t us) { return spring_time_native(spring_clock::FromMicroSecs(us)); } - static spring_time fromMilliSecs(const boost::int64_t ms) { return spring_time_native(spring_clock::FromMilliSecs(ms)); } - static spring_time fromSecs (const boost::int64_t s) { return spring_time_native(spring_clock::FromSecs ( s)); } + static spring_time fromNanoSecs (const int64 ns) { return spring_time_native(spring_clock::FromNanoSecs( ns)); } + static spring_time fromMicroSecs(const int64 us) { return spring_time_native(spring_clock::FromMicroSecs(us)); } + static spring_time fromMilliSecs(const int64 ms) { return spring_time_native(spring_clock::FromMilliSecs(ms)); } + static spring_time fromSecs (const int64 s) { return spring_time_native(spring_clock::FromSecs ( s)); } private: // convert integer to spring_time (n is interpreted as number of nanoseconds) - static spring_time spring_time_native(const boost::int64_t n) { spring_time s; s.x = n; return s; } + static spring_time spring_time_native(const int64 n) { spring_time s; s.x = n; return s; } void Serialize(creg::ISerializer& s); private: - boost::int64_t x; + int64 x; // initial time (the "Spring epoch", program start) // all other time-points *must* be larger than this // if the clock is monotonically increasing - static boost::int64_t xs; + static int64 xs; }; @@ -135,7 +141,8 @@ static const spring_time spring_notime(0); static const spring_time spring_nulltime(0); -#define spring_gettime() spring_time::gettime() +//#define spring_gettime() spring_time::gettime() +#define spring_gettime() spring_time::getelapsedtime() #define spring_getstarttime() spring_time::getstarttime() #define spring_now() spring_time::getelapsedtime() diff -Nru spring-96.0~14.04~ppa4/rts/System/myMath.cpp spring-98.0~14.04~ppa6/rts/System/myMath.cpp --- spring-96.0~14.04~ppa4/rts/System/myMath.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/myMath.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -204,6 +204,14 @@ return vec; } +float linearstep(const float edge0, const float edge1, const float value) +{ + if (value <= edge0) return 0.0f; + if (value >= edge1) return 1.0f; + const float x = (value - edge0) / (edge1 - edge0); + const float t = Clamp(x, 0.0f, 1.0f); + return t; +} float3 hs2rgb(float h, float s) diff -Nru spring-96.0~14.04~ppa4/rts/System/myMath.h spring-98.0~14.04~ppa6/rts/System/myMath.h --- spring-96.0~14.04~ppa4/rts/System/myMath.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/myMath.h 2014-10-07 20:09:51.000000000 +0000 @@ -104,6 +104,9 @@ float smoothstep(const float edge0, const float edge1, const float value) _pure _warn_unused_result; float3 smoothstep(const float edge0, const float edge1, float3 vec) _pure _warn_unused_result; +float linearstep(const float edge0, const float edge1, const float value) _pure _warn_unused_result; + + // inlined to avoid multiple definitions due to the specializing templates template inline T argmin(const T v1, const T v2) { return std::min(v1, v2); } template inline T argmax(const T v1, const T v2) { return std::max(v1, v2); } diff -Nru spring-96.0~14.04~ppa4/rts/System/Net/LocalConnection.cpp spring-98.0~14.04~ppa6/rts/System/Net/LocalConnection.cpp --- spring-96.0~14.04~ppa4/rts/System/Net/LocalConnection.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Net/LocalConnection.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -98,7 +98,7 @@ std::string CLocalConnection::GetFullAddress() const { - return "shared memory"; + return "Localhost"; } diff -Nru spring-96.0~14.04~ppa4/rts/System/Net/LoopbackConnection.cpp spring-98.0~14.04~ppa6/rts/System/Net/LoopbackConnection.cpp --- spring-96.0~14.04~ppa4/rts/System/Net/LoopbackConnection.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Net/LoopbackConnection.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -56,7 +56,7 @@ } std::string CLoopbackConnection::GetFullAddress() const { - return "non-shared memory"; + return "Loopback"; } bool CLoopbackConnection::HasIncomingData() const { diff -Nru spring-96.0~14.04~ppa4/rts/System/Net/Socket.cpp spring-98.0~14.04~ppa6/rts/System/Net/Socket.cpp --- spring-96.0~14.04~ppa4/rts/System/Net/Socket.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Net/Socket.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -6,6 +6,8 @@ #include "lib/streflop/streflop_cond.h" #include "System/Log/ILog.h" +#include "System/Util.h" + namespace netcode { @@ -31,23 +33,24 @@ } } -boost::asio::ip::udp::endpoint ResolveAddr(const std::string& host, int port) +boost::asio::ip::udp::endpoint ResolveAddr(const std::string& host, int port, boost::system::error_code* err) { + assert(err); using namespace boost::asio; - boost::system::error_code err; - ip::address tempAddr = WrapIP(host, &err); - if (err) { - // error, maybe a hostname? - ip::udp::resolver resolver(netcode::netservice); - std::ostringstream portbuf; - portbuf << port; - ip::udp::resolver::query query(host, portbuf.str()); - // TODO: check if unsync problem exists here too (see WrapResolve below) - ip::udp::resolver::iterator iter = resolver.resolve(query); - tempAddr = iter->endpoint().address(); + ip::address tempAddr = WrapIP(host, err); + if (!*err) + return ip::udp::endpoint(tempAddr, port); + + boost::asio::io_service io_service; + ip::udp::resolver resolver(io_service); + ip::udp::resolver::query query(host, IntToString(port)); + auto iter = WrapResolve(resolver, query, err); + ip::udp::resolver::iterator end; + if (!*err && iter != end) { + return *iter; } - return ip::udp::endpoint(tempAddr, port); + return ip::udp::endpoint(tempAddr, 0); } bool IsLoopbackAddress(const boost::asio::ip::address& addr) { @@ -79,12 +82,12 @@ return addr; } -boost::asio::ip::tcp::resolver::iterator WrapResolve( - boost::asio::ip::tcp::resolver& resolver, - boost::asio::ip::tcp::resolver::query& query, +boost::asio::ip::udp::resolver::iterator WrapResolve( + boost::asio::ip::udp::resolver& resolver, + boost::asio::ip::udp::resolver::query& query, boost::system::error_code* err) { - boost::asio::ip::tcp::resolver::iterator resolveIt; + boost::asio::ip::udp::resolver::iterator resolveIt; if (err == NULL) { resolveIt = resolver.resolve(query); @@ -100,5 +103,15 @@ return resolveIt; } + +boost::asio::ip::address GetAnyAddress(const bool IPv6) +{ + if (IPv6) { + return boost::asio::ip::address_v6::any(); + } + return boost::asio::ip::address_v4::any(); +} + + } // namespace netcode diff -Nru spring-96.0~14.04~ppa4/rts/System/Net/Socket.h spring-98.0~14.04~ppa6/rts/System/Net/Socket.h --- spring-96.0~14.04~ppa4/rts/System/Net/Socket.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Net/Socket.h 2014-10-07 20:09:51.000000000 +0000 @@ -25,7 +25,7 @@ * eventually resolving the host, if it is specified as name. * @param host name or IP */ -boost::asio::ip::udp::endpoint ResolveAddr(const std::string& host, int port); +boost::asio::ip::udp::endpoint ResolveAddr(const std::string& host, int port, boost::system::error_code* error); /** * Evaluates if an address is a loopback one or not. @@ -41,14 +41,17 @@ boost::system::error_code* err = NULL); /** - * Encapsulates the ip::tcp::resolver::resolve(query) function, + * Encapsulates the ip::udp::resolver::resolve(query) function, * for sync relevant reasons. */ -boost::asio::ip::tcp::resolver::iterator WrapResolve( - boost::asio::ip::tcp::resolver& resolver, - boost::asio::ip::tcp::resolver::query& query, +boost::asio::ip::udp::resolver::iterator WrapResolve( + boost::asio::ip::udp::resolver& resolver, + boost::asio::ip::udp::resolver::query& query, boost::system::error_code* err = NULL); + +boost::asio::ip::address GetAnyAddress(const bool IPv6); + } // namespace netcode #endif // SOCKET_H diff -Nru spring-96.0~14.04~ppa4/rts/System/Net/UDPConnection.cpp spring-98.0~14.04~ppa6/rts/System/Net/UDPConnection.cpp --- spring-96.0~14.04~ppa4/rts/System/Net/UDPConnection.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Net/UDPConnection.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -250,14 +250,10 @@ UDPConnection::UDPConnection(int sourcePort, const std::string& address, const unsigned port) : sharedSocket(false) { - addr = ResolveAddr(address, port); + boost::system::error_code err; + addr = ResolveAddr(address, port, &err); - ip::address sourceAddr; - if (addr.address().is_v6()) { - sourceAddr = ip::address_v6::any(); - } else { - sourceAddr = ip::address_v4::any(); - } + ip::address sourceAddr = GetAnyAddress(addr.address().is_v6()); boost::shared_ptr tempSocket(new ip::udp::socket( netcode::netservice, ip::udp::endpoint(sourceAddr, sourcePort))); mySocket = tempSocket; diff -Nru spring-96.0~14.04~ppa4/rts/System/Net/UDPListener.cpp spring-98.0~14.04~ppa6/rts/System/Net/UDPListener.cpp --- spring-96.0~14.04~ppa4/rts/System/Net/UDPListener.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Net/UDPListener.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -21,6 +21,7 @@ #include "System/Platform/errorhandler.h" #include "System/Util.h" // for IntToString (header only) + namespace netcode { using namespace boost::asio; @@ -30,7 +31,9 @@ { SocketPtr socket; - if (UDPListener::TryBindSocket(port, &socket, ip)) { + const std::string err = TryBindSocket(port, &socket, ip); + + if (err.empty()) { boost::asio::socket_base::non_blocking_io socketCommand(true); socket->io_control(socketCommand); @@ -39,46 +42,45 @@ } if (IsAcceptingConnections()) { - LOG("[UDPListener] successfully bound socket on port %i", port); + LOG("[UDPListener] successfully bound socket on port %i", socket->local_endpoint().port()); } else { - handleerror(NULL, "[UDPListener] error: unable to bind UDP port, see log for details.", "Network error", MBF_OK | MBF_EXCL); + throw network_error(err); } } -bool UDPListener::TryBindSocket(int port, SocketPtr* socket, const std::string& ip) { +std::string UDPListener::TryBindSocket(int port, SocketPtr* socket, const std::string& ip) { std::string errorMsg = ""; try { - ip::address addr; boost::system::error_code err; + if ((port < 0) || (port > 65535)) { + throw std::range_error("Port is out of range [0, 65535]: " + IntToString(port)); + } + socket->reset(new ip::udp::socket(netservice)); (*socket)->open(ip::udp::v6(), err); // test IP v6 support const bool supportsIPv6 = !err; - addr = WrapIP(ip, &err); + auto addr = ResolveAddr(ip, port, &err); if (ip.empty()) { // use the "any" address - if (supportsIPv6) { - addr = ip::address_v6::any(); - } else { - addr = ip::address_v4::any(); - } + addr = ip::udp::endpoint(GetAnyAddress(supportsIPv6), port); } else if (err) { - throw std::runtime_error("Failed to parse address " + ip + ": " + err.message()); + throw std::runtime_error("Failed to parse hostname \"" + ip + "\": " + err.message()); } - if (!supportsIPv6 && addr.is_v6()) { - throw std::runtime_error("IP v6 not supported, can not use address " + addr.to_string()); + if (!supportsIPv6 && addr.address().is_v6()) { + throw std::runtime_error("IP v6 not supported, can not use address " + addr.address().to_string()); } - if (netcode::IsLoopbackAddress(addr)) { + if (netcode::IsLoopbackAddress(addr.address())) { LOG_L(L_WARNING, "Opening socket on loopback address. Other users will not be able to connect!"); } - if (!addr.is_v6()) { + if (!addr.address().is_v6()) { if (supportsIPv6) { (*socket)->close(); } @@ -88,14 +90,10 @@ } } - if ((port < 0) || (port > 65535)) { - throw std::range_error("Port is out of range [0, 65535]: " + IntToString(port)); - } - LOG("Binding UDP socket to IP %s %s port %i", - (addr.is_v6() ? "(v6)" : "(v4)"), addr.to_string().c_str(), - port); - (*socket)->bind(ip::udp::endpoint(addr, port)); + (addr.address().is_v6() ? "(v6)" : "(v4)"), addr.address().to_string().c_str(), + addr.port()); + (*socket)->bind(addr); } catch (const std::runtime_error& ex) { // includes boost::system::system_error and std::range_error socket->reset(); errorMsg = ex.what(); @@ -103,14 +101,8 @@ errorMsg = "Unknown problem"; } } - const bool isBound = errorMsg.empty(); - - if (!isBound) { - LOG_L(L_ERROR, "Failed to bind UDP socket on IP %s, port %i: %s", - ip.c_str(), port, errorMsg.c_str()); - } - return isBound; + return errorMsg; } void UDPListener::Update() { diff -Nru spring-96.0~14.04~ppa4/rts/System/Net/UDPListener.h spring-98.0~14.04~ppa6/rts/System/Net/UDPListener.h --- spring-96.0~14.04~ppa4/rts/System/Net/UDPListener.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Net/UDPListener.h 2014-10-07 20:09:51.000000000 +0000 @@ -49,7 +49,7 @@ * the default value "" results in the v6 any address "::", * or the v4 equivalent "0.0.0.0", if v6 is no supported */ - static bool TryBindSocket(int port, SocketPtr* socket, + static std::string TryBindSocket(int port, SocketPtr* socket, const std::string& ip = ""); /** diff -Nru spring-96.0~14.04~ppa4/rts/System/Object.cpp spring-98.0~14.04~ppa6/rts/System/Object.cpp --- spring-96.0~14.04~ppa4/rts/System/Object.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Object.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -19,7 +19,7 @@ CR_SERIALIZER(Serialize), CR_POSTLOAD(PostLoad) - )); + )) Threading::AtomicCounterInt64 CObject::cur_sync_id(0); diff -Nru spring-96.0~14.04~ppa4/rts/System/Object.h spring-98.0~14.04~ppa6/rts/System/Object.h --- spring-96.0~14.04~ppa4/rts/System/Object.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Object.h 2014-10-07 20:09:51.000000000 +0000 @@ -13,7 +13,7 @@ class CObject { public: - CR_DECLARE(CObject); + CR_DECLARE(CObject) CObject(); virtual ~CObject(); diff -Nru spring-96.0~14.04~ppa4/rts/System/OffscreenGLContext.cpp spring-98.0~14.04~ppa6/rts/System/OffscreenGLContext.cpp --- spring-96.0~14.04~ppa4/rts/System/OffscreenGLContext.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/OffscreenGLContext.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,6 +7,7 @@ #include "System/maindefines.h" #include "System/Log/ILog.h" #include "System/Platform/errorhandler.h" +#include static PFNGLACTIVETEXTUREPROC mainGlActiveTexture = NULL; diff -Nru spring-96.0~14.04~ppa4/rts/System/OffscreenGLContext.h spring-98.0~14.04~ppa6/rts/System/OffscreenGLContext.h --- spring-96.0~14.04~ppa4/rts/System/OffscreenGLContext.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/OffscreenGLContext.h 2014-10-07 20:09:51.000000000 +0000 @@ -48,6 +48,7 @@ /******************************************************************************/ #include +#include namespace boost { class thread; diff -Nru spring-96.0~14.04~ppa4/rts/System/Platform/Clipboard.cpp spring-98.0~14.04~ppa6/rts/System/Platform/Clipboard.cpp --- spring-96.0~14.04~ppa4/rts/System/Platform/Clipboard.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Platform/Clipboard.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,42 +1,16 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ #include "Clipboard.h" +#include -#if defined(__APPLE__) || defined(HEADLESS) -#elif defined(WIN32) -# include -#else -# include -#endif std::string CClipboard::GetContents() const { - std::string contents; -#if defined(__APPLE__) || defined(HEADLESS) - // Nothing for now -#elif defined(WIN32) - OpenClipboard(NULL); - const void* p = GetClipboardData(CF_TEXT); - if (p != NULL) { - contents = (char*)p; + char* text = SDL_GetClipboardText(); + if (text == NULL) { + return ""; } - CloseClipboard(); -#else - // only works with the cut-buffer method (xterm) - // (and not with the more recent selections method) - SDL_SysWMinfo sdlinfo; - SDL_VERSION(&sdlinfo.version); - if (SDL_GetWMInfo(&sdlinfo)) { - sdlinfo.info.x11.lock_func(); - Display* display = sdlinfo.info.x11.display; - int count = 0; - char* msg = XFetchBytes(display, &count); - if ((msg != NULL) && (count > 0)) { - contents.append((char*)msg, count); - } - XFree(msg); - sdlinfo.info.x11.unlock_func(); - } -#endif - return contents; -}; + std::string s = text; + SDL_free(text); + return s; +} diff -Nru spring-96.0~14.04~ppa4/rts/System/Platform/CmdLineParams.cpp spring-98.0~14.04~ppa6/rts/System/Platform/CmdLineParams.cpp --- spring-96.0~14.04~ppa4/rts/System/Platform/CmdLineParams.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Platform/CmdLineParams.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -63,13 +63,17 @@ po::positional_options_description p; p.add("input-file", 1); - po::parsed_options parsed = po::command_line_parser(argc, argv).options(all).positional(p).allow_unregistered().run(); - po::store(parsed, vm); - po::notify(vm); - - std::vector unrecognized = po::collect_unrecognized(parsed.options, po::exclude_positional); - if (!unrecognized.empty()) - throw unrecognized_option("unrecognized option '" + unrecognized[0] + "'"); + try { + po::parsed_options parsed = po::command_line_parser(argc, argv).options(all).positional(p).allow_unregistered().run(); + po::store(parsed, vm); + po::notify(vm); + + std::vector unrecognized = po::collect_unrecognized(parsed.options, po::exclude_positional); + if (!unrecognized.empty()) + throw unrecognized_option("unrecognized option '" + unrecognized[0] + "'"); + } catch(const boost::program_options::too_many_positional_options_error& err) { + throw unrecognized_option("too many unnamed cmdline input options (forgot to quote filepath?)"); + } } void CmdLineParams::PrintUsage() const @@ -89,7 +93,13 @@ std::string cmdLine = (argc > 0) ? UnQuote(argv[0]) : "unknown"; for (int i = 1; i < argc; ++i) { cmdLine += " "; - cmdLine += argv[i]; + if (argv[i][0] != '-') { + cmdLine += "\""; + cmdLine += argv[i]; + cmdLine += "\""; + } else { + cmdLine += argv[i]; + } } return cmdLine; } diff -Nru spring-96.0~14.04~ppa4/rts/System/Platform/CpuID.cpp spring-98.0~14.04~ppa6/rts/System/Platform/CpuID.cpp --- spring-96.0~14.04~ppa4/rts/System/Platform/CpuID.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Platform/CpuID.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,308 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include "CpuID.h" +#include "System/Platform/Threading.h" +#include "System/Log/ILog.h" +//#include +#ifdef _MSC_VER + #include +#endif + +#include +#include +#include + + +namespace springproc { + +#if defined(__GNUC__) + // function inlining breaks this + _noinline void ExecCPUID(unsigned int* a, unsigned int* b, unsigned int* c, unsigned int* d) + { + #ifndef __APPLE__ + __asm__ __volatile__( + "cpuid" + : "=a" (*a), "=b" (*b), "=c" (*c), "=d" (*d) + : "0" (*a), "2" (*c) + ); + #else + #ifdef __x86_64__ + __asm__ __volatile__( + "pushq %%rbx\n\t" + "cpuid\n\t" + "movl %%ebx, %1\n\t" + "popq %%rbx" + : "=a" (*a), "=r" (*b), "=c" (*c), "=d" (*d) + : "0" (*a) + ); + #else + __asm__ __volatile__( + "pushl %%ebx\n\t" + "cpuid\n\t" + "movl %%ebx, %1\n\t" + "popl %%ebx" + : "=a" (*a), "=r" (*b), "=c" (*c), "=d" (*d) + : "0" (*a) + ); + #endif + #endif + } +#elif defined(_MSC_VER) && (_MSC_VER >= 1310) + void ExecCPUID(unsigned int* a, unsigned int* b, unsigned int* c, unsigned int* d) + { + int features[4]; + __cpuid(features, *a); + *a=features[0]; + *b=features[1]; + *c=features[2]; + *d=features[3]; + } +#else + // no-op on other compilers + void ExecCPUID(unsigned int* a, unsigned int* b, unsigned int* c, unsigned int* d) + { + } +#endif + + CpuId::CpuId(): shiftCore(0), shiftPackage(0), + maskVirtual(0), maskCore(0), maskPackage(0), + hasLeaf11(false) + { + nbProcessors = Threading::GetLogicalCpuCores(); + // TODO: allocating a bit more than needed, maybe move + // this after determining the numbers. + + affinityMaskOfCores = new uint64_t[nbProcessors]; + affinityMaskOfPackages = new uint64_t[nbProcessors]; + processorApicIds = new uint32_t[nbProcessors]; + + setDefault(); + + unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0; + eax = 0; + ExecCPUID(&eax, &ebx, &ecx, &edx); + + // Check if it Intel + if (ebx == 0x756e6547) { // "Genu", from "GenuineIntel" + getIdsIntel(); + } else if (ebx == 0x68747541) { // "htuA" from "AuthenticAMD" + // TODO: AMD has also something similar to SMT (called CMT) in Bulldozer + // microarchitecture (FX processors). + getIdsAmd(); + } + } + + // Function based on Figure 1 from Kuo_CpuTopology_rc1.rh1.final.pdf + void CpuId::getIdsIntel() + { + int maxLeaf; + unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0; + eax = 0; + ExecCPUID(&eax, &ebx, &ecx, &edx); + + maxLeaf = eax; + if (maxLeaf >= 0xB) { + eax = 11; + ecx = 0; + ExecCPUID(&eax, &ebx, &ecx, &edx); + + // Check if cpuid leaf 11 really exists + if (ebx != 0) { + hasLeaf11 = true; + LOG_L(L_DEBUG,"[CpuId] leaf 11 support"); + getMasksIntelLeaf11(); + getIdsIntelEnumerate(); + return; + } + } + + if (maxLeaf >= 4) { + LOG_L(L_DEBUG,"[CpuId] leaf 4 support"); + getMasksIntelLeaf1and4(); + getIdsIntelEnumerate(); + return; + } + // Either it is a very old processor, or the cpuid instruction is disabled + // from BIOS. Print a warning an use processor number + LOG_L(L_WARNING,"[CpuId] Max cpuid leaf is less than 4! Using OS processor number."); + setDefault(); + } + + void CpuId::getMasksIntelLeaf11Enumerate() + { + uint32_t currentLevel = 0; + unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0; + eax = 1; + + ExecCPUID(&eax, &ebx, &ecx, &edx); + + eax = 11; + ecx = currentLevel; + currentLevel++; + ExecCPUID(&eax, &ebx, &ecx, &edx); + + if ((ebx && 0xFFFF) == 0) + return; + + if (((ecx >> 8) & 0xFF) == 1) { + LOG_L(L_DEBUG,"[CpuId] SMT level found"); + shiftCore = eax & 0xf; + } else { + LOG_L(L_DEBUG,"[CpuId] No SMT level supported"); + } + + eax = 11; + ecx = currentLevel; + currentLevel++; + ExecCPUID(&eax, &ebx, &ecx, &edx); + + if (((ecx >> 8) & 0xFF) == 2) { + LOG_L(L_DEBUG,"[CpuId] Core level found"); + // Practically this is shiftCore + shitVirtual so it is shiftPackage + shiftPackage = eax & 0xf; + } else { + LOG_L(L_DEBUG,"[CpuId] NO Core level supported"); + } + } + + // Implementing "Sub ID Extraction Parameters for x2APIC ID" from + // Kuo_CpuTopology_rc1.rh1.final.pdf + + void CpuId::getMasksIntelLeaf11() + { + getMasksIntelLeaf11Enumerate(); + + // We determined the shifts now compute the masks + maskVirtual = ~((-1) << shiftCore); + maskCore = (~((-1) << shiftPackage)) ^ maskVirtual; + maskPackage = (-1) << shiftPackage; + } + + void CpuId::getMasksIntelLeaf1and4() + { + int i; + + unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0; + + unsigned maxAddressableLogical; + unsigned maxAddressableCores; + + eax = 1; + ExecCPUID(&eax, &ebx, &ecx, &edx); + + maxAddressableLogical = (ebx >> 18) & 0xff; + + eax = 4; + ecx = 0; + ExecCPUID(&eax, &ebx, &ecx, &edx); + maxAddressableCores = ((eax >> 26) & 0x3f) + 1; + + shiftCore = (maxAddressableLogical / maxAddressableCores); + // We compute the next power of 2 that is larger than shiftPackage + i = 0; + while ((1 << i) < shiftCore) + i++; + shiftCore = i; + + i = 0; + while ((1 << i) < maxAddressableCores) + i++; + shiftPackage = i; + + // We determined the shifts now compute the masks + maskVirtual = ~((-1) << shiftCore); + maskCore = (~((-1) << shiftPackage)) ^ maskVirtual; + maskPackage = (-1) << shiftPackage; + } + + void CpuId::getIdsIntelEnumerate() + { + auto oldAffinity = Threading::GetAffinity(); + + int processorNumber = Threading::GetLogicalCpuCores(); + assert(processorNumber <= 64); // as the affinity mask is a uint64_t + assert(processorNumber <= 32); // spring uses uint32_t + for (size_t processor = 0; processor < processorNumber; processor++) { + Threading::SetAffinity(((uint32_t) 1) << processor, true); + boost::this_thread::yield(); + processorApicIds[processor] = getApicIdIntel(); + } + + // We determine the total numbers of cores + std::set< uint32_t> cores; + for (size_t processor = 0; processor < processorNumber; processor++) { + auto ret = cores.insert(processorApicIds[processor] >> shiftCore); + if (!ret.second) + continue; + + affinityMaskOfCores[cores.size() - 1] = ((uint64_t) 1) << processor; + } + coreTotalNumber = cores.size(); + + // We determine the total numbers of packages cores + std::set packages; + for (size_t processor = 0; processor < processorNumber; processor++) { + auto ret = packages.insert(processorApicIds[processor] >> shiftPackage); + if (!ret.second) + continue; + + affinityMaskOfPackages[packages.size() - 1] |= ((uint64_t) 1) << processor; + } + + packageTotalNumber = packages.size(); + + Threading::SetAffinity(oldAffinity); + } + + uint32_t CpuId::getApicIdIntel() + { + unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0; + + if (hasLeaf11) { + eax = 11; + ExecCPUID(&eax, &ebx, &ecx, &edx); + return edx; + } else { + eax = 1; + ExecCPUID(&eax, &ebx, &ecx, &edx); + return (unsigned char)(ebx >> 24); + } + } + + void CpuId::getIdsAmd() + { + LOG_L(L_WARNING,"[CpuId] ht/smt/cmt detection for AMD is not implemented! Using processor number reported by OS."); + } + + int CpuId::getCoreTotalNumber() + { + return coreTotalNumber; + } + + int CpuId::getPackageTotalNumber() + { + return packageTotalNumber; + } + + uint64_t CpuId::getAffinityMaskOfCore(int x) + { + return affinityMaskOfCores[x]; + } + + uint64_t CpuId::getAffinityMaskOfPackage(int x) + { + return affinityMaskOfPackages[x]; + } + + void CpuId::setDefault() + { + coreTotalNumber = Threading::GetLogicalCpuCores(); + packageTotalNumber = 1; + + // As we could not determine anything just set affinity mask to (-1) + for (int i = 0; i < Threading::GetLogicalCpuCores(); i++) { + affinityMaskOfCores[i] = affinityMaskOfPackages[i] = -1; + } + } + +} diff -Nru spring-96.0~14.04~ppa4/rts/System/Platform/CpuID.h spring-98.0~14.04~ppa6/rts/System/Platform/CpuID.h --- spring-96.0~14.04~ppa4/rts/System/Platform/CpuID.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Platform/CpuID.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,96 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef CPUID_H +#define CPUID_H + +#if defined(__GNUC__) + #define _noinline __attribute__((__noinline__)) +#else + #define _noinline +#endif + +#include + +namespace springproc { + _noinline void ExecCPUID(unsigned int* a, unsigned int* b, unsigned int* c, unsigned int* d); + + /** Class to detect the processor topology, more specifically, + for now it can detect the number of real (not hyper threaded + core. + + It uses 'cpuid' instructions to query the information. It + implements both the new (i7 and above) and legacy (from P4 on + methods). + + The implementation is done only for Intel processor for now, as at + the time of the writing it was not clear how to achieve a similar + result for AMD CMT multithreading. + + This file is based on the following documentations from Intel: + - "Intel® 64 Architecture Processor Topology Enumeration" + (Kuo_CpuTopology_rc1.rh1.final.pdf) + - "Intel® 64 and IA-32 Architectures Software Developer’s Manual + Volume 3A: System Programming Guide, Part 1" + (64-ia-32-architectures-software-developer-vol-3a-part-1-manual.pdf) + - "Intel® 64 and IA-32 Architectures Software Developer’s Manual + Volume 2A: Instruction Set Reference, A-M" + (64-ia-32-architectures-software-developer-vol-2a-manual.pdf) */ + + class CpuId { + private: + void getIdsAmd(); + void getIdsIntel(); + void setDefault(); + + int nbProcessors; + int coreTotalNumber; + int packageTotalNumber; + + /** Array of the size coreTotalNumber, containing for each + core the affinity mask. */ + uint64_t *affinityMaskOfCores; + uint64_t *affinityMaskOfPackages; + + //////////////////////// + // Intel specific fields + + uint32_t* processorApicIds; + + void getIdsIntelEnumerate(); + + void getMasksIntelLeaf11Enumerate(); + void getMasksIntelLeaf11(); + void getMasksIntelLeaf1and4(); + + uint32_t getApicIdIntel(); + + uint32_t shiftCore; + uint32_t shiftPackage; + + uint32_t maskVirtual; + uint32_t maskCore; + uint32_t maskPackage; + + bool hasLeaf11; + + //////////////////////// + // AMD specific fields + + //////////////////////// + public: + CpuId(); + + /** Total number of cores in the system. This excludes SMT/HT + cores. */ + int getCoreTotalNumber(); + + /** Total number of physical processor dies in the system. */ + int getPackageTotalNumber(); + + uint64_t getAffinityMaskOfCore(int x); + uint64_t getAffinityMaskOfPackage(int x); + }; + +} + +#endif // CPUID_H diff -Nru spring-96.0~14.04~ppa4/rts/System/Platform/CrashHandler.h spring-98.0~14.04~ppa6/rts/System/Platform/CrashHandler.h --- spring-96.0~14.04~ppa4/rts/System/Platform/CrashHandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Platform/CrashHandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -16,6 +16,6 @@ void CleanupStacktrace(const int logLevel = LOG_LEVEL_ERROR); void OutputStacktrace(); -}; +} #endif // _CRASH_HANDLER_H_ diff -Nru spring-96.0~14.04~ppa4/rts/System/Platform/errorhandler.h spring-98.0~14.04~ppa6/rts/System/Platform/errorhandler.h --- spring-96.0~14.04~ppa4/rts/System/Platform/errorhandler.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Platform/errorhandler.h 2014-10-07 20:09:51.000000000 +0000 @@ -9,6 +9,9 @@ #define _ERROR_HANDLER_H #include +#ifndef NO_CATCH_EXCEPTIONS +#include +#endif #include #include #include "System/Exceptions.h" @@ -60,6 +63,9 @@ } \ catch (const unsupported_error& e) { \ ErrorMessageBox(e.what(), "Spring: Hardware Problem: ", MBF_OK | MBF_CRASH); \ + } \ + catch (const network_error& e) { \ + ErrorMessageBox(e.what(), "Spring: Network Error: ", MBF_OK | MBF_EXCL); \ } /** diff -Nru spring-96.0~14.04~ppa4/rts/System/Platform/Linux/CrashHandler.cpp spring-98.0~14.04~ppa6/rts/System/Platform/Linux/CrashHandler.cpp --- spring-96.0~14.04~ppa4/rts/System/Platform/Linux/CrashHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Platform/Linux/CrashHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -188,11 +188,11 @@ char binPathName[512]; char line[512]; - int red; + // read all lines while (!paths_notFound.empty() && (fgets(line, 511, mapsFile) != NULL)) { // parse the line - red = sscanf(line, "%lx-%*x %*s %lx %*s %*u %s", + const int red = sscanf(line, "%lx-%*x %*s %lx %*s %*u %s", &mem_start, &binAddr_offset, binPathName); if (red == 3) { @@ -336,13 +336,17 @@ __FORCE_ALIGN_STACK__ static void ForcedExitAfterFiveSecs() { boost::this_thread::sleep(boost::posix_time::seconds(5)); - exit(-1); + std::exit(-1); } __FORCE_ALIGN_STACK__ static void ForcedExitAfterTenSecs() { boost::this_thread::sleep(boost::posix_time::seconds(10)); +#if defined(__GNUC__) std::_Exit(-1); +#else + std::quick_exit(-1); +#endif } @@ -637,4 +641,4 @@ std::set_new_handler(NULL); } -}; +} diff -Nru spring-96.0~14.04~ppa4/rts/System/Platform/Linux/MessageBox.cpp spring-98.0~14.04~ppa6/rts/System/Platform/Linux/MessageBox.cpp --- spring-96.0~14.04~ppa4/rts/System/Platform/Linux/MessageBox.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Platform/Linux/MessageBox.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -126,4 +126,4 @@ } } -}; //namespace Platform +} //namespace Platform diff -Nru spring-96.0~14.04~ppa4/rts/System/Platform/Linux/myX11.cpp spring-98.0~14.04~ppa6/rts/System/Platform/Linux/myX11.cpp --- spring-96.0~14.04~ppa4/rts/System/Platform/Linux/myX11.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Platform/Linux/myX11.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,153 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#ifndef HEADLESS - -#include "myX11.h" - -#include -#include -#include - -#include -#if !defined(HEADLESS) - #include -#endif - - -void MyX11GetFrameBorderOffset(Display* display, Window& window, int* out_left, int* out_top) -{ - // XGetWindowProperty stuff - Atom actual_type; - int actual_format; - unsigned long nitems; - unsigned long bytes_remaining; - int* data; - int status; - - Atom net_frame_extents = XInternAtom(display, "_NET_FRAME_EXTENTS", True); - - status = XGetWindowProperty( - display, - window, - net_frame_extents, - 0, // long_offset - 4, // long_length - we expect 4 32-bit values for _NET_FRAME_EXTENTS - false, // delete - AnyPropertyType, - &actual_type, - &actual_format, - &nitems, - &bytes_remaining, - (unsigned char**)&data); - - *out_left = *out_top = 0; - if (status == Success) { - if ((nitems == 4) && (bytes_remaining == 0)) { - *out_left = data[0]; - *out_top = data[2]; - } - XFree(data); - } -} - -static const int windowStates = 8; -static const std::string windowStatesStr[windowStates] = { - "_NET_WM_STATE_STICKY", - "_NET_WM_STATE_MAXIMIZED_VERT", - "_NET_WM_STATE_MAXIMIZED_HORZ", - "_NET_WM_STATE_SHADED", - "_NET_WM_STATE_HIDDEN", - "_NET_WM_STATE_FULLSCREEN", - "_NET_WM_STATE_ABOVE", - "_NET_WM_STATE_BELOW" -}; - -int MyX11GetWindowState(Display* display, Window& window) -{ - // XGetWindowProperty stuff - Atom actual_type; - int actual_format; - unsigned long nitems; - unsigned long bytes_remaining; - Atom* data; - int status; - - Atom atom = XInternAtom(display, "_NET_WM_STATE", true); - - Atom windowStatesAtoms[windowStates]; - std::map windowStatesInt; - for (int i=0; i::iterator it = windowStatesInt.find(a); - if (it != windowStatesInt.end()) { - windowState += it->second; - } - } - XFree(data); - return windowState; - } - return 0; -} - - -void MyX11SetWindowState(Display* display, Window& window, int windowState) -{ - if (windowState <= 0) - return; - - - Atom windowStatesAtoms[windowStates]; - for (int i=0; i -#undef KeyPress -#undef KeyRelease -#undef GrayScale - -/** - * @brief returns the offset of a window to the display - * @param display The display - * @param window The window - * @param out_left Pointer to an int, that will hold the x offset - * @param out_top Pointer to an int, that will hold the y offset - */ -void MyX11GetFrameBorderOffset(Display* display, Window& window, int* out_left, int* out_top); - -/** - * @brief returns the window-state of the given window - * @see MyX11SetWindowState() - */ -int MyX11GetWindowState(Display* display, Window& window); - -/** - * @brief sets the window to windowState (maximized, minimized, ...) - * @see MyX11GetWindowState() - */ -void MyX11SetWindowState(Display* display, Window& window, int windowState); - -#endif // #ifndef HEADLESS - -#endif // #ifndef MY_X11_H diff -Nru spring-96.0~14.04~ppa4/rts/System/Platform/Linux/WindowManagerHelper.cpp spring-98.0~14.04~ppa6/rts/System/Platform/Linux/WindowManagerHelper.cpp --- spring-96.0~14.04~ppa4/rts/System/Platform/Linux/WindowManagerHelper.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Platform/Linux/WindowManagerHelper.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,101 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include "System/Platform/WindowManagerHelper.h" +#include + +#ifndef HEADLESS + #include + #undef KeyPress + #undef KeyRelease + #undef GrayScale +#endif + +namespace WindowManagerHelper { + +void BlockCompositing(SDL_Window* window) +{ +#ifndef HEADLESS + SDL_SysWMinfo info; + SDL_VERSION(&info.version); + if (!SDL_GetWindowWMInfo(window, &info)) + return; + + auto x11display = info.info.x11.display; + auto x11window = info.info.x11.window; + + bool b = true; + Atom blockCompositAtomKDE = XInternAtom(x11display, "_KDE_NET_WM_BLOCK_COMPOSITING", false); + XChangeProperty(x11display, x11window, blockCompositAtomKDE, XA_INTEGER, 8, PropModeReplace, (const unsigned char*)&b, 1); + + Atom blockCompositAtom = XInternAtom(x11display, "_NET_WM_BYPASS_COMPOSITOR", false); + XChangeProperty(x11display, x11window, blockCompositAtom, XA_INTEGER, 8, PropModeReplace, (const unsigned char*)&b, 1); +#endif +} + + +int GetWindowState(SDL_Window* window) +{ + int flags = 0; +#ifndef HEADLESS + SDL_SysWMinfo info; + SDL_VERSION(&info.version); + if (!SDL_GetWindowWMInfo(window, &info)) + return 0; + + auto x11display = info.info.x11.display; + auto x11window = info.info.x11.window; + + // XGetWindowProperty stuff + Atom actual_type; + int actual_format; + unsigned long nitems; + unsigned long bytes_remaining; + Atom* data; + int status; + + Atom atom = XInternAtom(x11display, "_NET_WM_STATE", true); + + Atom maxVAtom = XInternAtom(x11display, "_NET_WM_STATE_MAXIMIZED_VERT", false); + Atom maxHAtom = XInternAtom(x11display, "_NET_WM_STATE_MAXIMIZED_HORZ", false); + Atom minAtom = XInternAtom(x11display, "_NET_WM_STATE_HIDDEN", false); + + status = XGetWindowProperty( + x11display, + x11window, + atom, + 0, + 20, + false, + AnyPropertyType, + &actual_type, + &actual_format, + &nitems, + &bytes_remaining, + (unsigned char**)&data); + + if (status != Success) + return 0; + + int maximized = 0; + bool minimized = false; + for (int i=0; i + + +namespace WindowManagerHelper { + +void BlockCompositing(SDL_Window* window) +{ + //FIXME implement? +} + + +int GetWindowState(SDL_Window* window) +{ + return SDL_GetWindowFlags(window); +} + +}; // namespace WindowManagerHelper diff -Nru spring-96.0~14.04~ppa4/rts/System/Platform/MessageBox.h spring-98.0~14.04~ppa6/rts/System/Platform/MessageBox.h --- spring-96.0~14.04~ppa4/rts/System/Platform/MessageBox.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Platform/MessageBox.h 2014-10-07 20:09:51.000000000 +0000 @@ -14,6 +14,6 @@ * @param flags @see errorhandler.h */ void MsgBox(const std::string& message, const std::string& caption, const unsigned int& flags); -}; +} #endif // _MESSAGEBOX_H_ diff -Nru spring-96.0~14.04~ppa4/rts/System/Platform/Misc.cpp spring-98.0~14.04~ppa6/rts/System/Platform/Misc.cpp --- spring-96.0~14.04~ppa4/rts/System/Platform/Misc.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Platform/Misc.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -253,7 +253,7 @@ // this will only be used if moduleFilePath stays empty const char* error = NULL; -#if defined(linux) || defined(__APPLE__) || defined(__FreeBSD__) +#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) #ifdef __APPLE__ #define SHARED_LIBRARY_EXTENSION "dylib" #else @@ -401,7 +401,7 @@ return bIsWow64; } #else -// simply assume other OS doesn't need 32bit emulation +// simply assume other OS don't need 32bit emulation bool Is32BitEmulation() { return false; @@ -427,17 +427,36 @@ #endif } +std::string GetShortFileName(const std::string& file) { +#ifdef WIN32 + std::vector shortPathC(file.size() + 1, 0); + + // FIXME: stackoverflow.com/questions/843843/getshortpathname-unpredictable-results + const int length = GetShortPathName(file.c_str(), &shortPathC[0], file.size() + 1); + + if (length > 0 && length <= (file.size() + 1)) { + return (std::string(reinterpret_cast(&shortPathC[0]))); + } +#endif + + return file; +} + std::string ExecuteProcess(const std::string& file, std::vector args) { + // "The first argument, by convention, should point to + // the filename associated with the file being executed." + // NOTE: + // spaces in the first argument or quoted file paths + // are not supported on Windows, so translate + // to a short path there + args.insert(args.begin(), GetShortFileName(file)); + // "The array of pointers must be terminated by a NULL pointer." // --> include one extra argument string and leave it NULL std::vector processArgs(args.size() + 1, NULL); std::string execError; - // "The first argument, by convention, should point to - // the filename associated with the file being executed." - args.insert(args.begin(), Quote(file)); - for (size_t a = 0; a < args.size(); ++a) { const std::string& arg = args[a]; const size_t argSize = arg.length() + 1; @@ -451,7 +470,7 @@ #define EXECVP execvp #endif if (EXECVP(args[0].c_str(), &processArgs[0]) == -1) { - execError = strerror(errno); + LOG("[%s] error: \"%s\" %s (%d)", __FUNCTION__, args[0].c_str(), (execError = strerror(errno)).c_str(), errno); } #undef EXECVP diff -Nru spring-96.0~14.04~ppa4/rts/System/Platform/RecursiveScopedLock.h spring-98.0~14.04~ppa6/rts/System/Platform/RecursiveScopedLock.h --- spring-96.0~14.04~ppa4/rts/System/Platform/RecursiveScopedLock.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Platform/RecursiveScopedLock.h 2014-10-07 20:09:51.000000000 +0000 @@ -35,6 +35,6 @@ } }; -}; +} #endif // RECURSIVE_SCOPED_LOCK_H diff -Nru spring-96.0~14.04~ppa4/rts/System/Platform/SDL1_keysym.cpp spring-98.0~14.04~ppa6/rts/System/Platform/SDL1_keysym.cpp --- spring-96.0~14.04~ppa4/rts/System/Platform/SDL1_keysym.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Platform/SDL1_keysym.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,302 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include "SDL1_keysym.h" +#include +#include + + +template +class unordered_bimap { +public: + typedef std::unordered_map first_type; + typedef std::unordered_map second_type; + + first_type const& first() const { return first_; } + second_type const& second() const { return second_; } + + unordered_bimap(const std::initializer_list> list) + : first_(list) + { + second_.reserve(list.size()); + for (const auto& pair: list) { + if (second_.find(pair.second) == second_.end()) { + second_[pair.second] = pair.first; + } + } + } + +private: + const first_type first_; + second_type second_; +}; + + +static const unordered_bimap SDL_keysym_bimap = { + {SDLK_UNKNOWN, 0}, + + {SDLK_RETURN, 13}, + {SDLK_ESCAPE, 27}, + {SDLK_BACKSPACE, 8}, + {SDLK_TAB, 9}, + {SDLK_SPACE, 32}, + {SDLK_EXCLAIM, 33}, + {SDLK_QUOTEDBL, 34}, + {SDLK_HASH, 35}, + //{SDLK_PERCENT, 0}, + {SDLK_DOLLAR, 36}, + {SDLK_AMPERSAND, 38}, + {SDLK_QUOTE, 39}, + {SDLK_LEFTPAREN, 40}, + {SDLK_RIGHTPAREN, 41}, + {SDLK_ASTERISK, 42}, + {SDLK_PLUS, 43}, + {SDLK_COMMA, 44}, + {SDLK_MINUS, 45}, + {SDLK_PERIOD, 46}, + {SDLK_SLASH, 47}, + {SDLK_0, 48}, + {SDLK_1, 49}, + {SDLK_2, 50}, + {SDLK_3, 51}, + {SDLK_4, 52}, + {SDLK_5, 53}, + {SDLK_6, 54}, + {SDLK_7, 55}, + {SDLK_8, 56}, + {SDLK_9, 57}, + {SDLK_COLON, 58}, + {SDLK_SEMICOLON, 59}, + {SDLK_LESS, 60}, + {SDLK_EQUALS, 61}, + {SDLK_GREATER, 62}, + {SDLK_QUESTION, 63}, + {SDLK_AT, 64}, + {SDLK_LEFTBRACKET, 91}, + {SDLK_BACKSLASH, 92}, + {SDLK_RIGHTBRACKET, 93}, + {SDLK_CARET, 94}, + {SDLK_UNDERSCORE, 95}, + {SDLK_BACKQUOTE, 96}, + {SDLK_a, 97}, + {SDLK_b, 98}, + {SDLK_c, 99}, + {SDLK_d, 100}, + {SDLK_e, 101}, + {SDLK_f, 102}, + {SDLK_g, 103}, + {SDLK_h, 104}, + {SDLK_i, 105}, + {SDLK_j, 106}, + {SDLK_k, 107}, + {SDLK_l, 108}, + {SDLK_m, 109}, + {SDLK_n, 110}, + {SDLK_o, 111}, + {SDLK_p, 112}, + {SDLK_q, 113}, + {SDLK_r, 114}, + {SDLK_s, 115}, + {SDLK_t, 116}, + {SDLK_u, 117}, + {SDLK_v, 118}, + {SDLK_w, 119}, + {SDLK_x, 120}, + {SDLK_y, 121}, + {SDLK_z, 122}, + + {SDLK_CAPSLOCK, 301}, + + {SDLK_F1, 282}, + {SDLK_F2, 283}, + {SDLK_F3, 284}, + {SDLK_F4, 285}, + {SDLK_F5, 286}, + {SDLK_F6, 287}, + {SDLK_F7, 288}, + {SDLK_F8, 289}, + {SDLK_F9, 290}, + {SDLK_F10, 291}, + {SDLK_F11, 292}, + {SDLK_F12, 293}, + + {SDLK_PRINTSCREEN, 316}, + {SDLK_SCROLLLOCK, 302}, + {SDLK_PAUSE, 19}, + {SDLK_INSERT, 277}, + {SDLK_HOME, 278}, + {SDLK_PAGEUP, 280}, + {SDLK_DELETE, 127}, + {SDLK_END, 279}, + {SDLK_PAGEDOWN, 281}, + {SDLK_RIGHT, 275}, + {SDLK_LEFT, 276}, + {SDLK_DOWN, 274}, + {SDLK_UP, 273}, + + {SDLK_NUMLOCKCLEAR, 300}, + {SDLK_KP_DIVIDE, 267}, + {SDLK_KP_MULTIPLY, 268}, + {SDLK_KP_MINUS, 269}, + {SDLK_KP_PLUS, 270}, + {SDLK_KP_ENTER, 271}, + {SDLK_KP_1, 257}, + {SDLK_KP_2, 258}, + {SDLK_KP_3, 259}, + {SDLK_KP_4, 260}, + {SDLK_KP_5, 261}, + {SDLK_KP_6, 262}, + {SDLK_KP_7, 263}, + {SDLK_KP_8, 264}, + {SDLK_KP_9, 265}, + {SDLK_KP_0, 256}, + {SDLK_KP_PERIOD, 266}, + +// {SDLK_APPLICATION, 0}, + {SDLK_POWER, 320}, + {SDLK_KP_EQUALS, 272}, + {SDLK_F13, 294}, + {SDLK_F14, 295}, + {SDLK_F15, 296}, +// {SDLK_F16, 0}, +// {SDLK_F17, 0}, +// {SDLK_F18, 0}, +// {SDLK_F19, 0}, +// {SDLK_F20, 0}, +// {SDLK_F21, 0}, +// {SDLK_F22, 0}, +// {SDLK_F23, 0}, +// {SDLK_F24, 0}, +// {SDLK_EXECUTE, 0}, + {SDLK_HELP, 315}, + {SDLK_MENU, 319}, +// {SDLK_SELECT, 0}, +// {SDLK_STOP, 0}, +// {SDLK_AGAIN, 0}, + {SDLK_UNDO, 322}, +// {SDLK_CUT, 0}, +// {SDLK_COPY, 0}, +// {SDLK_PASTE, 0}, +// {SDLK_FIND, 0}, +// {SDLK_MUTE, 0}, +// {SDLK_VOLUMEUP, 0}, +// {SDLK_VOLUMEDOWN, 0}, + {SDLK_KP_COMMA, 44}, //using SDLK_COMMA +// {SDLK_KP_EQUALSAS400, 0}, + +// {SDLK_ALTERASE, 0}, + {SDLK_SYSREQ, 317}, +// {SDLK_CANCEL, 0}, + {SDLK_CLEAR, 12}, +// {SDLK_PRIOR, 0}, +// {SDLK_RETURN2, 0}, +// {SDLK_SEPARATOR, 0}, +// {SDLK_OUT, 0}, +// {SDLK_OPER, 0}, +// {SDLK_CLEARAGAIN, 0}, +// {SDLK_CRSEL, 0}, +// {SDLK_EXSEL, 0}, + +// {SDLK_KP_00, 0}, +// {SDLK_KP_000, 0}, +// {SDLK_THOUSANDSSEPARATOR, 0}, +// {SDLK_DECIMALSEPARATOR, 0}, +// {SDLK_CURRENCYUNIT, 0}, +// {SDLK_CURRENCYSUBUNIT, 0}, +// {SDLK_KP_LEFTPAREN, 0}, +// {SDLK_KP_RIGHTPAREN, 0}, +// {SDLK_KP_LEFTBRACE, 0}, +// {SDLK_KP_RIGHTBRACE, 0}, +// {SDLK_KP_TAB, 0}, +// {SDLK_KP_BACKSPACE, 0}, +// {SDLK_KP_A, 0}, +// {SDLK_KP_B, 0}, +// {SDLK_KP_C, 0}, +// {SDLK_KP_D, 0}, +// {SDLK_KP_E, 0}, +// {SDLK_KP_F, 0}, +// {SDLK_KP_XOR, 0}, +// {SDLK_KP_POWER, 0}, +// {SDLK_KP_PERCENT, 0}, +// {SDLK_KP_LESS, 0}, +// {SDLK_KP_GREATER, 0}, +// {SDLK_KP_AMPERSAND, 0}, +// {SDLK_KP_DBLAMPERSAND, 0}, +// {SDLK_KP_VERTICALBAR, 0}, +// {SDLK_KP_DBLVERTICALBAR, 0}, +// {SDLK_KP_COLON, 0}, +// {SDLK_KP_HASH, 0}, +// {SDLK_KP_SPACE, 0}, +// {SDLK_KP_AT, 0}, +// {SDLK_KP_EXCLAM, 0}, +// {SDLK_KP_MEMSTORE, 0}, +// {SDLK_KP_MEMRECALL, 0}, +// {SDLK_KP_MEMCLEAR, 0}, +// {SDLK_KP_MEMADD, 0}, +// {SDLK_KP_MEMSUBTRACT, 0}, +// {SDLK_KP_MEMMULTIPLY, 0}, +// {SDLK_KP_MEMDIVIDE, 0}, +// {SDLK_KP_PLUSMINUS, 0}, +// {SDLK_KP_CLEAR, 0}, +// {SDLK_KP_CLEARENTRY, 0}, +// {SDLK_KP_BINARY, 0}, +// {SDLK_KP_OCTAL, 0}, +// {SDLK_KP_DECIMAL, 0}, +// {SDLK_KP_HEXADECIMAL, 0}, + + {SDLK_LCTRL, 306}, + {SDLK_LSHIFT, 304}, + {SDLK_LALT, 308}, + {SDLK_LGUI, 310}, + {SDLK_RCTRL, 305}, + {SDLK_RSHIFT, 303}, + {SDLK_RALT, 307}, + {SDLK_RGUI, 309}, + + {SDLK_MODE, 313}, + +// {SDLK_AUDIONEXT, 0}, +// {SDLK_AUDIOPREV, 0}, +// {SDLK_AUDIOSTOP, 0}, +// {SDLK_AUDIOPLAY, 0}, +// {SDLK_AUDIOMUTE, 0}, +// {SDLK_MEDIASELECT, 0}, +// {SDLK_WWW, 0}, +// {SDLK_MAIL, 0}, +// {SDLK_CALCULATOR, 0}, +// {SDLK_COMPUTER, 0}, +// {SDLK_AC_SEARCH, 0}, +// {SDLK_AC_HOME, 0}, +// {SDLK_AC_BACK, 0}, +// {SDLK_AC_FORWARD, 0}, +// {SDLK_AC_STOP, 0}, +// {SDLK_AC_REFRESH, 0}, +// {SDLK_AC_BOOKMARKS, 0}, + +// {SDLK_BRIGHTNESSDOWN, 0}, +// {SDLK_BRIGHTNESSUP, 0}, +// {SDLK_DISPLAYSWITCH, 0}, +// {SDLK_KBDILLUMTOGGLE, 0}, +// {SDLK_KBDILLUMDOWN, 0}, +// {SDLK_KBDILLUMUP, 0}, +// {SDLK_EJECT, 0}, +// {SDLK_SLEEP, 0}, +}; + + +int SDL21_keysyms(const int SDL2_keycode) +{ + auto it = SDL_keysym_bimap.first().find(SDL2_keycode); + if (it != SDL_keysym_bimap.first().end()) + return it->second; + return 0; +} + + +int SDL12_keysyms(const int SDL1_keycode) +{ + auto it = SDL_keysym_bimap.second().find(SDL1_keycode); + if (it != SDL_keysym_bimap.second().end()) + return it->second; + return 0; +} + diff -Nru spring-96.0~14.04~ppa4/rts/System/Platform/SDL1_keysym.h spring-98.0~14.04~ppa6/rts/System/Platform/SDL1_keysym.h --- spring-96.0~14.04~ppa4/rts/System/Platform/SDL1_keysym.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Platform/SDL1_keysym.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,7 @@ +#ifndef SDL1_KEYSYM_H +#define SDL1_KEYSYM_H + +extern int SDL21_keysyms(const int SDL2_keycode); +extern int SDL12_keysyms(const int SDL1_keycode); + +#endif // SDL1_KEYSYM_H diff -Nru spring-96.0~14.04~ppa4/rts/System/Platform/Threading.cpp spring-98.0~14.04~ppa6/rts/System/Platform/Threading.cpp --- spring-96.0~14.04~ppa4/rts/System/Platform/Threading.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Platform/Threading.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,7 +1,5 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ -#include "lib/gml/gml_base.h" -#include "lib/gml/gmlmut.h" #include "Threading.h" #include "Game/GameController.h" #include "System/bitops.h" @@ -10,12 +8,9 @@ #include "System/Config/ConfigHandler.h" #endif #include "System/Log/ILog.h" +#include "System/Platform/CpuID.h" #include "System/Platform/CrashHandler.h" -#ifndef DEDICATED - #include "System/Sync/FPUCheck.h" -#endif - #include #include #include @@ -30,14 +25,9 @@ #include #endif -#include "lib/gml/gmlcnf.h" -#include "lib/gml/gml_base.h" - - - #ifndef UNIT_TEST CONFIG(int, WorkerThreadCount).defaultValue(-1).safemodeValue(0).minimumValue(-1).description("Count of worker threads (including mainthread!) used in parallel sections."); -CONFIG(int, WorkerThreadSpinTime).defaultValue(5).minimumValue(0).description("The number of milliseconds worker threads will spin after no tasks to perform."); +CONFIG(int, WorkerThreadSpinTime).defaultValue(1).minimumValue(0).description("The number of milliseconds worker threads will spin after no tasks to perform."); #endif @@ -61,7 +51,7 @@ #if defined(__APPLE__) || defined(__FreeBSD__) #elif defined(WIN32) - static DWORD cpusSystem = 0; + static DWORD_PTR cpusSystem = 0; #else static cpu_set_t cpusSystem; #endif @@ -77,7 +67,7 @@ #elif defined(WIN32) // Get the available cores - DWORD curMask; + DWORD_PTR curMask; GetProcessAffinityMask(GetCurrentProcess(), &curMask, &cpusSystem); #else @@ -86,10 +76,41 @@ sched_getaffinity(0, sizeof(cpu_set_t), &cpusSystem); #endif + GetPhysicalCpuCores(); // (uses a static, too) inited = true; } + boost::uint32_t GetAffinity() + { + #if defined(__APPLE__) || defined(__FreeBSD__) + // no-op + return 0; + + #elif defined(WIN32) + DWORD_PTR curMask; + DWORD_PTR systemCpus; + GetProcessAffinityMask(GetCurrentProcess(), &curMask, &systemCpus); + return curMask; + #else + cpu_set_t curAffinity; + CPU_ZERO(&curAffinity); + sched_getaffinity(0, sizeof(cpu_set_t), &curAffinity); + + boost::uint32_t mask = 0; + + int numCpus = std::min(CPU_COUNT(&curAffinity), 32); // w/o the min(.., 32) `(1 << n)` could overflow! + for (int n = numCpus - 1; n >= 0; --n) { + if (CPU_ISSET(n, &curAffinity)) { + mask |= (1 << n); + } + } + + return mask; + #endif + } + + boost::uint32_t SetAffinity(boost::uint32_t cores_bitmask, bool hard) { if (cores_bitmask == 0) { @@ -156,12 +177,6 @@ } } - int GetAvailableCores() - { - // auto-detect number of system threads - return boost::thread::hardware_concurrency(); - } - boost::uint32_t GetAvailableCoresMask() { @@ -193,6 +208,8 @@ boost::uint32_t ompCore = 1; // find an unused core + // count down cause hyperthread cores are appended to the end and we prefer those for our worker threads + // (the physical cores are prefered for task specific threads) { while ((ompCore) && !(ompCore & availCores)) ompCore <<= 1; @@ -223,13 +240,34 @@ } + int GetLogicalCpuCores() { + // auto-detect number of system threads (including hyperthreading) + return boost::thread::hardware_concurrency(); + } + + + /** Function that returns the number of real cpu cores (not + hyperthreading ones). These are the total cores in the system + (across all existing processors, if more than one)*/ + int GetPhysicalCpuCores() { + // Get CPU features + static springproc::CpuId cpuid; + return cpuid.getCoreTotalNumber(); + } + + + bool HasHyperThreading() { + return (GetLogicalCpuCores() > GetPhysicalCpuCores()); + } + + void InitThreadPool() { boost::uint32_t systemCores = Threading::GetAvailableCoresMask(); boost::uint32_t mainAffinity = systemCores; - boost::uint32_t ompAvailCores = systemCores & ~mainAffinity; #ifndef UNIT_TEST - mainAffinity = systemCores & configHandler->GetUnsigned("SetCoreAffinity"); + mainAffinity &= configHandler->GetUnsigned("SetCoreAffinity"); #endif + boost::uint32_t ompAvailCores = systemCores & ~mainAffinity; { int workerCount = -1; @@ -237,10 +275,23 @@ workerCount = configHandler->GetUnsigned("WorkerThreadCount"); ThreadPool::SetThreadSpinTime(configHandler->GetUnsigned("WorkerThreadSpinTime")); #endif + const int numCores = ThreadPool::GetMaxThreads(); + // For latency reasons our worker threads yield rarely and so eat a lot cputime with idleing. // So it's better we always leave 1 core free for our other threads, drivers & OS - if (workerCount < 0) workerCount = ThreadPool::GetMaxThreads() - 1; - //if (workerCount > ThreadPool::GetMaxThreads()) LOG_L(L_WARNING, ""); + if (workerCount < 0) { + if (numCores == 2) { + workerCount = numCores; + } else if (numCores < 6) { + workerCount = numCores - 1; + } else { + workerCount = numCores / 2; + } + } + if (workerCount > numCores) { + LOG_L(L_WARNING, "Set ThreadPool workers to %i, but there are just %i cores!", workerCount, numCores); + workerCount = numCores; + } ThreadPool::SetThreadCount(workerCount); } @@ -249,13 +300,15 @@ boost::uint32_t ompCores = 0; ompCores = parallel_reduce([&]() -> boost::uint32_t { const int i = ThreadPool::GetThreadNum(); - if (i != 0) { - // 0 is the source thread, skip - boost::uint32_t ompCore = GetCpuCoreForWorkerThread(i - 1, ompAvailCores, mainAffinity); - Threading::SetAffinity(ompCore); - return ompCore; - } - return 0; + + // 0 is the source thread, skip + if (i == 0) + return 0; + + boost::uint32_t ompCore = GetCpuCoreForWorkerThread(i - 1, ompAvailCores, mainAffinity); + //boost::uint32_t ompCore = ompAvailCores; + Threading::SetAffinity(ompCore); + return ompCore; }, [](boost::uint32_t a, boost::unique_future& b) -> boost::uint32_t { return a | b.get(); }); // affinity of mainthread @@ -274,20 +327,18 @@ //Note: only available with mingw64!!! #else - if (!GML::Enabled()) { // with GML mainthread yields a lot, so SCHED_BATCH with its longer wakup times is counter-productive then - if (GetAvailableCores() > 1) { - // Change os scheduler for this process. - // This way the kernel knows that we are a CPU-intensive task - // and won't randomly move us across the cores and tries - // to maximize the runtime (_slower_ wakeups, less yields) - //Note: - // It _may_ be possible that this has negative impact in case - // threads are waiting for mutexes (-> less yields). - int policy; - struct sched_param param; - pthread_getschedparam(Threading::GetCurrentThread(), &policy, ¶m); - pthread_setschedparam(Threading::GetCurrentThread(), SCHED_BATCH, ¶m); - } + if (GetLogicalCpuCores() > 1) { + // Change os scheduler for this process. + // This way the kernel knows that we are a CPU-intensive task + // and won't randomly move us across the cores and tries + // to maximize the runtime (_slower_ wakeups, less yields) + //Note: + // It _may_ be possible that this has negative impact in case + // threads are waiting for mutexes (-> less yields). + int policy; + struct sched_param param; + pthread_getschedparam(Threading::GetCurrentThread(), &policy, ¶m); + pthread_setschedparam(Threading::GetCurrentThread(), SCHED_BATCH, ¶m); } #endif } @@ -382,15 +433,6 @@ bool IsSimThread() { return ((!simThreadID)? false : NativeThreadIdsEqual(Threading::GetCurrentThreadId(), *simThreadID)); } - bool UpdateGameController(CGameController* ac) { - GML_MSTMUTEX_LOCK(sim, 1); // UpdateGameController - - SetSimThread(true); - bool ret = ac->Update(); - SetSimThread(false); - return ret; - } - void SetLuaBatchThread(bool set) { if (set) { luaBatchThreadID = Threading::GetCurrentThreadId(); @@ -402,7 +444,6 @@ return ((!luaBatchThreadID)? false : NativeThreadIdsEqual(Threading::GetCurrentThreadId(), *luaBatchThreadID)); } - void SetThreadName(const std::string& newname) { #if defined(__USE_GNU) && !defined(WIN32) @@ -421,4 +462,4 @@ { return threadError; } -}; +} diff -Nru spring-96.0~14.04~ppa4/rts/System/Platform/Threading.h spring-98.0~14.04~ppa6/rts/System/Platform/Threading.h --- spring-96.0~14.04~ppa4/rts/System/Platform/Threading.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Platform/Threading.h 2014-10-07 20:09:51.000000000 +0000 @@ -17,6 +17,7 @@ class CGameController; + namespace Threading { /** * Generic types & functions to handle OS native threads @@ -42,11 +43,17 @@ * want to run. Note that this approach will fail when N > 32. */ void DetectCores(); + boost::uint32_t GetAffinity(); boost::uint32_t SetAffinity(boost::uint32_t cores_bitmask, bool hard = true); void SetAffinityHelper(const char* threadName, boost::uint32_t affinity); - int GetAvailableCores(); boost::uint32_t GetAvailableCoresMask(); + /** + * returns count of cpu cores/ hyperthreadings cores + */ + int GetPhysicalCpuCores(); /// physical cores only (excluding hyperthreading) + int GetLogicalCpuCores(); /// physical + hyperthreading + bool HasHyperThreading(); /** * threadpool related stuff @@ -79,8 +86,6 @@ void SetSimThread(bool set); bool IsSimThread(); - bool UpdateGameController(CGameController* ac); - void SetLuaBatchThread(bool set); bool IsLuaBatchThread(); @@ -109,7 +114,8 @@ * A 64bit atomic counter */ struct AtomicCounterInt64; -}; +} + // // Inlined Definitions diff -Nru spring-96.0~14.04~ppa4/rts/System/Platform/Watchdog.cpp spring-98.0~14.04~ppa6/rts/System/Platform/Watchdog.cpp --- spring-96.0~14.04~ppa4/rts/System/Platform/Watchdog.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Platform/Watchdog.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,8 +2,6 @@ #include "Watchdog.h" -#include "lib/gml/gml_base.h" - #ifdef USE_VALGRIND #include #endif @@ -109,8 +107,6 @@ if (spring_istime(curwdt) && (curtime - curwdt) > hangTimeout) { if (!hangDetected) { LOG_L(L_WARNING, "[Watchdog] Hang detection triggered for Spring %s.", SpringVersion::GetFull().c_str()); - if (GML::Enabled()) - LOG_L(L_WARNING, "MT with %d threads.", GML::ThreadCount()); } LOG_L(L_WARNING, " (in thread: %s)", threadNames[i]); diff -Nru spring-96.0~14.04~ppa4/rts/System/Platform/Win/CrashHandler.cpp spring-98.0~14.04~ppa6/rts/System/Platform/Win/CrashHandler.cpp --- spring-96.0~14.04~ppa4/rts/System/Platform/Win/CrashHandler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Platform/Win/CrashHandler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -1,6 +1,5 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ -#include "lib/gml/gml_base.h" #include #include #include @@ -318,8 +317,6 @@ void OutputStacktrace() { LOG_L(L_ERROR, "Error handler invoked for Spring %s.", (SpringVersion::GetFull()).c_str()); - if (GML::Enabled()) - LOG_L(L_ERROR, "MT with %d threads.", GML::ThreadCount()); PrepareStacktrace(); @@ -342,9 +339,6 @@ // Prologue. logSinkHandler.SetSinking(false); LOG_L(L_ERROR, "Spring %s has crashed.", (SpringVersion::GetFull()).c_str()); - if (GML::Enabled()) - LOG_L(L_ERROR, "MT with %d threads.", GML::ThreadCount()); - PrepareStacktrace(); const std::string error(ExceptionName(e->ExceptionRecord->ExceptionCode)); diff -Nru spring-96.0~14.04~ppa4/rts/System/Platform/Win/WindowManagerHelper.cpp spring-98.0~14.04~ppa6/rts/System/Platform/Win/WindowManagerHelper.cpp --- spring-96.0~14.04~ppa4/rts/System/Platform/Win/WindowManagerHelper.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Platform/Win/WindowManagerHelper.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,52 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include "System/Platform/WindowManagerHelper.h" +#include "Rendering/GlobalRendering.h" +#include +#include + + +namespace WindowManagerHelper { + +void BlockCompositing(SDL_Window* window) +{ +#ifndef HEADLESS + // only available in WinVista+ + HMODULE dwmapiDllHandle = LoadLibrary("dwmapi.dll"); + + if (dwmapiDllHandle != nullptr) { + typedef HRESULT (*DwmEnableCompositionFunction)(UINT uCompositionAction); + auto DwmEnableComposition = (DwmEnableCompositionFunction) ::GetProcAddress(dwmapiDllHandle, "DwmEnableComposition"); + if (DwmEnableComposition != nullptr) { + static const unsigned int DWM_EC_DISABLECOMPOSITION = 0U; + DwmEnableComposition(DWM_EC_DISABLECOMPOSITION); + } + + FreeLibrary(dwmapiDllHandle); + } +#endif +} + + +int GetWindowState(SDL_Window* window) +{ + int state = 0; +#ifndef HEADLESS + WINDOWPLACEMENT wp; + wp.length = sizeof(WINDOWPLACEMENT); + + struct SDL_SysWMinfo info; + SDL_VERSION(&info.version); + SDL_GetWindowWMInfo(globalRendering->window, &info); + + if (GetWindowPlacement(info.info.win.window, &wp)) { + if (wp.showCmd == SW_SHOWMAXIMIZED) + state = SDL_WINDOW_MAXIMIZED; + if (wp.showCmd == SW_SHOWMINIMIZED) + state = SDL_WINDOW_MINIMIZED; + } +#endif + return state; +} + +}; // namespace WindowManagerHelper diff -Nru spring-96.0~14.04~ppa4/rts/System/Platform/Win/wsdl.cpp spring-98.0~14.04~ppa6/rts/System/Platform/Win/wsdl.cpp --- spring-96.0~14.04~ppa4/rts/System/Platform/Win/wsdl.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Platform/Win/wsdl.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,337 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -/* Copyright (C) 2009 Wildfire Games. - * This file is part of 0 A.D. - * - * 0 A.D. 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 2 of the License, or - * (at your option) any later version. - * - * 0 A.D. 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 0 A.D. If not, see . - */ - -/* - * emulate SDL on Windows. - */ - -#include "Rendering/GlobalRendering.h" -#include -#include "wsdl.h" -#include -#include - -namespace wsdl -{ - -static HWND g_hWnd = (HWND)INVALID_HANDLE_VALUE; -static int outstanding_press_events = 0; - -void ResetMouseButtons() { - outstanding_press_events = 0; -} - - -static void queue_event(SDL_Event& ev) -{ - ::SDL_PushEvent(&ev); -} - -//---------------------------------------------------------------------------- -// app activation - -enum SdlActivationType { LOSE = 0, GAIN = 1 }; - -static inline void queue_active_event(SdlActivationType type, size_t changed_app_state) -{ - // SDL says this event is not generated when the window is created, - // but skipping the first event may confuse things. - - SDL_Event ev; - ev.type = SDL_ACTIVEEVENT; - ev.active.state = (uint8_t)changed_app_state; - ev.active.gain = (uint8_t)((type == GAIN)? 1 : 0); - queue_event(ev); -} - - -// SDL_APP* bitflags indicating whether we are active. -// note: responsibility for yielding lies with SDL apps - -// they control the main loop. -static Uint8 app_state; - -void active_change_state(SdlActivationType type, Uint8 changed_app_state) -{ - Uint8 old_app_state = app_state; - - if(type == GAIN) - app_state = Uint8(app_state | changed_app_state); - else - app_state = Uint8(app_state & ~changed_app_state); - - // generate an event - but only if the given state flags actually changed. - if((old_app_state & changed_app_state) != (app_state & changed_app_state)) - queue_active_event(type, changed_app_state); -} - -LRESULT OnActivate(HWND hWnd, UINT state, HWND hWndActDeact, BOOL fMinimized) -{ - SdlActivationType type; - Uint8 changed_app_state; - - // went active and not minimized - if(state != WA_INACTIVE && !fMinimized) - { - type = GAIN; - changed_app_state = SDL_APPINPUTFOCUS|SDL_APPACTIVE; - - } - // deactivated (Alt+Tab out) or minimized - else - { - type = LOSE; - changed_app_state = SDL_APPINPUTFOCUS; - if(fMinimized) - changed_app_state |= SDL_APPACTIVE; - } - - active_change_state(type, changed_app_state); - return 0; -} - - -Uint8 SDL_GetAppState() -{ - Uint8 sdl_app_state = ::SDL_GetAppState(); - sdl_app_state &= ~(SDL_APPACTIVE | SDL_APPINPUTFOCUS); // we handle those ourself - return sdl_app_state | app_state; -} - - -//---------------------------------------------------------------------------- -// mouse - -// background: there are several types of coordinates. -// - screen coords are relative to the primary desktop and may therefore be -// negative on multi-monitor systems (e.g. if secondary monitor is left of -// primary). they are prefixed with screen_*. -// - "client" coords are simply relative to the parent window's origin and -// can also be negative (e.g. in the window's NC area). -// these are prefixed with client_*. -// - "idealized" coords are what the app sees. these range from 0 to -// windowDimensions-1. they are returned by GetCoords and have no prefix. - -void queue_mouse_event(int x, int y, int relx, int rely) -{ - SDL_Event ev; - ev.type = SDL_MOUSEMOTION; - ev.motion.x = (Uint16)x; - ev.motion.y = (Uint16)y; - ev.motion.xrel = (Sint16)relx; - ev.motion.yrel = (Sint16)rely; - queue_event(ev); -} - -void queue_button_event(int button, int state, int x, int y) -{ - SDL_Event ev; - ev.type = Uint8((state == SDL_PRESSED)? SDL_MOUSEBUTTONDOWN : SDL_MOUSEBUTTONUP); - ev.button.button = (uint8_t)button; - ev.button.state = (uint8_t)state; - ev.button.x = (Uint16)x; - ev.button.y = (Uint16)y; - queue_event(ev); -} - - -static int mouse_x, mouse_y; - -// generate a mouse move message and update our notion of the mouse position. -// x, y are client pixel coordinates. -// notes: -// - does not actually move the OS cursor; -// - called from mouse_update and SDL_WarpMouse. -static void mouse_moved(int x, int y) -{ - // nothing to do if it hasn't changed since last time - if(mouse_x == x && mouse_y == y) - return; - - queue_mouse_event(x, y, x-mouse_x, y-mouse_y); - mouse_x = x; - mouse_y = y; -} - -static POINT ScreenFromClient(int client_x, int client_y) -{ - POINT screen_pt; - screen_pt.x = (LONG)client_x; - screen_pt.y = (LONG)client_y; - ClientToScreen(g_hWnd, &screen_pt); - return screen_pt; -} - -// get idealized client coordinates or return false if outside our window. -static bool GetCoords(int screen_x, int screen_y, int& x, int& y) -{ - POINT screen_pt; - screen_pt.x = (LONG)screen_x; - screen_pt.y = (LONG)screen_y; - - POINT client_pt; - { - SetLastError(0); - client_pt = screen_pt; // translated below - MapWindowPoints(HWND_DESKTOP, g_hWnd, &client_pt, 1); - } - - { - RECT client_rect; - GetClientRect(g_hWnd, &client_rect); - if(!PtInRect(&client_rect, client_pt)) - return false; - } - - /* causes bigslowdown - if(WindowFromPoint(screen_pt) != g_hWnd) - return false;*/ - - x = client_pt.x; - y = client_pt.y; - return true; -} - - -// (we define a new function signature since the windowsx.h message crackers -// don't provide for passing uMsg) -LRESULT OnMouseButton(HWND hWnd, UINT uMsg, int client_x, int client_y, UINT flags) -{ - int button; - int state; - switch(uMsg) - { - case WM_LBUTTONDOWN: - button = SDL_BUTTON_LEFT; - state = SDL_PRESSED; - break; - case WM_LBUTTONUP: - button = SDL_BUTTON_LEFT; - state = SDL_RELEASED; - break; - case WM_RBUTTONDOWN: - button = SDL_BUTTON_RIGHT; - state = SDL_PRESSED; - break; - case WM_RBUTTONUP: - button = SDL_BUTTON_RIGHT; - state = SDL_RELEASED; - break; - case WM_MBUTTONDOWN: - button = SDL_BUTTON_MIDDLE; - state = SDL_PRESSED; - break; - case WM_MBUTTONUP: - button = SDL_BUTTON_MIDDLE; - state = SDL_RELEASED; - break; - default: - return 0; - } - - //! mouse capture - if (!globalRendering->fullScreen) { - const POINT screen_pt = ScreenFromClient(client_x, client_y); - - static SDL_GrabMode oldMode; - static bool saveMode = false; - if(state == SDL_PRESSED) { - //! grab mouse to ensure we get up events - if(++outstanding_press_events > 0) - { - if (!saveMode) - { - oldMode = SDL_WM_GrabInput(SDL_GRAB_QUERY); - saveMode = true; - } - - POINT pt; - GetCursorPos(&pt); //! SDL_WM_GrabInput sometimes moves the cursor, so we have to reset it afterwards - SDL_WM_GrabInput(SDL_GRAB_ON); - SetCursorPos(pt.x, pt.y); - } - } else { - //! release after all up events received - if(--outstanding_press_events <= 0) - { - if (saveMode) - { - POINT pt; - GetCursorPos(&pt); //! SDL_WM_GrabInput sometimes moves the cursor, so we have to reset it afterwards - SDL_WM_GrabInput(oldMode); - SetCursorPos(pt.x, pt.y); - saveMode = false; - } - outstanding_press_events = 0; - } - } - - //! only queue clicks inside of the window - int x, y; - if(GetCoords(screen_pt.x, screen_pt.y, x, y)) - queue_button_event(button, state, x, y); - } else { - //! no outside checking needed for full-screen - queue_button_event(button, state, client_x, client_y); - } - - - return 0; -} - -// (note: this message is sent even if the cursor is outside our window) -LRESULT OnMouseWheel(HWND hWnd, int screen_x, int screen_y, int zDelta, UINT fwKeys) -{ - int x, y; - if(GetCoords(screen_x, screen_y, x, y)) - { - int button = (zDelta < 0)? SDL_BUTTON_WHEELDOWN : SDL_BUTTON_WHEELUP; - // SDL says this sends a down message followed by up. - queue_button_event(button, SDL_PRESSED, x, y); - queue_button_event(button, SDL_RELEASED, x, y); - } - - return 0; // handled -} - - -LRESULT OnMouseMotion(HWND hWnd, int x, int y, UINT flags) -{ - mouse_moved(x, y); - return 0; -} - - -void SDL_WarpMouse(int x, int y) -{ - const int client_x = x, client_y = y; - const POINT screen_pt = ScreenFromClient(client_x, client_y); - SetCursorPos(screen_pt.x, screen_pt.y); - mouse_x = x; - mouse_y = y; -} - - -//---------------------------------------------------------------------------- -// Framework initialization - -void Init(HWND hWnd) -{ - g_hWnd = hWnd; -} -} diff -Nru spring-96.0~14.04~ppa4/rts/System/Platform/Win/wsdl.h spring-98.0~14.04~ppa6/rts/System/Platform/Win/wsdl.h --- spring-96.0~14.04~ppa4/rts/System/Platform/Win/wsdl.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Platform/Win/wsdl.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -/* Copyright (C) 2009 Wildfire Games. - * This file is part of 0 A.D. - * - * 0 A.D. 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 2 of the License, or - * (at your option) any later version. - * - * 0 A.D. 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 0 A.D. If not, see . - */ - -/* - * emulate SDL on Windows. - */ - -#ifndef INCLUDED_WSDL -#define INCLUDED_WSDL - -#ifdef WIN32 - -#include - -#include "SDL_events.h" - -namespace wsdl -{ -void ResetMouseButtons(); -void Init(HWND hWnd); // set on startup -void SDL_WarpMouse(int x, int y); -LRESULT OnActivate(HWND hWnd, UINT state, HWND hWndActDeact, BOOL fMinimized); -LRESULT OnMouseMotion(HWND hWnd, int x, int y, UINT flags); -LRESULT OnMouseButton(HWND hWnd, UINT uMsg, int client_x, int client_y, UINT flags); -LRESULT OnMouseWheel(HWND hWnd, int screen_x, int screen_y, int zDelta, UINT fwKeys); -} - -#endif // WIN32 - -#endif // #ifndef INCLUDED_WSDL diff -Nru spring-96.0~14.04~ppa4/rts/System/Platform/WindowManagerHelper.cpp spring-98.0~14.04~ppa6/rts/System/Platform/WindowManagerHelper.cpp --- spring-96.0~14.04~ppa4/rts/System/Platform/WindowManagerHelper.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Platform/WindowManagerHelper.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -5,25 +5,28 @@ #include #include +#include "Rendering/GlobalRendering.h" #include "Rendering/Textures/Bitmap.h" #include "System/Log/ILog.h" #include "Game/GameVersion.h" -SDL_Surface* WindowManagerHelper::currentIcon = NULL; +namespace WindowManagerHelper { -void WindowManagerHelper::SetIcon(const CBitmap* icon) { +static SDL_Surface* currentIcon = nullptr; + +void SetIcon(const CBitmap* icon) { if (SpringVersion::IsHeadless()) return; if (icon != NULL) { // 24bit RGB or 32bit RGBA if (((icon->channels != 3) && (icon->channels != 4)) -#ifdef WIN32 +//#ifdef WIN32 // on windows, the icon has to be 32x32 || (icon->xsize != 32) || (icon->ysize != 32) -#endif // WIN32 +//#endif ) { LOG_L(L_WARNING, "window-manager icon: Trying to set a window-manager icon with the wrong format."); LOG_L(L_WARNING, "window-manager icon: It has to be 24bit or 32bit, and on windows it additionally has to be 32x32 pixels."); @@ -33,7 +36,7 @@ if (newIcon == NULL) { LOG_L(L_WARNING, "window-manager icon: Failed to create SDL surface, reason: %s", SDL_GetError()); } else { - SDL_WM_SetIcon(newIcon, NULL); + SDL_SetWindowIcon(globalRendering->window, newIcon); if (currentIcon != NULL) { // release the old icon unsigned char* pixelData = (unsigned char*) currentIcon->pixels; @@ -47,8 +50,11 @@ } } -void WindowManagerHelper::FreeIcon() { - SDL_WM_SetIcon(NULL, NULL); + +void FreeIcon() { + if (globalRendering != NULL) + SDL_SetWindowIcon(globalRendering->window, NULL); + if (currentIcon != NULL) { // release the old icon unsigned char* pixelData = (unsigned char*) currentIcon->pixels; @@ -58,14 +64,9 @@ } } -void WindowManagerHelper::SetCaption(const std::string& title, const std::string& titleShort) { - // titleShort may only ever be used under X11, but not QT(KDE) or Windows - // for more details, see: - // http://www.gpwiki.org/index.php/SDL:Tutorials:Initializing_SDL_Libraries#About_the_icon_.28.22Icon_Title.22.29_parameter_on_different_window-managers - SDL_WM_SetCaption(title.c_str(), titleShort.c_str()); +void SetCaption(const std::string& title) { + SDL_SetWindowTitle(globalRendering->window, title.c_str()); } -void WindowManagerHelper::SetCaption(const std::string& title) { - SetCaption(title, title); -} +}; // namespace WindowManagerHelper diff -Nru spring-96.0~14.04~ppa4/rts/System/Platform/WindowManagerHelper.h spring-98.0~14.04~ppa6/rts/System/Platform/WindowManagerHelper.h --- spring-96.0~14.04~ppa4/rts/System/Platform/WindowManagerHelper.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Platform/WindowManagerHelper.h 2014-10-07 20:09:51.000000000 +0000 @@ -6,10 +6,9 @@ #include class CBitmap; -struct SDL_Surface; +struct SDL_Window; -struct WindowManagerHelper { -public: +namespace WindowManagerHelper { /** * Sets the window-manager icon for the running process. * It will be displayed in the OS task-bar, for example. @@ -19,31 +18,28 @@ * @see SDL_WM_SetIcon() * Note: Must be called before the first call to SDL_SetVideoMode. */ - static void SetIcon(const CBitmap* icon); - static void FreeIcon(); + void SetIcon(const CBitmap* icon); + void FreeIcon(); /** - * Sets the window-manager captions/titles for the running process. - * @param title will be displayed in the window title (in windowed mode) - * example: "MyGame 1.0 - Chicken Mode (Spring 0.83.0.1)" - * @param titleShort will be displayed in the OS task-bar - * example: "MyGame" - * This may only ever be used under X11, but not QT(KDE) or Windows. - * @see SDL_WM_SetCaption() - */ - static void SetCaption(const std::string& title, - const std::string& titleShort); - /** * Sets the window-manager caption/title for the running process. * @param title will be displayed in the window title (in windowed mode) * and in the OS task-bar * example: "MyGame" * @see #SetCaption(const std::string&, const std::string&) */ - static void SetCaption(const std::string& title); + void SetCaption(const std::string& title); + + + /** + * @brief disables desktop compositing (kwin, aero, compiz, ...) to fix tearing & vsync problems + */ + void BlockCompositing(SDL_Window* window); -private: - static SDL_Surface* currentIcon; + /** + * @brief returns the window-state of the given window in SDL_GetWindowFlags() format + */ + int GetWindowState(SDL_Window* window); }; #endif // WINDOW_MANAGER_HELPER_H diff -Nru spring-96.0~14.04~ppa4/rts/System/Rectangle.cpp spring-98.0~14.04~ppa6/rts/System/Rectangle.cpp --- spring-96.0~14.04~ppa4/rts/System/Rectangle.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Rectangle.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,10 +2,10 @@ #include "Rectangle.h" -CR_BIND(SRectangle, ); +CR_BIND(SRectangle, ) CR_REG_METADATA(SRectangle, ( CR_MEMBER(x1), CR_MEMBER(y1), CR_MEMBER(x2), CR_MEMBER(y2) -)); +)) diff -Nru spring-96.0~14.04~ppa4/rts/System/Rectangle.h spring-98.0~14.04~ppa6/rts/System/Rectangle.h --- spring-96.0~14.04~ppa4/rts/System/Rectangle.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Rectangle.h 2014-10-07 20:09:51.000000000 +0000 @@ -8,7 +8,7 @@ #include "System/creg/creg_cond.h" struct SRectangle { - CR_DECLARE_STRUCT(SRectangle); + CR_DECLARE_STRUCT(SRectangle) SRectangle() : x1(0) @@ -27,6 +27,13 @@ int GetHeight() const { return z2 - z1; } int GetArea() const { return (GetWidth() * GetHeight()); } + bool Inside(const int2 pos) const { + // note: *min inclusive, *max exclusive + const bool xb = (pos.x >= x1 && pos.x < x2); + const bool yb = (pos.y >= y1 && pos.y < y2); + return (xb && yb); + } + void ClampPos(int2* pos) const { pos->x = Clamp(pos->x, x1, x2); pos->y = Clamp(pos->y, y1, y2); @@ -61,15 +68,23 @@ ); } - int x1; + union { + int x1; + int left; + }; union { int z1; int y1; + int top; + }; + union { + int x2; + int right; }; - int x2; union { int z2; int y2; + int bottom; }; }; diff -Nru spring-96.0~14.04~ppa4/rts/System/SafeCStrings.h spring-98.0~14.04~ppa6/rts/System/SafeCStrings.h --- spring-96.0~14.04~ppa4/rts/System/SafeCStrings.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/SafeCStrings.h 2014-10-07 20:09:51.000000000 +0000 @@ -28,7 +28,7 @@ ///@} #ifdef __cplusplus -} // extern "C" +} /* extern "C" */ #endif -#endif // SAFE_C_STRINGS_H +#endif /* SAFE_C_STRINGS_H */ diff -Nru spring-96.0~14.04~ppa4/rts/System/SafeVector.cpp spring-98.0~14.04~ppa6/rts/System/SafeVector.cpp --- spring-96.0~14.04~ppa4/rts/System/SafeVector.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/SafeVector.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,7 @@ #include "System/Platform/CrashHandler.h" #include "System/maindefines.h" -CR_BIND_TEMPLATE(safe_vector, ); +CR_BIND_TEMPLATE(safe_vector, ) template <> const float& safe_vector::safe_element(size_type idx) const { static const float def = 0.0f; diff -Nru spring-96.0~14.04~ppa4/rts/System/SafeVector.h spring-98.0~14.04~ppa6/rts/System/SafeVector.h --- spring-96.0~14.04~ppa4/rts/System/SafeVector.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/SafeVector.h 2014-10-07 20:09:51.000000000 +0000 @@ -13,7 +13,7 @@ template class safe_vector : public std::vector { - CR_DECLARE_STRUCT(safe_vector); + CR_DECLARE_STRUCT(safe_vector) public: typedef typename std::vector::size_type size_type; diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/ALShared.cpp spring-98.0~14.04~ppa6/rts/System/Sound/ALShared.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/ALShared.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/ALShared.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#include "ALShared.h" - -#include "SoundLog.h" - -#include - - -bool CheckError(const char* msg) -{ - ALenum e = alGetError(); - const bool hasError = (e != AL_NO_ERROR); - if (hasError) { - char* alerr = (char*)alGetString(e); - LOG_L(L_ERROR, "%s: %s", - msg, ((alerr != NULL) ? alerr : "Unknown error")); - } - - return !hasError; -} diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/ALShared.h spring-98.0~14.04~ppa6/rts/System/Sound/ALShared.h --- spring-96.0~14.04~ppa4/rts/System/Sound/ALShared.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/ALShared.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#ifndef _AL_SHARED_H_ -#define _AL_SHARED_H_ - -#include - -bool CheckError(const char* msg); - -#endif // _AL_SHARED_H_ diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/AudioChannel.cpp spring-98.0~14.04~ppa6/rts/System/Sound/AudioChannel.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/AudioChannel.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/AudioChannel.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,235 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#include "AudioChannel.h" - -#include "ALShared.h" -#include "ISound.h" -#include "SoundItem.h" -#include "SoundLog.h" -#include "SoundSource.h" -#include "Sim/Misc/GuiSoundSet.h" -#include "Sim/Objects/WorldObject.h" - -#include - -extern boost::recursive_mutex soundMutex; - -const size_t AudioChannel::MAX_STREAM_QUEUESIZE = 10; - - -AudioChannel::AudioChannel() - : curStreamSrc(NULL) -{ -} - - -void AudioChannel::SetVolume(float newVolume) -{ - volume = std::max(newVolume, 0.f); - - if (cur_sources.empty()) - return; - - boost::recursive_mutex::scoped_lock lck(soundMutex); - - for (std::map::iterator it = cur_sources.begin(); it != cur_sources.end(); ++it) { - it->first->UpdateVolume(); - } - CheckError("AudioChannel::SetVolume"); -} - - -void AudioChannel::Enable(bool newState) -{ - boost::recursive_mutex::scoped_lock lck(soundMutex); - - enabled = newState; - - if (!enabled) { - SetVolume(0.f); - } -} - - -void AudioChannel::SoundSourceFinished(CSoundSource* sndSource) -{ - if (curStreamSrc == sndSource) { - if (!streamQueue.empty()) { - StreamQueueItem& next = streamQueue.back(); - StreamPlay(next.fileName, next.volume, false); - streamQueue.pop_back(); - } else { - curStreamSrc = NULL; - } - } - - cur_sources.erase(sndSource); -} - - -void AudioChannel::FindSourceAndPlay(size_t id, const float3& pos, const float3& velocity, float volume, bool relative) -{ - boost::recursive_mutex::scoped_lock lck(soundMutex); - - if (!enabled) - return; - - if (volume <= 0.0f) - return; - - SoundItem* sndItem = sound->GetSoundItem(id); - if (!sndItem) { - sound->numEmptyPlayRequests++; - return; - } - - if (pos.distance(sound->GetListenerPos()) > sndItem->MaxDistance()) { - if (!relative) { - return; - } else { - LOG("CSound::PlaySample: maxdist ignored for relative playback: %s", - sndItem->Name().c_str()); - } - } - - if (emmitsThisFrame >= emmitsPerFrame) - return; - emmitsThisFrame++; - - if (cur_sources.size() >= maxConcurrentSources) { - CSoundSource* src = NULL; - int prio = INT_MAX; - for (std::map::iterator it = cur_sources.begin(); it != cur_sources.end(); ++it) { - if (it->first->GetCurrentPriority() < prio) { - src = it->first; - prio = it->first->GetCurrentPriority(); - } - } - - if (src && prio <= sndItem->GetPriority()) { - src->Stop(); - } else { - LOG_L(L_DEBUG, "CSound::PlaySample: Max concurrent sounds in channel reached! Dropping playback!"); - return; - } - } - - CSoundSource* sndSource = sound->GetNextBestSource(); - if (!sndSource) { - LOG_L(L_DEBUG, "CSound::PlaySample: Max sounds reached! Dropping playback!"); - return; - } - - if (sndSource->GetCurrentPriority() < sndItem->GetPriority()) { - if (sndSource->IsPlaying()) - sound->numAbortedPlays++; - - sndSource->Play(this, sndItem, pos, velocity, volume, relative); - CheckError("CSound::FindSourceAndPlay"); - - cur_sources[sndSource] = true; - } -} - -void AudioChannel::PlaySample(size_t id, float volume) -{ - FindSourceAndPlay(id, -FwdVector, ZeroVector, volume, true); -} - -void AudioChannel::PlaySample(size_t id, const float3& pos, float volume) -{ - FindSourceAndPlay(id, pos, ZeroVector, volume, false); -} - -void AudioChannel::PlaySample(size_t id, const float3& pos, const float3& velocity, float volume) -{ - FindSourceAndPlay(id, pos, velocity, volume, false); -} - - -void AudioChannel::PlaySample(size_t id, const CWorldObject* obj, float volume) -{ - FindSourceAndPlay(id, obj->pos, obj->speed, volume, false); -} - - -void AudioChannel::PlayRandomSample(const GuiSoundSet& soundSet, const CWorldObject* obj) -{ - PlayRandomSample(soundSet, obj->pos); -} - -void AudioChannel::PlayRandomSample(const GuiSoundSet& soundSet, const float3& pos) -{ - const int soundIdx = soundSet.getRandomIdx(); - - if (soundIdx < 0) - return; - - const int soundID = soundSet.getID(soundIdx); - const float soundVol = soundSet.getVolume(soundIdx); - - PlaySample(soundID, pos, soundVol); -} - - -void AudioChannel::StreamPlay(const std::string& filepath, float volume, bool enqueue) -{ - boost::recursive_mutex::scoped_lock lck(soundMutex); - - if (!enabled) - return; - - if (curStreamSrc && enqueue) { - if (streamQueue.size() > MAX_STREAM_QUEUESIZE) { - streamQueue.resize(MAX_STREAM_QUEUESIZE); - streamQueue.pop_back(); //! make room for the new item - } - StreamQueueItem newItem(filepath, volume); - streamQueue.push_back(newItem); - return; - } - - if (!curStreamSrc) - curStreamSrc = sound->GetNextBestSource(); //! may return 0 if no sources available - - if (curStreamSrc) { - cur_sources[curStreamSrc] = true; //! This one first, PlayStream may invoke Stop immediately thus setting curStreamSrc to NULL - curStreamSrc->PlayStream(this, filepath, volume); - } -} - -void AudioChannel::StreamPause() -{ - boost::recursive_mutex::scoped_lock lck(soundMutex); - - if (curStreamSrc) - curStreamSrc->StreamPause(); -} - -void AudioChannel::StreamStop() -{ - boost::recursive_mutex::scoped_lock lck(soundMutex); - - if (curStreamSrc) - curStreamSrc->StreamStop(); -} - -float AudioChannel::StreamGetTime() -{ - boost::recursive_mutex::scoped_lock lck(soundMutex); - - if (curStreamSrc) - return curStreamSrc->GetStreamTime(); - else - return 0.0f; -} - -float AudioChannel::StreamGetPlayTime() -{ - boost::recursive_mutex::scoped_lock lck(soundMutex); - - if (curStreamSrc) - return curStreamSrc->GetStreamPlayTime(); - else - return 0.0f; -} diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/AudioChannel.h spring-98.0~14.04~ppa6/rts/System/Sound/AudioChannel.h --- spring-96.0~14.04~ppa4/rts/System/Sound/AudioChannel.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/AudioChannel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#ifndef AUDIO_CHANNEL_H -#define AUDIO_CHANNEL_H - -#include -#include -#include - -#include "IAudioChannel.h" -#include - -struct GuiSoundSet; -class CSoundSource; -class CWorldObject; - -/** - * @brief Channel for playing sounds - * - * Has its own volume "slider", and can be enabled / disabled seperately. - * Abstract base class. - */ -class AudioChannel : public IAudioChannel { -public: - AudioChannel(); - - void Enable(bool newState); - void SetVolume(float newVolume); - - void PlaySample(size_t id, float volume = 1.0f); - void PlaySample(size_t id, const float3& pos, float volume = 1.0f); - void PlaySample(size_t id, const float3& pos, const float3& velocity, float volume = 1.0f); - - void PlaySample(size_t id, const CWorldObject* obj, float volume = 1.0f); - - void PlayRandomSample(const GuiSoundSet& soundSet, const CWorldObject* obj); - void PlayRandomSample(const GuiSoundSet& soundSet, const float3& pos); - - void StreamPlay(const std::string& path, float volume = 1.0f, bool enqueue = false); - - /** - * @brief Stop playback - * - * Do not call this if you just want to play another file (for performance). - */ - void StreamStop(); - void StreamPause(); - float StreamGetTime(); - float StreamGetPlayTime(); - -protected: - void FindSourceAndPlay(size_t id, const float3& pos, const float3& velocity, float volume, bool relative); - - void SoundSourceFinished(CSoundSource* sndSource); - -private: - std::map cur_sources; - - //! streams - struct StreamQueueItem { - StreamQueueItem() : volume(0.f) {} - StreamQueueItem(const std::string& fileName, float& volume) - : fileName(fileName) - , volume(volume) - {} - std::string fileName; - float volume; - }; - - CSoundSource* curStreamSrc; - std::vector streamQueue; - static const size_t MAX_STREAM_QUEUESIZE; -}; - -#endif // AUDIO_CHANNEL_H diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/CMakeLists.txt spring-98.0~14.04~ppa6/rts/System/Sound/CMakeLists.txt --- spring-96.0~14.04~ppa4/rts/System/Sound/CMakeLists.txt 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/CMakeLists.txt 2014-10-07 20:09:51.000000000 +0000 @@ -6,8 +6,8 @@ SET(noSoundSources IAudioChannel.cpp ISound.cpp - SoundChannels.cpp - NullSound.cpp + Null/SoundChannels.cpp + Null/NullSound.cpp ) ADD_LIBRARY(no-sound STATIC EXCLUDE_FROM_ALL ${noSoundSources}) @@ -16,27 +16,30 @@ # Define default sound implementation if (NO_SOUND) - SetGlobal(sound-impl no-sound) + set(sound-impl no-sound PARENT_SCOPE) else (NO_SOUND) - SetGlobal(sound-impl sound) + set(sound-impl sound PARENT_SCOPE) endif (NO_SOUND) # Real Sound implementaiton if (NOT NO_SOUND) SET(soundSources - ${noSoundSources} - ALShared.cpp - EFX.cpp - EFXfuncs.cpp - EFXPresets.cpp - AudioChannel.cpp - OggStream.cpp - Sound.cpp - SoundBuffer.cpp - SoundItem.cpp - SoundSource.cpp - VorbisShared.cpp + ISound.cpp + IAudioChannel.cpp + Null/NullSound.cpp + OpenAL/ALShared.cpp + OpenAL/EFX.cpp + OpenAL/EFXfuncs.cpp + OpenAL/EFXPresets.cpp + OpenAL/AudioChannel.cpp + OpenAL/OggStream.cpp + OpenAL/Sound.cpp + OpenAL/SoundChannels.cpp + OpenAL/SoundBuffer.cpp + OpenAL/SoundItem.cpp + OpenAL/SoundSource.cpp + OpenAL/VorbisShared.cpp ) FIND_PACKAGE_STATIC(OpenAL REQUIRED) @@ -44,8 +47,8 @@ FIND_PACKAGE_STATIC(OggVorbis REQUIRED) INCLUDE_DIRECTORIES(${OGG_INCLUDE_DIR} ${VORBIS_INCLUDE_DIR}) - FIND_PACKAGE(SDL REQUIRED) - INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR}) + FIND_PACKAGE(SDL2 REQUIRED) + INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/AL) @@ -53,6 +56,6 @@ ADD_LIBRARY(sound STATIC EXCLUDE_FROM_ALL ${soundSources}) TARGET_LINK_LIBRARIES(sound ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_LIBRARY}) TARGET_LINK_LIBRARIES(sound ${OPENAL_LIBRARY}) - TARGET_LINK_LIBRARIES(sound ${SDL_LIBRARY}) + TARGET_LINK_LIBRARIES(sound ${SDL2_LIBRARY}) endif (NOT NO_SOUND) diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/EFX.cpp spring-98.0~14.04~ppa6/rts/System/Sound/EFX.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/EFX.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/EFX.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,279 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#include "EFX.h" - -#include "ALShared.h" -#include "EFXPresets.h" -#include "EFXfuncs.h" - -#include "SoundLog.h" -#include "System/Config/ConfigHandler.h" -#include "System/myMath.h" - - -/******************************************************************************/ -/******************************************************************************/ - -CONFIG(float, snd_airAbsorption).defaultValue(0.1f); -CONFIG(bool, UseEFX).defaultValue(true).safemodeValue(false); - -static std::string default_preset = "outdoors_valley";//"bathroom"; - -/******************************************************************************/ -/******************************************************************************/ - -CEFX* efx = NULL; -float CEFX::heightRolloffModifier = 1.f; - -CEFX::CEFX(ALCdevice* device) - :enabled(false) - ,supported(false) - ,sfxProperties(NULL) - ,sfxSlot(0) - ,sfxReverb(0) - ,sfxFilter(0) - ,updates(0) - ,maxSlots(0) - ,maxSlotsPerSource(0) -{ - SetAirAbsorptionFactor(configHandler->GetFloat("snd_airAbsorption")); - - bool hasExtension = alcIsExtensionPresent(device, "ALC_EXT_EFX"); - - if(hasExtension && alGenEffects && alDeleteEffects) - supported = true; - - //! set default preset - eaxPresets["default"] = eaxPresets[default_preset]; - - //! always allocate this - sfxProperties = new EAXSfxProps(); - *sfxProperties = eaxPresets[default_preset]; - - if (!supported) { - if(!hasExtension) - LOG(" EFX Supported: no"); - else - LOG(" EFX is supported but software does not seem to work properly"); - return; - } - - //! clear log - alGetError() ; - - //! Check Available Effects - { - static const ALuint effects[] = { - AL_EFFECT_REVERB, - AL_EFFECT_EAXREVERB, - AL_EFFECT_CHORUS, - AL_EFFECT_DISTORTION, - AL_EFFECT_ECHO, - AL_EFFECT_FLANGER, - AL_EFFECT_FREQUENCY_SHIFTER, - AL_EFFECT_VOCAL_MORPHER, - AL_EFFECT_PITCH_SHIFTER, - AL_EFFECT_RING_MODULATOR, - AL_EFFECT_AUTOWAH, - AL_EFFECT_COMPRESSOR, - AL_EFFECT_EQUALIZER - }; - - ALuint alFx; - alGenEffects(1, &alFx); - if (alGetError() == AL_NO_ERROR) { - for(size_t i = 0; i < sizeof(effects)/sizeof(effects[0]); i++) { - const ALuint fx = effects[i]; - alEffecti(alFx, AL_EFFECT_TYPE, fx); - effectsSupported[fx] = (alGetError() == AL_NO_ERROR); - } - } - alDeleteEffects(1, &alFx); - } - - //! Check Available Filters - { - static const ALuint filters[] = { - AL_FILTER_LOWPASS, - AL_FILTER_HIGHPASS, - AL_FILTER_BANDPASS - }; - - ALuint alFilter; - alGenFilters(1, &alFilter); - if (alGetError() == AL_NO_ERROR) { - for(size_t i = 0; i < sizeof(filters)/sizeof(filters[0]); i++) { - const ALuint filter = filters[i]; - alFilteri(alFilter, AL_FILTER_TYPE, filter); - filtersSupported[filter] = (alGetError() == AL_NO_ERROR); - } - } - alDeleteFilters(1, &alFilter); - } - - //! Check Max Available EffectSlots - { - int n; - ALuint alFXSlots[128]; - for (n = 0; n < 128; n++) { - alGenAuxiliaryEffectSlots(1, &alFXSlots[n]); - if (alGetError() != AL_NO_ERROR) - break; - } - maxSlots = n; - - alDeleteAuxiliaryEffectSlots(n, alFXSlots); - } - - //! Check Max AUX FX SLOTS Per Sound Source - alcGetIntegerv(device, ALC_MAX_AUXILIARY_SENDS, 1, (ALCint*)&maxSlotsPerSource); - - - //! Check requirements - if (!effectsSupported[AL_EFFECT_EAXREVERB] - || !filtersSupported[AL_FILTER_LOWPASS] - || (maxSlots<1) - || (maxSlotsPerSource<1) - ) { - if (enabled) { - LOG_L(L_WARNING, " EFX Supported: no"); - } - supported = false; - return; - } - - - //! Create our global sfx enviroment - alGenAuxiliaryEffectSlots(1, &sfxSlot); - alGenEffects(1, &sfxReverb); - alEffecti(sfxReverb, AL_EFFECT_TYPE, AL_EFFECT_EAXREVERB); - alGenFilters(1, &sfxFilter); - alFilteri(sfxFilter, AL_FILTER_TYPE, AL_FILTER_LOWPASS); - if (!alIsAuxiliaryEffectSlot(sfxSlot) || !alIsEffect(sfxReverb) || !alIsFilter(sfxFilter)) { - LOG_L(L_ERROR, " Initializing EFX failed!"); - alDeleteFilters(1, &sfxFilter); - alDeleteEffects(1, &sfxReverb); - alDeleteAuxiliaryEffectSlots(1, &sfxSlot); - supported = false; - return; - } - - - //! Load defaults - CommitEffects(); - if (!CheckError(" EFX")) { - LOG_L(L_ERROR, " Initializing EFX failed!"); - alAuxiliaryEffectSloti(sfxSlot, AL_EFFECTSLOT_EFFECT, AL_EFFECT_NULL); - alDeleteFilters(1, &sfxFilter); - alDeleteEffects(1, &sfxReverb); - alDeleteAuxiliaryEffectSlots(1, &sfxSlot); - supported = false; - return; - } - - //! User may disable it (performance reasons?) - enabled = configHandler->GetBool("UseEFX"); - LOG(" EFX Enabled: %s", (enabled ? "yes" : "no")); - if (enabled) { - LOG_L(L_DEBUG, " EFX MaxSlots: %i", maxSlots); - LOG_L(L_DEBUG, " EFX MaxSlotsPerSource: %i", maxSlotsPerSource); - } - - configHandler->NotifyOnChange(this); -} - - -CEFX::~CEFX() -{ - if (supported) { - alAuxiliaryEffectSloti(sfxSlot, AL_EFFECTSLOT_EFFECT, AL_EFFECT_NULL); - alDeleteFilters(1, &sfxFilter); - alDeleteEffects(1, &sfxReverb); - alDeleteAuxiliaryEffectSlots(1, &sfxSlot); - } - delete sfxProperties; -} - - -void CEFX::Enable() -{ - if (supported && !enabled) { - enabled = true; - CommitEffects(); - LOG("EAX enabled"); - } -} - - -void CEFX::Disable() -{ - if (enabled) { - enabled = false; - alAuxiliaryEffectSloti(sfxSlot, AL_EFFECTSLOT_EFFECT, AL_EFFECT_NULL); - LOG("EAX disabled"); - } -} - - -void CEFX::SetPreset(std::string name, bool verbose, bool commit) -{ - if (!supported) - return; - - - std::map::const_iterator it = eaxPresets.find(name); - if (it != eaxPresets.end()) { - *sfxProperties = it->second; - if (commit) - CommitEffects(); - if (verbose) - LOG("EAX Preset changed to: %s", name.c_str()); - } -} - - -void CEFX::SetHeightRolloffModifer(const float& mod) -{ - heightRolloffModifier = mod; - - if (!supported) - return; - - alEffectf(sfxReverb, AL_EAXREVERB_ROOM_ROLLOFF_FACTOR, sfxProperties->properties_f[AL_EAXREVERB_ROOM_ROLLOFF_FACTOR] * heightRolloffModifier); - alAuxiliaryEffectSloti(sfxSlot, AL_EFFECTSLOT_EFFECT, sfxReverb); -} - - -void CEFX::CommitEffects() -{ - if (!supported) - return; - - //! commit reverb properties - for (std::map::iterator it = sfxProperties->properties_f.begin(); it != sfxProperties->properties_f.end(); ++it) - alEffectf(sfxReverb, it->first, it->second); - for (std::map::iterator it = sfxProperties->properties_i.begin(); it != sfxProperties->properties_i.end(); ++it) - alEffecti(sfxReverb, it->first, it->second); - for (std::map::iterator it = sfxProperties->properties_v.begin(); it != sfxProperties->properties_v.end(); ++it) - alEffectfv(sfxReverb, it->first, (ALfloat*)&it->second[0]); - - alEffectf(sfxReverb, AL_EAXREVERB_ROOM_ROLLOFF_FACTOR, sfxProperties->properties_f[AL_EAXREVERB_ROOM_ROLLOFF_FACTOR] * heightRolloffModifier); - alAuxiliaryEffectSloti(sfxSlot, AL_EFFECTSLOT_EFFECT, sfxReverb); - - for (std::map::iterator it=sfxProperties->filter_properties_f.begin(); it != sfxProperties->filter_properties_f.end(); ++it) - alFilterf(sfxFilter, it->first, it->second); - - updates++; -} - -void CEFX::SetAirAbsorptionFactor(ALfloat value) -{ - airAbsorptionFactor = Clamp(value, AL_MIN_AIR_ABSORPTION_FACTOR, AL_MAX_AIR_ABSORPTION_FACTOR); -} - -void CEFX::ConfigNotify(const std::string& key, const std::string& value) -{ - if (key == "snd_airAbsorption") { - SetAirAbsorptionFactor(std::atof(value.c_str())); - } -} diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/EFXfuncs.cpp spring-98.0~14.04~ppa6/rts/System/Sound/EFXfuncs.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/EFXfuncs.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/EFXfuncs.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#include "EFXfuncs.h" -#include "System/Util.h" - - -LPALGENEFFECTS alGenEffects = NULL; -LPALDELETEEFFECTS alDeleteEffects = NULL; -LPALISEFFECT alIsEffect = NULL; -LPALEFFECTI alEffecti = NULL; -LPALEFFECTIV alEffectiv = NULL; -LPALEFFECTF alEffectf = NULL; -LPALEFFECTFV alEffectfv = NULL; -LPALGETEFFECTI alGetEffecti = NULL; -LPALGETEFFECTIV alGetEffectiv = NULL; -LPALGETEFFECTF alGetEffectf = NULL; -LPALGETEFFECTFV alGetEffectfv = NULL; -LPALGENFILTERS alGenFilters = NULL; -LPALDELETEFILTERS alDeleteFilters = NULL; -LPALISFILTER alIsFilter = NULL; -LPALFILTERI alFilteri = NULL; -LPALFILTERIV alFilteriv = NULL; -LPALFILTERF alFilterf = NULL; -LPALFILTERFV alFilterfv = NULL; -LPALGETFILTERI alGetFilteri = NULL; -LPALGETFILTERIV alGetFilteriv = NULL; -LPALGETFILTERF alGetFilterf = NULL; -LPALGETFILTERFV alGetFilterfv = NULL; -LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots = NULL; -LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots = NULL; -LPALISAUXILIARYEFFECTSLOT alIsAuxiliaryEffectSlot = NULL; -LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti = NULL; -LPALAUXILIARYEFFECTSLOTIV alAuxiliaryEffectSlotiv = NULL; -LPALAUXILIARYEFFECTSLOTF alAuxiliaryEffectSlotf = NULL; -LPALAUXILIARYEFFECTSLOTFV alAuxiliaryEffectSlotfv = NULL; -LPALGETAUXILIARYEFFECTSLOTI alGetAuxiliaryEffectSloti = NULL; -LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv = NULL; -LPALGETAUXILIARYEFFECTSLOTF alGetAuxiliaryEffectSlotf = NULL; -LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv = NULL; - - -static void InitEfxProcAddr() -{ - alGenEffects = (LPALGENEFFECTS)alGetProcAddress("alGenEffects"); - alDeleteEffects = (LPALDELETEEFFECTS)alGetProcAddress("alDeleteEffects"); - alIsEffect = (LPALISEFFECT)alGetProcAddress("alIsEffect"); - alEffecti = (LPALEFFECTI)alGetProcAddress("alEffecti"); - alEffectiv = (LPALEFFECTIV)alGetProcAddress("alEffectiv"); - alEffectf = (LPALEFFECTF)alGetProcAddress("alEffectf"); - alEffectfv = (LPALEFFECTFV)alGetProcAddress("alEffectfv"); - alGetEffecti = (LPALGETEFFECTI)alGetProcAddress("alGetEffecti"); - alGetEffectiv = (LPALGETEFFECTIV)alGetProcAddress("alGetEffectiv"); - alGetEffectf = (LPALGETEFFECTF)alGetProcAddress("alGetEffectf"); - alGetEffectfv = (LPALGETEFFECTFV)alGetProcAddress("alGetEffectfv"); - alGenFilters = (LPALGENFILTERS)alGetProcAddress("alGenFilters"); - alDeleteFilters = (LPALDELETEFILTERS)alGetProcAddress("alDeleteFilters"); - alIsFilter = (LPALISFILTER)alGetProcAddress("alIsFilter"); - alFilteri = (LPALFILTERI)alGetProcAddress("alFilteri"); - alFilteriv = (LPALFILTERIV)alGetProcAddress("alFilteriv"); - alFilterf = (LPALFILTERF)alGetProcAddress("alFilterf"); - alFilterfv = (LPALFILTERFV)alGetProcAddress("alFilterfv"); - alGetFilteri = (LPALGETFILTERI)alGetProcAddress("alGetFilteri"); - alGetFilteriv= (LPALGETFILTERIV)alGetProcAddress("alGetFilteriv"); - alGetFilterf = (LPALGETFILTERF)alGetProcAddress("alGetFilterf"); - alGetFilterfv= (LPALGETFILTERFV)alGetProcAddress("alGetFilterfv"); - alGenAuxiliaryEffectSlots = (LPALGENAUXILIARYEFFECTSLOTS)alGetProcAddress("alGenAuxiliaryEffectSlots"); - alDeleteAuxiliaryEffectSlots = (LPALDELETEAUXILIARYEFFECTSLOTS)alGetProcAddress("alDeleteAuxiliaryEffectSlots"); - alIsAuxiliaryEffectSlot = (LPALISAUXILIARYEFFECTSLOT)alGetProcAddress("alIsAuxiliaryEffectSlot"); - alAuxiliaryEffectSloti = (LPALAUXILIARYEFFECTSLOTI)alGetProcAddress("alAuxiliaryEffectSloti"); - alAuxiliaryEffectSlotiv = (LPALAUXILIARYEFFECTSLOTIV)alGetProcAddress("alAuxiliaryEffectSlotiv"); - alAuxiliaryEffectSlotf = (LPALAUXILIARYEFFECTSLOTF)alGetProcAddress("alAuxiliaryEffectSlotf"); - alAuxiliaryEffectSlotfv = (LPALAUXILIARYEFFECTSLOTFV)alGetProcAddress("alAuxiliaryEffectSlotfv"); - alGetAuxiliaryEffectSloti = (LPALGETAUXILIARYEFFECTSLOTI)alGetProcAddress("alGetAuxiliaryEffectSloti"); - alGetAuxiliaryEffectSlotiv = (LPALGETAUXILIARYEFFECTSLOTIV)alGetProcAddress("alGetAuxiliaryEffectSlotiv"); - alGetAuxiliaryEffectSlotf = (LPALGETAUXILIARYEFFECTSLOTF)alGetProcAddress("alGetAuxiliaryEffectSlotf"); - alGetAuxiliaryEffectSlotfv = (LPALGETAUXILIARYEFFECTSLOTFV)alGetProcAddress("alGetAuxiliaryEffectSlotfv"); -} - -DO_ONCE(InitEfxProcAddr) diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/EFXfuncs.h spring-98.0~14.04~ppa6/rts/System/Sound/EFXfuncs.h --- spring-96.0~14.04~ppa4/rts/System/Sound/EFXfuncs.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/EFXfuncs.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#ifndef _EFX_FUNCS_H_ -#define _EFX_FUNCS_H_ - -#include -#include - -//! EFX Function Pointers -extern LPALGENEFFECTS alGenEffects; -extern LPALDELETEEFFECTS alDeleteEffects; -extern LPALISEFFECT alIsEffect; -extern LPALEFFECTI alEffecti; -extern LPALEFFECTIV alEffectiv; -extern LPALEFFECTF alEffectf; -extern LPALEFFECTFV alEffectfv; -extern LPALGETEFFECTI alGetEffecti; -extern LPALGETEFFECTIV alGetEffectiv; -extern LPALGETEFFECTF alGetEffectf; -extern LPALGETEFFECTFV alGetEffectfv; -extern LPALGENFILTERS alGenFilters; -extern LPALDELETEFILTERS alDeleteFilters; -extern LPALISFILTER alIsFilter; -extern LPALFILTERI alFilteri; -extern LPALFILTERIV alFilteriv; -extern LPALFILTERF alFilterf; -extern LPALFILTERFV alFilterfv; -extern LPALGETFILTERI alGetFilteri; -extern LPALGETFILTERIV alGetFilteriv; -extern LPALGETFILTERF alGetFilterf; -extern LPALGETFILTERFV alGetFilterfv; -extern LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots; -extern LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots; -extern LPALISAUXILIARYEFFECTSLOT alIsAuxiliaryEffectSlot; -extern LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti; -extern LPALAUXILIARYEFFECTSLOTIV alAuxiliaryEffectSlotiv; -extern LPALAUXILIARYEFFECTSLOTF alAuxiliaryEffectSlotf; -extern LPALAUXILIARYEFFECTSLOTFV alAuxiliaryEffectSlotfv; -extern LPALGETAUXILIARYEFFECTSLOTI alGetAuxiliaryEffectSloti; -extern LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv; -extern LPALGETAUXILIARYEFFECTSLOTF alGetAuxiliaryEffectSlotf; -extern LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv; - -#endif //_EFX_FUNCS_H_ diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/EFX.h spring-98.0~14.04~ppa6/rts/System/Sound/EFX.h --- spring-96.0~14.04~ppa4/rts/System/Sound/EFX.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/EFX.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#ifndef _EFX_H_ -#define _EFX_H_ - -#include -#include -#include -#include -#include - -struct EAXSfxProps; - -/// Default sound effects system implementation -class CEFX -{ -public: - CEFX(ALCdevice* device); - ~CEFX(); - - void SetPreset(std::string name, bool verbose = true, bool commit = true); - void CommitEffects(); - - void Enable(); - void Disable(); - - void SetHeightRolloffModifer(const float& mod); - -public: - /// @see ConfigHandler::ConfigNotifyCallback - void ConfigNotify(const std::string& key, const std::string& value); - - void SetAirAbsorptionFactor(ALfloat value); - ALfloat GetAirAbsorptionFactor() const { return airAbsorptionFactor; } - - - bool enabled; - bool supported; - - EAXSfxProps* sfxProperties; - ALuint sfxSlot; - ALuint sfxReverb; - ALuint sfxFilter; -private: - ALfloat airAbsorptionFactor; -public: - - int updates; - -private: - //! reduce the rolloff when the camera is height above the ground (so we still hear something in tab mode or far zoom) - static float heightRolloffModifier; - -private: - //! some more information about the supported features - std::map effectsSupported; - std::map filtersSupported; - int maxSlots; - ALuint maxSlotsPerSource; -}; - -//! init in Sound.cpp -extern CEFX* efx; - -#endif // _EFX_H_ diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/EFXPresets.cpp spring-98.0~14.04~ppa6/rts/System/Sound/EFXPresets.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/EFXPresets.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/EFXPresets.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,224 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#include "EFXPresets.h" -#include "System/Util.h" - -std::map eaxPresets; - -std::map alParamType; -std::map nameToALParam; -std::map alParamToName; -std::map nameToALFilterParam; -std::map alFilterParamToName; - -static void InitPresets() -{ - //source: EFX-Util.h from the OpenAL1.1 SDK - - // STANDARD PRESETS - eaxPresets["generic"] = EAXSfxProps(1, 1, 0.316228, 0.891251, 1, 1.49, 0.83, 1, 0.0500035, 0.007, float3(0, 0, 0.3), 1.25893, 0.011, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["paddedcell"] = EAXSfxProps(0.1715, 1, 0.316228, 0.001, 1, 0.17, 0.1, 1, 0.250035, 0.001, float3(0, 0, 0.3), 1.26911, 0.002, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["room"] = EAXSfxProps(0.428687, 1, 0.316228, 0.592925, 1, 0.4, 0.83, 1, 0.150314, 0.002, float3(0, 0, 0.3), 1.06292, 0.003, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["bathroom"] = EAXSfxProps(0.1715, 1, 0.316228, 0.251189, 1, 1.49, 0.54, 1, 0.653131, 0.007, float3(0, 0, 0.3), 3.27341, 0.011, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["livingroom"] = EAXSfxProps(0.976562, 1, 0.316228, 0.001, 1, 0.5, 0.1, 1, 0.205116, 0.003, float3(0, 0, 0.3), 0.280543, 0.004, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["stoneroom"] = EAXSfxProps(1, 1, 0.316228, 0.707946, 1, 2.31, 0.64, 1, 0.441062, 0.012, float3(0, 0, 0.3), 1.10027, 0.017, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["auditorium"] = EAXSfxProps(1, 1, 0.316228, 0.578096, 1, 4.32, 0.59, 1, 0.403181, 0.02, float3(0, 0, 0.3), 0.716968, 0.03, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["concerthall"] = EAXSfxProps(1, 1, 0.316228, 0.562341, 1, 3.92, 0.7, 1, 0.242661, 0.02, float3(0, 0, 0.3), 0.9977, 0.029, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["cave"] = EAXSfxProps(1, 1, 0.316228, 1, 1, 2.91, 1.3, 1, 0.500035, 0.015, float3(0, 0, 0.3), 0.706318, 0.022, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_FALSE); - eaxPresets["arena"] = EAXSfxProps(1, 1, 0.316228, 0.447713, 1, 7.24, 0.33, 1, 0.261216, 0.02, float3(0, 0, 0.3), 1.01859, 0.03, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["hangar"] = EAXSfxProps(1, 1, 0.316228, 0.316228, 1, 10.05, 0.23, 1, 0.500035, 0.02, float3(0, 0, 0.3), 1.25603, 0.03, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["carpettedhallway"] = EAXSfxProps(0.428687, 1, 0.316228, 0.01, 1, 0.3, 0.1, 1, 0.121479, 0.002, float3(0, 0, 0.3), 0.153109, 0.03, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["hallway"] = EAXSfxProps(0.3645, 1, 0.316228, 0.707946, 1, 1.49, 0.59, 1, 0.245754, 0.007, float3(0, 0, 0.3), 1.6615, 0.011, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["stonecorridor"] = EAXSfxProps(1, 1, 0.316228, 0.761202, 1, 2.7, 0.79, 1, 0.247172, 0.013, float3(0, 0, 0.3), 1.5758, 0.02, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["alley"] = EAXSfxProps(1, 0.3, 0.316228, 0.732825, 1, 1.49, 0.86, 1, 0.250035, 0.007, float3(0, 0, 0.3), 0.995405, 0.011, float3(0, 0, 0.3), 0.125, 0.95, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["forest"] = EAXSfxProps(1, 0.3, 0.316228, 0.0223872, 1, 1.49, 0.54, 1, 0.0524807, 0.162, float3(0, 0, 0.3), 0.768245, 0.088, float3(0, 0, 0.3), 0.125, 1, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["city"] = EAXSfxProps(1, 0.5, 0.316228, 0.398107, 1, 1.49, 0.67, 1, 0.0730298, 0.007, float3(0, 0, 0.3), 0.142725, 0.011, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["mountains"] = EAXSfxProps(1, 0.27, 0.316228, 0.0562341, 1, 1.49, 0.21, 1, 0.040738, 0.3, float3(0, 0, 0.3), 0.191867, 0.1, float3(0, 0, 0.3), 0.25, 1, 0.25, 0, 0.99426, 5000, 250, 1, AL_FALSE); - eaxPresets["quarry"] = EAXSfxProps(1, 1, 0.316228, 0.316228, 1, 1.49, 0.83, 1, 0, 0.061, float3(0, 0, 0.3), 1.77828, 0.025, float3(0, 0, 0.3), 0.125, 0.7, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["plain"] = EAXSfxProps(1, 0.21, 0.316228, 0.1, 1, 1.49, 0.5, 1, 0.058479, 0.179, float3(0, 0, 0.3), 0.108893, 0.1, float3(0, 0, 0.3), 0.25, 1, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["parkinglot"] = EAXSfxProps(1, 1, 0.316228, 1, 1, 1.65, 1.5, 1, 0.208209, 0.008, float3(0, 0, 0.3), 0.265155, 0.012, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_FALSE); - eaxPresets["sewerpipe"] = EAXSfxProps(0.307063, 0.8, 0.316228, 0.316228, 1, 2.81, 0.14, 1, 1.6387, 0.014, float3(0, 0, 0.3), 3.24713, 0.021, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["underwater"] = EAXSfxProps(0.3645, 1, 0.316228, 0.01, 1, 1.49, 0.1, 1, 0.596348, 0.007, float3(0, 0, 0.3), 7.07946, 0.011, float3(0, 0, 0.3), 0.25, 0, 1.18, 0.348, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["drugged"] = EAXSfxProps(0.428687, 0.5, 0.316228, 1, 1, 8.39, 1.39, 1, 0.875992, 0.002, float3(0, 0, 0.3), 3.10814, 0.03, float3(0, 0, 0.3), 0.25, 0, 0.25, 1, 0.99426, 5000, 250, 1, AL_FALSE); - eaxPresets["dizzy"] = EAXSfxProps(0.3645, 0.6, 0.316228, 0.630957, 1, 17.23, 0.56, 1, 0.139155, 0.02, float3(0, 0, 0.3), 0.493742, 0.03, float3(0, 0, 0.3), 0.25, 1, 0.81, 0.31, 0.99426, 5000, 250, 1, AL_FALSE); - eaxPresets["psychotic"] = EAXSfxProps(0.0625, 0.5, 0.316228, 0.840427, 1, 7.56, 0.91, 1, 0.486407, 0.02, float3(0, 0, 0.3), 2.43781, 0.03, float3(0, 0, 0.3), 0.25, 0, 4, 1, 0.99426, 5000, 250, 1, AL_FALSE); - - // CASTLE PRESETS - eaxPresets["castle_smallroom"] = EAXSfxProps(1, 0.89, 0.316228, 0.398107, 0.1, 1.22, 0.83, 0.31, 0.891251, 0.022, float3(0, 0, 0.3), 1.99526, 0.011, float3(0, 0, 0.3), 0.138, 0.08, 0.25, 0, 0.99426, 5168.6, 139.5, 1, AL_TRUE); - eaxPresets["castle_shortpassage"] = EAXSfxProps(1, 0.89, 0.316228, 0.316228, 0.1, 2.32, 0.83, 0.31, 0.891251, 0.007, float3(0, 0, 0.3), 1.25893, 0.023, float3(0, 0, 0.3), 0.138, 0.08, 0.25, 0, 0.99426, 5168.6, 139.5, 1, AL_TRUE); - eaxPresets["castle_mediumroom"] = EAXSfxProps(1, 0.93, 0.316228, 0.281838, 0.1, 2.04, 0.83, 0.46, 0.630957, 0.022, float3(0, 0, 0.3), 1.58489, 0.011, float3(0, 0, 0.3), 0.155, 0.03, 0.25, 0, 0.99426, 5168.6, 139.5, 1, AL_TRUE); - eaxPresets["castle_longpassage"] = EAXSfxProps(1, 0.89, 0.316228, 0.398107, 0.1, 3.42, 0.83, 0.31, 0.891251, 0.007, float3(0, 0, 0.3), 1.41254, 0.023, float3(0, 0, 0.3), 0.138, 0.08, 0.25, 0, 0.99426, 5168.6, 139.5, 1, AL_TRUE); - eaxPresets["castle_largeroom"] = EAXSfxProps(1, 0.82, 0.316228, 0.281838, 0.125893, 2.53, 0.83, 0.5, 0.446684, 0.034, float3(0, 0, 0.3), 1.25893, 0.016, float3(0, 0, 0.3), 0.185, 0.07, 0.25, 0, 0.99426, 5168.6, 139.5, 1, AL_TRUE); - eaxPresets["castle_hall"] = EAXSfxProps(1, 0.81, 0.316228, 0.281838, 0.177828, 3.14, 0.79, 0.62, 0.177828, 0.056, float3(0, 0, 0.3), 1.12202, 0.024, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5168.6, 139.5, 1, AL_TRUE); - eaxPresets["castle_cupboard"] = EAXSfxProps(1, 0.89, 0.316228, 0.281838, 0.1, 0.67, 0.87, 0.31, 1.41254, 0.01, float3(0, 0, 0.3), 3.54813, 0.007, float3(0, 0, 0.3), 0.138, 0.08, 0.25, 0, 0.99426, 5168.6, 139.5, 1, AL_TRUE); - eaxPresets["castle_courtyard"] = EAXSfxProps(1, 0.42, 0.316228, 0.446684, 0.199526, 2.13, 0.61, 0.23, 0.223872, 0.16, float3(0, 0, 0.3), 0.707946, 0.036, float3(0, 0, 0.3), 0.25, 0.37, 0.25, 0, 0.99426, 5000, 250, 1, AL_FALSE); - eaxPresets["castle_alcove"] = EAXSfxProps(1, 0.89, 0.316228, 0.501187, 0.1, 1.64, 0.87, 0.31, 1, 0.007, float3(0, 0, 0.3), 1.41254, 0.034, float3(0, 0, 0.3), 0.138, 0.08, 0.25, 0, 0.99426, 5168.6, 139.5, 1, AL_TRUE); - - // FACTORY PRESETS - eaxPresets["factory_alcove"] = EAXSfxProps(0.3645, 0.59, 0.251189, 0.794328, 0.501187, 3.14, 0.65, 1.31, 1.41254, 0.01, float3(0, 0, 0.3), 1, 0.038, float3(0, 0, 0.3), 0.114, 0.1, 0.25, 0, 0.99426, 3762.6, 362.5, 1, AL_TRUE); - eaxPresets["factory_shortpassage"] = EAXSfxProps(0.3645, 0.64, 0.251189, 0.794328, 0.501187, 2.53, 0.65, 1.31, 1, 0.01, float3(0, 0, 0.3), 1.25893, 0.038, float3(0, 0, 0.3), 0.135, 0.23, 0.25, 0, 0.99426, 3762.6, 362.5, 1, AL_TRUE); - eaxPresets["factory_mediumroom"] = EAXSfxProps(0.428687, 0.82, 0.251189, 0.794328, 0.501187, 2.76, 0.65, 1.31, 0.281838, 0.022, float3(0, 0, 0.3), 1.41254, 0.023, float3(0, 0, 0.3), 0.174, 0.07, 0.25, 0, 0.99426, 3762.6, 362.5, 1, AL_TRUE); - eaxPresets["factory_longpassage"] = EAXSfxProps(0.3645, 0.64, 0.251189, 0.794328, 0.501187, 4.06, 0.65, 1.31, 1, 0.02, float3(0, 0, 0.3), 1.25893, 0.037, float3(0, 0, 0.3), 0.135, 0.23, 0.25, 0, 0.99426, 3762.6, 362.5, 1, AL_TRUE); - eaxPresets["factory_largeroom"] = EAXSfxProps(0.428687, 0.75, 0.251189, 0.707946, 0.630957, 4.24, 0.51, 1.31, 0.177828, 0.039, float3(0, 0, 0.3), 1.12202, 0.023, float3(0, 0, 0.3), 0.231, 0.07, 0.25, 0, 0.99426, 3762.6, 362.5, 1, AL_TRUE); - eaxPresets["factory_hall"] = EAXSfxProps(0.428687, 0.75, 0.316228, 0.707946, 0.630957, 7.43, 0.51, 1.31, 0.0630957, 0.073, float3(0, 0, 0.3), 0.891251, 0.027, float3(0, 0, 0.3), 0.25, 0.07, 0.25, 0, 0.99426, 3762.6, 362.5, 1, AL_TRUE); - eaxPresets["factory_cupboard"] = EAXSfxProps(0.307063, 0.63, 0.251189, 0.794328, 0.501187, 0.49, 0.65, 1.31, 1.25893, 0.01, float3(0, 0, 0.3), 1.99526, 0.032, float3(0, 0, 0.3), 0.107, 0.07, 0.25, 0, 0.99426, 3762.6, 362.5, 1, AL_TRUE); - eaxPresets["factory_courtyard"] = EAXSfxProps(0.307063, 0.57, 0.316228, 0.316228, 0.630957, 2.32, 0.29, 0.56, 0.223872, 0.14, float3(0, 0, 0.3), 0.398107, 0.039, float3(0, 0, 0.3), 0.25, 0.29, 0.25, 0, 0.99426, 3762.6, 362.5, 1, AL_TRUE); - eaxPresets["factory_smallroom"] = EAXSfxProps(0.3645, 0.82, 0.316228, 0.794328, 0.501187, 1.72, 0.65, 1.31, 0.707946, 0.01, float3(0, 0, 0.3), 1.77828, 0.024, float3(0, 0, 0.3), 0.119, 0.07, 0.25, 0, 0.99426, 3762.6, 362.5, 1, AL_TRUE); - - // ICE PALACE PRESETS - eaxPresets["icepalace_alcove"] = EAXSfxProps(1, 0.84, 0.316228, 0.562341, 0.281838, 2.76, 1.46, 0.28, 1.12202, 0.01, float3(0, 0, 0.3), 0.891251, 0.03, float3(0, 0, 0.3), 0.161, 0.09, 0.25, 0, 0.99426, 12428.5, 99.6, 1, AL_TRUE); - eaxPresets["icepalace_shortpassage"] = EAXSfxProps(1, 0.75, 0.316228, 0.562341, 0.281838, 1.79, 1.46, 0.28, 0.501187, 0.01, float3(0, 0, 0.3), 1.12202, 0.019, float3(0, 0, 0.3), 0.177, 0.09, 0.25, 0, 0.99426, 12428.5, 99.6, 1, AL_TRUE); - eaxPresets["icepalace_mediumroom"] = EAXSfxProps(1, 0.87, 0.316228, 0.562341, 0.446684, 2.22, 1.53, 0.32, 0.398107, 0.039, float3(0, 0, 0.3), 1.12202, 0.027, float3(0, 0, 0.3), 0.186, 0.12, 0.25, 0, 0.99426, 12428.5, 99.6, 1, AL_TRUE); - eaxPresets["icepalace_longpassage"] = EAXSfxProps(1, 0.77, 0.316228, 0.562341, 0.398107, 3.01, 1.46, 0.28, 0.794328, 0.012, float3(0, 0, 0.3), 1.25893, 0.025, float3(0, 0, 0.3), 0.186, 0.04, 0.25, 0, 0.99426, 12428.5, 99.6, 1, AL_TRUE); - eaxPresets["icepalace_largeroom"] = EAXSfxProps(1, 0.81, 0.316228, 0.562341, 0.446684, 3.14, 1.53, 0.32, 0.251189, 0.039, float3(0, 0, 0.3), 1, 0.027, float3(0, 0, 0.3), 0.214, 0.11, 0.25, 0, 0.99426, 12428.5, 99.6, 1, AL_TRUE); - eaxPresets["icepalace_hall"] = EAXSfxProps(1, 0.76, 0.316228, 0.446684, 0.562341, 5.49, 1.53, 0.38, 0.112202, 0.054, float3(0, 0, 0.3), 0.630957, 0.052, float3(0, 0, 0.3), 0.226, 0.11, 0.25, 0, 0.99426, 12428.5, 99.6, 1, AL_TRUE); - eaxPresets["icepalace_cupboard"] = EAXSfxProps(1, 0.83, 0.316228, 0.501187, 0.223872, 0.76, 1.53, 0.26, 1.12202, 0.012, float3(0, 0, 0.3), 1.99526, 0.016, float3(0, 0, 0.3), 0.143, 0.08, 0.25, 0, 0.99426, 12428.5, 99.6, 1, AL_TRUE); - eaxPresets["icepalace_courtyard"] = EAXSfxProps(1, 0.59, 0.316228, 0.281838, 0.316228, 2.04, 1.2, 0.38, 0.316228, 0.173, float3(0, 0, 0.3), 0.316228, 0.043, float3(0, 0, 0.3), 0.235, 0.48, 0.25, 0, 0.99426, 12428.5, 99.6, 1, AL_TRUE); - eaxPresets["icepalace_smallroom"] = EAXSfxProps(1, 0.84, 0.316228, 0.562341, 0.281838, 1.51, 1.53, 0.27, 0.891251, 0.01, float3(0, 0, 0.3), 1.41254, 0.011, float3(0, 0, 0.3), 0.164, 0.14, 0.25, 0, 0.99426, 12428.5, 99.6, 1, AL_TRUE); - - // SPACE STATION PRESETS - eaxPresets["spacestation_alcove"] = EAXSfxProps(0.210938, 0.78, 0.316228, 0.707946, 0.891251, 1.16, 0.81, 0.55, 1.41254, 0.007, float3(0, 0, 0.3), 1, 0.018, float3(0, 0, 0.3), 0.192, 0.21, 0.25, 0, 0.99426, 3316.1, 458.2, 1, AL_TRUE); - eaxPresets["spacestation_mediumroom"] = EAXSfxProps(0.210938, 0.75, 0.316228, 0.630957, 0.891251, 3.01, 0.5, 0.55, 0.398107, 0.034, float3(0, 0, 0.3), 1.12202, 0.035, float3(0, 0, 0.3), 0.209, 0.31, 0.25, 0, 0.99426, 3316.1, 458.2, 1, AL_TRUE); - eaxPresets["spacestation_shortpassage"] = EAXSfxProps(0.210938, 0.87, 0.316228, 0.630957, 0.891251, 3.57, 0.5, 0.55, 1, 0.012, float3(0, 0, 0.3), 1.12202, 0.016, float3(0, 0, 0.3), 0.172, 0.2, 0.25, 0, 0.99426, 3316.1, 458.2, 1, AL_TRUE); - eaxPresets["spacestation_longpassage"] = EAXSfxProps(0.428687, 0.82, 0.316228, 0.630957, 0.891251, 4.62, 0.62, 0.55, 1, 0.012, float3(0, 0, 0.3), 1.25893, 0.031, float3(0, 0, 0.3), 0.25, 0.23, 0.25, 0, 0.99426, 3316.1, 458.2, 1, AL_TRUE); - eaxPresets["spacestation_largeroom"] = EAXSfxProps(0.3645, 0.81, 0.316228, 0.630957, 0.891251, 3.89, 0.38, 0.61, 0.316228, 0.056, float3(0, 0, 0.3), 0.891251, 0.035, float3(0, 0, 0.3), 0.233, 0.28, 0.25, 0, 0.99426, 3316.1, 458.2, 1, AL_TRUE); - eaxPresets["spacestation_hall"] = EAXSfxProps(0.428687, 0.87, 0.316228, 0.630957, 0.891251, 7.11, 0.38, 0.61, 0.177828, 0.1, float3(0, 0, 0.3), 0.630957, 0.047, float3(0, 0, 0.3), 0.25, 0.25, 0.25, 0, 0.99426, 3316.1, 458.2, 1, AL_TRUE); - eaxPresets["spacestation_cupboard"] = EAXSfxProps(0.1715, 0.56, 0.316228, 0.707946, 0.891251, 0.79, 0.81, 0.55, 1.41254, 0.007, float3(0, 0, 0.3), 1.77828, 0.018, float3(0, 0, 0.3), 0.181, 0.31, 0.25, 0, 0.99426, 3316.1, 458.2, 1, AL_TRUE); - eaxPresets["spacestation_smallroom"] = EAXSfxProps(0.210938, 0.7, 0.316228, 0.707946, 0.891251, 1.72, 0.82, 0.55, 0.794328, 0.007, float3(0, 0, 0.3), 1.41254, 0.013, float3(0, 0, 0.3), 0.188, 0.26, 0.25, 0, 0.99426, 3316.1, 458.2, 1, AL_TRUE); - - // WOODEN GALLEON PRESETS - eaxPresets["wooden_alcove"] = EAXSfxProps(1, 1, 0.316228, 0.125893, 0.316228, 1.22, 0.62, 0.91, 1.12202, 0.012, float3(0, 0, 0.3), 0.707946, 0.024, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 4705, 99.6, 1, AL_TRUE); - eaxPresets["wooden_shortpassage"] = EAXSfxProps(1, 1, 0.316228, 0.125893, 0.316228, 1.75, 0.5, 0.87, 0.891251, 0.012, float3(0, 0, 0.3), 0.630957, 0.024, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 4705, 99.6, 1, AL_TRUE); - eaxPresets["wooden_mediumroom"] = EAXSfxProps(1, 1, 0.316228, 0.1, 0.281838, 1.47, 0.42, 0.82, 0.891251, 0.049, float3(0, 0, 0.3), 0.891251, 0.029, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 4705, 99.6, 1, AL_TRUE); - eaxPresets["wooden_longpassage"] = EAXSfxProps(1, 1, 0.316228, 0.1, 0.316228, 1.99, 0.4, 0.79, 1, 0.02, float3(0, 0, 0.3), 0.446684, 0.036, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 4705, 99.6, 1, AL_TRUE); - eaxPresets["wooden_largeroom"] = EAXSfxProps(1, 1, 0.316228, 0.0891251, 0.281838, 2.65, 0.33, 0.82, 0.891251, 0.066, float3(0, 0, 0.3), 0.794328, 0.049, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 4705, 99.6, 1, AL_TRUE); - eaxPresets["wooden_hall"] = EAXSfxProps(1, 1, 0.316228, 0.0794328, 0.281838, 3.45, 0.3, 0.82, 0.891251, 0.088, float3(0, 0, 0.3), 0.794328, 0.063, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 4705, 99.6, 1, AL_TRUE); - eaxPresets["wooden_cupboard"] = EAXSfxProps(1, 1, 0.316228, 0.141254, 0.316228, 0.56, 0.46, 0.91, 1.12202, 0.012, float3(0, 0, 0.3), 1.12202, 0.028, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 4705, 99.6, 1, AL_TRUE); - eaxPresets["wooden_smallroom"] = EAXSfxProps(1, 1, 0.316228, 0.112202, 0.316228, 0.79, 0.32, 0.87, 1, 0.032, float3(0, 0, 0.3), 0.891251, 0.029, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 4705, 99.6, 1, AL_TRUE); - eaxPresets["wooden_courtyard"] = EAXSfxProps(1, 0.65, 0.316228, 0.0794328, 0.316228, 1.79, 0.35, 0.79, 0.562341, 0.123, float3(0, 0, 0.3), 0.1, 0.032, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 4705, 99.6, 1, AL_TRUE); - - // SPORTS PRESETS - eaxPresets["sport_emptystadium"] = EAXSfxProps(1, 1, 0.316228, 0.446684, 0.794328, 6.26, 0.51, 1.1, 0.0630957, 0.183, float3(0, 0, 0.3), 0.398107, 0.038, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["sport_squashcourt"] = EAXSfxProps(1, 0.75, 0.316228, 0.316228, 0.794328, 2.22, 0.91, 1.16, 0.446684, 0.007, float3(0, 0, 0.3), 0.794328, 0.011, float3(0, 0, 0.3), 0.126, 0.19, 0.25, 0, 0.99426, 7176.9, 211.2, 1, AL_TRUE); - eaxPresets["sport_smallswimmingpool"] = EAXSfxProps(1, 0.7, 0.316228, 0.794328, 0.891251, 2.76, 1.25, 1.14, 0.630957, 0.02, float3(0, 0, 0.3), 0.794328, 0.03, float3(0, 0, 0.3), 0.179, 0.15, 0.895, 0.19, 0.99426, 5000, 250, 1, AL_FALSE); - eaxPresets["sport_largeswimmingpool"] = EAXSfxProps(1, 0.82, 0.316228, 0.794328, 1, 5.49, 1.31, 1.14, 0.446684, 0.039, float3(0, 0, 0.3), 0.501187, 0.049, float3(0, 0, 0.3), 0.222, 0.55, 1.159, 0.21, 0.99426, 5000, 250, 1, AL_FALSE); - eaxPresets["sport_gymnasium"] = EAXSfxProps(1, 0.81, 0.316228, 0.446684, 0.891251, 3.14, 1.06, 1.35, 0.398107, 0.029, float3(0, 0, 0.3), 0.562341, 0.045, float3(0, 0, 0.3), 0.146, 0.14, 0.25, 0, 0.99426, 7176.9, 211.2, 1, AL_TRUE); - eaxPresets["sport_fullstadium"] = EAXSfxProps(1, 1, 0.316228, 0.0707946, 0.794328, 5.25, 0.17, 0.8, 0.1, 0.188, float3(0, 0, 0.3), 0.281838, 0.038, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["sport_stadiumtannoy"] = EAXSfxProps(1, 0.78, 0.316228, 0.562341, 0.501187, 2.53, 0.88, 0.68, 0.281838, 0.23, float3(0, 0, 0.3), 0.501187, 0.063, float3(0, 0, 0.3), 0.25, 0.2, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); - - // PREFAB PRESETS - eaxPresets["prefab_workshop"] = EAXSfxProps(0.428687, 1, 0.316228, 0.141254, 0.398107, 0.76, 1, 1, 1, 0.012, float3(0, 0, 0.3), 1.12202, 0.012, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_FALSE); - eaxPresets["prefab_schoolroom"] = EAXSfxProps(0.402178, 0.69, 0.316228, 0.630957, 0.501187, 0.98, 0.45, 0.18, 1.41254, 0.017, float3(0, 0, 0.3), 1.41254, 0.015, float3(0, 0, 0.3), 0.095, 0.14, 0.25, 0, 0.99426, 7176.9, 211.2, 1, AL_TRUE); - eaxPresets["prefab_practiseroom"] = EAXSfxProps(0.402178, 0.87, 0.316228, 0.398107, 0.501187, 1.12, 0.56, 0.18, 1.25893, 0.01, float3(0, 0, 0.3), 1.41254, 0.011, float3(0, 0, 0.3), 0.095, 0.14, 0.25, 0, 0.99426, 7176.9, 211.2, 1, AL_TRUE); - eaxPresets["prefab_outhouse"] = EAXSfxProps(1, 0.82, 0.316228, 0.112202, 0.158489, 1.38, 0.38, 0.35, 0.891251, 0.024, float3(0, 0, 0.3), 0.630957, 0.044, float3(0, 0, 0.3), 0.121, 0.17, 0.25, 0, 0.99426, 2854.4, 107.5, 1, AL_FALSE); - eaxPresets["prefab_caravan"] = EAXSfxProps(1, 1, 0.316228, 0.0891251, 0.125893, 0.43, 1.5, 1, 1, 0.012, float3(0, 0, 0.3), 1.99526, 0.012, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_FALSE); - - // DOME AND PIPE PRESETS - eaxPresets["dome_tomb"] = EAXSfxProps(1, 0.79, 0.316228, 0.354813, 0.223872, 4.18, 0.21, 0.1, 0.386812, 0.03, float3(0, 0, 0.3), 1.6788, 0.022, float3(0, 0, 0.3), 0.177, 0.19, 0.25, 0, 0.99426, 2854.4, 20, 1, AL_FALSE); - eaxPresets["pipe_small"] = EAXSfxProps(1, 1, 0.316228, 0.354813, 0.223872, 5.04, 0.1, 0.1, 0.501187, 0.032, float3(0, 0, 0.3), 2.51189, 0.015, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 2854.4, 20, 1, AL_TRUE); - eaxPresets["dome_saintpauls"] = EAXSfxProps(1, 0.87, 0.316228, 0.354813, 0.223872, 10.48, 0.19, 0.1, 0.177828, 0.09, float3(0, 0, 0.3), 1.25893, 0.042, float3(0, 0, 0.3), 0.25, 0.12, 0.25, 0, 0.99426, 2854.4, 20, 1, AL_TRUE); - eaxPresets["pipe_longthin"] = EAXSfxProps(0.256, 0.91, 0.316228, 0.446684, 0.281838, 9.21, 0.18, 0.1, 0.707946, 0.01, float3(0, 0, 0.3), 0.707946, 0.022, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 2854.4, 20, 1, AL_FALSE); - eaxPresets["pipe_large"] = EAXSfxProps(1, 1, 0.316228, 0.354813, 0.223872, 8.45, 0.1, 0.1, 0.398107, 0.046, float3(0, 0, 0.3), 1.58489, 0.032, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 2854.4, 20, 1, AL_TRUE); - eaxPresets["pipe_resonant"] = EAXSfxProps(0.137312, 0.91, 0.316228, 0.446684, 0.281838, 6.81, 0.18, 0.1, 0.707946, 0.01, float3(0, 0, 0.3), 1, 0.022, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 2854.4, 20, 1, AL_FALSE); - - // OUTDOORS PRESETS - eaxPresets["outdoors_backyard"] = EAXSfxProps(1, 0.45, 0.316228, 0.251189, 0.501187, 1.12, 0.34, 0.46, 0.446684, 0.069, float3(0, 0, 0.3), 0.707946, 0.023, float3(0, 0, 0.3), 0.218, 0.34, 0.25, 0, 0.99426, 4399.1, 242.9, 1, AL_FALSE); - eaxPresets["outdoors_rollingplains"] = EAXSfxProps(1, 0, 0.316228, 0.0112202, 0.630957, 2.13, 0.21, 0.46, 0.177828, 0.3, float3(0, 0, 0.3), 0.446684, 0.019, float3(0, 0, 0.3), 0.25, 1, 0.25, 0, 0.99426, 4399.1, 242.9, 1, AL_FALSE); - eaxPresets["outdoors_deepcanyon"] = EAXSfxProps(1, 0.74, 0.316228, 0.177828, 0.630957, 3.89, 0.21, 0.46, 0.316228, 0.223, float3(0, 0, 0.3), 0.354813, 0.019, float3(0, 0, 0.3), 0.25, 1, 0.25, 0, 0.99426, 4399.1, 242.9, 1, AL_FALSE); - eaxPresets["outdoors_creek"] = EAXSfxProps(1, 0.35, 0.316228, 0.177828, 0.501187, 2.13, 0.21, 0.46, 0.398107, 0.115, float3(0, 0, 0.3), 0.199526, 0.031, float3(0, 0, 0.3), 0.218, 0.34, 0.25, 0, 0.99426, 4399.1, 242.9, 1, AL_FALSE); - eaxPresets["outdoors_valley"] = EAXSfxProps(1, 0.28, 0.316228, 0.0281838, 0.158489, 2.88, 0.26, 0.35, 0.141254, 0.263, float3(0, 0, 0.3), 0.398107, 0.1, float3(0, 0, 0.3), 0.25, 0.34, 0.25, 0, 0.99426, 2854.4, 107.5, 1, AL_FALSE); - - // MOOD PRESETS - eaxPresets["mood_heaven"] = EAXSfxProps(1, 0.94, 0.316228, 0.794328, 0.446684, 5.04, 1.12, 0.56, 0.242661, 0.02, float3(0, 0, 0.3), 1.25893, 0.029, float3(0, 0, 0.3), 0.25, 0.08, 2.742, 0.05, 0.9977, 5000, 250, 1, AL_TRUE); - eaxPresets["mood_hell"] = EAXSfxProps(1, 0.57, 0.316228, 0.354813, 0.446684, 3.57, 0.49, 2, 0, 0.02, float3(0, 0, 0.3), 1.41254, 0.03, float3(0, 0, 0.3), 0.11, 0.04, 2.109, 0.52, 0.99426, 5000, 139.5, 1, AL_FALSE); - eaxPresets["mood_memory"] = EAXSfxProps(1, 0.85, 0.316228, 0.630957, 0.354813, 4.06, 0.82, 0.56, 0.0398107, 0, float3(0, 0, 0.3), 1.12202, 0, float3(0, 0, 0.3), 0.25, 0, 0.474, 0.45, 0.988553, 5000, 250, 1, AL_FALSE); - - // DRIVING SIMULATION PRESETS - eaxPresets["driving_commentator"] = EAXSfxProps(1, 0, 0.316228, 0.562341, 0.501187, 2.42, 0.88, 0.68, 0.199526, 0.093, float3(0, 0, 0.3), 0.251189, 0.017, float3(0, 0, 0.3), 0.25, 1, 0.25, 0, 0.988553, 5000, 250, 1, AL_TRUE); - eaxPresets["driving_pitgarage"] = EAXSfxProps(0.428687, 0.59, 0.316228, 0.707946, 0.562341, 1.72, 0.93, 0.87, 0.562341, 0, float3(0, 0, 0.3), 1.25893, 0.016, float3(0, 0, 0.3), 0.25, 0.11, 0.25, 0, 0.99426, 5000, 250, 1, AL_FALSE); - eaxPresets["driving_incar_racer"] = EAXSfxProps(0.0831875, 0.8, 0.316228, 1, 0.794328, 0.17, 2, 0.41, 1.77828, 0.007, float3(0, 0, 0.3), 0.707946, 0.015, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 10268.2, 251, 1, AL_TRUE); - eaxPresets["driving_incar_sports"] = EAXSfxProps(0.0831875, 0.8, 0.316228, 0.630957, 1, 0.17, 0.75, 0.41, 1, 0.01, float3(0, 0, 0.3), 0.562341, 0, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 10268.2, 251, 1, AL_TRUE); - eaxPresets["driving_incar_luxury"] = EAXSfxProps(0.256, 1, 0.316228, 0.1, 0.501187, 0.13, 0.41, 0.46, 0.794328, 0.01, float3(0, 0, 0.3), 1.58489, 0.01, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 10268.2, 251, 1, AL_TRUE); - eaxPresets["driving_fullgrandstand"] = EAXSfxProps(1, 1, 0.316228, 0.281838, 0.630957, 3.01, 1.37, 1.28, 0.354813, 0.09, float3(0, 0, 0.3), 0.177828, 0.049, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 10420.2, 250, 1, AL_FALSE); - eaxPresets["driving_emptygrandstand"] = EAXSfxProps(1, 1, 0.316228, 1, 0.794328, 4.62, 1.75, 1.4, 0.208209, 0.09, float3(0, 0, 0.3), 0.251189, 0.049, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 10420.2, 250, 1, AL_FALSE); - eaxPresets["driving_tunnel"] = EAXSfxProps(1, 0.81, 0.316228, 0.398107, 0.891251, 3.42, 0.94, 1.31, 0.707946, 0.051, float3(0, 0, 0.3), 0.707946, 0.047, float3(0, 0, 0.3), 0.214, 0.05, 0.25, 0, 0.99426, 5000, 155.3, 1, AL_TRUE); - - // CITY PRESETS - eaxPresets["city_streets"] = EAXSfxProps(1, 0.78, 0.316228, 0.707946, 0.891251, 1.79, 1.12, 0.91, 0.281838, 0.046, float3(0, 0, 0.3), 0.199526, 0.028, float3(0, 0, 0.3), 0.25, 0.2, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["city_subway"] = EAXSfxProps(1, 0.74, 0.316228, 0.707946, 0.891251, 3.01, 1.23, 0.91, 0.707946, 0.046, float3(0, 0, 0.3), 1.25893, 0.028, float3(0, 0, 0.3), 0.125, 0.21, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["city_museum"] = EAXSfxProps(1, 0.82, 0.316228, 0.177828, 0.177828, 3.28, 1.4, 0.57, 0.251189, 0.039, float3(0, 0, 0.3), 0.891251, 0.034, float3(0, 0, 0.3), 0.13, 0.17, 0.25, 0, 0.99426, 2854.4, 107.5, 1, AL_FALSE); - eaxPresets["city_library"] = EAXSfxProps(1, 0.82, 0.316228, 0.281838, 0.0891251, 2.76, 0.89, 0.41, 0.354813, 0.029, float3(0, 0, 0.3), 0.891251, 0.02, float3(0, 0, 0.3), 0.13, 0.17, 0.25, 0, 0.99426, 2854.4, 107.5, 1, AL_FALSE); - eaxPresets["city_underpass"] = EAXSfxProps(1, 0.82, 0.316228, 0.446684, 0.891251, 3.57, 1.12, 0.91, 0.398107, 0.059, float3(0, 0, 0.3), 0.891251, 0.037, float3(0, 0, 0.3), 0.25, 0.14, 0.25, 0, 0.991973, 5000, 250, 1, AL_TRUE); - eaxPresets["city_abandoned"] = EAXSfxProps(1, 0.69, 0.316228, 0.794328, 0.891251, 3.28, 1.17, 0.91, 0.446684, 0.044, float3(0, 0, 0.3), 0.281838, 0.024, float3(0, 0, 0.3), 0.25, 0.2, 0.25, 0, 0.996552, 5000, 250, 1, AL_TRUE); - - // MISC ROOMS - eaxPresets["dustyroom"] = EAXSfxProps(0.3645, 0.56, 0.316228, 0.794328, 0.707946, 1.79, 0.38, 0.21, 0.501187, 0.002, float3(0, 0, 0.3), 1.25893, 0.006, float3(0, 0, 0.3), 0.202, 0.05, 0.25, 0, 0.988553, 13046, 163.3, 1, AL_TRUE); - eaxPresets["chapel"] = EAXSfxProps(1, 0.84, 0.316228, 0.562341, 1, 4.62, 0.64, 1.23, 0.446684, 0.032, float3(0, 0, 0.3), 0.794328, 0.049, float3(0, 0, 0.3), 0.25, 0, 0.25, 0.11, 0.99426, 5000, 250, 1, AL_TRUE); - eaxPresets["smallwaterroom"] = EAXSfxProps(1, 0.7, 0.316228, 0.447713, 1, 1.51, 1.25, 1.14, 0.891251, 0.02, float3(0, 0, 0.3), 1.41254, 0.03, float3(0, 0, 0.3), 0.179, 0.15, 0.895, 0.19, 0.991973, 5000, 250, 1, AL_FALSE); -} - -static void InitConversionTables() -{ - alParamType[AL_EAXREVERB_DENSITY] = EFXParamTypes::FLOAT; - alParamType[AL_EAXREVERB_DIFFUSION] = EFXParamTypes::FLOAT; - alParamType[AL_EAXREVERB_GAIN] = EFXParamTypes::FLOAT; - alParamType[AL_EAXREVERB_GAINHF] = EFXParamTypes::FLOAT; - alParamType[AL_EAXREVERB_GAINLF] = EFXParamTypes::FLOAT; - alParamType[AL_EAXREVERB_DECAY_TIME] = EFXParamTypes::FLOAT; - alParamType[AL_EAXREVERB_DECAY_HFLIMIT] = EFXParamTypes::BOOL; - alParamType[AL_EAXREVERB_DECAY_HFRATIO] = EFXParamTypes::FLOAT; - alParamType[AL_EAXREVERB_DECAY_LFRATIO] = EFXParamTypes::FLOAT; - alParamType[AL_EAXREVERB_REFLECTIONS_GAIN] = EFXParamTypes::FLOAT; - alParamType[AL_EAXREVERB_REFLECTIONS_DELAY] = EFXParamTypes::FLOAT; - alParamType[AL_EAXREVERB_REFLECTIONS_PAN] = EFXParamTypes::VECTOR; - alParamType[AL_EAXREVERB_LATE_REVERB_GAIN] = EFXParamTypes::FLOAT; - alParamType[AL_EAXREVERB_LATE_REVERB_DELAY] = EFXParamTypes::FLOAT; - alParamType[AL_EAXREVERB_LATE_REVERB_PAN] = EFXParamTypes::VECTOR; - alParamType[AL_EAXREVERB_ECHO_TIME] = EFXParamTypes::FLOAT; - alParamType[AL_EAXREVERB_ECHO_DEPTH] = EFXParamTypes::FLOAT; - alParamType[AL_EAXREVERB_MODULATION_TIME] = EFXParamTypes::FLOAT; - alParamType[AL_EAXREVERB_MODULATION_DEPTH] = EFXParamTypes::FLOAT; - alParamType[AL_EAXREVERB_AIR_ABSORPTION_GAINHF] = EFXParamTypes::FLOAT; - alParamType[AL_EAXREVERB_HFREFERENCE] = EFXParamTypes::FLOAT; - alParamType[AL_EAXREVERB_LFREFERENCE] = EFXParamTypes::FLOAT; - alParamType[AL_EAXREVERB_ROOM_ROLLOFF_FACTOR] = EFXParamTypes::FLOAT; - alParamType[AL_LOWPASS_GAIN] = EFXParamTypes::FLOAT; - alParamType[AL_LOWPASS_GAINHF] = EFXParamTypes::FLOAT; - - - alParamToName[AL_EAXREVERB_DENSITY] = "density"; - alParamToName[AL_EAXREVERB_DIFFUSION] = "diffusion"; - alParamToName[AL_EAXREVERB_GAIN] = "gain"; - alParamToName[AL_EAXREVERB_GAINHF] = "gainhf"; - alParamToName[AL_EAXREVERB_GAINLF] = "gainlf"; - alParamToName[AL_EAXREVERB_DECAY_TIME] = "decaytime"; - alParamToName[AL_EAXREVERB_DECAY_HFLIMIT] = "decayhflimit"; - alParamToName[AL_EAXREVERB_DECAY_HFRATIO] = "decayhfratio"; - alParamToName[AL_EAXREVERB_DECAY_LFRATIO] = "decaylfratio"; - alParamToName[AL_EAXREVERB_REFLECTIONS_GAIN] = "reflectionsgain"; - alParamToName[AL_EAXREVERB_REFLECTIONS_DELAY] = "reflectionsdelay"; - alParamToName[AL_EAXREVERB_REFLECTIONS_PAN] = "reflectionspan"; - alParamToName[AL_EAXREVERB_LATE_REVERB_GAIN] = "latereverbgain"; - alParamToName[AL_EAXREVERB_LATE_REVERB_DELAY] = "latereverbdelay"; - alParamToName[AL_EAXREVERB_LATE_REVERB_PAN] = "latereverbpan"; - alParamToName[AL_EAXREVERB_ECHO_TIME] = "echotime"; - alParamToName[AL_EAXREVERB_ECHO_DEPTH] = "echodepth"; - alParamToName[AL_EAXREVERB_MODULATION_TIME] = "modtime"; - alParamToName[AL_EAXREVERB_MODULATION_DEPTH] = "moddepth"; - alParamToName[AL_EAXREVERB_AIR_ABSORPTION_GAINHF] = "airabsorptiongainhf"; - alParamToName[AL_EAXREVERB_HFREFERENCE] = "hfreference"; - alParamToName[AL_EAXREVERB_LFREFERENCE] = "lfreference"; - alParamToName[AL_EAXREVERB_ROOM_ROLLOFF_FACTOR] = "roomrollofffactor"; - - alFilterParamToName[AL_LOWPASS_GAIN] = "gainlf"; - alFilterParamToName[AL_LOWPASS_GAINHF] = "gainhf"; - - for (std::map::iterator it=alParamToName.begin(); it != alParamToName.end(); ++it) - nameToALParam[it->second] = it->first; - - for (std::map::iterator it=alFilterParamToName.begin(); it != alFilterParamToName.end(); ++it) - nameToALFilterParam[it->second] = it->first; -} - -DO_ONCE(InitPresets) -DO_ONCE(InitConversionTables) diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/EFXPresets.h spring-98.0~14.04~ppa6/rts/System/Sound/EFXPresets.h --- spring-96.0~14.04~ppa4/rts/System/Sound/EFXPresets.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/EFXPresets.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#ifndef _EFX_PRESETS_H_ -#define _EFX_PRESETS_H_ - -#include -#include -#include "System/float3.h" -#include -#include - - -struct EAXSfxProps -{ - EAXSfxProps( - ALfloat _density, - ALfloat _diffusion, - ALfloat _gain, - ALfloat _gainHF, - ALfloat _gainLF, - ALfloat _decayTime, - ALfloat _decayHFRatio, - ALfloat _decayLFRatio, - ALfloat _reflectionGain, - ALfloat _reflectionDelay, - float3 _reflectionPan, - ALfloat _lateReverbGain, - ALfloat _lateReverbDelay, - float3 _lateReverbPan, - ALfloat _echoTime, - ALfloat _echoDepth, - ALfloat _modTime, - ALfloat _modDepth, - ALfloat _airAbsorptionGainHF, - ALfloat _hfReference, - ALfloat _lfReference, - ALfloat _roomRollOffFactor, - ALboolean _decayHFLimit - ) - { - properties_f[AL_EAXREVERB_DENSITY] = _density; - properties_f[AL_EAXREVERB_DIFFUSION] = _diffusion; - properties_f[AL_EAXREVERB_GAIN] = _gain; - properties_f[AL_EAXREVERB_GAINHF] = _gainHF; - properties_f[AL_EAXREVERB_GAINLF] = _gainLF; - properties_f[AL_EAXREVERB_DECAY_TIME] = _decayTime; - properties_i[AL_EAXREVERB_DECAY_HFLIMIT] = _decayHFLimit; - properties_f[AL_EAXREVERB_DECAY_HFRATIO] = _decayHFRatio; - properties_f[AL_EAXREVERB_DECAY_LFRATIO] = _decayLFRatio; - properties_f[AL_EAXREVERB_REFLECTIONS_GAIN] = _reflectionGain; - properties_f[AL_EAXREVERB_REFLECTIONS_DELAY] = _reflectionDelay; - properties_v[AL_EAXREVERB_REFLECTIONS_PAN] = _reflectionPan; - properties_f[AL_EAXREVERB_LATE_REVERB_GAIN] = _lateReverbGain; - properties_f[AL_EAXREVERB_LATE_REVERB_DELAY] = _lateReverbDelay; - properties_v[AL_EAXREVERB_LATE_REVERB_PAN] = _lateReverbPan; - properties_f[AL_EAXREVERB_ECHO_TIME] = _echoTime; - properties_f[AL_EAXREVERB_ECHO_DEPTH] = _echoDepth; - properties_f[AL_EAXREVERB_MODULATION_TIME] = _modTime; - properties_f[AL_EAXREVERB_MODULATION_DEPTH] = _modDepth; - properties_f[AL_EAXREVERB_AIR_ABSORPTION_GAINHF] = _airAbsorptionGainHF; - properties_f[AL_EAXREVERB_HFREFERENCE] = _hfReference; - properties_f[AL_EAXREVERB_LFREFERENCE] = _lfReference; - properties_f[AL_EAXREVERB_ROOM_ROLLOFF_FACTOR] = _roomRollOffFactor; - - filter_properties_f[AL_LOWPASS_GAIN] = 1.0f; - filter_properties_f[AL_LOWPASS_GAINHF] = 1.0f; - } - - EAXSfxProps() {} - - // Reverb - std::map properties_f; - std::map properties_i; - std::map properties_v; - - // Filter - std::map filter_properties_f; -}; - -namespace EFXParamTypes { - enum { - FLOAT, - VECTOR, - BOOL - }; -} - -extern std::map eaxPresets; - -extern std::map alParamType; -extern std::map nameToALParam; -extern std::map alParamToName; -extern std::map nameToALFilterParam; -extern std::map alFilterParamToName; - -#endif // _EFX_PRESETS_H_ \ No newline at end of file diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/IAudioChannel.h spring-98.0~14.04~ppa6/rts/System/Sound/IAudioChannel.h --- spring-96.0~14.04~ppa4/rts/System/Sound/IAudioChannel.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/IAudioChannel.h 2014-10-07 20:09:51.000000000 +0000 @@ -19,9 +19,9 @@ class IAudioChannel { protected: IAudioChannel(); +public: virtual ~IAudioChannel(); -public: virtual void Enable(bool newState) = 0; bool IsEnabled() const { diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/ISoundChannels.h spring-98.0~14.04~ppa6/rts/System/Sound/ISoundChannels.h --- spring-96.0~14.04~ppa4/rts/System/Sound/ISoundChannels.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/ISoundChannels.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,18 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef SOUND_CHANNELS_H +#define SOUND_CHANNELS_H + +#include "IAudioChannel.h" +/** +* @brief If you want to play a sound, use one of these +*/ +namespace Channels { + extern IAudioChannel* BGMusic; + extern IAudioChannel* General; + extern IAudioChannel* Battle; + extern IAudioChannel* UnitReply; + extern IAudioChannel* UserInterface; +} + +#endif diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/ISound.cpp spring-98.0~14.04~ppa6/rts/System/Sound/ISound.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/ISound.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/ISound.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -3,14 +3,22 @@ #include "ISound.h" #ifndef NO_SOUND -#include "Sound.h" +#include "OpenAL/Sound.h" #endif // NO_SOUND -#include "NullSound.h" +#include "Null/NullSound.h" #include "SoundLog.h" #include "System/Config/ConfigHandler.h" -CONFIG(bool, NoSound).defaultValue(false); +#include "ISoundChannels.h" +#include "Null/NullAudioChannel.h" +#ifndef NO_SOUND +#include "OpenAL/AudioChannel.h" +#endif +#include +#include "System/Misc/SpringTime.h" //FIXME: remove this + +CONFIG(bool, Sound).defaultValue(true).description("Select the Sound driver, true = OpenAL, false = NullAudio"); ISound* ISound::singleton = NULL; @@ -21,16 +29,31 @@ { } +static std::list sounddefs; + void ISound::Initialize() { if (singleton == NULL) { #ifndef NO_SOUND - const bool noSound = configHandler->GetBool("NoSound"); - if (!noSound) { + if (!IsNullAudio()) { + Channels::BGMusic = new AudioChannel(); + Channels::General = new AudioChannel(); + Channels::Battle = new AudioChannel(); + Channels::UnitReply = new AudioChannel(); + Channels::UserInterface = new AudioChannel(); singleton = new CSound(); + for(const std::string& filename: sounddefs) { + spring_sleep(spring_msecs(1000)); //FIXME BADHACK: the sound device is initialized asynchron in a thread this is why loading sounds instantly fails + singleton->LoadSoundDefsImpl(filename); + } } else #endif // NO_SOUND { + Channels::BGMusic = new NullAudioChannel(); + Channels::General = new NullAudioChannel(); + Channels::Battle = new NullAudioChannel(); + Channels::UnitReply = new NullAudioChannel(); + Channels::UserInterface = new NullAudioChannel(); singleton = new NullSound(); } } else { @@ -38,16 +61,51 @@ } } +#define SafeDelete(var) \ + delete var; \ + var = NULL; + void ISound::Shutdown() { ISound* tmpSound = singleton; singleton = NULL; - delete tmpSound; - tmpSound = NULL; + SafeDelete(tmpSound); + + SafeDelete(Channels::BGMusic); + SafeDelete(Channels::General); + SafeDelete(Channels::Battle); + SafeDelete(Channels::UnitReply); + SafeDelete(Channels::UserInterface); + } + bool ISound::IsInitialized() { return (singleton != NULL); } +bool ISound::IsNullAudio() +{ + return !configHandler->GetBool("Sound"); +} + + +bool ISound::ChangeOutput() +{ + if (IsNullAudio()) { + //FIXME: on reload, sound-ids change (depends on order when they are requested, see GetSoundId()/GetSoundItem() + LOG_L(L_ERROR, "re-enabling sound isn't supported yet, expect problems!"); + } + Shutdown(); + configHandler->Set("Sound", IsNullAudio()); + Initialize(); + return IsNullAudio(); +} + +bool ISound::LoadSoundDefs(const std::string& filename) +{ + sounddefs.push_back(filename); + return singleton->LoadSoundDefsImpl(filename); +} + diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/ISound.h spring-98.0~14.04~ppa6/rts/System/Sound/ISound.h --- spring-96.0~14.04~ppa4/rts/System/Sound/ISound.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/ISound.h 2014-10-07 20:09:51.000000000 +0000 @@ -48,16 +48,22 @@ virtual bool Mute() = 0; virtual bool IsMuted() const = 0; + ///change current output device + static bool ChangeOutput(); + virtual void Iconified(bool state) = 0; virtual void PrintDebugInfo() = 0; - virtual bool LoadSoundDefs(const std::string& fileName) = 0; + bool LoadSoundDefs(const std::string& fileName); virtual const float3& GetListenerPos() const = 0; public: unsigned numEmptyPlayRequests; unsigned numAbortedPlays; +private: + virtual bool LoadSoundDefsImpl(const std::string& fileName) = 0; + static bool IsNullAudio(); }; #define sound ISound::GetInstance() diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/Null/NullAudioChannel.h spring-98.0~14.04~ppa6/rts/System/Sound/Null/NullAudioChannel.h --- spring-96.0~14.04~ppa4/rts/System/Sound/Null/NullAudioChannel.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/Null/NullAudioChannel.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,39 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef NULL_AUDIO_CHANNEL_H +#define NULL_AUDIO_CHANNEL_H + +#include "System/Sound/IAudioChannel.h" + + +class NullAudioChannel : public IAudioChannel { +public: + ~NullAudioChannel() {} + + void Enable(bool newState) {} + void SetVolume(float newVolume) {} + + void PlaySample(size_t id, float volume = 1.0f) {} + void PlaySample(size_t id, const float3& p, float volume = 1.0f) {} + void PlaySample(size_t id, const float3& p, const float3& velocity, float volume = 1.0f) {} + + void PlaySample(size_t id, const CWorldObject* p, float volume = 1.0f) {} + + void PlayRandomSample(const GuiSoundSet& soundSet, const CWorldObject* obj) {} + void PlayRandomSample(const GuiSoundSet& soundSet, const float3& pos) {} + + void StreamPlay(const std::string& path, float volume = 1.0f, bool enqueue = false) {} + + void StreamStop() {} + void StreamPause() {} + float StreamGetTime() { return 0.f; } + float StreamGetPlayTime() { return 0.f; } + +protected: + void FindSourceAndPlay(size_t id, const float3& p, const float3& velocity, float volume, bool relative) {} + + void SoundSourceFinished(CSoundSource* sndSource) {} + friend class CSoundSource; +}; + +#endif // NULL_AUDIO_CHANNEL_H diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/Null/NullSound.cpp spring-98.0~14.04~ppa6/rts/System/Sound/Null/NullSound.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/Null/NullSound.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/Null/NullSound.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,61 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include "NullSound.h" +#include "NullAudioChannel.h" + +#include "System/Sound/SoundLog.h" +#include "System/float3.h" + + +NullSound::NullSound() { +} + +NullSound::~NullSound() { +} + +bool NullSound::HasSoundItem(const std::string& name) const { + return false; +} + +size_t NullSound::GetSoundId(const std::string& name) { + return 0; +} + +CSoundSource* NullSound::GetNextBestSource(bool lock) { + return NULL; +} + +void NullSound::PitchAdjust(const float newPitch) { +} + +void NullSound::ConfigNotify(const std::string& key, const std::string& value) { +} + +bool NullSound::Mute() { + return true; +} + +bool NullSound::IsMuted() const { + return true; +} + +void NullSound::Iconified(bool state) { +} + +void NullSound::UpdateListener(const float3& campos, const float3& camdir, const float3& camup, float lastFrameTime) { +} + +void NullSound::PrintDebugInfo() { + LOG("Null Sound System"); +} + +bool NullSound::LoadSoundDefsImpl(const std::string& fileName) { + return false; +} + +void NullSound::NewFrame() { +} + +const float3& NullSound::GetListenerPos() const { + return ZeroVector; +} diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/Null/NullSound.h spring-98.0~14.04~ppa6/rts/System/Sound/Null/NullSound.h --- spring-96.0~14.04~ppa4/rts/System/Sound/Null/NullSound.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/Null/NullSound.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,43 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef _NULL_SOUND_H_ +#define _NULL_SOUND_H_ + +#include "System/Sound/ISound.h" + +#include + +class float3; +class CSoundSource; + +/// Empty sound system implementation +class NullSound : public ISound +{ +public: + NullSound(); + virtual ~NullSound(); + + bool HasSoundItem(const std::string& name) const; + size_t GetSoundId(const std::string& name); + SoundItem* GetSoundItem(size_t id) const { return NULL; } + + CSoundSource* GetNextBestSource(bool lock = true); + + void UpdateListener(const float3& campos, const float3& camdir, const float3& camup, float lastFrameTime); + void NewFrame(); + + void ConfigNotify(const std::string& key, const std::string& value); + void PitchAdjust(const float newPitch); + + bool Mute(); + bool IsMuted() const; + + void Iconified(bool state); + + void PrintDebugInfo(); + bool LoadSoundDefsImpl(const std::string& fileName); + + const float3& GetListenerPos() const; +}; + +#endif // _NULL_SOUND_H_ diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/Null/SoundChannels.cpp spring-98.0~14.04~ppa6/rts/System/Sound/Null/SoundChannels.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/Null/SoundChannels.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/Null/SoundChannels.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,12 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include "NullAudioChannel.h" + +namespace Channels +{ + NullAudioChannel* BGMusic = NULL; + NullAudioChannel* General = NULL; + NullAudioChannel* Battle = NULL; + NullAudioChannel* UnitReply = NULL; + NullAudioChannel* UserInterface = NULL; +} diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/NullAudioChannel.h spring-98.0~14.04~ppa6/rts/System/Sound/NullAudioChannel.h --- spring-96.0~14.04~ppa4/rts/System/Sound/NullAudioChannel.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/NullAudioChannel.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#ifndef NULL_AUDIO_CHANNEL_H -#define NULL_AUDIO_CHANNEL_H - -#include "IAudioChannel.h" - - -class NullAudioChannel : public IAudioChannel { -public: - void Enable(bool newState) {} - void SetVolume(float newVolume) {} - - void PlaySample(size_t id, float volume = 1.0f) {} - void PlaySample(size_t id, const float3& p, float volume = 1.0f) {} - void PlaySample(size_t id, const float3& p, const float3& velocity, float volume = 1.0f) {} - - void PlaySample(size_t id, const CWorldObject* p, float volume = 1.0f) {} - - void PlayRandomSample(const GuiSoundSet& soundSet, const CWorldObject* obj) {} - void PlayRandomSample(const GuiSoundSet& soundSet, const float3& pos) {} - - void StreamPlay(const std::string& path, float volume = 1.0f, bool enqueue = false) {} - - void StreamStop() {} - void StreamPause() {} - float StreamGetTime() { return 0.f; } - float StreamGetPlayTime() { return 0.f; } - -protected: - void FindSourceAndPlay(size_t id, const float3& p, const float3& velocity, float volume, bool relative) {} - - void SoundSourceFinished(CSoundSource* sndSource) {} - friend class CSoundSource; -}; - -#endif // NULL_AUDIO_CHANNEL_H diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/NullSound.cpp spring-98.0~14.04~ppa6/rts/System/Sound/NullSound.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/NullSound.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/NullSound.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#include "NullSound.h" - -#include "SoundLog.h" -#include "System/float3.h" - - -NullSound::NullSound() { -} - -NullSound::~NullSound() { -} - -bool NullSound::HasSoundItem(const std::string& name) const { - return false; -} - -size_t NullSound::GetSoundId(const std::string& name) { - return 0; -} - -CSoundSource* NullSound::GetNextBestSource(bool lock) { - return NULL; -} - -void NullSound::PitchAdjust(const float newPitch) { -} - -void NullSound::ConfigNotify(const std::string& key, const std::string& value) { -} - -bool NullSound::Mute() { - return true; -} - -bool NullSound::IsMuted() const { - return true; -} - -void NullSound::Iconified(bool state) { -} - -void NullSound::UpdateListener(const float3& campos, const float3& camdir, const float3& camup, float lastFrameTime) { -} - -void NullSound::PrintDebugInfo() { - LOG("Null Sound System"); -} - -bool NullSound::LoadSoundDefs(const std::string& fileName) { - return false; -} - -void NullSound::NewFrame() { -} - -const float3& NullSound::GetListenerPos() const { - return ZeroVector; -} diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/NullSound.h spring-98.0~14.04~ppa6/rts/System/Sound/NullSound.h --- spring-96.0~14.04~ppa4/rts/System/Sound/NullSound.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/NullSound.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#ifndef _NULL_SOUND_H_ -#define _NULL_SOUND_H_ - -#include "ISound.h" - -#include - -class float3; -class CSoundSource; - -/// Empty sound system implementation -class NullSound : public ISound -{ -public: - NullSound(); - virtual ~NullSound(); - - bool HasSoundItem(const std::string& name) const; - size_t GetSoundId(const std::string& name); - SoundItem* GetSoundItem(size_t id) const { return NULL; } - - CSoundSource* GetNextBestSource(bool lock = true); - - void UpdateListener(const float3& campos, const float3& camdir, const float3& camup, float lastFrameTime); - void NewFrame(); - - void ConfigNotify(const std::string& key, const std::string& value); - void PitchAdjust(const float newPitch); - - bool Mute(); - bool IsMuted() const; - - void Iconified(bool state); - - void PrintDebugInfo(); - bool LoadSoundDefs(const std::string& fileName); - - const float3& GetListenerPos() const; -}; - -#endif // _NULL_SOUND_H_ diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/OggStream.cpp spring-98.0~14.04~ppa6/rts/System/Sound/OggStream.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/OggStream.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/OggStream.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,340 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#include "OggStream.h" - -#include "System/FileSystem/FileHandler.h" -#include "SoundLog.h" -#include "ALShared.h" -#include "VorbisShared.h" - - -namespace VorbisCallbacks { - size_t VorbisStreamRead(void* ptr, size_t size, size_t nmemb, void* datasource) - { - CFileHandler* buffer = static_cast(datasource); - return buffer->Read(ptr, size * nmemb); - } - - int VorbisStreamClose(void* datasource) - { - CFileHandler* buffer = static_cast(datasource); - delete buffer; - return 0; - } - - int VorbisStreamSeek(void* datasource, ogg_int64_t offset, int whence) - { - CFileHandler* buffer = static_cast(datasource); - if (whence == SEEK_SET) - { - buffer->Seek(offset, std::ios_base::beg); - } - else if (whence == SEEK_CUR) - { - buffer->Seek(offset, std::ios_base::cur); - } - else if (whence == SEEK_END) - { - buffer->Seek(offset, std::ios_base::end); - } - - return 0; - } - - long VorbisStreamTell(void* datasource) - { - CFileHandler* buffer = static_cast(datasource); - return buffer->GetPos(); - } - -} - - - -COggStream::COggStream(ALuint _source) - : vorbisInfo(NULL) - , source(_source) - , format(AL_FORMAT_MONO16) - , stopped(true) - , paused(false) -{ - for (unsigned i = 0; i < NUM_BUFFERS; ++i) { - buffers[i] = 0; - } - for (unsigned i = 0; i < BUFFER_SIZE; ++i) { - pcmDecodeBuffer[i] = 0; - } -} - -COggStream::~COggStream() -{ - Stop(); -} - -// open an Ogg stream from a given file and start playing it -void COggStream::Play(const std::string& path, float volume) -{ - if (!stopped) { - // we're already playing another stream - return; - } - - vorbisTags.clear(); - - ov_callbacks vorbisCallbacks; - vorbisCallbacks.read_func = VorbisCallbacks::VorbisStreamRead; - vorbisCallbacks.close_func = VorbisCallbacks::VorbisStreamClose; - vorbisCallbacks.seek_func = VorbisCallbacks::VorbisStreamSeek; - vorbisCallbacks.tell_func = VorbisCallbacks::VorbisStreamTell; - - CFileHandler* buf = new CFileHandler(path); - const int result = ov_open_callbacks(buf, &oggStream, NULL, 0, vorbisCallbacks); - if (result < 0) { - LOG_L(L_WARNING, "Could not open Ogg stream (reason: %s).", - ErrorString(result).c_str()); - return; - } - - - vorbisInfo = ov_info(&oggStream, -1); - { - vorbis_comment* vorbisComment; - vorbisComment = ov_comment(&oggStream, -1); - vorbisTags.resize(vorbisComment->comments); - - for (unsigned i = 0; i < vorbisComment->comments; ++i) { - vorbisTags[i] = std::string(vorbisComment->user_comments[i], vorbisComment->comment_lengths[i]); - } - - vendor = std::string(vorbisComment->vendor); - // DisplayInfo(); - } - - if (vorbisInfo->channels == 1) { - format = AL_FORMAT_MONO16; - } else { - format = AL_FORMAT_STEREO16; - } - - alGenBuffers(2, buffers); CheckError("COggStream::Play"); - - if (!StartPlaying()) { - ReleaseBuffers(); - } else { - stopped = false; - paused = false; - } - - CheckError("COggStream::Play"); -} - -float COggStream::GetPlayTime() const -{ - return msecsPlayed.toSecsf(); -} - -float COggStream::GetTotalTime() -{ - return ov_time_total(&oggStream, -1); -} - -bool COggStream::Valid() const -{ - return (vorbisInfo != 0); -} - -bool COggStream::IsFinished() -{ - return !Valid() || (GetPlayTime() >= GetTotalTime()); -} - -const COggStream::TagVector& COggStream::VorbisTags() const -{ - return vorbisTags; -} - -// display Ogg info and comments -void COggStream::DisplayInfo() -{ - LOG("version: %d", vorbisInfo->version); - LOG("channels: %d", vorbisInfo->channels); - LOG("time (sec): %lf", ov_time_total(&oggStream,-1)); - LOG("rate (Hz): %ld", vorbisInfo->rate); - LOG("bitrate (upper): %ld", vorbisInfo->bitrate_upper); - LOG("bitrate (nominal): %ld", vorbisInfo->bitrate_nominal); - LOG("bitrate (lower): %ld", vorbisInfo->bitrate_lower); - LOG("bitrate (window): %ld", vorbisInfo->bitrate_window); - LOG("vendor: %s", vendor.c_str()); - - for (TagVector::const_iterator it = vorbisTags.begin(); it != vorbisTags.end(); ++it) { - LOG("%s", it->c_str()); - } -} - - -// clean up the OpenAL resources -void COggStream::ReleaseBuffers() -{ - stopped = true; - paused = false; - - EmptyBuffers(); - - alDeleteBuffers(2, buffers); - CheckError("COggStream::ReleaseBuffers"); - - ov_clear(&oggStream); -} - - -// returns true if both buffers were -// filled with data from the stream -bool COggStream::StartPlaying() -{ - msecsPlayed = spring_nulltime; - lastTick = spring_gettime(); - - if (!DecodeStream(buffers[0])) { return false; } - if (!DecodeStream(buffers[1])) { return false; } - - alSourceQueueBuffers(source, 2, buffers); CheckError("COggStream::StartPlaying"); - alSourcePlay(source); CheckError("COggStream::StartPlaying"); - - return true; -} - - -// returns true if we're still playing -bool COggStream::IsPlaying() -{ - ALenum state = 0; - alGetSourcei(source, AL_SOURCE_STATE, &state); - - return (state == AL_PLAYING); -} - -// stops the currently playing stream -void COggStream::Stop() -{ - if (stopped) { - return; - } - - ReleaseBuffers(); - msecsPlayed = spring_nulltime; - vorbisInfo = NULL; - lastTick = spring_gettime(); -} - -bool COggStream::TogglePause() -{ - if (!stopped) { - paused = !paused; - } - - return paused; -} - - -// pop the processed buffers from the queue, -// refill them, and push them back in line -bool COggStream::UpdateBuffers() -{ - int buffersProcessed = 0; - bool active = true; - - alGetSourcei(source, AL_BUFFERS_PROCESSED, &buffersProcessed); - - while (buffersProcessed-- > 0) { - ALuint buffer; - alSourceUnqueueBuffers(source, 1, &buffer); CheckError("COggStream::UpdateBuffers"); - - // false if we've reached end of stream - active = DecodeStream(buffer); - if (active) - alSourceQueueBuffers(source, 1, &buffer); CheckError("COggStream::UpdateBuffers"); - } - CheckError("COggStream::UpdateBuffers"); - - return active; -} - - -void COggStream::Update() -{ - if (stopped) { - return; - } - - spring_time tick = spring_gettime(); - - if (!paused) { - if (UpdateBuffers()) { - if (!IsPlaying()) { - // source state changed - if (!StartPlaying()) { - // stream stopped - ReleaseBuffers(); - } else { - // stream interrupted - ReleaseBuffers(); - } - } - } else if (!IsPlaying()) { - // EOS and all chunks processed by OpenALs - ReleaseBuffers(); - } - - msecsPlayed += (tick - lastTick); - } - - lastTick = tick; -} - - -// read decoded data from audio stream into PCM buffer -bool COggStream::DecodeStream(ALuint buffer) -{ - memset(pcmDecodeBuffer, 0, BUFFER_SIZE); - - int size = 0; - int section = 0; - int result = 0; - - while (size < BUFFER_SIZE) { - result = ov_read(&oggStream, pcmDecodeBuffer + size, BUFFER_SIZE - size, 0, 2, 1, §ion); - - if (result > 0) { - size += result; - } else { - if (result < 0) { - LOG_L(L_WARNING, "Error reading Ogg stream (%s)", - ErrorString(result).c_str()); - } else { - break; - } - } - } - - if (size == 0) { - return false; - } - - alBufferData(buffer, format, pcmDecodeBuffer, size, vorbisInfo->rate); - CheckError("COggStream::DecodeStream"); - - return true; -} - - -// dequeue any buffers pending on source -void COggStream::EmptyBuffers() -{ - int queuedBuffers = 0; - alGetSourcei(source, AL_BUFFERS_QUEUED, &queuedBuffers); CheckError("COggStream::EmptyBuffers"); - - while (queuedBuffers-- > 0) { - ALuint buffer; - alSourceUnqueueBuffers(source, 1, &buffer); CheckError("COggStream::EmptyBuffers"); - } -} diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/OggStream.h spring-98.0~14.04~ppa6/rts/System/Sound/OggStream.h --- spring-96.0~14.04~ppa4/rts/System/Sound/OggStream.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/OggStream.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#ifndef OGG_STREAM_H -#define OGG_STREAM_H - -#include "System/Misc/SpringTime.h" - -#include -#include -#include - -#include -#include - - -class COggStream -{ -public: - typedef std::vector TagVector; - COggStream(ALuint _source); - ~COggStream(); - - void Play(const std::string& path, float volume); - void Stop(); - bool TogglePause(); - void Update(); - - float GetPlayTime() const; - float GetTotalTime(); - bool Valid() const; - bool IsFinished(); - - const TagVector& VorbisTags() const; - -private: - void DisplayInfo(); - bool IsPlaying(); - bool StartPlaying(); - - bool DecodeStream(ALuint buffer); - void EmptyBuffers(); - void ReleaseBuffers(); - - /** - * @brief Decode next part of the stream and queue it for playing - * @return whether it is the end of the stream - * (check for IsPlaying() whether the complete stream was played) - */ - bool UpdateBuffers(); - - OggVorbis_File oggStream; - vorbis_info* vorbisInfo; - - static const unsigned int BUFFER_SIZE = (512 * 1024); // 512KB - static const unsigned int NUM_BUFFERS = 2; - - char pcmDecodeBuffer[BUFFER_SIZE]; - - ALuint buffers[NUM_BUFFERS]; - ALuint source; - ALenum format; - - bool stopped; - bool paused; - - spring_time msecsPlayed; - spring_time lastTick; - - std::vector vorbisTags; - std::string vendor; -}; - -#endif // OGG_STREAM_H diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/ALShared.cpp spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/ALShared.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/ALShared.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/ALShared.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,37 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include "ALShared.h" + +#include "System/Sound/SoundLog.h" + +#include + +bool CheckError(const char* msg) +{ + ALenum e = alGetError(); + const char* err; + switch(e) { + case AL_INVALID_NAME: + err = "AL_INVALID_NAME"; + break; + case AL_INVALID_ENUM: + err = "AL_INVALID_ENUM"; + break; + case AL_INVALID_VALUE: + err = "AL_INVALID_VALUE"; + break; + case AL_INVALID_OPERATION: + err = "AL_INVALID_OPERATION"; + break; + case AL_OUT_OF_MEMORY: + err = "AL_OUT_OF_MEMORY"; + break; + default: + err = "Unknown error"; + break; + case AL_NO_ERROR: + return true; + } + LOG_L(L_ERROR, "%s: %s (%d)", msg, err, e); + return false; +} diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/ALShared.h spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/ALShared.h --- spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/ALShared.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/ALShared.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,10 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef _AL_SHARED_H_ +#define _AL_SHARED_H_ + +#include + +bool CheckError(const char* msg); + +#endif // _AL_SHARED_H_ diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/AudioChannel.cpp spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/AudioChannel.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/AudioChannel.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/AudioChannel.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,235 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include "AudioChannel.h" + +#include "ALShared.h" +#include "System/Sound/ISound.h" +#include "SoundItem.h" +#include "System/Sound/SoundLog.h" +#include "SoundSource.h" +#include "Sim/Misc/GuiSoundSet.h" +#include "Sim/Objects/WorldObject.h" + +#include + +extern boost::recursive_mutex soundMutex; + +const size_t AudioChannel::MAX_STREAM_QUEUESIZE = 10; + + +AudioChannel::AudioChannel() + : curStreamSrc(NULL) +{ +} + + +void AudioChannel::SetVolume(float newVolume) +{ + volume = std::max(newVolume, 0.f); + + if (cur_sources.empty()) + return; + + boost::recursive_mutex::scoped_lock lck(soundMutex); + + for (std::map::iterator it = cur_sources.begin(); it != cur_sources.end(); ++it) { + it->first->UpdateVolume(); + } + CheckError("AudioChannel::SetVolume"); +} + + +void AudioChannel::Enable(bool newState) +{ + boost::recursive_mutex::scoped_lock lck(soundMutex); + + enabled = newState; + + if (!enabled) { + SetVolume(0.f); + } +} + + +void AudioChannel::SoundSourceFinished(CSoundSource* sndSource) +{ + if (curStreamSrc == sndSource) { + if (!streamQueue.empty()) { + StreamQueueItem& next = streamQueue.back(); + StreamPlay(next.fileName, next.volume, false); + streamQueue.pop_back(); + } else { + curStreamSrc = NULL; + } + } + + cur_sources.erase(sndSource); +} + + +void AudioChannel::FindSourceAndPlay(size_t id, const float3& pos, const float3& velocity, float volume, bool relative) +{ + boost::recursive_mutex::scoped_lock lck(soundMutex); + + if (!enabled) + return; + + if (volume <= 0.0f) + return; + + SoundItem* sndItem = sound->GetSoundItem(id); + if (!sndItem) { + sound->numEmptyPlayRequests++; + return; + } + + if (pos.distance(sound->GetListenerPos()) > sndItem->MaxDistance()) { + if (!relative) { + return; + } else { + LOG("CSound::PlaySample: maxdist ignored for relative playback: %s", + sndItem->Name().c_str()); + } + } + + if (emmitsThisFrame >= emmitsPerFrame) + return; + emmitsThisFrame++; + + if (cur_sources.size() >= maxConcurrentSources) { + CSoundSource* src = NULL; + int prio = INT_MAX; + for (std::map::iterator it = cur_sources.begin(); it != cur_sources.end(); ++it) { + if (it->first->GetCurrentPriority() < prio) { + src = it->first; + prio = it->first->GetCurrentPriority(); + } + } + + if (src && prio <= sndItem->GetPriority()) { + src->Stop(); + } else { + LOG_L(L_DEBUG, "CSound::PlaySample: Max concurrent sounds in channel reached! Dropping playback!"); + return; + } + } + + CSoundSource* sndSource = sound->GetNextBestSource(); + if (!sndSource) { + LOG_L(L_DEBUG, "CSound::PlaySample: Max sounds reached! Dropping playback!"); + return; + } + + if (sndSource->GetCurrentPriority() < sndItem->GetPriority()) { + if (sndSource->IsPlaying()) + sound->numAbortedPlays++; + + sndSource->Play(this, sndItem, pos, velocity, volume, relative); + CheckError("CSound::FindSourceAndPlay"); + + cur_sources[sndSource] = true; + } +} + +void AudioChannel::PlaySample(size_t id, float volume) +{ + FindSourceAndPlay(id, -FwdVector, ZeroVector, volume, true); +} + +void AudioChannel::PlaySample(size_t id, const float3& pos, float volume) +{ + FindSourceAndPlay(id, pos, ZeroVector, volume, false); +} + +void AudioChannel::PlaySample(size_t id, const float3& pos, const float3& velocity, float volume) +{ + FindSourceAndPlay(id, pos, velocity, volume, false); +} + + +void AudioChannel::PlaySample(size_t id, const CWorldObject* obj, float volume) +{ + FindSourceAndPlay(id, obj->pos, obj->speed, volume, false); +} + + +void AudioChannel::PlayRandomSample(const GuiSoundSet& soundSet, const CWorldObject* obj) +{ + PlayRandomSample(soundSet, obj->pos); +} + +void AudioChannel::PlayRandomSample(const GuiSoundSet& soundSet, const float3& pos) +{ + const int soundIdx = soundSet.getRandomIdx(); + + if (soundIdx < 0) + return; + + const int soundID = soundSet.getID(soundIdx); + const float soundVol = soundSet.getVolume(soundIdx); + + PlaySample(soundID, pos, soundVol); +} + + +void AudioChannel::StreamPlay(const std::string& filepath, float volume, bool enqueue) +{ + boost::recursive_mutex::scoped_lock lck(soundMutex); + + if (!enabled) + return; + + if (curStreamSrc && enqueue) { + if (streamQueue.size() > MAX_STREAM_QUEUESIZE) { + streamQueue.resize(MAX_STREAM_QUEUESIZE); + streamQueue.pop_back(); //! make room for the new item + } + StreamQueueItem newItem(filepath, volume); + streamQueue.push_back(newItem); + return; + } + + if (!curStreamSrc) + curStreamSrc = sound->GetNextBestSource(); //! may return 0 if no sources available + + if (curStreamSrc) { + cur_sources[curStreamSrc] = true; //! This one first, PlayStream may invoke Stop immediately thus setting curStreamSrc to NULL + curStreamSrc->PlayStream(this, filepath, volume); + } +} + +void AudioChannel::StreamPause() +{ + boost::recursive_mutex::scoped_lock lck(soundMutex); + + if (curStreamSrc) + curStreamSrc->StreamPause(); +} + +void AudioChannel::StreamStop() +{ + boost::recursive_mutex::scoped_lock lck(soundMutex); + + if (curStreamSrc) + curStreamSrc->StreamStop(); +} + +float AudioChannel::StreamGetTime() +{ + boost::recursive_mutex::scoped_lock lck(soundMutex); + + if (curStreamSrc) + return curStreamSrc->GetStreamTime(); + else + return 0.0f; +} + +float AudioChannel::StreamGetPlayTime() +{ + boost::recursive_mutex::scoped_lock lck(soundMutex); + + if (curStreamSrc) + return curStreamSrc->GetStreamPlayTime(); + else + return 0.0f; +} diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/AudioChannel.h spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/AudioChannel.h --- spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/AudioChannel.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/AudioChannel.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,76 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef AUDIO_CHANNEL_H +#define AUDIO_CHANNEL_H + +#include +#include +#include + +#include "System/Sound/IAudioChannel.h" +#include + +struct GuiSoundSet; +class CSoundSource; +class CWorldObject; + +/** + * @brief Channel for playing sounds + * + * Has its own volume "slider", and can be enabled / disabled seperately. + * Abstract base class. + */ +class AudioChannel : public IAudioChannel { +public: + AudioChannel(); + ~AudioChannel() {} + + void Enable(bool newState); + void SetVolume(float newVolume); + + void PlaySample(size_t id, float volume = 1.0f); + void PlaySample(size_t id, const float3& pos, float volume = 1.0f); + void PlaySample(size_t id, const float3& pos, const float3& velocity, float volume = 1.0f); + + void PlaySample(size_t id, const CWorldObject* obj, float volume = 1.0f); + + void PlayRandomSample(const GuiSoundSet& soundSet, const CWorldObject* obj); + void PlayRandomSample(const GuiSoundSet& soundSet, const float3& pos); + + void StreamPlay(const std::string& path, float volume = 1.0f, bool enqueue = false); + + /** + * @brief Stop playback + * + * Do not call this if you just want to play another file (for performance). + */ + void StreamStop(); + void StreamPause(); + float StreamGetTime(); + float StreamGetPlayTime(); + +protected: + void FindSourceAndPlay(size_t id, const float3& pos, const float3& velocity, float volume, bool relative); + + void SoundSourceFinished(CSoundSource* sndSource); + +private: + std::map cur_sources; + + //! streams + struct StreamQueueItem { + StreamQueueItem() : volume(0.f) {} + StreamQueueItem(const std::string& fileName, float& volume) + : fileName(fileName) + , volume(volume) + {} + std::string fileName; + float volume; + }; + + CSoundSource* curStreamSrc; + std::vector streamQueue; + static const size_t MAX_STREAM_QUEUESIZE; +}; + +#endif // AUDIO_CHANNEL_H diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/EFX.cpp spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/EFX.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/EFX.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/EFX.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,281 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include "EFX.h" + +#include "ALShared.h" +#include "EFXPresets.h" +#include "EFXfuncs.h" + +#include "System/Sound/SoundLog.h" +#include "System/Config/ConfigHandler.h" +#include "System/myMath.h" + + +/******************************************************************************/ +/******************************************************************************/ + +CONFIG(float, snd_airAbsorption).defaultValue(0.1f); +CONFIG(bool, UseEFX).defaultValue(true).safemodeValue(false); + +static std::string default_preset = "outdoors_valley";//"bathroom"; + +/******************************************************************************/ +/******************************************************************************/ + +CEFX* efx = NULL; +float CEFX::heightRolloffModifier = 1.f; + +CEFX::CEFX(ALCdevice* device) + :enabled(false) + ,supported(false) + ,sfxProperties(NULL) + ,sfxSlot(0) + ,sfxReverb(0) + ,sfxFilter(0) + ,updates(0) + ,maxSlots(0) + ,maxSlotsPerSource(0) +{ + SetAirAbsorptionFactor(configHandler->GetFloat("snd_airAbsorption")); + + bool hasExtension = alcIsExtensionPresent(device, "ALC_EXT_EFX"); + + if(hasExtension && alGenEffects && alDeleteEffects) + supported = true; + + //! set default preset + eaxPresets["default"] = eaxPresets[default_preset]; + + //! always allocate this + sfxProperties = new EAXSfxProps(); + *sfxProperties = eaxPresets[default_preset]; + + if (!supported) { + if(!hasExtension) { + LOG(" EFX Supported: no"); + } else { + LOG(" EFX is supported but software does not seem to work properly"); + } + return; + } + + //! clear log + alGetError() ; + + //! Check Available Effects + { + static const ALuint effects[] = { + AL_EFFECT_REVERB, + AL_EFFECT_EAXREVERB, + AL_EFFECT_CHORUS, + AL_EFFECT_DISTORTION, + AL_EFFECT_ECHO, + AL_EFFECT_FLANGER, + AL_EFFECT_FREQUENCY_SHIFTER, + AL_EFFECT_VOCAL_MORPHER, + AL_EFFECT_PITCH_SHIFTER, + AL_EFFECT_RING_MODULATOR, + AL_EFFECT_AUTOWAH, + AL_EFFECT_COMPRESSOR, + AL_EFFECT_EQUALIZER + }; + + ALuint alFx; + alGenEffects(1, &alFx); + if (alGetError() == AL_NO_ERROR) { + for(size_t i = 0; i < sizeof(effects)/sizeof(effects[0]); i++) { + const ALuint fx = effects[i]; + alEffecti(alFx, AL_EFFECT_TYPE, fx); + effectsSupported[fx] = (alGetError() == AL_NO_ERROR); + } + } + alDeleteEffects(1, &alFx); + } + + //! Check Available Filters + { + static const ALuint filters[] = { + AL_FILTER_LOWPASS, + AL_FILTER_HIGHPASS, + AL_FILTER_BANDPASS + }; + + ALuint alFilter; + alGenFilters(1, &alFilter); + if (alGetError() == AL_NO_ERROR) { + for(size_t i = 0; i < sizeof(filters)/sizeof(filters[0]); i++) { + const ALuint filter = filters[i]; + alFilteri(alFilter, AL_FILTER_TYPE, filter); + filtersSupported[filter] = (alGetError() == AL_NO_ERROR); + } + } + alDeleteFilters(1, &alFilter); + } + + //! Check Max Available EffectSlots + { + int n; + ALuint alFXSlots[128]; + for (n = 0; n < 128; n++) { + alGenAuxiliaryEffectSlots(1, &alFXSlots[n]); + if (alGetError() != AL_NO_ERROR) + break; + } + maxSlots = n; + + alDeleteAuxiliaryEffectSlots(n, alFXSlots); + } + + //! Check Max AUX FX SLOTS Per Sound Source + alcGetIntegerv(device, ALC_MAX_AUXILIARY_SENDS, 1, (ALCint*)&maxSlotsPerSource); + + + //! Check requirements + if (!effectsSupported[AL_EFFECT_EAXREVERB] + || !filtersSupported[AL_FILTER_LOWPASS] + || (maxSlots<1) + || (maxSlotsPerSource<1) + ) { + if (enabled) { + LOG_L(L_WARNING, " EFX Supported: no"); + } + supported = false; + return; + } + + + //! Create our global sfx enviroment + alGenAuxiliaryEffectSlots(1, &sfxSlot); + alGenEffects(1, &sfxReverb); + alEffecti(sfxReverb, AL_EFFECT_TYPE, AL_EFFECT_EAXREVERB); + alGenFilters(1, &sfxFilter); + alFilteri(sfxFilter, AL_FILTER_TYPE, AL_FILTER_LOWPASS); + if (!alIsAuxiliaryEffectSlot(sfxSlot) || !alIsEffect(sfxReverb) || !alIsFilter(sfxFilter)) { + LOG_L(L_ERROR, " Initializing EFX failed!"); + alDeleteFilters(1, &sfxFilter); + alDeleteEffects(1, &sfxReverb); + alDeleteAuxiliaryEffectSlots(1, &sfxSlot); + supported = false; + return; + } + + + //! Load defaults + CommitEffects(); + if (!CheckError(" EFX")) { + LOG_L(L_ERROR, " Initializing EFX failed!"); + alAuxiliaryEffectSloti(sfxSlot, AL_EFFECTSLOT_EFFECT, AL_EFFECT_NULL); + alDeleteFilters(1, &sfxFilter); + alDeleteEffects(1, &sfxReverb); + alDeleteAuxiliaryEffectSlots(1, &sfxSlot); + supported = false; + return; + } + + //! User may disable it (performance reasons?) + enabled = configHandler->GetBool("UseEFX"); + LOG(" EFX Enabled: %s", (enabled ? "yes" : "no")); + if (enabled) { + LOG_L(L_DEBUG, " EFX MaxSlots: %i", maxSlots); + LOG_L(L_DEBUG, " EFX MaxSlotsPerSource: %i", maxSlotsPerSource); + } + + configHandler->NotifyOnChange(this); +} + + +CEFX::~CEFX() +{ + configHandler->RemoveObserver(this); + if (supported) { + alAuxiliaryEffectSloti(sfxSlot, AL_EFFECTSLOT_EFFECT, AL_EFFECT_NULL); + alDeleteFilters(1, &sfxFilter); + alDeleteEffects(1, &sfxReverb); + alDeleteAuxiliaryEffectSlots(1, &sfxSlot); + } + delete sfxProperties; +} + + +void CEFX::Enable() +{ + if (supported && !enabled) { + enabled = true; + CommitEffects(); + LOG("EAX enabled"); + } +} + + +void CEFX::Disable() +{ + if (enabled) { + enabled = false; + alAuxiliaryEffectSloti(sfxSlot, AL_EFFECTSLOT_EFFECT, AL_EFFECT_NULL); + LOG("EAX disabled"); + } +} + + +void CEFX::SetPreset(std::string name, bool verbose, bool commit) +{ + if (!supported) + return; + + + std::map::const_iterator it = eaxPresets.find(name); + if (it != eaxPresets.end()) { + *sfxProperties = it->second; + if (commit) + CommitEffects(); + if (verbose) + LOG("EAX Preset changed to: %s", name.c_str()); + } +} + + +void CEFX::SetHeightRolloffModifer(const float& mod) +{ + heightRolloffModifier = mod; + + if (!supported) + return; + + alEffectf(sfxReverb, AL_EAXREVERB_ROOM_ROLLOFF_FACTOR, sfxProperties->properties_f[AL_EAXREVERB_ROOM_ROLLOFF_FACTOR] * heightRolloffModifier); + alAuxiliaryEffectSloti(sfxSlot, AL_EFFECTSLOT_EFFECT, sfxReverb); +} + + +void CEFX::CommitEffects() +{ + if (!supported) + return; + + //! commit reverb properties + for (std::map::iterator it = sfxProperties->properties_f.begin(); it != sfxProperties->properties_f.end(); ++it) + alEffectf(sfxReverb, it->first, it->second); + for (std::map::iterator it = sfxProperties->properties_i.begin(); it != sfxProperties->properties_i.end(); ++it) + alEffecti(sfxReverb, it->first, it->second); + for (std::map::iterator it = sfxProperties->properties_v.begin(); it != sfxProperties->properties_v.end(); ++it) + alEffectfv(sfxReverb, it->first, (ALfloat*)&it->second[0]); + + alEffectf(sfxReverb, AL_EAXREVERB_ROOM_ROLLOFF_FACTOR, sfxProperties->properties_f[AL_EAXREVERB_ROOM_ROLLOFF_FACTOR] * heightRolloffModifier); + alAuxiliaryEffectSloti(sfxSlot, AL_EFFECTSLOT_EFFECT, sfxReverb); + + for (std::map::iterator it=sfxProperties->filter_properties_f.begin(); it != sfxProperties->filter_properties_f.end(); ++it) + alFilterf(sfxFilter, it->first, it->second); + + updates++; +} + +void CEFX::SetAirAbsorptionFactor(ALfloat value) +{ + airAbsorptionFactor = Clamp(value, AL_MIN_AIR_ABSORPTION_FACTOR, AL_MAX_AIR_ABSORPTION_FACTOR); +} + +void CEFX::ConfigNotify(const std::string& key, const std::string& value) +{ + if (key == "snd_airAbsorption") { + SetAirAbsorptionFactor(std::atof(value.c_str())); + } +} diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/EFXfuncs.cpp spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/EFXfuncs.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/EFXfuncs.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/EFXfuncs.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,79 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include "EFXfuncs.h" +#include "System/Util.h" + + +LPALGENEFFECTS alGenEffects = NULL; +LPALDELETEEFFECTS alDeleteEffects = NULL; +LPALISEFFECT alIsEffect = NULL; +LPALEFFECTI alEffecti = NULL; +LPALEFFECTIV alEffectiv = NULL; +LPALEFFECTF alEffectf = NULL; +LPALEFFECTFV alEffectfv = NULL; +LPALGETEFFECTI alGetEffecti = NULL; +LPALGETEFFECTIV alGetEffectiv = NULL; +LPALGETEFFECTF alGetEffectf = NULL; +LPALGETEFFECTFV alGetEffectfv = NULL; +LPALGENFILTERS alGenFilters = NULL; +LPALDELETEFILTERS alDeleteFilters = NULL; +LPALISFILTER alIsFilter = NULL; +LPALFILTERI alFilteri = NULL; +LPALFILTERIV alFilteriv = NULL; +LPALFILTERF alFilterf = NULL; +LPALFILTERFV alFilterfv = NULL; +LPALGETFILTERI alGetFilteri = NULL; +LPALGETFILTERIV alGetFilteriv = NULL; +LPALGETFILTERF alGetFilterf = NULL; +LPALGETFILTERFV alGetFilterfv = NULL; +LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots = NULL; +LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots = NULL; +LPALISAUXILIARYEFFECTSLOT alIsAuxiliaryEffectSlot = NULL; +LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti = NULL; +LPALAUXILIARYEFFECTSLOTIV alAuxiliaryEffectSlotiv = NULL; +LPALAUXILIARYEFFECTSLOTF alAuxiliaryEffectSlotf = NULL; +LPALAUXILIARYEFFECTSLOTFV alAuxiliaryEffectSlotfv = NULL; +LPALGETAUXILIARYEFFECTSLOTI alGetAuxiliaryEffectSloti = NULL; +LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv = NULL; +LPALGETAUXILIARYEFFECTSLOTF alGetAuxiliaryEffectSlotf = NULL; +LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv = NULL; + + +static void InitEfxProcAddr() +{ + alGenEffects = (LPALGENEFFECTS)alGetProcAddress("alGenEffects"); + alDeleteEffects = (LPALDELETEEFFECTS)alGetProcAddress("alDeleteEffects"); + alIsEffect = (LPALISEFFECT)alGetProcAddress("alIsEffect"); + alEffecti = (LPALEFFECTI)alGetProcAddress("alEffecti"); + alEffectiv = (LPALEFFECTIV)alGetProcAddress("alEffectiv"); + alEffectf = (LPALEFFECTF)alGetProcAddress("alEffectf"); + alEffectfv = (LPALEFFECTFV)alGetProcAddress("alEffectfv"); + alGetEffecti = (LPALGETEFFECTI)alGetProcAddress("alGetEffecti"); + alGetEffectiv = (LPALGETEFFECTIV)alGetProcAddress("alGetEffectiv"); + alGetEffectf = (LPALGETEFFECTF)alGetProcAddress("alGetEffectf"); + alGetEffectfv = (LPALGETEFFECTFV)alGetProcAddress("alGetEffectfv"); + alGenFilters = (LPALGENFILTERS)alGetProcAddress("alGenFilters"); + alDeleteFilters = (LPALDELETEFILTERS)alGetProcAddress("alDeleteFilters"); + alIsFilter = (LPALISFILTER)alGetProcAddress("alIsFilter"); + alFilteri = (LPALFILTERI)alGetProcAddress("alFilteri"); + alFilteriv = (LPALFILTERIV)alGetProcAddress("alFilteriv"); + alFilterf = (LPALFILTERF)alGetProcAddress("alFilterf"); + alFilterfv = (LPALFILTERFV)alGetProcAddress("alFilterfv"); + alGetFilteri = (LPALGETFILTERI)alGetProcAddress("alGetFilteri"); + alGetFilteriv= (LPALGETFILTERIV)alGetProcAddress("alGetFilteriv"); + alGetFilterf = (LPALGETFILTERF)alGetProcAddress("alGetFilterf"); + alGetFilterfv= (LPALGETFILTERFV)alGetProcAddress("alGetFilterfv"); + alGenAuxiliaryEffectSlots = (LPALGENAUXILIARYEFFECTSLOTS)alGetProcAddress("alGenAuxiliaryEffectSlots"); + alDeleteAuxiliaryEffectSlots = (LPALDELETEAUXILIARYEFFECTSLOTS)alGetProcAddress("alDeleteAuxiliaryEffectSlots"); + alIsAuxiliaryEffectSlot = (LPALISAUXILIARYEFFECTSLOT)alGetProcAddress("alIsAuxiliaryEffectSlot"); + alAuxiliaryEffectSloti = (LPALAUXILIARYEFFECTSLOTI)alGetProcAddress("alAuxiliaryEffectSloti"); + alAuxiliaryEffectSlotiv = (LPALAUXILIARYEFFECTSLOTIV)alGetProcAddress("alAuxiliaryEffectSlotiv"); + alAuxiliaryEffectSlotf = (LPALAUXILIARYEFFECTSLOTF)alGetProcAddress("alAuxiliaryEffectSlotf"); + alAuxiliaryEffectSlotfv = (LPALAUXILIARYEFFECTSLOTFV)alGetProcAddress("alAuxiliaryEffectSlotfv"); + alGetAuxiliaryEffectSloti = (LPALGETAUXILIARYEFFECTSLOTI)alGetProcAddress("alGetAuxiliaryEffectSloti"); + alGetAuxiliaryEffectSlotiv = (LPALGETAUXILIARYEFFECTSLOTIV)alGetProcAddress("alGetAuxiliaryEffectSlotiv"); + alGetAuxiliaryEffectSlotf = (LPALGETAUXILIARYEFFECTSLOTF)alGetProcAddress("alGetAuxiliaryEffectSlotf"); + alGetAuxiliaryEffectSlotfv = (LPALGETAUXILIARYEFFECTSLOTFV)alGetProcAddress("alGetAuxiliaryEffectSlotfv"); +} + +DO_ONCE(InitEfxProcAddr) diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/EFXfuncs.h spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/EFXfuncs.h --- spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/EFXfuncs.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/EFXfuncs.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,44 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef _EFX_FUNCS_H_ +#define _EFX_FUNCS_H_ + +#include +#include + +//! EFX Function Pointers +extern LPALGENEFFECTS alGenEffects; +extern LPALDELETEEFFECTS alDeleteEffects; +extern LPALISEFFECT alIsEffect; +extern LPALEFFECTI alEffecti; +extern LPALEFFECTIV alEffectiv; +extern LPALEFFECTF alEffectf; +extern LPALEFFECTFV alEffectfv; +extern LPALGETEFFECTI alGetEffecti; +extern LPALGETEFFECTIV alGetEffectiv; +extern LPALGETEFFECTF alGetEffectf; +extern LPALGETEFFECTFV alGetEffectfv; +extern LPALGENFILTERS alGenFilters; +extern LPALDELETEFILTERS alDeleteFilters; +extern LPALISFILTER alIsFilter; +extern LPALFILTERI alFilteri; +extern LPALFILTERIV alFilteriv; +extern LPALFILTERF alFilterf; +extern LPALFILTERFV alFilterfv; +extern LPALGETFILTERI alGetFilteri; +extern LPALGETFILTERIV alGetFilteriv; +extern LPALGETFILTERF alGetFilterf; +extern LPALGETFILTERFV alGetFilterfv; +extern LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots; +extern LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots; +extern LPALISAUXILIARYEFFECTSLOT alIsAuxiliaryEffectSlot; +extern LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti; +extern LPALAUXILIARYEFFECTSLOTIV alAuxiliaryEffectSlotiv; +extern LPALAUXILIARYEFFECTSLOTF alAuxiliaryEffectSlotf; +extern LPALAUXILIARYEFFECTSLOTFV alAuxiliaryEffectSlotfv; +extern LPALGETAUXILIARYEFFECTSLOTI alGetAuxiliaryEffectSloti; +extern LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv; +extern LPALGETAUXILIARYEFFECTSLOTF alGetAuxiliaryEffectSlotf; +extern LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv; + +#endif //_EFX_FUNCS_H_ diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/EFX.h spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/EFX.h --- spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/EFX.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/EFX.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,65 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef _EFX_H_ +#define _EFX_H_ + +#include +#include +#include +#include +#include + +struct EAXSfxProps; + +/// Default sound effects system implementation +class CEFX +{ +public: + CEFX(ALCdevice* device); + ~CEFX(); + + void SetPreset(std::string name, bool verbose = true, bool commit = true); + void CommitEffects(); + + void Enable(); + void Disable(); + + void SetHeightRolloffModifer(const float& mod); + +public: + /// @see ConfigHandler::ConfigNotifyCallback + void ConfigNotify(const std::string& key, const std::string& value); + + void SetAirAbsorptionFactor(ALfloat value); + ALfloat GetAirAbsorptionFactor() const { return airAbsorptionFactor; } + + + bool enabled; + bool supported; + + EAXSfxProps* sfxProperties; + ALuint sfxSlot; + ALuint sfxReverb; + ALuint sfxFilter; +private: + ALfloat airAbsorptionFactor; +public: + + int updates; + +private: + //! reduce the rolloff when the camera is height above the ground (so we still hear something in tab mode or far zoom) + static float heightRolloffModifier; + +private: + //! some more information about the supported features + std::map effectsSupported; + std::map filtersSupported; + int maxSlots; + ALuint maxSlotsPerSource; +}; + +//! init in Sound.cpp +extern CEFX* efx; + +#endif // _EFX_H_ diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/EFXPresets.cpp spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/EFXPresets.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/EFXPresets.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/EFXPresets.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,224 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include "EFXPresets.h" +#include "System/Util.h" + +std::map eaxPresets; + +std::map alParamType; +std::map nameToALParam; +std::map alParamToName; +std::map nameToALFilterParam; +std::map alFilterParamToName; + +static void InitPresets() +{ + //source: EFX-Util.h from the OpenAL1.1 SDK + + // STANDARD PRESETS + eaxPresets["generic"] = EAXSfxProps(1, 1, 0.316228, 0.891251, 1, 1.49, 0.83, 1, 0.0500035, 0.007, float3(0, 0, 0.3), 1.25893, 0.011, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["paddedcell"] = EAXSfxProps(0.1715, 1, 0.316228, 0.001, 1, 0.17, 0.1, 1, 0.250035, 0.001, float3(0, 0, 0.3), 1.26911, 0.002, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["room"] = EAXSfxProps(0.428687, 1, 0.316228, 0.592925, 1, 0.4, 0.83, 1, 0.150314, 0.002, float3(0, 0, 0.3), 1.06292, 0.003, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["bathroom"] = EAXSfxProps(0.1715, 1, 0.316228, 0.251189, 1, 1.49, 0.54, 1, 0.653131, 0.007, float3(0, 0, 0.3), 3.27341, 0.011, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["livingroom"] = EAXSfxProps(0.976562, 1, 0.316228, 0.001, 1, 0.5, 0.1, 1, 0.205116, 0.003, float3(0, 0, 0.3), 0.280543, 0.004, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["stoneroom"] = EAXSfxProps(1, 1, 0.316228, 0.707946, 1, 2.31, 0.64, 1, 0.441062, 0.012, float3(0, 0, 0.3), 1.10027, 0.017, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["auditorium"] = EAXSfxProps(1, 1, 0.316228, 0.578096, 1, 4.32, 0.59, 1, 0.403181, 0.02, float3(0, 0, 0.3), 0.716968, 0.03, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["concerthall"] = EAXSfxProps(1, 1, 0.316228, 0.562341, 1, 3.92, 0.7, 1, 0.242661, 0.02, float3(0, 0, 0.3), 0.9977, 0.029, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["cave"] = EAXSfxProps(1, 1, 0.316228, 1, 1, 2.91, 1.3, 1, 0.500035, 0.015, float3(0, 0, 0.3), 0.706318, 0.022, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_FALSE); + eaxPresets["arena"] = EAXSfxProps(1, 1, 0.316228, 0.447713, 1, 7.24, 0.33, 1, 0.261216, 0.02, float3(0, 0, 0.3), 1.01859, 0.03, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["hangar"] = EAXSfxProps(1, 1, 0.316228, 0.316228, 1, 10.05, 0.23, 1, 0.500035, 0.02, float3(0, 0, 0.3), 1.25603, 0.03, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["carpettedhallway"] = EAXSfxProps(0.428687, 1, 0.316228, 0.01, 1, 0.3, 0.1, 1, 0.121479, 0.002, float3(0, 0, 0.3), 0.153109, 0.03, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["hallway"] = EAXSfxProps(0.3645, 1, 0.316228, 0.707946, 1, 1.49, 0.59, 1, 0.245754, 0.007, float3(0, 0, 0.3), 1.6615, 0.011, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["stonecorridor"] = EAXSfxProps(1, 1, 0.316228, 0.761202, 1, 2.7, 0.79, 1, 0.247172, 0.013, float3(0, 0, 0.3), 1.5758, 0.02, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["alley"] = EAXSfxProps(1, 0.3, 0.316228, 0.732825, 1, 1.49, 0.86, 1, 0.250035, 0.007, float3(0, 0, 0.3), 0.995405, 0.011, float3(0, 0, 0.3), 0.125, 0.95, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["forest"] = EAXSfxProps(1, 0.3, 0.316228, 0.0223872, 1, 1.49, 0.54, 1, 0.0524807, 0.162, float3(0, 0, 0.3), 0.768245, 0.088, float3(0, 0, 0.3), 0.125, 1, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["city"] = EAXSfxProps(1, 0.5, 0.316228, 0.398107, 1, 1.49, 0.67, 1, 0.0730298, 0.007, float3(0, 0, 0.3), 0.142725, 0.011, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["mountains"] = EAXSfxProps(1, 0.27, 0.316228, 0.0562341, 1, 1.49, 0.21, 1, 0.040738, 0.3, float3(0, 0, 0.3), 0.191867, 0.1, float3(0, 0, 0.3), 0.25, 1, 0.25, 0, 0.99426, 5000, 250, 1, AL_FALSE); + eaxPresets["quarry"] = EAXSfxProps(1, 1, 0.316228, 0.316228, 1, 1.49, 0.83, 1, 0, 0.061, float3(0, 0, 0.3), 1.77828, 0.025, float3(0, 0, 0.3), 0.125, 0.7, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["plain"] = EAXSfxProps(1, 0.21, 0.316228, 0.1, 1, 1.49, 0.5, 1, 0.058479, 0.179, float3(0, 0, 0.3), 0.108893, 0.1, float3(0, 0, 0.3), 0.25, 1, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["parkinglot"] = EAXSfxProps(1, 1, 0.316228, 1, 1, 1.65, 1.5, 1, 0.208209, 0.008, float3(0, 0, 0.3), 0.265155, 0.012, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_FALSE); + eaxPresets["sewerpipe"] = EAXSfxProps(0.307063, 0.8, 0.316228, 0.316228, 1, 2.81, 0.14, 1, 1.6387, 0.014, float3(0, 0, 0.3), 3.24713, 0.021, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["underwater"] = EAXSfxProps(0.3645, 1, 0.316228, 0.01, 1, 1.49, 0.1, 1, 0.596348, 0.007, float3(0, 0, 0.3), 7.07946, 0.011, float3(0, 0, 0.3), 0.25, 0, 1.18, 0.348, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["drugged"] = EAXSfxProps(0.428687, 0.5, 0.316228, 1, 1, 8.39, 1.39, 1, 0.875992, 0.002, float3(0, 0, 0.3), 3.10814, 0.03, float3(0, 0, 0.3), 0.25, 0, 0.25, 1, 0.99426, 5000, 250, 1, AL_FALSE); + eaxPresets["dizzy"] = EAXSfxProps(0.3645, 0.6, 0.316228, 0.630957, 1, 17.23, 0.56, 1, 0.139155, 0.02, float3(0, 0, 0.3), 0.493742, 0.03, float3(0, 0, 0.3), 0.25, 1, 0.81, 0.31, 0.99426, 5000, 250, 1, AL_FALSE); + eaxPresets["psychotic"] = EAXSfxProps(0.0625, 0.5, 0.316228, 0.840427, 1, 7.56, 0.91, 1, 0.486407, 0.02, float3(0, 0, 0.3), 2.43781, 0.03, float3(0, 0, 0.3), 0.25, 0, 4, 1, 0.99426, 5000, 250, 1, AL_FALSE); + + // CASTLE PRESETS + eaxPresets["castle_smallroom"] = EAXSfxProps(1, 0.89, 0.316228, 0.398107, 0.1, 1.22, 0.83, 0.31, 0.891251, 0.022, float3(0, 0, 0.3), 1.99526, 0.011, float3(0, 0, 0.3), 0.138, 0.08, 0.25, 0, 0.99426, 5168.6, 139.5, 1, AL_TRUE); + eaxPresets["castle_shortpassage"] = EAXSfxProps(1, 0.89, 0.316228, 0.316228, 0.1, 2.32, 0.83, 0.31, 0.891251, 0.007, float3(0, 0, 0.3), 1.25893, 0.023, float3(0, 0, 0.3), 0.138, 0.08, 0.25, 0, 0.99426, 5168.6, 139.5, 1, AL_TRUE); + eaxPresets["castle_mediumroom"] = EAXSfxProps(1, 0.93, 0.316228, 0.281838, 0.1, 2.04, 0.83, 0.46, 0.630957, 0.022, float3(0, 0, 0.3), 1.58489, 0.011, float3(0, 0, 0.3), 0.155, 0.03, 0.25, 0, 0.99426, 5168.6, 139.5, 1, AL_TRUE); + eaxPresets["castle_longpassage"] = EAXSfxProps(1, 0.89, 0.316228, 0.398107, 0.1, 3.42, 0.83, 0.31, 0.891251, 0.007, float3(0, 0, 0.3), 1.41254, 0.023, float3(0, 0, 0.3), 0.138, 0.08, 0.25, 0, 0.99426, 5168.6, 139.5, 1, AL_TRUE); + eaxPresets["castle_largeroom"] = EAXSfxProps(1, 0.82, 0.316228, 0.281838, 0.125893, 2.53, 0.83, 0.5, 0.446684, 0.034, float3(0, 0, 0.3), 1.25893, 0.016, float3(0, 0, 0.3), 0.185, 0.07, 0.25, 0, 0.99426, 5168.6, 139.5, 1, AL_TRUE); + eaxPresets["castle_hall"] = EAXSfxProps(1, 0.81, 0.316228, 0.281838, 0.177828, 3.14, 0.79, 0.62, 0.177828, 0.056, float3(0, 0, 0.3), 1.12202, 0.024, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5168.6, 139.5, 1, AL_TRUE); + eaxPresets["castle_cupboard"] = EAXSfxProps(1, 0.89, 0.316228, 0.281838, 0.1, 0.67, 0.87, 0.31, 1.41254, 0.01, float3(0, 0, 0.3), 3.54813, 0.007, float3(0, 0, 0.3), 0.138, 0.08, 0.25, 0, 0.99426, 5168.6, 139.5, 1, AL_TRUE); + eaxPresets["castle_courtyard"] = EAXSfxProps(1, 0.42, 0.316228, 0.446684, 0.199526, 2.13, 0.61, 0.23, 0.223872, 0.16, float3(0, 0, 0.3), 0.707946, 0.036, float3(0, 0, 0.3), 0.25, 0.37, 0.25, 0, 0.99426, 5000, 250, 1, AL_FALSE); + eaxPresets["castle_alcove"] = EAXSfxProps(1, 0.89, 0.316228, 0.501187, 0.1, 1.64, 0.87, 0.31, 1, 0.007, float3(0, 0, 0.3), 1.41254, 0.034, float3(0, 0, 0.3), 0.138, 0.08, 0.25, 0, 0.99426, 5168.6, 139.5, 1, AL_TRUE); + + // FACTORY PRESETS + eaxPresets["factory_alcove"] = EAXSfxProps(0.3645, 0.59, 0.251189, 0.794328, 0.501187, 3.14, 0.65, 1.31, 1.41254, 0.01, float3(0, 0, 0.3), 1, 0.038, float3(0, 0, 0.3), 0.114, 0.1, 0.25, 0, 0.99426, 3762.6, 362.5, 1, AL_TRUE); + eaxPresets["factory_shortpassage"] = EAXSfxProps(0.3645, 0.64, 0.251189, 0.794328, 0.501187, 2.53, 0.65, 1.31, 1, 0.01, float3(0, 0, 0.3), 1.25893, 0.038, float3(0, 0, 0.3), 0.135, 0.23, 0.25, 0, 0.99426, 3762.6, 362.5, 1, AL_TRUE); + eaxPresets["factory_mediumroom"] = EAXSfxProps(0.428687, 0.82, 0.251189, 0.794328, 0.501187, 2.76, 0.65, 1.31, 0.281838, 0.022, float3(0, 0, 0.3), 1.41254, 0.023, float3(0, 0, 0.3), 0.174, 0.07, 0.25, 0, 0.99426, 3762.6, 362.5, 1, AL_TRUE); + eaxPresets["factory_longpassage"] = EAXSfxProps(0.3645, 0.64, 0.251189, 0.794328, 0.501187, 4.06, 0.65, 1.31, 1, 0.02, float3(0, 0, 0.3), 1.25893, 0.037, float3(0, 0, 0.3), 0.135, 0.23, 0.25, 0, 0.99426, 3762.6, 362.5, 1, AL_TRUE); + eaxPresets["factory_largeroom"] = EAXSfxProps(0.428687, 0.75, 0.251189, 0.707946, 0.630957, 4.24, 0.51, 1.31, 0.177828, 0.039, float3(0, 0, 0.3), 1.12202, 0.023, float3(0, 0, 0.3), 0.231, 0.07, 0.25, 0, 0.99426, 3762.6, 362.5, 1, AL_TRUE); + eaxPresets["factory_hall"] = EAXSfxProps(0.428687, 0.75, 0.316228, 0.707946, 0.630957, 7.43, 0.51, 1.31, 0.0630957, 0.073, float3(0, 0, 0.3), 0.891251, 0.027, float3(0, 0, 0.3), 0.25, 0.07, 0.25, 0, 0.99426, 3762.6, 362.5, 1, AL_TRUE); + eaxPresets["factory_cupboard"] = EAXSfxProps(0.307063, 0.63, 0.251189, 0.794328, 0.501187, 0.49, 0.65, 1.31, 1.25893, 0.01, float3(0, 0, 0.3), 1.99526, 0.032, float3(0, 0, 0.3), 0.107, 0.07, 0.25, 0, 0.99426, 3762.6, 362.5, 1, AL_TRUE); + eaxPresets["factory_courtyard"] = EAXSfxProps(0.307063, 0.57, 0.316228, 0.316228, 0.630957, 2.32, 0.29, 0.56, 0.223872, 0.14, float3(0, 0, 0.3), 0.398107, 0.039, float3(0, 0, 0.3), 0.25, 0.29, 0.25, 0, 0.99426, 3762.6, 362.5, 1, AL_TRUE); + eaxPresets["factory_smallroom"] = EAXSfxProps(0.3645, 0.82, 0.316228, 0.794328, 0.501187, 1.72, 0.65, 1.31, 0.707946, 0.01, float3(0, 0, 0.3), 1.77828, 0.024, float3(0, 0, 0.3), 0.119, 0.07, 0.25, 0, 0.99426, 3762.6, 362.5, 1, AL_TRUE); + + // ICE PALACE PRESETS + eaxPresets["icepalace_alcove"] = EAXSfxProps(1, 0.84, 0.316228, 0.562341, 0.281838, 2.76, 1.46, 0.28, 1.12202, 0.01, float3(0, 0, 0.3), 0.891251, 0.03, float3(0, 0, 0.3), 0.161, 0.09, 0.25, 0, 0.99426, 12428.5, 99.6, 1, AL_TRUE); + eaxPresets["icepalace_shortpassage"] = EAXSfxProps(1, 0.75, 0.316228, 0.562341, 0.281838, 1.79, 1.46, 0.28, 0.501187, 0.01, float3(0, 0, 0.3), 1.12202, 0.019, float3(0, 0, 0.3), 0.177, 0.09, 0.25, 0, 0.99426, 12428.5, 99.6, 1, AL_TRUE); + eaxPresets["icepalace_mediumroom"] = EAXSfxProps(1, 0.87, 0.316228, 0.562341, 0.446684, 2.22, 1.53, 0.32, 0.398107, 0.039, float3(0, 0, 0.3), 1.12202, 0.027, float3(0, 0, 0.3), 0.186, 0.12, 0.25, 0, 0.99426, 12428.5, 99.6, 1, AL_TRUE); + eaxPresets["icepalace_longpassage"] = EAXSfxProps(1, 0.77, 0.316228, 0.562341, 0.398107, 3.01, 1.46, 0.28, 0.794328, 0.012, float3(0, 0, 0.3), 1.25893, 0.025, float3(0, 0, 0.3), 0.186, 0.04, 0.25, 0, 0.99426, 12428.5, 99.6, 1, AL_TRUE); + eaxPresets["icepalace_largeroom"] = EAXSfxProps(1, 0.81, 0.316228, 0.562341, 0.446684, 3.14, 1.53, 0.32, 0.251189, 0.039, float3(0, 0, 0.3), 1, 0.027, float3(0, 0, 0.3), 0.214, 0.11, 0.25, 0, 0.99426, 12428.5, 99.6, 1, AL_TRUE); + eaxPresets["icepalace_hall"] = EAXSfxProps(1, 0.76, 0.316228, 0.446684, 0.562341, 5.49, 1.53, 0.38, 0.112202, 0.054, float3(0, 0, 0.3), 0.630957, 0.052, float3(0, 0, 0.3), 0.226, 0.11, 0.25, 0, 0.99426, 12428.5, 99.6, 1, AL_TRUE); + eaxPresets["icepalace_cupboard"] = EAXSfxProps(1, 0.83, 0.316228, 0.501187, 0.223872, 0.76, 1.53, 0.26, 1.12202, 0.012, float3(0, 0, 0.3), 1.99526, 0.016, float3(0, 0, 0.3), 0.143, 0.08, 0.25, 0, 0.99426, 12428.5, 99.6, 1, AL_TRUE); + eaxPresets["icepalace_courtyard"] = EAXSfxProps(1, 0.59, 0.316228, 0.281838, 0.316228, 2.04, 1.2, 0.38, 0.316228, 0.173, float3(0, 0, 0.3), 0.316228, 0.043, float3(0, 0, 0.3), 0.235, 0.48, 0.25, 0, 0.99426, 12428.5, 99.6, 1, AL_TRUE); + eaxPresets["icepalace_smallroom"] = EAXSfxProps(1, 0.84, 0.316228, 0.562341, 0.281838, 1.51, 1.53, 0.27, 0.891251, 0.01, float3(0, 0, 0.3), 1.41254, 0.011, float3(0, 0, 0.3), 0.164, 0.14, 0.25, 0, 0.99426, 12428.5, 99.6, 1, AL_TRUE); + + // SPACE STATION PRESETS + eaxPresets["spacestation_alcove"] = EAXSfxProps(0.210938, 0.78, 0.316228, 0.707946, 0.891251, 1.16, 0.81, 0.55, 1.41254, 0.007, float3(0, 0, 0.3), 1, 0.018, float3(0, 0, 0.3), 0.192, 0.21, 0.25, 0, 0.99426, 3316.1, 458.2, 1, AL_TRUE); + eaxPresets["spacestation_mediumroom"] = EAXSfxProps(0.210938, 0.75, 0.316228, 0.630957, 0.891251, 3.01, 0.5, 0.55, 0.398107, 0.034, float3(0, 0, 0.3), 1.12202, 0.035, float3(0, 0, 0.3), 0.209, 0.31, 0.25, 0, 0.99426, 3316.1, 458.2, 1, AL_TRUE); + eaxPresets["spacestation_shortpassage"] = EAXSfxProps(0.210938, 0.87, 0.316228, 0.630957, 0.891251, 3.57, 0.5, 0.55, 1, 0.012, float3(0, 0, 0.3), 1.12202, 0.016, float3(0, 0, 0.3), 0.172, 0.2, 0.25, 0, 0.99426, 3316.1, 458.2, 1, AL_TRUE); + eaxPresets["spacestation_longpassage"] = EAXSfxProps(0.428687, 0.82, 0.316228, 0.630957, 0.891251, 4.62, 0.62, 0.55, 1, 0.012, float3(0, 0, 0.3), 1.25893, 0.031, float3(0, 0, 0.3), 0.25, 0.23, 0.25, 0, 0.99426, 3316.1, 458.2, 1, AL_TRUE); + eaxPresets["spacestation_largeroom"] = EAXSfxProps(0.3645, 0.81, 0.316228, 0.630957, 0.891251, 3.89, 0.38, 0.61, 0.316228, 0.056, float3(0, 0, 0.3), 0.891251, 0.035, float3(0, 0, 0.3), 0.233, 0.28, 0.25, 0, 0.99426, 3316.1, 458.2, 1, AL_TRUE); + eaxPresets["spacestation_hall"] = EAXSfxProps(0.428687, 0.87, 0.316228, 0.630957, 0.891251, 7.11, 0.38, 0.61, 0.177828, 0.1, float3(0, 0, 0.3), 0.630957, 0.047, float3(0, 0, 0.3), 0.25, 0.25, 0.25, 0, 0.99426, 3316.1, 458.2, 1, AL_TRUE); + eaxPresets["spacestation_cupboard"] = EAXSfxProps(0.1715, 0.56, 0.316228, 0.707946, 0.891251, 0.79, 0.81, 0.55, 1.41254, 0.007, float3(0, 0, 0.3), 1.77828, 0.018, float3(0, 0, 0.3), 0.181, 0.31, 0.25, 0, 0.99426, 3316.1, 458.2, 1, AL_TRUE); + eaxPresets["spacestation_smallroom"] = EAXSfxProps(0.210938, 0.7, 0.316228, 0.707946, 0.891251, 1.72, 0.82, 0.55, 0.794328, 0.007, float3(0, 0, 0.3), 1.41254, 0.013, float3(0, 0, 0.3), 0.188, 0.26, 0.25, 0, 0.99426, 3316.1, 458.2, 1, AL_TRUE); + + // WOODEN GALLEON PRESETS + eaxPresets["wooden_alcove"] = EAXSfxProps(1, 1, 0.316228, 0.125893, 0.316228, 1.22, 0.62, 0.91, 1.12202, 0.012, float3(0, 0, 0.3), 0.707946, 0.024, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 4705, 99.6, 1, AL_TRUE); + eaxPresets["wooden_shortpassage"] = EAXSfxProps(1, 1, 0.316228, 0.125893, 0.316228, 1.75, 0.5, 0.87, 0.891251, 0.012, float3(0, 0, 0.3), 0.630957, 0.024, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 4705, 99.6, 1, AL_TRUE); + eaxPresets["wooden_mediumroom"] = EAXSfxProps(1, 1, 0.316228, 0.1, 0.281838, 1.47, 0.42, 0.82, 0.891251, 0.049, float3(0, 0, 0.3), 0.891251, 0.029, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 4705, 99.6, 1, AL_TRUE); + eaxPresets["wooden_longpassage"] = EAXSfxProps(1, 1, 0.316228, 0.1, 0.316228, 1.99, 0.4, 0.79, 1, 0.02, float3(0, 0, 0.3), 0.446684, 0.036, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 4705, 99.6, 1, AL_TRUE); + eaxPresets["wooden_largeroom"] = EAXSfxProps(1, 1, 0.316228, 0.0891251, 0.281838, 2.65, 0.33, 0.82, 0.891251, 0.066, float3(0, 0, 0.3), 0.794328, 0.049, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 4705, 99.6, 1, AL_TRUE); + eaxPresets["wooden_hall"] = EAXSfxProps(1, 1, 0.316228, 0.0794328, 0.281838, 3.45, 0.3, 0.82, 0.891251, 0.088, float3(0, 0, 0.3), 0.794328, 0.063, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 4705, 99.6, 1, AL_TRUE); + eaxPresets["wooden_cupboard"] = EAXSfxProps(1, 1, 0.316228, 0.141254, 0.316228, 0.56, 0.46, 0.91, 1.12202, 0.012, float3(0, 0, 0.3), 1.12202, 0.028, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 4705, 99.6, 1, AL_TRUE); + eaxPresets["wooden_smallroom"] = EAXSfxProps(1, 1, 0.316228, 0.112202, 0.316228, 0.79, 0.32, 0.87, 1, 0.032, float3(0, 0, 0.3), 0.891251, 0.029, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 4705, 99.6, 1, AL_TRUE); + eaxPresets["wooden_courtyard"] = EAXSfxProps(1, 0.65, 0.316228, 0.0794328, 0.316228, 1.79, 0.35, 0.79, 0.562341, 0.123, float3(0, 0, 0.3), 0.1, 0.032, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 4705, 99.6, 1, AL_TRUE); + + // SPORTS PRESETS + eaxPresets["sport_emptystadium"] = EAXSfxProps(1, 1, 0.316228, 0.446684, 0.794328, 6.26, 0.51, 1.1, 0.0630957, 0.183, float3(0, 0, 0.3), 0.398107, 0.038, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["sport_squashcourt"] = EAXSfxProps(1, 0.75, 0.316228, 0.316228, 0.794328, 2.22, 0.91, 1.16, 0.446684, 0.007, float3(0, 0, 0.3), 0.794328, 0.011, float3(0, 0, 0.3), 0.126, 0.19, 0.25, 0, 0.99426, 7176.9, 211.2, 1, AL_TRUE); + eaxPresets["sport_smallswimmingpool"] = EAXSfxProps(1, 0.7, 0.316228, 0.794328, 0.891251, 2.76, 1.25, 1.14, 0.630957, 0.02, float3(0, 0, 0.3), 0.794328, 0.03, float3(0, 0, 0.3), 0.179, 0.15, 0.895, 0.19, 0.99426, 5000, 250, 1, AL_FALSE); + eaxPresets["sport_largeswimmingpool"] = EAXSfxProps(1, 0.82, 0.316228, 0.794328, 1, 5.49, 1.31, 1.14, 0.446684, 0.039, float3(0, 0, 0.3), 0.501187, 0.049, float3(0, 0, 0.3), 0.222, 0.55, 1.159, 0.21, 0.99426, 5000, 250, 1, AL_FALSE); + eaxPresets["sport_gymnasium"] = EAXSfxProps(1, 0.81, 0.316228, 0.446684, 0.891251, 3.14, 1.06, 1.35, 0.398107, 0.029, float3(0, 0, 0.3), 0.562341, 0.045, float3(0, 0, 0.3), 0.146, 0.14, 0.25, 0, 0.99426, 7176.9, 211.2, 1, AL_TRUE); + eaxPresets["sport_fullstadium"] = EAXSfxProps(1, 1, 0.316228, 0.0707946, 0.794328, 5.25, 0.17, 0.8, 0.1, 0.188, float3(0, 0, 0.3), 0.281838, 0.038, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["sport_stadiumtannoy"] = EAXSfxProps(1, 0.78, 0.316228, 0.562341, 0.501187, 2.53, 0.88, 0.68, 0.281838, 0.23, float3(0, 0, 0.3), 0.501187, 0.063, float3(0, 0, 0.3), 0.25, 0.2, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); + + // PREFAB PRESETS + eaxPresets["prefab_workshop"] = EAXSfxProps(0.428687, 1, 0.316228, 0.141254, 0.398107, 0.76, 1, 1, 1, 0.012, float3(0, 0, 0.3), 1.12202, 0.012, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_FALSE); + eaxPresets["prefab_schoolroom"] = EAXSfxProps(0.402178, 0.69, 0.316228, 0.630957, 0.501187, 0.98, 0.45, 0.18, 1.41254, 0.017, float3(0, 0, 0.3), 1.41254, 0.015, float3(0, 0, 0.3), 0.095, 0.14, 0.25, 0, 0.99426, 7176.9, 211.2, 1, AL_TRUE); + eaxPresets["prefab_practiseroom"] = EAXSfxProps(0.402178, 0.87, 0.316228, 0.398107, 0.501187, 1.12, 0.56, 0.18, 1.25893, 0.01, float3(0, 0, 0.3), 1.41254, 0.011, float3(0, 0, 0.3), 0.095, 0.14, 0.25, 0, 0.99426, 7176.9, 211.2, 1, AL_TRUE); + eaxPresets["prefab_outhouse"] = EAXSfxProps(1, 0.82, 0.316228, 0.112202, 0.158489, 1.38, 0.38, 0.35, 0.891251, 0.024, float3(0, 0, 0.3), 0.630957, 0.044, float3(0, 0, 0.3), 0.121, 0.17, 0.25, 0, 0.99426, 2854.4, 107.5, 1, AL_FALSE); + eaxPresets["prefab_caravan"] = EAXSfxProps(1, 1, 0.316228, 0.0891251, 0.125893, 0.43, 1.5, 1, 1, 0.012, float3(0, 0, 0.3), 1.99526, 0.012, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 5000, 250, 1, AL_FALSE); + + // DOME AND PIPE PRESETS + eaxPresets["dome_tomb"] = EAXSfxProps(1, 0.79, 0.316228, 0.354813, 0.223872, 4.18, 0.21, 0.1, 0.386812, 0.03, float3(0, 0, 0.3), 1.6788, 0.022, float3(0, 0, 0.3), 0.177, 0.19, 0.25, 0, 0.99426, 2854.4, 20, 1, AL_FALSE); + eaxPresets["pipe_small"] = EAXSfxProps(1, 1, 0.316228, 0.354813, 0.223872, 5.04, 0.1, 0.1, 0.501187, 0.032, float3(0, 0, 0.3), 2.51189, 0.015, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 2854.4, 20, 1, AL_TRUE); + eaxPresets["dome_saintpauls"] = EAXSfxProps(1, 0.87, 0.316228, 0.354813, 0.223872, 10.48, 0.19, 0.1, 0.177828, 0.09, float3(0, 0, 0.3), 1.25893, 0.042, float3(0, 0, 0.3), 0.25, 0.12, 0.25, 0, 0.99426, 2854.4, 20, 1, AL_TRUE); + eaxPresets["pipe_longthin"] = EAXSfxProps(0.256, 0.91, 0.316228, 0.446684, 0.281838, 9.21, 0.18, 0.1, 0.707946, 0.01, float3(0, 0, 0.3), 0.707946, 0.022, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 2854.4, 20, 1, AL_FALSE); + eaxPresets["pipe_large"] = EAXSfxProps(1, 1, 0.316228, 0.354813, 0.223872, 8.45, 0.1, 0.1, 0.398107, 0.046, float3(0, 0, 0.3), 1.58489, 0.032, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 2854.4, 20, 1, AL_TRUE); + eaxPresets["pipe_resonant"] = EAXSfxProps(0.137312, 0.91, 0.316228, 0.446684, 0.281838, 6.81, 0.18, 0.1, 0.707946, 0.01, float3(0, 0, 0.3), 1, 0.022, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 2854.4, 20, 1, AL_FALSE); + + // OUTDOORS PRESETS + eaxPresets["outdoors_backyard"] = EAXSfxProps(1, 0.45, 0.316228, 0.251189, 0.501187, 1.12, 0.34, 0.46, 0.446684, 0.069, float3(0, 0, 0.3), 0.707946, 0.023, float3(0, 0, 0.3), 0.218, 0.34, 0.25, 0, 0.99426, 4399.1, 242.9, 1, AL_FALSE); + eaxPresets["outdoors_rollingplains"] = EAXSfxProps(1, 0, 0.316228, 0.0112202, 0.630957, 2.13, 0.21, 0.46, 0.177828, 0.3, float3(0, 0, 0.3), 0.446684, 0.019, float3(0, 0, 0.3), 0.25, 1, 0.25, 0, 0.99426, 4399.1, 242.9, 1, AL_FALSE); + eaxPresets["outdoors_deepcanyon"] = EAXSfxProps(1, 0.74, 0.316228, 0.177828, 0.630957, 3.89, 0.21, 0.46, 0.316228, 0.223, float3(0, 0, 0.3), 0.354813, 0.019, float3(0, 0, 0.3), 0.25, 1, 0.25, 0, 0.99426, 4399.1, 242.9, 1, AL_FALSE); + eaxPresets["outdoors_creek"] = EAXSfxProps(1, 0.35, 0.316228, 0.177828, 0.501187, 2.13, 0.21, 0.46, 0.398107, 0.115, float3(0, 0, 0.3), 0.199526, 0.031, float3(0, 0, 0.3), 0.218, 0.34, 0.25, 0, 0.99426, 4399.1, 242.9, 1, AL_FALSE); + eaxPresets["outdoors_valley"] = EAXSfxProps(1, 0.28, 0.316228, 0.0281838, 0.158489, 2.88, 0.26, 0.35, 0.141254, 0.263, float3(0, 0, 0.3), 0.398107, 0.1, float3(0, 0, 0.3), 0.25, 0.34, 0.25, 0, 0.99426, 2854.4, 107.5, 1, AL_FALSE); + + // MOOD PRESETS + eaxPresets["mood_heaven"] = EAXSfxProps(1, 0.94, 0.316228, 0.794328, 0.446684, 5.04, 1.12, 0.56, 0.242661, 0.02, float3(0, 0, 0.3), 1.25893, 0.029, float3(0, 0, 0.3), 0.25, 0.08, 2.742, 0.05, 0.9977, 5000, 250, 1, AL_TRUE); + eaxPresets["mood_hell"] = EAXSfxProps(1, 0.57, 0.316228, 0.354813, 0.446684, 3.57, 0.49, 2, 0, 0.02, float3(0, 0, 0.3), 1.41254, 0.03, float3(0, 0, 0.3), 0.11, 0.04, 2.109, 0.52, 0.99426, 5000, 139.5, 1, AL_FALSE); + eaxPresets["mood_memory"] = EAXSfxProps(1, 0.85, 0.316228, 0.630957, 0.354813, 4.06, 0.82, 0.56, 0.0398107, 0, float3(0, 0, 0.3), 1.12202, 0, float3(0, 0, 0.3), 0.25, 0, 0.474, 0.45, 0.988553, 5000, 250, 1, AL_FALSE); + + // DRIVING SIMULATION PRESETS + eaxPresets["driving_commentator"] = EAXSfxProps(1, 0, 0.316228, 0.562341, 0.501187, 2.42, 0.88, 0.68, 0.199526, 0.093, float3(0, 0, 0.3), 0.251189, 0.017, float3(0, 0, 0.3), 0.25, 1, 0.25, 0, 0.988553, 5000, 250, 1, AL_TRUE); + eaxPresets["driving_pitgarage"] = EAXSfxProps(0.428687, 0.59, 0.316228, 0.707946, 0.562341, 1.72, 0.93, 0.87, 0.562341, 0, float3(0, 0, 0.3), 1.25893, 0.016, float3(0, 0, 0.3), 0.25, 0.11, 0.25, 0, 0.99426, 5000, 250, 1, AL_FALSE); + eaxPresets["driving_incar_racer"] = EAXSfxProps(0.0831875, 0.8, 0.316228, 1, 0.794328, 0.17, 2, 0.41, 1.77828, 0.007, float3(0, 0, 0.3), 0.707946, 0.015, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 10268.2, 251, 1, AL_TRUE); + eaxPresets["driving_incar_sports"] = EAXSfxProps(0.0831875, 0.8, 0.316228, 0.630957, 1, 0.17, 0.75, 0.41, 1, 0.01, float3(0, 0, 0.3), 0.562341, 0, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 10268.2, 251, 1, AL_TRUE); + eaxPresets["driving_incar_luxury"] = EAXSfxProps(0.256, 1, 0.316228, 0.1, 0.501187, 0.13, 0.41, 0.46, 0.794328, 0.01, float3(0, 0, 0.3), 1.58489, 0.01, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 10268.2, 251, 1, AL_TRUE); + eaxPresets["driving_fullgrandstand"] = EAXSfxProps(1, 1, 0.316228, 0.281838, 0.630957, 3.01, 1.37, 1.28, 0.354813, 0.09, float3(0, 0, 0.3), 0.177828, 0.049, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 10420.2, 250, 1, AL_FALSE); + eaxPresets["driving_emptygrandstand"] = EAXSfxProps(1, 1, 0.316228, 1, 0.794328, 4.62, 1.75, 1.4, 0.208209, 0.09, float3(0, 0, 0.3), 0.251189, 0.049, float3(0, 0, 0.3), 0.25, 0, 0.25, 0, 0.99426, 10420.2, 250, 1, AL_FALSE); + eaxPresets["driving_tunnel"] = EAXSfxProps(1, 0.81, 0.316228, 0.398107, 0.891251, 3.42, 0.94, 1.31, 0.707946, 0.051, float3(0, 0, 0.3), 0.707946, 0.047, float3(0, 0, 0.3), 0.214, 0.05, 0.25, 0, 0.99426, 5000, 155.3, 1, AL_TRUE); + + // CITY PRESETS + eaxPresets["city_streets"] = EAXSfxProps(1, 0.78, 0.316228, 0.707946, 0.891251, 1.79, 1.12, 0.91, 0.281838, 0.046, float3(0, 0, 0.3), 0.199526, 0.028, float3(0, 0, 0.3), 0.25, 0.2, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["city_subway"] = EAXSfxProps(1, 0.74, 0.316228, 0.707946, 0.891251, 3.01, 1.23, 0.91, 0.707946, 0.046, float3(0, 0, 0.3), 1.25893, 0.028, float3(0, 0, 0.3), 0.125, 0.21, 0.25, 0, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["city_museum"] = EAXSfxProps(1, 0.82, 0.316228, 0.177828, 0.177828, 3.28, 1.4, 0.57, 0.251189, 0.039, float3(0, 0, 0.3), 0.891251, 0.034, float3(0, 0, 0.3), 0.13, 0.17, 0.25, 0, 0.99426, 2854.4, 107.5, 1, AL_FALSE); + eaxPresets["city_library"] = EAXSfxProps(1, 0.82, 0.316228, 0.281838, 0.0891251, 2.76, 0.89, 0.41, 0.354813, 0.029, float3(0, 0, 0.3), 0.891251, 0.02, float3(0, 0, 0.3), 0.13, 0.17, 0.25, 0, 0.99426, 2854.4, 107.5, 1, AL_FALSE); + eaxPresets["city_underpass"] = EAXSfxProps(1, 0.82, 0.316228, 0.446684, 0.891251, 3.57, 1.12, 0.91, 0.398107, 0.059, float3(0, 0, 0.3), 0.891251, 0.037, float3(0, 0, 0.3), 0.25, 0.14, 0.25, 0, 0.991973, 5000, 250, 1, AL_TRUE); + eaxPresets["city_abandoned"] = EAXSfxProps(1, 0.69, 0.316228, 0.794328, 0.891251, 3.28, 1.17, 0.91, 0.446684, 0.044, float3(0, 0, 0.3), 0.281838, 0.024, float3(0, 0, 0.3), 0.25, 0.2, 0.25, 0, 0.996552, 5000, 250, 1, AL_TRUE); + + // MISC ROOMS + eaxPresets["dustyroom"] = EAXSfxProps(0.3645, 0.56, 0.316228, 0.794328, 0.707946, 1.79, 0.38, 0.21, 0.501187, 0.002, float3(0, 0, 0.3), 1.25893, 0.006, float3(0, 0, 0.3), 0.202, 0.05, 0.25, 0, 0.988553, 13046, 163.3, 1, AL_TRUE); + eaxPresets["chapel"] = EAXSfxProps(1, 0.84, 0.316228, 0.562341, 1, 4.62, 0.64, 1.23, 0.446684, 0.032, float3(0, 0, 0.3), 0.794328, 0.049, float3(0, 0, 0.3), 0.25, 0, 0.25, 0.11, 0.99426, 5000, 250, 1, AL_TRUE); + eaxPresets["smallwaterroom"] = EAXSfxProps(1, 0.7, 0.316228, 0.447713, 1, 1.51, 1.25, 1.14, 0.891251, 0.02, float3(0, 0, 0.3), 1.41254, 0.03, float3(0, 0, 0.3), 0.179, 0.15, 0.895, 0.19, 0.991973, 5000, 250, 1, AL_FALSE); +} + +static void InitConversionTables() +{ + alParamType[AL_EAXREVERB_DENSITY] = EFXParamTypes::FLOAT; + alParamType[AL_EAXREVERB_DIFFUSION] = EFXParamTypes::FLOAT; + alParamType[AL_EAXREVERB_GAIN] = EFXParamTypes::FLOAT; + alParamType[AL_EAXREVERB_GAINHF] = EFXParamTypes::FLOAT; + alParamType[AL_EAXREVERB_GAINLF] = EFXParamTypes::FLOAT; + alParamType[AL_EAXREVERB_DECAY_TIME] = EFXParamTypes::FLOAT; + alParamType[AL_EAXREVERB_DECAY_HFLIMIT] = EFXParamTypes::BOOL; + alParamType[AL_EAXREVERB_DECAY_HFRATIO] = EFXParamTypes::FLOAT; + alParamType[AL_EAXREVERB_DECAY_LFRATIO] = EFXParamTypes::FLOAT; + alParamType[AL_EAXREVERB_REFLECTIONS_GAIN] = EFXParamTypes::FLOAT; + alParamType[AL_EAXREVERB_REFLECTIONS_DELAY] = EFXParamTypes::FLOAT; + alParamType[AL_EAXREVERB_REFLECTIONS_PAN] = EFXParamTypes::VECTOR; + alParamType[AL_EAXREVERB_LATE_REVERB_GAIN] = EFXParamTypes::FLOAT; + alParamType[AL_EAXREVERB_LATE_REVERB_DELAY] = EFXParamTypes::FLOAT; + alParamType[AL_EAXREVERB_LATE_REVERB_PAN] = EFXParamTypes::VECTOR; + alParamType[AL_EAXREVERB_ECHO_TIME] = EFXParamTypes::FLOAT; + alParamType[AL_EAXREVERB_ECHO_DEPTH] = EFXParamTypes::FLOAT; + alParamType[AL_EAXREVERB_MODULATION_TIME] = EFXParamTypes::FLOAT; + alParamType[AL_EAXREVERB_MODULATION_DEPTH] = EFXParamTypes::FLOAT; + alParamType[AL_EAXREVERB_AIR_ABSORPTION_GAINHF] = EFXParamTypes::FLOAT; + alParamType[AL_EAXREVERB_HFREFERENCE] = EFXParamTypes::FLOAT; + alParamType[AL_EAXREVERB_LFREFERENCE] = EFXParamTypes::FLOAT; + alParamType[AL_EAXREVERB_ROOM_ROLLOFF_FACTOR] = EFXParamTypes::FLOAT; + alParamType[AL_LOWPASS_GAIN] = EFXParamTypes::FLOAT; + alParamType[AL_LOWPASS_GAINHF] = EFXParamTypes::FLOAT; + + + alParamToName[AL_EAXREVERB_DENSITY] = "density"; + alParamToName[AL_EAXREVERB_DIFFUSION] = "diffusion"; + alParamToName[AL_EAXREVERB_GAIN] = "gain"; + alParamToName[AL_EAXREVERB_GAINHF] = "gainhf"; + alParamToName[AL_EAXREVERB_GAINLF] = "gainlf"; + alParamToName[AL_EAXREVERB_DECAY_TIME] = "decaytime"; + alParamToName[AL_EAXREVERB_DECAY_HFLIMIT] = "decayhflimit"; + alParamToName[AL_EAXREVERB_DECAY_HFRATIO] = "decayhfratio"; + alParamToName[AL_EAXREVERB_DECAY_LFRATIO] = "decaylfratio"; + alParamToName[AL_EAXREVERB_REFLECTIONS_GAIN] = "reflectionsgain"; + alParamToName[AL_EAXREVERB_REFLECTIONS_DELAY] = "reflectionsdelay"; + alParamToName[AL_EAXREVERB_REFLECTIONS_PAN] = "reflectionspan"; + alParamToName[AL_EAXREVERB_LATE_REVERB_GAIN] = "latereverbgain"; + alParamToName[AL_EAXREVERB_LATE_REVERB_DELAY] = "latereverbdelay"; + alParamToName[AL_EAXREVERB_LATE_REVERB_PAN] = "latereverbpan"; + alParamToName[AL_EAXREVERB_ECHO_TIME] = "echotime"; + alParamToName[AL_EAXREVERB_ECHO_DEPTH] = "echodepth"; + alParamToName[AL_EAXREVERB_MODULATION_TIME] = "modtime"; + alParamToName[AL_EAXREVERB_MODULATION_DEPTH] = "moddepth"; + alParamToName[AL_EAXREVERB_AIR_ABSORPTION_GAINHF] = "airabsorptiongainhf"; + alParamToName[AL_EAXREVERB_HFREFERENCE] = "hfreference"; + alParamToName[AL_EAXREVERB_LFREFERENCE] = "lfreference"; + alParamToName[AL_EAXREVERB_ROOM_ROLLOFF_FACTOR] = "roomrollofffactor"; + + alFilterParamToName[AL_LOWPASS_GAIN] = "gainlf"; + alFilterParamToName[AL_LOWPASS_GAINHF] = "gainhf"; + + for (std::map::iterator it=alParamToName.begin(); it != alParamToName.end(); ++it) + nameToALParam[it->second] = it->first; + + for (std::map::iterator it=alFilterParamToName.begin(); it != alFilterParamToName.end(); ++it) + nameToALFilterParam[it->second] = it->first; +} + +DO_ONCE(InitPresets) +DO_ONCE(InitConversionTables) diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/EFXPresets.h spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/EFXPresets.h --- spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/EFXPresets.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/EFXPresets.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,96 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef _EFX_PRESETS_H_ +#define _EFX_PRESETS_H_ + +#include +#include +#include "System/float3.h" +#include +#include + + +struct EAXSfxProps +{ + EAXSfxProps( + ALfloat _density, + ALfloat _diffusion, + ALfloat _gain, + ALfloat _gainHF, + ALfloat _gainLF, + ALfloat _decayTime, + ALfloat _decayHFRatio, + ALfloat _decayLFRatio, + ALfloat _reflectionGain, + ALfloat _reflectionDelay, + float3 _reflectionPan, + ALfloat _lateReverbGain, + ALfloat _lateReverbDelay, + float3 _lateReverbPan, + ALfloat _echoTime, + ALfloat _echoDepth, + ALfloat _modTime, + ALfloat _modDepth, + ALfloat _airAbsorptionGainHF, + ALfloat _hfReference, + ALfloat _lfReference, + ALfloat _roomRollOffFactor, + ALboolean _decayHFLimit + ) + { + properties_f[AL_EAXREVERB_DENSITY] = _density; + properties_f[AL_EAXREVERB_DIFFUSION] = _diffusion; + properties_f[AL_EAXREVERB_GAIN] = _gain; + properties_f[AL_EAXREVERB_GAINHF] = _gainHF; + properties_f[AL_EAXREVERB_GAINLF] = _gainLF; + properties_f[AL_EAXREVERB_DECAY_TIME] = _decayTime; + properties_i[AL_EAXREVERB_DECAY_HFLIMIT] = _decayHFLimit; + properties_f[AL_EAXREVERB_DECAY_HFRATIO] = _decayHFRatio; + properties_f[AL_EAXREVERB_DECAY_LFRATIO] = _decayLFRatio; + properties_f[AL_EAXREVERB_REFLECTIONS_GAIN] = _reflectionGain; + properties_f[AL_EAXREVERB_REFLECTIONS_DELAY] = _reflectionDelay; + properties_v[AL_EAXREVERB_REFLECTIONS_PAN] = _reflectionPan; + properties_f[AL_EAXREVERB_LATE_REVERB_GAIN] = _lateReverbGain; + properties_f[AL_EAXREVERB_LATE_REVERB_DELAY] = _lateReverbDelay; + properties_v[AL_EAXREVERB_LATE_REVERB_PAN] = _lateReverbPan; + properties_f[AL_EAXREVERB_ECHO_TIME] = _echoTime; + properties_f[AL_EAXREVERB_ECHO_DEPTH] = _echoDepth; + properties_f[AL_EAXREVERB_MODULATION_TIME] = _modTime; + properties_f[AL_EAXREVERB_MODULATION_DEPTH] = _modDepth; + properties_f[AL_EAXREVERB_AIR_ABSORPTION_GAINHF] = _airAbsorptionGainHF; + properties_f[AL_EAXREVERB_HFREFERENCE] = _hfReference; + properties_f[AL_EAXREVERB_LFREFERENCE] = _lfReference; + properties_f[AL_EAXREVERB_ROOM_ROLLOFF_FACTOR] = _roomRollOffFactor; + + filter_properties_f[AL_LOWPASS_GAIN] = 1.0f; + filter_properties_f[AL_LOWPASS_GAINHF] = 1.0f; + } + + EAXSfxProps() {} + + // Reverb + std::map properties_f; + std::map properties_i; + std::map properties_v; + + // Filter + std::map filter_properties_f; +}; + +namespace EFXParamTypes { + enum { + FLOAT, + VECTOR, + BOOL + }; +} + +extern std::map eaxPresets; + +extern std::map alParamType; +extern std::map nameToALParam; +extern std::map alParamToName; +extern std::map nameToALFilterParam; +extern std::map alFilterParamToName; + +#endif // _EFX_PRESETS_H_ \ No newline at end of file diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/OggStream.cpp spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/OggStream.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/OggStream.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/OggStream.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,331 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include "OggStream.h" + +#include //memset +#include "System/FileSystem/FileHandler.h" +#include "System/Sound/SoundLog.h" +#include "ALShared.h" +#include "VorbisShared.h" + + +namespace VorbisCallbacks { + size_t VorbisStreamRead(void* ptr, size_t size, size_t nmemb, void* datasource) + { + CFileHandler* buffer = static_cast(datasource); + return buffer->Read(ptr, size * nmemb); + } + + int VorbisStreamClose(void* datasource) + { + CFileHandler* buffer = static_cast(datasource); + delete buffer; + return 0; + } + + int VorbisStreamSeek(void* datasource, ogg_int64_t offset, int whence) + { + CFileHandler* buffer = static_cast(datasource); + if (whence == SEEK_SET) + { + buffer->Seek(offset, std::ios_base::beg); + } + else if (whence == SEEK_CUR) + { + buffer->Seek(offset, std::ios_base::cur); + } + else if (whence == SEEK_END) + { + buffer->Seek(offset, std::ios_base::end); + } + + return 0; + } + + long VorbisStreamTell(void* datasource) + { + CFileHandler* buffer = static_cast(datasource); + return buffer->GetPos(); + } + +} + + + +COggStream::COggStream(ALuint _source) + : vorbisInfo(NULL) + , source(_source) + , format(AL_FORMAT_MONO16) + , stopped(true) + , paused(false) +{ + for (unsigned i = 0; i < NUM_BUFFERS; ++i) { + buffers[i] = 0; + } + for (unsigned i = 0; i < BUFFER_SIZE; ++i) { + pcmDecodeBuffer[i] = 0; + } +} + +COggStream::~COggStream() +{ + Stop(); +} + +// open an Ogg stream from a given file and start playing it +void COggStream::Play(const std::string& path, float volume) +{ + if (!stopped) { + // we're already playing another stream + return; + } + + vorbisTags.clear(); + + ov_callbacks vorbisCallbacks; + vorbisCallbacks.read_func = VorbisCallbacks::VorbisStreamRead; + vorbisCallbacks.close_func = VorbisCallbacks::VorbisStreamClose; + vorbisCallbacks.seek_func = VorbisCallbacks::VorbisStreamSeek; + vorbisCallbacks.tell_func = VorbisCallbacks::VorbisStreamTell; + + CFileHandler* buf = new CFileHandler(path); + const int result = ov_open_callbacks(buf, &oggStream, NULL, 0, vorbisCallbacks); + if (result < 0) { + LOG_L(L_WARNING, "Could not open Ogg stream (reason: %s).", + ErrorString(result).c_str()); + return; + } + + + vorbisInfo = ov_info(&oggStream, -1); + { + vorbis_comment* vorbisComment; + vorbisComment = ov_comment(&oggStream, -1); + vorbisTags.resize(vorbisComment->comments); + + for (unsigned i = 0; i < vorbisComment->comments; ++i) { + vorbisTags[i] = std::string(vorbisComment->user_comments[i], vorbisComment->comment_lengths[i]); + } + + vendor = std::string(vorbisComment->vendor); + // DisplayInfo(); + } + + if (vorbisInfo->channels == 1) { + format = AL_FORMAT_MONO16; + } else { + format = AL_FORMAT_STEREO16; + } + + alGenBuffers(2, buffers); CheckError("COggStream::Play"); + + if (!StartPlaying()) { + ReleaseBuffers(); + } else { + stopped = false; + paused = false; + } + + CheckError("COggStream::Play"); +} + +float COggStream::GetPlayTime() const +{ + return msecsPlayed.toSecsf(); +} + +float COggStream::GetTotalTime() +{ + return ov_time_total(&oggStream, -1); +} + +bool COggStream::Valid() const +{ + return (vorbisInfo != 0); +} + +bool COggStream::IsFinished() +{ + return !Valid() || (GetPlayTime() >= GetTotalTime()); +} + +const COggStream::TagVector& COggStream::VorbisTags() const +{ + return vorbisTags; +} + +// display Ogg info and comments +void COggStream::DisplayInfo() +{ + LOG("version: %d", vorbisInfo->version); + LOG("channels: %d", vorbisInfo->channels); + LOG("time (sec): %lf", ov_time_total(&oggStream,-1)); + LOG("rate (Hz): %ld", vorbisInfo->rate); + LOG("bitrate (upper): %ld", vorbisInfo->bitrate_upper); + LOG("bitrate (nominal): %ld", vorbisInfo->bitrate_nominal); + LOG("bitrate (lower): %ld", vorbisInfo->bitrate_lower); + LOG("bitrate (window): %ld", vorbisInfo->bitrate_window); + LOG("vendor: %s", vendor.c_str()); + + for (TagVector::const_iterator it = vorbisTags.begin(); it != vorbisTags.end(); ++it) { + LOG("%s", it->c_str()); + } +} + + +// clean up the OpenAL resources +void COggStream::ReleaseBuffers() +{ + stopped = true; + paused = false; + + EmptyBuffers(); + + alDeleteBuffers(2, buffers); + CheckError("COggStream::ReleaseBuffers"); + + ov_clear(&oggStream); +} + + +// returns true if both buffers were +// filled with data from the stream +bool COggStream::StartPlaying() +{ + msecsPlayed = spring_nulltime; + lastTick = spring_gettime(); + + if (!DecodeStream(buffers[0])) { return false; } + if (!DecodeStream(buffers[1])) { return false; } + + alSourceQueueBuffers(source, 2, buffers); CheckError("COggStream::StartPlaying"); + alSourcePlay(source); CheckError("COggStream::StartPlaying"); + + return true; +} + + +// returns true if we're still playing +bool COggStream::IsPlaying() +{ + ALenum state = 0; + alGetSourcei(source, AL_SOURCE_STATE, &state); + + return (state == AL_PLAYING); +} + +// stops the currently playing stream +void COggStream::Stop() +{ + if (stopped) { + return; + } + + ReleaseBuffers(); + msecsPlayed = spring_nulltime; + vorbisInfo = NULL; + lastTick = spring_gettime(); +} + +bool COggStream::TogglePause() +{ + if (!stopped) { + paused = !paused; + } + + return paused; +} + + +// pop the processed buffers from the queue, +// refill them, and push them back in line +bool COggStream::UpdateBuffers() +{ + int buffersProcessed = 0; + bool active = true; + + alGetSourcei(source, AL_BUFFERS_PROCESSED, &buffersProcessed); + + while (buffersProcessed-- > 0) { + ALuint buffer; + alSourceUnqueueBuffers(source, 1, &buffer); CheckError("COggStream::UpdateBuffers"); + + // false if we've reached end of stream + active = DecodeStream(buffer); + if (active) + alSourceQueueBuffers(source, 1, &buffer); CheckError("COggStream::UpdateBuffers"); + } + CheckError("COggStream::UpdateBuffers"); + + return active; +} + + +void COggStream::Update() +{ + if (stopped) { + return; + } + + spring_time tick = spring_gettime(); + + if (!paused) { + UpdateBuffers(); + + if (!IsPlaying()) { + ReleaseBuffers(); + } + + msecsPlayed += (tick - lastTick); + } + + lastTick = tick; +} + + +// read decoded data from audio stream into PCM buffer +bool COggStream::DecodeStream(ALuint buffer) +{ + memset(pcmDecodeBuffer, 0, BUFFER_SIZE); + + int size = 0; + int section = 0; + int result = 0; + + while (size < BUFFER_SIZE) { + result = ov_read(&oggStream, pcmDecodeBuffer + size, BUFFER_SIZE - size, 0, 2, 1, §ion); + + if (result > 0) { + size += result; + } else { + if (result < 0) { + LOG_L(L_WARNING, "Error reading Ogg stream (%s)", + ErrorString(result).c_str()); + } else { + break; + } + } + } + + if (size == 0) { + return false; + } + + alBufferData(buffer, format, pcmDecodeBuffer, size, vorbisInfo->rate); + CheckError("COggStream::DecodeStream"); + + return true; +} + + +// dequeue any buffers pending on source +void COggStream::EmptyBuffers() +{ + int queuedBuffers = 0; + alGetSourcei(source, AL_BUFFERS_QUEUED, &queuedBuffers); CheckError("COggStream::EmptyBuffers"); + + while (queuedBuffers-- > 0) { + ALuint buffer; + alSourceUnqueueBuffers(source, 1, &buffer); CheckError("COggStream::EmptyBuffers"); + } +} diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/OggStream.h spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/OggStream.h --- spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/OggStream.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/OggStream.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,73 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef OGG_STREAM_H +#define OGG_STREAM_H + +#include "System/Misc/SpringTime.h" + +#include +#include +#include + +#include +#include + + +class COggStream +{ +public: + typedef std::vector TagVector; + COggStream(ALuint _source); + ~COggStream(); + + void Play(const std::string& path, float volume); + void Stop(); + bool TogglePause(); + void Update(); + + float GetPlayTime() const; + float GetTotalTime(); + bool Valid() const; + bool IsFinished(); + + const TagVector& VorbisTags() const; + +private: + void DisplayInfo(); + bool IsPlaying(); + bool StartPlaying(); + + bool DecodeStream(ALuint buffer); + void EmptyBuffers(); + void ReleaseBuffers(); + + /** + * @brief Decode next part of the stream and queue it for playing + * @return whether it is the end of the stream + * (check for IsPlaying() whether the complete stream was played) + */ + bool UpdateBuffers(); + + OggVorbis_File oggStream; + vorbis_info* vorbisInfo; + + static const unsigned int BUFFER_SIZE = (512 * 1024); // 512KB + static const unsigned int NUM_BUFFERS = 2; + + char pcmDecodeBuffer[BUFFER_SIZE]; + + ALuint buffers[NUM_BUFFERS]; + ALuint source; + ALenum format; + + bool stopped; + bool paused; + + spring_time msecsPlayed; + spring_time lastTick; + + std::vector vorbisTags; + std::string vendor; +}; + +#endif // OGG_STREAM_H diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/SoundBuffer.cpp spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/SoundBuffer.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/SoundBuffer.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/SoundBuffer.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,287 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include "SoundBuffer.h" + + +#include "System/Sound/SoundLog.h" +#include "ALShared.h" +#include "VorbisShared.h" +#include "System/Platform/byteorder.h" + +#include +#include +#include + +namespace +{ +struct VorbisInputBuffer +{ + boost::uint8_t* data; + size_t pos; + size_t size; +}; + +size_t VorbisRead(void* ptr, size_t size, size_t nmemb, void* datasource) +{ + VorbisInputBuffer* buffer = static_cast(datasource); + const size_t maxRead = std::min(size * nmemb, buffer->size - buffer->pos); + memcpy(ptr, buffer->data + buffer->pos, maxRead); + buffer->pos += maxRead; + return maxRead; +} + +int VorbisClose(void* datasource) +{ + return 0; // nothing to be done here +} +} + +SoundBuffer::bufferMapT SoundBuffer::bufferMap; // filename, index into Buffers +SoundBuffer::bufferVecT SoundBuffer::buffers; + +SoundBuffer::SoundBuffer() : id(0), channels(0), length(0.0f) +{ +} + +SoundBuffer::~SoundBuffer() +{ +} + +#pragma pack(push, 1) +// Header copied from WavLib by Michael McTernan +struct WAVHeader +{ + boost::uint8_t riff[4]; // "RIFF" + boost::int32_t totalLength; + boost::uint8_t wavefmt[8]; // WAVEfmt " + boost::int32_t length; // Remaining length 4 bytes + boost::int16_t format_tag; + boost::int16_t channels; // Mono=1 Stereo=2 + boost::int32_t SamplesPerSec; + boost::int32_t AvgBytesPerSec; + boost::int16_t BlockAlign; + boost::int16_t BitsPerSample; + boost::uint8_t data[4]; // "data" + boost::int32_t datalen; // Raw data length 4 bytes +}; +#pragma pack(pop) + +bool SoundBuffer::LoadWAV(const std::string& file, std::vector buffer) +{ + WAVHeader* header = (WAVHeader*)(&buffer[0]); + + if ((buffer.empty()) || memcmp(header->riff, "RIFF", 4) || memcmp(header->wavefmt, "WAVEfmt", 7)) { + LOG_L(L_ERROR, "ReadWAV: invalid header: %s", file.c_str()); + return false; + } + +#define hswabword(c) swabWordInPlace(header->c) +#define hswabdword(c) swabDWordInPlace(header->c) + hswabword(format_tag); + hswabword(channels); + hswabword(BlockAlign); + hswabword(BitsPerSample); + + hswabdword(totalLength); + hswabdword(length); + hswabdword(SamplesPerSec); + hswabdword(AvgBytesPerSec); + hswabdword(datalen); +#undef hswabword +#undef hswabdword + + if (header->format_tag != 1) { // Microsoft PCM format? + LOG_L(L_ERROR, "ReadWAV (%s): invalid format tag", file.c_str()); + return false; + } + + ALenum format; + if (header->channels == 1) { + if (header->BitsPerSample == 8) format = AL_FORMAT_MONO8; + else if (header->BitsPerSample == 16) format = AL_FORMAT_MONO16; + else { + LOG_L(L_ERROR, "ReadWAV (%s): invalid number of bits per sample (mono)", file.c_str()); + return false; + } + } + else if (header->channels == 2) { + if (header->BitsPerSample == 8) format = AL_FORMAT_STEREO8; + else if (header->BitsPerSample == 16) format = AL_FORMAT_STEREO16; + else { + LOG_L(L_ERROR, "ReadWAV (%s): invalid number of bits per sample (stereo)", file.c_str()); + return false; + } + } + else { + LOG_L(L_ERROR, "ReadWAV (%s): invalid number of channels.", file.c_str()); + return false; + } + + if (static_cast(header->datalen) > buffer.size() - sizeof(WAVHeader)) { + LOG_L(L_ERROR, + "WAV file %s has data length %i greater than actual data length %i", + file.c_str(), header->datalen, + (int)(buffer.size() - sizeof(WAVHeader))); + +// LOG_L(L_WARNING, "OpenAL: size %d\n", size); +// LOG_L(L_WARNING, "OpenAL: sizeof(WAVHeader) %d\n", sizeof(WAVHeader)); +// LOG_L(L_WARNING, "OpenAL: format_tag %d\n", header->format_tag); +// LOG_L(L_WARNING, "OpenAL: channels %d\n", header->channels); +// LOG_L(L_WARNING, "OpenAL: BlockAlign %d\n", header->BlockAlign); +// LOG_L(L_WARNING, "OpenAL: BitsPerSample %d\n", header->BitsPerSample); +// LOG_L(L_WARNING, "OpenAL: totalLength %d\n", header->totalLength); +// LOG_L(L_WARNING, "OpenAL: length %d\n", header->length); +// LOG_L(L_WARNING, "OpenAL: SamplesPerSec %d\n", header->SamplesPerSec); +// LOG_L(L_WARNING, "OpenAL: AvgBytesPerSec %d\n", header->AvgBytesPerSec); + + header->datalen = boost::uint32_t(buffer.size() - sizeof(WAVHeader))&(~boost::uint32_t((header->BitsPerSample*header->channels)/8 -1)); + } + + if (!AlGenBuffer(file, format, &buffer[sizeof(WAVHeader)], header->datalen, header->SamplesPerSec)) { + LOG_L(L_WARNING, "Loading audio failed for %s", file.c_str()); + } + + filename = file; + channels = header->channels; + length = float(header->datalen) / (header->channels * header->SamplesPerSec * header->BitsPerSample); + + return true; +} + +bool SoundBuffer::LoadVorbis(const std::string& file, std::vector buffer) +{ + VorbisInputBuffer buf; + buf.data = &buffer[0]; + buf.pos = 0; + buf.size = buffer.size(); + + ov_callbacks vorbisCallbacks; + vorbisCallbacks.read_func = VorbisRead; + vorbisCallbacks.close_func = VorbisClose; + vorbisCallbacks.seek_func = NULL; + vorbisCallbacks.tell_func = NULL; + + OggVorbis_File oggStream; + const int result = ov_open_callbacks(&buf, &oggStream, NULL, 0, vorbisCallbacks); + if (result < 0) { + LOG_L(L_WARNING, "Could not open Ogg stream (reason: %s).", + ErrorString(result).c_str()); + return false; + } + + vorbis_info* vorbisInfo = ov_info(&oggStream, -1); + // vorbis_comment* vorbisComment = ov_comment(&oggStream, -1); + + ALenum format; + if (vorbisInfo->channels == 1) + { + format = AL_FORMAT_MONO16; + } + else if (vorbisInfo->channels == 2) + { + format = AL_FORMAT_STEREO16; + } + else + { + LOG_L(L_ERROR, "File %s: invalid number of channels: %i", + file.c_str(), vorbisInfo->channels); + return false; + } + + size_t pos = 0; + std::vector decodeBuffer(512*1024); // 512kb read buffer + int section = 0; + long read = 0; + do + { + if (4*pos > 3*decodeBuffer.size()) // enlarge buffer so ov_read has enough space + decodeBuffer.resize(decodeBuffer.size()*2); + read = ov_read(&oggStream, (char*)&decodeBuffer[pos], decodeBuffer.size() - pos, 0, 2, 1, §ion); + switch(read) + { + case OV_HOLE: + LOG_L(L_WARNING, + "%s: garbage or corrupt page in stream (non-fatal)", + file.c_str()); + continue; // read next + case OV_EBADLINK: + LOG_L(L_WARNING, "%s: corrupted stream", file.c_str()); + return false; // abort + case OV_EINVAL: + LOG_L(L_WARNING, "%s: corrupted headers", file.c_str()); + return false; // abort + default: + break; // all good + }; + pos += read; + } while (read > 0); // read == 0 indicated EOF, read < 0 is error + + AlGenBuffer(file, format, &decodeBuffer[0], pos, vorbisInfo->rate); + filename = file; + channels = vorbisInfo->channels; + length = ov_time_total(&oggStream, -1); + return true; +} + +int SoundBuffer::BufferSize() const +{ + ALint size; + alGetBufferi(id, AL_SIZE, &size); + return static_cast(size); +} + +void SoundBuffer::Initialise() +{ + buffers.resize(1); // empty ("zero") buffer +} + +void SoundBuffer::Deinitialise() +{ + bufferMap.clear(); + buffers.clear(); +} + +size_t SoundBuffer::GetId(const std::string& name) +{ + bufferMapT::const_iterator it = bufferMap.find(name); + if (it != bufferMap.end()) + return it->second; + else + return 0; +} + +boost::shared_ptr SoundBuffer::GetById(const size_t id) +{ + assert(id < buffers.size()); + return buffers.at(id); +} + +size_t SoundBuffer::Count() +{ + return buffers.size(); +} + +size_t SoundBuffer::AllocedSize() +{ + int numBytes = 0; + for (bufferVecT::const_iterator it = ++buffers.begin(); it != buffers.end(); ++it) + numBytes += (*it)->BufferSize(); + return numBytes; +} + +size_t SoundBuffer::Insert(boost::shared_ptr buffer) +{ + size_t bufId = buffers.size(); + buffers.push_back(buffer); + bufferMap[buffer->GetFilename()] = bufId; + return bufId; +} + +bool SoundBuffer::AlGenBuffer(const std::string& file, ALenum format, const boost::uint8_t* data, size_t datalength, int rate) +{ + alGenBuffers(1, &id); + if (!CheckError("SoundBuffer::AlGenBuffers")) + return false; + alBufferData(id, format, (ALvoid*) data, datalength, rate); + return CheckError("SoundBuffer::AlGenBufferData"); +} diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/SoundBuffer.h spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/SoundBuffer.h --- spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/SoundBuffer.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/SoundBuffer.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,79 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef SOUNDBUFFER_H +#define SOUNDBUFFER_H + +#include +#include +#include +#include +#include +#include +#include + +/** + * @brief A buffer holding a sound + * + * One of this will be created for each wav-file used. + * They are loaded on demand and unloaded when game ends. + * They can be shared among multiple SoundItem + */ +class SoundBuffer : boost::noncopyable +{ +public: + /// Construct an "empty" buffer + /// can be played, but you won't hear anything + SoundBuffer(); + ~SoundBuffer(); + + bool LoadWAV(const std::string& file, std::vector buffer); + bool LoadVorbis(const std::string& file, std::vector buffer); + + const std::string& GetFilename() const + { + return filename; + }; + + ALuint GetId() const + { + return id; + }; + + ALuint GetChannels() const + { + return channels; + }; + + ALfloat GetLength() const + { + return length; + }; + + int BufferSize() const; + + static void Initialise(); + static void Deinitialise(); + + static size_t GetId(const std::string& name); + static boost::shared_ptr GetById(const size_t id); + + static size_t Count(); + static size_t AllocedSize(); + + static size_t Insert(boost::shared_ptr buffer); +private: + bool AlGenBuffer(const std::string& file, ALenum format, const boost::uint8_t* data, size_t datalength, int rate); + + std::string filename; + ALuint id; + ALuint channels; + ALfloat length; + + typedef std::map bufferMapT; + typedef std::vector< boost::shared_ptr > bufferVecT; + static bufferMapT bufferMap; // filename, index into Buffers + static bufferVecT buffers; +}; + + +#endif diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/SoundChannels.cpp spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/SoundChannels.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/SoundChannels.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/SoundChannels.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,12 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include "AudioChannel.h" + +namespace Channels +{ + AudioChannel* BGMusic = NULL; + AudioChannel* General = NULL; + AudioChannel* Battle = NULL; + AudioChannel* UnitReply = NULL; + AudioChannel* UserInterface = NULL; +} diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/Sound.cpp spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/Sound.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/Sound.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/Sound.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,630 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include "Sound.h" + +#include +#include +#include +#ifndef ALC_ALL_DEVICES_SPECIFIER +//needed for ALC_ALL_DEVICES_SPECIFIER on some special *nix +#include +#endif +#include +#include + +#include "System/Sound/ISoundChannels.h" +#include "System/Sound/SoundLog.h" +#include "SoundSource.h" +#include "SoundBuffer.h" +#include "SoundItem.h" +#include "ALShared.h" +#include "EFX.h" +#include "EFXPresets.h" + +#include "System/TimeProfiler.h" +#include "System/Config/ConfigHandler.h" +#include "System/Exceptions.h" +#include "System/FileSystem/FileHandler.h" +#include "Lua/LuaParser.h" +#include "Map/Ground.h" +#include "Sim/Misc/GlobalConstants.h" +#include "System/myMath.h" +#include "System/Util.h" +#include "System/Platform/Watchdog.h" + +#include "System/float3.h" + +CONFIG(int, MaxSounds).defaultValue(128).minimumValue(0).description("Maximum parallel played sounds."); +CONFIG(bool, PitchAdjust).defaultValue(false).description("When enabled adjust sound speed/pitch to game speed."); +CONFIG(int, snd_volmaster).defaultValue(60).minimumValue(0).maximumValue(200).description("Master sound volume."); +CONFIG(int, snd_volgeneral).defaultValue(100).minimumValue(0).maximumValue(200).description("Volume for \"general\" sound channel."); +CONFIG(int, snd_volunitreply).defaultValue(100).minimumValue(0).maximumValue(200).description("Volume for \"unit reply\" sound channel."); +CONFIG(int, snd_volbattle).defaultValue(100).minimumValue(0).maximumValue(200).description("Volume for \"battle\" sound channel."); +CONFIG(int, snd_volui).defaultValue(100).minimumValue(0).maximumValue(200).description("Volume for \"ui\" sound channel."); +CONFIG(int, snd_volmusic).defaultValue(100).minimumValue(0).maximumValue(200).description("Volume for \"music\" sound channel."); +CONFIG(std::string, snd_device).defaultValue("").description("Sets the used output device. See \"Available Devices\" section in infolog.txt."); + +boost::recursive_mutex soundMutex; + + +CSound::CSound() + : myPos(ZeroVector) + , prevVelocity(ZeroVector) + , soundThread(NULL) + , soundThreadQuit(false) +{ + boost::recursive_mutex::scoped_lock lck(soundMutex); + mute = false; + appIsIconified = false; + int maxSounds = configHandler->GetInt("MaxSounds"); + pitchAdjust = configHandler->GetBool("PitchAdjust"); + + masterVolume = configHandler->GetInt("snd_volmaster") * 0.01f; + Channels::General->SetVolume(configHandler->GetInt("snd_volgeneral") * 0.01f); + Channels::UnitReply->SetVolume(configHandler->GetInt("snd_volunitreply") * 0.01f); + Channels::UnitReply->SetMaxConcurrent(1); + Channels::UnitReply->SetMaxEmmits(1); + Channels::Battle->SetVolume(configHandler->GetInt("snd_volbattle") * 0.01f); + Channels::UserInterface->SetVolume(configHandler->GetInt("snd_volui") * 0.01f); + Channels::BGMusic->SetVolume(configHandler->GetInt("snd_volmusic") * 0.01f); + + SoundBuffer::Initialise(); + soundItemDef temp; + temp["name"] = "EmptySource"; + sounds.push_back(NULL); + + if (maxSounds <= 0) { + LOG_L(L_WARNING, "MaxSounds set to 0, sound is disabled"); + } else { + soundThread = new boost::thread(boost::bind(&CSound::StartThread, this, maxSounds)); + } + + configHandler->NotifyOnChange(this); +} + +CSound::~CSound() +{ + soundThreadQuit = true; + configHandler->RemoveObserver(this); + + LOG_L(L_INFO, "[%s][1] soundThread=%p", __FUNCTION__, soundThread); + + if (soundThread != NULL) { + soundThread->join(); + delete soundThread; + soundThread = NULL; + } + + LOG_L(L_INFO, "[%s][2]", __FUNCTION__); + + for (soundVecT::iterator it = sounds.begin(); it != sounds.end(); ++it) + delete *it; + + sounds.clear(); + SoundBuffer::Deinitialise(); + + LOG_L(L_INFO, "[%s][3]", __FUNCTION__); +} + +bool CSound::HasSoundItem(const std::string& name) const +{ + soundMapT::const_iterator it = soundMap.find(name); + if (it != soundMap.end()) + { + return true; + } + else + { + soundItemDefMap::const_iterator it = soundItemDefs.find(StringToLower(name)); + if (it != soundItemDefs.end()) + return true; + else + return false; + } +} + +size_t CSound::GetSoundId(const std::string& name) +{ + boost::recursive_mutex::scoped_lock lck(soundMutex); + + if (sources.empty()) + return 0; + + soundMapT::const_iterator it = soundMap.find(name); + if (it != soundMap.end()) { + // sounditem found + return it->second; + } else { + soundItemDefMap::const_iterator itemDefIt = soundItemDefs.find(StringToLower(name)); + if (itemDefIt != soundItemDefs.end()) { + return MakeItemFromDef(itemDefIt->second); + } else { + if (LoadSoundBuffer(name) > 0) // maybe raw filename? + { + soundItemDef temp = defaultItem; + temp["file"] = name; + return MakeItemFromDef(temp); + } else { + LOG_L(L_ERROR, "CSound::GetSoundId: could not find sound: %s", name.c_str()); + return 0; + } + } + } +} + +SoundItem* CSound::GetSoundItem(size_t id) const { + //! id==0 is a special id and invalid + if (id == 0 || id >= sounds.size()) + return NULL; + return sounds[id]; +} + +CSoundSource* CSound::GetNextBestSource(bool lock) +{ + boost::recursive_mutex::scoped_lock lck(soundMutex, boost::defer_lock); + if (lock) + lck.lock(); + + if (sources.empty()) + return NULL; + + CSoundSource* bestPos = NULL; + for (sourceVecT::iterator it = sources.begin(); it != sources.end(); ++it) + { + if (!it->IsPlaying()) + { + return &(*it); + } + else if (it->GetCurrentPriority() <= (bestPos ? bestPos->GetCurrentPriority() : INT_MAX)) + { + bestPos = &(*it); + } + } + return bestPos; +} + +void CSound::PitchAdjust(const float newPitch) +{ + boost::recursive_mutex::scoped_lock lck(soundMutex); + if (pitchAdjust) + CSoundSource::SetPitch(newPitch); +} + +void CSound::ConfigNotify(const std::string& key, const std::string& value) +{ + boost::recursive_mutex::scoped_lock lck(soundMutex); + if (key == "snd_volmaster") + { + masterVolume = std::atoi(value.c_str()) * 0.01f; + if (!mute && !appIsIconified) + alListenerf(AL_GAIN, masterVolume); + } + else if (key == "snd_eaxpreset") + { + efx->SetPreset(value); + } + else if (key == "snd_filter") + { + float gainlf = 1.f; + float gainhf = 1.f; + sscanf(value.c_str(), "%f %f", &gainlf, &gainhf); + efx->sfxProperties->filter_properties_f[AL_LOWPASS_GAIN] = gainlf; + efx->sfxProperties->filter_properties_f[AL_LOWPASS_GAINHF] = gainhf; + efx->CommitEffects(); + } + else if (key == "UseEFX") + { + bool enable = (std::atoi(value.c_str()) != 0); + if (enable) + efx->Enable(); + else + efx->Disable(); + } + else if (key == "snd_volgeneral") + { + Channels::General->SetVolume(std::atoi(value.c_str()) * 0.01f); + } + else if (key == "snd_volunitreply") + { + Channels::UnitReply->SetVolume(std::atoi(value.c_str()) * 0.01f); + } + else if (key == "snd_volbattle") + { + Channels::Battle->SetVolume(std::atoi(value.c_str()) * 0.01f); + } + else if (key == "snd_volui") + { + Channels::UserInterface->SetVolume(std::atoi(value.c_str()) * 0.01f); + } + else if (key == "snd_volmusic") + { + Channels::BGMusic->SetVolume(std::atoi(value.c_str()) * 0.01f); + } + else if (key == "PitchAdjust") + { + bool tempPitchAdjust = (std::atoi(value.c_str()) != 0); + if (!tempPitchAdjust) + PitchAdjust(1.0); + pitchAdjust = tempPitchAdjust; + } +} + +bool CSound::Mute() +{ + boost::recursive_mutex::scoped_lock lck(soundMutex); + mute = !mute; + if (mute) + alListenerf(AL_GAIN, 0.0); + else + alListenerf(AL_GAIN, masterVolume); + return mute; +} + +bool CSound::IsMuted() const +{ + return mute; +} + +void CSound::Iconified(bool state) +{ + boost::recursive_mutex::scoped_lock lck(soundMutex); + if (appIsIconified != state && !mute) + { + if (state == false) + alListenerf(AL_GAIN, masterVolume); + else if (state == true) + alListenerf(AL_GAIN, 0.0); + } + appIsIconified = state; +} + +__FORCE_ALIGN_STACK__ +void CSound::StartThread(int maxSounds) +{ + { + boost::recursive_mutex::scoped_lock lck(soundMutex); + + // alc... will create its own thread it will copy the name from the current thread. + // Later we finally rename `our` audio thread. + Threading::SetThreadName("openal"); + + // NULL -> default device + const ALchar* deviceName = NULL; + std::string configDeviceName = ""; + + // we do not want to set a default for snd_device, + // so we do it like this ... + if (configHandler->IsSet("snd_device")) + { + configDeviceName = configHandler->GetString("snd_device"); + deviceName = configDeviceName.c_str(); + } + + ALCdevice* device = alcOpenDevice(deviceName); + + if ((device == NULL) && (deviceName != NULL)) + { + LOG_L(L_WARNING, + "Could not open the sound device \"%s\", trying the default device ...", + deviceName); + configDeviceName = ""; + deviceName = NULL; + device = alcOpenDevice(deviceName); + } + + if (device == NULL) + { + LOG_L(L_ERROR, "Could not open a sound device, disabling sounds"); + CheckError("CSound::InitAL"); + return; + } + else + { + ALCcontext *context = alcCreateContext(device, NULL); + if (context != NULL) + { + alcMakeContextCurrent(context); + CheckError("CSound::CreateContext"); + } + else + { + alcCloseDevice(device); + LOG_L(L_ERROR, "Could not create OpenAL audio context"); + return; + } + } + maxSounds = GetMaxMonoSources(device, maxSounds); + + LOG("OpenAL info:"); + if(alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT")) + { + LOG(" Available Devices:"); + const char* deviceSpecifier = alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER); + while (*deviceSpecifier != '\0') { + LOG(" %s", deviceSpecifier); + while (*deviceSpecifier++ != '\0') + ; + } + LOG(" Device: %s", (const char*)alcGetString(device, ALC_DEVICE_SPECIFIER)); + } + LOG(" Vendor: %s", (const char*)alGetString(AL_VENDOR)); + LOG(" Version: %s", (const char*)alGetString(AL_VERSION)); + LOG(" Renderer: %s", (const char*)alGetString(AL_RENDERER)); + LOG(" AL Extensions: %s", (const char*)alGetString(AL_EXTENSIONS)); + LOG(" ALC Extensions: %s", (const char*)alcGetString(device, ALC_EXTENSIONS)); + + // Init EFX + efx = new CEFX(device); + + // Generate sound sources + for (int i = 0; i < maxSounds; i++) + { + CSoundSource* thenewone = new CSoundSource(); + if (thenewone->IsValid()) { + sources.push_back(thenewone); + } else { + maxSounds = std::max(i-1, 0); + LOG_L(L_WARNING, + "Your hardware/driver can not handle more than %i soundsources", + maxSounds); + delete thenewone; + break; + } + } + LOG(" Max Sounds: %i", maxSounds); + + // Set distance model (sound attenuation) + alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED); + alDopplerFactor(0.2f); + + alListenerf(AL_GAIN, masterVolume); + } + + Threading::SetThreadName("audio"); + Watchdog::RegisterThread(WDT_AUDIO); + + while (!soundThreadQuit) { + boost::this_thread::sleep(boost::posix_time::millisec(50)); //! 20Hz + Watchdog::ClearTimer(WDT_AUDIO); + Update(); + } + + Watchdog::DeregisterThread(WDT_AUDIO); + + sources.clear(); // delete all sources + delete efx; // must happen after sources and before context + efx = NULL; + ALCcontext* curcontext = alcGetCurrentContext(); + ALCdevice* curdevice = alcGetContextsDevice(curcontext); + alcMakeContextCurrent(NULL); + alcDestroyContext(curcontext); + alcCloseDevice(curdevice); +} + +void CSound::Update() +{ + boost::recursive_mutex::scoped_lock lck(soundMutex); // lock + for (sourceVecT::iterator it = sources.begin(); it != sources.end(); ++it) + it->Update(); + CheckError("CSound::Update"); +} + +size_t CSound::MakeItemFromDef(const soundItemDef& itemDef) +{ + //! MakeItemFromDef is private. Only caller is LoadSoundDefs and it sets the mutex itself. + //boost::recursive_mutex::scoped_lock lck(soundMutex); + const size_t newid = sounds.size(); + soundItemDef::const_iterator it = itemDef.find("file"); + if (it == itemDef.end()) + return 0; + + boost::shared_ptr buffer = SoundBuffer::GetById(LoadSoundBuffer(it->second)); + + if (!buffer) + return 0; + + SoundItem* buf = new SoundItem(buffer, itemDef); + sounds.push_back(buf); + soundMap[buf->Name()] = newid; + return newid; +} + +void CSound::UpdateListener(const float3& campos, const float3& camdir, const float3& camup, float lastFrameTime) +{ + boost::recursive_mutex::scoped_lock lck(soundMutex); + if (sources.empty()) + return; + + myPos = campos; + const float3 myPosInMeters = myPos * ELMOS_TO_METERS; + alListener3f(AL_POSITION, myPosInMeters.x, myPosInMeters.y, myPosInMeters.z); + + //! reduce the rolloff when the camera is high above the ground (so we still hear something in tab mode or far zoom) + //! for altitudes up to and including 600 elmos, the rolloff is always clamped to 1 + const float camHeight = std::max(1.0f, campos.y - CGround::GetHeightAboveWater(campos.x, campos.z)); + const float newMod = std::min(600.0f / camHeight, 1.0f); + + CSoundSource::SetHeightRolloffModifer(newMod); + efx->SetHeightRolloffModifer(newMod); + + //! Result were bad with listener related doppler effects. + //! The user experiences the camera/listener not as a world-interacting object. + //! So changing sounds on camera movements were irritating, esp. because zooming with the mouse wheel + //! often is faster than the speed of sound, causing very high frequencies. + //! Note: soundsource related doppler effects are not deactivated by this! Flying cannon shoots still change their frequencies. + //! Note2: by not updating the listener velocity soundsource related velocities are calculated wrong, + //! so even if the camera is moving with a cannon shoot the frequency gets changed. + /* + const float3 velocity = (myPos - prevPos) / (lastFrameTime); + float3 velocityAvg = velocity * 0.6f + prevVelocity * 0.4f; + prevVelocity = velocityAvg; + velocityAvg *= ELMOS_TO_METERS; + velocityAvg.y *= 0.001f; //! scale vertical axis separatly (zoom with mousewheel is faster than speed of sound!) + velocityAvg *= 0.15f; + alListener3f(AL_VELOCITY, velocityAvg.x, velocityAvg.y, velocityAvg.z); + */ + + ALfloat ListenerOri[] = {camdir.x, camdir.y, camdir.z, camup.x, camup.y, camup.z}; + alListenerfv(AL_ORIENTATION, ListenerOri); + CheckError("CSound::UpdateListener"); +} + +void CSound::PrintDebugInfo() +{ + boost::recursive_mutex::scoped_lock lck(soundMutex); + + LOG_L(L_DEBUG, "OpenAL Sound System:"); + LOG_L(L_DEBUG, "# SoundSources: %i", (int)sources.size()); + LOG_L(L_DEBUG, "# SoundBuffers: %i", (int)SoundBuffer::Count()); + + LOG_L(L_DEBUG, "# reserved for buffers: %i kB", (int)(SoundBuffer::AllocedSize() / 1024)); + LOG_L(L_DEBUG, "# PlayRequests for empty sound: %i", numEmptyPlayRequests); + LOG_L(L_DEBUG, "# Samples disrupted: %i", numAbortedPlays); + LOG_L(L_DEBUG, "# SoundItems: %i", (int)sounds.size()); +} + +bool CSound::LoadSoundDefsImpl(const std::string& fileName) +{ + //! can be called from LuaUnsyncedCtrl too + boost::recursive_mutex::scoped_lock lck(soundMutex); + + LuaParser parser(fileName, SPRING_VFS_MOD, SPRING_VFS_ZIP); + parser.Execute(); + if (!parser.IsValid()) + { + LOG_L(L_WARNING, "Could not load %s: %s", + fileName.c_str(), parser.GetErrorLog().c_str()); + return false; + } + else + { + const LuaTable soundRoot = parser.GetRoot(); + const LuaTable soundItemTable = soundRoot.SubTable("SoundItems"); + if (!soundItemTable.IsValid()) + { + LOG_L(L_WARNING, "CSound(): could not parse SoundItems table in %s", fileName.c_str()); + return false; + } + else + { + std::vector keys; + soundItemTable.GetKeys(keys); + for (std::vector::const_iterator it = keys.begin(); it != keys.end(); ++it) + { + std::string name(*it); + + soundItemDef bufmap; + const LuaTable buf(soundItemTable.SubTable(name)); + buf.GetMap(bufmap); + bufmap["name"] = name; + soundItemDefMap::const_iterator sit = soundItemDefs.find(name); + + if (name == "default") { + defaultItem = bufmap; + defaultItem.erase("name"); //must be empty for default item + defaultItem.erase("file"); + continue; + } + + if (sit != soundItemDefs.end()) + LOG_L(L_WARNING, "Sound %s gets overwritten by %s", name.c_str(), fileName.c_str()); + + if (!buf.KeyExists("file")) { + // no file, drop + LOG_L(L_WARNING, "Sound %s is missing file tag (ignoring)", name.c_str()); + continue; + } else { + soundItemDefs[name] = bufmap; + } + + if (buf.KeyExists("preload")) { + MakeItemFromDef(bufmap); + } + } + LOG(" parsed %i sounds from %s", (int)keys.size(), fileName.c_str()); + } + } + + //FIXME why do sounds w/o an own soundItemDef create (!=pointer) a new one from the defaultItem? + for (soundItemDefMap::iterator it = soundItemDefs.begin(); it != soundItemDefs.end(); ++it) { + soundItemDef& snddef = it->second; + if (snddef.find("name") == snddef.end()) { + // uses defaultItem! update it! + const std::string file = snddef["file"]; + snddef = defaultItem; + snddef["file"] = file; + } + } + + return true; +} + +//! only used internally, locked in caller's scope +size_t CSound::LoadSoundBuffer(const std::string& path) +{ + const size_t id = SoundBuffer::GetId(path); + + if (id > 0) { + return id; // file is loaded already + } else { + CFileHandler file(path); + + if (!file.FileExists()) { + LOG_L(L_ERROR, "Unable to open audio file: %s", path.c_str()); + return 0; + } + + std::vector buf(file.FileSize()); + file.Read(&buf[0], file.FileSize()); + + boost::shared_ptr buffer(new SoundBuffer()); + bool success = false; + const std::string ending = file.GetFileExt(); + if (ending == "wav") { + success = buffer->LoadWAV(path, buf); + } else if (ending == "ogg") { + success = buffer->LoadVorbis(path, buf); + } else { + LOG_L(L_WARNING, "CSound::LoadALBuffer: unknown audio format: %s", + ending.c_str()); + } + + CheckError("CSound::LoadALBuffer"); + if (!success) { + LOG_L(L_WARNING, "Failed to load file: %s", path.c_str()); + return 0; + } + + return SoundBuffer::Insert(buffer); + } +} + +void CSound::NewFrame() +{ + Channels::General->UpdateFrame(); + Channels::Battle->UpdateFrame(); + Channels::UnitReply->UpdateFrame(); + Channels::UserInterface->UpdateFrame(); +} + + +// try to get the maximum number of supported sounds, this is similar to code CSound::StartThread +// but should be more safe +int CSound::GetMaxMonoSources(ALCdevice* device, int maxSounds) +{ + ALCint size; + alcGetIntegerv(device, ALC_ATTRIBUTES_SIZE, 1, &size); + std::vector attrs(size); + alcGetIntegerv(device, ALC_ALL_ATTRIBUTES, size, &attrs[0] ); + for (int i=0; i +#include +#include +#include +#include +#include + +#include "System/float3.h" + +#include "SoundItem.h" + +class CSoundSource; +class SoundBuffer; +class SoundItem; +struct ALCdevice_struct; +typedef struct ALCdevice_struct ALCdevice; + +namespace boost { + class thread; +} + + +/// Default sound system implementation (OpenAL) +class CSound : public ISound +{ +public: + CSound(); + virtual ~CSound(); + + virtual bool HasSoundItem(const std::string& name) const; + virtual size_t GetSoundId(const std::string& name); + SoundItem* GetSoundItem(size_t id) const; + + virtual CSoundSource* GetNextBestSource(bool lock = true); + + virtual void UpdateListener(const float3& campos, const float3& camdir, const float3& camup, float lastFrameTime); + virtual void NewFrame(); + + /// @see ConfigHandler::ConfigNotifyCallback + virtual void ConfigNotify(const std::string& key, const std::string& value); + virtual void PitchAdjust(const float newPitch); + + virtual bool Mute(); + virtual bool IsMuted() const; + + virtual void Iconified(bool state); + + virtual void PrintDebugInfo(); + virtual bool LoadSoundDefsImpl(const std::string& fileName); + const float3& GetListenerPos() const { + return myPos; + } + +private: + typedef std::map soundItemDef; + typedef std::map soundItemDefMap; + +private: + void StartThread(int maxSounds); + void Update(); + int GetMaxMonoSources(ALCdevice* device, int maxSounds); + + size_t MakeItemFromDef(const soundItemDef& itemDef); + + size_t LoadSoundBuffer(const std::string& filename); + +private: + float masterVolume; + bool mute; + /// we do not play if minimized / iconified + bool appIsIconified; + bool pitchAdjust; + + typedef std::map soundMapT; + typedef std::vector soundVecT; + soundMapT soundMap; + soundVecT sounds; + + /// unscaled + float3 myPos; + float3 prevVelocity; + + typedef boost::ptr_vector sourceVecT; + sourceVecT sources; + + soundItemDef defaultItem; + soundItemDefMap soundItemDefs; + + boost::thread* soundThread; + + volatile bool soundThreadQuit; +}; + +#endif // _SOUND_H_ diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/SoundItem.cpp spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/SoundItem.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/SoundItem.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/SoundItem.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,103 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include "SoundItem.h" + +#include +#include +#include + +#include "SoundBuffer.h" +#include "System/UnsyncedRNG.h" + +namespace +{ + UnsyncedRNG randnum; // no need for strong randomness here, so default seed is ok + + template + inline bool MapEntryValExtract(const std::map& map, const std::string& key, T& t) + { + std::map::const_iterator it = map.find(key); + if (it != map.end()) + { + std::istringstream stream(it->second); + stream >> t; + return true; + } + else + return false; + } + + template + void FitInIntervall(const T& lower, T& val, const T& upper) + { + val = std::max(std::min(val, upper), lower); + } +} + +SoundItem::SoundItem(boost::shared_ptr _buffer, const std::map& items) + : buffer(_buffer) + , gain(1.0) + , gainMod(0) + , pitch(1.0) + , pitchMod(0) + , dopplerScale(1.0) + , maxDist(FLT_MAX) + , rolloff(1.0f) + , priority(0) + , maxConcurrent(16) + , currentlyPlaying(0) + , loopTime(0) + , in3D(true) +{ + if (!MapEntryValExtract(items, "name", name)) + name = buffer->GetFilename(); + + MapEntryValExtract(items, "gain", gain); + MapEntryValExtract(items, "gainmod", gainMod); + FitInIntervall(0.f, gainMod, 1.f); + MapEntryValExtract(items, "pitch", pitch); + MapEntryValExtract(items, "pitchmod", pitchMod); + FitInIntervall(0.f, pitchMod, 1.f); + MapEntryValExtract(items, "dopplerscale", dopplerScale); + MapEntryValExtract(items, "priority", priority); + MapEntryValExtract(items, "maxconcurrent", maxConcurrent); + MapEntryValExtract(items, "maxdist", maxDist); + MapEntryValExtract(items, "rolloff", rolloff); + MapEntryValExtract(items, "in3d", in3D); + MapEntryValExtract(items, "looptime", loopTime); +} + +bool SoundItem::PlayNow() +{ + if (maxConcurrent >= currentlyPlaying) + { + currentlyPlaying++; + return true; + } + else + { + return false; + } +} + +void SoundItem::StopPlay() +{ + assert(currentlyPlaying > 0); + --currentlyPlaying; +} + +float SoundItem::GetGain() const +{ + float tgain = 0; + if (gainMod > 0) + tgain = (float(randnum(200))/100.f - 1.f)*gainMod; + return gain * (1.f + tgain); +} + +float SoundItem::GetPitch() const +{ + float tpitch = 0; + if (pitchMod > 0) + tpitch = (float(randnum(200))/100.f - 1.f)*pitchMod; + return pitch * (1.f + tpitch); +} diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/SoundItem.h spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/SoundItem.h --- spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/SoundItem.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/SoundItem.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,69 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef SOUNDITEM_H +#define SOUNDITEM_H + +#include +#include +#include + +class SoundBuffer; + +/** + * @brief A class representing a sound which can be played + * + * This can be played by CSoundSource. + * Each soundsource has exactly one SoundBuffer it wraps around, while one buffer can be shared among multiple Items. + * You can adjust various playing parameters within this class, sou you can have 1 buffer and multiple SoundItems + * which differ in pitch, volume etc. + */ +class SoundItem +{ + friend class CSoundSource; +public: + SoundItem(boost::shared_ptr buffer, const std::map& items); + + bool PlayNow(); + void StopPlay(); + float MaxDistance() const + { + return maxDist; + }; + const std::string& Name() const + { + return name; + }; + const int GetPriority() const + { + return priority; + }; + + float GetGain() const; + float GetPitch() const; + +private: + boost::shared_ptr buffer; + /// unique identifier (if no name is specified, this will be the filename + std::string name; + + /// volume gain, applied to this sound + float gain; + float gainMod; + /// sound pitch (multiplied with globalPitch from CSoundSource when played) + float pitch; + float pitchMod; + float dopplerScale; + + float maxDist; + float rolloff; + int priority; + + unsigned maxConcurrent; + unsigned currentlyPlaying; + + unsigned loopTime; + + bool in3D; +}; + +#endif diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/SoundSource.cpp spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/SoundSource.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/SoundSource.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/SoundSource.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,287 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include "SoundSource.h" + +#include +#include + +#include "ALShared.h" +#include "EFX.h" +#include "System/Sound/IAudioChannel.h" +#include "OggStream.h" +#include "System/Sound/SoundLog.h" +#include "SoundBuffer.h" +#include "SoundItem.h" + +#include "Sound.h" //remove when unified ElmoInMeters + +#include "Sim/Misc/GlobalConstants.h" +#include "System/float3.h" +#include "System/Util.h" +#include "System/myMath.h" + +float CSoundSource::referenceDistance = 200.0f; +float CSoundSource::globalPitch = 1.0; +float CSoundSource::heightRolloffModifier = 1.0f; +static const float ROLLOFF_FACTOR = 5.f; + +CSoundSource::CSoundSource() + : curPlaying(NULL) + , curChannel(NULL) + , curStream(NULL) + , curVolume(1.f) + , loopStop(1e9) + , in3D(false) + , efxEnabled(false) + , efxUpdates(0) + , curHeightRolloffModifier(1) +{ + alGenSources(1, &id); + if (!CheckError("CSoundSource::CSoundSource")) { + id = 0; + } else { + alSourcef(id, AL_REFERENCE_DISTANCE, referenceDistance * ELMOS_TO_METERS); + CheckError("CSoundSource::CSoundSource"); + } +} + +CSoundSource::~CSoundSource() +{ + if (efxEnabled) { + alSource3i(id, AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL); + alSourcei(id, AL_DIRECT_FILTER, AL_FILTER_NULL); + } + + Stop(); + alDeleteSources(1, &id); + CheckError("CSoundSource::~CSoundSource"); +} + +void CSoundSource::Update() +{ + if (curPlaying) { + if (in3D && (efxEnabled != efx->enabled)) { + alSourcef(id, AL_AIR_ABSORPTION_FACTOR, (efx->enabled) ? efx->GetAirAbsorptionFactor() : 0); + alSource3i(id, AL_AUXILIARY_SEND_FILTER, (efx->enabled) ? efx->sfxSlot : AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL); + alSourcei(id, AL_DIRECT_FILTER, (efx->enabled) ? efx->sfxFilter : AL_FILTER_NULL); + efxEnabled = efx->enabled; + efxUpdates = efx->updates; + } + + if (heightRolloffModifier != curHeightRolloffModifier) { + curHeightRolloffModifier = heightRolloffModifier; + alSourcef(id, AL_ROLLOFF_FACTOR, ROLLOFF_FACTOR * curPlaying->rolloff * heightRolloffModifier); + } + + if (!IsPlaying() || ((curPlaying->loopTime > 0) && (spring_gettime() > loopStop))) + Stop(); + } + + if (curStream) { + if (curStream->IsFinished()) { + Stop(); + } + else { + curStream->Update(); + CheckError("CSoundSource::Update"); + } + } + + if (efxEnabled && (efxUpdates != efx->updates)) { + //! airAbsorption & LowPass aren't auto updated by OpenAL on change, so we need to do it per source + alSourcef(id, AL_AIR_ABSORPTION_FACTOR, efx->GetAirAbsorptionFactor()); + alSourcei(id, AL_DIRECT_FILTER, efx->sfxFilter); + efxUpdates = efx->updates; + } +} + +int CSoundSource::GetCurrentPriority() const +{ + if (curStream) { + return INT_MAX; + } + else if (!curPlaying) { + return INT_MIN; + } + return curPlaying->priority; +} + +bool CSoundSource::IsPlaying() const +{ + if (curStream) + return true; + + if (!curPlaying) + return false; + + CheckError("CSoundSource::IsPlaying"); + ALint state; + alGetSourcei(id, AL_SOURCE_STATE, &state); + CheckError("CSoundSource::IsPlaying"); + return (state == AL_PLAYING); +} + +void CSoundSource::Stop() +{ + alSourceStop(id); + if (curPlaying) { + curPlaying->StopPlay(); + curPlaying = NULL; + } + if (curStream) { + SafeDelete(curStream); + } + if (curChannel) { + curChannel->SoundSourceFinished(this); + curChannel = NULL; + } + CheckError("CSoundSource::Stop"); +} + +void CSoundSource::Play(IAudioChannel* channel, SoundItem* item, float3 pos, float3 velocity, float volume, bool relative) +{ + assert(!curStream); + assert(channel); + if (!item->PlayNow()) + return; + Stop(); + curVolume = volume; + curPlaying = item; + curChannel = channel; + alSourcei(id, AL_BUFFER, item->buffer->GetId()); + alSourcef(id, AL_GAIN, volume * item->GetGain() * channel->volume); + alSourcef(id, AL_PITCH, item->GetPitch() * globalPitch); + velocity *= item->dopplerScale * ELMOS_TO_METERS; + alSource3f(id, AL_VELOCITY, velocity.x, velocity.y, velocity.z); + alSourcei(id, AL_LOOPING, (item->loopTime > 0) ? AL_TRUE : AL_FALSE); + loopStop = spring_gettime() + spring_msecs(item->loopTime); + if (relative || !item->in3D) { + in3D = false; + if (efxEnabled) { + alSource3i(id, AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL); + alSourcei(id, AL_DIRECT_FILTER, AL_FILTER_NULL); + efxEnabled = false; + } + alSourcei(id, AL_SOURCE_RELATIVE, AL_TRUE); + alSourcef(id, AL_ROLLOFF_FACTOR, 0.f); + alSource3f(id, AL_POSITION, 0.0f, 0.0f, -1.0f * ELMOS_TO_METERS); +#ifdef __APPLE__ + alSourcef(id, AL_REFERENCE_DISTANCE, referenceDistance * ELMOS_TO_METERS); +#endif + } else { + if (item->buffer->GetChannels() > 1) { + LOG_L(L_WARNING, "Can not play non-mono \"%s\" in 3d.", + item->buffer->GetFilename().c_str()); + } + + in3D = true; + if (efx->enabled) { + efxEnabled = true; + alSourcef(id, AL_AIR_ABSORPTION_FACTOR, efx->GetAirAbsorptionFactor()); + alSource3i(id, AL_AUXILIARY_SEND_FILTER, efx->sfxSlot, 0, AL_FILTER_NULL); + alSourcei(id, AL_DIRECT_FILTER, efx->sfxFilter); + efxUpdates = efx->updates; + } + alSourcei(id, AL_SOURCE_RELATIVE, AL_FALSE); + pos *= ELMOS_TO_METERS; + alSource3f(id, AL_POSITION, pos.x, pos.y, pos.z); + curHeightRolloffModifier = heightRolloffModifier; + alSourcef(id, AL_ROLLOFF_FACTOR, ROLLOFF_FACTOR * item->rolloff * heightRolloffModifier); +#ifdef __APPLE__ + alSourcef(id, AL_MAX_DISTANCE, 1000000.0f); + //! Max distance is too small by default on my Mac... + ALfloat gain = channel->volume * item->GetGain() * volume; + if (gain > 1.0f) { + //! OpenAL on Mac cannot handle AL_GAIN > 1 well, so we will adjust settings to get the same output with AL_GAIN = 1. + ALint model = alGetInteger(AL_DISTANCE_MODEL); + ALfloat rolloff = ROLLOFF_FACTOR * item->rolloff * heightRolloffModifier; + ALfloat ref = referenceDistance * ELMOS_TO_METERS; + if ((model == AL_INVERSE_DISTANCE_CLAMPED) || (model == AL_INVERSE_DISTANCE)) { + alSourcef(id, AL_REFERENCE_DISTANCE, ((gain - 1.0f) * ref / rolloff) + ref); + alSourcef(id, AL_ROLLOFF_FACTOR, (gain + rolloff - 1.0f) / gain); + alSourcef(id, AL_GAIN, 1.0f); + } + } else { + alSourcef(id, AL_REFERENCE_DISTANCE, referenceDistance * ELMOS_TO_METERS); + } +#endif + } + alSourcePlay(id); + + if (item->buffer->GetId() == 0) { + LOG_L(L_WARNING, + "CSoundSource::Play: Empty buffer for item %s (file %s)", + item->name.c_str(), item->buffer->GetFilename().c_str()); + } + CheckError("CSoundSource::Play"); +} + +void CSoundSource::PlayStream(IAudioChannel* channel, const std::string& file, float volume) +{ + //! stop any current playback + Stop(); + + if (!curStream) + curStream = new COggStream(id); + + //! setup OpenAL params + curChannel = channel; + curVolume = volume; + in3D = false; + if (efxEnabled) { + alSource3i(id, AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL); + alSourcei(id, AL_DIRECT_FILTER, AL_FILTER_NULL); + efxEnabled = false; + } + alSource3f(id, AL_POSITION, 0.0f, 0.0f, 0.0f); + alSourcef(id, AL_GAIN, volume); + alSource3f(id, AL_VELOCITY, 0.0f, 0.0f, 0.0f); + alSource3f(id, AL_DIRECTION, 0.0f, 0.0f, 0.0f); + alSourcef(id, AL_ROLLOFF_FACTOR, 0.0f); + alSourcei(id, AL_SOURCE_RELATIVE, AL_TRUE); + + //! COggStreams only appends buffers, giving errors when a buffer of another format is still assigned + alSourcei(id, AL_BUFFER, AL_NONE); + curStream->Play(file, volume); + curStream->Update(); + CheckError("CSoundSource::Update"); +} + +void CSoundSource::StreamStop() +{ + if (curStream) + Stop(); +} + +void CSoundSource::StreamPause() +{ + if (curStream) { + if (curStream->TogglePause()) + alSourcePause(id); + else + alSourcePlay(id); + } +} + +float CSoundSource::GetStreamTime() +{ + return curStream ? curStream->GetTotalTime() : 0; +} + +float CSoundSource::GetStreamPlayTime() +{ + return curStream ? curStream->GetPlayTime() : 0; +} + +void CSoundSource::UpdateVolume() +{ + if (!curChannel) + return; + + if (curStream) { + alSourcef(id, AL_GAIN, curVolume * curChannel->volume); + } + else if (curPlaying) { + alSourcef(id, AL_GAIN, curVolume * curPlaying->GetGain() * curChannel->volume); + } +} diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/SoundSource.h spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/SoundSource.h --- spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/SoundSource.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/SoundSource.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,77 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef SOUNDSOURCE_H +#define SOUNDSOURCE_H + +#include + +#include +#include +#include "System/Misc/SpringTime.h" + +class IAudioChannel; +class float3; +class SoundItem; +class COggStream; + +/** + * @brief One soundsource wich can play some sounds + * + * Construct some of them, and they can play SoundItems positioned anywhere in 3D-space for you. + */ +class CSoundSource : boost::noncopyable +{ +public: + /// is ready after this + CSoundSource(); + /// will stop during deletion + ~CSoundSource(); + + void Update(); + + void UpdateVolume(); + bool IsValid() const { return (id != 0); }; + + int GetCurrentPriority() const; + bool IsPlaying() const; + void Stop(); + + /// will stop a currently playing sound, if any + void Play(IAudioChannel* channel, SoundItem* buffer, float3 pos, float3 velocity, float volume, bool relative = false); + void PlayStream(IAudioChannel* channel, const std::string& stream, float volume); + void StreamStop(); + void StreamPause(); + float GetStreamTime(); + float GetStreamPlayTime(); + + static void SetPitch(const float& newPitch) + { + globalPitch = newPitch; + }; + static void SetHeightRolloffModifer(const float& mod) + { + heightRolloffModifier = mod; + }; + +private: + static float referenceDistance; + + //! used to adjust the pitch to the GameSpeed (optional) + static float globalPitch; + + //! reduce the rolloff when the camera is height above the ground (so we still hear something in tab mode or far zoom) + static float heightRolloffModifier; + + ALuint id; + SoundItem* curPlaying; + IAudioChannel* curChannel; + COggStream* curStream; + float curVolume; + spring_time loopStop; + bool in3D; + bool efxEnabled; + int efxUpdates; + ALfloat curHeightRolloffModifier; +}; + +#endif diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/VorbisShared.cpp spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/VorbisShared.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/VorbisShared.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/VorbisShared.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,24 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include "VorbisShared.h" + +#include +#include + +std::string ErrorString(int code) +{ + switch (code) { + case OV_EREAD: + return std::string("Read from media."); + case OV_ENOTVORBIS: + return std::string("Not Vorbis data."); + case OV_EVERSION: + return std::string("Vorbis version mismatch."); + case OV_EBADHEADER: + return std::string("Invalid Vorbis header."); + case OV_EFAULT: + return std::string("Internal logic fault (bug or heap/stack corruption."); + default: + return std::string("Unknown Ogg error."); + } +} diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/VorbisShared.h spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/VorbisShared.h --- spring-96.0~14.04~ppa4/rts/System/Sound/OpenAL/VorbisShared.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/OpenAL/VorbisShared.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,10 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#ifndef VORBIS_SHARED +#define VORBIS_SHARED + +#include + +std::string ErrorString(int code); + +#endif diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/SoundBuffer.cpp spring-98.0~14.04~ppa6/rts/System/Sound/SoundBuffer.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/SoundBuffer.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/SoundBuffer.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,284 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#include "SoundBuffer.h" - - -#include "SoundLog.h" -#include "ALShared.h" -#include "VorbisShared.h" -#include "System/Platform/byteorder.h" - -#include -#include -#include - -namespace -{ -struct VorbisInputBuffer -{ - boost::uint8_t* data; - size_t pos; - size_t size; -}; - -size_t VorbisRead(void* ptr, size_t size, size_t nmemb, void* datasource) -{ - VorbisInputBuffer* buffer = static_cast(datasource); - const size_t maxRead = std::min(size * nmemb, buffer->size - buffer->pos); - memcpy(ptr, buffer->data + buffer->pos, maxRead); - buffer->pos += maxRead; - return maxRead; -}; - -int VorbisClose(void* datasource) -{ - return 0; // nothing to be done here -}; -} - -SoundBuffer::bufferMapT SoundBuffer::bufferMap; // filename, index into Buffers -SoundBuffer::bufferVecT SoundBuffer::buffers; - -SoundBuffer::SoundBuffer() : id(0), channels(0), length(0.0f) -{ -} - -SoundBuffer::~SoundBuffer() -{ -} - -#pragma pack(push, 1) -// Header copied from WavLib by Michael McTernan -struct WAVHeader -{ - boost::uint8_t riff[4]; // "RIFF" - boost::int32_t totalLength; - boost::uint8_t wavefmt[8]; // WAVEfmt " - boost::int32_t length; // Remaining length 4 bytes - boost::int16_t format_tag; - boost::int16_t channels; // Mono=1 Stereo=2 - boost::int32_t SamplesPerSec; - boost::int32_t AvgBytesPerSec; - boost::int16_t BlockAlign; - boost::int16_t BitsPerSample; - boost::uint8_t data[4]; // "data" - boost::int32_t datalen; // Raw data length 4 bytes -}; -#pragma pack(pop) - -bool SoundBuffer::LoadWAV(const std::string& file, std::vector buffer) -{ - WAVHeader* header = (WAVHeader*)(&buffer[0]); - - if ((buffer.empty()) || memcmp(header->riff, "RIFF", 4) || memcmp(header->wavefmt, "WAVEfmt", 7)) { - LOG_L(L_ERROR, "ReadWAV: invalid header: %s", file.c_str()); - return false; - } - -#define hswabword(c) swabWordInPlace(header->c) -#define hswabdword(c) swabDWordInPlace(header->c) - hswabword(format_tag); - hswabword(channels); - hswabword(BlockAlign); - hswabword(BitsPerSample); - - hswabdword(totalLength); - hswabdword(length); - hswabdword(SamplesPerSec); - hswabdword(AvgBytesPerSec); - hswabdword(datalen); -#undef hswabword -#undef hswabdword - - if (header->format_tag != 1) { // Microsoft PCM format? - LOG_L(L_ERROR, "ReadWAV (%s): invalid format tag", file.c_str()); - return false; - } - - ALenum format; - if (header->channels == 1) { - if (header->BitsPerSample == 8) format = AL_FORMAT_MONO8; - else if (header->BitsPerSample == 16) format = AL_FORMAT_MONO16; - else { - LOG_L(L_ERROR, "ReadWAV (%s): invalid number of bits per sample (mono)", file.c_str()); - return false; - } - } - else if (header->channels == 2) { - if (header->BitsPerSample == 8) format = AL_FORMAT_STEREO8; - else if (header->BitsPerSample == 16) format = AL_FORMAT_STEREO16; - else { - LOG_L(L_ERROR, "ReadWAV (%s): invalid number of bits per sample (stereo)", file.c_str()); - return false; - } - } - else { - LOG_L(L_ERROR, "ReadWAV (%s): invalid number of channels.", file.c_str()); - return false; - } - - if (static_cast(header->datalen) > buffer.size() - sizeof(WAVHeader)) { - LOG_L(L_ERROR, - "WAV file %s has data length %i greater than actual data length %i", - file.c_str(), header->datalen, - (int)(buffer.size() - sizeof(WAVHeader))); - -// LOG_L(L_WARNING, "OpenAL: size %d\n", size); -// LOG_L(L_WARNING, "OpenAL: sizeof(WAVHeader) %d\n", sizeof(WAVHeader)); -// LOG_L(L_WARNING, "OpenAL: format_tag %d\n", header->format_tag); -// LOG_L(L_WARNING, "OpenAL: channels %d\n", header->channels); -// LOG_L(L_WARNING, "OpenAL: BlockAlign %d\n", header->BlockAlign); -// LOG_L(L_WARNING, "OpenAL: BitsPerSample %d\n", header->BitsPerSample); -// LOG_L(L_WARNING, "OpenAL: totalLength %d\n", header->totalLength); -// LOG_L(L_WARNING, "OpenAL: length %d\n", header->length); -// LOG_L(L_WARNING, "OpenAL: SamplesPerSec %d\n", header->SamplesPerSec); -// LOG_L(L_WARNING, "OpenAL: AvgBytesPerSec %d\n", header->AvgBytesPerSec); - - header->datalen = boost::uint32_t(buffer.size() - sizeof(WAVHeader))&(~boost::uint32_t((header->BitsPerSample*header->channels)/8 -1)); - } - - if (!AlGenBuffer(file, format, &buffer[sizeof(WAVHeader)], header->datalen, header->SamplesPerSec)) { - LOG_L(L_WARNING, "Loading audio failed for %s", file.c_str()); - } - - filename = file; - channels = header->channels; - length = float(header->datalen) / (header->channels * header->SamplesPerSec * header->BitsPerSample); - - return true; -} - -bool SoundBuffer::LoadVorbis(const std::string& file, std::vector buffer) -{ - VorbisInputBuffer buf; - buf.data = &buffer[0]; - buf.pos = 0; - buf.size = buffer.size(); - - ov_callbacks vorbisCallbacks; - vorbisCallbacks.read_func = VorbisRead; - vorbisCallbacks.close_func = VorbisClose; - vorbisCallbacks.seek_func = NULL; - vorbisCallbacks.tell_func = NULL; - - OggVorbis_File oggStream; - const int result = ov_open_callbacks(&buf, &oggStream, NULL, 0, vorbisCallbacks); - if (result < 0) { - LOG_L(L_WARNING, "Could not open Ogg stream (reason: %s).", - ErrorString(result).c_str()); - return false; - } - - vorbis_info* vorbisInfo = ov_info(&oggStream, -1); - // vorbis_comment* vorbisComment = ov_comment(&oggStream, -1); - - ALenum format; - if (vorbisInfo->channels == 1) - { - format = AL_FORMAT_MONO16; - } - else if (vorbisInfo->channels == 2) - { - format = AL_FORMAT_STEREO16; - } - else - { - LOG_L(L_ERROR, "File %s: invalid number of channels: %i", - file.c_str(), vorbisInfo->channels); - return false; - } - - size_t pos = 0; - std::vector decodeBuffer(512*1024); // 512kb read buffer - int section = 0; - long read = 0; - do - { - if (4*pos > 3*decodeBuffer.size()) // enlarge buffer so ov_read has enough space - decodeBuffer.resize(decodeBuffer.size()*2); - read = ov_read(&oggStream, (char*)&decodeBuffer[pos], decodeBuffer.size() - pos, 0, 2, 1, §ion); - switch(read) - { - case OV_HOLE: - LOG_L(L_WARNING, - "%s: garbage or corrupt page in stream (non-fatal)", - file.c_str()); - continue; // read next - case OV_EBADLINK: - LOG_L(L_WARNING, "%s: corrupted stream", file.c_str()); - return false; // abort - case OV_EINVAL: - LOG_L(L_WARNING, "%s: corrupted headers", file.c_str()); - return false; // abort - default: - break; // all good - }; - pos += read; - } while (read > 0); // read == 0 indicated EOF, read < 0 is error - - AlGenBuffer(file, format, &decodeBuffer[0], pos, vorbisInfo->rate); - filename = file; - channels = vorbisInfo->channels; - length = ov_time_total(&oggStream, -1); - return true; -} - -int SoundBuffer::BufferSize() const -{ - ALint size; - alGetBufferi(id, AL_SIZE, &size); - return static_cast(size); -} - -void SoundBuffer::Initialise() -{ - buffers.resize(1); // empty ("zero") buffer -}; - -void SoundBuffer::Deinitialise() -{ - buffers.resize(0); -}; - -size_t SoundBuffer::GetId(const std::string& name) -{ - bufferMapT::const_iterator it = bufferMap.find(name); - if (it != bufferMap.end()) - return it->second; - else - return 0; -}; - -boost::shared_ptr SoundBuffer::GetById(const size_t id) -{ - assert(id < buffers.size()); - return buffers.at(id); -}; - -size_t SoundBuffer::Count() -{ - return buffers.size(); -}; - -size_t SoundBuffer::AllocedSize() -{ - int numBytes = 0; - for (bufferVecT::const_iterator it = ++buffers.begin(); it != buffers.end(); ++it) - numBytes += (*it)->BufferSize(); - return numBytes; -}; - -size_t SoundBuffer::Insert(boost::shared_ptr buffer) -{ - size_t bufId = buffers.size(); - buffers.push_back(buffer); - bufferMap[buffer->GetFilename()] = bufId; - return bufId; -}; - -bool SoundBuffer::AlGenBuffer(const std::string& file, ALenum format, const boost::uint8_t* data, size_t datalength, int rate) -{ - alGenBuffers(1, &id); - alBufferData(id, format, (ALvoid*) data, datalength, rate); - return CheckError("SoundBuffer::AlGenBuffer"); -} diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/SoundBuffer.h spring-98.0~14.04~ppa6/rts/System/Sound/SoundBuffer.h --- spring-96.0~14.04~ppa4/rts/System/Sound/SoundBuffer.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/SoundBuffer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#ifndef SOUNDBUFFER_H -#define SOUNDBUFFER_H - -#include -#include -#include -#include -#include -#include -#include - -/** - * @brief A buffer holding a sound - * - * One of this will be created for each wav-file used. - * They are loaded on demand and unloaded when game ends. - * They can be shared among multiple SoundItem - */ -class SoundBuffer : boost::noncopyable -{ -public: - /// Construct an "empty" buffer - /// can be played, but you won't hear anything - SoundBuffer(); - ~SoundBuffer(); - - bool LoadWAV(const std::string& file, std::vector buffer); - bool LoadVorbis(const std::string& file, std::vector buffer); - - const std::string& GetFilename() const - { - return filename; - }; - - ALuint GetId() const - { - return id; - }; - - ALuint GetChannels() const - { - return channels; - }; - - ALfloat GetLength() const - { - return length; - }; - - int BufferSize() const; - - static void Initialise(); - static void Deinitialise(); - - static size_t GetId(const std::string& name); - static boost::shared_ptr GetById(const size_t id); - - static size_t Count(); - static size_t AllocedSize(); - - static size_t Insert(boost::shared_ptr buffer); -private: - bool AlGenBuffer(const std::string& file, ALenum format, const boost::uint8_t* data, size_t datalength, int rate); - - std::string filename; - ALuint id; - ALuint channels; - ALfloat length; - - typedef std::map bufferMapT; - typedef std::vector< boost::shared_ptr > bufferVecT; - static bufferMapT bufferMap; // filename, index into Buffers - static bufferVecT buffers; -}; - - -#endif diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/SoundChannels.cpp spring-98.0~14.04~ppa6/rts/System/Sound/SoundChannels.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/SoundChannels.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/SoundChannels.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#include "IAudioChannel.h" -#include "SoundChannels.h" - -namespace Channels -{ - AudioChannelImpl BGMusic; - AudioChannelImpl General; - AudioChannelImpl Battle; - AudioChannelImpl UnitReply; - AudioChannelImpl UserInterface; -} diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/SoundChannels.h spring-98.0~14.04~ppa6/rts/System/Sound/SoundChannels.h --- spring-96.0~14.04~ppa4/rts/System/Sound/SoundChannels.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/SoundChannels.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#ifndef SOUND_CHANNELS_H -#define SOUND_CHANNELS_H - -#ifdef NO_SOUND - #include "NullAudioChannel.h" - - typedef NullAudioChannel AudioChannelImpl; -#else - #include "AudioChannel.h" - - typedef AudioChannel AudioChannelImpl; -#endif - -/** -* @brief If you want to play a sound, use one of these -*/ -namespace Channels { - extern AudioChannelImpl BGMusic; - extern AudioChannelImpl General; - extern AudioChannelImpl Battle; - extern AudioChannelImpl UnitReply; - extern AudioChannelImpl UserInterface; -}; - -#endif diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/Sound.cpp spring-98.0~14.04~ppa6/rts/System/Sound/Sound.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/Sound.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/Sound.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,624 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#include "Sound.h" - -#include -#include -#include -#include -#include - -#include "SoundChannels.h" -#include "SoundLog.h" -#include "SoundSource.h" -#include "SoundBuffer.h" -#include "SoundItem.h" -#include "ALShared.h" -#include "EFX.h" -#include "EFXPresets.h" - -#include "System/TimeProfiler.h" -#include "System/Config/ConfigHandler.h" -#include "System/Exceptions.h" -#include "System/FileSystem/FileHandler.h" -#include "Lua/LuaParser.h" -#include "Map/Ground.h" -#include "Sim/Misc/GlobalConstants.h" -#include "System/myMath.h" -#include "System/Util.h" -#include "System/Platform/Watchdog.h" - -#include "System/float3.h" - -CONFIG(int, MaxSounds).defaultValue(128).minimumValue(0).description("Maximum parallel played sounds."); -CONFIG(bool, PitchAdjust).defaultValue(false).description("When enabled adjust sound speed/pitch to game speed."); -CONFIG(int, snd_volmaster).defaultValue(60).minimumValue(0).maximumValue(200).description("Master sound volume."); -CONFIG(int, snd_volgeneral).defaultValue(100).minimumValue(0).maximumValue(200).description("Volume for \"general\" sound channel."); -CONFIG(int, snd_volunitreply).defaultValue(100).minimumValue(0).maximumValue(200).description("Volume for \"unit reply\" sound channel."); -CONFIG(int, snd_volbattle).defaultValue(100).minimumValue(0).maximumValue(200).description("Volume for \"battle\" sound channel."); -CONFIG(int, snd_volui).defaultValue(100).minimumValue(0).maximumValue(200).description("Volume for \"ui\" sound channel."); -CONFIG(int, snd_volmusic).defaultValue(100).minimumValue(0).maximumValue(200).description("Volume for \"music\" sound channel."); -CONFIG(std::string, snd_device).defaultValue("").description("Sets the used output device. See \"Available Devices\" section in infolog.txt."); - -boost::recursive_mutex soundMutex; - - -CSound::CSound() - : myPos(ZeroVector) - , prevVelocity(ZeroVector) - , soundThread(NULL) - , soundThreadQuit(false) -{ - boost::recursive_mutex::scoped_lock lck(soundMutex); - mute = false; - appIsIconified = false; - int maxSounds = configHandler->GetInt("MaxSounds"); - pitchAdjust = configHandler->GetBool("PitchAdjust"); - - masterVolume = configHandler->GetInt("snd_volmaster") * 0.01f; - Channels::General.SetVolume(configHandler->GetInt("snd_volgeneral") * 0.01f); - Channels::UnitReply.SetVolume(configHandler->GetInt("snd_volunitreply") * 0.01f); - Channels::UnitReply.SetMaxConcurrent(1); - Channels::UnitReply.SetMaxEmmits(1); - Channels::Battle.SetVolume(configHandler->GetInt("snd_volbattle") * 0.01f); - Channels::UserInterface.SetVolume(configHandler->GetInt("snd_volui") * 0.01f); - Channels::BGMusic.SetVolume(configHandler->GetInt("snd_volmusic") * 0.01f); - - SoundBuffer::Initialise(); - soundItemDef temp; - temp["name"] = "EmptySource"; - sounds.push_back(NULL); - - if (maxSounds <= 0) { - LOG_L(L_WARNING, "MaxSounds set to 0, sound is disabled"); - } else { - soundThread = new boost::thread(boost::bind(&CSound::StartThread, this, maxSounds)); - } - - configHandler->NotifyOnChange(this); -} - -CSound::~CSound() -{ - soundThreadQuit = true; - - LOG_L(L_INFO, "[%s][1] soundThread=%p", __FUNCTION__, soundThread); - - if (soundThread != NULL) { - soundThread->join(); - delete soundThread; - soundThread = NULL; - } - - LOG_L(L_INFO, "[%s][2]", __FUNCTION__); - - for (soundVecT::iterator it = sounds.begin(); it != sounds.end(); ++it) - delete *it; - - sounds.clear(); - SoundBuffer::Deinitialise(); - - LOG_L(L_INFO, "[%s][3]", __FUNCTION__); -} - -bool CSound::HasSoundItem(const std::string& name) const -{ - soundMapT::const_iterator it = soundMap.find(name); - if (it != soundMap.end()) - { - return true; - } - else - { - soundItemDefMap::const_iterator it = soundItemDefs.find(StringToLower(name)); - if (it != soundItemDefs.end()) - return true; - else - return false; - } -} - -size_t CSound::GetSoundId(const std::string& name) -{ - boost::recursive_mutex::scoped_lock lck(soundMutex); - - if (sources.empty()) - return 0; - - soundMapT::const_iterator it = soundMap.find(name); - if (it != soundMap.end()) { - // sounditem found - return it->second; - } else { - soundItemDefMap::const_iterator itemDefIt = soundItemDefs.find(StringToLower(name)); - if (itemDefIt != soundItemDefs.end()) { - return MakeItemFromDef(itemDefIt->second); - } else { - if (LoadSoundBuffer(name) > 0) // maybe raw filename? - { - soundItemDef temp = defaultItem; - temp["file"] = name; - return MakeItemFromDef(temp); - } else { - LOG_L(L_ERROR, "CSound::GetSoundId: could not find sound: %s", name.c_str()); - return 0; - } - } - } -} - -SoundItem* CSound::GetSoundItem(size_t id) const { - //! id==0 is a special id and invalid - if (id == 0 || id >= sounds.size()) - return NULL; - return sounds[id]; -} - -CSoundSource* CSound::GetNextBestSource(bool lock) -{ - boost::recursive_mutex::scoped_lock lck(soundMutex, boost::defer_lock); - if (lock) - lck.lock(); - - if (sources.empty()) - return NULL; - - CSoundSource* bestPos = NULL; - for (sourceVecT::iterator it = sources.begin(); it != sources.end(); ++it) - { - if (!it->IsPlaying()) - { - return &(*it); - } - else if (it->GetCurrentPriority() <= (bestPos ? bestPos->GetCurrentPriority() : INT_MAX)) - { - bestPos = &(*it); - } - } - return bestPos; -} - -void CSound::PitchAdjust(const float newPitch) -{ - boost::recursive_mutex::scoped_lock lck(soundMutex); - if (pitchAdjust) - CSoundSource::SetPitch(newPitch); -} - -void CSound::ConfigNotify(const std::string& key, const std::string& value) -{ - boost::recursive_mutex::scoped_lock lck(soundMutex); - if (key == "snd_volmaster") - { - masterVolume = std::atoi(value.c_str()) * 0.01f; - if (!mute && !appIsIconified) - alListenerf(AL_GAIN, masterVolume); - } - else if (key == "snd_eaxpreset") - { - efx->SetPreset(value); - } - else if (key == "snd_filter") - { - float gainlf = 1.f; - float gainhf = 1.f; - sscanf(value.c_str(), "%f %f", &gainlf, &gainhf); - efx->sfxProperties->filter_properties_f[AL_LOWPASS_GAIN] = gainlf; - efx->sfxProperties->filter_properties_f[AL_LOWPASS_GAINHF] = gainhf; - efx->CommitEffects(); - } - else if (key == "UseEFX") - { - bool enable = (std::atoi(value.c_str()) != 0); - if (enable) - efx->Enable(); - else - efx->Disable(); - } - else if (key == "snd_volgeneral") - { - Channels::General.SetVolume(std::atoi(value.c_str()) * 0.01f); - } - else if (key == "snd_volunitreply") - { - Channels::UnitReply.SetVolume(std::atoi(value.c_str()) * 0.01f); - } - else if (key == "snd_volbattle") - { - Channels::Battle.SetVolume(std::atoi(value.c_str()) * 0.01f); - } - else if (key == "snd_volui") - { - Channels::UserInterface.SetVolume(std::atoi(value.c_str()) * 0.01f); - } - else if (key == "snd_volmusic") - { - Channels::BGMusic.SetVolume(std::atoi(value.c_str()) * 0.01f); - } - else if (key == "PitchAdjust") - { - bool tempPitchAdjust = (std::atoi(value.c_str()) != 0); - if (!tempPitchAdjust) - PitchAdjust(1.0); - pitchAdjust = tempPitchAdjust; - } -} - -bool CSound::Mute() -{ - boost::recursive_mutex::scoped_lock lck(soundMutex); - mute = !mute; - if (mute) - alListenerf(AL_GAIN, 0.0); - else - alListenerf(AL_GAIN, masterVolume); - return mute; -} - -bool CSound::IsMuted() const -{ - return mute; -} - -void CSound::Iconified(bool state) -{ - boost::recursive_mutex::scoped_lock lck(soundMutex); - if (appIsIconified != state && !mute) - { - if (state == false) - alListenerf(AL_GAIN, masterVolume); - else if (state == true) - alListenerf(AL_GAIN, 0.0); - } - appIsIconified = state; -} - -__FORCE_ALIGN_STACK__ -void CSound::StartThread(int maxSounds) -{ - { - boost::recursive_mutex::scoped_lock lck(soundMutex); - - // alc... will create its own thread it will copy the name from the current thread. - // Later we finally rename `our` audio thread. - Threading::SetThreadName("openal"); - - // NULL -> default device - const ALchar* deviceName = NULL; - std::string configDeviceName = ""; - - // we do not want to set a default for snd_device, - // so we do it like this ... - if (configHandler->IsSet("snd_device")) - { - configDeviceName = configHandler->GetString("snd_device"); - deviceName = configDeviceName.c_str(); - } - - ALCdevice* device = alcOpenDevice(deviceName); - - if ((device == NULL) && (deviceName != NULL)) - { - LOG_L(L_WARNING, - "Could not open the sound device \"%s\", trying the default device ...", - deviceName); - configDeviceName = ""; - deviceName = NULL; - device = alcOpenDevice(deviceName); - } - - if (device == NULL) - { - LOG_L(L_ERROR, "Could not open a sound device, disabling sounds"); - CheckError("CSound::InitAL"); - return; - } - else - { - ALCcontext *context = alcCreateContext(device, NULL); - if (context != NULL) - { - alcMakeContextCurrent(context); - CheckError("CSound::CreateContext"); - } - else - { - alcCloseDevice(device); - LOG_L(L_ERROR, "Could not create OpenAL audio context"); - return; - } - } - maxSounds = GetMaxMonoSources(device, maxSounds); - - LOG("OpenAL info:"); - if(alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT")) - { - LOG(" Available Devices:"); - const char* deviceSpecifier = alcGetString(NULL, ALC_DEVICE_SPECIFIER); - while (*deviceSpecifier != '\0') { - LOG(" %s", deviceSpecifier); - while (*deviceSpecifier++ != '\0') - ; - } - LOG(" Device: %s", (const char*)alcGetString(device, ALC_DEVICE_SPECIFIER)); - } - LOG(" Vendor: %s", (const char*)alGetString(AL_VENDOR)); - LOG(" Version: %s", (const char*)alGetString(AL_VERSION)); - LOG(" Renderer: %s", (const char*)alGetString(AL_RENDERER)); - LOG(" AL Extensions: %s", (const char*)alGetString(AL_EXTENSIONS)); - LOG(" ALC Extensions: %s", (const char*)alcGetString(device, ALC_EXTENSIONS)); - - // Init EFX - efx = new CEFX(device); - - // Generate sound sources - for (int i = 0; i < maxSounds; i++) - { - CSoundSource* thenewone = new CSoundSource(); - if (thenewone->IsValid()) { - sources.push_back(thenewone); - } else { - maxSounds = std::max(i-1, 0); - LOG_L(L_WARNING, - "Your hardware/driver can not handle more than %i soundsources", - maxSounds); - delete thenewone; - break; - } - } - LOG(" Max Sounds: %i", maxSounds); - - // Set distance model (sound attenuation) - alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED); - alDopplerFactor(0.2f); - - alListenerf(AL_GAIN, masterVolume); - } - - Threading::SetThreadName("audio"); - Watchdog::RegisterThread(WDT_AUDIO); - - while (!soundThreadQuit) { - boost::this_thread::sleep(boost::posix_time::millisec(50)); //! 20Hz - Watchdog::ClearTimer(WDT_AUDIO); - Update(); - } - - Watchdog::DeregisterThread(WDT_AUDIO); - - sources.clear(); // delete all sources - delete efx; // must happen after sources and before context - ALCcontext* curcontext = alcGetCurrentContext(); - ALCdevice* curdevice = alcGetContextsDevice(curcontext); - alcMakeContextCurrent(NULL); - alcDestroyContext(curcontext); - alcCloseDevice(curdevice); -} - -void CSound::Update() -{ - boost::recursive_mutex::scoped_lock lck(soundMutex); // lock - for (sourceVecT::iterator it = sources.begin(); it != sources.end(); ++it) - it->Update(); - CheckError("CSound::Update"); -} - -size_t CSound::MakeItemFromDef(const soundItemDef& itemDef) -{ - //! MakeItemFromDef is private. Only caller is LoadSoundDefs and it sets the mutex itself. - //boost::recursive_mutex::scoped_lock lck(soundMutex); - const size_t newid = sounds.size(); - soundItemDef::const_iterator it = itemDef.find("file"); - if (it == itemDef.end()) - return 0; - - boost::shared_ptr buffer = SoundBuffer::GetById(LoadSoundBuffer(it->second)); - - if (!buffer) - return 0; - - SoundItem* buf = new SoundItem(buffer, itemDef); - sounds.push_back(buf); - soundMap[buf->Name()] = newid; - return newid; -} - -void CSound::UpdateListener(const float3& campos, const float3& camdir, const float3& camup, float lastFrameTime) -{ - boost::recursive_mutex::scoped_lock lck(soundMutex); - if (sources.empty()) - return; - - myPos = campos; - const float3 myPosInMeters = myPos * ELMOS_TO_METERS; - alListener3f(AL_POSITION, myPosInMeters.x, myPosInMeters.y, myPosInMeters.z); - - //! reduce the rolloff when the camera is high above the ground (so we still hear something in tab mode or far zoom) - //! for altitudes up to and including 600 elmos, the rolloff is always clamped to 1 - const float camHeight = std::max(1.0f, campos.y - ground->GetHeightAboveWater(campos.x, campos.z)); - const float newMod = std::min(600.0f / camHeight, 1.0f); - - CSoundSource::SetHeightRolloffModifer(newMod); - efx->SetHeightRolloffModifer(newMod); - - //! Result were bad with listener related doppler effects. - //! The user experiences the camera/listener not as a world-interacting object. - //! So changing sounds on camera movements were irritating, esp. because zooming with the mouse wheel - //! often is faster than the speed of sound, causing very high frequencies. - //! Note: soundsource related doppler effects are not deactivated by this! Flying cannon shoots still change their frequencies. - //! Note2: by not updating the listener velocity soundsource related velocities are calculated wrong, - //! so even if the camera is moving with a cannon shoot the frequency gets changed. - /* - const float3 velocity = (myPos - prevPos) / (lastFrameTime); - float3 velocityAvg = velocity * 0.6f + prevVelocity * 0.4f; - prevVelocity = velocityAvg; - velocityAvg *= ELMOS_TO_METERS; - velocityAvg.y *= 0.001f; //! scale vertical axis separatly (zoom with mousewheel is faster than speed of sound!) - velocityAvg *= 0.15f; - alListener3f(AL_VELOCITY, velocityAvg.x, velocityAvg.y, velocityAvg.z); - */ - - ALfloat ListenerOri[] = {camdir.x, camdir.y, camdir.z, camup.x, camup.y, camup.z}; - alListenerfv(AL_ORIENTATION, ListenerOri); - CheckError("CSound::UpdateListener"); -} - -void CSound::PrintDebugInfo() -{ - boost::recursive_mutex::scoped_lock lck(soundMutex); - - LOG_L(L_DEBUG, "OpenAL Sound System:"); - LOG_L(L_DEBUG, "# SoundSources: %i", (int)sources.size()); - LOG_L(L_DEBUG, "# SoundBuffers: %i", (int)SoundBuffer::Count()); - - LOG_L(L_DEBUG, "# reserved for buffers: %i kB", (int)(SoundBuffer::AllocedSize() / 1024)); - LOG_L(L_DEBUG, "# PlayRequests for empty sound: %i", numEmptyPlayRequests); - LOG_L(L_DEBUG, "# Samples disrupted: %i", numAbortedPlays); - LOG_L(L_DEBUG, "# SoundItems: %i", (int)sounds.size()); -} - -bool CSound::LoadSoundDefs(const std::string& fileName) -{ - //! can be called from LuaUnsyncedCtrl too - boost::recursive_mutex::scoped_lock lck(soundMutex); - - LuaParser parser(fileName, SPRING_VFS_MOD, SPRING_VFS_ZIP); - parser.Execute(); - if (!parser.IsValid()) - { - LOG_L(L_WARNING, "Could not load %s: %s", - fileName.c_str(), parser.GetErrorLog().c_str()); - return false; - } - else - { - const LuaTable soundRoot = parser.GetRoot(); - const LuaTable soundItemTable = soundRoot.SubTable("SoundItems"); - if (!soundItemTable.IsValid()) - { - LOG_L(L_WARNING, "CSound(): could not parse SoundItems table in %s", fileName.c_str()); - return false; - } - else - { - std::vector keys; - soundItemTable.GetKeys(keys); - for (std::vector::const_iterator it = keys.begin(); it != keys.end(); ++it) - { - std::string name(*it); - - soundItemDef bufmap; - const LuaTable buf(soundItemTable.SubTable(name)); - buf.GetMap(bufmap); - bufmap["name"] = name; - soundItemDefMap::const_iterator sit = soundItemDefs.find(name); - - if (name == "default") { - defaultItem = bufmap; - defaultItem.erase("name"); //must be empty for default item - defaultItem.erase("file"); - continue; - } - - if (sit != soundItemDefs.end()) - LOG_L(L_WARNING, "Sound %s gets overwritten by %s", name.c_str(), fileName.c_str()); - - if (!buf.KeyExists("file")) { - // no file, drop - LOG_L(L_WARNING, "Sound %s is missing file tag (ignoring)", name.c_str()); - continue; - } else { - soundItemDefs[name] = bufmap; - } - - if (buf.KeyExists("preload")) { - MakeItemFromDef(bufmap); - } - } - LOG(" parsed %i sounds from %s", (int)keys.size(), fileName.c_str()); - } - } - - //FIXME why do sounds w/o an own soundItemDef create (!=pointer) a new one from the defaultItem? - for (soundItemDefMap::iterator it = soundItemDefs.begin(); it != soundItemDefs.end(); ++it) { - soundItemDef& snddef = it->second; - if (snddef.find("name") == snddef.end()) { - // uses defaultItem! update it! - const std::string file = snddef["file"]; - snddef = defaultItem; - snddef["file"] = file; - } - } - - return true; -} - -//! only used internally, locked in caller's scope -size_t CSound::LoadSoundBuffer(const std::string& path) -{ - const size_t id = SoundBuffer::GetId(path); - - if (id > 0) { - return id; // file is loaded already - } else { - CFileHandler file(path); - - if (!file.FileExists()) { - LOG_L(L_ERROR, "Unable to open audio file: %s", path.c_str()); - return 0; - } - - std::vector buf(file.FileSize()); - file.Read(&buf[0], file.FileSize()); - - boost::shared_ptr buffer(new SoundBuffer()); - bool success = false; - const std::string ending = file.GetFileExt(); - if (ending == "wav") { - success = buffer->LoadWAV(path, buf); - } else if (ending == "ogg") { - success = buffer->LoadVorbis(path, buf); - } else { - LOG_L(L_WARNING, "CSound::LoadALBuffer: unknown audio format: %s", - ending.c_str()); - } - - CheckError("CSound::LoadALBuffer"); - if (!success) { - LOG_L(L_WARNING, "Failed to load file: %s", path.c_str()); - return 0; - } - - return SoundBuffer::Insert(buffer); - } -} - -void CSound::NewFrame() -{ - Channels::General.UpdateFrame(); - Channels::Battle.UpdateFrame(); - Channels::UnitReply.UpdateFrame(); - Channels::UserInterface.UpdateFrame(); -} - - -// try to get the maximum number of supported sounds, this is similar to code CSound::StartThread -// but should be more safe -int CSound::GetMaxMonoSources(ALCdevice* device, int maxSounds) -{ - ALCint size; - alcGetIntegerv(device, ALC_ATTRIBUTES_SIZE, 1, &size); - std::vector attrs(size); - alcGetIntegerv(device, ALC_ALL_ATTRIBUTES, size, &attrs[0] ); - for (int i=0; i -#include -#include -#include -#include -#include - -#include "System/float3.h" - -#include "SoundItem.h" - -class CSoundSource; -class SoundBuffer; -class SoundItem; -struct ALCdevice_struct; -typedef struct ALCdevice_struct ALCdevice; - -namespace boost { - class thread; -}; - - -/// Default sound system implementation (OpenAL) -class CSound : public ISound -{ -public: - CSound(); - virtual ~CSound(); - - virtual bool HasSoundItem(const std::string& name) const; - virtual size_t GetSoundId(const std::string& name); - SoundItem* GetSoundItem(size_t id) const; - - virtual CSoundSource* GetNextBestSource(bool lock = true); - - virtual void UpdateListener(const float3& campos, const float3& camdir, const float3& camup, float lastFrameTime); - virtual void NewFrame(); - - /// @see ConfigHandler::ConfigNotifyCallback - virtual void ConfigNotify(const std::string& key, const std::string& value); - virtual void PitchAdjust(const float newPitch); - - virtual bool Mute(); - virtual bool IsMuted() const; - - virtual void Iconified(bool state); - - virtual void PrintDebugInfo(); - virtual bool LoadSoundDefs(const std::string& fileName); - - const float3& GetListenerPos() const { - return myPos; - } - -private: - typedef std::map soundItemDef; - typedef std::map soundItemDefMap; - -private: - void StartThread(int maxSounds); - void Update(); - int GetMaxMonoSources(ALCdevice* device, int maxSounds); - - size_t MakeItemFromDef(const soundItemDef& itemDef); - - size_t LoadSoundBuffer(const std::string& filename); - -private: - float masterVolume; - bool mute; - /// we do not play if minimized / iconified - bool appIsIconified; - bool pitchAdjust; - - typedef std::map soundMapT; - typedef std::vector soundVecT; - soundMapT soundMap; - soundVecT sounds; - - /// unscaled - float3 myPos; - float3 prevVelocity; - - typedef boost::ptr_vector sourceVecT; - sourceVecT sources; - - soundItemDef defaultItem; - soundItemDefMap soundItemDefs; - - boost::thread* soundThread; - - volatile bool soundThreadQuit; -}; - -#endif // _SOUND_H_ diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/SoundItem.cpp spring-98.0~14.04~ppa6/rts/System/Sound/SoundItem.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/SoundItem.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/SoundItem.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#include "SoundItem.h" - -#include -#include -#include - -#include "SoundBuffer.h" -#include "System/UnsyncedRNG.h" - -namespace -{ - UnsyncedRNG randnum; // no need for strong randomness here, so default seed is ok - - template - inline bool MapEntryValExtract(const std::map& map, const std::string& key, T& t) - { - std::map::const_iterator it = map.find(key); - if (it != map.end()) - { - std::istringstream stream(it->second); - stream >> t; - return true; - } - else - return false; - } - - template - void FitInIntervall(const T& lower, T& val, const T& upper) - { - val = std::max(std::min(val, upper), lower); - } -} - -SoundItem::SoundItem(boost::shared_ptr _buffer, const std::map& items) - : buffer(_buffer) - , gain(1.0) - , gainMod(0) - , pitch(1.0) - , pitchMod(0) - , dopplerScale(1.0) - , maxDist(FLT_MAX) - , rolloff(1.0f) - , priority(0) - , maxConcurrent(16) - , currentlyPlaying(0) - , loopTime(0) - , in3D(true) -{ - if (!MapEntryValExtract(items, "name", name)) - name = buffer->GetFilename(); - - MapEntryValExtract(items, "gain", gain); - MapEntryValExtract(items, "gainmod", gainMod); - FitInIntervall(0.f, gainMod, 1.f); - MapEntryValExtract(items, "pitch", pitch); - MapEntryValExtract(items, "pitchmod", pitchMod); - FitInIntervall(0.f, pitchMod, 1.f); - MapEntryValExtract(items, "dopplerscale", dopplerScale); - MapEntryValExtract(items, "priority", priority); - MapEntryValExtract(items, "maxconcurrent", maxConcurrent); - MapEntryValExtract(items, "maxdist", maxDist); - MapEntryValExtract(items, "rolloff", rolloff); - MapEntryValExtract(items, "in3d", in3D); - MapEntryValExtract(items, "looptime", loopTime); -} - -bool SoundItem::PlayNow() -{ - if (maxConcurrent >= currentlyPlaying) - { - currentlyPlaying++; - return true; - } - else - { - return false; - } -} - -void SoundItem::StopPlay() -{ - assert(currentlyPlaying > 0); - --currentlyPlaying; -} - -float SoundItem::GetGain() const -{ - float tgain = 0; - if (gainMod > 0) - tgain = (float(randnum(200))/100.f - 1.f)*gainMod; - return gain * (1.f + tgain); -} - -float SoundItem::GetPitch() const -{ - float tpitch = 0; - if (pitchMod > 0) - tpitch = (float(randnum(200))/100.f - 1.f)*pitchMod; - return pitch * (1.f + tpitch); -} diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/SoundItem.h spring-98.0~14.04~ppa6/rts/System/Sound/SoundItem.h --- spring-96.0~14.04~ppa4/rts/System/Sound/SoundItem.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/SoundItem.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#ifndef SOUNDITEM_H -#define SOUNDITEM_H - -#include -#include -#include - -class SoundBuffer; - -/** - * @brief A class representing a sound which can be played - * - * This can be played by CSoundSource. - * Each soundsource has exactly one SoundBuffer it wraps around, while one buffer can be shared among multiple Items. - * You can adjust various playing parameters within this class, sou you can have 1 buffer and multiple SoundItems - * which differ in pitch, volume etc. - */ -class SoundItem -{ - friend class CSoundSource; -public: - SoundItem(boost::shared_ptr buffer, const std::map& items); - - bool PlayNow(); - void StopPlay(); - float MaxDistance() const - { - return maxDist; - }; - const std::string& Name() const - { - return name; - }; - const int GetPriority() const - { - return priority; - }; - - float GetGain() const; - float GetPitch() const; - -private: - boost::shared_ptr buffer; - /// unique identifier (if no name is specified, this will be the filename - std::string name; - - /// volume gain, applied to this sound - float gain; - float gainMod; - /// sound pitch (multiplied with globalPitch from CSoundSource when played) - float pitch; - float pitchMod; - float dopplerScale; - - float maxDist; - float rolloff; - int priority; - - unsigned maxConcurrent; - unsigned currentlyPlaying; - - unsigned loopTime; - - bool in3D; -}; - -#endif diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/SoundSource.cpp spring-98.0~14.04~ppa6/rts/System/Sound/SoundSource.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/SoundSource.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/SoundSource.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,287 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#include "SoundSource.h" - -#include -#include - -#include "ALShared.h" -#include "EFX.h" -#include "IAudioChannel.h" -#include "OggStream.h" -#include "SoundLog.h" -#include "SoundBuffer.h" -#include "SoundItem.h" - -#include "Sound.h" //remove when unified ElmoInMeters - -#include "Sim/Misc/GlobalConstants.h" -#include "System/float3.h" -#include "System/Util.h" -#include "System/myMath.h" - -float CSoundSource::referenceDistance = 200.0f; -float CSoundSource::globalPitch = 1.0; -float CSoundSource::heightRolloffModifier = 1.0f; -static const float ROLLOFF_FACTOR = 5.f; - -CSoundSource::CSoundSource() - : curPlaying(NULL) - , curChannel(NULL) - , curStream(NULL) - , curVolume(1.f) - , loopStop(1e9) - , in3D(false) - , efxEnabled(false) - , efxUpdates(0) - , curHeightRolloffModifier(1) -{ - alGenSources(1, &id); - if (!CheckError("CSoundSource::CSoundSource")) { - id = 0; - } else { - alSourcef(id, AL_REFERENCE_DISTANCE, referenceDistance * ELMOS_TO_METERS); - CheckError("CSoundSource::CSoundSource"); - } -} - -CSoundSource::~CSoundSource() -{ - if (efxEnabled) { - alSource3i(id, AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL); - alSourcei(id, AL_DIRECT_FILTER, AL_FILTER_NULL); - } - - Stop(); - alDeleteSources(1, &id); - CheckError("CSoundSource::~CSoundSource"); -} - -void CSoundSource::Update() -{ - if (curPlaying) { - if (in3D && (efxEnabled != efx->enabled)) { - alSourcef(id, AL_AIR_ABSORPTION_FACTOR, (efx->enabled) ? efx->GetAirAbsorptionFactor() : 0); - alSource3i(id, AL_AUXILIARY_SEND_FILTER, (efx->enabled) ? efx->sfxSlot : AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL); - alSourcei(id, AL_DIRECT_FILTER, (efx->enabled) ? efx->sfxFilter : AL_FILTER_NULL); - efxEnabled = efx->enabled; - efxUpdates = efx->updates; - } - - if (heightRolloffModifier != curHeightRolloffModifier) { - curHeightRolloffModifier = heightRolloffModifier; - alSourcef(id, AL_ROLLOFF_FACTOR, ROLLOFF_FACTOR * curPlaying->rolloff * heightRolloffModifier); - } - - if (!IsPlaying() || ((curPlaying->loopTime > 0) && (spring_gettime() > loopStop))) - Stop(); - } - - if (curStream) { - if (curStream->IsFinished()) { - Stop(); - } - else { - curStream->Update(); - CheckError("CSoundSource::Update"); - } - } - - if (efxEnabled && (efxUpdates != efx->updates)) { - //! airAbsorption & LowPass aren't auto updated by OpenAL on change, so we need to do it per source - alSourcef(id, AL_AIR_ABSORPTION_FACTOR, efx->GetAirAbsorptionFactor()); - alSourcei(id, AL_DIRECT_FILTER, efx->sfxFilter); - efxUpdates = efx->updates; - } -} - -int CSoundSource::GetCurrentPriority() const -{ - if (curStream) { - return INT_MAX; - } - else if (!curPlaying) { - return INT_MIN; - } - return curPlaying->priority; -} - -bool CSoundSource::IsPlaying() const -{ - if (curStream) - return true; - - if (!curPlaying) - return false; - - CheckError("CSoundSource::IsPlaying"); - ALint state; - alGetSourcei(id, AL_SOURCE_STATE, &state); - CheckError("CSoundSource::IsPlaying"); - return (state == AL_PLAYING); -} - -void CSoundSource::Stop() -{ - alSourceStop(id); - if (curPlaying) { - curPlaying->StopPlay(); - curPlaying = NULL; - } - if (curStream) { - SafeDelete(curStream); - } - if (curChannel) { - curChannel->SoundSourceFinished(this); - curChannel = NULL; - } - CheckError("CSoundSource::Stop"); -} - -void CSoundSource::Play(IAudioChannel* channel, SoundItem* item, float3 pos, float3 velocity, float volume, bool relative) -{ - assert(!curStream); - assert(channel); - if (!item->PlayNow()) - return; - Stop(); - curVolume = volume; - curPlaying = item; - curChannel = channel; - alSourcei(id, AL_BUFFER, item->buffer->GetId()); - alSourcef(id, AL_GAIN, volume * item->GetGain() * channel->volume); - alSourcef(id, AL_PITCH, item->GetPitch() * globalPitch); - velocity *= item->dopplerScale * ELMOS_TO_METERS; - alSource3f(id, AL_VELOCITY, velocity.x, velocity.y, velocity.z); - alSourcei(id, AL_LOOPING, (item->loopTime > 0) ? AL_TRUE : AL_FALSE); - loopStop = spring_gettime() + spring_msecs(item->loopTime); - if (relative || !item->in3D) { - in3D = false; - if (efxEnabled) { - alSource3i(id, AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL); - alSourcei(id, AL_DIRECT_FILTER, AL_FILTER_NULL); - efxEnabled = false; - } - alSourcei(id, AL_SOURCE_RELATIVE, AL_TRUE); - alSourcef(id, AL_ROLLOFF_FACTOR, 0.f); - alSource3f(id, AL_POSITION, 0.0f, 0.0f, -1.0f * ELMOS_TO_METERS); -#ifdef __APPLE__ - alSourcef(id, AL_REFERENCE_DISTANCE, referenceDistance * ELMOS_TO_METERS); -#endif - } else { - if (item->buffer->GetChannels() > 1) { - LOG_L(L_WARNING, "Can not play non-mono \"%s\" in 3d.", - item->buffer->GetFilename().c_str()); - } - - in3D = true; - if (efx->enabled) { - efxEnabled = true; - alSourcef(id, AL_AIR_ABSORPTION_FACTOR, efx->GetAirAbsorptionFactor()); - alSource3i(id, AL_AUXILIARY_SEND_FILTER, efx->sfxSlot, 0, AL_FILTER_NULL); - alSourcei(id, AL_DIRECT_FILTER, efx->sfxFilter); - efxUpdates = efx->updates; - } - alSourcei(id, AL_SOURCE_RELATIVE, AL_FALSE); - pos *= ELMOS_TO_METERS; - alSource3f(id, AL_POSITION, pos.x, pos.y, pos.z); - curHeightRolloffModifier = heightRolloffModifier; - alSourcef(id, AL_ROLLOFF_FACTOR, ROLLOFF_FACTOR * item->rolloff * heightRolloffModifier); -#ifdef __APPLE__ - alSourcef(id, AL_MAX_DISTANCE, 1000000.0f); - //! Max distance is too small by default on my Mac... - ALfloat gain = channel->volume * item->GetGain() * volume; - if (gain > 1.0f) { - //! OpenAL on Mac cannot handle AL_GAIN > 1 well, so we will adjust settings to get the same output with AL_GAIN = 1. - ALint model = alGetInteger(AL_DISTANCE_MODEL); - ALfloat rolloff = ROLLOFF_FACTOR * item->rolloff * heightRolloffModifier; - ALfloat ref = referenceDistance * ELMOS_TO_METERS; - if ((model == AL_INVERSE_DISTANCE_CLAMPED) || (model == AL_INVERSE_DISTANCE)) { - alSourcef(id, AL_REFERENCE_DISTANCE, ((gain - 1.0f) * ref / rolloff) + ref); - alSourcef(id, AL_ROLLOFF_FACTOR, (gain + rolloff - 1.0f) / gain); - alSourcef(id, AL_GAIN, 1.0f); - } - } else { - alSourcef(id, AL_REFERENCE_DISTANCE, referenceDistance * ELMOS_TO_METERS); - } -#endif - } - alSourcePlay(id); - - if (item->buffer->GetId() == 0) { - LOG_L(L_WARNING, - "CSoundSource::Play: Empty buffer for item %s (file %s)", - item->name.c_str(), item->buffer->GetFilename().c_str()); - } - CheckError("CSoundSource::Play"); -} - -void CSoundSource::PlayStream(IAudioChannel* channel, const std::string& file, float volume) -{ - //! stop any current playback - Stop(); - - if (!curStream) - curStream = new COggStream(id); - - //! setup OpenAL params - curChannel = channel; - curVolume = volume; - in3D = false; - if (efxEnabled) { - alSource3i(id, AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL); - alSourcei(id, AL_DIRECT_FILTER, AL_FILTER_NULL); - efxEnabled = false; - } - alSource3f(id, AL_POSITION, 0.0f, 0.0f, 0.0f); - alSourcef(id, AL_GAIN, volume); - alSource3f(id, AL_VELOCITY, 0.0f, 0.0f, 0.0f); - alSource3f(id, AL_DIRECTION, 0.0f, 0.0f, 0.0f); - alSourcef(id, AL_ROLLOFF_FACTOR, 0.0f); - alSourcei(id, AL_SOURCE_RELATIVE, AL_TRUE); - - //! COggStreams only appends buffers, giving errors when a buffer of another format is still assigned - alSourcei(id, AL_BUFFER, AL_NONE); - curStream->Play(file, volume); - curStream->Update(); - CheckError("CSoundSource::Update"); -} - -void CSoundSource::StreamStop() -{ - if (curStream) - Stop(); -} - -void CSoundSource::StreamPause() -{ - if (curStream) { - if (curStream->TogglePause()) - alSourcePause(id); - else - alSourcePlay(id); - } -} - -float CSoundSource::GetStreamTime() -{ - return curStream ? curStream->GetTotalTime() : 0; -} - -float CSoundSource::GetStreamPlayTime() -{ - return curStream ? curStream->GetPlayTime() : 0; -} - -void CSoundSource::UpdateVolume() -{ - if (!curChannel) - return; - - if (curStream) { - alSourcef(id, AL_GAIN, curVolume * curChannel->volume); - } - else if (curPlaying) { - alSourcef(id, AL_GAIN, curVolume * curPlaying->GetGain() * curChannel->volume); - } -} diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/SoundSource.h spring-98.0~14.04~ppa6/rts/System/Sound/SoundSource.h --- spring-96.0~14.04~ppa4/rts/System/Sound/SoundSource.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/SoundSource.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#ifndef SOUNDSOURCE_H -#define SOUNDSOURCE_H - -#include - -#include -#include -#include "System/Misc/SpringTime.h" - -class IAudioChannel; -class float3; -class SoundItem; -class COggStream; - -/** - * @brief One soundsource wich can play some sounds - * - * Construct some of them, and they can play SoundItems positioned anywhere in 3D-space for you. - */ -class CSoundSource : boost::noncopyable -{ -public: - /// is ready after this - CSoundSource(); - /// will stop during deletion - ~CSoundSource(); - - void Update(); - - void UpdateVolume(); - bool IsValid() const { return (id != 0); }; - - int GetCurrentPriority() const; - bool IsPlaying() const; - void Stop(); - - /// will stop a currently playing sound, if any - void Play(IAudioChannel* channel, SoundItem* buffer, float3 pos, float3 velocity, float volume, bool relative = false); - void PlayStream(IAudioChannel* channel, const std::string& stream, float volume); - void StreamStop(); - void StreamPause(); - float GetStreamTime(); - float GetStreamPlayTime(); - - static void SetPitch(const float& newPitch) - { - globalPitch = newPitch; - }; - static void SetHeightRolloffModifer(const float& mod) - { - heightRolloffModifier = mod; - }; - -private: - static float referenceDistance; - - //! used to adjust the pitch to the GameSpeed (optional) - static float globalPitch; - - //! reduce the rolloff when the camera is height above the ground (so we still hear something in tab mode or far zoom) - static float heightRolloffModifier; - - ALuint id; - SoundItem* curPlaying; - IAudioChannel* curChannel; - COggStream* curStream; - float curVolume; - spring_time loopStop; - bool in3D; - bool efxEnabled; - int efxUpdates; - ALfloat curHeightRolloffModifier; -}; - -#endif diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/VorbisShared.cpp spring-98.0~14.04~ppa6/rts/System/Sound/VorbisShared.cpp --- spring-96.0~14.04~ppa4/rts/System/Sound/VorbisShared.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/VorbisShared.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#include "VorbisShared.h" - -#include -#include - -std::string ErrorString(int code) -{ - switch (code) { - case OV_EREAD: - return std::string("Read from media."); - case OV_ENOTVORBIS: - return std::string("Not Vorbis data."); - case OV_EVERSION: - return std::string("Vorbis version mismatch."); - case OV_EBADHEADER: - return std::string("Invalid Vorbis header."); - case OV_EFAULT: - return std::string("Internal logic fault (bug or heap/stack corruption."); - default: - return std::string("Unknown Ogg error."); - } -}; diff -Nru spring-96.0~14.04~ppa4/rts/System/Sound/VorbisShared.h spring-98.0~14.04~ppa6/rts/System/Sound/VorbisShared.h --- spring-96.0~14.04~ppa4/rts/System/Sound/VorbisShared.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sound/VorbisShared.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ - -#ifndef VORBIS_SHARED -#define VORBIS_SHARED - -#include - -std::string ErrorString(int code); - -#endif diff -Nru spring-96.0~14.04~ppa4/rts/System/SpringApp.cpp spring-98.0~14.04~ppa6/rts/System/SpringApp.cpp --- spring-96.0~14.04~ppa4/rts/System/SpringApp.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/SpringApp.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -3,14 +3,14 @@ #include "System/Input/InputHandler.h" #include -#if !defined(HEADLESS) - #include -#endif #include +#ifdef WIN32 +//windows workarrounds #undef KeyPress #undef KeyRelease +#endif #include "Rendering/GL/myGL.h" #include "System/SpringApp.h" @@ -32,9 +32,10 @@ #include "Lua/LuaOpenGL.h" #include "Menu/SelectMenu.h" #include "Rendering/GlobalRendering.h" -#include "Rendering/glFont.h" +#include "Rendering/Fonts/glFont.h" #include "Rendering/GLContext.h" #include "Rendering/VerticalSync.h" +#include "Rendering/GL/FBO.h" #include "Rendering/Textures/NamedTextures.h" #include "Rendering/Textures/TextureAtlas.h" #include "Sim/Misc/DefinitionTag.h" @@ -60,8 +61,9 @@ #include "System/Input/MouseInput.h" #include "System/Input/Joystick.h" #include "System/FileSystem/DataDirLocater.h" -#include "System/FileSystem/FileSystemInitializer.h" #include "System/FileSystem/FileHandler.h" +#include "System/FileSystem/FileSystem.h" +#include "System/FileSystem/FileSystemInitializer.h" #include "System/Platform/CmdLineParams.h" #include "System/Platform/Misc.h" #include "System/Platform/errorhandler.h" @@ -71,18 +73,14 @@ #include "System/Platform/WindowManagerHelper.h" #include "System/Sound/ISound.h" #include "System/Sync/FPUCheck.h" +#include "System/UriParser.h" +#include "lib/luasocket/src/restrictions.h" #ifdef WIN32 #include "System/Platform/Win/WinVersion.h" -#elif defined(__APPLE__) -#elif defined(HEADLESS) -#else - #include - #include "System/Platform/Linux/myX11.h" #endif -#include "lib/gml/gml_base.h" -#include "lib/luasocket/src/restrictions.h" + CONFIG(unsigned, SetCoreAffinity).defaultValue(0).safemodeValue(1).description("Defines a bitmask indicating which CPU cores the main-thread should use."); CONFIG(unsigned, SetCoreAffinitySim).defaultValue(0).safemodeValue(1).description("Defines a bitmask indicating which CPU cores the sim-thread should use."); @@ -105,15 +103,15 @@ CONFIG(int, YResolution).defaultValue(0).minimumValue(0).description("Sets the height of the game screen. If set to 0 Spring will autodetect the current resolution of your desktop."); CONFIG(int, WindowPosX).defaultValue(32).description("Sets the horizontal position of the game window, if Fullscreen is 0. When WindowBorderless is set, this should usually be 0."); CONFIG(int, WindowPosY).defaultValue(32).description("Sets the vertical position of the game window, if Fullscreen is 0. When WindowBorderless is set, this should usually be 0."); -CONFIG(int, WindowState).defaultValue(0); +CONFIG(int, WindowState).defaultValue(CGlobalRendering::WINSTATE_MAXIMIZED); CONFIG(bool, WindowBorderless).defaultValue(false).description("When set and Fullscreen is 0, will put the game in Borderless Window mode, also known as Windowed Fullscreen. When using this, it is generally best to also set WindowPosX and WindowPosY to 0"); CONFIG(int, PathingThreadCount).defaultValue(0).safemodeValue(1).minimumValue(0); -CONFIG(int, MultiThreadCount).defaultValue(0).safemodeValue(1).minimumValue(0).maximumValue(GML_MAX_NUM_THREADS); CONFIG(std::string, name).defaultValue(UnnamedPlayerName).description("Sets your name in the game. Since this is overridden by lobbies with your lobby username when playing, it usually only comes up when viewing replays or starting the engine directly for testing purposes."); +CONFIG(bool, BlockCompositing).defaultValue(false).safemodeValue(true).description("Disables kwin compositing to fix tearing, possible fixes low FPS in windowed mode, too."); -SelectMenu* selectMenu = NULL; -ClientSetup* startsetup = NULL; +static SDL_GLContext sdlGlCtx; +static SDL_Window* window; /** @@ -180,14 +178,14 @@ FileSystemInitializer::InitializeLogOutput(); CLogOutput::LogSystemInfo(); + LOG(" CPU Clock: %s", spring_clock::GetName()); + LOG("Physical CPU Cores: %d", Threading::GetPhysicalCpuCores()); + LOG(" Logical CPU Cores: %d", Threading::GetLogicalCpuCores()); CMyMath::Init(); globalRendering = new CGlobalRendering(); globalRendering->SetFullScreen(configHandler->GetBool("Fullscreen"), cmdline->IsSet("window"), cmdline->IsSet("fullscreen")); - globalRendering->SetViewSize( - cmdline->IsSet("xresolution")? std::max(cmdline->GetInt("xresolution"), 640): configHandler->GetInt("XResolution"), - cmdline->IsSet("yresolution")? std::max(cmdline->GetInt("yresolution"), 480): configHandler->GetInt("YResolution") - ); + globalRendering->SetViewSize(configHandler->GetInt("XResolution"), configHandler->GetInt("YResolution")); #if !(defined(WIN32) || defined(__APPLE__) || defined(HEADLESS)) // this MUST run before any other X11 call (esp. those by SDL!) @@ -198,7 +196,7 @@ } #endif -#if defined(_WIN32) && defined(__GNUC__) +#if defined(WIN32) && defined(__GNUC__) // load QTCreator's gdb helper dll; a variant of this should also work on other OSes { // don't display a dialog box if gdb helpers aren't found @@ -209,15 +207,12 @@ SetErrorMode(olderrors); } #endif - - // Initialize class system - creg::System::InitializeClasses(); - // Initialize crash reporting CrashHandler::Install(); - good_fpu_control_registers(__FUNCTION__); + // CREG & GlobalConfig + creg::System::InitializeClasses(); GlobalConfig::Instantiate(); // Create Window @@ -226,44 +221,32 @@ return false; } + // Init OpenGL + LoadExtensions(); // Initialize GLEW + globalRendering->PostInit(); + InitOpenGL(); + // Install Watchdog (must happen after time epoch is set) Watchdog::Install(); Watchdog::RegisterThread(WDT_MAIN, true); // ArchiveScanner uses for_mt --> needs thread-count set - // FIXME: USELESS? InitThreadPool ALSO CALLS SetThreadCount! + // (use all threads available, later switch to less) ThreadPool::SetThreadCount(ThreadPool::GetMaxThreads()); FileSystemInitializer::Initialize(); - Threading::InitThreadPool(); mouseInput = IMouseInput::GetInstance(); - keyInput = KeyInput::GetInstance(); input.AddHandler(boost::bind(&SpringApp::MainEventHandler, this, _1)); // Global structures gs = new CGlobalSynced(); gu = new CGlobalUnsynced(); - // Initialize GLEW - LoadExtensions(); - - // check if FSAA init worked fine - if (globalRendering->FSAA && !MultisampleVerify()) - globalRendering->FSAA = 0; - - globalRendering->PostInit(); - - InitOpenGL(); + // GUIs agui::InitGui(); LoadFonts(); - - // Initialize named texture handler CNamedTextures::Init(); - - // Initialize Lua GL LuaOpenGL::Init(); - - // Sound & Input ISound::Initialize(); InitJoystick(); @@ -272,9 +255,7 @@ // Multithreading & Affinity Threading::SetThreadName("unknown"); // set default threadname - - LOG("[%s] CPU Clock: %s", __FUNCTION__, spring_clock::GetName()); - LOG("[%s] CPU Cores: %d", __FUNCTION__, Threading::GetAvailableCores()); + Threading::InitThreadPool(); // Create CGameSetup and CPreGame objects Startup(); @@ -294,34 +275,24 @@ // SDL will cause a creation of gpu-driver thread that will clone its name from the starting threads (= this one = mainthread) Threading::SetThreadName("gpu-driver"); - #ifdef WIN32 // the crash reporter should be catching errors, not SDL if ((SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) == -1)) { - #else - if ((SDL_Init(SDL_INIT_VIDEO) == -1)) { - #endif LOG_L(L_FATAL, "Could not initialize SDL: %s", SDL_GetError()); return false; } PrintAvailableResolutions(); - WindowManagerHelper::SetCaption(title); + SDL_DisableScreenSaver(); - if (!SetSDLVideoMode()) { + if (!CreateSDLWindow(title)) { LOG_L(L_FATAL, "Failed to set SDL video mode: %s", SDL_GetError()); return false; } - RestoreWindowPosition(); if (cmdline->IsSet("minimise")) { - globalRendering->active = false; - SDL_WM_IconifyWindow(); + SDL_HideWindow(window); } - glClearColor(0.0f,0.0f,0.0f,0.0f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - SDL_GL_SwapBuffers(); - // anyone other thread spawned from the main-process should be `unknown` Threading::SetThreadName("unknown"); return true; @@ -332,27 +303,25 @@ * * Sets SDL video mode options/settings */ -bool SpringApp::SetSDLVideoMode() +bool SpringApp::CreateSDLWindow(const char* title) { - int sdlflags = SDL_OPENGL | SDL_RESIZABLE; + int sdlflags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE; - // w/o SDL_NOFRAME, kde's windowmanager still creates a border (in fullscreen!) and forces a `window`-resize causing a lot of trouble (in the ::SaveWindowPosition) - sdlflags |= globalRendering->fullScreen ? SDL_FULLSCREEN | SDL_NOFRAME : 0; - - const bool winBorderless = configHandler->GetBool("WindowBorderless"); - sdlflags |= winBorderless ? SDL_NOFRAME : 0; - - SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); + // use standard: 24bit color + 24bit depth + 8bit stencil & doublebuffered + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); // enable alpha channel ??? - - globalRendering->depthBufferBits = 24; - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, globalRendering->depthBufferBits); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); + //SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - //! FullScreen AntiAliasing + // Create GL debug context when wanted (allows further GL verbose informations, but runs slower) + if (configHandler->GetBool("DebugGL")) { + SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG); + } + + // FullScreen AntiAliasing globalRendering->FSAA = configHandler->GetInt("FSAALevel"); if (globalRendering->FSAA > 0) { make_even_number(globalRendering->FSAA); @@ -360,256 +329,120 @@ SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, globalRendering->FSAA); } - //! use desktop resolution? - if ((globalRendering->viewSizeX<=0) || (globalRendering->viewSizeY<=0)) { - const SDL_VideoInfo* screenInfo = SDL_GetVideoInfo(); //! it's a read-only struct (we don't need to free it!) - globalRendering->viewSizeX = screenInfo->current_w; - globalRendering->viewSizeY = screenInfo->current_h; - } - //! fallback if resolution couldn't be detected - if ((globalRendering->viewSizeX<=0) || (globalRendering->viewSizeY<=0)) { - globalRendering->viewSizeX = 1024; - globalRendering->viewSizeY = 768; - } - - //! screen will be freed by SDL_Quit() - //! from: http://sdl.beuc.net/sdl.wiki/SDL_SetVideoMode - //! Note 3: This function should be called in the main thread of your application. - //! User note 1: Some have found that enabling OpenGL attributes like SDL_GL_STENCIL_SIZE (the stencil buffer size) before the video mode has been set causes the application to simply ignore those attributes, while enabling attributes after the video mode has been set works fine. - //! User note 2: Also note that, in Windows, setting the video mode resets the current OpenGL context. You must execute again the OpenGL initialization code (set the clear color or the shade model, or reload textures, for example) after calling SDL_SetVideoMode. In Linux, however, it works fine, and the initialization code only needs to be executed after the first call to SDL_SetVideoMode (although there is no harm in executing the initialization code after each call to SDL_SetVideoMode, for example for a multiplatform application). - SDL_Surface* screen = SDL_SetVideoMode(globalRendering->viewSizeX, globalRendering->viewSizeY, 32, sdlflags); - if (!screen) { - char buf[1024]; - SNPRINTF(buf, sizeof(buf), "Could not set video mode:\n%s", SDL_GetError()); - handleerror(NULL, buf, "ERROR", MBF_OK|MBF_EXCL); - return false; - } - -#ifdef STREFLOP_H - //! Something in SDL_SetVideoMode (OpenGL drivers?) messes with the FPU control word. - //! Set single precision floating point math. - streflop::streflop_init(); -#endif - - //! setup GL smoothing - const int lineSmoothing = configHandler->GetInt("SmoothLines"); - if (lineSmoothing > 0) { - GLenum hint = GL_FASTEST; - if (lineSmoothing >= 3) { - hint = GL_NICEST; - } else if (lineSmoothing >= 2) { - hint = GL_DONT_CARE; - } - glEnable(GL_LINE_SMOOTH); - glHint(GL_LINE_SMOOTH_HINT, hint); - } - const int pointSmoothing = configHandler->GetInt("SmoothPoints"); - if (pointSmoothing > 0) { - GLenum hint = GL_FASTEST; - if (pointSmoothing >= 3) { - hint = GL_NICEST; - } else if (pointSmoothing >= 2) { - hint = GL_DONT_CARE; - } - glEnable(GL_POINT_SMOOTH); - glHint(GL_POINT_SMOOTH_HINT, hint); - } - - //! setup LOD bias factor - const float lodBias = configHandler->GetFloat("TextureLODBias"); - if (math::fabs(lodBias)>0.01f) { - glTexEnvf(GL_TEXTURE_FILTER_CONTROL,GL_TEXTURE_LOD_BIAS, lodBias ); - } - - //! there must be a way to see if this is necessary, compare old/new context pointers? - if (configHandler->GetBool("FixAltTab")) { - //! free GL resources - GLContext::Free(); - - //! initialize any GL resources that were lost - GLContext::Init(); - } - - int bits; - SDL_GL_GetAttribute(SDL_GL_BUFFER_SIZE, &bits); - SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &globalRendering->depthBufferBits); - - if (globalRendering->fullScreen) { - LOG("[%s] video mode set to %ix%i/%ibit", __FUNCTION__, globalRendering->viewSizeX, globalRendering->viewSizeY, bits); - } else { - LOG("[%s] video mode set to %ix%i/%ibit (windowed)", __FUNCTION__, globalRendering->viewSizeX, globalRendering->viewSizeY, bits); + // Use Native Desktop Resolution + // and yes SDL2 can do this itself when sizeX & sizeY are set to zero, but + // oh wonder SDL2 failes then when you use Display Cloneing and similar + // -> i.e. DVI monitor runs then at 640x400 and HDMI at full-HD (yes with display _cloning_!) + SDL_DisplayMode dmode; + SDL_GetDesktopDisplayMode(0, &dmode); + if (globalRendering->viewSizeX<=0) globalRendering->viewSizeX = dmode.w; + if (globalRendering->viewSizeY<=0) globalRendering->viewSizeY = dmode.h; + + // In Windowed Mode Limit Minimum Window Size + static const int minViewSizeX = 400; + static const int minViewSizeY = 300; + if (!globalRendering->fullScreen) { + globalRendering->viewSizeX = std::max(globalRendering->viewSizeX, minViewSizeX); + globalRendering->viewSizeY = std::max(globalRendering->viewSizeY, minViewSizeY); } - return true; -} - - -// origin for our coordinates is the bottom left corner -bool SpringApp::GetDisplayGeometry() -{ -#ifndef HEADLESS - //! not really needed, but makes it safer against unknown windowmanager behaviours + // Borderless + const bool borderless = configHandler->GetBool("WindowBorderless"); if (globalRendering->fullScreen) { - globalRendering->UpdateWindowGeometry(); - return true; + sdlflags |= borderless ? SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_FULLSCREEN; } + sdlflags |= borderless ? SDL_WINDOW_BORDERLESS : 0; - SDL_SysWMinfo info; - SDL_VERSION(&info.version); - - if (!SDL_GetWMInfo(&info)) { - return false; +#if defined(WIN32) + if (borderless && !globalRendering->fullScreen) { + sdlflags &= ~SDL_WINDOW_RESIZABLE; } +#endif - - #if defined(__APPLE__) - // TODO: implement this function & RestoreWindowPosition() on Mac - globalRendering->screenSizeX = 0; - globalRendering->screenSizeY = 0; - globalRendering->winSizeX = globalRendering->viewSizeX; - globalRendering->winSizeY = globalRendering->viewSizeY; - globalRendering->winPosX = 30; - globalRendering->winPosY = 30; - globalRendering->winState = CGlobalRendering::WINSTATE_DEFAULT; - - #elif defined(WIN32) - globalRendering->screenSizeX = GetSystemMetrics(SM_CXSCREEN); - globalRendering->screenSizeY = GetSystemMetrics(SM_CYSCREEN); - - RECT rect; - if (!GetClientRect(info.window, &rect)) { - return false; + // Window Pos & State + globalRendering->winPosX = configHandler->GetInt("WindowPosX"); + globalRendering->winPosY = configHandler->GetInt("WindowPosY"); + globalRendering->winState = configHandler->GetInt("WindowState"); + switch (globalRendering->winState) { + case CGlobalRendering::WINSTATE_MAXIMIZED: sdlflags |= SDL_WINDOW_MAXIMIZED; break; + case CGlobalRendering::WINSTATE_MINIMIZED: sdlflags |= SDL_WINDOW_MINIMIZED; break; } - if ((rect.right - rect.left) == 0 || (rect.bottom - rect.top) == 0) + // Create Window + window = SDL_CreateWindow(title, + globalRendering->winPosX, globalRendering->winPosY, + globalRendering->viewSizeX, globalRendering->viewSizeY, + sdlflags); + if (!window) { + char buf[1024]; + SNPRINTF(buf, sizeof(buf), "Could not set video mode:\n%s", SDL_GetError()); + handleerror(NULL, buf, "ERROR", MBF_OK|MBF_EXCL); return false; - - globalRendering->winSizeX = rect.right - rect.left; - globalRendering->winSizeY = rect.bottom - rect.top; - - // translate from client coords to screen coords - MapWindowPoints(info.window, HWND_DESKTOP, (LPPOINT)&rect, 2); - - // GetClientRect doesn't do the right thing for restoring window position - if (!globalRendering->fullScreen) { - GetWindowRect(info.window, &rect); - } - - globalRendering->winPosX = rect.left; - globalRendering->winPosY = rect.top; - - // Get WindowState - WINDOWPLACEMENT wp; - wp.length = sizeof(WINDOWPLACEMENT); - if (GetWindowPlacement(info.window, &wp)) { - switch (wp.showCmd) { - case SW_SHOWMAXIMIZED: - globalRendering->winState = CGlobalRendering::WINSTATE_MAXIMIZED; - break; - case SW_SHOWMINIMIZED: - //! minimized startup breaks SDL_init stuff, so don't store it - //globalRendering->winState = CGlobalRendering::WINSTATE_MINIMIZED; - //break; - default: - globalRendering->winState = CGlobalRendering::WINSTATE_DEFAULT; - } } - #else - info.info.x11.lock_func(); - { - Display* display = info.info.x11.display; - Window window = info.info.x11.wmwindow; + // Create GL Context + SDL_SetWindowMinimumSize(window, minViewSizeX, minViewSizeY); + sdlGlCtx = SDL_GL_CreateContext(window); + globalRendering->window = window; - XWindowAttributes attrs; - XGetWindowAttributes(display, window, &attrs); - const Screen* screen = attrs.screen; - - globalRendering->screenSizeX = WidthOfScreen(screen); - globalRendering->screenSizeY = HeightOfScreen(screen); - globalRendering->winSizeX = attrs.width; - globalRendering->winSizeY = attrs.height; - - Window tmp; - int xp, yp; - XTranslateCoordinates(display, window, attrs.root, 0, 0, &xp, &yp, &tmp); - globalRendering->winPosX = xp; - globalRendering->winPosY = yp; - - if (!globalRendering->fullScreen) { - int frame_left, frame_top; - MyX11GetFrameBorderOffset(display, window, &frame_left, &frame_top); - globalRendering->winPosX -= frame_left; - globalRendering->winPosY -= frame_top; - } +#ifdef STREFLOP_H + // Something in SDL_SetVideoMode (OpenGL drivers?) messes with the FPU control word. + // Set single precision floating point math. + streflop::streflop_init(); +#endif - globalRendering->winState = MyX11GetWindowState(display, window); +#if !defined(HEADLESS) + // disable desktop compositing to fix tearing + // (happens at 300fps, neither fullscreen nor vsync fixes it, so disable compositing) + // On Windows Aero often uses vsync, and so when Spring runs windowed it will run with + // vsync too, resulting in bad performance. + if (configHandler->GetBool("BlockCompositing")) { + WindowManagerHelper::BlockCompositing(window); } - info.info.x11.unlock_func(); - - #endif // defined(__APPLE__) -#endif // defined(HEADLESS) +#endif return true; } -/** - * Restores position of the window, if we are not in full-screen mode - */ -void SpringApp::RestoreWindowPosition() +// origin for our coordinates is the bottom left corner +void SpringApp::GetDisplayGeometry() { - globalRendering->winPosX = configHandler->GetInt("WindowPosX"); - globalRendering->winPosY = configHandler->GetInt("WindowPosY"); - globalRendering->winState = configHandler->GetInt("WindowState"); - -#ifndef HEADLESS - if (!globalRendering->fullScreen) { - SDL_SysWMinfo info; - SDL_VERSION(&info.version); - - if (SDL_GetWMInfo(&info)) { - #if defined(WIN32) - bool stateChanged = false; - - if (globalRendering->winState != CGlobalRendering::WINSTATE_DEFAULT) { - WINDOWPLACEMENT wp; - memset(&wp,0,sizeof(WINDOWPLACEMENT)); - wp.length = sizeof(WINDOWPLACEMENT); - stateChanged = true; - int wState; - switch (globalRendering->winState) { - case 1: wState = SW_SHOWMAXIMIZED; break; - //! Setting the main-window minimized breaks initialization - case 2: // wState = SW_SHOWMINIMIZED; break; - default: stateChanged = false; - } - if (stateChanged) { - ShowWindow(info.window, wState); - GetDisplayGeometry(); - } - } - - if (!stateChanged) { - MoveWindow(info.window, globalRendering->winPosX, globalRendering->winPosY, globalRendering->viewSizeX, globalRendering->viewSizeY, true); - streflop::streflop_init(); // MoveWindow may modify FPU flags - } - - #elif defined(__APPLE__) - // TODO: implement this function +#ifdef HEADLESS + globalRendering->screenSizeX = 8; + globalRendering->screenSizeY = 8; + globalRendering->winSizeX = 8; + globalRendering->winSizeY = 8; + globalRendering->winPosX = 0; + globalRendering->winPosY = 0; + globalRendering->UpdateViewPortGeometry(); + return; - #else - info.info.x11.lock_func(); - { - XMoveWindow(info.info.x11.display, info.info.x11.wmwindow, globalRendering->winPosX, globalRendering->winPosY); - MyX11SetWindowState(info.info.x11.display, info.info.x11.wmwindow, globalRendering->winState); - } - info.info.x11.unlock_func(); +#else + SDL_Rect screenSize; + SDL_GetDisplayBounds(SDL_GetWindowDisplayIndex(window), &screenSize); + globalRendering->screenSizeX = screenSize.w; + globalRendering->screenSizeY = screenSize.h; + + SDL_GetWindowSize(window, &globalRendering->winSizeX, &globalRendering->winSizeY); + SDL_GetWindowPosition(window, &globalRendering->winPosX, &globalRendering->winPosY); + + globalRendering->UpdateViewPortGeometry(); + + //XXX SDL2 is crap ... + // Reading window state fails if it is changed via the window manager, like clicking on the titlebar (2013) + // https://bugzilla.libsdl.org/show_bug.cgi?id=1508 & https://bugzilla.libsdl.org/show_bug.cgi?id=2282 + // happens on linux too! + const int state = WindowManagerHelper::GetWindowState(window); - #endif // defined(WIN32) - } + globalRendering->winState = CGlobalRendering::WINSTATE_DEFAULT; + if (state & SDL_WINDOW_MAXIMIZED) { + globalRendering->winState = CGlobalRendering::WINSTATE_MAXIMIZED; + } else + if (state & SDL_WINDOW_MINIMIZED) { + globalRendering->winState = CGlobalRendering::WINSTATE_MINIMIZED; } -#endif // defined(HEADLESS) +#endif } @@ -619,12 +452,16 @@ void SpringApp::SaveWindowPosition() { #ifndef HEADLESS + configHandler->Set("Fullscreen", globalRendering->fullScreen); if (!globalRendering->fullScreen) { GetDisplayGeometry(); if (globalRendering->winState == CGlobalRendering::WINSTATE_DEFAULT) { configHandler->Set("WindowPosX", globalRendering->winPosX); configHandler->Set("WindowPosY", globalRendering->winPosY); configHandler->Set("WindowState", globalRendering->winState); + } else + if (globalRendering->winState == CGlobalRendering::WINSTATE_MINIMIZED) { + // don't automatically save minimized states } else { configHandler->Set("WindowState", globalRendering->winState); } @@ -633,16 +470,12 @@ } -void SpringApp::SetupViewportGeometry(bool windowExposed) +void SpringApp::SetupViewportGeometry() { - if (!GetDisplayGeometry()) { - // note: if GDG returns false this might not have been called - // guaranteed in fullscreen-mode when it returns (true) early - globalRendering->UpdateWindowGeometry(); - } + GetDisplayGeometry(); globalRendering->SetDualScreenParams(); - globalRendering->UpdateViewPortGeometry(windowExposed); + globalRendering->UpdateViewPortGeometry(); globalRendering->UpdatePixelGeometry(); const int vpx = globalRendering->viewPosX; @@ -657,17 +490,72 @@ */ void SpringApp::InitOpenGL() { + // reinit vsync VSync.Init(); - SetupViewportGeometry(false); + // check if FSAA init worked fine + if (globalRendering->FSAA && !MultisampleVerify()) + globalRendering->FSAA = 0; + + // setup GL smoothing + const int lineSmoothing = configHandler->GetInt("SmoothLines"); + if (lineSmoothing > 0) { + GLenum hint = GL_FASTEST; + if (lineSmoothing >= 3) { + hint = GL_NICEST; + } else if (lineSmoothing >= 2) { + hint = GL_DONT_CARE; + } + glEnable(GL_LINE_SMOOTH); + glHint(GL_LINE_SMOOTH_HINT, hint); + } + const int pointSmoothing = configHandler->GetInt("SmoothPoints"); + if (pointSmoothing > 0) { + GLenum hint = GL_FASTEST; + if (pointSmoothing >= 3) { + hint = GL_NICEST; + } else if (pointSmoothing >= 2) { + hint = GL_DONT_CARE; + } + glEnable(GL_POINT_SMOOTH); + glHint(GL_POINT_SMOOTH_HINT, hint); + } + + // setup LOD bias factor + const float lodBias = configHandler->GetFloat("TextureLODBias"); + if (math::fabs(lodBias) > 0.01f) { + glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, lodBias ); + } + + //FIXME not needed anymore with SDL2? + if (configHandler->GetBool("FixAltTab")) { + // free GL resources + GLContext::Free(); + + // initialize any GL resources that were lost + GLContext::Init(); + } + + // setup viewport + SetupViewportGeometry(); glViewport(globalRendering->viewPosX, globalRendering->viewPosY, globalRendering->viewSizeX, globalRendering->viewSizeY); - gluPerspective(45.0f, globalRendering->aspectRatio, 2.8f, CGlobalRendering::MAX_VIEW_RANGE); + gluPerspective(45.0f, globalRendering->aspectRatio, 2.8f, CGlobalRendering::MAX_VIEW_RANGE); // Initialize some GL states glShadeModel(GL_SMOOTH); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); + + // Clear Window + glClearColor(0.0f,0.0f,0.0f,0.0f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + SDL_GL_SwapWindow(window); + + // Print Final Mode (call after SetupViewportGeometry, which updates viewSizeX/Y) + SDL_DisplayMode dmode; + SDL_GetWindowDisplayMode(window, &dmode); + LOG("[%s] video mode set to %ix%i:%ibit @%iHz %s", __FUNCTION__, globalRendering->viewSizeX, globalRendering->viewSizeY, SDL_BITSPERPIXEL(dmode.format), dmode.refresh_rate, globalRendering->fullScreen ? "" : "(windowed)"); } @@ -691,12 +579,22 @@ const static std::string installBroken = ", installation of spring broken? did you run make install?"; if (!font) { throw content_error(std::string("Failed to load FontFile: ") + fontFile + installBroken); - } else if (!smallFont) { + } + if (!smallFont) { throw content_error(std::string("Failed to load SmallFontFile: ") + smallFontFile + installBroken); } } - +// initialize basic systems for command line help / output +static void ConsolePrintInitialize(const std::string& configSource, bool safemode) +{ + spring_clock::PushTickRate(false); + spring_time::setstarttime(spring_time::gettime(true)); + LOG_DISABLE(); + FileSystemInitializer::PreInitializeConfigHandler(configSource, safemode); + FileSystemInitializer::InitializeLogOutput(); + LOG_ENABLE(); +} /** * @return whether commandline parsing was successful @@ -714,8 +612,7 @@ cmdline->AddSwitch('b', "minimise", "Start in background (minimised)"); cmdline->AddSwitch(0, "nocolor", "Disables colorized stdout"); cmdline->AddSwitch('q', "quiet", "Ignore unrecognized arguments"); - cmdline->AddSwitch('s', "server", "Run as a server"); - cmdline->AddSwitch('c', "client", "Run as a client"); + cmdline->AddString('s', "server", "Run as a server"); cmdline->AddSwitch('t', "textureatlas", "Dump each finalized textureatlas in textureatlasN.tga"); cmdline->AddInt( 0, "benchmark", "Enable benchmark mode (writes a benchmark.data file). The given number specifies the timespan to test."); @@ -809,18 +706,12 @@ // mutually exclusive options that cause spring to quit immediately if (cmdline->IsSet("list-ai-interfaces")) { - LOG_DISABLE(); - FileSystemInitializer::PreInitializeConfigHandler(configSource, safemode); - FileSystemInitializer::InitializeLogOutput(); - LOG_ENABLE(); + ConsolePrintInitialize(configSource, safemode); IAILibraryManager::OutputAIInterfacesInfo(); exit(0); } else if (cmdline->IsSet("list-skirmish-ais")) { - LOG_DISABLE(); - FileSystemInitializer::PreInitializeConfigHandler(configSource, safemode); - FileSystemInitializer::InitializeLogOutput(); - LOG_ENABLE(); + ConsolePrintInitialize(configSource, safemode); IAILibraryManager::OutputSkirmishAIInfo(); exit(0); } @@ -849,21 +740,15 @@ } -void SpringApp::RunScript(const std::string& buf) { - startsetup = new ClientSetup(); - startsetup->Init(buf); - - // commandline parameters overwrite setup - if (cmdline->IsSet("client")) - startsetup->isHost = false; - else if (cmdline->IsSet("server")) - startsetup->isHost = true; +void SpringApp::RunScript(boost::shared_ptr clientSetup, const std::string& buf) +{ + clientSetup->LoadFromStartScript(buf); + // LoadFromStartScript overrides all values so reset cmdline defined ones + if (cmdline->IsSet("server")) { clientSetup->hostIP = cmdline->GetString("server"); clientSetup->isHost = true; } + clientSetup->SanityCheck(); -#ifdef SYNCDEBUG - CSyncDebugger::GetInstance()->Initialize(startsetup->isHost, 64); //FIXME: add actual number of player -#endif - pregame = new CPreGame(startsetup); - if (startsetup->isHost) + pregame = new CPreGame(clientSetup); + if (clientSetup->isHost) pregame->LoadSetupscript(buf); } @@ -873,63 +758,56 @@ */ void SpringApp::Startup() { - if ((cmdline->IsSet("game") && cmdline->IsSet("map"))) { // --game and --map directly specified, try to run them - const std::string game = cmdline->GetString("game"); - const std::string map = cmdline->GetString("map"); - std::string buf = StartScriptGen::CreateMinimalSetup(game, map); - RunScript(buf); - return; - } - + // bash input const std::string inputFile = cmdline->GetInputFile(); + const std::string extension = FileSystem::GetExtension(inputFile); - if (inputFile.empty()) { -#ifdef HEADLESS - LOG_L(L_FATAL, - "The headless version of the engine can not be run in interactive mode.\n" - "Please supply a start-script, save- or demo-file."); - exit(1); -#endif - bool server = !cmdline->IsSet("client") || cmdline->IsSet("server"); -#ifdef SYNCDEBUG - CSyncDebugger::GetInstance()->Initialize(server, 64); -#endif - selectMenu = new SelectMenu(server); - activeController = selectMenu; - } else if (inputFile.rfind("sdf") == inputFile.size() - 3) { - std::string demoFileName = inputFile; - std::string demoPlayerName = configHandler->GetString("name"); + // create base clientsetup + boost::shared_ptr startsetup(new ClientSetup()); + if (cmdline->IsSet("server")) { startsetup->hostIP = cmdline->GetString("server"); startsetup->isHost = true; } + startsetup->myPlayerName = configHandler->GetString("name"); + startsetup->SanityCheck(); - if (demoPlayerName.empty()) { - demoPlayerName = UnnamedPlayerName; + // no argument (either game is given or show selectmenu) + if (inputFile.empty()) { + startsetup->isHost = true; + if (cmdline->IsSet("game") && cmdline->IsSet("map")) { + // --game and --map directly specified, try to run them + std::string buf = StartScriptGen::CreateMinimalSetup(cmdline->GetString("game"), cmdline->GetString("map")); + RunScript(startsetup, buf); } else { - demoPlayerName = StringReplaceInPlace(demoPlayerName, ' ', '_'); + // menu + #ifdef HEADLESS + handleerror(NULL, + "The headless version of the engine can not be run in interactive mode.\n" + "Please supply a start-script, save- or demo-file.", "ERROR", MBF_OK|MBF_EXCL); + #endif + activeController = new SelectMenu(startsetup); } + return; + } - demoPlayerName += " (spec)"; - - startsetup = new ClientSetup(); - startsetup->isHost = true; // local demo play - startsetup->myPlayerName = demoPlayerName; - -#ifdef SYNCDEBUG - CSyncDebugger::GetInstance()->Initialize(true, 64); //FIXME: add actual number of player -#endif - + // process given argument + if (inputFile.find("spring://") == 0) { + // url (syntax: spring://username:password@host:port) + if (!ParseSpringUri(inputFile, startsetup->myPlayerName, startsetup->myPasswd, startsetup->hostIP, startsetup->hostPort)) + throw content_error("invalid url specified: " + inputFile); + startsetup->isHost = false; + pregame = new CPreGame(startsetup); + } else if (extension == "sdf") { + // demo + startsetup->isHost = true; + startsetup->myPlayerName += " (spec)"; pregame = new CPreGame(startsetup); - pregame->LoadDemo(demoFileName); - } else if (inputFile.rfind("ssf") == inputFile.size() - 3) { - std::string savefile = inputFile; - startsetup = new ClientSetup(); + pregame->LoadDemo(inputFile); + } else if (extension == "ssf") { + // savegame startsetup->isHost = true; - startsetup->myPlayerName = configHandler->GetString("name"); -#ifdef SYNCDEBUG - CSyncDebugger::GetInstance()->Initialize(true, 64); //FIXME: add actual number of player -#endif pregame = new CPreGame(startsetup); - pregame->LoadSavefile(savefile); + pregame->LoadSavefile(inputFile); } else { - LOG("[%s] loading startscript from: %s", __FUNCTION__, inputFile.c_str()); + // startscript + LOG("[%s] Loading StartScript from: %s", __FUNCTION__, inputFile.c_str()); CFileHandler fh(inputFile, SPRING_VFS_PWD_ALL); if (!fh.FileExists()) throw content_error("Setup-script does not exist in given location: " + inputFile); @@ -937,7 +815,8 @@ std::string buf; if (!fh.LoadStringData(buf)) throw content_error("Setup-script cannot be read: " + inputFile); - RunScript(buf); + + RunScript(startsetup, buf); } } @@ -955,66 +834,22 @@ int ret = 1; if (activeController) { - Watchdog::ClearTimer(WDT_MAIN); - - if (!GML::SimThreadRunning()) { - ret = Threading::UpdateGameController(activeController); - } - + ret = activeController->Update(); if (ret) { ScopedTimer cputimer("GameController::Draw"); ret = activeController->Draw(); - - GML::PumpAux(); } } - { - ScopedTimer cputimer("SwapBuffers"); - VSync.Delay(); - SDL_GL_SwapBuffers(); - } - - if (globalRendering->FSAA) - glDisable(GL_MULTISAMPLE_ARB); - + ScopedTimer cputimer("SwapBuffers"); + spring_time pre = spring_now(); + VSync.Delay(); + SDL_GL_SwapWindow(window); + eventHandler.DbgTimingInfo(TIMING_SWAP, pre, spring_now()); return ret; } - -static void ResetScreenSaverTimeout() -{ -#ifndef HEADLESS - #if defined(WIN32) - static spring_time lastreset; - spring_time curreset = spring_gettime(); - if(globalRendering->active && (curreset - lastreset) > spring_secs(1)) { - lastreset = curreset; - int timeout; // reset screen saver timer - if(SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, &timeout, 0)) - SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, timeout, NULL, 0); - streflop::streflop_init(); // SystemParametersInfo may modify FPU flags - } - #elif defined(__APPLE__) - // TODO: implement - return; - #else - static spring_time lastreset; - spring_time curreset = spring_gettime(); - if(globalRendering->active && (curreset - lastreset) > spring_secs(1)) { - lastreset = curreset; - SDL_SysWMinfo info; - SDL_VERSION(&info.version); - if (SDL_GetWMInfo(&info)) { - XForceScreenSaver(info.info.x11.display, ScreenSaverReset); - } - } - #endif -#endif -} - - /** * Executes the application * (contains main game loop) @@ -1028,13 +863,11 @@ CATCH_SPRING_ERRORS while (!gu->globalQuit) { - ResetScreenSaverTimeout(); + Watchdog::ClearTimer(WDT_MAIN); input.PushEvents(); - if (!Update()) break; } - SaveWindowPosition(); ShutDown(); @@ -1061,7 +894,6 @@ LOG("[SpringApp::%s][1]", __FUNCTION__); ThreadPool::SetThreadCount(0); - GML::Exit(); LOG("[SpringApp::%s][2]", __FUNCTION__); SafeDelete(pregame); @@ -1069,21 +901,19 @@ // expect game-pointer to remain valid during call delete game; game = NULL; - LOG("[SpringApp::%s][3]", __FUNCTION__); - SafeDelete(selectMenu); agui::FreeGui(); - LOG("[SpringApp::%s][4]", __FUNCTION__); + LOG("[SpringApp::%s][3]", __FUNCTION__); SafeDelete(net); SafeDelete(gameServer); SafeDelete(gameSetup); - LOG("[SpringApp::%s][5]", __FUNCTION__); + LOG("[SpringApp::%s][4]", __FUNCTION__); CLoadScreen::DeleteInstance(); ISound::Shutdown(); FreeJoystick(); - LOG("[SpringApp::%s][6]", __FUNCTION__); + LOG("[SpringApp::%s][5]", __FUNCTION__); SafeDelete(font); SafeDelete(smallFont); CNamedTextures::Kill(); @@ -1091,111 +921,84 @@ GlobalConfig::Deallocate(); UnloadExtensions(); - LOG("[SpringApp::%s][7]", __FUNCTION__); IMouseInput::FreeInstance(mouseInput); - KeyInput::FreeInstance(keyInput); - LOG("[SpringApp::%s][8]", __FUNCTION__); - SDL_WM_GrabInput(SDL_GRAB_OFF); + LOG("[SpringApp::%s][6]", __FUNCTION__); + SDL_SetWindowGrab(window, SDL_FALSE); WindowManagerHelper::FreeIcon(); #if !defined(HEADLESS) + SDL_GL_DeleteContext(sdlGlCtx); SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK); #endif SDL_Quit(); - LOG("[SpringApp::%s][9]", __FUNCTION__); + LOG("[SpringApp::%s][7]", __FUNCTION__); SafeDelete(gs); SafeDelete(gu); SafeDelete(globalRendering); - SafeDelete(startsetup); SafeDelete(luaSocketRestrictions); - LOG("[SpringApp::%s][10]", __FUNCTION__); FileSystemInitializer::Cleanup(); - LOG("[SpringApp::%s][11]", __FUNCTION__); + LOG("[SpringApp::%s][8]", __FUNCTION__); Watchdog::Uninstall(); - LOG("[SpringApp::%s][12]", __FUNCTION__); + LOG("[SpringApp::%s][9]", __FUNCTION__); } + bool SpringApp::MainEventHandler(const SDL_Event& event) { switch (event.type) { - case SDL_VIDEORESIZE: { - GML_MSTMUTEX_LOCK(sim, -1); // MainEventHandler - - Watchdog::ClearTimer(WDT_MAIN, true); - globalRendering->viewSizeX = event.resize.w; - globalRendering->viewSizeY = event.resize.h; -#ifndef WIN32 - // HACK We don't want to break resizing on windows (again?), - // so someone should test this very well before enabling it. - SetSDLVideoMode(); -#endif - InitOpenGL(); - activeController->ResizeEvent(); - - break; - } - case SDL_VIDEOEXPOSE: { - GML_MSTMUTEX_LOCK(sim, -1); // MainEventHandler - - Watchdog::ClearTimer(WDT_MAIN, true); - // re-initialize the stencil - glClearStencil(0); - glClear(GL_STENCIL_BUFFER_BIT); SDL_GL_SwapBuffers(); - glClear(GL_STENCIL_BUFFER_BIT); SDL_GL_SwapBuffers(); - SetupViewportGeometry(true); - - break; - } - case SDL_QUIT: { - gu->globalQuit = true; - break; - } - case SDL_ACTIVEEVENT: { - Watchdog::ClearTimer(WDT_MAIN, true); - - //! deactivate sounds and other - if (event.active.state & (SDL_APPACTIVE | (globalRendering->fullScreen ? SDL_APPINPUTFOCUS : 0))) { - globalRendering->active = !!event.active.gain; - if (ISound::IsInitialized()) { - sound->Iconified(!event.active.gain); - } - } - - //! update keydown table - if (event.active.gain) { - keyInput->Update(event.key.keysym.unicode, ((keyBindings != NULL)? keyBindings->GetFakeMetaKey(): -1)); - } - - //! unlock mouse - if (mouse && mouse->locked) { - mouse->ToggleMiddleClickScroll(); - } - - //! release all keyboard keys - if ((event.active.state & (SDL_APPACTIVE | SDL_APPINPUTFOCUS))) { - for (boost::uint16_t i = 1; i < SDLK_LAST; ++i) { - if (i != SDLK_NUMLOCK && i != SDLK_CAPSLOCK && i != SDLK_SCROLLOCK && keyInput->IsKeyPressed(i)) { - SDL_Event event; - event.type = event.key.type = SDL_KEYUP; - event.key.state = SDL_RELEASED; - event.key.keysym.sym = (SDLKey)i; - event.key.keysym.unicode = i; - //event.keysym.mod =; - //event.keysym.scancode =; - SDL_PushEvent(&event); + case SDL_WINDOWEVENT: { + switch (event.window.event) { + case SDL_WINDOWEVENT_RESIZED: { + Watchdog::ClearTimer(WDT_MAIN, true); + InitOpenGL(); + activeController->ResizeEvent(); + mouseInput->InstallWndCallback(); + } break; + case SDL_WINDOWEVENT_SHOWN: { + // reactivate sounds and other + globalRendering->active = true; + if (ISound::IsInitialized()) { + sound->Iconified(false); } - } - // SDL has some bug and does not update modstate on alt+tab/minimize etc. - SDL_SetModState((SDLMod)(SDL_GetModState() & (KMOD_NUM | KMOD_CAPS | KMOD_MODE))); - } + if (globalRendering->fullScreen) { + FBO::GLContextReinit(); + } + } break; + case SDL_WINDOWEVENT_HIDDEN: { + // deactivate sounds and other + globalRendering->active = false; + if (ISound::IsInitialized()) { + sound->Iconified(true); + } + if (globalRendering->fullScreen) { + FBO::GLContextLost(); + } + } break; + case SDL_WINDOWEVENT_FOCUS_GAINED: { + // update keydown table + KeyInput::Update(0, ((keyBindings != NULL)? keyBindings->GetFakeMetaKey(): -1)); + } break; + case SDL_WINDOWEVENT_FOCUS_LOST: { + Watchdog::ClearTimer(WDT_MAIN, true); + + // SDL has some bug and does not update modstate on alt+tab/minimize etc. + //FIXME check if still happens with SDL2 (2013) + SDL_SetModState((SDL_Keymod)(SDL_GetModState() & (KMOD_NUM | KMOD_CAPS | KMOD_MODE))); + + // release all keyboard keys + KeyInput::ReleaseAllKeys(); + + // simulate mouse release to prevent hung buttons + for (int i = 1; i <= NUM_BUTTONS; ++i) { + if (!mouse) + continue; + + if (!mouse->buttons[i].pressed) + continue; - //! simulate mouse release to prevent hung buttons - if ((event.active.state & (SDL_APPACTIVE | SDL_APPMOUSEFOCUS))) { - for (int i = 1; i <= NUM_BUTTONS; ++i) { - if (mouse && mouse->buttons[i].pressed) { SDL_Event event; event.type = event.button.type = SDL_MOUSEBUTTONUP; event.button.state = SDL_RELEASED; @@ -1205,67 +1008,67 @@ event.button.y = -1; SDL_PushEvent(&event); } - } - //! and make sure to un-capture mouse - if(!event.active.gain && SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON) - SDL_WM_GrabInput(SDL_GRAB_OFF); - } + // unlock mouse + if (mouse && mouse->locked) { + mouse->ToggleMiddleClickScroll(); + } - break; - } - case SDL_KEYDOWN: { - const boost::uint16_t sym = keyInput->GetNormalizedKeySymbol(event.key.keysym.sym); - const bool isRepeat = !!keyInput->GetKeyState(sym); + // and make sure to un-capture mouse + if (SDL_GetWindowGrab(window)) + SDL_SetWindowGrab(window, SDL_FALSE); - keyInput->Update(event.key.keysym.unicode, ((keyBindings != NULL)? keyBindings->GetFakeMetaKey(): -1)); + break; + } + case SDL_WINDOWEVENT_CLOSE: { + gu->globalQuit = true; + break; + } + }; + } break; + case SDL_QUIT: { + gu->globalQuit = true; + } break; + case SDL_TEXTEDITING: { + //FIXME don't known when this is called + } break; + case SDL_TEXTINPUT: { + if (!activeController) { + break; + } - if (activeController) { - activeController->KeyPressed(sym, isRepeat); + std::string utf8Text = event.text.text; - if (activeController->userWriting){ - // use unicode for printed characters - const boost::uint16_t usym = keyInput->GetCurrentKeyUnicodeChar(); - - const bool isDelete = (usym == 127); - const bool isIllegalUnicode = (127 < usym) && (usym < 161); - - //TODO spring doesn't support unicode/non-latin yet :< - const bool isLatin = (usym >= 32) && (usym <= 255); - const bool isColor = (usym == 255); // we use \255 for inlined colorcodes! - - if (isLatin && !isDelete && !isIllegalUnicode) { - CGameController* ac = activeController; - - if (ac->ignoreNextChar || (ac->ignoreChar == (char)usym)) { - ac->ignoreNextChar = false; - } else { - if (!isColor && (!isRepeat || ac->userInput.length() > 0)) { - const int len = (int)ac->userInput.length(); - const char str[2] = { (char)usym, 0 }; - - ac->writingPos = std::max(0, std::min(len, ac->writingPos)); - ac->userInput.insert(ac->writingPos, str); - ac->writingPos++; - } - } - } + const bool catched = eventHandler.TextInput(utf8Text); + + if (activeController->userWriting && !catched){ + auto ac = activeController; + if (ac->ignoreNextChar) { + utf8Text = utf8Text.substr(Utf8NextChar(utf8Text, 0)); } - activeController->ignoreNextChar = false; + ac->writingPos = Clamp(ac->writingPos, 0, ac->userInput.length()); + ac->userInput.insert(ac->writingPos, utf8Text); + ac->writingPos += utf8Text.length(); } - break; - } + } break; + case SDL_KEYDOWN: { + KeyInput::Update(event.key.keysym.sym, ((keyBindings != NULL)? keyBindings->GetFakeMetaKey(): -1)); + + if (activeController) { + activeController->KeyPressed(KeyInput::GetNormalizedKeySymbol(event.key.keysym.sym), event.key.repeat); + } + } break; case SDL_KEYUP: { - keyInput->Update(event.key.keysym.unicode, ((keyBindings != NULL)? keyBindings->GetFakeMetaKey(): -1)); + KeyInput::Update(event.key.keysym.sym, ((keyBindings != NULL)? keyBindings->GetFakeMetaKey(): -1)); if (activeController) { - activeController->KeyReleased(keyInput->GetNormalizedKeySymbol(event.key.keysym.sym)); + if (activeController->ignoreNextChar) { + activeController->ignoreNextChar = false; + } + activeController->KeyReleased(KeyInput::GetNormalizedKeySymbol(event.key.keysym.sym)); } - break; - } - default: - break; - } + } break; + }; return false; } diff -Nru spring-96.0~14.04~ppa4/rts/System/SpringApp.h spring-98.0~14.04~ppa6/rts/System/SpringApp.h --- spring-96.0~14.04~ppa4/rts/System/SpringApp.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/SpringApp.h 2014-10-07 20:09:51.000000000 +0000 @@ -5,7 +5,10 @@ #include #include +#include + +class ClientSetup; class CmdLineParams; class CGameController; union SDL_Event; @@ -31,13 +34,12 @@ bool InitWindow(const char* title); //!< Initializes window static void InitOpenGL(); //!< Initializes OpenGL static void LoadFonts(); //!< Initialize glFonts (font & smallFont) - static bool SetSDLVideoMode(); //!< Sets SDL video mode + static bool CreateSDLWindow(const char* title); //!< Creates a SDL window int Update(); //!< Run simulation and draw bool UpdateSim(CGameController *ac); - static bool GetDisplayGeometry(); - static void SetupViewportGeometry(bool windowExposed); - static void RestoreWindowPosition(); + static void GetDisplayGeometry(); + static void SetupViewportGeometry(); static void SaveWindowPosition(); /** @@ -49,7 +51,7 @@ private: bool MainEventHandler(const SDL_Event& ev); - void RunScript(const std::string& buf); + void RunScript(boost::shared_ptr clientSetup, const std::string& buf); }; /** diff -Nru spring-96.0~14.04~ppa4/rts/System/StartScriptGen.cpp spring-98.0~14.04~ppa6/rts/System/StartScriptGen.cpp --- spring-96.0~14.04~ppa4/rts/System/StartScriptGen.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/StartScriptGen.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -8,6 +8,8 @@ #include "System/Util.h" #include "System/Config/ConfigHandler.h" #include "System/FileSystem/ArchiveScanner.h" +#include "System/UriParser.h" +#include "System/FileSystem/RapidHandler.h" #include "System/Log/ILog.h" #include @@ -188,6 +190,14 @@ return false; } + static bool GetGameByRapidTag(const std::string& lazyName, std::string& tag) + { + if (!ParseRapidUri(lazyName, tag)) + return false; + tag = GetRapidName(tag); + return !tag.empty(); + } + static std::string GetGame(const std::string& lazyName) { @@ -195,7 +205,7 @@ if (GetGameByExactName(lazyName, &applicableName)) return applicableName; if (GetGameByShortName(lazyName, &applicableName)) return applicableName; if (GetRandomGame(lazyName, &applicableName)) return applicableName; - //TODO add rapid tags support, e.g. `s44:test` + if (GetGameByRapidTag(lazyName, applicableName)) return applicableName; return lazyName; } @@ -232,7 +242,6 @@ modopts->AddPair("MinimalSetup", 1); //use for ingame detecting this type of start g->AddPair("IsHost", 1); - g->AddPair("OnlyLocal", 1); g->add_name_value("MyPlayerName", playername); TdfParser::TdfSection* player0 = g->construct_subsection("PLAYER0"); @@ -267,7 +276,6 @@ modopts->AddPair("MaxSpeed", 20); g->AddPair("IsHost", 1); - g->AddPair("OnlyLocal", 1); g->add_name_value("MyPlayerName", playername); g->AddPair("NoHelperAIs", configHandler->GetBool("NoHelperAIs")); @@ -321,4 +329,4 @@ return str.str(); } -}; //namespace StartScriptGen +} //namespace StartScriptGen diff -Nru spring-96.0~14.04~ppa4/rts/System/StartScriptGen.h spring-98.0~14.04~ppa6/rts/System/StartScriptGen.h --- spring-96.0~14.04~ppa4/rts/System/StartScriptGen.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/StartScriptGen.h 2014-10-07 20:09:51.000000000 +0000 @@ -19,4 +19,4 @@ * @param playername name to use ingame */ std::string CreateDefaultSetup(const std::string& map, const std::string& game, const std::string& ai, const std::string& playername); -}; +} diff -Nru spring-96.0~14.04~ppa4/rts/System/Sync/FPUCheck.cpp spring-98.0~14.04~ppa6/rts/System/Sync/FPUCheck.cpp --- spring-96.0~14.04~ppa4/rts/System/Sync/FPUCheck.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sync/FPUCheck.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -5,16 +5,11 @@ #endif #include "FPUCheck.h" -#include #include "lib/streflop/streflop_cond.h" #include "System/Exceptions.h" #include "System/ThreadPool.h" #include "System/Log/ILog.h" -#include "System/Platform/Threading.h" - -#ifdef _MSC_VER -#include -#endif +#include "System/Platform/CpuID.h" #ifdef STREFLOP_H #ifdef STREFLOP_SSE @@ -193,56 +188,6 @@ } namespace springproc { - #if defined(__GNUC__) - // function inlining breaks this - __attribute__((__noinline__)) - void ExecCPUID(unsigned int* a, unsigned int* b, unsigned int* c, unsigned int* d) - { - #ifndef __APPLE__ - __asm__ __volatile__( - "cpuid" - : "=a" (*a), "=b" (*b), "=c" (*c), "=d" (*d) - : "0" (*a) - ); - #else - #ifdef __x86_64__ - __asm__ __volatile__( - "pushq %%rbx\n\t" - "cpuid\n\t" - "movl %%ebx, %1\n\t" - "popq %%rbx" - : "=a" (*a), "=r" (*b), "=c" (*c), "=d" (*d) - : "0" (*a) - ); - #else - __asm__ __volatile__( - "pushl %%ebx\n\t" - "cpuid\n\t" - "movl %%ebx, %1\n\t" - "popl %%ebx" - : "=a" (*a), "=r" (*b), "=c" (*c), "=d" (*d) - : "0" (*a) - ); - #endif - #endif - } - #elif defined(_MSC_VER) && (_MSC_VER >= 1310) - void ExecCPUID(unsigned int* a, unsigned int* b, unsigned int* c, unsigned int* d) - { - int features[4]; - __cpuid(features, *a); - *a=features[0]; - *b=features[1]; - *c=features[2]; - *d=features[3]; - } - #else - // no-op on other compilers - void ExecCPUID(unsigned int* a, unsigned int* b, unsigned int* c, unsigned int* d) - { - } - #endif - unsigned int GetProcMaxStandardLevel() { unsigned int rEAX = 0x00000000; diff -Nru spring-96.0~14.04~ppa4/rts/System/Sync/FPUCheck.h spring-98.0~14.04~ppa6/rts/System/Sync/FPUCheck.h --- spring-96.0~14.04~ppa4/rts/System/Sync/FPUCheck.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sync/FPUCheck.h 2014-10-07 20:09:51.000000000 +0000 @@ -15,15 +15,7 @@ extern void good_fpu_init(); extern void streflop_init_omp(); -#if defined(__GNUC__) - #define _noinline __attribute__((__noinline__)) -#else - #define _noinline -#endif - namespace springproc { - _noinline void ExecCPUID(unsigned int* a, unsigned int* b, unsigned int* c, unsigned int* d); - unsigned int GetProcMaxStandardLevel(); unsigned int GetProcMaxExtendedLevel(); unsigned int GetProcSSEBits(); diff -Nru spring-96.0~14.04~ppa4/rts/System/Sync/SyncedFloat3.cpp spring-98.0~14.04~ppa6/rts/System/Sync/SyncedFloat3.cpp --- spring-96.0~14.04~ppa4/rts/System/Sync/SyncedFloat3.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sync/SyncedFloat3.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -5,8 +5,8 @@ #if defined(SYNCDEBUG) || defined(SYNCCHECK) -CR_BIND(SyncedFloat3, ); -CR_REG_METADATA(SyncedFloat3, (CR_MEMBER(x), CR_MEMBER(y), CR_MEMBER(z))); +CR_BIND(SyncedFloat3, ) +CR_REG_METADATA(SyncedFloat3, (CR_MEMBER(x), CR_MEMBER(y), CR_MEMBER(z))) bool SyncedFloat3::IsInBounds() const diff -Nru spring-96.0~14.04~ppa4/rts/System/Sync/SyncedFloat3.h spring-98.0~14.04~ppa6/rts/System/Sync/SyncedFloat3.h --- spring-96.0~14.04~ppa4/rts/System/Sync/SyncedFloat3.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sync/SyncedFloat3.h 2014-10-07 20:09:51.000000000 +0000 @@ -23,7 +23,7 @@ { public: // value type -> _STRUCT (because no virtual dtor or vtable is required) - CR_DECLARE_STRUCT(SyncedFloat3); + CR_DECLARE_STRUCT(SyncedFloat3) /** * @brief Constructor diff -Nru spring-96.0~14.04~ppa4/rts/System/Sync/Upcast.h spring-98.0~14.04~ppa6/rts/System/Sync/Upcast.h --- spring-96.0~14.04~ppa4/rts/System/Sync/Upcast.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Sync/Upcast.h 2014-10-07 20:09:51.000000000 +0000 @@ -71,6 +71,6 @@ #define UPCAST(U, V) \ typename upcast::Upcast< U, V >::type -}; +} #endif // UPCAST_H diff -Nru spring-96.0~14.04~ppa4/rts/System/ThreadPool.cpp spring-98.0~14.04~ppa6/rts/System/ThreadPool.cpp --- spring-96.0~14.04~ppa4/rts/System/ThreadPool.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/ThreadPool.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -56,7 +56,7 @@ int GetMaxThreads() { - return Threading::GetAvailableCores(); + return Threading::GetPhysicalCpuCores(); } int GetNumThreads() @@ -136,12 +136,11 @@ static bool DoTask(std::shared_ptr tg) { auto p = tg->GetTask(); - const bool f = p; - if (f) { + if (p) { SCOPED_MT_TIMER("::ThreadWorkers (accumulated)"); (*p)(); } - return f; + return static_cast(p); } @@ -207,8 +206,8 @@ void SetThreadCount(int num) { int curThreads = ThreadPool::GetNumThreads(); - - LOG("[ThreadPool::%s][1] #wanted=%d #current=%d", __FUNCTION__, num, curThreads); + LOG("[ThreadPool::%s][1] #wanted=%d #current=%d #max=%d", __FUNCTION__, num, curThreads, ThreadPool::GetMaxThreads()); + num = std::min(num, ThreadPool::GetMaxThreads()); if (curThreads < num) { #ifndef UNITSYNC @@ -265,7 +264,7 @@ spinlockMs = milliSeconds; } -}; +} #endif diff -Nru spring-96.0~14.04~ppa4/rts/System/ThreadPool.h spring-98.0~14.04~ppa6/rts/System/ThreadPool.h --- spring-96.0~14.04~ppa4/rts/System/ThreadPool.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/ThreadPool.h 2014-10-07 20:09:51.000000000 +0000 @@ -19,7 +19,7 @@ static inline int GetMaxThreads() { return 1; } static inline int GetNumThreads() { return 1; } static inline void NotifyWorkerThreads() {} -}; +} static inline void for_mt(int start, int end, int step, const std::function&& f) @@ -118,7 +118,7 @@ int GetMaxThreads(); int GetNumThreads(); void NotifyWorkerThreads(); -}; +} template @@ -378,7 +378,7 @@ ThreadPool::PushTaskGroup(singletask); return singletask->GetFuture(); } -}; +} #endif #endif diff -Nru spring-96.0~14.04~ppa4/rts/System/TimeProfiler.cpp spring-98.0~14.04~ppa6/rts/System/TimeProfiler.cpp --- spring-96.0~14.04~ppa4/rts/System/TimeProfiler.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/TimeProfiler.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -7,7 +7,6 @@ #include #include -#include "lib/gml/gmlmut.h" #include "System/Log/ILog.h" #include "System/UnsyncedRNG.h" #ifdef THREADPOOL @@ -110,7 +109,7 @@ ScopedOnceTimer::~ScopedOnceTimer() { - LOG("%s: %lli ms", GetName().c_str(), spring_diffmsecs(spring_gettime(), starttime)); + LOG("%s: %i ms", GetName().c_str(), int(spring_diffmsecs(spring_gettime(), starttime))); } diff -Nru spring-96.0~14.04~ppa4/rts/System/type2.cpp spring-98.0~14.04~ppa6/rts/System/type2.cpp --- spring-96.0~14.04~ppa4/rts/System/type2.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/type2.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -3,8 +3,8 @@ #include "System/type2.h" #include "System/creg/creg_cond.h" -CR_BIND_TEMPLATE(int2, ); -CR_REG_METADATA(int2, (CR_MEMBER(x), CR_MEMBER(y))); +CR_BIND_TEMPLATE(int2, ) +CR_REG_METADATA(int2, (CR_MEMBER(x), CR_MEMBER(y))) -CR_BIND_TEMPLATE(float2, ); -CR_REG_METADATA(float2, (CR_MEMBER(x), CR_MEMBER(y))); +CR_BIND_TEMPLATE(float2, ) +CR_REG_METADATA(float2, (CR_MEMBER(x), CR_MEMBER(y))) diff -Nru spring-96.0~14.04~ppa4/rts/System/type2.h spring-98.0~14.04~ppa6/rts/System/type2.h --- spring-96.0~14.04~ppa4/rts/System/type2.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/type2.h 2014-10-07 20:09:51.000000000 +0000 @@ -8,19 +8,26 @@ #include "System/FastMath.h" template struct type2 { - CR_DECLARE_STRUCT(type2); + CR_DECLARE_STRUCT(type2) type2(): x(t(0)), y(t(0)) {} type2(const t nx, const t ny) : x(nx), y(ny) {} bool operator == (const type2& v) const { return (x == v.x) && (y == v.y); } bool operator != (const type2& v) const { return (x != v.x) || (y != v.y); } + bool operator < (const type2& f) const { return (x != f.x) ? (x < f.x) : (y < f.y); } - type2& operator += (const type2& v) { - x += v.x; - y += v.y; - return *this; - } + type2 operator + (const type2& v) const { return (type2(x + v.x, y + v.y)); } + type2 operator - (const type2& v) const { return (type2(x - v.x, y - v.y)); } + type2 operator / (const type2& v) const { return (type2(x / v.x, y / v.y)); } + type2 operator / (const t& i) const { return (type2(x / i , y / i )); } + type2 operator * (const type2& v) const { return (type2(x * v.x, y * v.y)); } + type2 operator * (const t& i) const { return (type2(x * i , y * i )); } + + type2& operator += (const type2& v) { x += v.x; y += v.y; return *this; } + type2& operator -= (const type2& v) { x -= v.x; y -= v.y; return *this; } + type2& operator *= (const t& i) { x *= i; y *= i; return *this; } + type2& operator /= (const t& i) { x /= i; y /= i; return *this; } t distance(const type2& f) const { const t dx = x - f.x; diff -Nru spring-96.0~14.04~ppa4/rts/System/UnsyncedRNG.cpp spring-98.0~14.04~ppa6/rts/System/UnsyncedRNG.cpp --- spring-96.0~14.04~ppa4/rts/System/UnsyncedRNG.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/UnsyncedRNG.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -5,38 +5,34 @@ #include -// like 5-6x slower than our, but much better distribution -//#define USE_BOOST_RNG + +UnsyncedRNG::UnsyncedRNG() +: randSeed(0) #ifdef USE_BOOST_RNG - #include - #include - #include - #include - #include - - static boost::random::mt19937 rng; - //static boost::random::mt11213b rng; - static boost::random::uniform_01 dist01; - static boost::random::uniform_smallint distInt(0, RANDINT_MAX); - static boost::random::uniform_on_sphere distSphere(3); - static boost::variate_generator > gen01(rng, dist01); - static boost::variate_generator > genInt(rng, distInt); - static boost::variate_generator > genSphere(rng, distSphere); +, distInt(0, RANDINT_MAX) +, distSphere(3) +, gen01(rng, dist01) +, genInt(rng, distInt) +, genSphere(rng, distSphere) #endif +{ +} -UnsyncedRNG::UnsyncedRNG() : randSeed(0) -{ +void UnsyncedRNG::operator=(const UnsyncedRNG& urng) +{ + randSeed = urng.randSeed; + Seed(randSeed); } + void UnsyncedRNG::Seed(unsigned seed) { + randSeed = seed; #ifdef USE_BOOST_RNG rng.seed(seed); -#else - randSeed = seed; #endif } @@ -76,6 +72,17 @@ return ret; } + +float3 UnsyncedRNG::RandVector2D() +{ + float3 ret; + do { + ret.x = RandFloat() * 2 - 1; + ret.z = RandFloat() * 2 - 1; + } while (ret.SqLength() > 1); + + return ret; +} int UnsyncedRNG::operator()(int n) { diff -Nru spring-96.0~14.04~ppa4/rts/System/UnsyncedRNG.h spring-98.0~14.04~ppa6/rts/System/UnsyncedRNG.h --- spring-96.0~14.04~ppa4/rts/System/UnsyncedRNG.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/UnsyncedRNG.h 2014-10-07 20:09:51.000000000 +0000 @@ -5,6 +5,17 @@ #include "System/float3.h" +// like 5-6x slower than our, but much better distribution +//#define USE_BOOST_RNG +#ifdef USE_BOOST_RNG + #include + #include + #include + #include + #include +#endif + + class UnsyncedRNG { public: @@ -22,12 +33,24 @@ /** @brief returns a random vector with length [0, 1] */ float3 RandVector(); + float3 RandVector2D(); /** @brief returns a random number in the range [0, n) */ int operator()(int n); + void operator=(const UnsyncedRNG& urng); private: unsigned randSeed; + +#ifdef USE_BOOST_RNG + boost::random::mt19937 rng; + boost::random::uniform_01 dist01; + boost::random::uniform_smallint distInt; + boost::random::uniform_on_sphere distSphere; + boost::variate_generator > gen01; + boost::variate_generator > genInt; + boost::variate_generator > genSphere; +#endif }; #endif // UNSYNCEDRNG_H_ diff -Nru spring-96.0~14.04~ppa4/rts/System/UriParser.cpp spring-98.0~14.04~ppa6/rts/System/UriParser.cpp --- spring-96.0~14.04~ppa4/rts/System/UriParser.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/UriParser.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,49 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include "UriParser.h" +#include "Util.h" + +static void SplitString(const std::string& text, const char* sepChar, std::string& s1, std::string& s2, std::string& all) +{ + const size_t q = text.find(sepChar); + if (q != std::string::npos) { + s1 = text.substr(0, q); + s2 = text.substr(q + 1); + return; + } + all = text; +} + +bool ParseSpringUri(const std::string& uri, std::string& username, std::string& password, std::string& host, int& port) +{ + // see http://cpp-netlib.org/0.10.1/in_depth/uri.html (2014) + if (uri.find("spring://") == std::string::npos) + return false; // wrong scheme + + const std::string full = uri.substr(std::string("spring://").length()); + std::string authority, query, user_info, server, portStr; + bool error = false; + SplitString(full, "/", authority, query, authority); + SplitString(authority, "@", user_info, server, server); + SplitString(user_info, ":", username, password, username); + SplitString(server, ":", host, portStr, host); + if (portStr.empty()) + return true; + port = StringToInt(portStr, &error); + if (error) { + port = 0; + return false; + } + //FIXME pass query + return true; +} + +bool ParseRapidUri(const std::string& uri, std::string& tag) +{ + if (uri.find("rapid://") == std::string::npos) { + return false; // wrong scheme + } + tag = uri.substr(std::string("rapid://").length()); + return !tag.empty(); +} + diff -Nru spring-96.0~14.04~ppa4/rts/System/UriParser.h spring-98.0~14.04~ppa6/rts/System/UriParser.h --- spring-96.0~14.04~ppa4/rts/System/UriParser.h 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/UriParser.h 2014-10-07 20:09:51.000000000 +0000 @@ -0,0 +1,10 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include + +// url (syntax: spring://username:password@host:port) +bool ParseSpringUri(const std::string& uri, std::string& username, std::string& password, std::string& host, int& port); + +// url (syntax: rapid://ba:stable) +bool ParseRapidUri(const std::string& uri, std::string& tag); + diff -Nru spring-96.0~14.04~ppa4/rts/System/Util.cpp spring-98.0~14.04~ppa6/rts/System/Util.cpp --- spring-96.0~14.04~ppa4/rts/System/Util.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Util.cpp 2014-10-07 20:09:51.000000000 +0000 @@ -2,10 +2,11 @@ #include "System/Util.h" #if defined(_MSC_VER) && (_MSC_VER >= 1310) -#include + #include #endif #include + std::string StringReplace(const std::string& text, const std::string& from, const std::string& to) @@ -106,3 +107,148 @@ return (str.compare(str.size() - strlen(postfix), str.size(), postfix) == 0); } } + + +void InverseOrSetBool(bool& container, const std::string& argValue, const bool inverseArg) +{ + if (argValue.empty()) { + // toggle + container = !container; + } else { + // set + const bool value = StringToBool(argValue); + container = inverseArg ? (!value) : (value); + } +} + + + +static inline unsigned count_leading_ones(uint8_t x) +{ + uint32_t i = ~x; + return __builtin_clz((i<<24) | 0x00FFFFFF); +} + + +char32_t Utf8GetNextChar(const std::string& text, int& pos) +{ + // UTF8 looks like this + // 1Byte == ASCII: 0xxxxxxxxx + // 2Bytes encoded char: 110xxxxxxx 10xxxxxx + // 3Bytes encoded char: 1110xxxxxx 10xxxxxx 10xxxxxx + // 4Bytes encoded char: 11110xxxxx 10xxxxxx 10xxxxxx 10xxxxxx + // Originaly there were 5&6 byte versions too, but they were dropped in RFC 3629. + // So UTF8 maps to UTF16 range only. + + static const auto UTF8_CONT_MASK = 0xC0; // 11xxxxxx + static const auto UTF8_CONT_OKAY = 0x80; // 10xxxxxx + + union UTF8_4Byte { + uint32_t i; + uint8_t c[4]; + }; + + // read next 4bytes and check if it is an utf8 sequence + UTF8_4Byte utf8 = { 0 }; + const int remainingChars = text.length() - pos; + if (remainingChars >= 4) { + utf8.i = *(uint32_t*)(&text[pos]); + } else { + // read ahead of end of string + if (remainingChars <= 0) + return 0; + + // end of string reached, only read till end + switch (remainingChars) { + case 3: utf8.c[2] = uint8_t(text[pos + 2]); + case 2: utf8.c[1] = uint8_t(text[pos + 1]); + case 1: utf8.c[0] = uint8_t(text[pos ]); + }; + } + + // how many bytes are requested for our multi-byte utf8 sequence + unsigned clo = count_leading_ones(utf8.c[0]); + if (clo>4 || clo==0) clo = 1; // ignore >=5 byte ones cause of RFC 3629 + + // how many healthy utf8 bytes are following + unsigned numValidUtf8Bytes = 1; // first char is always valid + numValidUtf8Bytes += int((utf8.c[1] & UTF8_CONT_MASK) == UTF8_CONT_OKAY); + numValidUtf8Bytes += int((utf8.c[2] & UTF8_CONT_MASK) == UTF8_CONT_OKAY); + numValidUtf8Bytes += int((utf8.c[3] & UTF8_CONT_MASK) == UTF8_CONT_OKAY); + + // check if enough trailing utf8 bytes are healthy + // else ignore utf8 and parse it as 8bit Latin-1 char (extended ASCII) + // this adds backwardcompatibility with the old renderer + // which supported extended ASCII with umlauts etc. + const auto usedUtf8Bytes = (clo <= numValidUtf8Bytes) ? clo : 1u; + + char32_t u = 0; + switch (usedUtf8Bytes) { + case 0: + case 1: { + u = utf8.c[0]; + } break; + case 2: { + u = (char32_t(utf8.c[0] & 0x1F)) << 6; + u |= (char32_t(utf8.c[1] & 0x3F)); + } break; + case 3: { + u = (char32_t(utf8.c[0] & 0x0F)) << 12; + u |= (char32_t(utf8.c[1] & 0x3F)) << 6; + u |= (char32_t(utf8.c[2] & 0x3F)); + } break; + case 4: { + u = (char32_t(utf8.c[0] & 0x07)) << 18; + u |= (char32_t(utf8.c[1] & 0x3F)) << 12; + u |= (char32_t(utf8.c[2] & 0x3F)) << 6; + u |= (char32_t(utf8.c[3] & 0x3F)); + //TODO limit range to UTF16! + } break; + } + pos += usedUtf8Bytes; + + // replace tabs with spaces + if (u == 0x9) + u = 0x2007; + + return u; +} + + +std::string UnicodeToUtf8(char32_t ch) +{ + std::string str; + + // in: 0000 0000 0000 0000 0000 0000 0aaa aaaa + // out: 0aaa aaaa + if(ch<(1<<7)) + { + str += (char)ch; + } + // in: 0000 0000 0000 0000 0000 0bbb bbaa aaaa + // out: 110b bbbb 10aa aaaa + else if(ch<(1<<11)) + { + str += 0xC0 | (char)(ch>>6); + str += 0x80 | (char)(ch&0x3F); + } + // in: 0000 0000 0000 0000 cccc bbbb bbaa aaaa + // out: 1110 cccc 10bb bbbb 10aa aaaa + else if(ch<(1<<16)) + { + str += 0xE0 | (char)(ch>>12); + str += 0x80 | (char)((ch>>6)&0x3F); + str += 0x80 | (char)(ch&0x3F); + } + // in: 0000 0000 000d ddcc cccc bbbb bbaa aaaa + // out: 1111 0ddd 10cc cccc 10bb bbbb 10aa aaaa + else if(ch<(1<<21)) + { + str += 0xF0 | (char)(ch>>18); + str += 0x80 | (char)((ch>>12)&0x3F); + str += 0x80 | (char)((ch>>6)&0x3F); + str += 0x80 | (char)(ch&0x3F); + } + + return str; +} diff -Nru spring-96.0~14.04~ppa4/rts/System/Util.h spring-98.0~14.04~ppa6/rts/System/Util.h --- spring-96.0~14.04~ppa4/rts/System/Util.h 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/rts/System/Util.h 2014-10-07 20:09:51.000000000 +0000 @@ -120,11 +120,12 @@ return std::string(buf); } -static inline int StringToInt(std::string str, bool* failed = NULL) +template +static inline int_type StringToInt(std::string str, bool* failed = NULL) { StringTrimInPlace(str); std::istringstream stream(str); - int buffer = 0; + int_type buffer = 0; stream >> buffer; if (failed != NULL) @@ -153,6 +154,26 @@ return StringEndsWith(str, postfix.c_str()); } + +/// Appends postfix, when it doesn't already ends with it +static inline void EnsureEndsWith(std::string* str, const char* postfix) +{ + if (!StringEndsWith(*str, postfix)) { + *str += postfix; + } +} + + +/** + * Sets a bool according to the value encoded in a string. + * The conversion works like this: + * - "" -> toggle-value + * - "0" -> false + * - "1" -> true + */ +void InverseOrSetBool(bool& container, const std::string& argValue, const bool inverseArg = false); + + /// Helper function to avoid division by Zero static inline float SafeDivide(const float a, const float b) { @@ -276,4 +297,33 @@ }; + + +char32_t Utf8GetNextChar(const std::string& text, int& pos); +std::string UnicodeToUtf8(char32_t ch); + + +static inline int Utf8CharLen(const std::string& str, int pos) +{ + const auto oldPos = pos; + Utf8GetNextChar(str, pos); + return pos - oldPos; +} + +static inline int Utf8NextChar(const std::string& str, int pos) +{ + Utf8GetNextChar(str, pos); + return pos; +} + +static inline int Utf8PrevChar(const std::string& str, int pos) +{ + int startPos = std::max(pos - 4, 0); + int oldPos = startPos; + while (startPos < pos) { + oldPos = startPos; + Utf8GetNextChar(str, startPos); + } + return oldPos; +} #endif // UTIL_H diff -Nru spring-96.0~14.04~ppa4/test/CMakeLists.txt spring-98.0~14.04~ppa6/test/CMakeLists.txt --- spring-96.0~14.04~ppa4/test/CMakeLists.txt 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/test/CMakeLists.txt 2014-10-07 20:09:52.000000000 +0000 @@ -237,6 +237,7 @@ ${Boost_REGEX_LIBRARY} ) add_spring_test(${test_name} "${test_src}" "${test_libs}" "") + add_dependencies(test_${test_name} generateVersionFiles) ################################################################################ ### LuaSocketRestrictions set(test_name LuaSocketRestrictions) @@ -256,8 +257,6 @@ ################################################################################ ### CREG add_test(NAME testCreg COMMAND ${CMAKE_BINARY_DIR}/spring-headless${CMAKE_EXECUTABLE_SUFFIX} --test-creg) - add_dependencies(tests testCreg) - add_dependencies(tests engine-headless) ################################################################################ ### CREG LoadSave @@ -276,6 +275,7 @@ ) add_spring_test(${test_name} "${test_src}" "${test_libs}" -"DTEST") + ################################################################################ ### UnitSync set(test_name UnitSync) @@ -292,6 +292,7 @@ add_spring_test(${test_name} "${test_src}" "${test_libs}" "") add_dependencies(test_${test_name} springcontent.sdz) + ################################################################################ ### ThreadPool set(test_name ThreadPool) @@ -299,8 +300,9 @@ "${CMAKE_CURRENT_SOURCE_DIR}/engine/System/testThreadPool.cpp" "${ENGINE_SOURCE_DIR}/System/ThreadPool.cpp" "${ENGINE_SOURCE_DIR}/System/Misc/SpringTime.cpp" - "${ENGINE_SOURCE_DIR}/System/Platform/Threading.cpp" "${ENGINE_SOURCE_DIR}/System/UnsyncedRNG.cpp" + "${ENGINE_SOURCE_DIR}/System/Platform/CpuID.cpp" + "${ENGINE_SOURCE_DIR}/System/Platform/Threading.cpp" ${test_Log_sources} ) set(test_libs @@ -310,7 +312,22 @@ ${Boost_SYSTEM_LIBRARY} ${WINMM_LIBRARY} ) +if(NOT WIN32) +# FIXME: sometimes fails on windows add_spring_test(${test_name} "${test_src}" "${test_libs}" "-DTHREADPOOL -DUNITSYNC") +endif() + +################################################################################ +### EventClient + set(test_name EventClient) + Set(test_src + "${CMAKE_CURRENT_SOURCE_DIR}/engine/System/EventClient.cpp" + ${test_Log_sources} + ) + set(test_libs + ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} + ) + add_spring_test(${test_name} "${test_src}" "${test_libs}" "") ################################################################################ EndIf (NOT Boost_FOUND) diff -Nru spring-96.0~14.04~ppa4/test/engine/System/EventClient.cpp spring-98.0~14.04~ppa6/test/engine/System/EventClient.cpp --- spring-96.0~14.04~ppa4/test/engine/System/EventClient.cpp 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/test/engine/System/EventClient.cpp 2014-10-07 20:09:52.000000000 +0000 @@ -0,0 +1,39 @@ +/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ + +#include +#include + +#define BOOST_TEST_MODULE EventClient +#include + + +class A +{ +public: + virtual void Foo() {} +}; + + + +class B : public A +{ +public: + void Foo() {} +}; + + +BOOST_AUTO_TEST_CASE( EventClient ) +{ + // Checks Pointer-to-Member-Functions (PMF) + // used by CEventClient to detect if a virtual function is overriden + // and so if the derived class wants the event + + //BOOST_CHECK(&A::Foo == &B::Foo); // undefined for virtual methods + + // old way using gcc's pmf casting extension (illegal in iso c++) + //BOOST_CHECK(reinterpret_cast(&A::Foo) != reinterpret_cast(&B::Foo)); + + // new way should work everywhere + BOOST_CHECK(typeid(&A::Foo) != typeid(&B::Foo)); + BOOST_CHECK(typeid(&A::Foo) == typeid(&A::Foo)); +} diff -Nru spring-96.0~14.04~ppa4/test/engine/System/Log/TestILog.cpp spring-98.0~14.04~ppa6/test/engine/System/Log/TestILog.cpp --- spring-96.0~14.04~ppa4/test/engine/System/Log/TestILog.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/test/engine/System/Log/TestILog.cpp 2014-10-07 20:09:52.000000000 +0000 @@ -151,12 +151,13 @@ { // do NOT add braces here, as that would invalidate the test! int x = 0; - if (x == 0) + if (x == 0) { LOG("(IsSingleInstruction) Test"); - else if (x == 1) + } else if (x == 1) { LOG("(IsSingleInstruction) if"); - else + } else { LOG("(IsSingleInstruction) LOG() is a single instruction."); + } TLOG("(IsSingleInstruction) Test"); } diff -Nru spring-96.0~14.04~ppa4/test/engine/System/Misc/testSpringTime.cpp spring-98.0~14.04~ppa6/test/engine/System/Misc/testSpringTime.cpp --- spring-96.0~14.04~ppa4/test/engine/System/Misc/testSpringTime.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/test/engine/System/Misc/testSpringTime.cpp 2014-10-07 20:09:52.000000000 +0000 @@ -193,7 +193,11 @@ float springAvg = TestProcessor::Run(); bestAvg = std::min(bestAvg, springAvg); - BOOST_CHECK( std::abs(springAvg - bestAvg) < 3.f * bestAvg ); + + const float diff = std::abs(springAvg - bestAvg); + if (diff >= 3.0f * bestAvg) { + LOG_L(L_ERROR, "Clockquality is bad: %f, running inside a VM?", diff); + } // check min precision range diff -Nru spring-96.0~14.04~ppa4/test/engine/System/Net/TestUDPListener.cpp spring-98.0~14.04~ppa6/test/engine/System/Net/TestUDPListener.cpp --- spring-96.0~14.04~ppa4/test/engine/System/Net/TestUDPListener.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/test/engine/System/Net/TestUDPListener.cpp 2014-10-07 20:09:52.000000000 +0000 @@ -5,11 +5,11 @@ #include static inline bool TryBindAddr(netcode::SocketPtr& socket, const char* address) { - return netcode::UDPListener::TryBindSocket(11111, &socket, address); + return netcode::UDPListener::TryBindSocket(11111, &socket, address).empty(); } static inline bool TryBindPort(netcode::SocketPtr& socket, int port) { - return netcode::UDPListener::TryBindSocket(port, &socket, "::"); + return netcode::UDPListener::TryBindSocket(port, &socket, "::").empty(); } BOOST_AUTO_TEST_CASE(TryBindSocket) @@ -40,8 +40,8 @@ BOOST_CHECK(!TryBindAddr(socket, "fe80")); - // host-names (only addresses are allowed) - BOOST_CHECK(!TryBindAddr(socket, "localhost")); + // host-names + BOOST_CHECK(TryBindAddr(socket, "localhost")); BOOST_CHECK(!TryBindAddr(socket, "local.lan")); BOOST_CHECK(!TryBindAddr(socket, "google.com")); diff -Nru spring-96.0~14.04~ppa4/test/engine/System/NullGlobalConfig.cpp spring-98.0~14.04~ppa6/test/engine/System/NullGlobalConfig.cpp --- spring-96.0~14.04~ppa4/test/engine/System/NullGlobalConfig.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/test/engine/System/NullGlobalConfig.cpp 2014-10-07 20:09:52.000000000 +0000 @@ -28,6 +28,9 @@ if ((linkIncomingMaxPacketRate > 0) && (linkIncomingSustainedBandwidth <= 0)) { linkIncomingSustainedBandwidth = linkIncomingPeakBandwidth = 1024 * 1024; } + useNetMessageSmoothingBuffer = true; + luaWritableConfigFile = false; + networkLossFactor = 0; } void GlobalConfig::Instantiate() { diff -Nru spring-96.0~14.04~ppa4/test/engine/System/testThreadPool.cpp spring-98.0~14.04~ppa6/test/engine/System/testThreadPool.cpp --- spring-96.0~14.04~ppa4/test/engine/System/testThreadPool.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/test/engine/System/testThreadPool.cpp 2014-10-07 20:09:52.000000000 +0000 @@ -7,7 +7,7 @@ #define BOOST_TEST_MODULE ThreadPool #include -#define NUM_THREADS 10 +static int NUM_THREADS = std::min(ThreadPool::GetMaxThreads(), 10); // !!! BOOST.TEST IS NOT THREADSAFE !!! (facepalms) #define SAFE_BOOST_CHECK( P ) do { boost::lock_guard _(m); BOOST_CHECK( ( P ) ); } while( 0 ); diff -Nru spring-96.0~14.04~ppa4/test/headercheck/CMakeLists.txt spring-98.0~14.04~ppa6/test/headercheck/CMakeLists.txt --- spring-96.0~14.04~ppa4/test/headercheck/CMakeLists.txt 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/test/headercheck/CMakeLists.txt 2014-10-07 20:09:52.000000000 +0000 @@ -7,7 +7,7 @@ ${Spring_SOURCE_DIR}/include ${Spring_SOURCE_DIR}/rts/lib ${Spring_SOURCE_DIR}/rts/lib/lua/include - ${SDL_INCLUDE_DIR} + ${SDL2_INCLUDE_DIR} ${OPENAL_INCLUDE_DIR} ) diff -Nru spring-96.0~14.04~ppa4/test/lib/luasocket/TestRestriction.cpp spring-98.0~14.04~ppa6/test/lib/luasocket/TestRestriction.cpp --- spring-96.0~14.04~ppa4/test/lib/luasocket/TestRestriction.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/test/lib/luasocket/TestRestriction.cpp 2014-10-07 20:09:52.000000000 +0000 @@ -10,14 +10,9 @@ BOOST_AUTO_TEST_CASE(TestRestriction) { CLuaSocketRestrictions rest = CLuaSocketRestrictions(); - #define CheckAccess(result, rules, host, port) \ - BOOST_CHECK(rest.isAllowed((CLuaSocketRestrictions::RestrictType)rules, host, port) == result); - #define AllowAccess(valid, rules, host, port) \ - if ( i == valid) { \ - CheckAccess(true, rules, host, port); \ - } else { \ - CheckAccess(false, rules, host, port); \ - } + #define CheckAccess(result, type, host, port) \ + BOOST_CHECK((result == rest.isAllowed((CLuaSocketRestrictions::RestrictType)type, host, port))); + for(int i=0; i1 and args[1] == "NEWFRAME": + if count>400: + print("%s %s" % (args[0], count)) + count = 0 + sumframes = 0 + elif len(args) == 6 and args[1] == "NETMSG_PAUSE:": # filter pause + #000009 NETMSG_PAUSE: Player 8 paused: 1 + count = 0 + paused = (args[5] == "1") + #print("paused: " + str(paused)) + elif not paused: + count = count + 1 + diff -Nru spring-96.0~14.04~ppa4/tools/DemoTool/DemoTool.cpp spring-98.0~14.04~ppa6/tools/DemoTool/DemoTool.cpp --- spring-96.0~14.04~ppa4/tools/DemoTool/DemoTool.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/DemoTool/DemoTool.cpp 2014-10-07 20:09:52.000000000 +0000 @@ -3,6 +3,7 @@ #include #include #include +#include //hex #include "StringSerializer.h" @@ -171,7 +172,6 @@ REGISTER_CMD(CMD_RESURRECT) REGISTER_CMD(CMD_CAPTURE) REGISTER_CMD(CMD_AUTOREPAIRLEVEL) - REGISTER_CMD(CMD_LOOPBACKATTACK) REGISTER_CMD(CMD_IDLEMODE) REGISTER_CMD(CMD_FAILED) @@ -195,6 +195,14 @@ return CMD_NAME_UNKNOWN; } +void PrintBinary(void* buf, int len) +{ + for(int i=0; ilength << " Player:" << (unsigned)buffer[3] << " Script: " << *(uint16_t*)&buffer[4] << " Mode: " << (unsigned)buffer[6] << " Msg: "; - for(int i = 7; i < packet->length; ++i) - std::cout << (char) packet->data[i]; + PrintBinary(&packet->data[7], packet->length); std::cout << std::endl; - } break; + } case NETMSG_TEAM: std::cout << "TEAM Playernum:" << (int)buffer[1] << " Action:"; switch (buffer[2]) { @@ -368,8 +376,23 @@ std::cout << " Energy: " << *(float*)(buffer + 8); std::cout << std::endl; break; + case NETMSG_CCOMMAND: + std::cout << "NETMSG_CCOMMAND: " << std::endl; + break; + case NETMSG_PAUSE: + std::cout << "NETMSG_PAUSE: Player " << (unsigned)buffer[1] << " paused: " << (unsigned)buffer[2] << std::endl; + break; + case NETMSG_SYNCRESPONSE: + std::cout << "NETMSG_SYNCRESPONSE: " << std::endl; + break; + case NETMSG_DIRECT_CONTROL: + std::cout << "NETMSG_DIRECT_CONTROL: " << std::endl; + break; + case NETMSG_SETSHARE: + std::cout << "NETMSG_SETSHARE: " << std::endl; + break; default: - std::cout << "MSG: " << (unsigned)buffer[0] << std::endl; + std::cout << "MSG: " << cmd << std::endl; } delete packet; } diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/CMakeLists.txt spring-98.0~14.04~ppa6/tools/pr-downloader/CMakeLists.txt --- spring-96.0~14.04~ppa4/tools/pr-downloader/CMakeLists.txt 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/CMakeLists.txt 2014-10-07 20:10:10.000000000 +0000 @@ -78,6 +78,9 @@ #set(CMAKE_INSTALL_RPATH "${PRD_LIBDIR}") endif (MINGW) +if(WIN32) + add_definitions(-DUNICODE -D_UNICODE) +endif() if (PREFER_STATIC_LIBS) #curl dependency @@ -99,8 +102,10 @@ include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src") # MINIZIP_FOUND is used in lib & FileSystem +Set(MINIZIP_FIND_QUIETLY TRUE) FIND_PACKAGE(MiniZip) if(NOT MINIZIP_FOUND) + message(STATUS "libminizip was not found, using integrated") include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/lib") endif() diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/.gitattributes spring-98.0~14.04~ppa6/tools/pr-downloader/.gitattributes --- spring-96.0~14.04~ppa4/tools/pr-downloader/.gitattributes 1970-01-01 00:00:00.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/.gitattributes 2014-10-07 20:10:10.000000000 +0000 @@ -0,0 +1,9 @@ +# Declare files that will always have LF line endings on checkout. +*.cpp text eol=lf +*.h text eol=lf +*.c text eol=lf +*.hpp text eol=lf +*.txt text eol=lf +*.cmake text eol=lf +*.sh text eol=lf +*.xpm text eol=lf diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/.gitignore spring-98.0~14.04~ppa6/tools/pr-downloader/.gitignore --- spring-96.0~14.04~ppa4/tools/pr-downloader/.gitignore 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/.gitignore 2014-10-07 20:10:10.000000000 +0000 @@ -7,12 +7,21 @@ /debian/*\.log /html build/ -CMakeFiles /curl* /zlib* /mingwlibs /dist +# output +/src/libspringdownloader.pc +/src/pr-downloader *.a *.so + +# CMake Makefile CMakeCache.txt +CMakeFiles + +#codeblocks project file +/pr-downloader.cbp + diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/CMakeLists.txt spring-98.0~14.04~ppa6/tools/pr-downloader/src/CMakeLists.txt --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/CMakeLists.txt 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/CMakeLists.txt 2014-10-07 20:10:10.000000000 +0000 @@ -1,23 +1,62 @@ subdirs(lib) -subdirs(Downloader) -subdirs(FileSystem) add_library(Version STATIC Version.cpp) set_target_properties(Version PROPERTIES COMPILE_DEFINITIONS "PR_DOWNLOADER_VERSION=${PR_DOWNLOADER_VERSION}") -add_library(Util STATIC - Util.cpp - Logger.cpp + +if (PRD_ARCHIVE_SUPPORT) + set(archivessrc FileSystem/SevenZipArchive.cpp FileSystem/ZipArchive.cpp) + set(archiveslib pr-7z) + add_definitions(-DARCHIVE_SUPPORT) +endif() + +add_library(Downloader STATIC + Downloader/Rapid/RapidDownloader.cpp + Downloader/Rapid/Repo.cpp + Downloader/Rapid/Sdp.cpp + Downloader/Http/HttpDownloader.cpp + Downloader/Http/DownloadData.cpp + Downloader/Plasma/PlasmaDownloader.cpp + Downloader/CurlWrapper.cpp Downloader/Download.cpp Downloader/IDownloader.cpp Downloader/Mirror.cpp Downloader/IDownloadsObserver.cpp + FileSystem/AtomicFile.cpp + FileSystem/FileData.cpp + FileSystem/FileSystem.cpp + FileSystem/File.cpp + FileSystem/HashMD5.cpp + FileSystem/HashSHA1.cpp + FileSystem/HashCRC32.cpp + FileSystem/IHash.cpp + Util.cpp + Logger.cpp + ${archivessrc} ) -add_library(CurlWrapper - Downloader/CurlWrapper.cpp +target_link_libraries(Downloader + ${CURL_LIBRARIES} + ${OPENSSL_LIBRARIES} + xmlrpc + ${WIN32LIBS} + soap + ${ZLIB_LIBRARIES} + pr-md5 + pr-sha1 + bencode + ${archiveslib} + Version ) -target_link_libraries(CurlWrapper Version) + +if(PRD_ARCHIVE_SUPPORT) + if (MINIZIP_FOUND) + target_link_libraries(Downloader ${MINIZIP_LIBRARIES}) + else() + target_link_libraries(Downloader pr-minizip) + endif() +endif() + set (PRDOWNLOADER "pr-downloader") set (PRDOWNLOADER_SHARED ${PRDOWNLOADER}_shared) @@ -32,12 +71,7 @@ set(PRDOWNLOADER_LIBS ${WIN32LIBS} - Util - Rapid - Http - CurlWrapper - Plasma - FileSystem + Downloader ) @@ -48,7 +82,7 @@ add_library(${PRDOWNLOADER_SHARED} SHARED pr-downloader.cpp ) - if(PRD_DO_INSTALL) + if(PRD_DO_INSTALL AND (PRD_DEVELOP_FILES OR (PRD_CONSOLETOOL AND NOT PRD_LINK_STATIC))) INSTALL (TARGETS ${PRDOWNLOADER_SHARED} RUNTIME DESTINATION ${PRD_BINDIR} LIBRARY DESTINATION ${PRD_LIBDIR} @@ -63,7 +97,7 @@ add_library(${PRDOWNLOADER_STATIC} STATIC pr-downloader.cpp ) - if(PRD_DO_INSTALL) + if(PRD_DO_INSTALL AND PRD_DEVELOP_FILES) INSTALL (TARGETS ${PRDOWNLOADER_STATIC} RUNTIME DESTINATION ${PRD_BINDIR} LIBRARY DESTINATION ${PRD_LIBDIR} @@ -111,7 +145,7 @@ endif() endif() -if(PRD_DO_INSTALL AND PRD_DEVELOP_FILES AND PRD_DO_INSTALL) +if(PRD_DO_INSTALL AND PRD_DEVELOP_FILES) INSTALL (FILES pr-downloader.h DESTINATION ${PRD_INCLUDE_DIR}/Downloader COMPONENT Devel ) diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/CMakeLists.txt spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/CMakeLists.txt --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/CMakeLists.txt 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ - -subdirs(Http) -subdirs(Plasma) -subdirs(Rapid) - diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/Download.cpp spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/Download.cpp --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/Download.cpp 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/Download.cpp 2014-10-07 20:10:10.000000000 +0000 @@ -40,8 +40,7 @@ hash(NULL), file(NULL), size(-1), - http_downloaded_size(0), - rapid_progress(0), + progress(0), state(IDownload::STATE_NONE), parallel_downloads(0), write_only_from(NULL) @@ -121,6 +120,9 @@ bool IDownload::addMirror(const std::string& url) { LOG_DEBUG("%s",url.c_str()); + if (origin_name.empty()) { + origin_name = url; + } Mirror* mirror=new Mirror(url); this->mirrors.push_back(mirror); return true; @@ -134,11 +136,9 @@ unsigned int IDownload::getProgress() const { - if ( dltype == TYP_RAPID ) - return rapid_progress; - if (file==NULL) - return -1; - return http_downloaded_size; + if ( dltype == TYP_RAPID || dltype == TYP_HTTP ) + return progress; + return 0; } diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/Download.h spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/Download.h --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/Download.h 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/Download.h 2014-10-07 20:10:10.000000000 +0000 @@ -90,13 +90,12 @@ * file size */ int size; - unsigned int http_downloaded_size; - - + + std::map rapid_size; std::map map_rapid_progress; - - int rapid_progress; + + int progress; /** * state for whole file */ @@ -106,7 +105,7 @@ */ unsigned int getProgress() const; std::string version; - + unsigned int parallel_downloads; DownloadData * write_only_from; diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/Http/CMakeLists.txt spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/Http/CMakeLists.txt --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/Http/CMakeLists.txt 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/Http/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ - -add_library(Http STATIC - HttpDownloader.cpp - DownloadData.cpp -) -target_link_libraries(Http - ${CURL_LIBRARIES} - ${OPENSSL_LIBRARIES} - xmlrpc -) - diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/Http/HttpDownloader.cpp spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/Http/HttpDownloader.cpp --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/Http/HttpDownloader.cpp 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/Http/HttpDownloader.cpp 2014-10-07 20:10:10.000000000 +0000 @@ -98,7 +98,7 @@ LOG_ERROR("Unknown Category %s", category.c_str()); filename+=PATH_DELIMITER; if ((resfile["mirrors"].getType()!=XmlRpc::XmlRpcValue::TypeArray) || - (resfile["filename"].getType()!=XmlRpc::XmlRpcValue::TypeString)) { + (resfile["filename"].getType()!=XmlRpc::XmlRpcValue::TypeString)) { LOG_ERROR("Invalid type in result"); return false; } @@ -153,12 +153,8 @@ if ( data->download->write_only_from != NULL && data->download->write_only_from != data ) return size*nmemb; else if ( data->download->write_only_from != NULL ) { - data->download->http_downloaded_size += size*nmemb; -// LOG_DEBUG("Downloaded %d",data->download->http_downloaded_size); return data->download->file->Write((const char*)ptr, size*nmemb, 0); } - data->download->http_downloaded_size += size*nmemb; -// LOG_DEBUG("Downloaded %d",data->download->http_downloaded_size); return data->download->file->Write((const char*)ptr, size*nmemb, data->start_piece); } @@ -255,6 +251,15 @@ return pieces; } +static int progress_func(DownloadData* data, double total, double done, double, double) +{ + data->download->progress = done; + if (data->got_ranges) { + LOG_PROGRESS(done, total, done >= total); + } + return 0; +} + bool CHttpDownloader::setupDownload(DownloadData* piece) { std::vector pieces = verifyAndGetNextPieces(*(piece->download->file), piece->download); @@ -284,7 +289,9 @@ piece->mirror->escapeUrl(escaped); curl_easy_setopt(curle, CURLOPT_WRITEFUNCTION, multi_write_data); curl_easy_setopt(curle, CURLOPT_WRITEDATA, piece); - curl_easy_setopt(curle, CURLOPT_NOPROGRESS, 1L); + curl_easy_setopt(curle, CURLOPT_NOPROGRESS, 0L); + curl_easy_setopt(curle, CURLOPT_PROGRESSDATA, piece); + curl_easy_setopt(curle, CURLOPT_PROGRESSFUNCTION, progress_func); curl_easy_setopt(curle, CURLOPT_URL, escaped.c_str()); if ((piece->download->size>0) && (piece->start_piece>=0) && piece->download->pieces.size() > 0) { //don't set range, if size unknown @@ -340,7 +347,7 @@ default: long http_code = 0; curl_easy_getinfo(msg->easy_handle, CURLINFO_RESPONSE_CODE, &http_code); - LOG_ERROR("CURL error(%d): %s %d (%s)",msg->msg, curl_easy_strerror(msg->data.result), http_code, data->mirror->url.c_str()); + LOG_ERROR("CURL error(%d:%d): %s %d (%s)",msg->msg, msg->data.result, curl_easy_strerror(msg->data.result), http_code, data->mirror->url.c_str()); if (data->start_piece>=0) { data->download->pieces[data->start_piece].state=IDownload::STATE_NONE; } @@ -367,7 +374,6 @@ // LOG("piece %d verified!", data->piece); } else { // piece download broken, mark mirror as broken (for this file) data->download->pieces[*it].state=IDownload::STATE_NONE; - data->download->http_downloaded_size -= data->download->piecesize; data->mirror->status=Mirror::STATUS_BROKEN; //FIXME: cleanup curl handle here + process next dl LOG_ERROR("Piece %d is invalid",*it); diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/Http/HttpDownloader.h spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/Http/HttpDownloader.h --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/Http/HttpDownloader.h 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/Http/HttpDownloader.h 2014-10-07 20:10:10.000000000 +0000 @@ -33,7 +33,6 @@ unsigned int getStatsPos(); unsigned int getCount(); const std::string& getCacheFile(const std::string &url); - void downloadStream(const std::string& url,std::list& files); virtual bool search(std::list& result, const std::string& name, IDownload::category=IDownload::CAT_NONE); virtual bool download(std::list< IDownload* >& download, int max_parallel=10); void showProcess(IDownload* download, bool forceOutput); diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/IDownloader.cpp spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/IDownloader.cpp --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/IDownloader.cpp 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/IDownloader.cpp 2014-10-07 20:10:10.000000000 +0000 @@ -82,3 +82,9 @@ } list.clear(); } + +bool IDownloader::setOption(const std::string& key, const std::string& value) +{ + LOG_ERROR("Invalid option: %s=%s", key.c_str(), value.c_str()); + return false; +} diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/IDownloader.h spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/IDownloader.h --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/IDownloader.h 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/IDownloader.h 2014-10-07 20:10:10.000000000 +0000 @@ -54,6 +54,7 @@ */ static void freeResult(std::list& list); + virtual bool setOption(const std::string& key, const std::string& value); private: static IDownloader* httpdl; static IDownloader* plasmadl; diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/Plasma/CMakeLists.txt spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/Plasma/CMakeLists.txt --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/Plasma/CMakeLists.txt 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/Plasma/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -add_library(Plasma STATIC - PlasmaDownloader.cpp -) - -target_link_libraries(Plasma - ${WIN32LIBS} - soap -) - diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/Plasma/PlasmaDownloader.cpp spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/Plasma/PlasmaDownloader.cpp --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/Plasma/PlasmaDownloader.cpp 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/Plasma/PlasmaDownloader.cpp 2014-10-07 20:10:10.000000000 +0000 @@ -83,7 +83,7 @@ return true; } -bool CPlasmaDownloader::download(IDownload* download,int max_parallel) +bool CPlasmaDownloader::download(IDownload* download,int /*max_parallel*/) { LOG_DEBUG("%s",download->name.c_str()); return httpDownload->download(download); diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/Rapid/CMakeLists.txt spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/Rapid/CMakeLists.txt --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/Rapid/CMakeLists.txt 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/Rapid/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ -add_library(Rapid STATIC - RapidDownloader.cpp - Repo.cpp - Sdp.cpp -) - diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/Rapid/RapidDownloader.cpp spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/Rapid/RapidDownloader.cpp --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/Rapid/RapidDownloader.cpp 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/Rapid/RapidDownloader.cpp 2014-10-07 20:10:10.000000000 +0000 @@ -18,11 +18,10 @@ #endif -CRapidDownloader::CRapidDownloader() +CRapidDownloader::CRapidDownloader(): + url(REPO_MASTER), + reposLoaded(false) { - reposLoaded = false; - sdps.clear(); - setMasterUrl(REPO_MASTER); } CRapidDownloader::~CRapidDownloader() @@ -107,7 +106,7 @@ return true; } -bool CRapidDownloader::download(IDownload* download,int max_parallel) +bool CRapidDownloader::download(IDownload* download, int /*max_parallel*/) { LOG_DEBUG("%s",download->name.c_str()); if (download->dltype != IDownload::TYP_RAPID) { //skip non-rapid downloads @@ -139,18 +138,29 @@ return false; } -void CRapidDownloader::setMasterUrl(const std::string& url) +bool CRapidDownloader::setOption(const std::string& key, const std::string& value) { - this->url=url; - reposLoaded = false; + if (key == "masterurl") { + url=value; + reposLoaded = false; + return true; + } + if (key == "forceupdate") { + reposLoaded = false; + return true; + } + return IDownloader::setOption(key, value); } void CRapidDownloader::download(const std::string& name) { std::string tmp; - urlToPath(name,tmp); - this->path = fileSystem->getSpringDir() + PATH_DELIMITER +"rapid" +PATH_DELIMITER+ tmp; + if (!urlToPath(name,tmp)){ + LOG_ERROR("Invalid path: %s", tmp.c_str()); + return; + } + path = fileSystem->getSpringDir() + PATH_DELIMITER +"rapid" +PATH_DELIMITER+ tmp; fileSystem->createSubdirs(path); LOG_DEBUG("%s",name.c_str()); //first try already downloaded file, as repo master file rarely changes @@ -164,7 +174,8 @@ bool CRapidDownloader::parse() { - gzFile fp=gzopen(path.c_str(), "rb"); + FILE* f = fileSystem->propen(path, "rb"); + gzFile fp=gzdopen(fileno(f), "rb"); if (fp==Z_NULL) { LOG_ERROR("Could not open %s", path.c_str()); return false; @@ -186,6 +197,7 @@ } } gzclose(fp); + fclose(f); LOG_INFO("Found %d repos in %s",repos.size(),path.c_str()); return true; } diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/Rapid/RapidDownloader.h spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/Rapid/RapidDownloader.h --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/Rapid/RapidDownloader.h 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/Rapid/RapidDownloader.h 2014-10-07 20:10:10.000000000 +0000 @@ -44,7 +44,7 @@ */ virtual bool download(IDownload* download,int max_parallel = 10); - void setMasterUrl(const std::string& url); + virtual bool setOption(const std::string& key, const std::string& value); /** parses a rep master-file */ diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/Rapid/Repo.cpp spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/Rapid/Repo.cpp --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/Rapid/Repo.cpp 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/Rapid/Repo.cpp 2014-10-07 20:10:10.000000000 +0000 @@ -41,7 +41,8 @@ bool CRepo::parse() { LOG_DEBUG("%s",tmpFile.c_str()); - gzFile fp=gzopen(tmpFile.c_str(), "r"); + FILE* f = fileSystem->propen(tmpFile, "rb"); + gzFile fp = gzdopen(fileno(f), "rb"); if (fp==Z_NULL) { LOG_ERROR("Could not open %s",tmpFile.c_str()); return false; @@ -81,5 +82,6 @@ LOG_ERROR("%d %s\n", errnum, errstr); } gzclose(fp); + fclose(f); return true; } diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/Rapid/Sdp.cpp spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/Rapid/Sdp.cpp --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/Downloader/Rapid/Sdp.cpp 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/Downloader/Rapid/Sdp.cpp 2014-10-07 20:10:10.000000000 +0000 @@ -160,70 +160,52 @@ md5.Set((*sdp->list_it)->md5, sizeof((*sdp->list_it)->md5)); fileSystem->getPoolFilename(md5.toString(), sdp->file_name); sdp->file_handle=new AtomicFile(sdp->file_name); -// LOG_DEBUG("opened %s, size: %d", sdp->file_name.c_str(), (*sdp->list_it)->size); -//FIXME sdp->setStatsPos(sdp->getStatsPos()+1); if (sdp->file_handle==NULL) { LOG_ERROR("couldn't open %s",(*sdp->list_it)->name.c_str()); return -1; } - //here comes the init new file stuff sdp->file_pos=0; } - if (sdp->file_handle!=NULL) { - if (sdp->skippedskipped); //calculate bytes we can skip, could overlap received bufs - for (int i=0; icursize_buf[sdp->skipped+i]=buf_pos[i]; -// if (sdp->skipped>0) { -// LOG_DEBUG("copy %d to %d ", i, sdp->skipped+i); -// } - } -// LOG_DEBUG("toskip: %d skipped: %d",toskip,sdp->skipped); - sdp->skipped=toskip+sdp->skipped; - buf_pos=buf_pos+toskip; - if (sdp->skipped==LENGTH_SIZE) { - (*sdp->list_it)->compsize=parse_int32(sdp->cursize_buf); -// LOG_DEBUG("%s %hhu %hhu %hhu %hhu", sdp->file_name.c_str(), sdp->cursize_buf[0], sdp->cursize_buf[1], sdp->cursize_buf[2], sdp->cursize_buf[3]); -// LOG_DEBUG("(data read from sdp)uncompressed size: %d (data read from net)compressed size: %d", (*sdp->list_it)->size, (*sdp->list_it)->compsize); - assert((*sdp->list_it)->size+2000 >= (*sdp->list_it)->compsize); - } + assert(sdp->file_handle!=NULL); + if (sdp->skippedskipped); //calculate bytes we can skip, could overlap received bufs + for (int i=0; icursize_buf[sdp->skipped+i]=buf_pos[i]; } - if (sdp->skipped==LENGTH_SIZE) { - int towrite=intmin ((*sdp->list_it)->compsize-sdp->file_pos , //minimum of bytes to write left in file and bytes to write left in buf - buf_end-buf_pos); -// LOG_DEBUG("%s %d %ld %ld %ld %d %d %d %d %d",sdp->file_name.c_str(), (*sdp->list_it).compsize, buf_pos,buf_end, buf_start, towrite, size, nmemb , sdp->skipped, sdp->file_pos); - int res=0; - if (towrite>0) { - res=sdp->file_handle->Write(buf_pos,towrite); - if (res!=towrite) { - LOG_ERROR("fwrite error"); - return -1; - } - if (res<=0) { - LOG_ERROR("wrote error: %d", res); - return -1; - } - } else if (towrite<0) { - LOG_DEBUG("Fatal, something went wrong here! %d", towrite); - return -1; - } + sdp->skipped += toskip; + buf_pos += toskip; + if (sdp->skipped==LENGTH_SIZE) { // all length bytes read, parse + (*sdp->list_it)->compsize=parse_int32(sdp->cursize_buf); + assert((*sdp->list_it)->size+2000 >= (*sdp->list_it)->compsize); + } + } + if (sdp->skipped==LENGTH_SIZE) { // length bytes read + const int towrite=intmin ((*sdp->list_it)->compsize-sdp->file_pos , //minimum of bytes to write left in file and bytes to write left in buf + buf_end-buf_pos); + if (towrite<0) { + LOG_ERROR("Fatal, something went wrong here! %d, %d %d", towrite, buf_end, buf_pos); + return -1; + } + const int res=sdp->file_handle->Write(buf_pos,towrite); + if (res!=towrite) { + LOG_ERROR("fwrite error"); + return -1; + } + buf_pos += res; + sdp->file_pos += res; - buf_pos=buf_pos+res; - sdp->file_pos+=res; - if (sdp->file_pos>=(*sdp->list_it)->compsize) { //file finished -> next file - sdp->file_handle->Close(); - delete sdp->file_handle; - sdp->file_handle = NULL; - if (!fileSystem->fileIsValid(*sdp->list_it,sdp->file_name.c_str())) { - LOG_ERROR("File is broken?!: %s",sdp->file_name.c_str()); - remove(sdp->file_name.c_str()); - return -1; - } - sdp->file_handle=NULL; - sdp->list_it++; - sdp->file_pos=0; - sdp->skipped=0; + if (sdp->file_pos>=(*sdp->list_it)->compsize) { //file finished -> next file + sdp->file_handle->Close(); + delete sdp->file_handle; + sdp->file_handle = NULL; + if (!fileSystem->fileIsValid(*sdp->list_it,sdp->file_name.c_str())) { + LOG_ERROR("File is broken?!: %s",sdp->file_name.c_str()); + fileSystem->removeFile(sdp->file_name.c_str()); + return -1; } + sdp->list_it++; + sdp->file_pos=0; + sdp->skipped=0; } } } @@ -235,7 +217,7 @@ draw a nice download status-bar */ static int progress_func(CSdp& csdp, double TotalToDownload, double NowDownloaded, - double TotalToUpload, double NowUploaded) + double TotalToUpload, double NowUploaded) { (void)csdp; @@ -252,7 +234,7 @@ for ( std::map::iterator it = csdp.m_download->map_rapid_progress.begin(); it != csdp.m_download->map_rapid_progress.end(); it++ ) { total += (*it).second; } - csdp.m_download->rapid_progress = total; + csdp.m_download->progress = total; if (TotalToDownload == NowDownloaded) //force output when download is finished LOG_PROGRESS(NowDownloaded,TotalToDownload, true); else @@ -281,7 +263,7 @@ std::list::iterator it; for (it=files.begin(); it!=files.end(); ++it) { if ((*it)->download==true) { - buf[i/8] = buf[i/8] + (1<<(i%8)); + buf[i/8] |= (1<<(i%8)); } i++; } diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/FileSystem/AtomicFile.cpp spring-98.0~14.04~ppa6/tools/pr-downloader/src/FileSystem/AtomicFile.cpp --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/FileSystem/AtomicFile.cpp 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/FileSystem/AtomicFile.cpp 2014-10-07 20:10:10.000000000 +0000 @@ -21,16 +21,16 @@ if (fileexists) { if (tmpexists) { //remove existing tempfile - remove(tmpname.c_str()); + fileSystem->removeFile(tmpname.c_str()); } //rename destination file to temp file - if (rename(filename.c_str(), tmpname.c_str())<0) { + if (fileSystem->Rename(filename, tmpname)<0) { LOG_ERROR("error renaming temp file %s", filename.c_str()); return false; } } LOG_DEBUG("opened %s", filename.c_str()); - handle = fopen(tmpname.c_str(), "wb+"); + handle = fileSystem->propen(tmpname, "wb+"); return (handle != NULL); } @@ -48,7 +48,7 @@ fsync(fileno(handle)); #endif fclose(handle); - rename(tmpname.c_str(), filename.c_str()); + fileSystem->Rename(tmpname, filename); handle = NULL; } @@ -57,6 +57,6 @@ if (handle!=NULL) { LOG_ERROR("File %s wasn't closed, deleting it", tmpname.c_str()); fclose(handle); - remove(tmpname.c_str()); + fileSystem->removeFile(tmpname.c_str()); } } diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/FileSystem/CMakeLists.txt spring-98.0~14.04~ppa6/tools/pr-downloader/src/FileSystem/CMakeLists.txt --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/FileSystem/CMakeLists.txt 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/FileSystem/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -if (PRD_ARCHIVE_SUPPORT) - set(archivessrc SevenZipArchive.cpp ZipArchive.cpp) - set(archiveslib pr-7z) - add_definitions(-DARCHIVE_SUPPORT) -endif() - -add_library(FileSystem - AtomicFile.cpp - FileData.cpp - FileSystem.cpp - File.cpp - HashMD5.cpp - HashSHA1.cpp - HashCRC32.cpp - IHash.cpp - ${archivessrc} -) -target_link_libraries(FileSystem - ${ZLIB_LIBRARIES} - pr-md5 - pr-sha1 - bencode - ${archiveslib} -) -if(PRD_ARCHIVE_SUPPORT) - if (MINIZIP_FOUND) - target_link_libraries(FileSystem ${MINIZIP_LIBRARIES}) - else() - target_link_libraries(FileSystem pr-minizip) - endif() -endif() - diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/FileSystem/File.cpp spring-98.0~14.04~ppa6/tools/pr-downloader/src/FileSystem/File.cpp --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/FileSystem/File.cpp 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/FileSystem/File.cpp 2014-10-07 20:10:10.000000000 +0000 @@ -4,6 +4,7 @@ #include "FileSystem.h" #include "Logger.h" #include "IHash.h" +#include "Util.h" #include #include @@ -37,8 +38,8 @@ if (handle!=0) { fclose(handle); if (IsNewFile()) { - unlink(filename.c_str()); //delete possible existing destination file - rename(tmpfile.c_str(), filename.c_str()); + fileSystem->removeFile(filename.c_str()); //delete possible existing destination file + fileSystem->Rename(tmpfile, filename); isnewfile = false; } handle=0; @@ -63,9 +64,9 @@ isnewfile=res!=0; if (isnewfile) { //if file is new, create it, if not, open the existing one without truncating it tmpfile = filename + ".tmp"; - handle=fopen(tmpfile.c_str(), "wb+"); + handle=fileSystem->propen(tmpfile, "wb+"); } else { - handle=fopen(filename.c_str(), "rb+"); + handle=fileSystem->propen(filename, "rb+"); timestamp = sb.st_mtime; } if (handle==0) { @@ -290,7 +291,7 @@ HANDLE h; bool close = false; if (handle==NULL) { - h = CreateFile(filename.c_str() , GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + h = CreateFile(s2ws(filename).c_str() , GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); close = true; } else { h = (HANDLE)_get_osfhandle(fileno(handle)); diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/FileSystem/FileSystem.cpp spring-98.0~14.04~ppa6/tools/pr-downloader/src/FileSystem/FileSystem.cpp --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/FileSystem/FileSystem.cpp 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/FileSystem/FileSystem.cpp 2014-10-07 20:10:10.000000000 +0000 @@ -30,12 +30,23 @@ CFileSystem* CFileSystem::singleton = NULL; + +FILE* CFileSystem::propen(const std::string& filename, const std::string& mode) const +{ +#ifdef WIN32 + return _wfopen(s2ws(filename).c_str(), s2ws(mode).c_str()); +#else + return fopen(filename.c_str(), mode.c_str()); +#endif +} + bool CFileSystem::fileIsValid(const FileData* mod, const std::string& filename) const { HashMD5 md5hash; int bytes; unsigned char data[IO_BUF_SIZE]; - gzFile inFile = gzopen (filename.c_str(), "rb"); + FILE* f= propen(filename.c_str(), "rb"); + gzFile inFile = gzdopen (fileno(f), "rb"); if (inFile == NULL) { //file can't be opened LOG_ERROR("Could not open file %s", filename.c_str()); return false; @@ -49,13 +60,14 @@ md5hash.Final(); gzclose (inFile); + fclose(f); /* if (filesize!=mod->size){ ERROR("File %s invalid, size wrong: %d but should be %d", filename.c_str(),filesize, mod->size); return false; }*/ if (!md5hash.compare(mod->md5, sizeof(mod->md5) )) { //file is invalid // ERROR("Damaged file found: %s",filename.c_str()); -// unlink(filename.c_str()); +// removeFile(filename.c_str()); return false; } return true; @@ -69,7 +81,8 @@ unsigned char c_size[4]; unsigned char length; - gzFile in=gzopen(filename.c_str(), "r"); + FILE* f= propen(filename.c_str(), "rb"); + gzFile in=gzdopen(fileno(f), "rb"); if (in==Z_NULL) { LOG_ERROR("Could not open %s",filename.c_str()); return false; @@ -100,6 +113,7 @@ files.push_back(f); } gzclose(in); + fclose(f); LOG_DEBUG("Parsed %s with %d files\n", filename.c_str(), (int)files.size()); return true; } @@ -108,13 +122,14 @@ { std::list::iterator it; for (it = tmpfiles.begin(); it != tmpfiles.end(); ++it) { - remove(it->c_str()); + removeFile(it->c_str()); } tmpfiles.clear(); } bool CFileSystem::setWritePath(const std::string& path) { + if (!path.empty()) { if(!directoryExists(path)) { LOG_ERROR("filesystem-writepath doesn't exist: %s", path.c_str()); @@ -133,18 +148,26 @@ springdir=".spring"; } #else - TCHAR pathMyDocs[MAX_PATH]; - SHGetFolderPath( NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, pathMyDocs); - springdir=pathMyDocs; - springdir.append("\\My Games\\Spring"); + wchar_t my_documents[MAX_PATH]; + HRESULT result = SHGetFolderPathW(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, my_documents); + if (result == S_OK) { + springdir = ws2s(my_documents); + } + springdir.append("\\My Games\\Spring"); #endif } + if (!springdir.empty()) { //dir has to be without slash at the end + if (springdir[springdir.length()-1] == PATH_DELIMITER) { + springdir = springdir.substr(0, springdir.size() - 1); + } + } LOG_INFO("Using filesystem-writepath: %s", springdir.c_str()); return true; } -CFileSystem::CFileSystem() +CFileSystem::CFileSystem(): + portableDownload(false) { } @@ -172,18 +195,26 @@ bool CFileSystem::directoryExists(const std::string& path) const { + if (path.empty()) return false; +#ifdef WIN32 + const std::wstring wpath = s2ws(path); + DWORD dwAttrib = GetFileAttributesW(wpath.c_str()); + return ((dwAttrib != INVALID_FILE_ATTRIBUTES) && (dwAttrib & FILE_ATTRIBUTE_DIRECTORY)); +#else struct stat fileinfo; int res=stat(path.c_str(),&fileinfo); return ((res == 0) && ((fileinfo.st_mode & S_IFDIR) != 0)); +#endif } +bool CreateDir(const std::string& path) +{ #ifdef WIN32 -#define MKDIR(path) \ - mkdir(path) + return CreateDirectory(s2ws(path).c_str(), NULL); #else -#define MKDIR(path) \ - mkdir(path, 0755) + return mkdir(path.c_str(), 0755) == 0; #endif +} bool CFileSystem::createSubdirs (const std::string& path) const { @@ -194,23 +225,23 @@ for (unsigned int i=2; idirectoryExists(tocreate)) { - if (MKDIR(tmp.substr(0,i).c_str())!=0) + if (!CreateDir(tmp.substr(0,i).c_str())) return false; } } } - if ((!directoryExists(tmp)) && (MKDIR(tmp.c_str()))!=0) + if ((!directoryExists(tmp)) && (!CreateDir(tmp.c_str()))) return false; return true; } -#undef MKDIR void CFileSystem::getPoolFilename(const std::string& md5str, std::string& path) @@ -227,7 +258,7 @@ } -int CFileSystem::validatePool(const std::string& path) +int CFileSystem::validatePool(const std::string& path, bool deletebroken) { if(!directoryExists(path)) { LOG_ERROR("Pool directory doesn't exist: %s", path.c_str()); @@ -276,6 +307,9 @@ if (!fileIsValid(&filedata, absname)) { //check if md5 in filename is the same as in filename LOG_ERROR("Invalid File in pool: %s",absname.c_str()); + if (deletebroken) { + removeFile(absname.c_str()); + } } else { res++; } @@ -312,10 +346,21 @@ return (tfileExists(tmp)) { LOG_ERROR("File already exists: %s", tmp.c_str()); - continue; + if (!overwrite) + continue; } LOG_INFO("extracting (%s)", tmp.c_str()); - FILE* f=fopen(tmp.c_str(), "wb+"); + FILE* f=propen(tmp, "wb+"); if (f == NULL) { LOG_ERROR("Error creating %s", tmp.c_str()); delete archive; @@ -481,8 +534,12 @@ bool CFileSystem::Rename(const std::string& source, const std::string& destination) { +#ifdef WIN32 + return MoveFileW(s2ws(source).c_str(), s2ws(destination).c_str()); +#else int res = rename(source.c_str(), destination.c_str()); return (res==0); +#endif } diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/FileSystem/FileSystem.h spring-98.0~14.04~ppa6/tools/pr-downloader/src/FileSystem/FileSystem.h --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/FileSystem/FileSystem.h 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/FileSystem/FileSystem.h 2014-10-07 20:10:10.000000000 +0000 @@ -57,7 +57,7 @@ Validate all files in /pool/ (check md5) @return count of valid files found */ - int validatePool(const std::string& path); + int validatePool(const std::string& path, bool deletebroken); /** check if file is older then secs, returns true if file is older or something goes wrong @@ -88,12 +88,13 @@ /** * extracts a 7z file to dstdir */ - bool extract(const std::string& filename, const std::string& dstdir); + bool extract(const std::string& filename, const std::string& dstdir, bool overwrite = false); /** * extract engine download */ bool extractEngine(const std::string& filename, const std::string& version); bool setWritePath(const std::string& path); + void setEnginePortableDownload(const bool portable) {portableDownload = portable;} /** * returns full filename for pool file from md5 @@ -108,12 +109,16 @@ std::string EscapePath(const std::string& path); + FILE* propen(const std::string& filename, const std::string& mode) const; + #ifdef WIN32 long FiletimeToTimestamp(const _FILETIME& time); void TimestampToFiletime(const time_t t, _FILETIME& pft); #endif + bool removeFile(const std::string& path); private: + bool portableDownload; std::list tmpfiles; std::list mods; bool parse_repository_line(char* str, SRepository* repository, int size); diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/FileSystem/SevenZipArchive.cpp spring-98.0~14.04~ppa6/tools/pr-downloader/src/FileSystem/SevenZipArchive.cpp --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/FileSystem/SevenZipArchive.cpp 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/FileSystem/SevenZipArchive.cpp 2014-10-07 20:10:10.000000000 +0000 @@ -13,6 +13,7 @@ } #include "Logger.h" +#include "Util.h" static Byte kUtf8Limits[5] = { 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; static Bool Utf16_To_Utf8(char *dest, size_t *destLen, const UInt16 *src, size_t srcLen) @@ -111,7 +112,11 @@ SzArEx_Init(&db); +#ifdef WIN32 + WRes wres = InFile_OpenW(&archiveStream.file, s2ws(name).c_str()); +#else WRes wres = InFile_Open(&archiveStream.file, name.c_str()); +#endif if (wres) { LOG_ERROR("Error opening %s %s", name.c_str(), strerror(wres)); return; diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/FileSystem/SevenZipArchive.h spring-98.0~14.04~ppa6/tools/pr-downloader/src/FileSystem/SevenZipArchive.h --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/FileSystem/SevenZipArchive.h 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/FileSystem/SevenZipArchive.h 2014-10-07 20:10:10.000000000 +0000 @@ -6,7 +6,7 @@ extern "C" { #include "lib/7z/7zFile.h" #include "lib/7z/7z.h" -}; +} #include #include diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/lib/7z/7zIn.c spring-98.0~14.04~ppa6/tools/pr-downloader/src/lib/7z/7zIn.c --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/lib/7z/7zIn.c 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/lib/7z/7zIn.c 2014-10-07 20:10:10.000000000 +0000 @@ -537,12 +537,12 @@ { UInt32 numCoders, numBindPairs, numPackStreams, i; UInt32 numInStreams = 0, numOutStreams = 0; - + RINOK(SzReadNumber32(sd, &numCoders)); if (numCoders > NUM_FOLDER_CODERS_MAX) return SZ_ERROR_UNSUPPORTED; folder->NumCoders = numCoders; - + MY_ALLOC(CSzCoderInfo, folder->Coders, (size_t)numCoders, alloc); for (i = 0; i < numCoders; i++) @@ -810,7 +810,7 @@ numDigests += numSubstreams; } - + si = 0; for (;;) { @@ -963,8 +963,8 @@ RINOK(SzReadArchiveProperties(sd)); RINOK(SzReadID(sd, &type)); } - - + + if (type == k7zIdMainStreamsInfo) { RINOK(SzReadStreamsInfo(sd, @@ -982,7 +982,7 @@ return SZ_OK; if (type != k7zIdFilesInfo) return SZ_ERROR_ARCHIVE; - + RINOK(SzReadNumber32(sd, &numFiles)); p->db.NumFiles = numFiles; @@ -1165,19 +1165,19 @@ RINOK(SzReadStreamsInfo(sd, &dataStartPos, p, &numUnpackStreams, unpackSizes, digestsDefined, digests, allocTemp, allocTemp)); - + dataStartPos += baseOffset; if (p->NumFolders != 1) return SZ_ERROR_ARCHIVE; folder = p->Folders; unpackSize = SzFolder_GetUnpackSize(folder); - + RINOK(LookInStream_SeekTo(inStream, dataStartPos)); if (!Buf_Create(outBuffer, (size_t)unpackSize, allocTemp)) return SZ_ERROR_MEM; - + res = SzFolder_Decode(folder, p->PackSizes, inStream, dataStartPos, outBuffer->data, (size_t)unpackSize, allocTemp); @@ -1240,7 +1240,7 @@ nextHeaderCRC = GetUi32(header + 28); p->startPosAfterHeader = startArcPos + k7zStartHeaderSize; - + if (CrcCalc(header + 12, 20) != GetUi32(header + 8)) return SZ_ERROR_CRC; @@ -1356,9 +1356,9 @@ *blockIndex = folderIndex; IAlloc_Free(allocMain, *outBuffer); *outBuffer = 0; - + RINOK(LookInStream_SeekTo(inStream, startOffset)); - + if (res == SZ_OK) { *outBufferSize = unpackSize; diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/lib/7z/CMakeLists.txt spring-98.0~14.04~ppa6/tools/pr-downloader/src/lib/7z/CMakeLists.txt --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/lib/7z/CMakeLists.txt 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/lib/7z/CMakeLists.txt 2014-10-07 20:10:10.000000000 +0000 @@ -1,4 +1,8 @@ -add_library(pr-7z +if(WIN32) + add_definitions(-DUNICODE -D_UNICODE) +endif() + +add_library(pr-7z STATIC 7zAlloc.c 7zBuf.c 7zBuf2.c diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/lib/7z/Lzma2Dec.c spring-98.0~14.04~ppa6/tools/pr-downloader/src/lib/7z/Lzma2Dec.c --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/lib/7z/Lzma2Dec.c 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/lib/7z/Lzma2Dec.c 2014-10-07 20:10:10.000000000 +0000 @@ -114,17 +114,17 @@ else p->unpackSize = (UInt32)(p->control & 0x1F) << 16; return LZMA2_STATE_UNPACK0; - + case LZMA2_STATE_UNPACK0: p->unpackSize |= (UInt32)b << 8; return LZMA2_STATE_UNPACK1; - + case LZMA2_STATE_UNPACK1: p->unpackSize |= (UInt32)b; p->unpackSize++; PRF(printf(" %8d", p->unpackSize)); return (LZMA2_IS_UNCOMPRESSED_STATE(p)) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0; - + case LZMA2_STATE_PACK0: p->packSize = (UInt32)b << 8; return LZMA2_STATE_PACK1; @@ -199,7 +199,7 @@ SizeT destSizeCur = dicLimit - dicPos; SizeT srcSizeCur = inSize - *srcLen; ELzmaFinishMode curFinishMode = LZMA_FINISH_ANY; - + if (p->unpackSize <= destSizeCur) { destSizeCur = (SizeT)p->unpackSize; @@ -250,7 +250,7 @@ Bool initState = (mode > 0); if ((!initDic && p->needInitDic) || (!initState && p->needInitState)) return SZ_ERROR_DATA; - + LzmaDec_InitDicAndState(&p->decoder, initDic, initState); p->needInitDic = False; p->needInitState = False; @@ -258,9 +258,9 @@ } if (srcSizeCur > p->packSize) srcSizeCur = (SizeT)p->packSize; - + res = LzmaDec_DecodeToDic(&p->decoder, dicPos + destSizeCur, src, &srcSizeCur, curFinishMode, status); - + src += srcSizeCur; *srcLen += srcSizeCur; p->packSize -= (UInt32)srcSizeCur; diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/lib/7z/LzmaDec.c spring-98.0~14.04~ppa6/tools/pr-downloader/src/lib/7z/LzmaDec.c --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/lib/7z/LzmaDec.c 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/lib/7z/LzmaDec.c 2014-10-07 20:10:10.000000000 +0000 @@ -141,7 +141,7 @@ Byte *dic = p->dic; SizeT dicBufSize = p->dicBufSize; SizeT dicPos = p->dicPos; - + UInt32 processedPos = p->processedPos; UInt32 checkDicSize = p->checkDicSize; unsigned len = 0; @@ -324,7 +324,7 @@ { NORMALIZE range >>= 1; - + { UInt32 t; code -= range; @@ -723,7 +723,7 @@ SizeT inSize = *srcLen; (*srcLen) = 0; LzmaDec_WriteRem(p, dicLimit); - + *status = LZMA_STATUS_NOT_SPECIFIED; while (p->remainLen != kMatchSpecLenStart) @@ -769,7 +769,7 @@ if (p->needInitState) LzmaDec_InitStateReal(p); - + if (p->tempBufSize == 0) { SizeT processed; @@ -900,12 +900,12 @@ { UInt32 dicSize; Byte d; - + if (size < LZMA_PROPS_SIZE) return SZ_ERROR_UNSUPPORTED; else dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24); - + if (dicSize < LZMA_DIC_MIN) dicSize = LZMA_DIC_MIN; p->dicSize = dicSize; diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/lib/minizip/CMakeLists.txt spring-98.0~14.04~ppa6/tools/pr-downloader/src/lib/minizip/CMakeLists.txt --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/lib/minizip/CMakeLists.txt 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/lib/minizip/CMakeLists.txt 2014-10-07 20:10:10.000000000 +0000 @@ -8,6 +8,10 @@ FIND_PACKAGE(ZLIB REQUIRED) +if(WIN32) + add_definitions(-DUNICODE -D_UNICODE) +endif() + ADD_LIBRARY(pr-minizip STATIC EXCLUDE_FROM_ALL ${miniZipSources}) TARGET_LINK_LIBRARIES(pr-minizip ${ZLIB_LIBRARY}) SET_TARGET_PROPERTIES(pr-minizip PROPERTIES COMPILE_FLAGS "${PIC_FLAG}") diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/main.cpp spring-98.0~14.04~ppa6/tools/pr-downloader/src/main.cpp --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/main.cpp 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/main.cpp 2014-10-07 20:10:10.000000000 +0000 @@ -18,6 +18,7 @@ enum { RAPID_DOWNLOAD=0, RAPID_VALIDATE, + RAPID_VALIDATE_DELETE, RAPID_SEARCH, HTTP_SEARCH, HTTP_DOWNLOAD, @@ -37,6 +38,7 @@ static struct option long_options[] = { {"rapid-download" , 1, 0, RAPID_DOWNLOAD}, {"rapid-validate" , 0, 0, RAPID_VALIDATE}, + {"delete" , 0, 0, RAPID_VALIDATE_DELETE}, {"dump-sdp" , 1, 0, FILESYSTEM_DUMPSDP}, {"http-download" , 1, 0, HTTP_DOWNLOAD}, {"http-search" , 1, 0, HTTP_SEARCH}, @@ -120,6 +122,7 @@ DownloadInit(); bool res=true; + bool removeinvalid = false; while (true) { int option_index = 0; int c = getopt_long(argc, argv, "", long_options, &option_index); @@ -131,7 +134,11 @@ break; } case RAPID_VALIDATE: { - DownloadRapidValidate(); + DownloadRapidValidate(removeinvalid); + break; + } + case RAPID_VALIDATE_DELETE: { + removeinvalid = true; break; } case FILESYSTEM_DUMPSDP: { diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/pr-downloader.cpp spring-98.0~14.04~ppa6/tools/pr-downloader/src/pr-downloader.cpp --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/pr-downloader.cpp 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/pr-downloader.cpp 2014-10-07 20:10:10.000000000 +0000 @@ -88,14 +88,11 @@ switch(type) { case DL_RAPID: return rapidDownload->search(searchres, searchname.c_str(), icat); - break; case DL_HTTP: case DL_ENGINE: return httpDownload->search(searchres, searchname.c_str(), icat); - break; case DL_PLASMA: return plasmaDownload->search(searchres, searchname.c_str(), icat); - break; case DL_ANY: rapidDownload->search(searchres, searchname.c_str(), icat); if (!searchres.empty()) { @@ -109,7 +106,6 @@ } //last try, use plasma return plasmaDownload->search(searchres, searchname.c_str(), icat); - break; default: LOG_ERROR("%s: type invalid", __FUNCTION__); return false; @@ -246,12 +242,12 @@ return res; } -bool DownloadRapidValidate() +bool DownloadRapidValidate(bool deletebroken) { std::string path = fileSystem->getSpringDir(); path += PATH_DELIMITER; path += "pool"; - return fileSystem->validatePool(path); + return fileSystem->validatePool(path, deletebroken); } bool DownloadDumpSDP(const char* path) diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/pr-downloader.h spring-98.0~14.04~ppa6/tools/pr-downloader/src/pr-downloader.h --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/pr-downloader.h 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/pr-downloader.h 2014-10-07 20:10:10.000000000 +0000 @@ -78,8 +78,9 @@ /** * validate rapid pool +* @param deletebroken files */ -extern bool DownloadRapidValidate(); +extern bool DownloadRapidValidate(bool deletebroken); /** * dump contents of a sdp diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/Util.cpp spring-98.0~14.04~ppa6/tools/pr-downloader/src/Util.cpp --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/Util.cpp 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/Util.cpp 2014-10-07 20:10:10.000000000 +0000 @@ -99,6 +99,11 @@ path.replace(pos,1,1, PATH_DELIMITER); pos=path.find("/",pos+1); } + for(size_t i=0; i +std::wstring s2ws(const std::string& s) +{ + const size_t slength = s.length(); + const int len = MultiByteToWideChar(CP_UTF8 , 0, s.c_str(), slength, 0, 0); + wchar_t* buf = new wchar_t[len]; + MultiByteToWideChar(CP_UTF8, 0, s.c_str(), slength, buf, len); + std::wstring r(buf, len); + delete[] buf; + return r; +} + +std::string ws2s(const std::wstring& s) +{ + const size_t slength = s.length(); + const int len = WideCharToMultiByte(CP_UTF8,0, s.c_str(),slength,NULL,0,NULL,NULL); + char* buf = new char[len]; + WideCharToMultiByte(CP_UTF8, 0, s.c_str(), slength, buf, len, NULL, NULL); + std::string r(buf, len); + delete [] buf; + return r; +} + + +#endif + + diff -Nru spring-96.0~14.04~ppa4/tools/pr-downloader/src/Util.h spring-98.0~14.04~ppa6/tools/pr-downloader/src/Util.h --- spring-96.0~14.04~ppa4/tools/pr-downloader/src/Util.h 2014-01-03 13:30:06.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/pr-downloader/src/Util.h 2014-10-07 20:10:10.000000000 +0000 @@ -59,4 +59,10 @@ */ unsigned long getTime(); +/* + convert std::wstring to std::string +*/ +std::string ws2s(const std::wstring& s); +std::wstring s2ws(const std::string& s); + #endif diff -Nru spring-96.0~14.04~ppa4/tools/unitsync/CMakeLists.txt spring-98.0~14.04~ppa6/tools/unitsync/CMakeLists.txt --- spring-96.0~14.04~ppa4/tools/unitsync/CMakeLists.txt 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/unitsync/CMakeLists.txt 2014-10-07 20:09:52.000000000 +0000 @@ -25,12 +25,12 @@ # We still need these header files, # even if we are not going to link with SDL. # We have them available anyway (mingwlibs). - FIND_PACKAGE(SDL REQUIRED) - INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR}) + FIND_PACKAGE(SDL2 REQUIRED) + INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR}) ELSE (MINGW) # Use a direct copy of the GL and SDL headers, # as these may not be available on headless systems. - INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/SDL) + INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/SDL2) ENDIF (MINGW) @@ -60,6 +60,7 @@ "${ENGINE_SRC_ROOT}/System/Config/ConfigLocater.cpp" "${ENGINE_SRC_ROOT}/System/CRC.cpp" "${ENGINE_SRC_ROOT}/System/Misc/SpringTime.cpp" + "${ENGINE_SRC_ROOT}/System/Platform/CpuID.cpp" "${ENGINE_SRC_ROOT}/System/Platform/Misc.cpp" "${ENGINE_SRC_ROOT}/System/Platform/ScopedFileLock.cpp" "${ENGINE_SRC_ROOT}/System/Platform/Threading.cpp" @@ -110,7 +111,9 @@ install (TARGETS unitsync DESTINATION ${LIBDIR}) Add_Subdirectory(test) -If (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/python/CMakeLists.txt" ) + +OPTION(UNITSYNC_PYTHON_BINDINGS "compile python bindings for unitsync (FIXME: broken with gcc 4.9 see #4377)" OFF) +If (UNITSYNC_PYTHON_BINDINGS) # only add this if the submodule is present Add_Subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/python") -EndIf (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/python/CMakeLists.txt") +EndIf() diff -Nru spring-96.0~14.04~ppa4/tools/unitsync/python/CMakeLists.txt spring-98.0~14.04~ppa6/tools/unitsync/python/CMakeLists.txt --- spring-96.0~14.04~ppa4/tools/unitsync/python/CMakeLists.txt 2014-01-03 13:30:08.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/unitsync/python/CMakeLists.txt 2014-10-07 20:10:12.000000000 +0000 @@ -1,4 +1,4 @@ -set(UNITSYNC_PYTHON_WRAPPER TRUE CACHE BOOL "Create a python wrapper for unitsync, if python is found on the system") +option(UNITSYNC_PYTHON_WRAPPER "Create a python wrapper for unitsync, if python is found on the system" TRUE) if (UNITSYNC_PYTHON_WRAPPER) # ADD_LIBRARY(static-unitsync STATIC ${unitsync_files}) diff -Nru spring-96.0~14.04~ppa4/tools/unitsync/test/CMakeLists.txt spring-98.0~14.04~ppa6/tools/unitsync/test/CMakeLists.txt --- spring-96.0~14.04~ppa4/tools/unitsync/test/CMakeLists.txt 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/unitsync/test/CMakeLists.txt 2014-10-07 20:09:52.000000000 +0000 @@ -10,10 +10,6 @@ REMOVE_DEFINITIONS(-DUNITSYNC) -# To allow linking to MODULE_LIBRARY targets -CMAKE_POLICY(SET CMP0001 OLD) -SET(CMAKE_BACKWARDS_COMPATIBILITY "2.2") - ADD_EXECUTABLE(lua2php EXCLUDE_FROM_ALL lua2php.cpp) TARGET_LINK_LIBRARIES(lua2php unitsync ${CMAKE_DL_LIBS}) ADD_DEPENDENCIES(lua2php unitsync) diff -Nru spring-96.0~14.04~ppa4/tools/unitsync/unitsync.cpp spring-98.0~14.04~ppa6/tools/unitsync/unitsync.cpp --- spring-96.0~14.04~ppa4/tools/unitsync/unitsync.cpp 2014-01-03 13:29:53.000000000 +0000 +++ spring-98.0~14.04~ppa6/tools/unitsync/unitsync.cpp 2014-10-07 20:09:52.000000000 +0000 @@ -1045,7 +1045,7 @@ CheckInit(); CheckNullOrEmpty(mapName); - mapArchives = archiveScanner->GetArchives(mapName); + mapArchives = archiveScanner->GetAllArchivesUsedBy(mapName); count = mapArchives.size(); } UNITSYNC_CATCH_BLOCKS; @@ -1471,7 +1471,7 @@ CheckInit(); CheckBounds(index, modData.size()); - primaryArchives = archiveScanner->GetArchives(modData[index].GetDependencies()[0]); + primaryArchives = archiveScanner->GetAllArchivesUsedBy(modData[index].GetDependencies()[0]); count = primaryArchives.size(); } UNITSYNC_CATCH_BLOCKS; diff -Nru spring-96.0~14.04~ppa4/.travis.yml spring-98.0~14.04~ppa6/.travis.yml --- spring-96.0~14.04~ppa4/.travis.yml 2014-01-03 13:29:52.000000000 +0000 +++ spring-98.0~14.04~ppa6/.travis.yml 2014-10-07 20:09:51.000000000 +0000 @@ -1,8 +1,29 @@ language: cpp compiler: +# - clang - gcc before_script: - - sudo apt-get install libglew-dev libsdl-dev libdevil-dev libopenal-dev libogg-dev libvorbis-dev libfreetype6-dev p7zip-full libxcursor-dev libboost-thread-dev libboost-regex-dev libboost-system-dev libboost-program-options-dev libboost-signals-dev +# sdl2 + - sudo add-apt-repository ppa:bartbes/love-stable --yes +# gcc 4.7 + - sudo add-apt-repository ppa:ubuntu-toolchain-r/test --yes + - sudo apt-get update -qq + - sudo apt-get install gcc-4.7 g++-4.7 + - sudo apt-get install libglew-dev libsdl2-dev libdevil-dev libopenal-dev libogg-dev libvorbis-dev libfreetype6-dev p7zip-full libxcursor-dev + - sudo apt-get install libboost-thread1.48-dev libboost-regex1.48-dev libboost-system1.48-dev libboost-program-options1.48-dev libboost-signals1.48-dev libboost-chrono1.48-dev libboost-filesystem1.48-dev libboost-test1.48-dev binutils-gold +env: + - TARGET=spring-headless + - TARGET=tests script: - - cmake . && make spring-headless && make check + - cmake -DCMAKE_CXX_COMPILER=g++-4.7 -DCMAKE_C_COMPILER=gcc-4.7 . + - make $TARGET -k +# disabled because "make check" needs installed spring and gcc 4.6 fails +# with creg it seems: https://travis-ci.org/spring/spring/builds/17682923#L2664 +# - make check +notifications: + irc: + channels: + - "chat.freenode.net#taspring" + on_success: change + on_failure: change diff -Nru spring-96.0~14.04~ppa4/VERSION spring-98.0~14.04~ppa6/VERSION --- spring-96.0~14.04~ppa4/VERSION 2014-01-03 13:30:08.000000000 +0000 +++ spring-98.0~14.04~ppa6/VERSION 2014-10-07 20:10:12.000000000 +0000 @@ -1 +1 @@ -96.0 +98.0