Skip to content

Commit

Permalink
build: Windows compilation fixes
Browse files Browse the repository at this point in the history
OPTIONAL changed to NOTREQUIRED (uh) because of conflict
  • Loading branch information
JanSimek committed Feb 2, 2014
1 parent b8e2d3d commit 5c54572
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 30 deletions.
16 changes: 12 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,15 @@ ELSE ( ENABLE_PHYSX )
ADD_DEFINITIONS( -DPHYSICS_NONE )
ENDIF ( ENABLE_PHYSX )

SET ( CMAKE_DATA_PATH "" CACHE STRING "Path to the top directory containing game data files" )
SET ( SHADOWGROUNDS_DATA_PATH "" CACHE STRING "Path to Shadowgrounds game data files (overrides CMAKE_DATA_PATH)" )
SET ( SURVIVOR_DATA_PATH "" CACHE STRING "Path to Survivor game data files (overrides CMAKE_DATA_PATH)" )

IF ( NOT CMAKE_DATA_PATH )
IF ( UNIX )
SET( CMAKE_DATA_PATH "/usr/share/games" )
ELSEIF ( NOT SHADOWGROUNDS_DATA_PATH OR NOT SURVIVOR_DATA_PATH )
MESSAGE( FATAL_ERROR "Neither {SHADOWGROUNDS,SURVIVOR}_DATA_PATH nor CMAKE_DATA_PATH is defined" )
MESSAGE( STATUS "WARNING: Neither {SHADOWGROUNDS,SURVIVOR}_DATA_PATH nor CMAKE_DATA_PATH is defined" )
ENDIF ( UNIX )
ENDIF ( NOT CMAKE_DATA_PATH)

Expand All @@ -133,7 +136,7 @@ IF( NOT LIGHT_MAX_AMOUNT )
SET( LIGHT_MAX_AMOUNT "5" CACHE STRING "Amount of light or what? Integer" FORCE ) # cmake doesn't support integers
ENDIF( NOT LIGHT_MAX_AMOUNT )
MARK_AS_ADVANCED( LINKEDLIST_USE_NODE_POOL BUILDINGMAP_SHOW_LOADINGMESSAGE LIGHT_MAX_AMOUNT )
CONFIGURE_FILE( project_common/configuration.h.in project_common/configuration.h )
CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/project_common/configuration.h.in ${CMAKE_BINARY_DIR}/project_common/configuration.h )

This comment has been minimized.

Copy link
@vayerx

vayerx Feb 4, 2014

Does Cmake for Windows require CMAKE_SOURCE_DIR to be explicitly specified?



# ------------------------------------------------
Expand Down Expand Up @@ -436,15 +439,20 @@ IF( UNIX )
)
ENDIF( UNIX )


# Set default build options
MACRO( SetShadowgroundsProperties name defines )
IF( FINAL_RELEASE_BUILD )
SET( FINAL_RELEASE_BUILD_FLAGS ";FINAL_RELEASE_BUILD=1" )
ENDIF()

IF (MSVC)
SET( INCLUDE_FLAG /FI )
ELSE ()
SET( INCLUDE_FLAG -include )
ENDIF ()

SET_TARGET_PROPERTIES( ${name} PROPERTIES
COMPILE_FLAGS "${SG_WARNINGS} -include ${PROJECT_BINARY_DIR}/project_common/configuration.h"
COMPILE_FLAGS "${SG_WARNINGS} ${INCLUDE_FLAG} ${PROJECT_BINARY_DIR}/project_common/configuration.h"
COMPILE_DEFINITIONS "${defines};SG_PROG_VERSION=\"${SG_PROG_VERSION}\";SG_PROG_HOST=\"${CMAKE_SYSTEM_NAME}\""
COMPILE_DEFINITIONS_DEBUG "_DEBUG=1"
COMPILE_DEFINITIONS_RELEASE "NDEBUG=1${FINAL_RELEASE_BUILD_FLAGS}"
Expand Down
2 changes: 1 addition & 1 deletion filesystem/file_package_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace frozenbyte {


enum Mode {
REQUIRED = 0, OPTIONAL = 1

This comment has been minimized.

Copy link
@vayerx

vayerx Feb 3, 2014

With what does "optional" conflict?

This comment has been minimized.

Copy link
@JanSimek

JanSimek Feb 3, 2014

Author Owner

I have no idea. Compilation fails with a very strange error that is explained by someone on Stackexchange.com as an internal conflict. Changing OPTIONAL to anything else fixes the compilation.

I know that NOTREQUIRED looks terrible, but I couldn't come up with anything better. I don't have access to Windows today and I can't find the Stackexchange link, but if you want to investigate this, I will post it here later.

This comment has been minimized.

Copy link
@JanSimek

JanSimek Feb 3, 2014

Author Owner

So the error message is this:
error 3805: '=' unexpected token, expected either '}' or a ','
The equal sign between OPTIONAL and 1 is highlighted.
Stackoverflow answer I was referring to: http://stackoverflow.com/a/10191253/1585128

REQUIRED = 0, NOTREQUIRED = 1,
};
void addPackage(boost::shared_ptr<IFilePackage> filePackage, int priority);
boost::shared_ptr<IFileList> findFiles(const std::string &dir,
Expand Down
2 changes: 1 addition & 1 deletion filesystem/input_stream_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace frozenbyte {

FilePackageManager::Mode mode = FilePackageManager::REQUIRED;
if (strchr(options, 'o')) {
mode = FilePackageManager::OPTIONAL;
mode = FilePackageManager::NOTREQUIRED;
}
InputStream stream = manager.getFile(filename, mode);

Expand Down
2 changes: 1 addition & 1 deletion game/GameOptionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ namespace game
igios_mapUserDataPrefix("config/options.txt") );
options_file >> options_config;

filesystem::InputStream def_options_config = filesystem::FilePackageManager::getInstance().getFile(
filesystem::InputStream def_options_file = filesystem::FilePackageManager::getInstance().getFile(
"data/misc/default_game_options.txt");
def_options_file >> def_options_config;

Expand Down
32 changes: 24 additions & 8 deletions project_common/configuration.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,24 @@
#pragma once

#ifdef _MSC_VER

#pragma warning ( disable: 4786 )
#pragma warning ( disable: 4103 )

#include <BaseTsd.h>
typedef SSIZE_T ssize_t;

#ifndef snprintf
# define snprintf _snprintf
#endif

#endif // _MSC_VER

// ignore __attribute__ on non-GCC platforms
#ifndef __GNUC__
# ifndef __attribute__
# define __attribute__(x)
# endif
#endif

// the new file to include,
Expand Down Expand Up @@ -38,19 +54,19 @@

// make memorymanager print extra data (string allocations' contents)
#define FROZENBYTE_DEBUG_MEMORY_PRINT_DATA 1
#endif

// old external script debug console (?)
//#define SCRIPT_DEBUG 1
#endif // !__GNUC__

// dump gamescene statistics to log (raytraces, pathfinds, etc.)
#define DUMP_GAMESCENE_STATS 1
// old external script debug console (?)
//#define SCRIPT_DEBUG 1

#endif
// dump gamescene statistics to log (raytraces, pathfinds, etc.)
#define DUMP_GAMESCENE_STATS 1

#endif // _DEBUG

// make debug view map of pathfinding
// WARNING: greatly affects pathfind efficiency, under no
// cicumstances leave this in the final product!!!
// circumstances leave this in the final product!!!
#cmakedefine PATHFIND_DEBUG 1

#ifdef PATHFIND_DEBUG
Expand Down
2 changes: 1 addition & 1 deletion shadowgrounds/shadowgrounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ int main(int argc, char *argv[])
*/

editor::EditorParser main_config;
filesystem::InputStream configFile = filesystem::FilePackageManager::getInstance().getFile("Config/main.txt", filesystem::FilePackageManager::OPTIONAL);
filesystem::InputStream configFile = filesystem::FilePackageManager::getInstance().getFile("Config/main.txt", filesystem::FilePackageManager::NOTREQUIRED);
configFile >> main_config;

GameOptionManager::getInstance()->load();
Expand Down
6 changes: 0 additions & 6 deletions storm/include/c2_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,3 @@
# define SAFE_DELETE_ARRAY(p) { if (p) { delete[] (p); (p) = NULL; } \
}
#endif

#ifndef C2_DO_NOT_DEFINE_DATATYPES
typedef uint8_t BYTE;
typedef uint16_t WORD;
typedef uint32_t DWORD;
#endif
2 changes: 1 addition & 1 deletion storm/storm3dv2/Storm3d_Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace {
if (!name)
return false;
filesystem::InputStream is =
filesystem::FilePackageManager::getInstance().getFile(name, filesystem::FilePackageManager::OPTIONAL);
filesystem::FilePackageManager::getInstance().getFile(name, filesystem::FilePackageManager::NOTREQUIRED);
return !is.isEof();
}

Expand Down
9 changes: 8 additions & 1 deletion storm/storm3dv2/render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
#include "igios.h"
#include "igios3D.h"
#include "storm3d.h"
#include <inttypes.h>

#ifndef _MSC_VER
# include <inttypes.h>
#endif

//! Apply FVF vertex format
/*! buffer must be bound before this
Expand Down Expand Up @@ -58,7 +61,9 @@ uintptr_t applyFVF(VxFormat fmt, uintptr_t size) {
}

if (ptr != size) {
#ifndef _MSC_VER // FIXME: inttypes.h
igiosWarning("applyFVF: ptr(%" PRIiPTR ") != size(%" PRIiPTR ")\n", ptr, size);
#endif // _MSC_VER
igios_backtrace();
}

Expand Down Expand Up @@ -99,7 +104,9 @@ void renderUP(VxFormat fmt, GLenum type, int count, int size, const char *vx) {
setStreamSource(0, 0, vx, size);

if (ptr != size) {
#ifndef _MSC_VER // FIXME: inttypes.h
igiosWarning("strange: ptr(%" PRIiPTR ") != size(%d)\n", ptr, size);
#endif // _MSC_VER
igios_backtrace();
}

Expand Down
5 changes: 4 additions & 1 deletion ui/Spotlight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,13 @@ namespace ui {
IStorm3D_Texture *coneStormTexture = NULL;
if (props.coneTextureFilename.empty()
&& props.coneAlphaMultiplier != 0.0f)
{
LOG_WARNING_W_DEBUG(

"Spotlight - Spot type has no cone texture filename but non-zero cone alpha multiplier.",
spottype.c_str() );
}
else
{
if ( !props.coneTextureFilename.empty() ) {
coneStormTexture = storm.CreateNewTexture( props.coneTextureFilename.c_str() );
if (coneStormTexture != NULL) {
Expand All @@ -476,6 +478,7 @@ namespace ui {
props.coneTextureFilename.c_str() );
}
}
}

spot = terrain.getRenderer().createSpot();
spot->setProjectionTexture(spotTexture);
Expand Down
6 changes: 3 additions & 3 deletions util/BuildingMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,6 @@ namespace frozenbyte {
}

// fill the interior parts of the map that are not reachable.
// - jpk
void floodfillInteriors()
{
// first, the collisionmap
Expand Down Expand Up @@ -599,8 +598,8 @@ namespace frozenbyte {
if (x >= 0 && x < xResolution
&& y >= 0 && y < yResolution)
heightMap[x][y] = 255;
else
#ifdef BUILDINGMAP_USE_OPTIONS
else
Logger::getInstance()->warning(
"BuildingMap::floodfillInteriors - Encountered door outside buildingmap area.");
#endif
Expand All @@ -625,7 +624,9 @@ namespace frozenbyte {

bool loadBinary(const std::string &fileName)
{
int tmp = 0;
filesystem::FB_FILE *fp = filesystem::fb_fopen(fileName.c_str(), "rb");

if (fp == 0)
return false;

Expand Down Expand Up @@ -658,7 +659,6 @@ namespace frozenbyte {
}
#endif

int tmp = 0;

This comment has been minimized.

Copy link
@vayerx

vayerx Feb 3, 2014

Why?

This comment has been minimized.

Copy link
@JanSimek

JanSimek Feb 3, 2014

Author Owner

Mistake. I like variables declared at the start of a function or block, so I moved it but then I realized that's how they did it all over the place, so I gave up on changing it and forgot to revert this.

if (versionNum >= 1) {
filesystem::fb_fread(&tmp, sizeof(int), 1, fp);
if (tmp != 0)
Expand Down
2 changes: 1 addition & 1 deletion util/LocaleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ namespace util {
LocaleResource &resource = *l.resources[resourceId].get();
EditorParser parser;

filesystem::InputStream stream = filesystem::FilePackageManager::getInstance().getFile(filename, filesystem::FilePackageManager::OPTIONAL);
filesystem::InputStream stream = filesystem::FilePackageManager::getInstance().getFile(filename, filesystem::FilePackageManager::NOTREQUIRED);
if ( !stream.isEof() ) {
stream >> parser;
} else {
Expand Down
3 changes: 2 additions & 1 deletion util/hiddencommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ bool hiddencommand(const char *command, bool wait_process)
//int termstat;
//_cwait( &termstat, pidValue, _WAIT_CHILD );
if (wait_process) {
uint32_t excode = STILL_ACTIVE;
DWORD /*uint32_t*/ excode = STILL_ACTIVE;
int failcount = 0;

while (excode == STILL_ACTIVE) {
GetExitCodeProcess(pis.hProcess, &excode);
Sleep(100);
Expand Down

0 comments on commit 5c54572

Please sign in to comment.