diff --git a/binaries/data/tools/atlas/lists.xml b/binaries/data/tools/atlas/lists.xml
index 4905257901..0c42b4bc3f 100644
--- a/binaries/data/tools/atlas/lists.xml
+++ b/binaries/data/tools/atlas/lists.xml
@@ -25,21 +25,20 @@
- - Attack
- - AttackA
- - AttackB
- - AttackC
- - Death
- - DeathA
- - DeathB
- - Idle
- - IdleA
- - IdleB
- - IdleC
- - Run
- - Special
- - Walk
- - Pack
+
+ - attack1
+ - attack2
+ - build
+ - corpse
+ - death
+ - gather_fruit
+ - gather_grain
+ - gather_stone
+ - gather_wood
+ - idle
+ - melee
+ - run
+ - walk
diff --git a/binaries/system/ActorViewer.bat b/binaries/system/ActorViewer.bat
new file mode 100644
index 0000000000..c27706d79c
--- /dev/null
+++ b/binaries/system/ActorViewer.bat
@@ -0,0 +1 @@
+pyrogenesis.exe -editor -actorviewer
\ No newline at end of file
diff --git a/build/premake/premake.lua b/build/premake/premake.lua
index 0f3a997cbb..ec4a748e65 100755
--- a/build/premake/premake.lua
+++ b/build/premake/premake.lua
@@ -484,9 +484,11 @@ function setup_atlas_packages()
setup_atlas_package("AtlasUI", "dll",
{ -- src
"ActorEditor",
+ "ActorViewer",
"ArchiveViewer",
"ColourTester",
"CustomControls/Buttons",
+ "CustomControls/Canvas",
"CustomControls/ColourDialog",
"CustomControls/DraggableListCtrl",
"CustomControls/EditableListCtrl",
diff --git a/source/graphics/GameView.cpp b/source/graphics/GameView.cpp
index e82ccb21cd..92e6321feb 100644
--- a/source/graphics/GameView.cpp
+++ b/source/graphics/GameView.cpp
@@ -303,32 +303,6 @@ void CGameView::SubmitModelRecursive(CModel* model)
}
}
-void CGameView::RenderNoCull()
-{
- CUnitManager *pUnitMan=m_pWorld->GetUnitManager();
- CTerrain *pTerrain=m_pWorld->GetTerrain();
-
- if (m_LockCullCamera == false)
- m_CullCamera = m_ViewCamera;
- g_Renderer.SetCamera(m_ViewCamera, m_CullCamera);
-
- CheckLightEnv();
-
- uint i,j;
- const std::vector& units=pUnitMan->GetUnits();
- for (i=0;iGetModel());
- }
-
- u32 patchesPerSide=pTerrain->GetPatchesPerSide();
- for (j=0; jGetPatch(i,j);
- g_Renderer.Submit(patch);
- }
- }
-}
-
static void MarkUpdateColorRecursive(CModel* model)
{
model->SetDirty(RENDERDATA_UPDATE_COLOR);
diff --git a/source/graphics/GameView.h b/source/graphics/GameView.h
index f45d3a0dcd..36b04c87f8 100644
--- a/source/graphics/GameView.h
+++ b/source/graphics/GameView.h
@@ -141,10 +141,6 @@ public:
void CameraLock(CVector3D Trans, bool smooth=true);
void CameraLock(float x, float y, float z, bool smooth=true);
- // RenderNoCull: render absolutely everything to a blank frame to force
- // renderer to load required assets
- void RenderNoCull();
-
// Camera Control Functions (used by input handler)
void ResetCamera();
void ResetCameraOrientation();
diff --git a/source/graphics/MapReader.cpp b/source/graphics/MapReader.cpp
index 7a7eec5eb0..457487db01 100644
--- a/source/graphics/MapReader.cpp
+++ b/source/graphics/MapReader.cpp
@@ -1,31 +1,31 @@
#include "precompiled.h"
#include "MapReader.h"
-#include "lib/types.h"
-#include "UnitManager.h"
-#include "Unit.h"
-#include "ps/Game.h"
-#include "ObjectManager.h"
-#include "simulation/Entity.h"
-#include "simulation/EntityTemplate.h"
-#include "simulation/EntityTemplateCollection.h"
-#include "simulation/EntityManager.h"
-#include "ps/CLogger.h"
-#include "maths/MathUtil.h"
-#include "Camera.h"
-#include "graphics/Patch.h"
+
+#include "graphics/Camera.h"
#include "graphics/GameView.h"
-#include "renderer/WaterManager.h"
-#include "renderer/SkyManager.h"
-
-#include "Model.h"
-#include "Terrain.h"
-#include "TextureManager.h"
-#include "TextureEntry.h"
-
+#include "graphics/Model.h"
+#include "graphics/ObjectManager.h"
+#include "graphics/Patch.h"
+#include "graphics/Terrain.h"
+#include "graphics/TextureEntry.h"
+#include "graphics/TextureManager.h"
+#include "graphics/Unit.h"
+#include "graphics/UnitManager.h"
#include "lib/timer.h"
+#include "lib/types.h"
+#include "maths/MathUtil.h"
+#include "ps/CLogger.h"
+#include "ps/Game.h"
#include "ps/Loader.h"
#include "ps/LoaderThunks.h"
+#include "ps/xml/Xeromyces.h"
+#include "renderer/SkyManager.h"
+#include "renderer/WaterManager.h"
+#include "simulation/Entity.h"
+#include "simulation/EntityManager.h"
+#include "simulation/EntityTemplate.h"
+#include "simulation/EntityTemplateCollection.h"
#define LOG_CATEGORY "graphics"
diff --git a/source/graphics/MapWriter.cpp b/source/graphics/MapWriter.cpp
index e2ca946e9e..317948acab 100644
--- a/source/graphics/MapWriter.cpp
+++ b/source/graphics/MapWriter.cpp
@@ -237,7 +237,7 @@ void CMapWriter::WriteXML(const char* filename,
CVector3D in = pCamera->m_Orientation.GetIn();
// Convert to spherical coordinates
float rotation = atan2(in.X, in.Z);
- float declination = atan2(sqrt(in.X*in.X + in.Z*in.Z), in.Y) - M_PI_2;
+ float declination = atan2(sqrt(in.X*in.X + in.Z*in.Z), in.Y) - PI/2;
{
XML_Element("Rotation");
diff --git a/source/graphics/ObjectManager.cpp b/source/graphics/ObjectManager.cpp
index d49f895833..0f82132aaf 100644
--- a/source/graphics/ObjectManager.cpp
+++ b/source/graphics/ObjectManager.cpp
@@ -29,7 +29,7 @@ bool operator< (const CObjectManager::ObjectKey& a, const CObjectManager::Object
return a.ActorVariation < b.ActorVariation;
}
-CObjectManager::CObjectManager() : m_SelectedThing(NULL)
+CObjectManager::CObjectManager()
{
m_ObjectTypes.reserve(32);
}
@@ -158,6 +158,10 @@ void CObjectManager::DeleteObject(CObjectEntry* entry)
int CObjectManager::LoadObjects()
{
+ // This is kind of useless - it should probably be removed,
+ // and UnloadObject moved into the destructor, and singletonness
+ // removed if we still want to unload the object manager and reuse it
+ // again later.
AddObjectType("");
return 0;
}
@@ -177,9 +181,6 @@ void CObjectManager::UnloadObjects()
);
}
m_ObjectTypes.clear();
-
- delete m_SelectedThing;
- m_SelectedThing = NULL;
}
diff --git a/source/graphics/ObjectManager.h b/source/graphics/ObjectManager.h
index d3121b2079..f7f01693e3 100644
--- a/source/graphics/ObjectManager.h
+++ b/source/graphics/ObjectManager.h
@@ -14,16 +14,6 @@ class CMatrix3D;
// access to sole CObjectManager object
#define g_ObjMan CObjectManager::GetSingleton()
-// Slight hack, to allow ScEd to place either entities or objects
-class CObjectThing
-{
-public:
- virtual ~CObjectThing() {}
- virtual void Create(CMatrix3D& transform, int playerID)=0;
- virtual void SetTransform(CMatrix3D& transform)=0;
- virtual CObjectEntry* GetObjectEntry()=0;
-};
-
///////////////////////////////////////////////////////////////////////////////////////////
// CObjectManager: manager class for all possible actor types
class CObjectManager : public Singleton
@@ -51,7 +41,6 @@ public:
};
public:
- CObjectThing* m_SelectedThing;
// constructor, destructor
CObjectManager();
@@ -68,8 +57,8 @@ public:
CObjectBase* FindObjectBase(const char* objname);
- CObjectEntry* FindObjectVariation(const char* objname, const std::vector >& selections);
- CObjectEntry* FindObjectVariation(CObjectBase* base, const std::vector >& selections);
+ CObjectEntry* FindObjectVariation(const char* objname, const std::vector >& selections);
+ CObjectEntry* FindObjectVariation(CObjectBase* base, const std::vector >& selections);
// Get all names, quite slowly. (Intended only for ScEd.)
void GetAllObjectNames(std::vector& names);
diff --git a/source/graphics/Unit.cpp b/source/graphics/Unit.cpp
index 1286d524d7..52f88e33da 100644
--- a/source/graphics/Unit.cpp
+++ b/source/graphics/Unit.cpp
@@ -7,18 +7,37 @@
#include "SkeletonAnim.h"
#include "SkeletonAnimDef.h"
-CUnit::CUnit(CObjectEntry* object, CEntity* entity, const std::set& actorSelections)
+CUnit::CUnit(CObjectEntry* object, CEntity* entity, const std::set& actorSelections)
: m_Object(object), m_Model(object->m_Model->Clone()), m_Entity(entity),
m_ID(-1), m_ActorSelections(actorSelections)
{
}
-
CUnit::~CUnit()
{
delete m_Model;
}
+CUnit* CUnit::Create(const CStr& actorName, CEntity* entity, const std::set& selections)
+{
+ CObjectBase* base = g_ObjMan.FindObjectBase(actorName);
+
+ if (! base)
+ return NULL;
+
+ std::set actorSelections = base->CalculateRandomVariation(selections);
+
+ std::vector > selectionsVec;
+ selectionsVec.push_back(actorSelections);
+
+ CObjectEntry* obj = g_ObjMan.FindObjectVariation(base, selectionsVec);
+
+ if (! obj)
+ return NULL;
+
+ return new CUnit(obj, entity, actorSelections);
+}
+
void CUnit::ShowAmmunition()
{
if (!m_Object->m_AmmunitionModel || !m_Object->m_AmmunitionPoint)
@@ -115,9 +134,9 @@ void CUnit::SetPlayerID(int id)
m_Model->SetPlayerID(m_PlayerID);
}
-void CUnit::SetEntitySelection(const CStrW& selection)
+void CUnit::SetEntitySelection(const CStr& selection)
{
- CStrW selection_lc = selection.LowerCase();
+ CStr selection_lc = selection.LowerCase();
// If we've already selected this, don't do anything
if (m_EntitySelections.find(selection_lc) != m_EntitySelections.end())
@@ -130,7 +149,7 @@ void CUnit::SetEntitySelection(const CStrW& selection)
ReloadObject();
}
-void CUnit::SetActorSelections(const std::set& selections)
+void CUnit::SetActorSelections(const std::set& selections)
{
m_ActorSelections = selections;
ReloadObject();
@@ -138,7 +157,7 @@ void CUnit::SetActorSelections(const std::set& selections)
void CUnit::ReloadObject()
{
- std::vector > selections;
+ std::vector > selections;
// TODO: push world selections (seasons, etc) (and reload whenever they're changed)
selections.push_back(m_EntitySelections);
selections.push_back(m_ActorSelections);
diff --git a/source/graphics/Unit.h b/source/graphics/Unit.h
index a6be5fb065..97ecf4d2eb 100644
--- a/source/graphics/Unit.h
+++ b/source/graphics/Unit.h
@@ -3,24 +3,31 @@
#include
+#include "ps/CStr.h"
+
class CModel;
class CObjectEntry;
class CEntity;
class CSkeletonAnim;
-class CStr8;
class CStrW;
/////////////////////////////////////////////////////////////////////////////////////////////
// CUnit: simple "actor" definition - defines a sole object within the world
class CUnit
{
+private:
+ // Private constructor. Needs complete list of selections for the variation.
+ CUnit(CObjectEntry* object, CEntity* entity, const std::set& actorSelections);
+
public:
- CUnit(CObjectEntry* object, CEntity* entity, const std::set& actorSelections);
+ // Attempt to create a unit with the given actor, attached to an entity
+ // (or NULL), with a set of suggested selections (with the rest being randomised).
+ // Returns NULL on failure.
+ static CUnit* Create(const CStr& actorName, CEntity* entity, const std::set& selections);
// destructor
~CUnit();
-
// get unit's template object; never NULL
CObjectEntry* GetObject() { return m_Object; }
// get unit's model data; never NULL
@@ -34,19 +41,20 @@ public:
// Sets the animation a random one matching 'name'. If none is found,
// sets to idle instead. Applies recursively to props.
- bool SetRandomAnimation(const CStr8& name, bool once = false, float speed = 0.0f);
+ // SetEntitySelection(name) should typically be used before this.
+ bool SetRandomAnimation(const CStr& name, bool once = false, float speed = 0.0f);
// Returns a random animation matching 'name'. If none is found,
// returns idle instead.
- CSkeletonAnim* GetRandomAnimation(const CStr8& name);
+ CSkeletonAnim* GetRandomAnimation(const CStr& name);
// Sets the entity-selection, and updates the unit to use the new
// actor variation.
- void SetEntitySelection(const CStrW& selection);
+ void SetEntitySelection(const CStr& selection);
// Returns whether the currently active animation is one of the ones
// matching 'name'.
- bool IsPlayingAnimation(const CStr8& name);
+ bool IsPlayingAnimation(const CStr& name);
// Set player ID of this unit
void SetPlayerID(int id);
@@ -57,9 +65,9 @@ public:
int GetID() const { return m_ID; }
void SetID(int id) { m_ID = id; }
- const std::set& GetActorSelections() const { return m_ActorSelections; }
+ const std::set& GetActorSelections() const { return m_ActorSelections; }
- void SetActorSelections(const std::set& selections);
+ void SetActorSelections(const std::set& selections);
private:
// object from which unit was created
@@ -76,9 +84,9 @@ private:
int m_ID;
// actor-level selections for this unit
- std::set m_ActorSelections;
+ std::set m_ActorSelections;
// entity-level selections for this unit
- std::set m_EntitySelections;
+ std::set m_EntitySelections;
void ReloadObject();
};
diff --git a/source/graphics/UnitManager.cpp b/source/graphics/UnitManager.cpp
index 26305c4144..97217cbf89 100644
--- a/source/graphics/UnitManager.cpp
+++ b/source/graphics/UnitManager.cpp
@@ -19,7 +19,6 @@
#include "ObjectEntry.h"
#include "simulation/Entity.h"
#include "simulation/LOSManager.h"
-#include "simulation/TerritoryManager.h"
extern CConsole* g_Console;
@@ -127,23 +126,9 @@ CUnit* CUnitManager::PickUnit(const CVector3D& origin, const CVector3D& dir) con
// CreateUnit: create a new unit and add it to the world
CUnit* CUnitManager::CreateUnit(const CStr& actorName, CEntity* entity, const std::set& selections)
{
- CObjectBase* base = g_ObjMan.FindObjectBase(actorName);
-
- if (! base)
- return NULL;
-
- std::set actorSelections = base->CalculateRandomVariation(selections);
-
- std::vector > selectionsVec;
- selectionsVec.push_back(actorSelections);
-
- CObjectEntry* obj = g_ObjMan.FindObjectVariation(base, selectionsVec);
-
- if (! obj)
- return NULL;
-
- CUnit* unit = new CUnit(obj, entity, actorSelections);
- AddUnit(unit);
+ CUnit* unit = CUnit::Create(actorName, entity, selections);
+ if (unit)
+ AddUnit(unit);
return unit;
}
diff --git a/source/graphics/UnitManager.h b/source/graphics/UnitManager.h
index c110e47cb2..bd10bb042b 100644
--- a/source/graphics/UnitManager.h
+++ b/source/graphics/UnitManager.h
@@ -41,7 +41,7 @@ public:
void DeleteAll();
// creates a new unit and adds it to the world
- CUnit* CreateUnit(const CStr& actorName, CEntity* entity, const std::set& selections);
+ CUnit* CreateUnit(const CStr& actorName, CEntity* entity, const std::set& selections);
// return the units
const std::vector& GetUnits() const { return m_Units; }
diff --git a/source/lib/app_hooks.cpp b/source/lib/app_hooks.cpp
index f22e88291f..33aeed64d9 100644
--- a/source/lib/app_hooks.cpp
+++ b/source/lib/app_hooks.cpp
@@ -157,7 +157,6 @@ static AppHooks ah =
void app_hooks_update(AppHooks* ah_)
{
debug_assert(ah_);
- ONCE_NOT(debug_warn("app hooks already set"));
// override members in if they are non-zero in
// (otherwise, we stick with the defaults set above)
diff --git a/source/lib/res/sound/snd_mgr.cpp b/source/lib/res/sound/snd_mgr.cpp
index 6f6b4ea19c..80855497f5 100644
--- a/source/lib/res/sound/snd_mgr.cpp
+++ b/source/lib/res/sound/snd_mgr.cpp
@@ -1394,7 +1394,7 @@ static float fade_factor_exponential(float t)
static float fade_factor_s_curve(float t)
{
// cosine curve
- float y = cos(t*M_PI + M_PI);
+ float y = cos(t*PI + PI);
// map [-1,1] to [0,1]
return (y + 1.0f) / 2.0f;
}
diff --git a/source/lib/sysdep/win/win.cpp b/source/lib/sysdep/win/win.cpp
index 5ca0b43e2b..bad4b423e9 100644
--- a/source/lib/sysdep/win/win.cpp
+++ b/source/lib/sysdep/win/win.cpp
@@ -327,7 +327,7 @@ static inline void pre_libc_init()
static int SEH_wrapped_entry()
{
int ret;
- //__try
+ __try
{
pre_libc_init();
#ifdef USE_WINMAIN
@@ -336,7 +336,7 @@ static int SEH_wrapped_entry()
ret = mainCRTStartup(); // calls _cinit and then our main
#endif
}
- //__except(wdbg_exception_filter(GetExceptionInformation()))
+ __except(wdbg_exception_filter(GetExceptionInformation()))
{
ret = -1;
}
diff --git a/source/main.cpp b/source/main.cpp
index 3ab8ee6d2e..5bbde1f62a 100644
--- a/source/main.cpp
+++ b/source/main.cpp
@@ -357,6 +357,9 @@ void kill_mainloop()
int main(int argc, char* argv[])
{
+ // If you ever want to catch a particular allocation:
+ //_CrtSetBreakAlloc(7864);
+
// see discussion at declaration of win_pre_main_init.
#if OS_WIN
win_pre_main_init();
diff --git a/source/maths/MathUtil.h b/source/maths/MathUtil.h
index 09253be38b..21927d3465 100644
--- a/source/maths/MathUtil.h
+++ b/source/maths/MathUtil.h
@@ -5,42 +5,32 @@
#define PI 3.14159265358979323846f
#endif
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-#ifndef M_PI_2
-#define M_PI_2 1.57079632679489661923
-#endif
-
#define DEGTORAD(a) ((a) * (PI/180.0f))
#define RADTODEG(a) ((a) * (180.0f/PI))
#define SQR(x) ((x) * (x))
-#define MAX3(a,b,c) ( MAX (MAX(a,b), c) )
-#define ABS(a) ((a > 0) ? (a) : (-a))
template
-T Interpolate( T& a, T& b, float l )
+T Interpolate(T& a, T& b, float l)
{
- return( a + ( b - a ) * l );
+ return a + (b - a) * l;
}
template
inline T clamp(T value, T min, T max)
{
- if (value<=min) return min;
- else if (value>=max) return max;
+ if (value <= min) return min;
+ else if (value >= max) return max;
else return value;
}
static inline int RoundUpToPowerOf2(int x)
{
- if ((x & (x-1))==0) return x;
- int d=x;
- while (d & (d-1)) {
- d&=(d-1);
- }
- return d<<1;
+ if ((x & (x-1)) == 0)
+ return x;
+ int d = x;
+ while (d & (d-1))
+ d &= (d-1);
+ return d << 1;
}
inline float sgn(float a)
diff --git a/source/maths/Noise.cpp b/source/maths/Noise.cpp
index b1675db998..22e563f298 100644
--- a/source/maths/Noise.cpp
+++ b/source/maths/Noise.cpp
@@ -31,7 +31,7 @@ Noise2D::Noise2D(int f)
grads[i] = new CVector2D_Maths[freq];
for(int j=0; jGetView()->RenderNoCull();
-
- g_Renderer.FlushFrame();
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
- g_Renderer.EndFrame();
-}
-
-
void Render()
{
MICROLOG(L"begin frame");
@@ -389,12 +378,6 @@ void Render()
g_Game->GetView()->GetCinema()->DrawAllSplines();
PROFILE_END( "render cinematic splines" );
}
- else
- {
- PROFILE_START( "flush frame" );
- g_Renderer.FlushFrame();
- PROFILE_END( "flush frame" );
- }
oglCheck();
@@ -898,9 +881,6 @@ void Init(int argc, char* argv[], uint flags)
// add all debug_printf "tags" that we are interested in:
debug_filter_add("TIMER");
- // If you ever want to catch a particular allocation:
- //_CrtSetBreakAlloc(187);
-
// Query CPU capabilities, possibly set some CPU-dependent flags
cpu_init();
@@ -1004,7 +984,13 @@ void Init(int argc, char* argv[], uint flags)
}
// (must come after SetVideoMode, since it calls oglInit)
- const char* missing = oglHaveExtensions(0, "GL_ARB_multitexture", "GL_EXT_draw_range_elements", "GL_ARB_texture_env_combine", "GL_ARB_texture_env_dot3", "GL_ARB_texture_env_crossbar", 0);
+ const char* missing = oglHaveExtensions(0,
+ "GL_ARB_multitexture",
+ "GL_EXT_draw_range_elements",
+ "GL_ARB_texture_env_combine",
+ "GL_ARB_texture_env_dot3",
+ "GL_ARB_texture_env_crossbar",
+ 0);
if(missing)
{
wchar_t buf[500];
@@ -1065,7 +1051,7 @@ void Init(int argc, char* argv[], uint flags)
// Check for heap corruption after every allocation. Very, very slowly.
// (And it highlights the allocation just after the one you care about,
// so you need to run it again and tell it to break on the one before.)
- //debug_heap_enable(DEBUG_HEAP_ALL);
+// debug_heap_enable(DEBUG_HEAP_ALL);
InitInput();
@@ -1079,27 +1065,20 @@ void Init(int argc, char* argv[], uint flags)
}
#endif
- {
- TIMER("Init_renderblank");
- MICROLOG(L"render blank");
- // render everything to a blank frame to force renderer to load everything
- RenderNoCull();
- }
-
if (g_FixedFrameTiming) {
- CCamera &g_Camera=*g_Game->GetView()->GetCamera();
+ CCamera &camera = *g_Game->GetView()->GetCamera();
#if 0 // TOPDOWN
- g_Camera.SetProjection(1.0f,10000.0f,DEGTORAD(90));
- g_Camera.m_Orientation.SetIdentity();
- g_Camera.m_Orientation.RotateX(DEGTORAD(90));
- g_Camera.m_Orientation.Translate(CELL_SIZE*250*0.5, 250, CELL_SIZE*250*0.5);
+ camera.SetProjection(1.0f,10000.0f,DEGTORAD(90));
+ camera.m_Orientation.SetIdentity();
+ camera.m_Orientation.RotateX(DEGTORAD(90));
+ camera.m_Orientation.Translate(CELL_SIZE*250*0.5, 250, CELL_SIZE*250*0.5);
#else // std view
- g_Camera.SetProjection(1.0f,10000.0f,DEGTORAD(20));
- g_Camera.m_Orientation.SetXRotation(DEGTORAD(30));
- g_Camera.m_Orientation.RotateY(DEGTORAD(-45));
- g_Camera.m_Orientation.Translate(350, 350, -275);
+ camera.SetProjection(1.0f,10000.0f,DEGTORAD(20));
+ camera.m_Orientation.SetXRotation(DEGTORAD(30));
+ camera.m_Orientation.RotateY(DEGTORAD(-45));
+ camera.m_Orientation.Translate(350, 350, -275);
#endif
- g_Camera.UpdateFrustum();
+ camera.UpdateFrustum();
}
if (g_AutostartMap.Length())
diff --git a/source/ps/GameSetup/GameSetup.h b/source/ps/GameSetup/GameSetup.h
index 2b8902efc2..321a18226e 100644
--- a/source/ps/GameSetup/GameSetup.h
+++ b/source/ps/GameSetup/GameSetup.h
@@ -15,6 +15,7 @@ extern void GUI_DisplayLoadProgress(int percent, const wchar_t* pending_task);
extern void Render();
+extern void RenderActor();
extern void Shutdown();
diff --git a/source/ps/Interact.cpp b/source/ps/Interact.cpp
index 3c8a7ae5bf..227916ed3b 100644
--- a/source/ps/Interact.cpp
+++ b/source/ps/Interact.cpp
@@ -2,9 +2,6 @@
#include "Interact.h"
-#include "ps/CConsole.h"
-#include "ps/Game.h"
-#include "ps/Hotkey.h"
#include "graphics/GameView.h"
#include "graphics/HFTracer.h"
#include "graphics/Model.h"
@@ -18,22 +15,27 @@
#include "lib/res/graphics/unifont.h"
#include "lib/timer.h"
#include "maths/MathUtil.h"
-#include "ps/Globals.h"
#include "network/NetMessage.h"
+#include "ps/CConsole.h"
+#include "ps/Game.h"
+#include "ps/Globals.h"
+#include "ps/Hotkey.h"
#include "ps/Player.h"
#include "ps/VFSUtil.h"
#include "ps/World.h"
#include "renderer/Renderer.h"
#include "scripting/GameEvents.h"
-#include "simulation/EntityTemplateCollection.h"
#include "simulation/BoundingObjects.h"
#include "simulation/Collision.h"
#include "simulation/Entity.h"
#include "simulation/EntityFormation.h"
#include "simulation/EntityManager.h"
+#include "simulation/EntityTemplate.h"
+#include "simulation/EntityTemplateCollection.h"
+#include "simulation/EventHandlers.h"
#include "simulation/FormationManager.h"
-#include "simulation/TerritoryManager.h"
#include "simulation/Simulation.h"
+#include "simulation/TerritoryManager.h"
#include "ps/CLogger.h"
#define LOG_CATEGORY "world"
@@ -1294,7 +1296,7 @@ InReaction interactInputHandler( const SDL_Event_* ev )
{
int deltax = ev->ev.motion.x - button_down_x;
int deltay = ev->ev.motion.y - button_down_y;
- if( ABS( deltax ) > 2 || ABS( deltay ) > 2 )
+ if( abs( deltax ) > 2 || abs( deltay ) > 2 )
g_Mouseover.startBandbox( button_down_x, button_down_y );
}
break;
@@ -1384,9 +1386,9 @@ bool CBuildingPlacer::activate(CStrW& templateName)
void CBuildingPlacer::mousePressed()
{
- CCamera &g_Camera=*g_Game->GetView()->GetCamera();
+ CCamera &camera=*g_Game->GetView()->GetCamera();
if( m_template->m_socket == L"" )
- clickPos = g_Camera.GetWorldCoordinates();
+ clickPos = camera.GetWorldCoordinates();
m_clicked = true;
}
@@ -1430,8 +1432,8 @@ void CBuildingPlacer::update( float timeStep )
{
// Rotate object
m_timeSinceClick += timeStep;
- CCamera &g_Camera=*g_Game->GetView()->GetCamera();
- CVector3D mousePos = g_Camera.GetWorldCoordinates();
+ CCamera &camera = *g_Game->GetView()->GetCamera();
+ CVector3D mousePos = camera.GetWorldCoordinates();
CVector3D dif = mousePos - clickPos;
float x = dif.X, z = dif.Z;
if(x*x + z*z < 3*3) {
@@ -1454,8 +1456,8 @@ void CBuildingPlacer::update( float timeStep )
}
else
{
- CCamera &g_Camera=*g_Game->GetView()->GetCamera();
- pos = g_Camera.GetWorldCoordinates();
+ CCamera &camera = *g_Game->GetView()->GetCamera();
+ pos = camera.GetWorldCoordinates();
}
bool onSocket = false;
diff --git a/source/ps/KeyName.cpp b/source/ps/KeyName.cpp
index cb4b1a3e64..37e80886e2 100644
--- a/source/ps/KeyName.cpp
+++ b/source/ps/KeyName.cpp
@@ -288,7 +288,6 @@ void initKeyNameMap()
SKeycodeMapping* it = keycodeMapping;
while( it->keycode != 0 )
{
- debug_printf("adding key %s\n", it->keyname);
keymap.insert( std::pair( CStr( it->keyname ).LowerCase(), it->keycode ) );
if( it->altkeyname )
keymap.insert( std::pair( CStr( it->altkeyname ).LowerCase(), it->keycode ) );
diff --git a/source/renderer/PatchRData.cpp b/source/renderer/PatchRData.cpp
index d43a094032..7f50becadb 100644
--- a/source/renderer/PatchRData.cpp
+++ b/source/renderer/PatchRData.cpp
@@ -412,38 +412,54 @@ void CPatchRData::Update()
CTerrain* terrain=m_Patch->m_Parent;
int mapSize=terrain->GetVerticesPerSide();
- CLOSManager* losMgr = g_Game->GetWorld()->GetLOSManager();
int vsize=PATCH_SIZE+1;
- // this is very similar to BuildVertices(), but just for color
- for (int j=0;jGetWorld()->GetLOSManager();
- const int DX[] = {1,1,0,0};
- const int DZ[] = {0,1,1,0};
- SColor4ub losMod(255, 255, 255, 255);
+ // this is very similar to BuildVertices(), but just for color
+ for (int j=0;j= 0 && tz >= 0 && tx <= mapSize-2 && tz <= mapSize-2)
+ for(int k=0; k<4; k++)
{
- ELOSStatus s = losMgr->GetStatus(tx, tz, g_Game->GetLocalPlayer());
- if(s==LOS_EXPLORED && losMod.R > 178)
- losMod = SColor4ub(178, 178, 178, 255);
- else if(s==LOS_UNEXPLORED && losMod.R > 0)
- losMod = SColor4ub(0, 0, 0, 255);
- }
- }
+ int tx = ix - DX[k];
+ int tz = iz - DZ[k];
- m_Vertices[v].m_LOSColor = losMod;
+ if(tx >= 0 && tz >= 0 && tx <= mapSize-2 && tz <= mapSize-2)
+ {
+ ELOSStatus s = losMgr->GetStatus(tx, tz, g_Game->GetLocalPlayer());
+ if(s==LOS_EXPLORED && losMod.R > 178)
+ losMod = SColor4ub(178, 178, 178, 255);
+ else if(s==LOS_UNEXPLORED && losMod.R > 0)
+ losMod = SColor4ub(0, 0, 0, 255);
+ }
+ }
+
+ m_Vertices[v].m_LOSColor = losMod;
+ }
}
}
+ else
+ {
+ for (int j = 0; j < vsize; ++j)
+ {
+ for (int i = 0; i < vsize; ++i)
+ {
+ int v = (j*vsize)+i;
+ m_Vertices[v].m_LOSColor = SColor4ub(255, 255, 255, 255);
+ }
+ }
+
+ }
// upload base vertices into their vertex buffer
m_VBBase->m_Owner->UpdateChunkVertices(m_VBBase,m_Vertices);
diff --git a/source/renderer/Renderer.cpp b/source/renderer/Renderer.cpp
index a5ae646b95..776e4eaa22 100644
--- a/source/renderer/Renderer.cpp
+++ b/source/renderer/Renderer.cpp
@@ -705,9 +705,6 @@ void CRenderer::SetFastPlayerColor(bool fast)
// BeginFrame: signal frame start
void CRenderer::BeginFrame()
{
- if(!g_Game || !g_Game->IsGameStarted())
- return;
-
// bump frame counter
m_FrameCounter++;
@@ -1158,9 +1155,6 @@ void CRenderer::RenderRefractions()
// FlushFrame: force rendering of any batched objects
void CRenderer::FlushFrame()
{
- if(!g_Game || !g_Game->IsGameStarted())
- return;
-
oglCheck();
// Prepare model renderers
@@ -1178,7 +1172,8 @@ void CRenderer::FlushFrame()
m->terrainRenderer->PrepareForRendering();
PROFILE_END("prepare terrain");
- if (m_Options.m_Shadows) {
+ if (m_Options.m_Shadows)
+ {
MICROLOG(L"render shadows");
RenderShadowMap();
}
@@ -1189,7 +1184,7 @@ void CRenderer::FlushFrame()
oglCheck();
- if(m_WaterManager->m_RenderWater && m_Options.m_FancyWater)
+ if (m_WaterManager->m_RenderWater && m_Options.m_FancyWater)
{
// render reflected and refracted scenes, then re-clear the screen
RenderReflections();
@@ -1227,7 +1222,7 @@ void CRenderer::FlushFrame()
oglCheck();
// render water
- if (m_WaterManager->m_RenderWater)
+ if (m_WaterManager->m_RenderWater && g_Game)
{
MICROLOG(L"render water");
m->terrainRenderer->RenderWater();
@@ -1247,7 +1242,6 @@ void CRenderer::FlushFrame()
// on all the time, so it might not be worth worrying about.
}
-
// Clean up texture blend mode so particles and other things render OK
// (really this should be cleaned up by whoever set it)
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
@@ -1284,9 +1278,6 @@ void CRenderer::FlushFrame()
// EndFrame: signal frame end
void CRenderer::EndFrame()
{
- if(!g_Game || !g_Game->IsGameStarted())
- return;
-
g_Renderer.SetTexture(0,0);
static bool once=false;
diff --git a/source/renderer/SkyManager.cpp b/source/renderer/SkyManager.cpp
index 84971fe562..4ca3fc8205 100644
--- a/source/renderer/SkyManager.cpp
+++ b/source/renderer/SkyManager.cpp
@@ -205,7 +205,7 @@ void SkyManager::RenderSky()
// Rotate so that the "left" face, which contains the brightest part of each
// skymap, is in the direction of the sun from our light environment
- glRotatef( 90.0f + g_Renderer.GetLightEnv().GetRotation()*180.0f/M_PI, 0.0f, 1.0f, 0.0f );
+ glRotatef( 90.0f + RADTODEG(g_Renderer.GetLightEnv().GetRotation()), 0.0f, 1.0f, 0.0f );
// Distance to draw the faces at
const float D = 2000.0;
diff --git a/source/renderer/TerrainRenderer.cpp b/source/renderer/TerrainRenderer.cpp
index 80f83aa5fb..97b663c68e 100644
--- a/source/renderer/TerrainRenderer.cpp
+++ b/source/renderer/TerrainRenderer.cpp
@@ -132,7 +132,7 @@ void TerrainRenderer::EndFrame()
// Query if patches have been submitted this frame
bool TerrainRenderer::HaveSubmissions()
{
- return m->visiblePatches.size() > 0;
+ return !m->visiblePatches.empty();
}
@@ -332,10 +332,10 @@ void TerrainRenderer::RenderTerrain(ShadowMap* shadow)
glMatrixMode(GL_MODELVIEW);
// restore OpenGL state
- if ( shadow )
+ if (shadow)
{
- if ( shadow->GetUseDepthTexture() )
- g_Renderer.BindTexture(2,0);
+ if (shadow->GetUseDepthTexture())
+ g_Renderer.BindTexture(2,0);
}
g_Renderer.BindTexture(1,0);
diff --git a/source/scripting/ScriptGlue.cpp b/source/scripting/ScriptGlue.cpp
index a6d5d36e45..d19ce15279 100644
--- a/source/scripting/ScriptGlue.cpp
+++ b/source/scripting/ScriptGlue.cpp
@@ -40,6 +40,7 @@
#include "simulation/EntityFormation.h"
#include "simulation/EntityHandles.h"
#include "simulation/EntityManager.h"
+#include "simulation/EntityTemplate.h"
#include "simulation/FormationManager.h"
#include "simulation/LOSManager.h"
#include "simulation/Scheduler.h"
diff --git a/source/scripting/ScriptableComplex.h b/source/scripting/ScriptableComplex.h
index c966048636..2f7e6ba758 100644
--- a/source/scripting/ScriptableComplex.h
+++ b/source/scripting/ScriptableComplex.h
@@ -14,15 +14,15 @@ before, 30+ files had to be recompiled because they #included Entity.h
which #includes ScriptableComplex.h.
*/
+#ifndef SCRIPTABLE_COMPLEX_INCLUDED
+#define SCRIPTABLE_COMPLEX_INCLUDED
+
#include "scripting/ScriptingHost.h"
#include "simulation/ScriptObject.h"
#include "JSConversions.h"
#include
-#ifndef SCRIPTABLE_COMPLEX_INCLUDED
-#define SCRIPTABLE_COMPLEX_INCLUDED
-
class IJSComplex;
class IJSComplexProperty
@@ -285,5 +285,3 @@ extern void* jscomplexproperty_suballoc();
extern void jscomplexproperty_suballoc_free(IJSComplexProperty* p);
#endif
-
-
diff --git a/source/scripting/ScriptableComplex.inl b/source/scripting/ScriptableComplex.inl
index 73a0d8efea..191600b06e 100644
--- a/source/scripting/ScriptableComplex.inl
+++ b/source/scripting/ScriptableComplex.inl
@@ -52,6 +52,7 @@ linker won't find the definitions of these functions. Right now this is only
#ifndef SCRIPTABLE_COMPLEX_INL_INCLUDED
#define SCRIPTABLE_COMPLEX_INL_INCLUDED
+#include "ScriptableComplex.h"
//-----------------------------------------------------------------------------
// CJSComplexPropertyAccessor
diff --git a/source/simulation/Collision.cpp b/source/simulation/Collision.cpp
index fe7bf25453..520780bb91 100644
--- a/source/simulation/Collision.cpp
+++ b/source/simulation/Collision.cpp
@@ -3,6 +3,7 @@
#include "Collision.h"
#include "Entity.h"
#include "EntityManager.h"
+#include "EntityTemplate.h"
#include
diff --git a/source/simulation/Entity.cpp b/source/simulation/Entity.cpp
index 26f87e2a51..9c9d2f1b5a 100644
--- a/source/simulation/Entity.cpp
+++ b/source/simulation/Entity.cpp
@@ -1,36 +1,36 @@
-// Last modified: May 15 2004, Mark Thompson (mark@wildfiregames.com)
-
#include "precompiled.h"
-#include "ps/Profile.h"
-
-#include "Entity.h"
-#include "EntityManager.h"
-#include "EntityTemplateCollection.h"
-#include "graphics/Unit.h"
-#include "Aura.h"
-#include "ProductionQueue.h"
-#include "renderer/Renderer.h"
-#include "graphics/Model.h"
-#include "graphics/Terrain.h"
-#include "ps/Interact.h"
-#include "Collision.h"
-#include "PathfindEngine.h"
-#include "ps/Game.h"
-#include "maths/scripting/JSInterface_Vector3D.h"
-#include "maths/MathUtil.h"
-#include "ps/CConsole.h"
-#include "renderer/WaterManager.h"
-#include "EntityFormation.h"
-#include "FormationManager.h"
-#include "TerritoryManager.h"
-#include "Formation.h"
-#include "TechnologyCollection.h"
#include "graphics/GameView.h"
+#include "graphics/Model.h"
#include "graphics/Sprite.h"
+#include "graphics/Terrain.h"
+#include "graphics/Unit.h"
#include "graphics/UnitManager.h"
+#include "maths/MathUtil.h"
+#include "maths/scripting/JSInterface_Vector3D.h"
+#include "ps/CConsole.h"
+#include "ps/Game.h"
+#include "ps/Interact.h"
+#include "ps/Profile.h"
+#include "renderer/Renderer.h"
+#include "renderer/WaterManager.h"
#include "scripting/ScriptableComplex.inl"
+#include "Aura.h"
+#include "Collision.h"
+#include "Entity.h"
+#include "EntityFormation.h"
+#include "EntityManager.h"
+#include "EntityTemplate.h"
+#include "EntityTemplateCollection.h"
+#include "EventHandlers.h"
+#include "Formation.h"
+#include "FormationManager.h"
+#include "PathfindEngine.h"
+#include "ProductionQueue.h"
+#include "TechnologyCollection.h"
+#include "TerritoryManager.h"
+
extern CConsole* g_Console;
extern int g_xres, g_yres;
@@ -467,7 +467,7 @@ void CEntity::update( size_t timestep )
{
if( ( m_lastState != -1 ) || !m_actor->GetModel()->GetAnimation() )
{
- m_actor->SetEntitySelection( L"idle" );
+ m_actor->SetEntitySelection( "idle" );
m_actor->SetRandomAnimation( "idle" );
}
}
@@ -1167,14 +1167,14 @@ void CEntity::renderAuras()
CVector2D CEntity::getScreenCoords( float height )
{
- CCamera &g_Camera=*g_Game->GetView()->GetCamera();
+ CCamera &camera = *g_Game->GetView()->GetCamera();
float sx, sy;
CVector3D above;
above.X = m_position.X;
above.Z = m_position.Z;
above.Y = getAnchorLevel(m_position.X, m_position.Z) + height;
- g_Camera.GetScreenCoordinates(above, sx, sy);
+ camera.GetScreenCoordinates(above, sx, sy);
return CVector2D( sx, sy );
}
@@ -1399,14 +1399,14 @@ void CEntity::renderRank()
if( g_Selection.m_unitUITextures.find( m_rankName ) == g_Selection.m_unitUITextures.end() )
return;
- CCamera *g_Camera=g_Game->GetView()->GetCamera();
+ CCamera *camera = g_Game->GetView()->GetCamera();
float sx, sy;
CVector3D above;
above.X = m_position.X;
above.Z = m_position.Z;
above.Y = getAnchorLevel(m_position.X, m_position.Z) + m_base->m_rankHeight;
- g_Camera->GetScreenCoordinates(above, sx, sy);
+ camera->GetScreenCoordinates(above, sx, sy);
int size = m_base->m_rankWidth/2;
float x1 = sx + m_base->m_healthBarSize/2;
@@ -1853,7 +1853,7 @@ bool CEntity::Kill( JSContext* UNUSED(cx), uintN UNUSED(argc), jsval* UNUSED(arg
if( m_actor )
{
- m_actor->SetEntitySelection( L"death" );
+ m_actor->SetEntitySelection( "death" );
m_actor->SetRandomAnimation( "death", true );
}
diff --git a/source/simulation/Entity.h b/source/simulation/Entity.h
index d3bf44ca5f..988457ed2a 100644
--- a/source/simulation/Entity.h
+++ b/source/simulation/Entity.h
@@ -38,13 +38,8 @@
#include "scripting/DOMEvent.h"
#include "scripting/ScriptCustomTypes.h"
-// JW: must be pulled in because CEntity no longer mirrors CEntityTemplate exactly.
-// some fields have been moved out of CEntity and are accessed via m_base,
-// so CEntityTemplate must be fully defined.
-#include "EntityTemplate.h"
-
class CAura;
-//class CEntityTemplate; // see comment above
+class CEntityTemplate;
class CBoundingObject;
class CPlayer;
class CProductionQueue;
diff --git a/source/simulation/EntityManager.cpp b/source/simulation/EntityManager.cpp
index 392d4b59af..022d833234 100644
--- a/source/simulation/EntityManager.cpp
+++ b/source/simulation/EntityManager.cpp
@@ -3,6 +3,7 @@
#include "EntityManager.h"
#include "EntityTemplateCollection.h"
+#include "EntityTemplate.h"
#include "ps/ConfigDB.h"
#include "ps/Profile.h"
#include "graphics/Terrain.h"
diff --git a/source/simulation/EntityManager.h b/source/simulation/EntityManager.h
index 09228e12c9..5210de459d 100644
--- a/source/simulation/EntityManager.h
+++ b/source/simulation/EntityManager.h
@@ -24,10 +24,11 @@
#include "EntityMessage.h"
#include "ps/Game.h"
#include "ps/World.h"
-#include "ps/CStr.h"
#include "maths/Vector3D.h"
class CEntityTemplate;
+class CPlayer;
+class CStrW;
#define MAX_HANDLES 4096
diff --git a/source/simulation/EntityStateProcessing.cpp b/source/simulation/EntityStateProcessing.cpp
index b77aa871bb..67c81fa689 100644
--- a/source/simulation/EntityStateProcessing.cpp
+++ b/source/simulation/EntityStateProcessing.cpp
@@ -4,6 +4,7 @@
#include "Entity.h"
#include "EntityTemplate.h"
+#include "EventHandlers.h"
#include "graphics/Model.h"
#include "graphics/ObjectEntry.h"
#include "graphics/SkeletonAnim.h"
@@ -406,7 +407,7 @@ bool CEntity::processContactActionNoPathing( CEntityOrder* current, size_t times
popOrder();
entf_clear(ENTF_IS_RUNNING);
entf_clear(ENTF_SHOULD_RUN);
- m_actor->SetEntitySelection( L"idle" );
+ m_actor->SetEntitySelection( "idle" );
m_actor->SetRandomAnimation( "idle" );
return( false );
}
diff --git a/source/simulation/EntitySupport.h b/source/simulation/EntitySupport.h
index c7475f7e7c..064ffd0a6f 100644
--- a/source/simulation/EntitySupport.h
+++ b/source/simulation/EntitySupport.h
@@ -4,7 +4,6 @@
#define ENTITY_SUPPORT_INCLUDED
#include "EntityHandles.h"
-#include "ScriptObject.h"
class CEntityManager;
diff --git a/source/simulation/EntityTemplate.h b/source/simulation/EntityTemplate.h
index b8250eda05..7287e9551e 100644
--- a/source/simulation/EntityTemplate.h
+++ b/source/simulation/EntityTemplate.h
@@ -21,13 +21,14 @@
#include "graphics/ObjectEntry.h"
#include "scripting/ScriptableComplex.h"
+#include "scripting/DOMEvent.h"
#include "BoundingObjects.h"
-#include "EventHandlers.h"
#include "EntitySupport.h"
#include "ScriptObject.h"
-#include "ps/XML/Xeromyces.h"
class CPlayer;
+class CXeromyces;
+class XMBElement;
class CEntityTemplate : public CJSComplex, public IEventTarget
{
diff --git a/source/simulation/EntityTemplateCollection.cpp b/source/simulation/EntityTemplateCollection.cpp
index ee2e78b1a0..e7e67f71b3 100644
--- a/source/simulation/EntityTemplateCollection.cpp
+++ b/source/simulation/EntityTemplateCollection.cpp
@@ -1,6 +1,7 @@
#include "precompiled.h"
#include "EntityTemplateCollection.h"
+#include "EntityTemplate.h"
#include "graphics/ObjectManager.h"
#include "graphics/Model.h"
#include "ps/CLogger.h"
diff --git a/source/simulation/EntityTemplateCollection.h b/source/simulation/EntityTemplateCollection.h
index cc5afe496b..5d1f2ada40 100644
--- a/source/simulation/EntityTemplateCollection.h
+++ b/source/simulation/EntityTemplateCollection.h
@@ -20,16 +20,18 @@
#include