Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ OPTION(WANT_STATIC_LIBS "Builds as many static libs as possible." OFF)
OPTION(WANT_USE_OpenSSL "Use libOpenSSL during CURL linking." ON)
OPTION(WANT_USE_FriBiDi "Enable libFriBIDi support." ON)
OPTION(WANT_USE_GoogleBreakpad "Enable GoogleBreakpad support." ON)
OPTION(WANT_USE_STREFLOP "Use the library streflop." ON)
OPTION(WANT_USE_XercesC "Enable libXercesC support." OFF)

FIND_PROGRAM(HELP2MAN "help2man")
Expand Down Expand Up @@ -263,39 +262,6 @@ endforeach()
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
#MESSAGE(STATUS "*TEST: Checking for max SSE LEVEL [${FORCE_MAX_SSE_LEVEL}]")

OPTION(FORCE_STREFLOP_SOFTWRAPPER "Set the streflop library to be forced to use the software emulator" OFF)
IF(NOT FORCE_MAX_SSE_LEVEL AND NOT FORCE_STREFLOP_SOFTWRAPPER)
SET(FORCE_MAX_SSE_LEVEL "1" CACHE STRING "Set the max SSE level to use if supported (0-3)")
ENDIF()

IF(NOT FORCE_STREFLOP_SOFTWRAPPER)
MESSAGE(STATUS "*NOTE: Checking for max SSE LEVEL [${FORCE_MAX_SSE_LEVEL}]")
special_check_for_sse( ${FORCE_MAX_SSE_LEVEL} )
ENDIF()

IF(WANT_USE_STREFLOP)
ADD_DEFINITIONS("-DUSE_STREFLOP -DSTREFLOP_RANDOM_GEN_SIZE=32 -DLIBM_COMPILING_FLT32 -DN_SPECIALIZED=32")

IF(HAS_SSE_EXTENSIONS AND NOT ${FORCE_MAX_SSE_LEVEL} MATCHES "0" AND NOT FORCE_STREFLOP_SOFTWRAPPER)
ADD_DEFINITIONS("-DSTREFLOP_SSE")
MESSAGE(STATUS "*NOTE: using SSE for STREFLOP.")
ELSE()
IF(NOT FORCE_STREFLOP_SOFTWRAPPER)
special_check_for_x87()
ENDIF()

IF(HAS_X87_SUPPORT AND NOT FORCE_STREFLOP_SOFTWRAPPER)
ADD_DEFINITIONS("-DSTREFLOP_X87")
MESSAGE(STATUS "*NOTE: using X87 for STREFLOP.")
ELSE()
ADD_DEFINITIONS("-DSTREFLOP_SOFT")
MESSAGE(STATUS "*NOTE: using SOFT emulation for STREFLOP.")
ENDIF()
ENDIF()
ELSE()
MESSAGE(STATUS "*WARNING: Disabled use of STREFLOP! Out of synchs may occur")
ENDIF()

include(CheckCXXSourceRuns)

check_cxx_source_runs("
Expand Down
26 changes: 0 additions & 26 deletions source/glest_game/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4364,29 +4364,7 @@ int glestMain(int argc, char **argv) {

printf("\nGIT: [%s]", getGITRevisionString().c_str());

#ifdef USE_STREFLOP

#if defined(STREFLOP_SSE)
const char *instruction_set = "[SSE]";
#elif defined(STREFLOP_X87)
const char *instruction_set = "[X87]";
#elif defined(STREFLOP_SOFT)
const char *instruction_set = "[SOFTFLOAT]";
#else
const char *instruction_set = "[none]";
#endif

#if defined(STREFLOP_NO_DENORMALS)
const char *denormals = "[no-denormals]";
#else
const char *denormals = "[denormals]";
#endif

printf(" - using STREFLOP %s - %s\n", instruction_set, denormals);

#else
printf("\n");
#endif
}

setGameVersion(glestVersionString);
Expand Down Expand Up @@ -4923,11 +4901,7 @@ int glestMain(int argc, char **argv) {
NetworkInterface::setDisplayMessageFunction(ExceptionHandler::DisplayMessage);
MenuStateMasterserver::setDisplayMessageFunction(ExceptionHandler::DisplayMessage);

#ifdef USE_STREFLOP
SystemFlags::OutputDebug(SystemFlags::debugSystem, "%s, STREFLOP enabled.\n", getNetworkVersionString().c_str());
#else
SystemFlags::OutputDebug(SystemFlags::debugSystem, "%s, STREFLOP NOT enabled.\n", getNetworkVersionString().c_str());
#endif

SystemFlags::OutputDebug(SystemFlags::debugSystem, "In [%s::%s Line: %d]\n", __FILE__, __FUNCTION__, __LINE__);
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands, "START\n");
Expand Down
25 changes: 5 additions & 20 deletions source/glest_game/type_instances/unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define NOMINMAX

#include <cassert>
#include "deterministic_math.h"
#include "unit.h"
#include "unit_particle_type.h"
#include "world.h"
Expand Down Expand Up @@ -949,22 +950,14 @@ void Unit::calculateXZRotation() {
SurfaceCell *sc = map->getSurfaceCell(Map::toSurfCoords(pos));
const Vec3f normal = sc->getNormal();

#ifdef USE_STREFLOP
targetRotationZ = radToDeg(streflop::atan2(static_cast<streflop::Simple>(abs(normal.x)), static_cast<streflop::Simple>(abs(normal.y))));
#else
targetRotationZ = radToDeg(atan2(abs(normal.x), abs(normal.y)));
#endif
targetRotationZ = deterministicAtan2Deg(abs(normal.x), abs(normal.y));

if ((normal.y < 0 || normal.x < 0) && !(normal.y < 0 && normal.x < 0)) {
targetRotationZ = targetRotationZ * -1;
}
targetRotationZ = targetRotationZ * -1;

#ifdef USE_STREFLOP
targetRotationX = radToDeg(streflop::atan2(static_cast<streflop::Simple>(abs(normal.z)), static_cast<streflop::Simple>(abs(normal.y))));
#else
targetRotationX = radToDeg(atan2(abs(normal.z), abs(normal.y)));
#endif
targetRotationX = deterministicAtan2Deg(abs(normal.z), abs(normal.y));

if ((normal.y < 0 || normal.z < 0) && !(normal.y < 0 && normal.z < 0)) {
targetRotationX = targetRotationX * -1;
Expand Down Expand Up @@ -1483,11 +1476,7 @@ void Unit::setTargetPos(const Vec2i &targetPos, bool threaded) {
// map->clampPos(relPos);

Vec2f relPosf = Vec2f((float)relPos.x, (float)relPos.y);
#ifdef USE_STREFLOP
targetRotation = radToDeg(streflop::atan2(static_cast<streflop::Simple>(relPosf.x), static_cast<streflop::Simple>(relPosf.y)));
#else
targetRotation = radToDeg(atan2(relPosf.x, relPosf.y));
#endif
targetRotation = deterministicAtan2Deg(relPosf.x, relPosf.y);
targetRotation = truncateDecimal<float>(targetRotation, 6);

targetRef = NULL;
Expand Down Expand Up @@ -3922,11 +3911,7 @@ void Unit::updateTarget() {
targetPos = target->getCellPos();
Vec2i relPos = targetPos - pos;
Vec2f relPosf = Vec2f((float)relPos.x, (float)relPos.y);
#ifdef USE_STREFLOP
targetRotation = radToDeg(streflop::atan2(static_cast<streflop::Simple>(relPosf.x), static_cast<streflop::Simple>(relPosf.y)));
#else
targetRotation = radToDeg(atan2(relPosf.x, relPosf.y));
#endif
targetRotation = deterministicAtan2Deg(relPosf.x, relPosf.y);
targetVec = target->getCurrVectorAsTarget();
}
}
Expand Down
13 changes: 1 addition & 12 deletions source/glest_game/world/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1709,12 +1709,7 @@ void Map::smoothSurface(Tileset *tileset) {
float numUsedToSmooth = 0.f;
for (int k = -1; k <= 1; ++k) {
for (int l = -1; l <= 1; ++l) {
#ifdef USE_STREFLOP
if (cliffLevel <= 0.1f ||
cliffLevel > streflop::fabs(static_cast<streflop::Simple>(oldHeights[(j)*surfaceW + (i)] - oldHeights[(j + k) * surfaceW + (i + l)]))) {
#else
if (cliffLevel <= 0.1f || cliffLevel > fabs(oldHeights[(j)*surfaceW + (i)] - oldHeights[(j + k) * surfaceW + (i + l)])) {
#endif
height += oldHeights[(j + k) * surfaceW + (i + l)];
numUsedToSmooth++;
} else {
Expand Down Expand Up @@ -2059,13 +2054,7 @@ bool PosCircularIterator::next() {
pos.y++;
}
if (pos.y > center.y + radius) return false;
}
#ifdef USE_STREFLOP
while (streflop::floor(static_cast<streflop::Simple>(pos.dist(center))) >= (radius + 1) || !map->isInside(pos) ||
!map->isInsideSurface(map->toSurfCoords(pos)));
#else
while (floor(pos.dist(center)) >= (radius + 1) || !map->isInside(pos) || !map->isInsideSurface(map->toSurfCoords(pos)));
#endif
} while (floor(pos.dist(center)) >= (radius + 1) || !map->isInside(pos) || !map->isInsideSurface(map->toSurfCoords(pos)));

return true;
}
Expand Down
4 changes: 0 additions & 4 deletions source/glest_game/world/tileset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,7 @@ void Tileset::load(const string &dir, Checksum *checksum, Checksum *tilesetCheck
if (SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled)
SystemFlags::OutputDebug(SystemFlags::debugSystem, "In [%s::%s Line: %d]\n", __FILE__, __FUNCTION__, __LINE__);

#ifdef USE_STREFLOP
float rnd = streflop::fabs(static_cast<streflop::Simple>(random.randRange(-1.f, 1.f)));
#else
float rnd = fabs(random.randRange(-1.f, 1.f));
#endif

if (SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled)
SystemFlags::OutputDebug(SystemFlags::debugSystem, "In [%s::%s Line: %d]\n", __FILE__, __FUNCTION__, __LINE__);
Expand Down
19 changes: 1 addition & 18 deletions source/glest_game/world/unit_updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3161,11 +3161,7 @@ bool UnitUpdater::unitOnRange(Unit *unit, int range, Unit **rangedPtr, const Att
for (int i = center.x - range; i < center.x + range + size; ++i) {
for (int j = center.y - range; j < center.y + range + size; ++j) {
// cells inside map and in range
#ifdef USE_STREFLOP
if (map->isInside(i, j) && streflop::floor(static_cast<streflop::Simple>(floatCenter.dist(Vec2f((float)i, (float)j)))) <= (range + 1)) {
#else
if (map->isInside(i, j) && floor(floatCenter.dist(Vec2f((float)i, (float)j))) <= (range + 1)) {
#endif
Cell *cell = map->getCell(i, j);
findEnemiesForCell(ast, cell, unit, commandTarget, enemies);

Expand Down Expand Up @@ -3318,12 +3314,7 @@ bool UnitUpdater::unitOnRange(Unit *unit, int range, Unit **rangedPtr, const Att
attackWarnings.erase(attackWarnings.begin() + i);
delete toDelete; // old one
} else {
#ifdef USE_STREFLOP
currentDistance = streflop::floor(
static_cast<streflop::Simple>(enemyFloatCenter.dist(attackWarnings[i]->attackPosition))); // no need for streflops here!
#else
currentDistance = floor(enemyFloatCenter.dist(attackWarnings[i]->attackPosition)); // no need for streflops here!
#endif
currentDistance = floor(enemyFloatCenter.dist(attackWarnings[i]->attackPosition));

if (nearest == NULL) {
nearest = attackWarnings[i];
Expand Down Expand Up @@ -3419,11 +3410,7 @@ vector<Unit *> UnitUpdater::enemyUnitsOnRange(const Unit *unit, const AttackSkil
for (int i = center.x - range; i < center.x + range + size; ++i) {
for (int j = center.y - range; j < center.y + range + size; ++j) {
// cells inside map and in range
#ifdef USE_STREFLOP
if (map->isInside(i, j) && streflop::floor(static_cast<streflop::Simple>(floatCenter.dist(Vec2f((float)i, (float)j)))) <= (range + 1)) {
#else
if (map->isInside(i, j) && floor(floatCenter.dist(Vec2f((float)i, (float)j))) <= (range + 1)) {
#endif
Cell *cell = map->getCell(i, j);
findEnemiesForCell(ast, cell, unit, commandTarget, enemies);

Expand Down Expand Up @@ -3503,11 +3490,7 @@ vector<Unit *> UnitUpdater::findUnitsInRange(const Unit *unit, int radius) {
for (int i = center.x - range; i < center.x + range + size; ++i) {
for (int j = center.y - range; j < center.y + range + size; ++j) {
// cells inside map and in range
#ifdef USE_STREFLOP
if (map->isInside(i, j) && streflop::floor(static_cast<streflop::Simple>(floatCenter.dist(Vec2f((float)i, (float)j)))) <= (range + 1)) {
#else
if (map->isInside(i, j) && floor(floatCenter.dist(Vec2f((float)i, (float)j))) <= (range + 1)) {
#endif
Cell *cell = map->getCell(i, j);
findUnitsForCell(cell, units);
}
Expand Down
47 changes: 1 addition & 46 deletions source/shared_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,47 +1,14 @@
#########################################################################################
# streflop

OPTION(FORCE_EMBEDDED_LIBS "Force use of embedded libraries' code." OFF)

# IMPORTANT: should come BEFORE finding packages
IF(NOT MSVC)
find_package(PkgConfig REQUIRED)
ENDIF()

IF(FORCE_STREFLOP_SOFTWRAPPER)
pkg_search_module(STREFLOP streflop-soft)
ELSE()
IF(HAS_SSE_EXTENSIONS AND NOT ${FORCE_MAX_SSE_LEVEL} MATCHES "0")
pkg_search_module(STREFLOP streflop-sse)
ELSE()
IF(HAS_X87_SUPPORT)
pkg_search_module(STREFLOP streflop-x87)
ELSE()
pkg_search_module(STREFLOP streflop-soft)
ENDIF()
ENDIF()
ENDIF()
IF(NOT STREFLOP_FOUND)
pkg_search_module(STREFLOP streflop)
ENDIF()
MESSAGE(STATUS "Search for Library STREFLOP result = ${STREFLOP_FOUND} libs: ${STREFLOP_LIBRARIES} include dirs: ${STREFLOP_INCLUDE_DIRS}")

IF(FORCE_EMBEDDED_LIBS)
SET(STREFLOP_FOUND OFF)
MESSAGE(STATUS "FORCING USE of EMBEDDED Libraries...")
ENDIF()

IF(WANT_USE_STREFLOP)
IF(NOT STREFLOP_FOUND)
ADD_SUBDIRECTORY(sources/streflop)
ELSE()
INCLUDE_DIRECTORIES(${STREFLOP_INCLUDE_DIRS} ${STREFLOP_INCLUDE_DIRS}/streflop)
SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${STREFLOP_LIBRARIES})

ADD_DEFINITIONS("-DUSE_STREFLOP_PKG")
ENDIF()
ENDIF()

#########################################################################################
# common libraries

Expand Down Expand Up @@ -266,14 +233,6 @@ IF(BUILD_MEGAGLEST_MODEL_VIEWER OR BUILD_MEGAGLEST_MAP_EDITOR OR BUILD_MEGAGLEST
util
xml)

IF(WANT_USE_STREFLOP AND NOT STREFLOP_FOUND)
SET(DIRS_WITH_SRC
${DIRS_WITH_SRC}
streflop
streflop/libm_flt32_source
streflop/softfloat)
ENDIF()

IF(FORCE_EMBEDDED_LIBS)
SET(FORCE_USE_EMBEDDED_Miniupnpc ON)
ELSE()
Expand Down Expand Up @@ -466,7 +425,7 @@ IF(BUILD_MEGAGLEST_MODEL_VIEWER OR BUILD_MEGAGLEST_MAP_EDITOR OR BUILD_MEGAGLEST
ENDIF()

SET_SOURCE_FILES_PROPERTIES(${MG_SOURCE_FILES} PROPERTIES COMPILE_FLAGS
"${PLATFORM_SPECIFIC_DEFINES} ${STREFLOP_PROPERTIES} ${CXXFLAGS}")
"${PLATFORM_SPECIFIC_DEFINES} ${CXXFLAGS}")

SET_SOURCE_FILES_PROPERTIES(${MG_INCLUDE_FILES} PROPERTIES HEADER_FILE_ONLY 1)

Expand Down Expand Up @@ -517,7 +476,6 @@ IF(BUILD_MEGAGLEST_MODEL_VIEWER OR BUILD_MEGAGLEST_MAP_EDITOR OR BUILD_MEGAGLEST
TARGET_LINK_LIBRARIES(${TARGET_NAME}
${JPEG_LIBRARIES}
${LUA_LIBRARIES}
${MG_STREFLOP}
${COMMON_LIBS}
ftgl
gdi32
Expand All @@ -530,9 +488,6 @@ IF(BUILD_MEGAGLEST_MODEL_VIEWER OR BUILD_MEGAGLEST_MAP_EDITOR OR BUILD_MEGAGLEST
ENDIF()
ENDIF()

IF(WANT_USE_STREFLOP AND NOT STREFLOP_FOUND)
TARGET_LINK_LIBRARIES(${TARGET_NAME} streflop)
ENDIF()
TARGET_LINK_LIBRARIES(${TARGET_NAME} ${EXTERNAL_LIBS} ${COMMON_LIBS})

#IF(MINIUPNP_DEBUG_BUILD)
Expand Down
8 changes: 0 additions & 8 deletions source/shared_lib/include/graphics/vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,8 @@ template <typename T> class Vec2 {
inline bool operator<(const Vec2<T> &v) const { return x < v.x || (x == v.x && y < v.y); }

inline float length() const {
#ifdef USE_STREFLOP
float len = static_cast<float>(streflop::sqrt(static_cast<streflop::Simple>(x * x + y * y)));
#else
float len = static_cast<float>(std::sqrt(static_cast<float>(x * x + y * y)));
len = truncateDecimal<float>(len, 6);
#endif
return len;
}

Expand Down Expand Up @@ -422,12 +418,8 @@ template <typename T> class Vec3 {
}

inline float length() const {
#ifdef USE_STREFLOP
float len = static_cast<float>(streflop::sqrt(static_cast<streflop::Simple>(x * x + y * y + z * z)));
#else
float len = static_cast<float>(std::sqrt(x * x + y * y + z * z));
len = truncateDecimal<float>(len, 6);
#endif
return len;
}

Expand Down
Loading
Loading