Some changes suggested by cppcheck

actorid
scrawl 12 years ago
parent 0923306404
commit 7dc30a01cd

@ -141,6 +141,10 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
, mFSStrict (false)
, mScriptConsoleMode (false)
, mCfgMgr(configurationManager)
, mEncoding(ToUTF8::WINDOWS_1252)
, mEncoder(NULL)
, mActivationDistanceOverride(-1)
{
std::srand ( std::time(NULL) );
MWClass::registerClasses();

@ -54,7 +54,7 @@ void validate(boost::any &v, std::vector<std::string> const &tokens, FallbackMap
FallbackMap *map = boost::any_cast<FallbackMap>(&v);
std::map<std::string,std::string>::iterator mapIt;
for(std::vector<std::string>::const_iterator it=tokens.begin(); it != tokens.end(); it++)
for(std::vector<std::string>::const_iterator it=tokens.begin(); it != tokens.end(); ++it)
{
int sep = it->find(",");
if(sep < 1 || sep == (int)it->length()-1)
@ -204,7 +204,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
// fallback archives
StringsVector archives = variables["fallback-archive"].as<StringsVector>();
for (StringsVector::const_iterator it = archives.begin(); it != archives.end(); it++)
for (StringsVector::const_iterator it = archives.begin(); it != archives.end(); ++it)
{
engine.addArchive(*it);
}

@ -376,13 +376,13 @@ namespace MWClass
MWWorld::Store<ESM::SoundGenerator>::iterator sound = store.begin();
while(sound != store.end())
{
if(type == sound->mType && sound->mCreature.size() > 0 &&
if(type == sound->mType && !sound->mCreature.empty() &&
Misc::StringUtils::ciEqual(ptrid.substr(0, sound->mCreature.size()),
sound->mCreature))
sounds.push_back(&*sound);
sound++;
++sound;
}
if(sounds.size() > 0)
if(!sounds.empty())
return sounds[(int)(rand()/(RAND_MAX+1.0)*sounds.size())]->mSound;
}

@ -272,10 +272,10 @@ namespace MWClass
ptr.get<ESM::NPC>();
assert(ref->mBase != NULL);
std::string headID = ref->mBase->mHead;
//std::string headID = ref->mBase->mHead;
int end = headID.find_last_of("head_") - 4;
std::string bodyRaceID = headID.substr(0, end);
//int end = headID.find_last_of("head_") - 4;
//std::string bodyRaceID = headID.substr(0, end);
std::string model = "meshes\\base_anim.nif";
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(ref->mBase->mRace);

@ -172,7 +172,6 @@ namespace MWDialogue
win->addResponse (Interpreter::fixDefinesDialog(info->mResponse, interpreterContext));
executeScript (info->mResultScript);
mLastTopic = Misc::StringUtils::lowerCase(it->mId);
mLastDialogue = *info;
break;
}
}
@ -293,7 +292,6 @@ namespace MWDialogue
executeScript (info->mResultScript);
mLastTopic = topic;
mLastDialogue = *info;
}
else
{
@ -455,7 +453,6 @@ namespace MWDialogue
MWBase::Environment::get().getWindowManager()->getDialogueWindow()->addResponse (Interpreter::fixDefinesDialog(text, interpreterContext));
MWBase::Environment::get().getJournal()->addTopic (mLastTopic, info->mId);
executeScript (info->mResultScript);
mLastDialogue = *info;
}
}
}

@ -31,7 +31,6 @@ namespace MWDialogue
int mChoice;
std::string mLastTopic;
ESM::DialInfo mLastDialogue;
bool mIsInChoice;
float mTemporaryDispositionChange;

@ -47,6 +47,8 @@ namespace MWGui
, mIngredients (4)
, mSortModel(NULL)
{
mAlchemy.setAlchemist (MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
getWidget(mCreateButton, "CreateButton");
getWidget(mCancelButton, "CancelButton");
getWidget(mIngredients[0], "Ingredient1");
@ -150,8 +152,6 @@ namespace MWGui
mNameEdit->setCaption("");
mAlchemy.setAlchemist (MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
int index = 0;
for (MWMechanics::Alchemy::TToolsIterator iter (mAlchemy.beginTools());

@ -108,7 +108,7 @@ struct TypesetBookImpl : TypesetBook
{
Contents::iterator i = mContents.insert (mContents.end (), Content (text.first, text.second));
if (i->size () == 0)
if (i->empty())
return Range (Utf8Point (NULL), Utf8Point (NULL));
Utf8Point begin = &i->front ();
@ -768,6 +768,11 @@ public:
PageDisplay ()
{
mPage = -1;
mViewTop = 0;
mViewBottom = 0;
mFocusItem = NULL;
mItemActive = false;
mNode = NULL;
}
void dirtyFocusItem ()
@ -1093,7 +1098,6 @@ class BookPageImpl : public BookPage
MYGUI_RTTI_DERIVED(BookPage)
public:
void showPage (TypesetBook::Ptr book, size_t page)
{
if (PageDisplay* pd = dynamic_cast <PageDisplay*> (getSubWidgetText ()))

@ -19,6 +19,7 @@ namespace MWGui
: WindowBase("openmw_book.layout")
, mTakeButtonShow(true)
, mTakeButtonAllowed(true)
, mCurrentPage(0)
{
getWidget(mCloseButton, "CloseButton");
mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onCloseButtonClicked);

@ -70,6 +70,9 @@ namespace MWGui
, mGenerateClassStep(0)
{
mCreationStage = CSE_NotStarted;
mGenerateClassSpecializations[0] = 0;
mGenerateClassSpecializations[1] = 0;
mGenerateClassSpecializations[2] = 0;
}
void CharacterCreation::setValue (const std::string& id, const MWMechanics::Stat<int>& value)

@ -372,6 +372,8 @@ namespace MWGui
, mAttribDialog(NULL)
, mSkillDialog(NULL)
, mDescDialog(NULL)
, mAffectedAttribute(NULL)
, mAffectedSkill(NULL)
{
// Centre dialog
center();
@ -718,6 +720,7 @@ namespace MWGui
SelectAttributeDialog::SelectAttributeDialog()
: WindowModal("openmw_chargen_select_attribute.layout")
, mAttributeId(ESM::Attribute::Strength)
{
// Centre dialog
center();

@ -217,7 +217,7 @@ namespace MWGui
mCommandLine->setCaption(complete( mCommandLine->getCaption(), matches ));
#if 0
int i = 0;
for(std::vector<std::string>::iterator it=matches.begin(); it < matches.end(); it++,i++ )
for(std::vector<std::string>::iterator it=matches.begin(); it < matches.end(); ++it,++i )
{
printOK( *it );
if( i == 50 )
@ -237,7 +237,7 @@ namespace MWGui
if(mCurrent != mCommandHistory.begin())
{
mCurrent--;
--mCurrent;
mCommandLine->setCaption(*mCurrent);
}
}
@ -245,7 +245,7 @@ namespace MWGui
{
if(mCurrent != mCommandHistory.end())
{
mCurrent++;
--mCurrent;
if(mCurrent != mCommandHistory.end())
mCommandLine->setCaption(*mCurrent);
@ -333,7 +333,7 @@ namespace MWGui
continue;
/* Is the beginning of the string different from the input string? If yes skip it. */
for( std::string::iterator iter=tmp.begin(), iter2=(*it).begin(); iter < tmp.end();iter++, iter2++) {
for( std::string::iterator iter=tmp.begin(), iter2=(*it).begin(); iter < tmp.end();++iter, ++iter2) {
if( tolower(*iter) != tolower(*iter2) ) {
string_different=true;
break;
@ -372,7 +372,7 @@ namespace MWGui
/* Check if all matching strings match further than input. If yes complete to this match. */
int i = tmp.length();
for(std::string::iterator iter=matches.front().begin()+tmp.length(); iter < matches.front().end(); iter++, i++) {
for(std::string::iterator iter=matches.front().begin()+tmp.length(); iter < matches.front().end(); ++iter, ++i) {
for(std::vector<std::string>::iterator it=matches.begin(); it < matches.end();++it) {
if( tolower((*it)[i]) != tolower(*iter) ) {
/* Append the longest match to the end of the output string*/

@ -78,7 +78,7 @@ namespace
return string.getChar(0);
}
bool is_not_empty(const std::string s) {
bool is_not_empty(const std::string& s) {
std::string temp = s;
boost::algorithm::trim(temp);
return !temp.empty();

@ -36,6 +36,7 @@ namespace MWGui
, mPreview(MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer ())
, mPreviewDirty(true)
, mDragAndDrop(dragAndDrop)
, mSelectedItem(-1)
{
static_cast<MyGUI::Window*>(mMainWidget)->eventWindowChangeCoord += MyGUI::newDelegate(this, &InventoryWindow::onWindowResize);

@ -9,6 +9,8 @@ namespace MWGui
ItemSelectionDialog::ItemSelectionDialog(const std::string &label)
: WindowModal("openmw_itemselection_dialog.layout")
, mSortModel(NULL)
, mModel(NULL)
{
getWidget(mItemView, "ItemView");
mItemView->eventItemClicked += MyGUI::newDelegate(this, &ItemSelectionDialog::onSelectedItem);

@ -32,6 +32,7 @@ namespace MWGui
ItemView::ItemView()
: mModel(NULL)
, mScrollView(NULL)
{
}

@ -101,7 +101,7 @@ public:
candidates.push_back(std::make_pair((j-i), candidate));
}
if (!candidates.size())
if (candidates.empty())
continue; // didn't match enough to disambiguate, on to next character
// shorter candidates will be added to the vector first. however, we want to check against longer candidates first

@ -24,6 +24,10 @@ namespace MWGui
, mLastWallpaperChangeTime(0.f)
, mFirstLoad(true)
, mTotalRefsLoading(0)
, mCurrentCellLoading(0)
, mTotalCellsLoading(0)
, mCurrentRefLoading(0)
, mCurrentRefList(0)
{
getWidget(mLoadingText, "LoadingText");
getWidget(mProgressBar, "ProgressBar");

@ -89,9 +89,6 @@ namespace MWGui
{
for (int my=0; my<3; ++my)
{
std::string name = "Map_" + boost::lexical_cast<std::string>(mx) + "_"
+ boost::lexical_cast<std::string>(my);
std::string image = mPrefix+"_"+ boost::lexical_cast<std::string>(mCurX + (mx-1)) + "_"
+ boost::lexical_cast<std::string>(mCurY + (-1*(my-1)));
MyGUI::ImageBox* fog = mFogWidgets[my + 3*mx];
@ -135,9 +132,6 @@ namespace MWGui
std::string image = mPrefix+"_"+ boost::lexical_cast<std::string>(x + (mx-1)) + "_"
+ boost::lexical_cast<std::string>(y + (-1*(my-1)));
std::string name = "Map_" + boost::lexical_cast<std::string>(mx) + "_"
+ boost::lexical_cast<std::string>(my);
MyGUI::ImageBox* box = mMapWidgets[my + 3*mx];
if (MyGUI::RenderManager::getInstance().getTexture(image) != 0)

@ -49,7 +49,7 @@ namespace MWGui
else {
(*it2)->update(height);
height += (*it2)->getHeight();
it2++;
++it2;
}
}
}
@ -57,7 +57,7 @@ namespace MWGui
}
else
{
it++;
++it;
}
}
@ -226,6 +226,7 @@ namespace MWGui
: WindowModal("openmw_interactive_messagebox.layout")
, mMessageBoxManager(parMessageBoxManager)
, mButtonPressed(-1)
, mTextButtonPadding(0)
{
WindowModal::open();

@ -44,6 +44,7 @@ namespace MWGui
, mAssignDialog(0)
, mItemSelectionDialog(0)
, mMagicSelectionDialog(0)
, mSelectedIndex(-1)
{
getWidget(mOkButton, "OKButton");
getWidget(mInstructionLabel, "InstructionLabel");

@ -33,6 +33,7 @@ namespace MWGui
, mHairIndex(0)
, mCurrentAngle(0)
, mPreviewDirty(true)
, mPreview(NULL)
{
// Centre dialog
center();

@ -18,7 +18,6 @@ namespace MWGui
ReviewDialog::ReviewDialog()
: WindowModal("openmw_chargen_review.layout")
, mLastPos(0)
{
// Centre dialog
center();
@ -321,9 +320,7 @@ namespace MWGui
if (!mMiscSkills.empty())
addSkills(mMiscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2);
mClientHeight = coord1.top;
mSkillView->setCanvasSize (mSkillView->getWidth(), std::max(mSkillView->getHeight(), mClientHeight));
mSkillView->setCanvasSize (mSkillView->getWidth(), std::max(mSkillView->getHeight(), coord1.top));
}
// widget controls

@ -79,7 +79,6 @@ namespace MWGui
MyGUI::TextBox *mNameWidget, *mRaceWidget, *mClassWidget, *mBirthSignWidget;
MyGUI::ScrollView* mSkillView;
int mLastPos, mClientHeight;
Widgets::MWDynamicStatPtr mHealth, mMagicka, mFatigue;

@ -139,7 +139,7 @@ namespace MWGui
if (adjustSize)
{
int s = effects.size() * 16+4;
if (!effects.size())
if (effects.empty())
s = 0;
int diff = parent->getWidth() - s;
parent->setSize(s, parent->getHeight());

@ -22,7 +22,11 @@ namespace MWGui
// information about a single magic effect source as required for display in the tooltip
struct MagicEffectInfo
{
MagicEffectInfo() : mPermanent(false) {}
MagicEffectInfo()
: mPermanent(false)
, mMagnitude(0)
, mRemainingTime(0)
{}
std::string mSource; // display name for effect source (e.g. potion name)
MWMechanics::EffectKey mKey;
int mMagnitude;

@ -21,7 +21,6 @@ namespace MWGui
StatsWindow::StatsWindow ()
: WindowPinnableBase("openmw_stats_window.layout")
, mSkillView(NULL)
, mClientHeight(0)
, mMajorSkills()
, mMinorSkills()
, mMiscSkills()
@ -82,7 +81,7 @@ namespace MWGui
{
mLeftPane->setCoord( MyGUI::IntCoord(0, 0, 0.44*window->getSize().width, window->getSize().height) );
mRightPane->setCoord( MyGUI::IntCoord(0.44*window->getSize().width, 0, 0.56*window->getSize().width, window->getSize().height) );
mSkillView->setCanvasSize (mSkillView->getWidth(), std::max(mSkillView->getHeight(), mClientHeight));
mSkillView->setCanvasSize (mSkillView->getWidth(), mSkillView->getCanvasSize().height);
}
void StatsWindow::setBar(const std::string& name, const std::string& tname, int val, int max)
@ -422,7 +421,6 @@ namespace MWGui
mSkillWidgets.clear();
mSkillView->setViewOffset (MyGUI::IntPoint(0,0));
mClientHeight = 0;
const int valueSize = 40;
MyGUI::IntCoord coord1(10, 0, mSkillView->getWidth() - (10 + valueSize) - 24, 18);
@ -565,9 +563,7 @@ namespace MWGui
mSkillWidgets[mSkillWidgets.size()-1-i]->setUserString("Caption_Text", "#{sCrimeHelp}");
}
mClientHeight = coord1.top;
mSkillView->setCanvasSize (mSkillView->getWidth(), std::max(mSkillView->getHeight(), mClientHeight));
mSkillView->setCanvasSize (mSkillView->getWidth(), std::max(mSkillView->getHeight(), coord1.top));
}
void StatsWindow::onPinToggled()

@ -57,7 +57,6 @@ namespace MWGui
MyGUI::Widget* mRightPane;
MyGUI::ScrollView* mSkillView;
int mLastPos, mClientHeight;
SkillList mMajorSkills, mMinorSkills, mMiscSkills;
std::map<int, MWMechanics::Stat<float> > mSkillValues;

@ -149,7 +149,6 @@ namespace MWGui
}
std::string type = focus->getUserString("ToolTipType");
std::string text = focus->getUserString("ToolTipText");
if (type == "")
{

@ -36,6 +36,9 @@ namespace MWGui
, mBalanceButtonsState(BBS_None)
, mBalanceChangePause(0.0)
, mItemToSell(-1)
, mTradeModel(NULL)
, mSortModel(NULL)
, mCurrentMerchantOffer(0)
{
getWidget(mFilterAll, "AllButton");
getWidget(mFilterWeapon, "WeaponButton");

@ -47,6 +47,8 @@ namespace MWGui
, mSleeping(false)
, mHours(1)
, mRemainingTime(0.05)
, mCurHour(0)
, mManualHours(1)
{
getWidget(mDateTimeText, "DateTimeText");
getWidget(mRestText, "RestText");

@ -899,6 +899,7 @@ namespace MWGui
: mEnableRepeat(true)
, mRepeatTriggerTime(0.5)
, mRepeatStepTime(0.1)
, mIsIncreasing(true)
{
}

@ -29,6 +29,8 @@ namespace MWMechanics
{
AiEscort::AiEscort(const std::string &actorId, int duration, float x, float y, float z)
: mActorId(actorId), mX(x), mY(y), mZ(z), mDuration(duration)
, cellX(std::numeric_limits<int>::max())
, cellY(std::numeric_limits<int>::max())
{
mMaxDist = 470;
@ -46,6 +48,8 @@ namespace MWMechanics
AiEscort::AiEscort(const std::string &actorId, const std::string &cellId,int duration, float x, float y, float z)
: mActorId(actorId), mCellId(cellId), mX(x), mY(y), mZ(z), mDuration(duration)
, cellX(std::numeric_limits<int>::max())
, cellY(std::numeric_limits<int>::max())
{
mMaxDist = 470;

@ -21,6 +21,8 @@ namespace MWMechanics
{
AiTravel::AiTravel(float x, float y, float z)
: mX(x),mY(y),mZ(z),mPathFinder()
, cellX(std::numeric_limits<int>::max())
, cellY(std::numeric_limits<int>::max())
{
}

@ -24,6 +24,13 @@ namespace MWMechanics
{
AiWander::AiWander(int distance, int duration, int timeOfDay, const std::vector<int>& idle, bool repeat):
mDistance(distance), mDuration(duration), mTimeOfDay(timeOfDay), mIdle(idle), mRepeat(repeat)
, mCellX(std::numeric_limits<int>::max())
, mCellY(std::numeric_limits<int>::max())
, mXCell(0)
, mYCell(0)
, mX(0)
, mY(0)
, mZ(0)
{
for(unsigned short counter = 0; counter < mIdle.size(); counter++)
{

@ -699,7 +699,7 @@ void CharacterController::update(float duration, Movement &movement)
if(movestate != CharState_None)
clearAnimQueue();
if(mAnimQueue.size() == 0)
if(mAnimQueue.empty())
idlestate = (inwater ? CharState_IdleSwim : (sneak ? CharState_IdleSneak : CharState_Idle));
else if(mAnimQueue.size() > 1)
{
@ -765,7 +765,7 @@ void CharacterController::playGroup(const std::string &groupname, int mode, int
else
{
count = std::max(count, 1);
if(mode != 0 || mAnimQueue.size() == 0)
if(mode != 0 || mAnimQueue.empty())
{
clearAnimQueue();
mAnimQueue.push_back(std::make_pair(groupname, count-1));
@ -801,7 +801,7 @@ bool CharacterController::isAnimPlaying(const std::string &groupName)
void CharacterController::clearAnimQueue()
{
if(mAnimQueue.size() > 0)
if(!mAnimQueue.empty())
mAnimation->disable(mAnimQueue.front().first);
mAnimQueue.clear();
}

@ -13,7 +13,7 @@ namespace MWMechanics
: mLevel (0), mLevelHealthBonus(0.f), mDead (false), mDied (false), mFriendlyHits (0),
mTalkedTo (false), mAlarmed (false),
mAttacked (false), mHostile (false),
mAttackingOrSpell(false)
mAttackingOrSpell(false), mAttackType(AT_Chop)
{
for (int i=0; i<4; ++i)
mAiSettings[i] = 0;

@ -11,8 +11,10 @@
namespace MWMechanics
{
Enchanting::Enchanting():
mCastStyle(ESM::Enchantment::CastOnce)
Enchanting::Enchanting()
: mCastStyle(ESM::Enchantment::CastOnce)
, mSelfEnchanting(false)
, mOldItemCount(0)
{}
void Enchanting::setOldItem(MWWorld::Ptr oldItem)

@ -416,7 +416,7 @@ namespace MWMechanics
if (playerNpcStats.getFactionRanks().find(Misc::StringUtils::lowerCase(npcFaction)) != playerNpcStats.getFactionRanks().end())
{
for(std::vector<ESM::Faction::Reaction>::const_iterator it = MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(Misc::StringUtils::lowerCase(npcFaction))->mReactions.begin();
it != MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(Misc::StringUtils::lowerCase(npcFaction))->mReactions.end(); it++)
it != MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(Misc::StringUtils::lowerCase(npcFaction))->mReactions.end(); ++it)
{
if(Misc::StringUtils::lowerCase(it->mFaction) == Misc::StringUtils::lowerCase(npcFaction)) reaction = it->mReaction;
}
@ -425,7 +425,7 @@ namespace MWMechanics
else if (npcFaction != "")
{
for(std::vector<ESM::Faction::Reaction>::const_iterator it = MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(Misc::StringUtils::lowerCase(npcFaction))->mReactions.begin();
it != MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(Misc::StringUtils::lowerCase(npcFaction))->mReactions.end();it++)
it != MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(Misc::StringUtils::lowerCase(npcFaction))->mReactions.end();++it)
{
if(playerNpcStats.getFactionRanks().find(Misc::StringUtils::lowerCase(it->mFaction)) != playerNpcStats.getFactionRanks().end() )
{

@ -119,7 +119,7 @@ namespace
boost::predecessor_map(&p[0]).distance_map(&d[0]).visitor(goalVisited(end)));
}
catch(found_path fg)
catch(found_path& fg)
{
for(PointID v = end; ; v = p[v])
{

@ -31,6 +31,7 @@ namespace MWRender
Actors(OEngine::Render::OgreRenderer& _rend, MWRender::RenderingManager* rendering)
: mRend(_rend)
, mRendering(rendering)
, mRootNode(NULL)
{}
~Actors();

@ -74,7 +74,7 @@ Animation::~Animation()
void Animation::setObjectRoot(Ogre::SceneNode *node, const std::string &model, bool baseonly)
{
OgreAssert(mAnimSources.size() == 0, "Setting object root while animation sources are set!");
OgreAssert(mAnimSources.empty(), "Setting object root while animation sources are set!");
if(!mInsert)
mInsert = node->createChildSceneNode();
@ -126,7 +126,7 @@ void Animation::setObjectRoot(Ogre::SceneNode *node, const std::string &model, b
else
{
mSkelBase->attachObjectToBone(iter->second, iter->first);
iter++;
++iter;
}
}
}
@ -214,7 +214,7 @@ void Animation::addAnimSource(const std::string &model)
std::vector<Ogre::Controller<Ogre::Real> > ctrls;
Ogre::SharedPtr<AnimSource> animsrc(OGRE_NEW AnimSource);
NifOgre::Loader::createKfControllers(mSkelBase, kfname, animsrc->mTextKeys, ctrls);
if(animsrc->mTextKeys.size() == 0 || ctrls.size() == 0)
if(animsrc->mTextKeys.empty() || ctrls.empty())
return;
mAnimSources.push_back(animsrc);
@ -497,7 +497,7 @@ bool Animation::reset(AnimState &state, const NifOgre::TextKeyMap &keys, const s
void Animation::handleTextKey(AnimState &state, const std::string &groupname, const NifOgre::TextKeyMap::const_iterator &key)
{
float time = key->first;
//float time = key->first;
const std::string &evt = key->second;
if(evt.compare(0, 7, "sound: ") == 0)
@ -550,7 +550,7 @@ void Animation::handleTextKey(AnimState &state, const std::string &groupname, co
void Animation::play(const std::string &groupname, int priority, int groups, bool autodisable, float speedmult, const std::string &start, const std::string &stop, float startpoint, size_t loops)
{
if(!mSkelBase || mAnimSources.size() == 0)
if(!mSkelBase || mAnimSources.empty())
return;
if(groupname.empty())
@ -567,7 +567,7 @@ void Animation::play(const std::string &groupname, int priority, int groups, boo
if(stateiter->second.mPriority == priority)
mStates.erase(stateiter++);
else
stateiter++;
++stateiter;
}
stateiter = mStates.find(groupname);
@ -642,7 +642,7 @@ void Animation::resetActiveGroups()
AnimStateMap::const_iterator active = mStates.end();
AnimStateMap::const_iterator state = mStates.begin();
for(;state != mStates.end();state++)
for(;state != mStates.end();++state)
{
if(!(state->second.mGroups&(1<<grp)))
continue;
@ -773,7 +773,7 @@ Ogre::Vector3 Animation::runAnimation(float duration)
resetActiveGroups();
}
else
stateiter++;
++stateiter;
}
for(size_t i = 0;i < mObjectRoot.mControllers.size();i++)

@ -36,6 +36,8 @@ namespace MWRender
mPreviewCam.yaw = 0.f;
mPreviewCam.offset = 400.f;
mMainCam.yaw = 0.f;
mMainCam.offset = 400.f;
}
Camera::~Camera()

@ -22,7 +22,6 @@ namespace MWRender
CharacterPreview::CharacterPreview(MWWorld::Ptr character, int sizeX, int sizeY, const std::string& name,
Ogre::Vector3 position, Ogre::Vector3 lookAt)
: mSceneMgr (0)
, mPosition(position)
, mLookAt(lookAt)
@ -31,6 +30,10 @@ namespace MWRender
, mName(name)
, mSizeX(sizeX)
, mSizeY(sizeY)
, mRenderTarget(NULL)
, mViewport(NULL)
, mCamera(NULL)
, mNode(NULL)
{
}

@ -22,6 +22,8 @@ namespace MWRender
: mCacheDir(cacheDir)
, mMinX(0), mMaxX(0)
, mMinY(0), mMaxY(0)
, mWidth(0)
, mHeight(0)
{
}
@ -91,15 +93,13 @@ namespace MWRender
Ogre::ColourValue mountainColour(0.05, 0.05, 0.05);
Ogre::ColourValue hillColour(0.16, 0.12, 0.08);
float mountainHeight = 15000.f;
float hillHeight = 2500.f;
unsigned char r,g,b;
if (land)
{
float landHeight = land->mLandData->mHeights[vertexY * ESM::Land::LAND_SIZE + vertexX];
const float landHeight = land->mLandData->mHeights[vertexY * ESM::Land::LAND_SIZE + vertexX];
const float mountainHeight = 15000.f;
const float hillHeight = 2500.f;
if (landHeight >= 0)
{

@ -286,7 +286,7 @@ void NpcAnimation::updateParts(bool forceupdate)
{
typedef std::multimap<ESM::BodyPart::MeshPart,ESM::PartReferenceType> BodyPartMapType;
static BodyPartMapType sBodyPartMap;
if(sBodyPartMap.size() == 0)
if(sBodyPartMap.empty())
{
sBodyPartMap.insert(std::make_pair(ESM::BodyPart::MP_Neck, ESM::PRT_Neck));
sBodyPartMap.insert(std::make_pair(ESM::BodyPart::MP_Chest, ESM::PRT_Cuirass));
@ -345,7 +345,7 @@ void NpcAnimation::updateParts(bool forceupdate)
{
if(!parts[bIt->second])
parts[bIt->second] = &*it;
bIt++;
++bIt;
}
}
continue;
@ -354,7 +354,7 @@ void NpcAnimation::updateParts(bool forceupdate)
while(bIt != sBodyPartMap.end() && bIt->first == bodypart.mData.mPart)
{
parts[bIt->second] = &*it;
bIt++;
++bIt;
}
}
}

@ -159,7 +159,7 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh, bool
}
if(!mIsStatic || !Settings::Manager::getBool("use static geometry", "Objects") ||
anyTransparency || objects.mParticles.size() > 0)
anyTransparency || !objects.mParticles.empty())
{
for(size_t i = 0;i < objects.mEntities.size();i++)
{
@ -233,7 +233,7 @@ void Objects::insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh, bool
(*iter)->detachFromParent();
mRenderer.getScene()->destroyEntity(*iter);
iter++;
++iter;
}
}

@ -71,7 +71,12 @@ class Objects{
///< Remove all movable objects from \a node.
public:
Objects(OEngine::Render::OgreRenderer& renderer, MWWorld::Fallback* fallback): mRenderer (renderer), mIsStatic(false), mFallback(fallback) {}
Objects(OEngine::Render::OgreRenderer& renderer, MWWorld::Fallback* fallback)
: mRenderer (renderer)
, mIsStatic(false)
, mFallback(fallback)
, mRootNode(NULL)
{}
~Objects(){}
void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_);
void insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh, bool light=false);

@ -32,7 +32,7 @@ OcclusionQuery::OcclusionQuery(OEngine::Render::OgreRenderer* renderer, SceneNod
mSupported = (mSunTotalAreaQuery != 0) && (mSunVisibleAreaQuery != 0);
}
catch (Ogre::Exception e)
catch (Ogre::Exception& e)
{
mSupported = false;
}

@ -1042,6 +1042,8 @@ VideoPlayer::VideoPlayer(Ogre::SceneManager* sceneMgr, Ogre::RenderWindow* windo
, mNode(NULL)
, mAllowSkipping(false)
, mWindow(window)
, mWidth(0)
, mHeight(0)
{
mVideoMaterial = Ogre::MaterialManager::getSingleton().getByName("VideoMaterial", "General");
if (mVideoMaterial.isNull ())

@ -43,6 +43,8 @@ namespace MWRender {
Reflection(Ogre::SceneManager* sceneManager)
: mSceneMgr(sceneManager)
, mIsUnderwater(false)
, mCamera(NULL)
, mParentCamera(NULL)
{}
virtual ~Reflection() {}

@ -297,7 +297,7 @@ namespace MWScript
std::map<std::string, int> ranks = MWWorld::Class::get (player).getNpcStats (player).getFactionRanks();
if (ranks.size())
if (!ranks.empty())
{
std::map<std::string, int>::const_iterator it = ranks.begin();

@ -225,7 +225,7 @@ struct OpenAL_Output::StreamThread {
if((*iter)->process() == false)
iter = mStreams.erase(iter);
else
iter++;
++iter;
}
mMutex.unlock();
boost::this_thread::sleep(boost::posix_time::milliseconds(50));
@ -797,7 +797,7 @@ ALuint OpenAL_Output::getBuffer(const std::string &fname)
if(nameiter->second == oldbuf)
mBufferCache.erase(nameiter++);
else
nameiter++;
++nameiter;
}
bufsize = 0;
@ -951,9 +951,9 @@ void OpenAL_Output::pauseSounds(int types)
if(sound && sound->mSource && (sound->getPlayType()&types))
sources.push_back(sound->mSource);
}
iter++;
++iter;
}
if(sources.size() > 0)
if(!sources.empty())
{
alSourcePausev(sources.size(), &sources[0]);
throwALerror();
@ -978,9 +978,9 @@ void OpenAL_Output::resumeSounds(int types)
if(sound && sound->mSource && (sound->getPlayType()&types))
sources.push_back(sound->mSource);
}
iter++;
++iter;
}
if(sources.size() > 0)
if(!sources.empty())
{
alSourcePlayv(sources.size(), &sources[0]);
throwALerror();

@ -173,7 +173,7 @@ namespace MWSound
{
if(snditer->second.first == ptr && snditer->second.second == id)
return snditer->first->isPlaying();
snditer++;
++snditer;
}
return false;
}
@ -298,7 +298,7 @@ namespace MWSound
mActiveSounds.erase(snditer++);
}
else
snditer++;
++snditer;
}
}
@ -380,7 +380,7 @@ namespace MWSound
mActiveSounds.erase(snditer++);
}
else
snditer++;
++snditer;
}
}
@ -395,7 +395,7 @@ namespace MWSound
mActiveSounds.erase(snditer++);
}
else
snditer++;
++snditer;
}
}
@ -411,7 +411,7 @@ namespace MWSound
mActiveSounds.erase(snditer++);
}
else
snditer++;
++snditer;
}
}
@ -427,7 +427,7 @@ namespace MWSound
mActiveSounds.erase(snditer++);
}
else
snditer++;
++snditer;
}
}
@ -490,7 +490,7 @@ namespace MWSound
while(soundIter != regn->mSoundList.end())
{
total += (int)soundIter->mChance;
soundIter++;
++soundIter;
}
if(total == 0)
return;
@ -509,7 +509,7 @@ namespace MWSound
}
pos += soundIter->mChance;
soundIter++;
++soundIter;
}
}
@ -557,7 +557,7 @@ namespace MWSound
snditer->first->setPosition(objpos);
}
snditer->first->update();
snditer++;
++snditer;
}
}
}
@ -584,7 +584,7 @@ namespace MWSound
{
snditer->first->mBaseVolume = volumeFromType(snditer->first->getPlayType());
snditer->first->update();
snditer++;
++snditer;
}
if(mMusic)
{

@ -80,7 +80,7 @@ namespace MWWorld
{
assert (mCell);
if (mCell->mContextList.size() == 0)
if (mCell->mContextList.empty())
return; // this is a dynamically generated cell -> skipping.
// Load references from all plugins that do something with this cell.
@ -113,7 +113,7 @@ namespace MWWorld
{
assert (mCell);
if (mCell->mContextList.size() == 0)
if (mCell->mContextList.empty())
return; // this is a dynamically generated cell -> skipping.
// Load references from all plugins that do something with this cell.
@ -174,7 +174,7 @@ namespace MWWorld
}
// Load moved references, from separately tracked list.
for (ESM::CellRefTracker::const_iterator it = mCell->mLeasedRefs.begin(); it != mCell->mLeasedRefs.end(); it++)
for (ESM::CellRefTracker::const_iterator it = mCell->mLeasedRefs.begin(); it != mCell->mLeasedRefs.end(); ++it)
{
// Doesn't seem to work in one line... huh? Too sleepy to check...
ESM::CellRef &ref = const_cast<ESM::CellRef&>(*it);

@ -237,7 +237,7 @@ void MWWorld::ContainerStore::addInitialItem (const std::string& id, const std::
}
}
if (!candidates.size())
if (candidates.empty())
return;
std::string item = candidates[std::rand()%candidates.size()];
addInitialItem(item, owner, count, failChance, false);

@ -510,7 +510,7 @@ namespace MWWorld
bool PhysicsSystem::toggleCollisionMode()
{
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = mEngine->mActorMap.begin(); it != mEngine->mActorMap.end();it++)
for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = mEngine->mActorMap.begin(); it != mEngine->mActorMap.end();++it)
{
if (it->first=="player")
{

@ -74,7 +74,7 @@ void Store<ESM::Cell>::load(ESM::ESMReader &esm, const std::string &id)
// copy list into new cell
cell->mContextList = oldcell->mContextList;
// merge lists of leased references, use newer data in case of conflict
for (ESM::MovedCellRefTracker::const_iterator it = cell->mMovedRefs.begin(); it != cell->mMovedRefs.end(); it++) {
for (ESM::MovedCellRefTracker::const_iterator it = cell->mMovedRefs.begin(); it != cell->mMovedRefs.end(); ++it) {
// remove reference from current leased ref tracker and add it to new cell
ESM::MovedCellRefTracker::iterator itold = std::find(oldcell->mMovedRefs.begin(), oldcell->mMovedRefs.end(), it->mRefnum);
if (itold != oldcell->mMovedRefs.end()) {

@ -49,7 +49,7 @@ namespace MWWorld
SharedIterator operator++(int) {
SharedIterator iter = *this;
mIter++;
++mIter;
return iter;
}
@ -61,7 +61,7 @@ namespace MWWorld
SharedIterator operator--(int) {
SharedIterator iter = *this;
mIter--;
--mIter;
return iter;
}

@ -165,8 +165,9 @@ namespace MWWorld
ToUTF8::Utf8Encoder* encoder, const std::map<std::string,std::string>& fallbackMap, int mActivationDistanceOverride)
: mPlayer (0), mLocalScripts (mStore), mGlobalVariables (0),
mSky (true), mCells (mStore, mEsm),
mNumFacing(0), mActivationDistanceOverride (mActivationDistanceOverride),
mFallback(fallbackMap), mPlayIntro(0), mTeleportEnabled(true)
mActivationDistanceOverride (mActivationDistanceOverride),
mFallback(fallbackMap), mPlayIntro(0), mTeleportEnabled(true),
mFacedDistance(FLT_MAX)
{
mPhysics = new PhysicsSystem(renderer);
mPhysEngine = mPhysics->getEngine();
@ -1117,7 +1118,7 @@ namespace MWWorld
bool World::castRay (float x1, float y1, float z1, float x2, float y2, float z2)
{
Ogre::Vector3 a(x1,y1,z1);std::cout << x1 << " " << x2;
Ogre::Vector3 a(x1,y1,z1);
Ogre::Vector3 b(x2,y2,z2);
return mPhysics->castRay(a,b,false,true);
}
@ -1329,7 +1330,7 @@ namespace MWWorld
++it;
}
if (results.size() == 0)
if (results.empty())
{
mFacedHandle = "";
mFacedDistance = FLT_MAX;
@ -1717,8 +1718,6 @@ namespace MWWorld
void World::getContainersOwnedBy (const MWWorld::Ptr& npc, std::vector<MWWorld::Ptr>& out)
{
std::string refId = npc.getCellRef().mRefID;
const Scene::CellStoreCollection& collection = mWorldScene->getActiveCells();
for (Scene::CellStoreCollection::const_iterator cellIt = collection.begin(); cellIt != collection.end(); ++cellIt)
{

@ -77,13 +77,6 @@ namespace MWWorld
int mActivationDistanceOverride;
std::string mFacedHandle;
float mFacedDistance;
Ptr mFaced1;
Ptr mFaced2;
std::string mFaced1Name;
std::string mFaced2Name;
float mFaced1Distance;
float mFaced2Distance;
int mNumFacing;
std::map<MWWorld::Ptr, int> mDoorStates;
///< only holds doors that are currently moving. 0 means closing, 1 opening

@ -130,7 +130,7 @@ public:
{
std::string normalizedPattern = normalize_path(pattern.begin(), pattern.end());
StringVectorPtr ptr = StringVectorPtr(new StringVector());
for(index::const_iterator iter = mIndex.begin();iter != mIndex.end();iter++)
for(index::const_iterator iter = mIndex.begin();iter != mIndex.end();++iter)
{
if(Ogre::StringUtil::match(iter->first, normalizedPattern) ||
(recursive && Ogre::StringUtil::match(iter->first, "*/"+normalizedPattern)))
@ -169,7 +169,7 @@ public:
}
else
{
for(index::const_iterator iter = mIndex.begin();iter != mIndex.end();iter++)
for(index::const_iterator iter = mIndex.begin();iter != mIndex.end();++iter)
{
if(Ogre::StringUtil::match(iter->first, normalizedPattern) ||
(recursive && Ogre::StringUtil::match(iter->first, "*/"+normalizedPattern)))
@ -249,7 +249,7 @@ public:
std::string normalizedPattern = normalize_path(pattern.begin(), pattern.end());
const Bsa::BSAFile::FileList &filelist = arc.getList();
StringVectorPtr ptr = StringVectorPtr(new StringVector());
for(Bsa::BSAFile::FileList::const_iterator iter = filelist.begin();iter != filelist.end();iter++)
for(Bsa::BSAFile::FileList::const_iterator iter = filelist.begin();iter != filelist.end();++iter)
{
std::string ent = normalize_path(iter->name, iter->name+std::strlen(iter->name));
if(Ogre::StringUtil::match(ent, normalizedPattern) ||
@ -266,7 +266,7 @@ public:
FileInfoListPtr ptr = FileInfoListPtr(new FileInfoList());
const Bsa::BSAFile::FileList &filelist = arc.getList();
for(Bsa::BSAFile::FileList::const_iterator iter = filelist.begin();iter != filelist.end();iter++)
for(Bsa::BSAFile::FileList::const_iterator iter = filelist.begin();iter != filelist.end();++iter)
{
std::string ent = normalize_path(iter->name, iter->name+std::strlen(iter->name));
if(Ogre::StringUtil::match(ent, normalizedPattern) ||

@ -52,7 +52,7 @@ namespace Compiler
Literals& literals, std::vector<Interpreter::Type_Code>& code, bool allowExpression)
: Parser (errorHandler, context), mLocals (locals), mLiterals (literals), mCode (code),
mState (BeginState), mExprParser (errorHandler, context, locals, literals),
mAllowExpression (allowExpression)
mAllowExpression (allowExpression), mButtons(0), mType(0)
{}
bool LineParser::parseInt (int value, const TokenLoc& loc, Scanner& scanner)

@ -509,7 +509,7 @@ namespace Compiler
Scanner::Scanner (ErrorHandler& errorHandler, std::istream& inputStream,
const Extensions *extensions)
: mErrorHandler (errorHandler), mStream (inputStream), mExtensions (extensions),
mPutback (Putback_None)
mPutback (Putback_None), mPutbackCode(0), mPutbackInteger(0), mPutbackFloat(0)
{
}

@ -18,6 +18,9 @@ ESM_Context ESMReader::getContext()
ESMReader::ESMReader()
: mBuffer(50*1024)
, mRecordFlags(0)
, mIdx(0)
, mGlobalReaderList(NULL)
, mEncoder(NULL)
{
}

@ -66,10 +66,11 @@ Land::Land()
, mX(0)
, mY(0)
, mEsm(NULL)
// , hasData(false)
, mDataTypes(0)
, mDataLoaded(false)
, mLandData(NULL)
, mPlugin(0)
, mHasData(false)
{
}

@ -56,14 +56,14 @@ void Pathgrid::load(ESMReader &esm)
std::vector<int>::const_iterator rawIt = rawConnections.begin();
int pointIndex = 0;
mEdges.reserve(edgeCount);
for(PointList::const_iterator it = mPoints.begin(); it != mPoints.end(); it++, pointIndex++)
for(PointList::const_iterator it = mPoints.begin(); it != mPoints.end(); ++it, ++pointIndex)
{
unsigned char connectionNum = (*it).mConnectionNum;
for (int i = 0; i < connectionNum; ++i) {
Edge edge;
edge.mV0 = pointIndex;
edge.mV1 = *rawIt;
rawIt++;
++rawIt;
mEdges.push_back(edge);
}
}

@ -7,7 +7,7 @@
namespace Interpreter{
bool Check(const std::string str, const std::string escword, unsigned int* i, unsigned int* start){
bool Check(const std::string& str, const std::string& escword, unsigned int* i, unsigned int* start){
bool retval = str.find(escword) == 0;
if(retval){
(*i) += escword.length();
@ -18,7 +18,7 @@ namespace Interpreter{
std::vector<std::string> globals;
bool longerStr(const std::string a, const std::string b){
bool longerStr(const std::string& a, const std::string& b){
return a.length() > b.length();
}

@ -7,7 +7,7 @@
namespace Interpreter
{
Runtime::Runtime() : mContext (0), mCode (0), mPC (0) {}
Runtime::Runtime() : mContext (0), mCode (0), mPC (0), mCodeSize(0) {}
int Runtime::getPC() const
{

@ -75,12 +75,12 @@ btVector3 ManualBulletShapeLoader::getbtVector(Ogre::Vector3 const &v)
void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource)
{
cShape = static_cast<OEngine::Physic::BulletShape *>(resource);
resourceName = cShape->getName();
cShape->mCollide = false;
mShape = static_cast<OEngine::Physic::BulletShape *>(resource);
mResourceName = mShape->getName();
mShape->mCollide = false;
mBoundingBox = NULL;
cShape->mBoxTranslation = Ogre::Vector3(0,0,0);
cShape->mBoxRotation = Ogre::Quaternion::IDENTITY;
mShape->mBoxTranslation = Ogre::Vector3(0,0,0);
mShape->mBoxRotation = Ogre::Quaternion::IDENTITY;
mHasShape = false;
btTriangleMesh* mesh1 = new btTriangleMesh();
@ -89,7 +89,7 @@ void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource)
// of the early stages of development. Right now we WANT to catch
// every error as early and intrusively as possible, as it's most
// likely a sign of incomplete code rather than faulty input.
Nif::NIFFile::ptr pnif (Nif::NIFFile::create (resourceName.substr(0, resourceName.length()-7)));
Nif::NIFFile::ptr pnif (Nif::NIFFile::create (mResourceName.substr(0, mResourceName.length()-7)));
Nif::NIFFile & nif = *pnif.get ();
if (nif.numRoots() < 1)
{
@ -108,29 +108,29 @@ void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource)
return;
}
cShape->mHasCollisionNode = hasRootCollisionNode(node);
mShape->mHasCollisionNode = hasRootCollisionNode(node);
//do a first pass
handleNode(mesh1, node,0,false,false,false);
if(mBoundingBox != NULL)
{
cShape->mCollisionShape = mBoundingBox;
mShape->mCollisionShape = mBoundingBox;
delete mesh1;
}
else if (mHasShape && cShape->mCollide)
else if (mHasShape && mShape->mCollide)
{
cShape->mCollisionShape = new TriangleMeshShape(mesh1,true);
mShape->mCollisionShape = new TriangleMeshShape(mesh1,true);
}
else
delete mesh1;
//second pass which create a shape for raycasting.
resourceName = cShape->getName();
cShape->mCollide = false;
mResourceName = mShape->getName();
mShape->mCollide = false;
mBoundingBox = NULL;
cShape->mBoxTranslation = Ogre::Vector3(0,0,0);
cShape->mBoxRotation = Ogre::Quaternion::IDENTITY;
mShape->mBoxTranslation = Ogre::Vector3(0,0,0);
mShape->mBoxRotation = Ogre::Quaternion::IDENTITY;
mHasShape = false;
btTriangleMesh* mesh2 = new btTriangleMesh();
@ -139,12 +139,12 @@ void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource)
if(mBoundingBox != NULL)
{
cShape->mRaycastingShape = mBoundingBox;
mShape->mRaycastingShape = mBoundingBox;
delete mesh2;
}
else if (mHasShape)
{
cShape->mRaycastingShape = new TriangleMeshShape(mesh2,true);
mShape->mRaycastingShape = new TriangleMeshShape(mesh2,true);
}
else
delete mesh2;
@ -224,18 +224,18 @@ void ManualBulletShapeLoader::handleNode(btTriangleMesh* mesh, const Nif::Node *
}
}
if ( (isCollisionNode || (!cShape->mHasCollisionNode && !raycasting))
&& (!isMarker || (cShape->mHasCollisionNode && !raycasting)))
if ( (isCollisionNode || (!mShape->mHasCollisionNode && !raycasting))
&& (!isMarker || (mShape->mHasCollisionNode && !raycasting)))
{
if(node->hasBounds)
{
cShape->mBoxTranslation = node->boundPos;
cShape->mBoxRotation = node->boundRot;
mShape->mBoxTranslation = node->boundPos;
mShape->mBoxRotation = node->boundRot;
mBoundingBox = new btBoxShape(getbtVector(node->boundXYZ));
}
else if(node->recType == Nif::RC_NiTriShape)
{
cShape->mCollide = !(flags&0x800);
mShape->mCollide = !(flags&0x800);
handleNiTriShape(mesh, static_cast<const Nif::NiTriShape*>(node), flags, node->getWorldTransform(), raycasting);
}
}

@ -50,7 +50,13 @@ namespace NifBullet
class ManualBulletShapeLoader : public OEngine::Physic::BulletShapeLoader
{
public:
ManualBulletShapeLoader():resourceGroup("General"){}
ManualBulletShapeLoader()
: mShape(NULL)
, mBoundingBox(NULL)
, mHasShape(false)
{
}
virtual ~ManualBulletShapeLoader();
void warn(const std::string &msg)
@ -94,10 +100,9 @@ private:
*/
void handleNiTriShape(btTriangleMesh* mesh, const Nif::NiTriShape *shape, int flags, const Ogre::Matrix4 &transform, bool raycasting);
std::string resourceName;
std::string resourceGroup;
std::string mResourceName;
OEngine::Physic::BulletShape* cShape;//current shape
OEngine::Physic::BulletShape* mShape;//current shape
btBoxShape *mBoundingBox;
bool mHasShape;

@ -30,7 +30,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace ICS
{
Control::Control(const std::string name, bool autoChangeDirectionOnLimitsAfterStop, bool autoReverseToInitialValue
Control::Control(const std::string& name, bool autoChangeDirectionOnLimitsAfterStop, bool autoReverseToInitialValue
, float initialValue, float stepSize, float stepsPerSeconds, bool axisBindable)
: mName(name)
, mValue(initialValue)

@ -35,7 +35,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace ICS
{
class DllExport Control
class DllExport Control
{
public:
@ -44,7 +44,7 @@ namespace ICS
DECREASE = -1, STOP = 0, INCREASE = 1
};
Control(const std::string name, bool autoChangeDirectionOnLimitsAfterStop = false, bool autoReverseToInitialValue = false, float initialValue = 0.5, float stepSize = 0.1, float stepsPerSeconds = 2.0, bool axisBindable = true);
Control(const std::string& name, bool autoChangeDirectionOnLimitsAfterStop = false, bool autoReverseToInitialValue = false, float initialValue = 0.5, float stepSize = 0.1, float stepsPerSeconds = 2.0, bool axisBindable = true);
~Control();
void setChangingDirection(ControlChangingDirection direction);
@ -104,4 +104,4 @@ namespace ICS
}
#endif
#endif

@ -31,7 +31,6 @@ namespace SFO
typedef std::map<std::string, SDL_Cursor*> CursorMap;
CursorMap mCursorMap;
SDL_Cursor* mDebugCursor;
std::string mCurrentCursor;
bool mEnabled;
bool mInitialized;

@ -293,7 +293,7 @@ namespace BtOgre {
{
const Ogre::Vector3 sz = getSize();
assert((sz.x > 0.0) && (sz.y > 0.0) && (sz.y > 0.0) &&
assert((sz.x > 0.0) && (sz.y > 0.0) && (sz.z > 0.0) &&
("Size of box must be greater than zero on all axes"));
btBoxShape* shape = new btBoxShape(Convert::toBullet(sz * 0.5));
@ -308,7 +308,7 @@ namespace BtOgre {
{
const Ogre::Vector3 sz = getSize();
assert((sz.x > 0.0) && (sz.y > 0.0) && (sz.y > 0.0) &&
assert((sz.x > 0.0) && (sz.y > 0.0) && (sz.z > 0.0) &&
("Size of Cylinder must be greater than zero on all axes"));
btCylinderShape* shape = new btCylinderShapeX(Convert::toBullet(sz * 0.5));

@ -150,7 +150,7 @@ namespace Physic
void PhysicActor::enableCollisionBody()
{
mEngine->dynamicsWorld->addRigidBody(mBody);
mEngine->dynamicsWorld->addRigidBody(mBody,CollisionType_Actor,CollisionType_World|CollisionType_HeightMap);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -178,6 +178,7 @@ namespace Physic
PhysicEngine::PhysicEngine(BulletShapeLoader* shapeLoader) :
mDebugActive(0)
, mSceneMgr(NULL)
{
// Set up the collision configuration and dispatcher
collisionConfiguration = new btDefaultCollisionConfiguration();
@ -620,7 +621,6 @@ namespace Physic
std::string name = "";
float d = -1;
float d1 = 10000.;
btCollisionWorld::ClosestRayResultCallback resultCallback1(from, to);
if(raycastingObjectOnly)
resultCallback1.m_collisionFilterMask = CollisionType_Raycasting;
@ -633,8 +633,7 @@ namespace Physic
if (resultCallback1.hasHit())
{
name = static_cast<const RigidBody&>(*resultCallback1.m_collisionObject).mName;
d1 = resultCallback1.m_closestHitFraction;
d = d1;
d = resultCallback1.m_closestHitFraction;;
}
return std::pair<std::string,float>(name,d);

@ -91,7 +91,11 @@ public:
mRenderSystem(nullptr),
mIsInitialise(false),
mManualRender(false),
mCountBatch(0)
mCountBatch(0),
mVertexProgramNoTexture(NULL),
mFragmentProgramNoTexture(NULL),
mVertexProgramOneTexture(NULL),
mFragmentProgramOneTexture(NULL)
{
}

@ -1,75 +0,0 @@
#ifndef OENGINE_INPUT_DISPATCHMAP_H
#define OENGINE_INPUT_DISPATCHMAP_H
#include <set>
#include <map>
#include <cassert>
namespace OEngine {
namespace Input {
/**
DispatchMap is a simple connection system that connects incomming
signals with outgoing signals.
The signals can be connected one-to-one, many-to-one, one-to-many
or many-to-many.
The dispatch map is completely system agnostic. It is a pure data
structure and all signals are just integer indices. It does not
delegate any actions, but used together with Dispatcher it can be
used to build an event system.
*/
struct DispatchMap
{
typedef std::set<int> OutList;
typedef std::map<int, OutList> InMap;
typedef OutList::iterator Oit;
typedef InMap::iterator Iit;
InMap map;
void bind(int in, int out)
{
map[in].insert(out);
}
void unbind(int in, int out)
{
Iit it = map.find(in);
if(it != map.end())
{
it->second.erase(out);
// If there are no more elements, then remove the entire list
if(it->second.empty())
map.erase(it);
}
}
/// Check if a given input is bound to anything
bool isBound(int in) const
{
return map.find(in) != map.end();
}
/**
Get the list of outputs bound to the given input. Only call this
on inputs that you know are bound to something.
The returned set is only intended for immediate iteration. Do not
store references to it.
*/
const OutList &getList(int in) const
{
assert(isBound(in));
InMap::const_iterator it = map.find(in);
assert(it != map.end());
const OutList &out = it->second;
assert(!out.empty());
return out;
}
};
}}
#endif

@ -1,78 +0,0 @@
#ifndef OENGINE_INPUT_DISPATCHER_H
#define OENGINE_INPUT_DISPATCHER_H
#include <cassert>
#include <iostream>
#include <mangle/input/event.hpp>
#include "dispatch_map.hpp"
#include "func_binder.hpp"
namespace OEngine {
namespace Input {
struct Dispatcher : Mangle::Input::Event
{
DispatchMap map;
FuncBinder funcs;
/**
Constructor. Takes the number of actions and passes it to
FuncBinder.
*/
Dispatcher(int actions) : funcs(actions) {}
void bind(unsigned int action, int key)
{
assert(action < funcs.getSize());
map.bind(key, action);
}
void unbind(unsigned int action, int key)
{
assert(action < funcs.getSize());
map.unbind(key, action);
}
bool isBound(int key) const { return map.isBound(key); }
/**
Instigate an event. It is translated through the dispatch map and
sent to the function bindings.
*/
typedef DispatchMap::OutList _O;
void event(Type type, int index, const void* p)
{
// No bindings, nothing happens
if(!isBound(index))
return;
// Get the mapped actions and execute them
const _O &list = map.getList(index);
_O::const_iterator it;
for(it = list.begin(); it != list.end(); it++)
{
//catch exceptions thrown in the input handlers so that pressing a key
//doesn't cause OpenMw to crash
try
{
funcs.call(*it, p);
}
catch(const std::exception& e)
{
std::cerr << "Exception in input handler: " << e.what() << std::endl;
}
catch(...)
{
std::cerr << "Unknown exception in input handler" << std::endl;
}
}
}
};
// This helps us play nice with Mangle's EventPtr, but it should
// really be defined for all the classes in OEngine.
typedef boost::shared_ptr<Dispatcher> DispatcherPtr;
}}
#endif

@ -1,106 +0,0 @@
#ifndef OENGINE_INPUT_FUNCBINDER_H
#define OENGINE_INPUT_FUNCBINDER_H
#include <string>
#include <vector>
#include <boost/function.hpp>
#include <cassert>
namespace OEngine {
namespace Input {
/**
An Action defines the user defined action corresponding to a
binding.
The first parameter is the action index that invoked this call. You
can assign the same function to multiple actions, and this can help
you keep track of which action was invoked.
The second parameter is an optional user-defined parameter,
represented by a void pointer. In many cases it is practical to
point this to temporaries (stack values), so make sure not to store
permanent references to it unless you've planning for this on the
calling side as well.
*/
typedef boost::function<void(int,const void*)> Action;
/**
The FuncBinder is a simple struct that binds user-defined indices
to functions. It is useful for binding eg. keyboard events to
specific actions in your program, but can potentially have many
other uses as well.
*/
class FuncBinder
{
struct FuncBinding
{
std::string name;
Action action;
};
std::vector<FuncBinding> bindings;
public:
/**
Constructor. Initialize the struct by telling it how many action
indices you intend to bind.
The indices you use should be 0 <= i < number.
*/
FuncBinder(int number) : bindings(number) {}
unsigned int getSize() { return bindings.size(); }
/**
Bind an action to an index.
*/
void bind(int index, Action action, const std::string &name="")
{
assert(index >= 0 && index < (int)bindings.size());
FuncBinding &fb = bindings[index];
fb.action = action;
fb.name = name;
}
/**
Unbind an index, reverting a previous bind().
*/
void unbind(int index)
{
assert(index >= 0 && index < (int)bindings.size());
bindings[index] = FuncBinding();
}
/**
Call a specific action. Takes an optional parameter that is
passed to the action.
*/
void call(int index, const void *p=NULL) const
{
assert(index >= 0 && index < (int)bindings.size());
const FuncBinding &fb = bindings[index];
if(fb.action) fb.action(index, p);
}
/// Check if a given index is bound to anything
bool isBound(int index) const
{
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 < (int)bindings.size());
return bindings[index].name;
}
};
}}
#endif

@ -1,46 +0,0 @@
#ifndef OENGINE_INPUT_POLLER_H
#define OENGINE_INPUT_POLLER_H
#include "dispatch_map.hpp"
#include <mangle/input/driver.hpp>
namespace OEngine {
namespace Input {
/** The poller is used to check (poll) for keys rather than waiting
for events. */
struct Poller
{
DispatchMap map;
Mangle::Input::Driver &input;
Poller(Mangle::Input::Driver &drv)
: input(drv) {}
/** Bind or unbind a given action with a key. The action is the first
parameter, the key is the second.
*/
void bind(int in, int out) { map.bind(in, out); }
void unbind(int in, int out) { map.unbind(in, out); }
bool isBound(int in) const { return map.isBound(in); }
/// Check whether a given action button is currently pressed.
typedef DispatchMap::OutList _O;
bool isDown(int index) const
{
// No bindings, no action
if(!isBound(index))
return false;
// Get all the keys bound to this action, and check them.
const _O &list = map.getList(index);
_O::const_iterator it;
for(it = list.begin(); it != list.end(); it++)
// If there's any match, we're good to go.
if(input.isDown(*it)) return true;
return false;
}
};
}}
#endif

@ -1,18 +0,0 @@
GCC=g++
all: funcbind_test dispatch_map_test sdl_driver_test sdl_binder_test
funcbind_test: funcbind_test.cpp ../func_binder.hpp
$(GCC) $< -o $@
dispatch_map_test: dispatch_map_test.cpp ../dispatch_map.hpp
$(GCC) $< -o $@
sdl_driver_test: sdl_driver_test.cpp
$(GCC) $< ../../mangle/input/servers/sdl_driver.cpp -o $@ -I/usr/include/SDL/ -lSDL -I../../
sdl_binder_test: sdl_binder_test.cpp
$(GCC) $< ../../mangle/input/servers/sdl_driver.cpp -o $@ -I/usr/include/SDL/ -lSDL -I../../
clean:
rm *_test

@ -1,54 +0,0 @@
#include <iostream>
using namespace std;
#include "../dispatch_map.hpp"
using namespace OEngine::Input;
typedef DispatchMap::OutList OutList;
typedef OutList::const_iterator Cit;
void showList(const DispatchMap::OutList &out)
{
for(Cit it = out.begin();
it != out.end(); it++)
{
cout << " " << *it << endl;
}
}
void showAll(DispatchMap &map)
{
cout << "\nPrinting everything:\n";
for(DispatchMap::Iit it = map.map.begin();
it != map.map.end(); it++)
{
cout << it->first << ":\n";
showList(map.getList(it->first));
}
}
int main()
{
cout << "Testing the dispatch map\n";
DispatchMap dsp;
dsp.bind(1,9);
dsp.bind(2,-5);
dsp.bind(2,9);
dsp.bind(3,10);
dsp.bind(3,12);
dsp.bind(3,10);
showAll(dsp);
dsp.unbind(1,9);
dsp.unbind(5,8);
dsp.unbind(3,11);
dsp.unbind(3,12);
dsp.unbind(3,12);
showAll(dsp);
return 0;
}

@ -1,47 +0,0 @@
#include <iostream>
using namespace std;
#include "../func_binder.hpp"
void f1(int i, const void *p)
{
cout << " F1 i=" << i << endl;
if(p)
cout << " Got a nice gift: "
<< *((const float*)p) << endl;
}
void f2(int i, const void *p)
{
cout << " F2 i=" << i << endl;
}
using namespace OEngine::Input;
int main()
{
cout << "This will test the function binding system\n";
FuncBinder bnd(5);
bnd.bind(0, &f1, "This is action 1");
bnd.bind(1, &f2);
bnd.bind(2, &f1, "This is action 3");
bnd.bind(3, &f2, "This is action 4");
bnd.unbind(2);
for(int i=0; i<5; i++)
{
cout << "Calling " << i << ": '" << bnd.getName(i) << "'\n";
bnd.call(i);
if(!bnd.isBound(i)) cout << " (not bound)\n";
}
cout << "\nCalling with parameter:\n";
float f = 3.1415;
bnd.call(0, &f);
return 0;
}

@ -1,18 +0,0 @@
Testing the dispatch map
Printing everything:
1:
9
2:
-5
9
3:
10
12
Printing everything:
2:
-5
9
3:
10

@ -1,15 +0,0 @@
This will test the function binding system
Calling 0: 'This is action 1'
F1 i=0
Calling 1: ''
F2 i=1
Calling 2: ''
(not bound)
Calling 3: 'This is action 4'
F2 i=3
Calling 4: ''
(not bound)
Calling with parameter:
F1 i=0
Got a nice gift: 3.1415

@ -1,4 +0,0 @@
Hold the Q key to quit:
You are running in script mode, aborting. Run this test with a parameter (any at all) to test the input loop properly
Bye bye!

@ -1,4 +0,0 @@
Hold the Q key to quit:
You are running in script mode, aborting. Run this test with a parameter (any at all) to test the input loop properly
Bye bye!

@ -1,71 +0,0 @@
#include <iostream>
#include <mangle/input/servers/sdl_driver.hpp>
#include <SDL.h>
#include "../dispatcher.hpp"
#include "../poller.hpp"
using namespace std;
using namespace Mangle::Input;
using namespace OEngine::Input;
enum Actions
{
A_Quit,
A_Left,
A_Right,
A_LAST
};
bool quit=false;
void doExit(int,const void*)
{
quit = true;
}
void goLeft(int,const void*)
{
cout << "Going left\n";
}
int main(int argc, char** argv)
{
SDL_Init(SDL_INIT_VIDEO);
SDL_SetVideoMode(640, 480, 0, SDL_SWSURFACE);
SDLDriver input;
Dispatcher *disp = new Dispatcher(A_LAST);
Poller poll(input);
input.setEvent(EventPtr(disp));
disp->funcs.bind(A_Quit, &doExit);
disp->funcs.bind(A_Left, &goLeft);
disp->bind(A_Quit, SDLK_q);
disp->bind(A_Left, SDLK_a);
disp->bind(A_Left, SDLK_LEFT);
poll.bind(A_Right, SDLK_d);
poll.bind(A_Right, SDLK_RIGHT);
cout << "Hold the Q key to quit:\n";
//input->setEvent(&mycb);
while(!quit)
{
input.capture();
if(poll.isDown(A_Right))
cout << "We're going right!\n";
SDL_Delay(20);
if(argc == 1)
{
cout << "You are running in script mode, aborting. Run this test with a parameter (any at all) to test the input loop properly\n";
break;
}
}
cout << "\nBye bye!\n";
SDL_Quit();
return 0;
}

@ -1,31 +0,0 @@
#include <iostream>
#include <mangle/input/servers/sdl_driver.hpp>
#include <SDL.h>
using namespace std;
using namespace Mangle::Input;
int main(int argc, char** argv)
{
SDL_Init(SDL_INIT_VIDEO);
SDL_SetVideoMode(640, 480, 0, SDL_SWSURFACE);
SDLDriver input;
cout << "Hold the Q key to quit:\n";
//input->setEvent(&mycb);
while(!input.isDown(SDLK_q))
{
input.capture();
SDL_Delay(20);
if(argc == 1)
{
cout << "You are running in script mode, aborting. Run this test with a parameter (any at all) to test the input loop properly\n";
break;
}
}
cout << "\nBye bye!\n";
SDL_Quit();
return 0;
}

@ -1,18 +0,0 @@
#!/bin/bash
make || exit
mkdir -p output
PROGS=*_test
for a in $PROGS; do
if [ -f "output/$a.out" ]; then
echo "Running $a:"
./$a | diff output/$a.out -
else
echo "Creating $a.out"
./$a > "output/$a.out"
git add "output/$a.out"
fi
done

@ -108,12 +108,12 @@ void OgreRenderer::loadPlugins()
void OgreRenderer::unloadPlugins()
{
std::vector<Ogre::ParticleEmitterFactory*>::iterator ei;
for(ei = mEmitterFactories.begin();ei != mEmitterFactories.end();ei++)
for(ei = mEmitterFactories.begin();ei != mEmitterFactories.end();++ei)
OGRE_DELETE (*ei);
mEmitterFactories.clear();
std::vector<Ogre::ParticleAffectorFactory*>::iterator ai;
for(ai = mAffectorFactories.begin();ai != mAffectorFactories.end();ai++)
for(ai = mAffectorFactories.begin();ai != mAffectorFactories.end();++ai)
OGRE_DELETE (*ai);
mAffectorFactories.clear();

Loading…
Cancel
Save