Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed VC2010 warnings/errors/projects

  • Loading branch information...
commit 5c2d73a86c313a3bc78696d0c02f69f126aca628 1 parent cbc5d26
@SebastienLussier SebastienLussier authored
View
49 CMakeLists.txt
@@ -112,6 +112,15 @@ function(force_recheck_library LIBRARY_NAME)
unset(CHECK_${LIBRARY_NAME}_LINK CACHE)
endfunction()
+function(create_source_groups)
+ # Source groups
+ set(SOURCE_GROUPS ai animation audio core game graphics gui io physics platform scene scripting window)
+ foreach(SOURCE_GROUP ${SOURCE_GROUPS})
+ file(GLOB_RECURSE SOURCES ${SRC_DIR}/${SOURCE_GROUP}/*.*)
+ source_group("${SOURCE_GROUP}" FILES ${SOURCES})
+ endforeach(SOURCE_GROUP)
+endfunction()
+
##############################################################################
option(ARX_BUILD_TESTS "Build tests" OFF)
@@ -148,11 +157,13 @@ mark_as_advanced(IL_LIBRARIES)
set(SRC_DIR src)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
-
include_directories(${SRC_DIR} ${ZLIB_INCLUDE_DIRS} ${IL_INCLUDE_DIR} ${FREETYPE_INCLUDE_DIRS})
if(MSVC)
# Set optimal options for msvc:
+
+ # Remove targets we don't really use (RelWithDebInfo, MinSizeRel)
+ set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Using only Debug and Release" FORCE)
# Disable deprecation warnings
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
@@ -160,25 +171,20 @@ if(MSVC)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
add_definitions(/wd4995)
- if(ARX_DEBUG)
- add_definitions(-D_CRTDBG_MAP_ALLOC)
- endif()
-
# TEMP - disable warning caused by the F2L removal
add_definitions(/wd4244) # conversion from 'float' to 'long', possible loss of data
-
- # Source groups
- set(SOURCE_GROUPS
- ai animation audio core game graphics gui io physics scene scripting window
- )
-
- file(GLOB_RECURSE ALL_INCLUDES ${SRC_DIR}/*.h)
- source_group("inc" FILES ${ALL_INCLUDES})
-
- foreach(SOURCE_GROUP ${SOURCE_GROUPS})
- file(GLOB_RECURSE SOURCES ${SRC_DIR}/${SOURCE_GROUP}/*.*)
- source_group("${SOURCE_GROUP}" FILES ${SOURCES})
- endforeach(SOURCE_GROUP)
+
+ # This is needed to use ZLIB as a DLL
+ add_definitions(-DZLIB_WINAPI)
+
+ # Add dx7 include & lib paths
+ if("$ENV{DX7SDK_PATH}" STREQUAL "")
+ message(WARNING "DX7SDK_PATH environment variable not found")
+ else("$ENV{DX7SDK_PATH}" STREQUAL "")
+ message(STATUS "Using DirectX 7 SDK found in " $ENV{DX7SDK_PATH})
+ include_directories("$ENV{DX7SDK_PATH}/include")
+ link_directories("$ENV{DX7SDK_PATH}/lib")
+ endif("$ENV{DX7SDK_PATH}" STREQUAL "")
else(MSVC)
# Set optimal options for gcc:
@@ -214,9 +220,11 @@ else(MSVC)
if(ARX_DEBUG)
#Debug
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g3")
+ add_definitions(-D_DEBUG)
else()
#Release
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -fno-strict-aliasing -g3") # TODO enable optimizations
+ add_definitions(-D_NDEBUG)
endif()
if(ARX_DEBUG_EXTRA)
@@ -250,17 +258,20 @@ if(ARX_MINGW)
endif(ARX_MINGW)
# Preprocessor definitions
-add_definitions(-D_DEBUG)
add_definitions(-DNOMINMAX)
#glob sources
file(GLOB_RECURSE ALL_SOURCES ${SRC_DIR}/*.cpp)
+file(GLOB_RECURSE ALL_INCLUDES ${SRC_DIR}/*.h)
#enable unity build if requested
if(ARX_USE_UNITYBUILD)
enable_unity_build(arx ALL_SOURCES)
endif()
+#create source groups
+create_source_groups()
+
#build
add_executable(arx ${ALL_SOURCES} ${ALL_INCLUDES})
View
1  src/core/Localization.cpp
@@ -27,6 +27,7 @@ ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
#include <list>
#include <sstream>
+#include <iterator>
#include "core/LocalizationHash.h"
#include "core/Unicode.hpp"
View
12 src/game/Inventory.cpp
@@ -503,9 +503,9 @@ bool FastInsert(INTERACTIVE_OBJ * _pIO, long _uiNumBag)
if (bFound)
{
- for (long jj = j; jj < (j + iSizeY); jj++)
+ for (size_t jj = j; jj < (j + iSizeY); jj++)
{
- for (long ii = i; ii < (i + iSizeX); ii++)
+ for (size_t ii = i; ii < (i + iSizeX); ii++)
{
if (inventory[_uiNumBag][ii][jj].io)
{
@@ -527,9 +527,9 @@ bool FastInsert(INTERACTIVE_OBJ * _pIO, long _uiNumBag)
if (bFound)
{
- for (long jj = j; jj < (j + iSizeY); jj++)
+ for (size_t jj = j; jj < (j + iSizeY); jj++)
{
- for (long ii = i; ii < (i + iSizeX); ii++)
+ for (size_t ii = i; ii < (i + iSizeX); ii++)
{
inventory[_uiNumBag][ii][jj].io = _pIO;
inventory[_uiNumBag][ii][jj].show = ((size_t)ii == i) && ((size_t)jj == j) ? 1 : 0;
@@ -563,8 +563,8 @@ void OptmizeInventory(unsigned int _uiNumBag)
int iSizeX = inventory[_uiNumBag][i][j].io->sizex;
int iSizeY = inventory[_uiNumBag][i][j].io->sizey;
- for(long jj = j ; jj < (j + iSizeY) ; jj++) {
- for(long ii = i ; ii < (i + iSizeX) ; ii++) {
+ for(size_t jj = j ; jj < (j + iSizeY) ; jj++) {
+ for(size_t ii = i ; ii < (i + iSizeX) ; ii++) {
inventory[_uiNumBag][ii][jj].io = NULL;
}
}
View
1  src/platform/String.cpp
@@ -1,5 +1,6 @@
#include "platform/String.h"
+#include "platform/Platform.h"
#include <cstring>
#include <algorithm>
View
2  src/scene/LoadLevel.cpp
@@ -859,7 +859,7 @@ INTERACTIVE_OBJ * LoadInter_Ex(const string & name, long ident, const EERIE_3D &
if (SendIOScriptEvent(io, SM_LOAD) == ACCEPT)
{
if(io->obj == NULL) {
- bool pbox = (io->ioflags & IO_ITEM);
+ bool pbox = (io->ioflags & IO_ITEM) == IO_ITEM;
io->obj = loadObject(io->filename, pbox);
if (io->ioflags & IO_NPC)
View
116 src/scripting/Script.cpp
@@ -1829,64 +1829,71 @@ std::string GetVarValueInterpretedAsText( std::string& temp1, EERIE_SCRIPT * ess
float t1;
long l1;
- if (temp1[0] == '^')
+ if(!temp1.empty())
{
- long lv;
- float fv;
- std::string tv;
+ if (temp1[0] == '^')
+ {
+ long lv;
+ float fv;
+ std::string tv;
- switch (GetSystemVar(esss,io,temp1,tv,&fv,&lv))//Arx: xrichter (2010-08-04) - fix a crash when $OBJONTOP return to many object name inside tv
+ switch (GetSystemVar(esss,io,temp1,tv,&fv,&lv))//Arx: xrichter (2010-08-04) - fix a crash when $OBJONTOP return to many object name inside tv
+ {
+ case TYPE_TEXT:
+ strcpy(var_text, tv.c_str());
+ return var_text;
+ break;
+ case TYPE_LONG:
+ sprintf(var_text, "%ld", lv);
+ return var_text;
+ break;
+ default:
+ sprintf(var_text, "%f", fv);
+ return var_text;
+ break;
+ }
+ }
+ else if (temp1[0] == '#')
{
- case TYPE_TEXT:
- strcpy(var_text, tv.c_str());
- return var_text;
- break;
- case TYPE_LONG:
- sprintf(var_text, "%ld", lv);
- return var_text;
- break;
- default:
- sprintf(var_text, "%f", fv);
- return var_text;
- break;
+ l1 = GETVarValueLong(svar, NB_GLOBALS, temp1);
+ sprintf(var_text, "%ld", l1);
+ return var_text;
}
+ else if (temp1[0] == '\xA7')
+ {
+ l1 = GETVarValueLong(esss->lvar, esss->nblvar, temp1);
+ sprintf(var_text, "%ld", l1);
+ return var_text;
+ }
+ else if (temp1[0] == '&') t1 = GETVarValueFloat(svar, NB_GLOBALS, temp1);
+ else if (temp1[0] == '@') t1 = GETVarValueFloat(esss->lvar, esss->nblvar, temp1);
+ else if (temp1[0] == '$')
+ {
+ std::string tempo = GETVarValueText(svar, NB_GLOBALS, temp1);
- }
- else if (temp1[0] == '#')
- {
- l1 = GETVarValueLong(svar, NB_GLOBALS, temp1);
- sprintf(var_text, "%ld", l1);
- return var_text;
- }
- else if (temp1[0] == '\xA7')
- {
- l1 = GETVarValueLong(esss->lvar, esss->nblvar, temp1);
- sprintf(var_text, "%ld", l1);
- return var_text;
- }
- else if (temp1[0] == '&') t1 = GETVarValueFloat(svar, NB_GLOBALS, temp1);
- else if (temp1[0] == '@') t1 = GETVarValueFloat(esss->lvar, esss->nblvar, temp1);
- else if (temp1[0] == '$')
- {
- std::string tempo = GETVarValueText(svar, NB_GLOBALS, temp1);
-
- if (tempo.empty()) strcpy(var_text, "VOID");
- else strcpy(var_text, tempo.c_str());
+ if (tempo.empty()) strcpy(var_text, "VOID");
+ else strcpy(var_text, tempo.c_str());
- return var_text;
- }
- else if (temp1[0] == '\xA3')
- {
- std::string tempo = GETVarValueText(esss->lvar, esss->nblvar, temp1);
+ return var_text;
+ }
+ else if (temp1[0] == '\xA3')
+ {
+ std::string tempo = GETVarValueText(esss->lvar, esss->nblvar, temp1);
- if (tempo.empty()) strcpy(var_text, "VOID");
- else strcpy(var_text, tempo.c_str());
+ if (tempo.empty()) strcpy(var_text, "VOID");
+ else strcpy(var_text, tempo.c_str());
- return var_text;
+ return var_text;
+ }
+ else
+ {
+ strcpy(var_text, temp1.c_str());
+ return var_text;
+ }
}
else
{
- strcpy(var_text, temp1.c_str());
+ strcpy(var_text, "");
return var_text;
}
@@ -2585,12 +2592,19 @@ long SkipNextStatement(EERIE_SCRIPT * es, long pos)
if (pos < 0) return -1;
- if (temp[0] == '{') brack++;
-
- if (temp[0] == '}') brack--;
+ if(!temp.empty())
+ {
+ if (temp[0] == '{')
+ brack++;
+ else if (temp[0] == '}')
+ brack--;
+ }
}
}
- else pos = GotoNextLine(es, pos);
+ else
+ {
+ pos = GotoNextLine(es, pos);
+ }
tpos = GetNextWord(es, pos, temp);
MakeUpcase(temp);
View
5 src/scripting/ScriptEvent.cpp
@@ -2571,7 +2571,6 @@ ScriptResult ScriptEvent::send(EERIE_SCRIPT * es, ScriptMessage msg, const std::
else if (!strcmp(word, "SETEQUIP"))
{
std::string temp2;
- temp2[0] = 0;
std::string temp3;
pos = GetNextWord(es, pos, temp3);
LogDebug << "SET_EQUIP "<< temp3;
@@ -2591,12 +2590,12 @@ ScriptResult ScriptEvent::send(EERIE_SCRIPT * es, ScriptMessage msg, const std::
{
word = temp3;
pos = GetNextWord(es, pos, temp2);
- temp3[0] = 0;
+ temp3.clear();
}
short flag = 0;
- if (temp2[0])
+ if (!temp2.empty())
{
if (temp2[temp2.length()-1] == '%') flag = 1;
}
View
10 tools/CMakeLists.txt
@@ -3,9 +3,12 @@ cmake_minimum_required(VERSION 2.8)
find_package(ZLIB REQUIRED)
-set(CMAKE_CXX_COMPILER g++)
-set(CMAKE_C_COMPILER gcc)
-set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wformat=2 -Wundef -Wpointer-arith -Wlogical-op -Wcast-qual -O2 -fno-strict-aliasing -ggdb")
+if(MSVC)
+else(MSVC)
+ set(CMAKE_CXX_COMPILER g++)
+ set(CMAKE_C_COMPILER gcc)
+ set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wformat=2 -Wundef -Wpointer-arith -Wlogical-op -Wcast-qual -O2 -fno-strict- aliasing -ggdb")
+endif(MSVC)
include_directories(
../src
@@ -13,6 +16,7 @@ include_directories(
add_executable(unpaker
unpak/unpak.cpp
+ savetool/Filesystem_C.cpp
../src/io/PakEntry.cpp
../src/io/PakReader.cpp
../src/io/HashMap.cpp
View
35 tools/savetool/Filesystem_C.cpp
@@ -24,6 +24,11 @@ ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
*/
#include "io/Filesystem.h"
+#include "platform/Platform.h"
+
+#if ARX_PLATFORM == ARX_PLATFORM_WIN32
+ #include <windows.h>
+#endif
#include <cstdio>
#include <cstdlib>
@@ -153,6 +158,36 @@ void * FileLoadMalloc(const std::string& name, size_t * SizeLoadMalloc)
return(adr);
}
+bool CreateFullPath(const std::string & path)
+{
+ LogInfo << "CreateFullPath(" << path << ")";
+
+ size_t start = 0;
+
+ while(true) {
+
+ size_t pos = path.find_first_of("/\\", start);
+ if(pos == string::npos) {
+ break;
+ }
+
+ pos++;
+
+#if ARX_PLATFORM == ARX_PLATFORM_WIN32
+ CreateDirectory(path.substr(0, pos).c_str(), NULL);
+#else
+ mkdir(path.substr(0, pos).c_str(), 0777);
+#endif
+ start = pos + 1;
+ }
+
+#if ARX_PLATFORM == ARX_PLATFORM_WIN32
+ return DirectoryExist(path);
+#else
+ return true;
+#endif
+}
+
// TODO stub functions
void * FileLoadMallocZero(const string & name, size_t * SizeLoadMalloc) {
View
3  tools/unpak/unpak.cpp
@@ -12,6 +12,7 @@ using std::ostringstream;
#include <algorithm>
using std::transform;
+#include "io/Filesystem.h"
#include "io/PakReader.h"
#include "io/PakEntry.h"
//#define TEST_PAK_FREAD
@@ -34,7 +35,7 @@ void dump(PakReader & pak, const PakDirectory * dir, const string & where = str
dirname += "/";
}
- mkdir(dirname.c_str(), 0777);
+ CreateFullPath(dirname);
//printf("%s", dirname.c_str());
Please sign in to comment.
Something went wrong with that request. Please try again.