diff --git a/source/graphics/Model.h b/source/graphics/Model.h index 677fd93b90..4d17766319 100755 --- a/source/graphics/Model.h +++ b/source/graphics/Model.h @@ -9,6 +9,8 @@ #ifndef _MODEL_H #define _MODEL_H +#include + #include "Texture.h" #include "ModelDef.h" #include "RenderableObject.h" diff --git a/source/graphics/ObjectManager.cpp b/source/graphics/ObjectManager.cpp index b848520b8e..89f199060c 100755 --- a/source/graphics/ObjectManager.cpp +++ b/source/graphics/ObjectManager.cpp @@ -1,5 +1,6 @@ #include "ObjectManager.h" #include +#include "CLogger.h" CObjectManager::CObjectManager() : m_SelectedObject(0) { diff --git a/source/graphics/SkeletonAnimManager.cpp b/source/graphics/SkeletonAnimManager.cpp index f7c93eca2b..1007058e2d 100755 --- a/source/graphics/SkeletonAnimManager.cpp +++ b/source/graphics/SkeletonAnimManager.cpp @@ -8,6 +8,7 @@ #include "res/res.h" #include "Model.h" +#include "CLogger.h" #include "SkeletonAnimManager.h" #include diff --git a/source/graphics/TextureManager.cpp b/source/graphics/TextureManager.cpp index b36b9735ce..9616fbfbf2 100755 --- a/source/graphics/TextureManager.cpp +++ b/source/graphics/TextureManager.cpp @@ -1,12 +1,11 @@ +#include #include "TextureManager.h" #include "lib.h" #include "ogl.h" #include "res/tex.h" -#ifdef _WIN32 -#include -#endif -#include +#include "CLogger.h" + const char* SupportedTextureFormats[] = { ".png", ".dds", ".tga", ".bmp" }; diff --git a/source/gui/CGUI.cpp b/source/gui/CGUI.cpp index 3a8a61fa6c..f7bc5f8693 100755 --- a/source/gui/CGUI.cpp +++ b/source/gui/CGUI.cpp @@ -38,6 +38,8 @@ using namespace std; #pragma comment(lib, "xerces-c_2.lib") #endif +extern int g_xres, g_yres; + // TODO Gee: how to draw overlays? void render(COverlayText* overlaytext) { diff --git a/source/gui/IGUIObject.cpp b/source/gui/IGUIObject.cpp index a2d7eb35a2..1231a05255 100755 --- a/source/gui/IGUIObject.cpp +++ b/source/gui/IGUIObject.cpp @@ -12,6 +12,8 @@ gee@pyro.nu #include ///// +extern int g_xres, g_yres; + using namespace std; //------------------------------------------------------------------- diff --git a/source/lib/sysdep/sysdep.cpp b/source/lib/sysdep/sysdep.cpp index 6cd7542ada..ff624f31e7 100755 --- a/source/lib/sysdep/sysdep.cpp +++ b/source/lib/sysdep/sysdep.cpp @@ -45,3 +45,18 @@ double round(double x) } #endif + + +#ifndef HAVE_C99 + +float fminf(float a, float b) +{ + return (a < b)? a : b; +} + +float fmaxf(float a, float b) +{ + return (a > b)? a : b; +} + +#endif diff --git a/source/lib/sysdep/sysdep.h b/source/lib/sysdep/sysdep.h index 01ea638786..541d66ac61 100755 --- a/source/lib/sysdep/sysdep.h +++ b/source/lib/sysdep/sysdep.h @@ -5,6 +5,8 @@ #include "win/win.h" #endif +#include "config.h" + #ifdef __cplusplus extern "C" { #endif @@ -19,6 +21,12 @@ extern void check_heap(); extern double round(double); #endif +#ifndef HAVE_C99 +extern float fminf(float a, float b); +extern float fmaxf(float a, float b); +#endif + + #ifdef __cplusplus } #endif diff --git a/source/lib/sysdep/win/win.cpp b/source/lib/sysdep/win/win.cpp index 0f475aa38e..3586026f1c 100755 --- a/source/lib/sysdep/win/win.cpp +++ b/source/lib/sysdep/win/win.cpp @@ -188,7 +188,7 @@ static inline void pre_main_init() #ifdef PARANOIA // force malloc et al to check the heap every call. // slower, but reports errors closer to where they occur. - int flags = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); + uint flags = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); flags |= _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_DELAY_FREE_MEM_DF; _CrtSetDbgFlag(flags); #endif diff --git a/source/lib/sysdep/win/wposix.cpp b/source/lib/sysdep/win/wposix.cpp index b9613cfead..0a2e759c03 100755 --- a/source/lib/sysdep/win/wposix.cpp +++ b/source/lib/sysdep/win/wposix.cpp @@ -369,7 +369,7 @@ int pthread_mutex_destroy(pthread_mutex_t* m) ////////////////////////////////////////////////////////////////////////////// -void* mmap(void* start, unsigned int len, int prot, int flags, int fd, long offset) +void* mmap(void* start, size_t len, int prot, int flags, int fd, off_t offset) { if(!(flags & MAP_FIXED)) start = 0; @@ -413,7 +413,7 @@ void* mmap(void* start, unsigned int len, int prot, int flags, int fd, long offs } -int munmap(void* start, unsigned int /* len */) +int munmap(void* start, size_t /* len */) { return UnmapViewOfFile(start) - 1; /* 0: success; -1: fail */ } diff --git a/source/lib/sysdep/win/wposix.h b/source/lib/sysdep/win/wposix.h index da5dfd559f..70e7ba725f 100755 --- a/source/lib/sysdep/win/wposix.h +++ b/source/lib/sysdep/win/wposix.h @@ -192,8 +192,8 @@ extern int closedir(DIR*); #define MAP_FAILED 0 -extern void* mmap(void* start, unsigned int len, int prot, int flags, int fd, long offset); -extern int munmap(void* start, unsigned int len); +extern void* mmap(void* start, size_t len, int prot, int flags, int fd, off_t offset); +extern int munmap(void* start, size_t len); // diff --git a/source/main.cpp b/source/main.cpp index a73e627882..cd1afa32b2 100755 --- a/source/main.cpp +++ b/source/main.cpp @@ -1,6 +1,8 @@ #include #include #include +#include + // Alan: For some reason if this gets included after anything else some // compile time errors get thrown up todo with javascript internal typedefs @@ -50,7 +52,11 @@ u32 game_ticks; bool keys[SDLK_LAST]; bool mouseButtons[5]; -#include +// Globals +int g_xres, g_yres; +int g_bpp; +int g_freq; + // flag to disable extended GL extensions until fix found - specifically, crashes // using VBOs on laptop Radeon cards @@ -526,7 +532,7 @@ int main(int argc, char* argv[]) } - new CConfig; +/// new CConfig; // vfs_mount("gui", "gui", 0); vfs_mount("", "mods/official/", 0); @@ -561,8 +567,9 @@ int main(int argc, char* argv[]) new CObjectManager; new CUnitManager; - // terr_init actually opens the renderer and loads a bunch of resources as well as setting up - // the terrain + g_Renderer.Open(g_xres,g_yres,g_bpp); + + // terr_init loads a bunch of resources as well as setting up the terrain terr_init(); @@ -617,7 +624,7 @@ g_Console->RegisterFunc(Testing, "Testing"); const double TICK_TIME = 30e-3; // [s] double time0 = get_time(); - g_Config.Update(); +// g_Config.Update(); while(!quit) { //g_Config.Update(); @@ -664,11 +671,11 @@ g_Console->RegisterFunc(Testing, "Testing"); #ifndef NO_GUI g_GUI.Destroy(); - delete CGUI::GetSingletonPtr(); // again, we should have all singleton deletes somewhere + delete CGUI::GetSingletonPtr(); #endif delete &g_ScriptingHost; - delete &g_Config; +/// delete &g_Config; delete &g_Pathfinder; delete &g_EntityManager; delete &g_EntityTemplateCollection; diff --git a/source/maths/MathUtil.h b/source/maths/MathUtil.h index 6ac5564589..83c41f0677 100755 --- a/source/maths/MathUtil.h +++ b/source/maths/MathUtil.h @@ -170,10 +170,10 @@ namespace MathUtil // PURPOSE: Wraps num between lowerBound and upperBound. // template - PS_RESULT Wrap(T *num,const T &lowerBound, const T &upperBound) + int Wrap(T *num,const T &lowerBound, const T &upperBound) { if(lowerBound >= upperBound) - return ERRONEOUS_BOUND_ERROR; + return -1; else { // translate to range 0 to n-1, find the modulus, then @@ -182,7 +182,7 @@ namespace MathUtil num = SignedModulus( num, Abs(upperBound - lowerBound) ); num += lowerBound; } - return PS_OK; + return 0; } diff --git a/source/ps/CStr.cpp b/source/ps/CStr.cpp index dde8dc86f5..c6530f9f42 100755 --- a/source/ps/CStr.cpp +++ b/source/ps/CStr.cpp @@ -1,5 +1,6 @@ #include "CStr.h" #include "Network/Serialization.h" +#include CStr::CStr() { diff --git a/source/ps/Config.cpp b/source/ps/Config.cpp index fba8bbc04c..0fffe24edf 100755 --- a/source/ps/Config.cpp +++ b/source/ps/Config.cpp @@ -3,6 +3,8 @@ // TODO: A few changes from VFS -> CFile usage if required. // TODO: Optimizations, when we've decided what needs to be done. +#if 0 + #include "Config.h" #include "res/res.h" @@ -311,3 +313,5 @@ void CConfig::Attach( CLogFile* LogFile ) { m_LogFile = LogFile; } + +#endif diff --git a/source/ps/Error.h b/source/ps/Error.h index 1ccd6ec066..1fb0d0abb0 100755 --- a/source/ps/Error.h +++ b/source/ps/Error.h @@ -27,6 +27,20 @@ const int NullPtr = 0; + +// Setup error interface +#define IsError() GError.ErrorMechanism_Error() +#define ClearError() GError.ErrorMechanism_ClearError() +#define TestError(TError) GError.ErrorMechanism_TestError(TError) + +#define SetError_Short(w,x) GError.ErrorMechanism_SetError(w,x,__FILE__,__LINE__) +#define SetError_Long(w,x,y,z) GError.ErrorMechanism_SetError(w,x,y,z) + +#define GetError() GError.ErrorMechanism_GetError() + + + + /****************************************************************************/ // USER DEFINED TYPES // /****************************************************************************/ diff --git a/source/ps/LogFile.cpp b/source/ps/LogFile.cpp index 34ad864bef..0e75cbfb87 100755 --- a/source/ps/LogFile.cpp +++ b/source/ps/LogFile.cpp @@ -1,5 +1,7 @@ // last modified Thursday, May 08, 2003 +#if 0 + #include "LogFile.h" #include "lib.h" @@ -360,3 +362,5 @@ string CLogFile::Date(const PS_DISPLAY_SETTINGS &options) return dateText; } + +#endif diff --git a/source/ps/NPFont.h b/source/ps/NPFont.h index b82c093455..416b9857a7 100755 --- a/source/ps/NPFont.h +++ b/source/ps/NPFont.h @@ -4,6 +4,7 @@ // necessary includes #include "CStr.h" #include "Texture.h" +#include ///////////////////////////////////////////////////////////////////////////////////////// // NPFont: diff --git a/source/ps/NPFontManager.cpp b/source/ps/NPFontManager.cpp index e73fd3db9a..e47bd779b1 100755 --- a/source/ps/NPFontManager.cpp +++ b/source/ps/NPFontManager.cpp @@ -2,6 +2,7 @@ #include "NPFont.h" #include +#include // the sole instance of the NPFontManager NPFontManager* NPFontManager::_instance=0; diff --git a/source/ps/Prometheus.cpp b/source/ps/Prometheus.cpp index 10d9164718..b888b9a412 100755 --- a/source/ps/Prometheus.cpp +++ b/source/ps/Prometheus.cpp @@ -1,9 +1,5 @@ #include "Prometheus.h" -// Globals -int g_xres = 800, g_yres = 600; -int g_bpp = 32; -int g_freq = 60; DEFINE_ERROR(PS_OK, "OK"); DEFINE_ERROR(PS_FAIL, "Fail"); diff --git a/source/ps/Prometheus.h b/source/ps/Prometheus.h index 84b295d2f8..9f3e383e05 100755 --- a/source/ps/Prometheus.h +++ b/source/ps/Prometheus.h @@ -10,19 +10,6 @@ Standard declarations which are included in all projects. #define PROMETHEUS_H -#include -#include -#include -#include "CLogger.h" - -// Globals -extern int g_xres, g_yres; -extern int g_bpp; -extern int g_freq; - - -// Error handling - typedef const char * PS_RESULT; #define DEFINE_ERROR(x, y) PS_RESULT x=y; @@ -32,29 +19,4 @@ DECLARE_ERROR(PS_OK); DECLARE_ERROR(PS_FAIL); -/* -inline bool ErrorMechanism_Error(); - inline void ErrorMechanism_ClearError(); - inline bool ErrorMechanism_TestError( PS_RESULT); - - inline void ErrorMechanism_SetError( - PS_RESULT, - std::string, - std::string, - unsigned int); - - inline CError ErrorMechanism_GetError(); -*/ - - -// Setup error interface -#define IsError() GError.ErrorMechanism_Error() -#define ClearError() GError.ErrorMechanism_ClearError() -#define TestError(TError) GError.ErrorMechanism_TestError(TError) - -#define SetError_Short(w,x) GError.ErrorMechanism_SetError(w,x,__FILE__,__LINE__) -#define SetError_Long(w,x,y,z) GError.ErrorMechanism_SetError(w,x,y,z) - -#define GetError() GError.ErrorMechanism_GetError() - #endif diff --git a/source/ps/Sound.h b/source/ps/Sound.h index bc1b8b96e7..1b38f1796c 100755 --- a/source/ps/Sound.h +++ b/source/ps/Sound.h @@ -11,6 +11,7 @@ Usage: Create a CWindow object, call Create, call Run. OnActivate() or OnPaint(). */ +#if 0 -----support pan, volume, and crossfading @@ -160,4 +161,7 @@ PS_RESULT CSound::Resume() return PS_OK; } -#endif \ No newline at end of file +#endif + + +#endif diff --git a/source/ps/XercesErrorHandler.cpp b/source/ps/XercesErrorHandler.cpp index d317d699a4..31b9622dfe 100755 --- a/source/ps/XercesErrorHandler.cpp +++ b/source/ps/XercesErrorHandler.cpp @@ -13,6 +13,7 @@ gee@pyro.nu #include #include #include "Prometheus.h" +#include "CLogger.h" // Use namespace XERCES_CPP_NAMESPACE_USE diff --git a/source/simulation/BaseEntityCollection.cpp b/source/simulation/BaseEntityCollection.cpp index 431f0dba72..83299b35a9 100755 --- a/source/simulation/BaseEntityCollection.cpp +++ b/source/simulation/BaseEntityCollection.cpp @@ -3,6 +3,7 @@ #include "BaseEntityCollection.h" #include "ObjectManager.h" #include "Model.h" +#include "CLogger.h" void CBaseEntityCollection::loadTemplates() { diff --git a/source/simulation/EntityProperties.cpp b/source/simulation/EntityProperties.cpp index f2623be9f9..cabf458c70 100755 --- a/source/simulation/EntityProperties.cpp +++ b/source/simulation/EntityProperties.cpp @@ -1,5 +1,7 @@ #include "EntityProperties.h" +#include + CGenericProperty::CGenericProperty() { m_type = PROP_INTEGER; diff --git a/source/terrain/terrainMain.cpp b/source/terrain/terrainMain.cpp index 56d8f4d18e..999c9a02a9 100755 --- a/source/terrain/terrainMain.cpp +++ b/source/terrain/terrainMain.cpp @@ -31,7 +31,7 @@ int g_TransTexCounter = 0; int g_TickCounter = 0; double g_LastTime; -static float g_CameraZoom = 10; +static float g_CameraZoom = 10; const int NUM_ALPHA_MAPS = 13; const float ViewScrollSpeed = 60; @@ -39,10 +39,10 @@ float ViewFOV; int mouse_x=50, mouse_y=50; +extern int g_xres, g_yres; + void terr_init() { - g_Renderer.Open(g_xres,g_yres,g_bpp); - SViewPort vp; vp.m_X=0; vp.m_Y=0; @@ -89,8 +89,8 @@ please put this code out of its misery :) */ float fov = g_Camera.GetFOV(); - -#if 0 + +#if 0 const float d_key = DEGTORAD(10.0f) * DeltaTime; const float d_wheel = DEGTORAD( 50.0f ) * DeltaTime; const float fov_max = DEGTORAD( 60.0f ); @@ -114,33 +114,33 @@ please put this code out of its misery :) if( fov < fov_min ) fov = fov_min; } - ViewFOV = fov; - g_Camera.SetProjection(1, 5000, fov); -#else - // RC - added ScEd style zoom in and out (actually moving camera, rather than fudging fov) - float dir=0; - if (mouseButtons[SDL_BUTTON_WHEELUP]) dir=-1; - else if (mouseButtons[SDL_BUTTON_WHEELDOWN]) dir=1; - - float factor=dir*dir; - if (factor) { - if (dir<0) factor=-factor; - CVector3D forward=g_Camera.m_Orientation.GetIn(); - - // check we're not going to zoom into the terrain, or too far out into space - float h=g_Camera.m_Orientation.GetTranslation().Y+forward.Y*factor*g_CameraZoom; - float minh=65536*HEIGHT_SCALE*1.05f; - - if (h1500) { - // yup, we will; don't move anywhere (do clamped move instead, at some point) - } else { - // do a full move - g_CameraZoom-=(factor)*0.1f; - if (g_CameraZoom<0.01f) g_CameraZoom=0.01f; - g_Camera.m_Orientation.Translate(forward*(factor*g_CameraZoom)); - } - } -#endif + ViewFOV = fov; + g_Camera.SetProjection(1, 5000, fov); +#else + // RC - added ScEd style zoom in and out (actually moving camera, rather than fudging fov) + float dir=0; + if (mouseButtons[SDL_BUTTON_WHEELUP]) dir=-1; + else if (mouseButtons[SDL_BUTTON_WHEELDOWN]) dir=1; + + float factor=dir*dir; + if (factor) { + if (dir<0) factor=-factor; + CVector3D forward=g_Camera.m_Orientation.GetIn(); + + // check we're not going to zoom into the terrain, or too far out into space + float h=g_Camera.m_Orientation.GetTranslation().Y+forward.Y*factor*g_CameraZoom; + float minh=65536*HEIGHT_SCALE*1.05f; + + if (h1500) { + // yup, we will; don't move anywhere (do clamped move instead, at some point) + } else { + // do a full move + g_CameraZoom-=(factor)*0.1f; + if (g_CameraZoom<0.01f) g_CameraZoom=0.01f; + g_Camera.m_Orientation.Translate(forward*(factor*g_CameraZoom)); + } + } +#endif g_Camera.UpdateFrustum (); }