From 3ed03fee2ffca36cd767c3b69796d1d0b9d7ba21 Mon Sep 17 00:00:00 2001 From: athile Date: Tue, 22 Jun 2010 18:13:16 -0700 Subject: [PATCH] Fix lighting defect and VS8 compiler warnings. --- esm/loadcell.hpp | 3 ++- esm/loadlevlist.hpp | 2 +- esm/loadscpt.hpp | 2 +- esm_store/cell_store.hpp | 3 ++- game/mwrender/cell.cpp | 15 ++++++++------- game/mwrender/interior.cpp | 2 +- input/func_binder.hpp | 15 ++++++++++----- input/listener.hpp | 2 +- 8 files changed, 26 insertions(+), 18 deletions(-) diff --git a/esm/loadcell.hpp b/esm/loadcell.hpp index dcb255949..c4641a57b 100644 --- a/esm/loadcell.hpp +++ b/esm/loadcell.hpp @@ -11,8 +11,9 @@ namespace ESM { loading process, but are rather loaded later on demand when we are setting up a specific cell. */ -struct CellRef +class CellRef { +public: int refnum; // Reference number std::string refID; // ID of object being referenced diff --git a/esm/loadlevlist.hpp b/esm/loadlevlist.hpp index 046fd91ef..8b0ae45b2 100644 --- a/esm/loadlevlist.hpp +++ b/esm/loadlevlist.hpp @@ -60,7 +60,7 @@ struct LeveledListBase // items. Also, some times we don't want to merge lists, just // overwrite. Figure out a way to give the user this option. - for(int i=0; i& live cellRender.insertBegin (liveRef.ref); cellRender.insertMesh ("meshes\\" + model); - - int color = liveRef.base->data.color; - - cellRender.insertLight(color & 255, - (color >> 8) & 255, - (color >> 16) & 255, - liveRef.base->data.radius); + + // Extract the color and convert to floating point + const int color = liveRef.base->data.color; + const float r = ((color >> 0) & 0xFF) / 255.0f; + const float g = ((color >> 8) & 0xFF) / 255.0f; + const float b = ((color >> 16) & 0xFF) / 255.0f; + const float radius = float(liveRef.base->data.radius); + cellRender.insertLight(r, g, b, radius); cellRender.insertEnd(); } diff --git a/game/mwrender/interior.cpp b/game/mwrender/interior.cpp index 22c39423e..684e7cf63 100644 --- a/game/mwrender/interior.cpp +++ b/game/mwrender/interior.cpp @@ -156,7 +156,7 @@ void InteriorCellRender::setAmbientMode() case 1: - scene.getMgr()->setAmbientLight(0.7*ambientColor + 0.3*ColourValue(1,1,1)); + scene.getMgr()->setAmbientLight(0.7f*ambientColor + 0.3f*ColourValue(1,1,1)); break; case 2: diff --git a/input/func_binder.hpp b/input/func_binder.hpp index b70650202..20119b07b 100644 --- a/input/func_binder.hpp +++ b/input/func_binder.hpp @@ -54,7 +54,8 @@ public: */ void bind(int index, Action action, const std::string &name="") { - assert(index >= 0 && index < bindings.size()); + assert(index >= 0 && index < (int)bindings.size()); + FuncBinding &fb = bindings[index]; fb.action = action; fb.name = name; @@ -65,7 +66,8 @@ public: */ void unbind(int index) { - assert(index >= 0 && index < bindings.size()); + assert(index >= 0 && index < (int)bindings.size()); + bindings[index] = FuncBinding(); } @@ -75,7 +77,8 @@ public: */ void call(int index, const void *p=NULL) const { - assert(index >= 0 && index < bindings.size()); + assert(index >= 0 && index < (int)bindings.size()); + const FuncBinding &fb = bindings[index]; if(fb.action) fb.action(index, p); } @@ -83,14 +86,16 @@ public: /// Check if a given index is bound to anything bool isBound(int index) const { - assert(index >= 0 && index < bindings.size()); + assert(index >= 0 && index < (int)bindings.size()); + return !bindings[index].action.empty(); } /// Return the name associated with an action (empty if not bound) const std::string &getName(int index) const { - assert(index >= 0 && index < bindings.size()); + assert(index >= 0 && index < (int)bindings.size()); + return bindings[index].name; } }; diff --git a/input/listener.hpp b/input/listener.hpp index f2a1bff20..5b9d4fb49 100644 --- a/input/listener.hpp +++ b/input/listener.hpp @@ -68,7 +68,7 @@ namespace Input assert(camera); // Mouse sensitivity. Should be a config option later. - const float MS = 0.2; + const float MS = 0.2f; float x = arg.state.X.rel * MS; float y = arg.state.Y.rel * MS;