From e3692092126ea14c3a3605c657fe0fec893f26ff Mon Sep 17 00:00:00 2001 From: Tom Prince Date: Thu, 3 Jun 2010 22:07:44 -0400 Subject: [PATCH] Constificiation. Signed-off-by: Tom Prince --- gemrb/core/Actor.cpp | 12 +++--- gemrb/core/Actor.h | 12 +++--- gemrb/core/ActorBlock.cpp | 49 ++++++++++++----------- gemrb/core/ActorBlock.h | 56 +++++++++++++------------- gemrb/core/Ambient.h | 2 +- gemrb/core/AnimationFactory.cpp | 6 +-- gemrb/core/AnimationFactory.h | 12 +++--- gemrb/core/Bitmap.h | 6 +-- gemrb/core/Cache.cpp | 2 +- gemrb/core/Cache.h | 2 +- gemrb/core/Calendar.cpp | 4 +- gemrb/core/Calendar.h | 4 +- gemrb/core/Compressor.h | 4 +- gemrb/core/Core.cpp | 2 +- gemrb/core/DataFileMgr.h | 16 ++++---- gemrb/core/DialogMgr.h | 2 +- gemrb/core/Effect.h | 2 +- gemrb/core/EffectQueue.cpp | 6 +-- gemrb/core/EffectQueue.h | 6 +-- gemrb/core/Factory.cpp | 4 +- gemrb/core/Factory.h | 4 +- gemrb/core/Font.cpp | 14 +++---- gemrb/core/Font.h | 14 +++---- gemrb/core/GSUtils.cpp | 12 +++--- gemrb/core/GSUtils.h | 12 +++--- gemrb/core/Game.cpp | 4 +- gemrb/core/Game.h | 4 +- gemrb/core/GameControl.cpp | 10 ++--- gemrb/core/GameControl.h | 10 ++--- gemrb/core/GameData.h | 2 +- gemrb/core/Image.h | 6 +-- gemrb/core/Interface.cpp | 8 ++-- gemrb/core/Interface.h | 10 ++--- gemrb/core/Inventory.cpp | 4 +- gemrb/core/Inventory.h | 4 +- gemrb/core/Label.cpp | 2 +- gemrb/core/Label.h | 2 +- gemrb/core/Map.cpp | 66 +++++++++++++++---------------- gemrb/core/Map.h | 66 +++++++++++++++---------------- gemrb/core/Palette.h | 2 +- gemrb/core/Particles.cpp | 4 +- gemrb/core/Particles.h | 10 ++--- gemrb/core/PluginMgr.cpp | 4 +- gemrb/core/PluginMgr.h | 4 +- gemrb/core/Polygon.cpp | 16 ++++---- gemrb/core/Polygon.h | 12 +++--- gemrb/core/Projectile.cpp | 24 +++++------ gemrb/core/Projectile.h | 26 ++++++------ gemrb/core/Region.cpp | 8 ++-- gemrb/core/Region.h | 8 ++-- gemrb/core/ResourceManager.cpp | 4 +- gemrb/core/ResourceManager.h | 4 +- gemrb/core/SaveGameIterator.cpp | 12 +++--- gemrb/core/SaveGameIterator.h | 26 ++++++------ gemrb/core/ScriptedAnimation.cpp | 2 +- gemrb/core/ScriptedAnimation.h | 2 +- gemrb/core/SoundMgr.h | 6 +-- gemrb/core/Spell.cpp | 4 +- gemrb/core/Spell.h | 4 +- gemrb/core/Sprite2D.cpp | 6 +-- gemrb/core/Sprite2D.h | 6 +-- gemrb/core/SpriteCover.cpp | 2 +- gemrb/core/SpriteCover.h | 2 +- gemrb/core/SymbolMgr.h | 14 +++---- gemrb/core/TileMap.cpp | 24 +++++------ gemrb/core/TileMap.h | 28 ++++++------- gemrb/core/TileOverlay.cpp | 2 +- gemrb/core/TileOverlay.h | 2 +- gemrb/core/Video.cpp | 8 ++-- gemrb/core/Video.h | 30 +++++++------- gemrb/core/WorldMap.cpp | 12 +++--- gemrb/core/WorldMap.h | 28 ++++++------- gemrb/includes/globals.h | 8 ++-- gemrb/plugins/DLGImporter/DLGImporter.cpp | 16 ++++---- gemrb/plugins/DLGImporter/DLGImporter.h | 16 ++++---- gemrb/plugins/IDSImporter/IDSImporter.cpp | 12 +++--- gemrb/plugins/IDSImporter/IDSImporter.h | 14 +++---- gemrb/plugins/INIImporter/INIImporter.cpp | 12 +++--- gemrb/plugins/INIImporter/INIImporter.h | 30 +++++++------- gemrb/plugins/SDLVideo/SDLVideo.cpp | 26 ++++++------ gemrb/plugins/SDLVideo/SDLVideo.h | 24 +++++------ gemrb/plugins/ZLibManager/ZLibManager.cpp | 4 +- gemrb/plugins/ZLibManager/ZLibManager.h | 4 +- 83 files changed, 488 insertions(+), 487 deletions(-) diff --git a/gemrb/core/Actor.cpp b/gemrb/core/Actor.cpp index 022641204..b7651f0f2 100644 --- a/gemrb/core/Actor.cpp +++ b/gemrb/core/Actor.cpp @@ -4492,7 +4492,7 @@ void Actor::SetRunFlags(ieDword flags) InternalFlags |= (flags & IF_RUNFLAGS); } -void Actor::WalkTo(Point &Des, ieDword flags, int MinDistance) +void Actor::WalkTo(const Point &Des, ieDword flags, int MinDistance) { PathTries = 0; if (InternalFlags&IF_REALLYDIED) { @@ -4509,7 +4509,7 @@ void Actor::WalkTo(Point &Des, ieDword flags, int MinDistance) } //there is a similar function in Map for stationary vvcs -void Actor::DrawVideocells(Region &screen, vvcVector &vvcCells, Color &tint) +void Actor::DrawVideocells(const Region &screen, vvcVector &vvcCells, const Color &tint) { Map* area = GetCurrentArea(); @@ -4530,9 +4530,9 @@ void Actor::DrawVideocells(Region &screen, vvcVector &vvcCells, Color &tint) } } -void Actor::DrawActorSprite(Region &screen, int cx, int cy, Region& bbox, +void Actor::DrawActorSprite(const Region &screen, int cx, int cy, const Region& bbox, SpriteCover*& newsc, Animation** anims, - unsigned char Face, Color& tint) + unsigned char Face, const Color& tint) { CharAnimations* ca = GetAnims(); int PartCount = ca->GetTotalPartCount(); @@ -4594,7 +4594,7 @@ bool Actor::ShouldHibernate() { return true; } -void Actor::Draw(Region &screen) +void Actor::Draw(const Region &screen) { Map* area = GetCurrentArea(); @@ -5326,7 +5326,7 @@ int Actor::SetEquippedQuickSlot(int slot, int header) //if target is a non living scriptable, then we simply shoot for its position //the fx should get a NULL target, and handle itself by using the position //(shouldn't crash when target is NULL) -bool Actor::UseItemPoint(ieDword slot, ieDword header, Point &target, ieDword flags) +bool Actor::UseItemPoint(ieDword slot, ieDword header, const Point &target, ieDword flags) { CREItem *item = inventory.GetSlotItem(slot); if (!item) diff --git a/gemrb/core/Actor.h b/gemrb/core/Actor.h index a87774c95..630e5f7e8 100644 --- a/gemrb/core/Actor.h +++ b/gemrb/core/Actor.h @@ -292,9 +292,9 @@ private: /*The projectile bringing the current attack*/ Projectile* attackProjectile ; /** paint the actor itself. Called internally by Draw() */ - void DrawActorSprite(Region &screen, int cx, int cy, Region& bbox, + void DrawActorSprite(const Region &screen, int cx, int cy, const Region& bbox, SpriteCover*& sc, Animation** anims, - unsigned char Face, Color& tint); + unsigned char Face, const Color& tint); /** fixes the palette */ void SetupColors(); @@ -519,7 +519,7 @@ public: /* call this when path needs to be changed */ void NewPath(); /* overridden method, won't walk if dead */ - void WalkTo(Point &Des, ieDword flags, int MinDistance = 0); + void WalkTo(const Point &Des, ieDword flags, int MinDistance = 0); /* resolve string constant (sound will be altered) */ void ResolveStringConstant(ieResRef sound, unsigned int index); void GetSoundFromINI(ieResRef Sound, unsigned int index); @@ -533,7 +533,7 @@ public: bool HandleActorStance(); /* if necessary, advance animation and draw actor */ - void Draw(Region &screen); + void Draw(const Region &screen); /* add mobile vvc (spell effects) to actor's list */ void AddVVCell(ScriptedAnimation* vvc); @@ -545,7 +545,7 @@ public: /* if it exists (faster than hasvvccell) */ ScriptedAnimation *FindOverlay(int index); /* draw videocells */ - void DrawVideocells(Region &screen, vvcVector &vvcCells, Color &tint); + void DrawVideocells(const Region &screen, vvcVector &vvcCells, const Color &tint); void SetLockedPalette(const ieDword *gradients); void UnlockPalette(); @@ -567,7 +567,7 @@ public: /* Sets equipped Quick slot, if header is -1, then use the current one */ int SetEquippedQuickSlot(int slot, int header); /* Uses an item on the target or point */ - bool UseItemPoint(ieDword slot, ieDword header, Point &point, ieDword flags); + bool UseItemPoint(ieDword slot, ieDword header, const Point &point, ieDword flags); bool UseItem(ieDword slot, ieDword header, Scriptable *target, ieDword flags, int damage = 0); /* Deducts a charge from an item */ void ChargeItem(ieDword slot, ieDword header, CREItem *item, Item *itm, bool silent); diff --git a/gemrb/core/ActorBlock.cpp b/gemrb/core/ActorBlock.cpp index 33b0afc3e..6570c8582 100644 --- a/gemrb/core/ActorBlock.cpp +++ b/gemrb/core/ActorBlock.cpp @@ -206,7 +206,7 @@ void Scriptable::FixHeadTextPos() #define MAX_DELAY 6000 static const Color black={0,0,0,0}; -void Scriptable::DrawOverheadText(Region &screen) +void Scriptable::DrawOverheadText(const Region &screen) { unsigned long time = core->GetGame()->Ticks; Palette *palette = NULL; @@ -258,7 +258,7 @@ void Scriptable::ImmediateEvent() lastRunTime = 0; } -bool Scriptable::IsPC() +bool Scriptable::IsPC() const { if(Type == ST_ACTOR) { if (((Actor *) this)->GetStat(IE_EA) <= EA_CHARMED) { @@ -470,7 +470,7 @@ void Scriptable::ProcessActions(bool force) } } -bool Scriptable::InMove() +bool Scriptable::InMove() const { if (Type!=ST_ACTOR) { return false; @@ -696,7 +696,7 @@ void Scriptable::CastSpellEnd( const ieResRef SpellResRef ) //set target as point //if spell needs to be depleted, do it //if spell is illegal stop casting -int Scriptable::CastSpellPoint( const ieResRef SpellResRef, Point &target, bool deplete, bool instant ) +int Scriptable::CastSpellPoint( const ieResRef SpellResRef, const Point &target, bool deplete, bool instant ) { LastTarget = 0; LastTargetPos.empty(); @@ -840,14 +840,14 @@ Selectable::~Selectable(void) delete cover; } -void Selectable::SetBBox(Region &newBBox) +void Selectable::SetBBox(const Region &newBBox) { BBox = newBBox; } static const unsigned long tp_steps[8]={3,2,1,0,1,2,3,4}; -void Selectable::DrawCircle(Region &vp) +void Selectable::DrawCircle(const Region &vp) { /* BG2 colours ground circles as follows: dark green for unselected party members @@ -896,7 +896,7 @@ void Selectable::DrawCircle(Region &vp) } // Check if P is over our ground circle -bool Selectable::IsOver(Point &P) +bool Selectable::IsOver(const Point &P) const { int csize = size; if (csize < 2) csize = 2; @@ -914,7 +914,7 @@ bool Selectable::IsOver(Point &P) return (r <= 48*48*(csize-1)*(csize-1)); } -bool Selectable::IsSelected() +bool Selectable::IsSelected() const { return Selected == 1; } @@ -985,7 +985,7 @@ Highlightable::~Highlightable(void) } } -bool Highlightable::IsOver(Point &Pos) +bool Highlightable::IsOver(const Point &Pos) const { if (!outline) { return false; @@ -993,7 +993,7 @@ bool Highlightable::IsOver(Point &Pos) return outline->PointIn( Pos ); } -void Highlightable::DrawOutline() +void Highlightable::DrawOutline() const { if (!outline) { return; @@ -1230,7 +1230,7 @@ bool Movable::DoStep(unsigned int walk_speed, ieDword time) return true; } -void Movable::AddWayPoint(Point &Des) +void Movable::AddWayPoint(const Point &Des) { if (!path) { WalkTo(Des); @@ -1269,7 +1269,7 @@ void Movable::FixPosition() Pos.y=Pos.y*12+6; } -void Movable::WalkTo(Point &Des, int distance) +void Movable::WalkTo(const Point &Des, int distance) { Point from; @@ -1337,7 +1337,7 @@ void Movable::WalkTo(Point &Des, int distance) } } -void Movable::RunAwayFrom(Point &Des, int PathLength, int flags) +void Movable::RunAwayFrom(const Point &Des, int PathLength, int flags) { ClearPath(); area->ClearSearchMapFor(this); @@ -1376,7 +1376,7 @@ void Movable::RandomWalk(bool can_stop, bool run) path = area->RunAway( Pos, p, size, 50, 1 ); } -void Movable::MoveTo(Point &Des) +void Movable::MoveTo(const Point &Des) { area->ClearSearchMapFor(this); Pos = Des; @@ -1407,7 +1407,7 @@ void Movable::ClearPath() //don't call ReleaseCurrentAction } -void Movable::DrawTargetPoint(Region &vp) +void Movable::DrawTargetPoint(const Region &vp) { if (!path || !Selected || (InternalFlags&IF_NORECTICLE) ) return; @@ -1806,7 +1806,7 @@ void Door::TryBashLock(Actor *actor) ImmediateEvent(); } -void Door::DebugDump() +void Door::DebugDump() const { printf( "Debugdump of Door %s:\n", GetScriptName() ); printf( "Door Open: %s\n", YESNO(IsOpen())); @@ -1880,18 +1880,18 @@ void Highlightable::DetectTrap(int skill) } } -bool Highlightable::PossibleToSeeTrap() +bool Highlightable::PossibleToSeeTrap() const { return CanDetectTrap(); } -bool InfoPoint::PossibleToSeeTrap() +bool InfoPoint::PossibleToSeeTrap() const { // Only detectable trap-type infopoints. return (CanDetectTrap() && (Type == ST_PROXIMITY) ); } -bool InfoPoint::CanDetectTrap() +bool InfoPoint::CanDetectTrap() const { // Traps can be detected on all types of infopoint, as long // as the trap is detectable and isn't deactivated. @@ -1900,7 +1900,7 @@ bool InfoPoint::CanDetectTrap() // returns true if the infopoint is a PS:T portal // GF_REVERSE_DOOR is the closest game feature (exists only in PST, and about area objects) -bool InfoPoint::IsPortal() +bool InfoPoint::IsPortal() const { if (Type!=ST_TRAVEL) return false; if (Cursor != IE_CURSOR_PORTAL) return false; @@ -1910,7 +1910,7 @@ bool InfoPoint::IsPortal() //trap that is visible on screen (marked by red) //if TrapDetected is a bitflag, we could show traps selectively for //players, really nice for multiplayer -bool Highlightable::VisibleTrap(int see_all) +bool Highlightable::VisibleTrap(int see_all) const { if (!Trapped) return false; if (!PossibleToSeeTrap()) return false; @@ -2017,7 +2017,7 @@ check: return false; } -void InfoPoint::DebugDump() +void InfoPoint::DebugDump() const { switch (Type) { case ST_TRIGGER: @@ -2266,7 +2266,7 @@ void Container::TryBashLock(Actor *actor) ImmediateEvent(); } -void Container::DebugDump() +void Container::DebugDump() const { printf( "Debugdump of Container %s\n", GetScriptName() ); printf( "Type: %d, LockDifficulty: %d\n", Type, LockDifficulty ); @@ -2278,7 +2278,8 @@ void Container::DebugDump() name = Scripts[0]->GetName(); } printf( "Script: %s, Key: %s\n", name, KeyResRef ); - inventory.dump(); + // FIXME: const_cast + const_cast(inventory).dump(); } bool Container::TryUnlock(Actor *actor) { diff --git a/gemrb/core/ActorBlock.h b/gemrb/core/ActorBlock.h index b425c9d9d..b9be90006 100644 --- a/gemrb/core/ActorBlock.h +++ b/gemrb/core/ActorBlock.h @@ -244,7 +244,7 @@ public: void DelayedEvent(); //call this to enable script running as soon as possible void ImmediateEvent(); - bool IsPC(); + bool IsPC() const; void ExecuteScript(int scriptCount); void AddAction(Action* aC); void AddActionInFront(Action* aC); @@ -253,7 +253,7 @@ public: Action* PopNextAction(); void ClearActions(); void ReleaseCurrentAction(); - bool InMove(); + bool InMove() const; void ProcessActions(bool force); //these functions handle clearing of triggers that resulted a //true condition (whole triggerblock returned true) @@ -262,9 +262,9 @@ public: void SetBitTrigger(ieDword bittrigger); void AddTrigger(ieDword *actorref); /* re/draws overhead text on the map screen */ - void DrawOverheadText(Region &screen); + void DrawOverheadText(const Region &screen); /* actor/scriptable casts spell */ - int CastSpellPoint( const ieResRef SpellResRef, Point &Target, bool deplete, bool instant = false ); + int CastSpellPoint( const ieResRef SpellResRef, const Point &Target, bool deplete, bool instant = false ); int CastSpell( const ieResRef SpellResRef, Scriptable* Target, bool deplete, bool instant = false ); /* spellcasting finished */ void CastSpellPointEnd( const ieResRef SpellResRef); @@ -296,11 +296,11 @@ private: // current SpriteCover for wallgroups SpriteCover* cover; public: - void SetBBox(Region &newBBox); - void DrawCircle(Region &vp); - bool IsOver(Point &Pos); + void SetBBox(const Region &newBBox); + void DrawCircle(const Region &vp); + bool IsOver(const Point &Pos) const; void SetOver(bool over); - bool IsSelected(); + bool IsSelected() const; void Select(int Value); void SetCircle(int size, const Color &color, Sprite2D* normal_circle, Sprite2D* selected_circle); @@ -316,9 +316,9 @@ class GEM_EXPORT Highlightable : public Scriptable { public: Highlightable(ScriptableType type); virtual ~Highlightable(void); - virtual int TrapResets() = 0; - virtual bool CanDetectTrap() { return true; } - virtual bool PossibleToSeeTrap(); + virtual int TrapResets() const = 0; + virtual bool CanDetectTrap() const { return true; } + virtual bool PossibleToSeeTrap() const; public: Gem_Polygon* outline; Color outlineColor; @@ -331,8 +331,8 @@ public: ieWord TrapDetected; ieResRef KeyResRef; public: - bool IsOver(Point &Pos); - void DrawOutline(); + bool IsOver(const Point &Pos) const; + void DrawOutline() const; void SetCursor(unsigned char CursorIndex); const char* GetKey(void) const { @@ -345,7 +345,7 @@ public: void DetectTrap(int skill); //returns true if trap is visible, only_detected must be true //if you want to see discovered traps, false is for cheats - bool VisibleTrap(int only_detected); + bool VisibleTrap(int only_detected) const; //returns true if trap has been triggered, tumble skill??? virtual bool TriggerTrap(int skill, ieDword ID); bool TryUnlock(Actor *actor, bool removekey); @@ -409,15 +409,15 @@ public: void SetStance(unsigned int arg); void SetAttackMoveChances(ieWord *amc); bool DoStep(unsigned int walk_speed, ieDword time = 0); - void AddWayPoint(Point &Des); - void RunAwayFrom(Point &Des, int PathLength, int flags); + void AddWayPoint(const Point &Des); + void RunAwayFrom(const Point &Des, int PathLength, int flags); void RandomWalk(bool can_stop, bool run); void MoveLine(int steps, int Pass, ieDword Orient); void FixPosition(); - void WalkTo(Point &Des, int MinDistance = 0); - void MoveTo(Point &Des); + void WalkTo(const Point &Des, int MinDistance = 0); + void MoveTo(const Point &Des); void ClearPath(); - void DrawTargetPoint(Region &vp); + void DrawTargetPoint(const Region &vp); /* returns the most likely position of this actor */ Point GetMostLikelyPosition(); virtual bool BlocksSearchMap() const = 0; @@ -494,8 +494,8 @@ public: void TryPickLock(Actor *actor); void TryBashLock(Actor* actor) ; bool TryUnlock(Actor *actor); - void DebugDump(); - int TrapResets() { return Flags & DOOR_RESET; } + void DebugDump() const; + int TrapResets() const { return Flags & DOOR_RESET; } void SetNewOverlay(TileOverlay *Overlay); }; @@ -518,8 +518,8 @@ public: void TryPickLock(Actor *actor); void TryBashLock(Actor* actor) ; bool TryUnlock(Actor *actor); - void DebugDump(); - int TrapResets() { return Flags & CONT_RESET; } + void DebugDump() const; + int TrapResets() const { return Flags & CONT_RESET; } private: //updates the ground icons for a pile void RefreshGroundIcons(); @@ -548,11 +548,11 @@ public: bool Entered(Actor *actor); //checks if the actor may use this travel trigger int CheckTravel(Actor *actor); - void DebugDump(); - int TrapResets() { return Flags & TRAP_RESET; } - bool CanDetectTrap(); - bool PossibleToSeeTrap(); - bool IsPortal(); + void DebugDump() const; + int TrapResets() const { return Flags & TRAP_RESET; } + bool CanDetectTrap() const; + bool PossibleToSeeTrap() const; + bool IsPortal() const; public: ieResRef Destination; diff --git a/gemrb/core/Ambient.h b/gemrb/core/Ambient.h index bdd03f88d..f5d36ccfc 100644 --- a/gemrb/core/Ambient.h +++ b/gemrb/core/Ambient.h @@ -50,7 +50,7 @@ public: ieWord getRadius() const { return radius; } ieWord getHeight() const { return height; } ieWord getGain() const { return gain; } - char *getSound(ieDword i) + char *getSound(ieDword i) const { if(i= cycles.size()) { return NULL; @@ -105,7 +105,7 @@ Sprite2D* AnimationFactory::GetFrame(unsigned short index, unsigned char cycle) return spr; } -Sprite2D* AnimationFactory::GetFrameWithoutCycle(unsigned short index) +Sprite2D* AnimationFactory::GetFrameWithoutCycle(unsigned short index) const { if(index >= frames.size()) { return NULL; @@ -116,7 +116,7 @@ Sprite2D* AnimationFactory::GetFrameWithoutCycle(unsigned short index) } Sprite2D* AnimationFactory::GetPaperdollImage(ieDword *Colors, - Sprite2D *&Picture2, unsigned int type) + Sprite2D *&Picture2, unsigned int type) const { if (frames.size()<2) { return NULL; diff --git a/gemrb/core/AnimationFactory.h b/gemrb/core/AnimationFactory.h index 9da8effc4..f67d31c36 100644 --- a/gemrb/core/AnimationFactory.h +++ b/gemrb/core/AnimationFactory.h @@ -42,13 +42,13 @@ public: void SetFrameData(unsigned char* FrameData); Animation* GetCycle(unsigned char cycle); /** No descriptions */ - Sprite2D* GetFrame(unsigned short index, unsigned char cycle=0); - Sprite2D* GetFrameWithoutCycle(unsigned short index); - size_t GetCycleCount() { return cycles.size(); } - size_t GetFrameCount() { return frames.size(); } - int GetCycleSize(int idx) { return cycles[idx].FramesCount; } + Sprite2D* GetFrame(unsigned short index, unsigned char cycle=0) const; + Sprite2D* GetFrameWithoutCycle(unsigned short index) const; + size_t GetCycleCount() const { return cycles.size(); } + size_t GetFrameCount() const { return frames.size(); } + int GetCycleSize(int idx) const { return cycles[idx].FramesCount; } Sprite2D* GetPaperdollImage(ieDword *Colors, Sprite2D *&Picture2, - unsigned int type); + unsigned int type) const; void IncDataRefCount(); void DecDataRefCount(); diff --git a/gemrb/core/Bitmap.h b/gemrb/core/Bitmap.h index ff1866bbd..2c37bdd87 100644 --- a/gemrb/core/Bitmap.h +++ b/gemrb/core/Bitmap.h @@ -25,7 +25,7 @@ class GEM_EXPORT Bitmap { public: Bitmap(unsigned int height, unsigned int width); ~Bitmap(); - unsigned char GetAt(unsigned int x, unsigned int y) + unsigned char GetAt(unsigned int x, unsigned int y) const { if (x >= width || y >= height) return 0; @@ -39,11 +39,11 @@ public: data[width*y+x] = idx; } - unsigned int GetHeight() + unsigned int GetHeight() const { return height; } - unsigned int GetWidth() + unsigned int GetWidth() const { return width; } diff --git a/gemrb/core/Cache.cpp b/gemrb/core/Cache.cpp index 319d0a962..03afea93b 100644 --- a/gemrb/core/Cache.cpp +++ b/gemrb/core/Cache.cpp @@ -199,7 +199,7 @@ Cache::MyAssoc* Cache::GetAssocAt(const ieResRef key) const return NULL; } -void *Cache::GetResource(const ieResRef key) +void *Cache::GetResource(const ieResRef key) const { Cache::MyAssoc* pAssoc = GetAssocAt( key ); if (pAssoc == NULL) { diff --git a/gemrb/core/Cache.h b/gemrb/core/Cache.h index b3f7fffe3..94640198b 100644 --- a/gemrb/core/Cache.h +++ b/gemrb/core/Cache.h @@ -64,7 +64,7 @@ public: return m_nCount==0; } // Lookup - void *GetResource(const ieResRef key); + void *GetResource(const ieResRef key) const; // Operations bool SetAt(const ieResRef key, void *rValue); // decreases refcount or drops data diff --git a/gemrb/core/Calendar.cpp b/gemrb/core/Calendar.cpp index 375558f50..d676d5d38 100644 --- a/gemrb/core/Calendar.cpp +++ b/gemrb/core/Calendar.cpp @@ -49,7 +49,7 @@ Calendar::~Calendar(void) if (days) free(days); } -void Calendar::GetMonthName(int dayandmonth) +void Calendar::GetMonthName(int dayandmonth) const { int month=1; @@ -72,7 +72,7 @@ void Calendar::GetMonthName(int dayandmonth) } } -int Calendar::GetCalendarDay(int date) +int Calendar::GetCalendarDay(int date) const { int dayandmonth; int month=1; diff --git a/gemrb/core/Calendar.h b/gemrb/core/Calendar.h index 3491207f6..28740f0ce 100644 --- a/gemrb/core/Calendar.h +++ b/gemrb/core/Calendar.h @@ -33,8 +33,8 @@ private: public: Calendar(void); ~Calendar(void); - void GetMonthName(int dayandmonth); - int GetCalendarDay(int date); + void GetMonthName(int dayandmonth) const; + int GetCalendarDay(int date) const; }; #endif diff --git a/gemrb/core/Compressor.h b/gemrb/core/Compressor.h index e3d56bc7c..5c5447e5f 100644 --- a/gemrb/core/Compressor.h +++ b/gemrb/core/Compressor.h @@ -32,9 +32,9 @@ public: /** Initialization Function. Returns FALSE if there was an error during initialization, else returns TRUE. */ virtual int Init(void); /** decompresses a datastream (memory or file) to a FILE * stream */ - virtual int Decompress(FILE* dest, DataStream* source, unsigned int size_guess = 0) = 0; + virtual int Decompress(FILE* dest, DataStream* source, unsigned int size_guess = 0) const = 0; /** compresses a datastream (memory or file) to another DataStream */ - virtual int Compress(DataStream *dest, DataStream* source) = 0; + virtual int Compress(DataStream *dest, DataStream* source) const = 0; }; #endif diff --git a/gemrb/core/Core.cpp b/gemrb/core/Core.cpp index 6edd08949..affc2bb73 100644 --- a/gemrb/core/Core.cpp +++ b/gemrb/core/Core.cpp @@ -124,7 +124,7 @@ static const unsigned char orientations[25]={ }; /** Calculates the orientation of a character (or projectile) facing a point */ -unsigned char GetOrient(Point &s, Point &d) +unsigned char GetOrient(const Point &s, const Point &d) { int deltaX = s.x - d.x; int deltaY = s.y - d.y; diff --git a/gemrb/core/DataFileMgr.h b/gemrb/core/DataFileMgr.h index ee9d759d2..860a70b64 100644 --- a/gemrb/core/DataFileMgr.h +++ b/gemrb/core/DataFileMgr.h @@ -41,18 +41,18 @@ public: DataFileMgr(void); virtual ~DataFileMgr(void); virtual bool Open(DataStream* stream, bool autoFree = false) = 0; - virtual int GetTagsCount() = 0; - virtual const char* GetTagNameByIndex(int index) = 0; - virtual int GetKeysCount(const char* Tag) = 0; - virtual const char* GetKeyNameByIndex(const char* Tag, int index) = 0; + virtual int GetTagsCount() const = 0; + virtual const char* GetTagNameByIndex(int index) const = 0; + virtual int GetKeysCount(const char* Tag) const = 0; + virtual const char* GetKeyNameByIndex(const char* Tag, int index) const = 0; virtual const char* GetKeyAsString(const char* Tag, const char* Key, - const char* Default) = 0; + const char* Default) const = 0; virtual int GetKeyAsInt(const char* Tag, const char* Key, - const int Default) = 0; + const int Default) const = 0; virtual float GetKeyAsFloat(const char* Tag, const char* Key, - const float Default) = 0; + const float Default) const = 0; virtual bool GetKeyAsBool(const char* Tag, const char* Key, - const bool Default) = 0; + const bool Default) const = 0; }; #endif diff --git a/gemrb/core/DialogMgr.h b/gemrb/core/DialogMgr.h index 7c9df06ba..5a8126e6c 100644 --- a/gemrb/core/DialogMgr.h +++ b/gemrb/core/DialogMgr.h @@ -30,7 +30,7 @@ public: DialogMgr(void); virtual ~DialogMgr(void); virtual bool Open(DataStream* stream, bool autoFree = true) = 0; - virtual Dialog* GetDialog() = 0; + virtual Dialog* GetDialog() const = 0; }; #endif diff --git a/gemrb/core/Effect.h b/gemrb/core/Effect.h index 4428a5f12..622aeb937 100644 --- a/gemrb/core/Effect.h +++ b/gemrb/core/Effect.h @@ -121,7 +121,7 @@ struct Effect { ieDword random_value; public: //don't modify position in case it was already set - void SetPosition(Point &p) { + void SetPosition(const Point &p) { if(PosX==0xffffffff && PosY==0xffffffff) { PosX=p.x; PosY=p.y; diff --git a/gemrb/core/EffectQueue.cpp b/gemrb/core/EffectQueue.cpp index c3436113d..e40ab43a0 100644 --- a/gemrb/core/EffectQueue.cpp +++ b/gemrb/core/EffectQueue.cpp @@ -493,7 +493,7 @@ void EffectQueue::Cleanup() } //Handle the target flag when the effect is applied first -int EffectQueue::AddEffect(Effect* fx, Scriptable* self, Actor* pretarget, Point &dest) const +int EffectQueue::AddEffect(Effect* fx, Scriptable* self, Actor* pretarget, const Point &dest) const { int i; Game *game; @@ -663,7 +663,7 @@ all_party: //will get copied (hence the fxqueue.AddEffect call) //if this returns FX_NOT_APPLIED, then the whole stack was resisted //or expired -int EffectQueue::AddAllEffects(Actor* target, Point &destination) const +int EffectQueue::AddAllEffects(Actor* target, const Point &destination) const { int res = FX_NOT_APPLIED; // pre-roll dice for fx needing them and stow them in the effect @@ -1893,7 +1893,7 @@ int EffectQueue::CheckImmunity(Actor *target) const return 0; } -void EffectQueue::AffectAllInRange(Map *map, Point &pos, int idstype, int idsvalue, +void EffectQueue::AffectAllInRange(Map *map, const Point &pos, int idstype, int idsvalue, unsigned int range, Actor *except) { int cnt = map->GetActorCount(true); diff --git a/gemrb/core/EffectQueue.h b/gemrb/core/EffectQueue.h index 50585275b..8e2153cdb 100644 --- a/gemrb/core/EffectQueue.h +++ b/gemrb/core/EffectQueue.h @@ -182,12 +182,12 @@ public: /** Adds an Effect to the queue, subject to level and other checks. * Returns FX_ABORT is unsuccessful. fx is just a reference, AddEffect() * will malloc its own copy */ - int AddEffect(Effect* fx, Scriptable* self, Actor* pretarget, Point &dest) const; + int AddEffect(Effect* fx, Scriptable* self, Actor* pretarget, const Point &dest) const; /** Removes first Effect matching fx from the queue. * Effects are matched based on their contents */ bool RemoveEffect(Effect* fx); - int AddAllEffects(Actor* target, Point &dest) const; + int AddAllEffects(Actor* target, const Point &dest) const; void ApplyAllEffects(Actor* target) const; /** remove effects marked for removal */ void Cleanup(); @@ -261,7 +261,7 @@ public: int CheckImmunity(Actor *target) const; // apply this effectqueue on all actors matching ids targeting // from pos, in range (no cone size yet) - void AffectAllInRange(Map *map, Point &pos, int idstype, int idsvalue, unsigned int range, Actor *except); + void AffectAllInRange(Map *map, const Point &pos, int idstype, int idsvalue, unsigned int range, Actor *except); /** Lists contents of the queue on a terminal for debugging */ void dump() const; //resolve effect diff --git a/gemrb/core/Factory.cpp b/gemrb/core/Factory.cpp index 85eb87849..aa7dbabb4 100644 --- a/gemrb/core/Factory.cpp +++ b/gemrb/core/Factory.cpp @@ -38,7 +38,7 @@ void Factory::AddFactoryObject(FactoryObject* fobject) fobjects.push_back( fobject ); } -int Factory::IsLoaded(const char* ResRef, SClass_ID type) +int Factory::IsLoaded(const char* ResRef, SClass_ID type) const { for (unsigned int i = 0; i < fobjects.size(); i++) { if (fobjects[i]->SuperClassID == type) { @@ -50,7 +50,7 @@ int Factory::IsLoaded(const char* ResRef, SClass_ID type) return -1; } -FactoryObject* Factory::GetFactoryObject(int pos) +FactoryObject* Factory::GetFactoryObject(int pos) const { return fobjects[pos]; } diff --git a/gemrb/core/Factory.h b/gemrb/core/Factory.h index 495ab9170..ec21d708e 100644 --- a/gemrb/core/Factory.h +++ b/gemrb/core/Factory.h @@ -33,8 +33,8 @@ public: Factory(void); ~Factory(void); void AddFactoryObject(FactoryObject* fobject); - int IsLoaded(const char* ResRef, SClass_ID type); - FactoryObject* GetFactoryObject(int pos); + int IsLoaded(const char* ResRef, SClass_ID type) const; + FactoryObject* GetFactoryObject(int pos) const; void FreeObjects(void); }; diff --git a/gemrb/core/Font.cpp b/gemrb/core/Font.cpp index d37d51920..a946d9324 100644 --- a/gemrb/core/Font.cpp +++ b/gemrb/core/Font.cpp @@ -116,7 +116,7 @@ void Font::AddChar(unsigned char* spr, int w, int h, short xPos, short yPos) void Font::PrintFromLine(int startrow, Region rgn, const unsigned char* string, Palette* hicolor, unsigned char Alignment, Font* initials, - Sprite2D* cursor, unsigned int curpos, bool NoColor) + Sprite2D* cursor, unsigned int curpos, bool NoColor) const { bool enablecap=false; int capital = 0; @@ -281,14 +281,14 @@ void Font::PrintFromLine(int startrow, Region rgn, const unsigned char* string, void Font::Print(Region rgn, const unsigned char* string, Palette* hicolor, unsigned char Alignment, bool anchor, Font* initials, - Sprite2D* cursor, unsigned int curpos, bool NoColor) + Sprite2D* cursor, unsigned int curpos, bool NoColor) const { Print(rgn, rgn, string, hicolor, Alignment, anchor, initials, cursor, curpos, NoColor); } void Font::Print(Region cliprgn, Region rgn, const unsigned char* string, Palette* hicolor, unsigned char Alignment, bool anchor, Font* initials, - Sprite2D* cursor, unsigned int curpos, bool NoColor) + Sprite2D* cursor, unsigned int curpos, bool NoColor) const { bool enablecap=false; int capital = 0; @@ -437,7 +437,7 @@ void Font::Print(Region cliprgn, Region rgn, const unsigned char* string, free( tmp ); } -int Font::PrintInitial(int x, int y, Region &rgn, unsigned char currChar) +int Font::PrintInitial(int x, int y, const Region &rgn, unsigned char currChar) const { Video *video = core->GetVideoDriver(); video->BlitSpriteRegion( sprBuffer, size[currChar], @@ -446,7 +446,7 @@ int Font::PrintInitial(int x, int y, Region &rgn, unsigned char currChar) return x; } -int Font::CalcStringWidth(const char* string, bool NoColor) +int Font::CalcStringWidth(const char* string, bool NoColor) const { size_t ret = 0, len = strlen( string ); for (size_t i = 0; i < len; i++) { @@ -470,7 +470,7 @@ int Font::CalcStringWidth(const char* string, bool NoColor) return ( int ) ret; } -void Font::SetupString(char* string, unsigned int width, bool NoColor) +void Font::SetupString(char* string, unsigned int width, bool NoColor) const { size_t len = strlen( string ); unsigned int psx = PARAGRAPH_START_X; @@ -537,7 +537,7 @@ void Font::SetupString(char* string, unsigned int width, bool NoColor) } } -Palette* Font::GetPalette() +Palette* Font::GetPalette() const { assert(palette); palette->IncRef(); diff --git a/gemrb/core/Font.h b/gemrb/core/Font.h index 56f3734d3..ec4ea7944 100644 --- a/gemrb/core/Font.h +++ b/gemrb/core/Font.h @@ -84,27 +84,27 @@ public: void Print(Region cliprgn, Region rgn, const unsigned char* string, Palette* color, unsigned char Alignment, bool anchor = false, Font* initials = NULL, Sprite2D* cursor = NULL, - unsigned int curpos = 0, bool NoColor = false); + unsigned int curpos = 0, bool NoColor = false) const; void Print(Region rgn, const unsigned char* string, Palette* color, unsigned char Alignment, bool anchor = false, Font* initials = NULL, Sprite2D* cursor = NULL, - unsigned int curpos = 0, bool NoColor = false); + unsigned int curpos = 0, bool NoColor = false) const; void PrintFromLine(int startrow, Region rgn, const unsigned char* string, Palette* color, unsigned char Alignment, Font* initials = NULL, Sprite2D* cursor = NULL, - unsigned int curpos = 0, bool NoColor = false); + unsigned int curpos = 0, bool NoColor = false) const; - Palette* GetPalette(); + Palette* GetPalette() const; void SetPalette(Palette* pal); /** Returns width of the string rendered in this font in pixels */ - int CalcStringWidth(const char* string, bool NoColor = false); - void SetupString(char* string, unsigned int width, bool NoColor = false); + int CalcStringWidth(const char* string, bool NoColor = false) const; + void SetupString(char* string, unsigned int width, bool NoColor = false) const; /** Sets ASCII code of the first character in the font. * (it allows remapping numeric fonts from \000 to '0') */ void SetFirstChar(unsigned char first); private: - int PrintInitial(int x, int y, Region &rgn, unsigned char currChar); + int PrintInitial(int x, int y, const Region &rgn, unsigned char currChar) const; }; #endif diff --git a/gemrb/core/GSUtils.cpp b/gemrb/core/GSUtils.cpp index 2f90149ab..a4ac8af07 100644 --- a/gemrb/core/GSUtils.cpp +++ b/gemrb/core/GSUtils.cpp @@ -958,7 +958,7 @@ void CreateVisualEffectCore(Actor *target, const char *effect, int iterations) } } -void CreateVisualEffectCore(Scriptable *Sender, Point &position, const char *effect, int iterations) +void CreateVisualEffectCore(Scriptable *Sender, const Point &position, const char *effect, int iterations) { ScriptedAnimation *vvc = GetVVCEffect(effect, iterations); if (vvc) { @@ -986,7 +986,7 @@ void ChangeAnimationCore(Actor *src, const char *resref, bool effect) } } -void EscapeAreaCore(Scriptable* Sender, Point &p, const char* area, Point &enter, int flags, int wait) +void EscapeAreaCore(Scriptable* Sender, const Point &p, const char* area, const Point &enter, int flags, int wait) { char Tmp[256]; @@ -1331,7 +1331,7 @@ void BeginDialog(Scriptable* Sender, Action* parameters, int Flags) } -void MoveBetweenAreasCore(Actor* actor, const char *area, Point &position, int face, bool adjust) +void MoveBetweenAreasCore(Actor* actor, const char *area, const Point &position, int face, bool adjust) { printMessage("GameScript", " ", WHITE); printf("MoveBetweenAreas: %s to %s [%d.%d] face: %d\n", actor->GetName(0), area,position.x,position.y, face); @@ -1868,7 +1868,7 @@ Action* GenerateActionCore(const char *src, const char *str, int acIndex) return newAction; } -void GoNear(Scriptable *Sender, Point &p) +void GoNear(Scriptable *Sender, const Point &p) { if (Sender->GetCurrentAction()) { printMessage("GameScript","Target busy???\n",LIGHT_RED); @@ -1924,7 +1924,7 @@ void MoveNearerTo(Scriptable *Sender, Scriptable *target, int distance) //It is not always good to release the current action if target is unreachable //we should also raise the trigger TargetUnreachable (if this is an Attack, at least) //i hacked only this low level function, didn't need the higher ones so far -int MoveNearerTo(Scriptable *Sender, Point &p, int distance, int dont_release) +int MoveNearerTo(Scriptable *Sender, const Point &p, int distance, int dont_release) { if (Sender->Type != ST_ACTOR) { printMessage("GameScript","MoveNearerTo only works with actors\n",LIGHT_RED); @@ -1956,7 +1956,7 @@ void GoNearAndRetry(Scriptable *Sender, Scriptable *target, bool flag, int dista GoNearAndRetry(Sender, p, distance); } -void GoNearAndRetry(Scriptable *Sender, Point &p, int distance) +void GoNearAndRetry(Scriptable *Sender, const Point &p, int distance) { if (!Sender->GetCurrentAction() ) { printMessage("GameScript","NULL action retried???\n",LIGHT_RED); diff --git a/gemrb/core/GSUtils.h b/gemrb/core/GSUtils.h index 895254cc7..0d8a874f6 100644 --- a/gemrb/core/GSUtils.h +++ b/gemrb/core/GSUtils.h @@ -66,7 +66,7 @@ bool HasItemCore(Inventory *inventory, const ieResRef itemname, ieDword flags); void ClickCore(Scriptable *Sender, Point point, int type, int speed); void TransformItemCore(Actor *actor, Action *parameters, bool onlyone); void CreateVisualEffectCore(Actor *target, const char *effect, int iterations); -void CreateVisualEffectCore(Scriptable *Sender, Point &position, const char *effect, int iterations); +void CreateVisualEffectCore(Scriptable *Sender, const Point &position, const char *effect, int iterations); void GetPositionFromScriptable(Scriptable* scr, Point &position, bool trap); void BeginDialog(Scriptable* Sender, Action* parameters, int flags); void ChangeAnimationCore(Actor *src, const char *resref, bool effect); @@ -86,12 +86,12 @@ bool ResolveSpellName(ieResRef spellres, Action *parameter); GEM_EXPORT void ResolveSpellName(ieResRef spellres, ieDword number); ieDword ResolveSpellNumber(const ieResRef spellres); bool ResolveItemName(ieResRef itemres, Actor *act, ieDword Slot); -void EscapeAreaCore(Scriptable *Sender, Point &p, const char *area, Point &enter, int flags, int wait); -void GoNear(Scriptable *Sender, Point &p); +void EscapeAreaCore(Scriptable *Sender, const Point &p, const char *area, const Point &enter, int flags, int wait); +void GoNear(Scriptable *Sender, const Point &p); void MoveNearerTo(Scriptable *Sender, Scriptable *target, int distance); -int MoveNearerTo(Scriptable *Sender, Point &p, int distance, int no_release); +int MoveNearerTo(Scriptable *Sender, const Point &p, int distance, int no_release); void GoNearAndRetry(Scriptable *Sender, Scriptable *target, bool destination, int distance); -void GoNearAndRetry(Scriptable *Sender, Point &p, int distance); +void GoNearAndRetry(Scriptable *Sender, const Point &p, int distance); #define NO_OPERATION -1 #define LESS_OR_EQUALS 0 @@ -134,7 +134,7 @@ GEM_EXPORT int SeeCore(Scriptable* Sender, Trigger* parameters, int justlos); GEM_EXPORT int DiffCore(ieDword a, ieDword b, int diffmode); GEM_EXPORT void DisplayStringCore(Scriptable* Sender, int Strref, int flags); GEM_EXPORT void SetVariable(Scriptable* Sender, const char* VarName, const char* Context, ieDword value); -GEM_EXPORT void MoveBetweenAreasCore(Actor* actor, const char *area, Point &position, int face, bool adjust); +GEM_EXPORT void MoveBetweenAreasCore(Actor* actor, const char *area, const Point &position, int face, bool adjust); GEM_EXPORT ieDword CheckVariable(Scriptable* Sender, const char* VarName, bool *valid = NULL); GEM_EXPORT ieDword CheckVariable(Scriptable* Sender, const char* VarName, const char* Context, bool *valid = NULL); Action* GenerateActionCore(const char *src, const char *str, int acIndex); diff --git a/gemrb/core/Game.cpp b/gemrb/core/Game.cpp index 7918e538a..1a34b9705 100644 --- a/gemrb/core/Game.cpp +++ b/gemrb/core/Game.cpp @@ -961,7 +961,7 @@ bool Game::EveryoneStopped() const } //canmove=true: if some PC can't move (or hostile), then this returns false -bool Game::EveryoneNearPoint(Map *area, Point &p, int flags) const +bool Game::EveryoneNearPoint(Map *area, const Point &p, int flags) const { for (unsigned int i=0; iGetVideoDriver(); @@ -1448,7 +1448,7 @@ void GameControl::TryToBash(Actor *source, Scriptable *tgt) } //generate action code for source actor to use item/cast spell on a point -void GameControl::TryToCast(Actor *source, Point &tgt) +void GameControl::TryToCast(Actor *source, const Point &tgt) { char Tmp[40]; @@ -2038,7 +2038,7 @@ void GameControl::OnSpecialKeyPress(unsigned char Key) } } -void GameControl::CalculateSelection(Point &p) +void GameControl::CalculateSelection(const Point &p) { unsigned int i; Game* game = core->GetGame(); @@ -2684,7 +2684,7 @@ end_of_choose: } //Create an overhead text over an arbitrary point -void GameControl::DisplayString(Point &p, const char *Text) +void GameControl::DisplayString(const Point &p, const char *Text) { Scriptable* scr = new Scriptable( ST_TRIGGER ); scr->overHeadText = (char *) Text; diff --git a/gemrb/core/GameControl.h b/gemrb/core/GameControl.h index 33c7c9c52..6bc2b833c 100644 --- a/gemrb/core/GameControl.h +++ b/gemrb/core/GameControl.h @@ -167,14 +167,14 @@ private: void QuickSave(); /** this function safely retrieves an Actor by ID */ Actor *GetActorByGlobalID(ieWord ID); - void CalculateSelection(Point &p); + void CalculateSelection(const Point &p); void ResizeDel(Window* win, int type); void ResizeAdd(Window* win, int type); void HandleWindowHide(const char *WindowName, const char *WindowPosition); void HandleWindowReveal(const char *WindowName, const char *WindowPosition); void ReadFormations(); /** Draws an arrow on the edge of the screen based on the point (points at offscreen actors) */ - void DrawArrowMarker(Region &screen, Point p, Region &viewport); + void DrawArrowMarker(const Region &screen, Point p, const Region &viewport); private: unsigned char LeftCount, BottomCount, RightCount, TopCount; @@ -203,7 +203,7 @@ public: int UnhideGUI(); void TryToAttack(Actor *source, Actor *target); void TryToBash(Actor *source, Scriptable *tgt); - void TryToCast(Actor *source, Point &p); + void TryToCast(Actor *source, const Point &p); void TryToCast(Actor *source, Actor *target); void TryToDefend(Actor *source, Actor *target); void TryToTalk(Actor *source, Actor *target); @@ -226,14 +226,14 @@ public: Point GetFormationOffset(ieDword formation, ieDword pos); void MoveToPointFormation(Actor *actor, unsigned int pos, Point src, Point p); /** calls MoveToPoint or RunToPoint */ - void CreateMovement(Actor *actor, Point &p); + void CreateMovement(Actor *actor, const Point &p); int InitDialog(Scriptable* speaker, Scriptable* target, const char* dlgref); void EndDialog(bool try_to_break=false); void DialogChoose(unsigned int choose); /** Displays a string over an object */ void DisplayString(Scriptable* target); /** Displays a string on screen */ - void DisplayString(Point &p, const char *Text); + void DisplayString(const Point &p, const char *Text); Actor *GetLastActor(); /** changes map to the current PC */ void ChangeMap(Actor *pc, bool forced); diff --git a/gemrb/core/GameData.h b/gemrb/core/GameData.h index 4ef8c7b80..125b63009 100644 --- a/gemrb/core/GameData.h +++ b/gemrb/core/GameData.h @@ -111,7 +111,7 @@ public: : Holder(static_cast(gamedata->GetResource(resname,&T::ID))) { } - ResourceHolder(const char* resname, ResourceManager& manager, bool silent = false) + ResourceHolder(const char* resname, const ResourceManager& manager, bool silent = false) : Holder(static_cast(manager.GetResource(resname,&T::ID,silent))) { } diff --git a/gemrb/core/Image.h b/gemrb/core/Image.h index 949dbc48d..8e0aa7eef 100644 --- a/gemrb/core/Image.h +++ b/gemrb/core/Image.h @@ -28,7 +28,7 @@ class GEM_EXPORT Image { public: Image(unsigned int height, unsigned int width); ~Image(); - Color GetPixel(unsigned int x, unsigned int y) + Color GetPixel(unsigned int x, unsigned int y) const { if (x >= width || y >= height) { static const Color black = { 0, 0, 0, 0 }; @@ -44,11 +44,11 @@ public: data[width*y+x] = idx; } - unsigned int GetHeight() + unsigned int GetHeight() const { return height; } - unsigned int GetWidth() + unsigned int GetWidth() const { return width; } diff --git a/gemrb/core/Interface.cpp b/gemrb/core/Interface.cpp index d7b668ca4..2a42afc9e 100644 --- a/gemrb/core/Interface.cpp +++ b/gemrb/core/Interface.cpp @@ -2462,7 +2462,7 @@ ScriptEngine* Interface::GetGUIScriptEngine() const } //NOTE: if there were more summoned creatures, it will return only the last -Actor *Interface::SummonCreature(const ieResRef resource, const ieResRef vvcres, Scriptable *Owner, Actor *target, Point &position, int eamod, int level, Effect *fx, bool sexmod) +Actor *Interface::SummonCreature(const ieResRef resource, const ieResRef vvcres, Scriptable *Owner, Actor *target, const Point &position, int eamod, int level, Effect *fx, bool sexmod) { //maximum number of monsters summoned int cnt=10; @@ -4854,7 +4854,7 @@ void Interface::ApplySpell(const ieResRef resname, Actor *actor, Scriptable *cas delete fxqueue; } -void Interface::ApplySpellPoint(const ieResRef resname, Map* area, Point &pos, Scriptable *caster, int level) +void Interface::ApplySpellPoint(const ieResRef resname, Map* area, const Point &pos, Scriptable *caster, int level) { Spell *spell = gamedata->GetSpell(resname); if (!spell) { @@ -4902,7 +4902,7 @@ int Interface::ApplyEffect(Effect *effect, Actor *actor, Scriptable *caster) return res; } -Effect *Interface::GetEffect(const ieResRef resname, int level, Point &p) +Effect *Interface::GetEffect(const ieResRef resname, int level, const Point &p) { //Don't free this reference, it is cached! Effect *effect = gamedata->GetEffect(resname); @@ -5179,7 +5179,7 @@ void Interface::RegisterOpcodes(int count, const EffectRef *opcodes) EffectQueue_RegisterOpcodes(count, opcodes); } -void Interface::SetInfoTextColor(Color &color) +void Interface::SetInfoTextColor(const Color &color) { if (InfoTextPalette) { gamedata->FreePalette(InfoTextPalette); diff --git a/gemrb/core/Interface.h b/gemrb/core/Interface.h index 8203d299a..ecbfeb6eb 100644 --- a/gemrb/core/Interface.h +++ b/gemrb/core/Interface.h @@ -363,7 +363,7 @@ public: /* makes sure the string is freed in TLKImp */ void FreeString(char *&str) const; /* sets the floattext color */ - void SetInfoTextColor(Color &color); + void SetInfoTextColor(const Color &color); /** returns a gradient set */ Color * GetPalette(unsigned index, int colors, Color *buffer) const; /** Returns a preloaded Font */ @@ -379,7 +379,7 @@ public: ScriptEngine * GetGUIScriptEngine() const; /** core for summoning creatures, returns the last created Actor may apply a single fx on the summoned creature normally an unsummon effect */ - Actor *SummonCreature(const ieResRef resource, const ieResRef vvcres, Scriptable *Owner, Actor *target, Point &position, int eamod, int level, Effect *fx, bool sexmod=1); + Actor *SummonCreature(const ieResRef resource, const ieResRef vvcres, Scriptable *Owner, Actor *target, const Point &position, int eamod, int level, Effect *fx, bool sexmod=1); /** Loads a WindowPack (CHUI file) in the Window Manager */ bool LoadWindowPack(const char *name); /** Loads a Window in the Window Manager */ @@ -615,12 +615,12 @@ public: /** applies the spell on the target */ void ApplySpell(const ieResRef resname, Actor *target, Scriptable *caster, int level); /** applies the spell on the area or on a scriptable object */ - void ApplySpellPoint(const ieResRef resname, Map *area, Point &pos, Scriptable *caster, int level); + void ApplySpellPoint(const ieResRef resname, Map *area, const Point &pos, Scriptable *caster, int level); /** applies a single effect on the target */ int ApplyEffect(Effect *fx, Actor *target, Scriptable *caster); - //int ApplyEffect(const ieResRef resname, Actor *target, Scriptable *caster, int level, Point &p); + //int ApplyEffect(const ieResRef resname, Actor *target, Scriptable *caster, int level, const Point &p); //Actor *target, Scriptable *caster, - Effect *GetEffect(const ieResRef resname, int level, Point &p); + Effect *GetEffect(const ieResRef resname, int level, const Point &p); /** dumps an area object to the cache */ int SwapoutArea(Map *map); /** saves (exports a character to the characters folder */ diff --git a/gemrb/core/Inventory.cpp b/gemrb/core/Inventory.cpp index 7a359ddba..8b3da78ee 100644 --- a/gemrb/core/Inventory.cpp +++ b/gemrb/core/Inventory.cpp @@ -715,7 +715,7 @@ int Inventory::FindItem(const char *resref, unsigned int flags) const return -1; } -bool Inventory::DropItemAtLocation(unsigned int slot, unsigned int flags, Map *map, Point &loc) +bool Inventory::DropItemAtLocation(unsigned int slot, unsigned int flags, Map *map, const Point &loc) { if (slot >= Slots.size()) { return false; @@ -743,7 +743,7 @@ bool Inventory::DropItemAtLocation(unsigned int slot, unsigned int flags, Map *m return true; } -bool Inventory::DropItemAtLocation(const char *resref, unsigned int flags, Map *map, Point &loc) +bool Inventory::DropItemAtLocation(const char *resref, unsigned int flags, Map *map, const Point &loc) { bool dropped = false; diff --git a/gemrb/core/Inventory.h b/gemrb/core/Inventory.h index 68031d844..042753f34 100644 --- a/gemrb/core/Inventory.h +++ b/gemrb/core/Inventory.h @@ -258,8 +258,8 @@ public: void ChargeAllItems(int hours); /** Finds the first slot of named item, if resref is empty, finds the first filled! slot */ int FindItem(const char *resref, unsigned int flags) const; - bool DropItemAtLocation(unsigned int slot, unsigned int flags, Map *map, Point &loc); - bool DropItemAtLocation(const char *resref, unsigned int flags, Map *map, Point &loc); + bool DropItemAtLocation(unsigned int slot, unsigned int flags, Map *map, const Point &loc); + bool DropItemAtLocation(const char *resref, unsigned int flags, Map *map, const Point &loc); bool SetEquippedSlot(ieWordSigned slotcode, ieWord header); int GetEquipped() const; int GetEquippedHeader() const; diff --git a/gemrb/core/Label.cpp b/gemrb/core/Label.cpp index c57673d3b..ecdee2b81 100644 --- a/gemrb/core/Label.cpp +++ b/gemrb/core/Label.cpp @@ -144,7 +144,7 @@ bool Label::SetEvent(int eventType, const char *handler) } /** Simply returns the pointer to the text, don't modify it! */ -const char* Label::QueryText() +const char* Label::QueryText() const { return ( const char * ) Buffer; } diff --git a/gemrb/core/Label.h b/gemrb/core/Label.h index ab573ad2e..f94953f74 100644 --- a/gemrb/core/Label.h +++ b/gemrb/core/Label.h @@ -55,7 +55,7 @@ public: /** Sets the Alignment of Text */ void SetAlignment(unsigned char Alignment); /** Simply returns the pointer to the text, don't modify it! */ - const char* QueryText(); + const char* QueryText() const; /** Mouse Button Down */ void OnMouseUp(unsigned short x, unsigned short y, unsigned short Button, diff --git a/gemrb/core/Map.cpp b/gemrb/core/Map.cpp index 4925fa835..3475ef4ff 100644 --- a/gemrb/core/Map.cpp +++ b/gemrb/core/Map.cpp @@ -1146,7 +1146,7 @@ void Map::DrawMap(Region screen) oldgametime=gametime; } -void Map::DrawSearchMap(Region &screen) +void Map::DrawSearchMap(const Region &screen) { Color inaccessible = { 128, 128, 128, 128 }; Video *vid=core->GetVideoDriver(); @@ -1219,7 +1219,7 @@ void Map::Shout(Actor* actor, int shoutID, unsigned int radius) } } -bool Map::AnyEnemyNearPoint(Point &p) +bool Map::AnyEnemyNearPoint(const Point &p) { ieDword gametime = core->GetGame()->GameTime; size_t i = actors.size(); @@ -1338,7 +1338,7 @@ Actor* Map::GetActorByGlobalID(ieDword objectID) GA_POINT 64 - not actor specific GA_NO_HIDDEN 128 - hidden actors don't play */ -Actor* Map::GetActor(Point &p, int flags) +Actor* Map::GetActor(const Point &p, int flags) { ieDword gametime = core->GetGame()->GameTime; size_t i = actors.size(); @@ -1358,7 +1358,7 @@ Actor* Map::GetActor(Point &p, int flags) return NULL; } -Actor* Map::GetActorInRadius(Point &p, int flags, unsigned int radius) +Actor* Map::GetActorInRadius(const Point &p, int flags, unsigned int radius) { ieDword gametime = core->GetGame()->GameTime; size_t i = actors.size(); @@ -1378,7 +1378,7 @@ Actor* Map::GetActorInRadius(Point &p, int flags, unsigned int radius) return NULL; } -Actor **Map::GetAllActorsInRadius(Point &p, int flags, unsigned int radius) +Actor **Map::GetAllActorsInRadius(const Point &p, int flags, unsigned int radius) { ieDword count = 1; size_t i; @@ -1621,7 +1621,7 @@ bool Map::GetBlocked(unsigned int px, unsigned int py, unsigned int size) return false; } -unsigned char Map::GetBlocked(Point &c) +unsigned char Map::GetBlocked(const Point &c) { return GetBlocked(c.x/16, c.y/12); } @@ -1788,7 +1788,7 @@ void Map::SortQueues() } } -void Map::AddProjectile(Projectile* pro, Point &source, ieWord actorID) +void Map::AddProjectile(Projectile* pro, const Point &source, ieWord actorID) { proIterator iter; @@ -1800,7 +1800,7 @@ void Map::AddProjectile(Projectile* pro, Point &source, ieWord actorID) } //adding projectile in order, based on its height parameter -void Map::AddProjectile(Projectile* pro, Point &source, Point &dest) +void Map::AddProjectile(Projectile* pro, const Point &source, const Point &dest) { proIterator iter; @@ -1813,7 +1813,7 @@ void Map::AddProjectile(Projectile* pro, Point &source, Point &dest) //returns the longest duration of the VVC cell named 'resource' (if it exists) //if P is empty, the position won't be checked -ieDword Map::HasVVCCell(const ieResRef resource, Point &p) +ieDword Map::HasVVCCell(const ieResRef resource, const Point &p) { scaIterator iter; ieDword ret = 0; @@ -1939,7 +1939,7 @@ bool Map::CanFree() return true; } -void Map::DebugDump(bool show_actors) +void Map::DebugDump(bool show_actors) const { printf( "DebugDump of Area %s:\n", scriptName ); printf( "OutDoor: %s\n", YESNO(AreaType & AT_OUTDOOR ) ); @@ -2096,7 +2096,7 @@ void Map::AdjustPosition(Point &goal, unsigned int radius) } //run away from dX, dY (ie.: find the best path of limited length that brings us the farthest from dX, dY) -PathNode* Map::RunAway(Point &s, Point &d, unsigned int size, unsigned int PathLen, int flags) +PathNode* Map::RunAway(const Point &s, const Point &d, unsigned int size, unsigned int PathLen, int flags) { Point start(s.x/16, s.y/12); Point goal (d.x/16, d.y/12); @@ -2196,7 +2196,7 @@ PathNode* Map::RunAway(Point &s, Point &d, unsigned int size, unsigned int PathL return Return; } -bool Map::TargetUnreachable(Point &s, Point &d, unsigned int size) +bool Map::TargetUnreachable(const Point &s, const Point &d, unsigned int size) { Point start( s.x/16, s.y/12 ); Point goal ( d.x/16, d.y/12 ); @@ -2237,13 +2237,13 @@ bool Map::TargetUnreachable(Point &s, Point &d, unsigned int size) /* Use this function when you target something by a straight line projectile (like a lightning bolt, arrow, etc) */ -PathNode* Map::GetLine(Point &start, Point &dest, int flags) +PathNode* Map::GetLine(const Point &start, const Point &dest, int flags) { int Orientation = GetOrient(start, dest); return GetLine(start, dest, 1, Orientation, flags); } -PathNode* Map::GetLine(Point &start, int Steps, int Orientation, int flags) +PathNode* Map::GetLine(const Point &start, int Steps, int Orientation, int flags) { Point dest=start; @@ -2255,7 +2255,7 @@ PathNode* Map::GetLine(Point &start, int Steps, int Orientation, int flags) return GetLine(start, dest, Steps, Orientation, flags); } -PathNode* Map::GetLine(Point &start, Point &dest, int Speed, int Orientation, int flags) +PathNode* Map::GetLine(const Point &start, const Point &dest, int Speed, int Orientation, int flags) { PathNode* StartNode = new PathNode; PathNode *Return = StartNode; @@ -2616,7 +2616,7 @@ bool Map::IsVisible(const Point &s, const Point &d) } //returns direction of area boundary, returns -1 if it isn't a boundary -int Map::WhichEdge(Point &s) +int Map::WhichEdge(const Point &s) { unsigned int sX=s.x/16; unsigned int sY=s.y/12; @@ -2650,7 +2650,7 @@ void Map::SetupAmbients() } //--------mapnotes---------------- //text must be a pointer we can claim ownership of -void Map::AddMapNote(Point &point, int color, char *text, ieStrRef strref) +void Map::AddMapNote(const Point &point, int color, char *text, ieStrRef strref) { MapNote *mn = new MapNote; @@ -2662,7 +2662,7 @@ void Map::AddMapNote(Point &point, int color, char *text, ieStrRef strref) mapnotes.push_back(mn); } -void Map::RemoveMapNote(Point &point) +void Map::RemoveMapNote(const Point &point) { size_t i = mapnotes.size(); while (i--) { @@ -2674,7 +2674,7 @@ void Map::RemoveMapNote(Point &point) } } -MapNote *Map::GetMapNote(Point &point) +MapNote *Map::GetMapNote(const Point &point) { size_t i = mapnotes.size(); while (i--) { @@ -2691,7 +2691,7 @@ void Map::LoadIniSpawn() INISpawn->InitSpawn(WEDResRef); } -void Map::SpawnCreature(Point &pos, const char *CreName, int radius) +void Map::SpawnCreature(const Point &pos, const char *CreName, int radius) { SpawnGroup *sg=NULL; Actor *creature; @@ -2769,7 +2769,7 @@ current) is compared against (party level * rest header difficulty). If it's greater, the spawning is aborted. If all the other conditions are true, at least one creature is summoned, regardless the difficulty cap. */ -bool Map::Rest(Point &pos, int hours, int day) +bool Map::Rest(const Point &pos, int hours, int day) { if (!RestHeader.CreatureNum || !RestHeader.Enabled || !RestHeader.Maximum) { return false; @@ -2823,7 +2823,7 @@ void Map::SetMapVisibility(int setreset) } // x, y are in tile coordinates -void Map::ExploreTile(Point &pos) +void Map::ExploreTile(const Point &pos) { int h = TMap->YCellCount * 2 + LargeFog; int y = pos.y/32; @@ -2843,7 +2843,7 @@ void Map::ExploreTile(Point &pos) VisibleBitmap[by] |= bi; } -void Map::ExploreMapChunk(Point &Pos, int range, int los) +void Map::ExploreMapChunk(const Point &Pos, int range, int los) { Point Tile; @@ -2905,7 +2905,7 @@ void Map::UpdateFog() } //Valid values are - PATH_MAP_FREE, PATH_MAP_PC, PATH_MAP_NPC -void Map::BlockSearchMap(Point &Pos, unsigned int size, unsigned int value) +void Map::BlockSearchMap(const Point &Pos, unsigned int size, unsigned int value) { // We block a circle of radius size-1 around (px,py) // Note that this does not exactly match BG2. BG2's approximations of @@ -2953,7 +2953,7 @@ Spawn* Map::GetSpawn(const char* Name) return NULL; } -Spawn *Map::GetSpawnRadius(Point &point, unsigned int radius) +Spawn *Map::GetSpawnRadius(const Point &point, unsigned int radius) { for (size_t i = 0; i < spawns.size(); i++) { Spawn* sp = spawns[i]; @@ -2982,7 +2982,7 @@ int Map::ConsolidateContainers() //Pos could be [-1,-1] in which case it copies the ground piles to their //original position in the second area -void Map::CopyGroundPiles(Map *othermap, Point &Pos) +void Map::CopyGroundPiles(Map *othermap, const Point &Pos) { int containercount = (int) TMap->GetContainerCount(); while (containercount--) { @@ -3005,7 +3005,7 @@ void Map::CopyGroundPiles(Map *othermap, Point &Pos) } } -Container *Map::GetPile(Point &position) +Container *Map::GetPile(Point position) { Point tmp[4]; char heapname[32]; @@ -3035,7 +3035,7 @@ Container *Map::GetPile(Point &position) return container; } -void Map::AddItemToLocation(Point &position, CREItem *item) +void Map::AddItemToLocation(const Point &position, CREItem *item) { Container *container = GetPile(position); container->AddItem(item); @@ -3053,7 +3053,7 @@ Container* Map::AddContainer(const char* Name, unsigned short Type, return c; } -int Map::GetCursor( Point &p) +int Map::GetCursor( const Point &p) { if (!IsVisible( p, true ) ) { return IE_CURSOR_INVALID; @@ -3093,7 +3093,7 @@ int Map::GetWeather() return WB_NORMAL; } -void Map::FadeSparkle(Point &pos, bool forced) +void Map::FadeSparkle(const Point &pos, bool forced) { spaIterator iter; @@ -3110,7 +3110,7 @@ void Map::FadeSparkle(Point &pos, bool forced) } } -void Map::Sparkle(ieDword color, ieDword type, Point &pos, unsigned int FragAnimID) +void Map::Sparkle(ieDword color, ieDword type, const Point &pos, unsigned int FragAnimID) { int style, path, grow, size, width; @@ -3207,7 +3207,7 @@ bool Map::DisplayTrackString(Actor *target) // returns a lightness level in the range of [0-100] // since the lightmap is much smaller than the area, we need to interpolate -unsigned int Map::GetLightLevel(Point &Pos) +unsigned int Map::GetLightLevel(const Point &Pos) { Color c = LightMap->GetPixel(Pos.x/16, Pos.y/12); // at night/dusk/dawn the lightmap color is adjusted by the color overlay. (Only get's darker.) @@ -3348,7 +3348,7 @@ bool AreaAnimation::Schedule(ieDword gametime) return false; } -void AreaAnimation::Draw(Region &screen, Map *area) +void AreaAnimation::Draw(const Region &screen, Map *area) { int ac=animcount; Video* video = core->GetVideoDriver(); diff --git a/gemrb/core/Map.h b/gemrb/core/Map.h index 6ce0ba659..e6d77eb89 100644 --- a/gemrb/core/Map.h +++ b/gemrb/core/Map.h @@ -197,7 +197,7 @@ public: void SetPalette(ieResRef PaletteRef); void BlendAnimation(); bool Schedule(ieDword gametime); - void Draw(Region &screen, Map *area); + void Draw(const Region &screen, Map *area); private: Animation *GetAnimationPiece(AnimationFactory *af, int animCycle); }; @@ -265,7 +265,7 @@ public: static void ReleaseMemory(); /** prints useful information on console */ - void DebugDump(bool show_actors=0); + void DebugDump(bool show_actors=0) const; TileMap *GetTileMap() { return TMap; } /* gets the signal of daylight changes */ bool ChangeMap(bool day_or_night); @@ -280,7 +280,7 @@ public: /* removes empty heaps and returns total itemcount */ int ConsolidateContainers(); /* transfers all piles (loose items) to another map */ - void CopyGroundPiles(Map *othermap, Point &Pos); + void CopyGroundPiles(Map *othermap, const Point &Pos); /* draws stationary vvc graphics */ //void DrawVideocells(Region screen); void DrawHighlightables(Region screen); @@ -312,14 +312,14 @@ public: void ActorSpottedByPlayer(Actor *actor); void AddActor(Actor* actor); //returns true if an enemy is near P (used in resting/saving) - bool AnyEnemyNearPoint(Point &p); + bool AnyEnemyNearPoint(const Point &p); bool GetBlocked(unsigned int x, unsigned int y, unsigned int size); unsigned char GetBlocked(unsigned int x, unsigned int y); - unsigned char GetBlocked(Point &p); + unsigned char GetBlocked(const Point &p); Actor* GetActorByGlobalID(ieDword objectID); - Actor* GetActor(Point &p, int flags); - Actor* GetActorInRadius(Point &p, int flags, unsigned int radius); - Actor **GetAllActorsInRadius(Point &p, int flags, unsigned int radius); + Actor* GetActor(const Point &p, int flags); + Actor* GetActorInRadius(const Point &p, int flags, unsigned int radius); + Actor **GetAllActorsInRadius(const Point &p, int flags, unsigned int radius); Actor* GetActor(const char* Name, int flags); Actor* GetActor(int i, bool any); Actor* GetActorByDialog(const char* resref); @@ -346,20 +346,20 @@ public: //get the next saved projectile Projectile* GetNextTrap(proIterator &iter); //add a projectile to the area - void AddProjectile(Projectile* pro, Point &source, Point &dest); - void AddProjectile(Projectile* pro, Point &source, ieWord actorID); + void AddProjectile(Projectile* pro, const Point &source, const Point &dest); + void AddProjectile(Projectile* pro, const Point &source, ieWord actorID); //returns the duration of a VVC cell set in the area (point may be set to empty) - ieDword HasVVCCell(const ieResRef resource, Point &p); + ieDword HasVVCCell(const ieResRef resource, const Point &p); void AddVVCell(ScriptedAnimation* vvc); bool CanFree(); - int GetCursor( Point &p); + int GetCursor( const Point &p); //adds a sparkle puff of colour to a point in the area //FragAnimID is an optional avatar animation ID (see avatars.2da) for //fragment animation - void Sparkle(ieDword color, ieDword type, Point &pos, unsigned int FragAnimID = 0); + void Sparkle(ieDword color, ieDword type, const Point &pos, unsigned int FragAnimID = 0); //removes or fades the sparkle puff at a point - void FadeSparkle(Point &pos, bool forced); + void FadeSparkle(const Point &pos, bool forced); //entrances void AddEntrance(char* Name, int XPos, int YPos, short Face); @@ -371,8 +371,8 @@ public: /* this function returns/creates a pile container at position */ Container* AddContainer(const char* Name, unsigned short Type, Gem_Polygon* outline); - Container *GetPile(Point &position); - void AddItemToLocation(Point &position, CREItem *item); + Container *GetPile(Point position); + void AddItemToLocation(const Point &position, CREItem *item); int GetWidth() const { return Width; } int GetHeight() const { return Height; } @@ -382,11 +382,11 @@ public: /*fills the visible bitmap with setreset */ void SetMapVisibility(int setreset = 0); /* set one fog tile as visible. x, y are tile coordinates */ - void ExploreTile(Point &Tile); + void ExploreTile(const Point &Tile); /* explore map from given point in map coordinates */ - void ExploreMapChunk(Point &Pos, int range, int los); + void ExploreMapChunk(const Point &Pos, int range, int los); /* block or unblock searchmap with value */ - void BlockSearchMap(Point &Pos, unsigned int size, unsigned int value); + void BlockSearchMap(const Point &Pos, unsigned int size, unsigned int value); void ClearSearchMapFor(Movable *actor); /* update VisibleBitmap by resolving vision of all explore actors */ void UpdateFog(); @@ -394,15 +394,15 @@ public: /* Finds the nearest passable point */ void AdjustPosition(Point &goal, unsigned int radius=0); /* Finds the path which leads the farthest from d */ - PathNode* RunAway(Point &s, Point &d, unsigned int size, unsigned int PathLen, int flags); + PathNode* RunAway(const Point &s, const Point &d, unsigned int size, unsigned int PathLen, int flags); /* Returns true if there is no path to d */ - bool TargetUnreachable(Point &s, Point &d, unsigned int size); + bool TargetUnreachable(const Point &s, const Point &d, unsigned int size); /* returns true if there is enemy visible */ bool AnyPCSeesEnemy(); /* Finds straight path from s, length l and orientation o, f=1 passes wall, f=2 rebounds from wall*/ - PathNode* GetLine(Point &start, Point &dest, int flags); - PathNode* GetLine(Point &start, int Steps, int Orientation, int flags); - PathNode* GetLine(Point &start, Point &dest, int speed, int Orientation, int flags); + PathNode* GetLine(const Point &start, const Point &dest, int flags); + PathNode* GetLine(const Point &start, int Steps, int Orientation, int flags); + PathNode* GetLine(const Point &start, const Point &dest, int speed, int Orientation, int flags); /* Finds the path which leads to near d */ PathNode* FindPathNear(const Point &s, const Point &d, unsigned int size, unsigned int MinDistance = 0, bool sight = true); /* Finds the path which leads to d */ @@ -412,7 +412,7 @@ public: /* returns false if point d cannot be seen from point d due to searchmap */ bool IsVisible(const Point &s, const Point &d); /* returns edge direction of map boundary, only worldmap regions */ - int WhichEdge(Point &s); + int WhichEdge(const Point &s); //ambients void AddAmbient(Ambient *ambient) { ambients.push_back(ambient); } @@ -421,16 +421,16 @@ public: unsigned int GetAmbientCount() { return (unsigned int) ambients.size(); } //mapnotes - void AddMapNote(Point &point, int color, char *text, ieStrRef strref); - void RemoveMapNote(Point &point); + void AddMapNote(const Point &point, int color, char *text, ieStrRef strref); + void RemoveMapNote(const Point &point); MapNote *GetMapNote(int i) { return mapnotes[i]; } - MapNote *GetMapNote(Point &point); + MapNote *GetMapNote(const Point &point); unsigned int GetMapNoteCount() { return (unsigned int) mapnotes.size(); } //restheader /* May spawn creature(s), returns true in case of an interrupted rest */ - bool Rest(Point &pos, int hours, int day); + bool Rest(const Point &pos, int hours, int day); /* Spawns creature(s) in radius of position */ - void SpawnCreature(Point &pos, const char *CreName, int radius = 0); + void SpawnCreature(const Point &pos, const char *CreName, int radius = 0); //spawns void LoadIniSpawn(); @@ -440,7 +440,7 @@ public: Spawn *GetSpawn(const char *Name); //returns spawn inside circle, checks for schedule and other //conditions as well - Spawn *GetSpawnRadius(Point &point, unsigned int radius); + Spawn *GetSpawnRadius(const Point &point, unsigned int radius); unsigned int GetSpawnCount() { return (unsigned int) spawns.size(); } void TriggerSpawn(Spawn *spawn); //move some or all players to a new area @@ -451,13 +451,13 @@ public: void SetTrackString(ieStrRef strref, int flg, int difficulty); //returns true if tracking failed bool DisplayTrackString(Actor *actor); - unsigned int GetLightLevel(Point &Pos); + unsigned int GetLightLevel(const Point &Pos); private: AreaAnimation *GetNextAreaAnimation(aniIterator &iter, ieDword gametime); Particles *GetNextSpark(spaIterator &iter); ScriptedAnimation *GetNextScriptedAnimation(scaIterator &iter); Actor *GetNextActor(int &q, int &index); - void DrawSearchMap(Region &screen); + void DrawSearchMap(const Region &screen); void GenerateQueues(); void SortQueues(); //Actor* GetRoot(int priority, int &index); diff --git a/gemrb/core/Palette.h b/gemrb/core/Palette.h index 28dab3bab..31c2076f1 100644 --- a/gemrb/core/Palette.h +++ b/gemrb/core/Palette.h @@ -49,7 +49,7 @@ struct RGBModifier { class GEM_EXPORT Palette { public: - Palette(Color* colours, bool alpha_=false) { + Palette(const Color* colours, bool alpha_=false) { for (int i = 0; i < 256; ++i) { col[i] = colours[i]; } diff --git a/gemrb/core/Particles.cpp b/gemrb/core/Particles.cpp index 38a260cf5..54e2686dc 100644 --- a/gemrb/core/Particles.cpp +++ b/gemrb/core/Particles.cpp @@ -131,7 +131,7 @@ void Particles::SetBitmap(unsigned int FragAnimID) */ } -bool Particles::AddNew(Point &point) +bool Particles::AddNew(const Point &point) { int st; @@ -173,7 +173,7 @@ bool Particles::AddNew(Point &point) return true; } -void Particles::Draw(Region &screen) +void Particles::Draw(const Region &screen) { int length; //used only for raindrops diff --git a/gemrb/core/Particles.h b/gemrb/core/Particles.h index e21b416c1..296c03906 100644 --- a/gemrb/core/Particles.h +++ b/gemrb/core/Particles.h @@ -85,8 +85,8 @@ public: void SetBitmap(unsigned int FragAnimID); void SetPhase(ieByte ph) { phase = ph; } - int GetPhase() { return phase; } - bool MatchPos(Point &p) { return pos.x==p.x && pos.y==p.y; } + int GetPhase() const { return phase; } + bool MatchPos(const Point &p) const { return pos.x==p.x && pos.y==p.y; } void SetType(ieByte t, ieByte p=SP_PATH_FALL, ieByte st=SP_SPAWN_NONE) { type=t; @@ -103,12 +103,12 @@ public: void SetColor(ieByte c) { color=c; } void SetOwner(Scriptable *o) { owner=o; } /* returns true if it cannot add new elements */ - bool AddNew(Point &point); - void Draw(Region &screen); + bool AddNew(const Point &point); + void Draw(const Region &screen); void AddParticles(int count); /* returns true if it could be destroyed (didn't draw anything) */ int Update(); - int GetHeight() { return pos.y+pos.h; } + int GetHeight() const { return pos.y+pos.h; } private: Element *points; ieDword target; //could be 0, in that case target is pos diff --git a/gemrb/core/PluginMgr.cpp b/gemrb/core/PluginMgr.cpp index 4f2f06d12..6a34dfcee 100644 --- a/gemrb/core/PluginMgr.cpp +++ b/gemrb/core/PluginMgr.cpp @@ -292,13 +292,13 @@ void PluginMgr::RegisterCleanup(void (*func)(void)) cleanupFunctions.push_back(func); } -void PluginMgr::RunInitializers() +void PluginMgr::RunInitializers() const { for (size_t i = 0; i < intializerFunctions.size(); i++) intializerFunctions[i](); } -void PluginMgr::RunCleanup() +void PluginMgr::RunCleanup() const { for (size_t i = 0; i < cleanupFunctions.size(); i++) cleanupFunctions[i](); diff --git a/gemrb/core/PluginMgr.h b/gemrb/core/PluginMgr.h index ec568952d..f9f2e5993 100644 --- a/gemrb/core/PluginMgr.h +++ b/gemrb/core/PluginMgr.h @@ -124,9 +124,9 @@ public: void RegisterCleanup(void (*cleanup)(void)); /** Run intializer functions. */ - void RunInitializers(); + void RunInitializers() const; /** Run cleanup functions */ - void RunCleanup(); + void RunCleanup() const; /** * Registers a driver plugin diff --git a/gemrb/core/Polygon.cpp b/gemrb/core/Polygon.cpp index f0e0f33ad..e741fe85d 100644 --- a/gemrb/core/Polygon.cpp +++ b/gemrb/core/Polygon.cpp @@ -75,13 +75,13 @@ void Gem_Polygon::RecalcBBox() BBox.h-=BBox.y; } -bool Gem_Polygon::PointIn(Point &p) +bool Gem_Polygon::PointIn(const Point &p) const { if(!BBox.PointInside(p) ) return false; return PointIn(p.x, p.y); } -bool Gem_Polygon::PointIn(int tx, int ty) +bool Gem_Polygon::PointIn(int tx, int ty) const { register int j, yflag0, yflag1, xflag0 , index; bool inside_flag = false; @@ -120,20 +120,20 @@ bool Gem_Polygon::PointIn(int tx, int ty) // returns twice the area of triangle a, b, c. // (can also be negative depending on orientation of a,b,c) -inline int area2(Point& a, Point& b, Point& c) +inline int area2(const Point& a, const Point& b, const Point& c) { return (b.x - a.x) * (c.y - a.y) - (c.x - a.x) * (b.y - a.y); } // return (c is to the left of a-b) -inline bool left(Point& a, Point& b, Point& c) +inline bool left(const Point& a, const Point& b, const Point& c) { return (area2(a, b, c) > 0); } // { return (c is collinear with a-b) -inline bool collinear(Point& a, Point& b, Point& c) +inline bool collinear(const Point& a, const Point& b, const Point& c) { return (area2(a, b, c) == 0); } @@ -352,7 +352,7 @@ void Gem_Polygon::ComputeTrapezoids() // wall polygons -void Wall_Polygon::SetBaseline(Point &a, Point &b) +void Wall_Polygon::SetBaseline(const Point &a, const Point &b) { if ((a.x trapezoids; - bool PointIn(Point &p); - bool PointIn(int x, int y); + bool PointIn(const Point &p) const; + bool PointIn(int x, int y) const; void RecalcBBox(); void ComputeTrapezoids(); }; @@ -67,11 +67,11 @@ class GEM_EXPORT Wall_Polygon: public Gem_Polygon { public: Wall_Polygon(Point *points,int count,Region *bbox) : Gem_Polygon(points,count,bbox) {} //is the point above the baseline - bool PointCovered(Point &p); - bool PointCovered(int x, int y); - ieDword GetPolygonFlag() { return wall_flag; } + bool PointCovered(const Point &p) const; + bool PointCovered(int x, int y) const; + ieDword GetPolygonFlag() const { return wall_flag; } void SetPolygonFlag(ieDword flg) { wall_flag=flg; } - void SetBaseline(Point &a, Point &b); + void SetBaseline(const Point &a, const Point &b); public: ieDword wall_flag; Point base0, base1; diff --git a/gemrb/core/Projectile.cpp b/gemrb/core/Projectile.cpp index cdc967880..65358ec51 100644 --- a/gemrb/core/Projectile.cpp +++ b/gemrb/core/Projectile.cpp @@ -629,12 +629,12 @@ void Projectile::SetCaster(ieDword caster) Caster=caster; } -ieDword Projectile::GetCaster() +ieDword Projectile::GetCaster() const { return Caster; } -void Projectile::NextTarget(Point &p) +void Projectile::NextTarget(const Point &p) { ClearPath(); Destination = p; @@ -659,7 +659,7 @@ void Projectile::NextTarget(Point &p) path = area->GetLine( Pos, Destination, Speed, Orientation, GL_PASS ); } -void Projectile::SetTarget(Point &p) +void Projectile::SetTarget(const Point &p) { Target = 0; NextTarget(p); @@ -689,7 +689,7 @@ void Projectile::SetTarget(ieDword tar) } } -void Projectile::MoveTo(Map *map, Point &Des) +void Projectile::MoveTo(Map *map, const Point &Des) { area = map; Origin = Des; @@ -911,7 +911,7 @@ int Projectile::Update() return 1; } -void Projectile::Draw(Region &screen) +void Projectile::Draw(const Region &screen) { switch (phase) { case P_UNINITED: @@ -937,7 +937,7 @@ void Projectile::Draw(Region &screen) } } -bool Projectile::DrawChildren(Region &screen) +bool Projectile::DrawChildren(const Region &screen) { bool drawn = false; @@ -959,7 +959,7 @@ bool Projectile::DrawChildren(Region &screen) } //draw until all children expire -void Projectile::DrawExploded(Region &screen) +void Projectile::DrawExploded(const Region &screen) { if (DrawChildren(screen)) { return; @@ -967,7 +967,7 @@ void Projectile::DrawExploded(Region &screen) phase = P_EXPIRED; } -void Projectile::DrawExplosion(Region &screen) +void Projectile::DrawExplosion(const Region &screen) { //This seems to be a needless safeguard if (!Extension) { @@ -1219,7 +1219,7 @@ void Projectile::SetupWall() SetTarget(p2); } -void Projectile::DrawLine(Region &screen, int face, ieDword flag) +void Projectile::DrawLine(const Region &screen, int face, ieDword flag) { Video *video = core->GetVideoDriver(); PathNode *iter = path; @@ -1238,7 +1238,7 @@ void Projectile::DrawLine(Region &screen, int face, ieDword flag) } } -void Projectile::DrawTravel(Region &screen) +void Projectile::DrawTravel(const Region &screen) { Video *video = core->GetVideoDriver(); ieDword flag; @@ -1370,7 +1370,7 @@ void Projectile::SetIdentifiers(const char *resref, ieWord id) type=id; } -bool Projectile::PointInRadius(Point &p) +bool Projectile::PointInRadius(const Point &p) const { switch(phase) { //better not trigger on projectiles unset/expired @@ -1399,7 +1399,7 @@ void Projectile::SetGradient(int gradient, bool type) } } -void Projectile::StaticTint(Color &newtint) +void Projectile::StaticTint(const Color &newtint) { tint = newtint; TFlags &= ~PTF_TINT; //turn off area tint diff --git a/gemrb/core/Projectile.h b/gemrb/core/Projectile.h index ce69186a9..15a691cb4 100644 --- a/gemrb/core/Projectile.h +++ b/gemrb/core/Projectile.h @@ -221,10 +221,10 @@ protected: int pathcounter; public: void SetCaster(ieDword t); - ieDword GetCaster(); + ieDword GetCaster() const; void SetTarget(ieDword t); - void SetTarget(Point &p); - bool PointInRadius(Point &p); + void SetTarget(const Point &p); + bool PointInRadius(const Point &p) const; void Cleanup(); //inliners to protect data consistency @@ -240,7 +240,7 @@ public: inline ieWord GetType() const { return type; } //This assumes that the effect queue cannot be bigger than 65535 //which is a sane expectation - inline EffectQueue *GetEffects() { + inline EffectQueue *GetEffects() const { return effects; } @@ -298,14 +298,14 @@ public: //sets how long a created travel projectile will hover over a spot //before vanishing (without the need of area extension) void SetDelay(int delay); - void MoveTo(Map *map, Point &Des); + void MoveTo(Map *map, const Point &Des); void ClearPath(); //handle phases, return 0 when expired int Update(); //draw object - void Draw(Region &screen); + void Draw(const Region &screen); void SetGradient(int gradient, bool tint); - void StaticTint(Color &newtint); + void StaticTint(const Color &newtint); private: //creates a child projectile with current_projectile_id - 1 void CreateIteration(); @@ -326,18 +326,18 @@ private: void SecondaryTarget(); //area projectiles (circles, cones) void CheckTrigger(unsigned int radius); void SetupWall(); - void DrawLine(Region &screen, int face, ieDword flag); - void DrawTravel(Region &screen); - bool DrawChildren(Region &screen); - void DrawExplosion(Region &screen); - void DrawExploded(Region &screen); + void DrawLine(const Region &screen, int face, ieDword flag); + void DrawTravel(const Region &screen); + bool DrawChildren(const Region &screen); + void DrawExplosion(const Region &screen); + void DrawExploded(const Region &screen); int GetTravelPos(int face); int GetShadowPos(int face); void SetPos(int face, int frame1, int frame2); //logic to resolve target when single projectile hit destination int CalculateTargetFlag(); Actor *GetTarget(); - void NextTarget(Point &p); + void NextTarget(const Point &p); void SetupPalette(Animation *anim[], Palette *&pal, const ieByte *gradients); }; diff --git a/gemrb/core/Region.cpp b/gemrb/core/Region.cpp index c2890e3c5..ac1e32e5a 100644 --- a/gemrb/core/Region.cpp +++ b/gemrb/core/Region.cpp @@ -97,7 +97,7 @@ bool Point::isempty() const return false; } -bool Point::PointInside(Point &p) +bool Point::PointInside(const Point &p) const { if (( p.x < 0 ) || ( p.x > x )) { return false; @@ -167,7 +167,7 @@ Region::Region(const Point &p, int w, int h) this->h = h; } -bool Region::PointInside(Point &p) +bool Region::PointInside(const Point &p) const { if (( p.x < x ) || ( p.x > ( x + w ) )) { return false; @@ -178,7 +178,7 @@ bool Region::PointInside(Point &p) return true; } -bool Region::PointInside(unsigned short XPos, unsigned short YPos) +bool Region::PointInside(unsigned short XPos, unsigned short YPos) const { if (( XPos < x ) || ( XPos > ( x + w ) )) { return false; @@ -189,7 +189,7 @@ bool Region::PointInside(unsigned short XPos, unsigned short YPos) return true; } -bool Region::InsideRegion(Region& rgn) +bool Region::InsideRegion(const Region& rgn) const { if (x > ( rgn.x + rgn.w )) { return false; diff --git a/gemrb/core/Region.h b/gemrb/core/Region.h index 0c4cd391b..9548a9053 100644 --- a/gemrb/core/Region.h +++ b/gemrb/core/Region.h @@ -60,7 +60,7 @@ public: x=0; y=0; } - bool PointInside(Point &p); + bool PointInside(const Point &p) const; ieDword asDword() const; // store coordinates in uint32 ((y << 16) | x) void fromDword(ieDword val); // extract coordinates from uint32 @@ -88,9 +88,9 @@ public: bool operator==(const Region& rgn); bool operator!=(const Region& rgn); Region(int x, int y, int w, int h); - bool PointInside(unsigned short XPos, unsigned short YPos); - bool PointInside(Point &p); - bool InsideRegion(Region& rgn); + bool PointInside(unsigned short XPos, unsigned short YPos) const; + bool PointInside(const Point &p) const; + bool InsideRegion(const Region& rgn) const; void Normalize(); }; diff --git a/gemrb/core/ResourceManager.cpp b/gemrb/core/ResourceManager.cpp index ef6bdf620..2c3d8d336 100644 --- a/gemrb/core/ResourceManager.cpp +++ b/gemrb/core/ResourceManager.cpp @@ -52,7 +52,7 @@ static void PrintPossibleFiles(const char* ResRef, const TypeID *type) } } -bool ResourceManager::Exists(const char *ResRef, SClass_ID type, bool silent) +bool ResourceManager::Exists(const char *ResRef, SClass_ID type, bool silent) const { if (ResRef[0] == '\0') return false; @@ -70,7 +70,7 @@ bool ResourceManager::Exists(const char *ResRef, SClass_ID type, bool silent) return false; } -bool ResourceManager::Exists(const char *ResRef, const TypeID *type, bool silent) +bool ResourceManager::Exists(const char *ResRef, const TypeID *type, bool silent) const { if (ResRef[0] == '\0') return false; diff --git a/gemrb/core/ResourceManager.h b/gemrb/core/ResourceManager.h index 2608d15ad..777d534b3 100644 --- a/gemrb/core/ResourceManager.h +++ b/gemrb/core/ResourceManager.h @@ -50,9 +50,9 @@ public: bool AddSource(const char *path, const char *description, PluginID type); /** returns true if resource exists */ - bool Exists(const char *ResRef, SClass_ID type, bool silent=false); + bool Exists(const char *ResRef, SClass_ID type, bool silent=false) const; /** returns true if resource exists */ - bool Exists(const char *ResRef, const TypeID *type, bool silent=false); + bool Exists(const char *ResRef, const TypeID *type, bool silent=false) const; /** Returns stream associated to given resource */ DataStream* GetResource(const char* resname, SClass_ID type, bool silent = false) const; diff --git a/gemrb/core/SaveGameIterator.cpp b/gemrb/core/SaveGameIterator.cpp index 08d18a61a..a6cb35a21 100644 --- a/gemrb/core/SaveGameIterator.cpp +++ b/gemrb/core/SaveGameIterator.cpp @@ -106,7 +106,7 @@ SaveGame::~SaveGame() { } -Sprite2D* SaveGame::GetPortrait(int index) +Sprite2D* SaveGame::GetPortrait(int index) const { if (index > PortraitCount) { return NULL; @@ -119,7 +119,7 @@ Sprite2D* SaveGame::GetPortrait(int index) return im->GetSprite2D(); } -Sprite2D* SaveGame::GetPreview() +Sprite2D* SaveGame::GetPreview() const { ResourceHolder im(Prefix, manager, true); if (!im) @@ -127,22 +127,22 @@ Sprite2D* SaveGame::GetPreview() return im->GetSprite2D(); } -DataStream* SaveGame::GetGame() +DataStream* SaveGame::GetGame() const { return manager.GetResource(Prefix, IE_GAM_CLASS_ID, true); } -DataStream* SaveGame::GetWmap() +DataStream* SaveGame::GetWmap() const { return manager.GetResource(core->WorldMapName, IE_WMP_CLASS_ID, true); } -DataStream* SaveGame::GetSave() +DataStream* SaveGame::GetSave() const { return manager.GetResource(Prefix, IE_SAV_CLASS_ID, true); } -const char* SaveGame::GetGameDate() +const char* SaveGame::GetGameDate() const { return GameDate; } diff --git a/gemrb/core/SaveGameIterator.h b/gemrb/core/SaveGameIterator.h index 447801b68..4c11163d8 100644 --- a/gemrb/core/SaveGameIterator.h +++ b/gemrb/core/SaveGameIterator.h @@ -39,41 +39,41 @@ public: public: SaveGame(const char* path, const char* name, const char* prefix, const char* slotname, int pCount, int saveID); ~SaveGame(); - int GetPortraitCount() + int GetPortraitCount() const { return PortraitCount; } - int GetSaveID() + int GetSaveID() const { return SaveID; } - const char* GetName() + const char* GetName() const { return Name; } - const char* GetPrefix() + const char* GetPrefix() const { return Prefix; } - const char* GetPath() + const char* GetPath() const { return Path; } - const char* GetDate() + const char* GetDate() const { return Date; } - const char* GetGameDate(); - const char* GetSlotName() + const char* GetGameDate() const; + const char* GetSlotName() const { return SlotName; } - Sprite2D* GetPortrait(int index); - Sprite2D* GetPreview(); - DataStream* GetGame(); - DataStream* GetWmap(); - DataStream* GetSave(); + Sprite2D* GetPortrait(int index) const; + Sprite2D* GetPreview() const; + DataStream* GetGame() const; + DataStream* GetWmap() const; + DataStream* GetSave() const; private: char Path[_MAX_PATH]; char Prefix[10]; diff --git a/gemrb/core/ScriptedAnimation.cpp b/gemrb/core/ScriptedAnimation.cpp index 98d3073bc..cd1ca2594 100644 --- a/gemrb/core/ScriptedAnimation.cpp +++ b/gemrb/core/ScriptedAnimation.cpp @@ -559,7 +559,7 @@ retry: } //it is not sure if we need tint at all -bool ScriptedAnimation::Draw(Region &screen, Point &Pos, Color &p_tint, Map *area, int dither, int orientation) +bool ScriptedAnimation::Draw(const Region &screen, const Point &Pos, const Color &p_tint, Map *area, int dither, int orientation) { if (FaceTarget) { SetOrientation(orientation); diff --git a/gemrb/core/ScriptedAnimation.h b/gemrb/core/ScriptedAnimation.h index f67bb1ace..333805ba0 100644 --- a/gemrb/core/ScriptedAnimation.h +++ b/gemrb/core/ScriptedAnimation.h @@ -87,7 +87,7 @@ public: ScriptedAnimation *twin; public: //draws the next frame of the videocell - bool Draw(Region &screen, Point &Pos, Color &tint, Map *area, int dither, int orientation); + bool Draw(const Region &screen, const Point &Pos, const Color &tint, Map *area, int dither, int orientation); //sets phase (0-2) void SetPhase(int arg); //sets sound for phase (p_onset, p_hold, p_release) diff --git a/gemrb/core/SoundMgr.h b/gemrb/core/SoundMgr.h index 68125e290..6c3e38796 100644 --- a/gemrb/core/SoundMgr.h +++ b/gemrb/core/SoundMgr.h @@ -42,15 +42,15 @@ public: * @returns Number of samples read. */ virtual int read_samples( short* memory, int cnt ) = 0 ; - int get_channels() + int get_channels() const { return channels; } - int get_samplerate() + int get_samplerate() const { return samplerate; } - int get_length() + int get_length() const { return samples; } // returns the total samples count diff --git a/gemrb/core/Spell.cpp b/gemrb/core/Spell.cpp index 6851624de..5fd38fe74 100644 --- a/gemrb/core/Spell.cpp +++ b/gemrb/core/Spell.cpp @@ -83,7 +83,7 @@ void Spell::AddCastingGlow(EffectQueue *fxqueue, ieDword duration) delete fx; } -EffectQueue *Spell::GetEffectBlock(Scriptable *self, Point &pos, int block_index, ieDword pro) const +EffectQueue *Spell::GetEffectBlock(Scriptable *self, const Point &pos, int block_index, ieDword pro) const { Effect *features; int count; @@ -135,7 +135,7 @@ EffectQueue *Spell::GetEffectBlock(Scriptable *self, Point &pos, int block_index return fxqueue; } -Projectile *Spell::GetProjectile(Scriptable *self, int header, Point &target) const +Projectile *Spell::GetProjectile(Scriptable *self, int header, const Point &target) const { SPLExtHeader *seh = GetExtHeader(header); if (!seh) { diff --git a/gemrb/core/Spell.h b/gemrb/core/Spell.h index 8858f5f35..5efcbea90 100644 --- a/gemrb/core/Spell.h +++ b/gemrb/core/Spell.h @@ -158,11 +158,11 @@ public: //converts a wanted level to block index count int GetHeaderIndexFromLevel(int level) const; //-1 will return the cfb - EffectQueue *GetEffectBlock(Scriptable *self, Point &pos, int block_index, ieDword pro=0) const; + EffectQueue *GetEffectBlock(Scriptable *self, const Point &pos, int block_index, ieDword pro=0) const; // add appropriate casting glow effect void AddCastingGlow(EffectQueue *fxqueue, ieDword duration); //returns a projectile created from an extended header - Projectile *GetProjectile(Scriptable *self, int headerindex, Point &pos) const; + Projectile *GetProjectile(Scriptable *self, int headerindex, const Point &pos) const; unsigned int GetCastingDistance(Actor *actor) const; }; diff --git a/gemrb/core/Sprite2D.cpp b/gemrb/core/Sprite2D.cpp index a6806e974..151c78e41 100644 --- a/gemrb/core/Sprite2D.cpp +++ b/gemrb/core/Sprite2D.cpp @@ -39,7 +39,7 @@ Sprite2D::~Sprite2D(void) { } -bool Sprite2D::IsPixelTransparent(unsigned short x, unsigned short y) +bool Sprite2D::IsPixelTransparent(unsigned short x, unsigned short y) const { if (x >= Width || y >= Height) return true; @@ -76,7 +76,7 @@ bool Sprite2D::IsPixelTransparent(unsigned short x, unsigned short y) } /** Get the Palette of a Sprite */ -Palette* Sprite2D::GetPalette() +Palette* Sprite2D::GetPalette() const { if (!vptr) return NULL; if (!BAM) { @@ -101,7 +101,7 @@ void Sprite2D::SetPalette(Palette* pal) } } -Color Sprite2D::GetPixel(unsigned short x, unsigned short y) +Color Sprite2D::GetPixel(unsigned short x, unsigned short y) const { Color c = { 0, 0, 0, 0 }; diff --git a/gemrb/core/Sprite2D.h b/gemrb/core/Sprite2D.h index ceddf5a11..715d23579 100644 --- a/gemrb/core/Sprite2D.h +++ b/gemrb/core/Sprite2D.h @@ -67,10 +67,10 @@ public: int XPos, YPos, Width, Height, Bpp; Sprite2D(void); ~Sprite2D(void); - bool IsPixelTransparent(unsigned short x, unsigned short y); - Palette *GetPalette(); + bool IsPixelTransparent(unsigned short x, unsigned short y) const; + Palette *GetPalette() const; void SetPalette(Palette *pal); - Color GetPixel(unsigned short x, unsigned short y); + Color GetPixel(unsigned short x, unsigned short y) const; public: // public only for SDLVideo int RefCount; public: diff --git a/gemrb/core/SpriteCover.cpp b/gemrb/core/SpriteCover.cpp index 6671f4b3c..e5fcf8954 100644 --- a/gemrb/core/SpriteCover.cpp +++ b/gemrb/core/SpriteCover.cpp @@ -33,7 +33,7 @@ SpriteCover::~SpriteCover() } bool SpriteCover::Covers(int x, int y, int xpos, int ypos, - int width, int height) + int width, int height) const { // if basepoint changed, no longer valid if (x != worldx || y != worldy) return false; diff --git a/gemrb/core/SpriteCover.h b/gemrb/core/SpriteCover.h index d9b71e984..9e1484716 100644 --- a/gemrb/core/SpriteCover.h +++ b/gemrb/core/SpriteCover.h @@ -32,7 +32,7 @@ public: SpriteCover(void); ~SpriteCover(void); - bool Covers(int x, int y, int xpos, int ypos, int width, int height); + bool Covers(int x, int y, int xpos, int ypos, int width, int height) const; }; diff --git a/gemrb/core/SymbolMgr.h b/gemrb/core/SymbolMgr.h index 78b03c364..08a0df2d0 100644 --- a/gemrb/core/SymbolMgr.h +++ b/gemrb/core/SymbolMgr.h @@ -44,13 +44,13 @@ public: SymbolMgr(void); virtual ~SymbolMgr(void); virtual bool Open(DataStream* stream, bool autoFree = true) = 0; - virtual int GetValue(const char* text) = 0; - virtual char* GetValue(int val) = 0; - virtual char* GetStringIndex(unsigned int Index) = 0; - virtual int GetValueIndex(unsigned int Index) = 0; - virtual int FindValue(int val) = 0; - virtual int FindString(char *str, int len) = 0; - virtual int GetSize() = 0; + virtual int GetValue(const char* text) const = 0; + virtual char* GetValue(int val) const = 0; + virtual char* GetStringIndex(unsigned int Index) const = 0; + virtual int GetValueIndex(unsigned int Index) const = 0; + virtual int FindValue(int val) const = 0; + virtual int FindString(char *str, int len) const = 0; + virtual int GetSize() const = 0; }; #endif // ! SYMBOLMGR_H diff --git a/gemrb/core/TileMap.cpp b/gemrb/core/TileMap.cpp index 78c735d84..e364b1059 100644 --- a/gemrb/core/TileMap.cpp +++ b/gemrb/core/TileMap.cpp @@ -105,7 +105,7 @@ Door* TileMap::AddDoor(const char *ID, const char* Name, unsigned int Flags, return door; } -Door* TileMap::GetDoor(unsigned int idx) +Door* TileMap::GetDoor(unsigned int idx) const { if (idx >= doors.size()) { return NULL; @@ -113,7 +113,7 @@ Door* TileMap::GetDoor(unsigned int idx) return doors[idx]; } -Door* TileMap::GetDoor(Point &p) +Door* TileMap::GetDoor(const Point &p) const { for (size_t i = 0; i < doors.size(); i++) { Gem_Polygon *doorpoly; @@ -138,7 +138,7 @@ Door* TileMap::GetDoor(Point &p) return NULL; } -Door* TileMap::GetDoorByPosition(Point &p) +Door* TileMap::GetDoorByPosition(const Point &p) const { for (size_t i = 0; i < doors.size(); i++) { Door* door = doors[i]; @@ -153,7 +153,7 @@ Door* TileMap::GetDoorByPosition(Point &p) return NULL; } -Door* TileMap::GetDoor(const char* Name) +Door* TileMap::GetDoor(const char* Name) const { if (!Name) { return NULL; @@ -413,7 +413,7 @@ void TileMap::AddContainer(Container *c) containers.push_back(c); } -Container* TileMap::GetContainer(unsigned int idx) +Container* TileMap::GetContainer(unsigned int idx) const { if (idx >= containers.size()) { return NULL; @@ -421,7 +421,7 @@ Container* TileMap::GetContainer(unsigned int idx) return containers[idx]; } -Container* TileMap::GetContainer(const char* Name) +Container* TileMap::GetContainer(const char* Name) const { for (size_t i = 0; i < containers.size(); i++) { Container* cn = containers[i]; @@ -434,7 +434,7 @@ Container* TileMap::GetContainer(const char* Name) //look for a container at position //use type = IE_CONTAINER_PILE if you want to find ground piles only //in this case, empty piles won't be found! -Container* TileMap::GetContainer(Point &position, int type) +Container* TileMap::GetContainer(const Point &position, int type) const { for (size_t i = 0; i < containers.size(); i++) { Container* c = containers[i]; @@ -467,7 +467,7 @@ Container* TileMap::GetContainer(Point &position, int type) return NULL; } -Container* TileMap::GetContainerByPosition(Point &position, int type) +Container* TileMap::GetContainerByPosition(const Point &position, int type) const { for (size_t i = 0; i < containers.size(); i++) { Container* c = containers[i]; @@ -544,7 +544,7 @@ InfoPoint* TileMap::AddInfoPoint(const char* Name, unsigned short Type, } //if detectable is set, then only detectable infopoints will be returned -InfoPoint* TileMap::GetInfoPoint(Point &p, bool detectable) +InfoPoint* TileMap::GetInfoPoint(const Point &p, bool detectable) const { for (size_t i = 0; i < infoPoints.size(); i++) { InfoPoint* ip = infoPoints[i]; @@ -581,7 +581,7 @@ InfoPoint* TileMap::GetInfoPoint(Point &p, bool detectable) return NULL; } -InfoPoint* TileMap::GetInfoPoint(const char* Name) +InfoPoint* TileMap::GetInfoPoint(const char* Name) const { for (size_t i = 0; i < infoPoints.size(); i++) { InfoPoint* ip = infoPoints[i]; @@ -591,7 +591,7 @@ InfoPoint* TileMap::GetInfoPoint(const char* Name) return NULL; } -InfoPoint* TileMap::GetInfoPoint(unsigned int idx) +InfoPoint* TileMap::GetInfoPoint(unsigned int idx) const { if (idx >= infoPoints.size()) { return NULL; @@ -599,7 +599,7 @@ InfoPoint* TileMap::GetInfoPoint(unsigned int idx) return infoPoints[idx]; } -InfoPoint* TileMap::GetTravelTo(const char* Destination) +InfoPoint* TileMap::GetTravelTo(const char* Destination) const { size_t i=infoPoints.size(); while (i--) { diff --git a/gemrb/core/TileMap.h b/gemrb/core/TileMap.h index 8f709626d..f3b9c4115 100644 --- a/gemrb/core/TileMap.h +++ b/gemrb/core/TileMap.h @@ -46,11 +46,11 @@ public: int ClosedIndex, unsigned short* indices, int count, Gem_Polygon* open, Gem_Polygon* closed); //gets door by active region (click target) - Door* GetDoor(Point &position); + Door* GetDoor(const Point &position) const; //gets door by activation position (spell target) - Door* GetDoorByPosition(Point &position); - Door* GetDoor(unsigned int idx); - Door* GetDoor(const char* Name); + Door* GetDoorByPosition(const Point &position) const; + Door* GetDoor(unsigned int idx) const; + Door* GetDoor(const char* Name) const; size_t GetDoorCount() { return doors.size(); } //update doors for a new overlay void UpdateDoors(); @@ -58,23 +58,23 @@ public: /* type is an optional filter for container type*/ void AddContainer(Container *c); //gets container by active region (click target) - Container* GetContainer(Point &position, int type=-1); + Container* GetContainer(const Point &position, int type=-1) const; //gets container by activation position (spell target) - Container* GetContainerByPosition(Point &position, int type=-1); - Container* GetContainer(const char* Name); - Container* GetContainer(unsigned int idx); + Container* GetContainerByPosition(const Point &position, int type=-1) const; + Container* GetContainer(const char* Name) const; + Container* GetContainer(unsigned int idx) const; /* cleans up empty heaps, returns 1 if container removed*/ int CleanupContainer(Container *container); - size_t GetContainerCount() { return containers.size(); } + size_t GetContainerCount() const { return containers.size(); } InfoPoint* AddInfoPoint(const char* Name, unsigned short Type, Gem_Polygon* outline); - InfoPoint* GetInfoPoint(Point &position, bool detectable); - InfoPoint* GetInfoPoint(const char* Name); - InfoPoint* GetInfoPoint(unsigned int idx); - InfoPoint* GetTravelTo(const char* Destination); + InfoPoint* GetInfoPoint(const Point &position, bool detectable) const; + InfoPoint* GetInfoPoint(const char* Name) const; + InfoPoint* GetInfoPoint(unsigned int idx) const; + InfoPoint* GetTravelTo(const char* Destination) const; InfoPoint* AdjustNearestTravel(Point &p); - size_t GetInfoPointCount() { return infoPoints.size(); } + size_t GetInfoPointCount() const { return infoPoints.size(); } TileObject* AddTile(const char* ID, const char* Name, unsigned int Flags, unsigned short* openindices, int opencount,unsigned short* closeindices, int closecount); diff --git a/gemrb/core/TileOverlay.cpp b/gemrb/core/TileOverlay.cpp index 00060d549..b87ab2a1c 100644 --- a/gemrb/core/TileOverlay.cpp +++ b/gemrb/core/TileOverlay.cpp @@ -46,7 +46,7 @@ void TileOverlay::AddTile(Tile* tile) tiles[count++] = tile; } -void TileOverlay::BumpViewport(Region &viewport, Region &vp) +void TileOverlay::BumpViewport(const Region &viewport, Region &vp) { bool bump = false; vp.w = viewport.w; diff --git a/gemrb/core/TileOverlay.h b/gemrb/core/TileOverlay.h index 1dbf86f49..8775d2cd7 100644 --- a/gemrb/core/TileOverlay.h +++ b/gemrb/core/TileOverlay.h @@ -38,7 +38,7 @@ public: ~TileOverlay(void); void AddTile(Tile* tile); void Draw(Region viewport, std::vector< TileOverlay*> &overlays); - void BumpViewport(Region &viewport, Region &vp); + void BumpViewport(const Region &viewport, Region &vp); }; #endif diff --git a/gemrb/core/Video.cpp b/gemrb/core/Video.cpp index 36be5f012..a04d3796e 100644 --- a/gemrb/core/Video.cpp +++ b/gemrb/core/Video.cpp @@ -66,7 +66,7 @@ void Video::SetMouseGrayed(bool grayed) } } -void Video::BlitTiled(Region rgn, Sprite2D* img, bool anchor) +void Video::BlitTiled(Region rgn, const Sprite2D* img, bool anchor) { int xrep = ( rgn.w + img->Width - 1 ) / img->Width; int yrep = ( rgn.h + img->Height - 1 ) / img->Height; @@ -79,7 +79,7 @@ void Video::BlitTiled(Region rgn, Sprite2D* img, bool anchor) } //Sprite conversion, creation -Sprite2D* Video::CreateAlpha( Sprite2D *sprite) +Sprite2D* Video::CreateAlpha( const Sprite2D *sprite) { if (!sprite) return 0; @@ -110,7 +110,7 @@ Sprite2D* Video::CreateAlpha( Sprite2D *sprite) 0x00FF0000, 0x0000FF00, 0x000000FF, pixels ); } -Sprite2D* Video::SpriteScaleDown( Sprite2D* sprite, unsigned int ratio ) +Sprite2D* Video::SpriteScaleDown( const Sprite2D* sprite, unsigned int ratio ) { unsigned int Width = sprite->Width / ratio; unsigned int Height = sprite->Height / ratio; @@ -162,7 +162,7 @@ Sprite2D* Video::CreateLight(int radius, int intensity) return light; } -Color Video::SpriteGetPixelSum(Sprite2D* sprite, unsigned short xbase, unsigned short ybase, unsigned int ratio) +Color Video::SpriteGetPixelSum(const Sprite2D* sprite, unsigned short xbase, unsigned short ybase, unsigned int ratio) { Color sum; unsigned int count = ratio*ratio; diff --git a/gemrb/core/Video.h b/gemrb/core/Video.h index d6c52d5e4..c2f7dadba 100644 --- a/gemrb/core/Video.h +++ b/gemrb/core/Video.h @@ -106,21 +106,21 @@ public: int /*transindex*/) { return 0; } virtual bool SupportsBAMSprites() { return false; } virtual void FreeSprite(Sprite2D* &spr) = 0; - virtual Sprite2D* DuplicateSprite(Sprite2D* spr) = 0; - virtual void BlitTile(Sprite2D* spr, Sprite2D* mask, int x, int y, Region* clip, bool trans) = 0; - virtual void BlitSprite(Sprite2D* spr, int x, int y, bool anchor = false, - Region* clip = NULL) = 0; + virtual Sprite2D* DuplicateSprite(const Sprite2D* spr) = 0; + virtual void BlitTile(const Sprite2D* spr, const Sprite2D* mask, int x, int y, const Region* clip, bool trans) = 0; + virtual void BlitSprite(const Sprite2D* spr, int x, int y, bool anchor = false, + const Region* clip = NULL) = 0; // Note: BlitSpriteRegion's clip region is shifted by Viewport.x/y if // anchor is false. This is different from the other BlitSprite functions. - virtual void BlitSpriteRegion(Sprite2D* spr, Region& size, int x, int y, - bool anchor = true, Region* clip = NULL) = 0; + virtual void BlitSpriteRegion(const Sprite2D* spr, const Region& size, int x, int y, + bool anchor = true, const Region* clip = NULL) = 0; // Note: Tint cannot be constified, because it is modified locally // not a pretty interface :) - virtual void BlitGameSprite(Sprite2D* spr, int x, int y, + virtual void BlitGameSprite(const Sprite2D* spr, int x, int y, unsigned int flags, Color tint, SpriteCover* cover, Palette *palette = NULL, - Region* clip = NULL, bool anchor = false) = 0; + const Region* clip = NULL, bool anchor = false) = 0; virtual void SetCursor(Sprite2D* up, Sprite2D* down) = 0; /** Sets a temporary cursor when dragging an Item from Inventory. * VideoDriver will call FreeSprite on it. @@ -135,7 +135,7 @@ public: /** This function Draws the Border of a Rectangle as described by the Region parameter. The Color used to draw the rectangle is passes via the Color parameter. */ virtual void DrawRect(const Region& rgn, const Color& color, bool fill = true, bool clipped = false) = 0; /** this function draws a clipped sprite */ - virtual void DrawRectSprite(const Region& rgn, const Color& color, Sprite2D* sprite) = 0; + virtual void DrawRectSprite(const Region& rgn, const Color& color, const Sprite2D* sprite) = 0; virtual void SetPixel(short x, short y, const Color& color, bool clipped = false) = 0; virtual void GetPixel(short x, short y, Color& color) = 0; virtual long GetPixel(void *, unsigned short x, unsigned short y) = 0; @@ -155,7 +155,7 @@ public: virtual void DrawLine(short x1, short y1, short x2, short y2, const Color& color, bool clipped = false) = 0; /** Blits a Sprite filling the Region */ - void BlitTiled(Region rgn, Sprite2D* img, bool anchor = false); + void BlitTiled(Region rgn, const Sprite2D* img, bool anchor = false); /** Sets Event Manager */ void SetEventMgr(EventMgr* evnt); /** Sends a Quit Signal to the Event Queue */ @@ -163,11 +163,11 @@ public: /** Gets the Palette of a surface */ virtual Palette* GetPalette(void* surface) = 0; /** Flips sprite vertically, returns new sprite */ - virtual Sprite2D *MirrorSpriteVertical(Sprite2D *sprite, bool MirrorAnchor) = 0; + virtual Sprite2D *MirrorSpriteVertical(const Sprite2D *sprite, bool MirrorAnchor) = 0; /** Flips sprite horizontally, returns new sprite */ - virtual Sprite2D *MirrorSpriteHorizontal(Sprite2D *sprite, bool MirrorAnchor) = 0; + virtual Sprite2D *MirrorSpriteHorizontal(const Sprite2D *sprite, bool MirrorAnchor) = 0; /** Duplicates and transforms sprite to have an alpha channel */ - Sprite2D* CreateAlpha(Sprite2D *sprite); + Sprite2D* CreateAlpha(const Sprite2D *sprite); /** Converts a Screen Coordinate to a Game Coordinate */ virtual void ConvertToGame(short& x, short& y) = 0; @@ -212,12 +212,12 @@ public: void SetMouseGrayed(bool grayed); /** Scales down a sprite by a ratio */ - Sprite2D* SpriteScaleDown( Sprite2D* sprite, unsigned int ratio ); + Sprite2D* SpriteScaleDown( const Sprite2D* sprite, unsigned int ratio ); /** Creates an ellipse or circle shaped sprite with various intensity * for projectile light spots */ Sprite2D* CreateLight(int radius, int intensity); - Color SpriteGetPixelSum (Sprite2D* sprite, unsigned short xbase, unsigned short ybase, unsigned int ratio); + Color SpriteGetPixelSum (const Sprite2D* sprite, unsigned short xbase, unsigned short ybase, unsigned int ratio); Region GetViewport(void); void SetViewport(int x, int y, unsigned int w, unsigned int h); void MoveViewportTo(int x, int y); diff --git a/gemrb/core/WorldMap.cpp b/gemrb/core/WorldMap.cpp index 35578c84c..ab04ef985 100644 --- a/gemrb/core/WorldMap.cpp +++ b/gemrb/core/WorldMap.cpp @@ -145,7 +145,7 @@ void WorldMap::AddAreaLink(WMPAreaLink *al) area_links.push_back(al); } -WMPAreaEntry *WorldMap::GetNewAreaEntry() +WMPAreaEntry *WorldMap::GetNewAreaEntry() const { return new WMPAreaEntry(); } @@ -225,7 +225,7 @@ void WorldMap::SetMapMOS(Sprite2D *newmos) MapMOS = newmos; } -WMPAreaEntry* WorldMap::GetArea(const ieResRef AreaName, unsigned int &i) +WMPAreaEntry* WorldMap::GetArea(const ieResRef AreaName, unsigned int &i) const { i=(unsigned int) area_entries.size(); while (i--) { @@ -322,7 +322,7 @@ int WorldMap::CalculateDistances(const ieResRef AreaName, int direction) } //returns the index of the area owning this link -unsigned int WorldMap::WhoseLinkAmI(int link_index) +unsigned int WorldMap::WhoseLinkAmI(int link_index) const { for (unsigned int i=0;i= TransitionsCount) { return NULL; @@ -164,7 +164,7 @@ DialogTransition* DLGImporter::GetTransition(unsigned int index) return dt; } -DialogString* DLGImporter::GetStateTrigger(unsigned int index) +DialogString* DLGImporter::GetStateTrigger(unsigned int index) const { if (index >= StateTriggersCount) { return NULL; @@ -190,7 +190,7 @@ DialogString* DLGImporter::GetStateTrigger(unsigned int index) return ds; } -DialogString* DLGImporter::GetTransitionTrigger(unsigned int index) +DialogString* DLGImporter::GetTransitionTrigger(unsigned int index) const { if (index >= TransitionTriggersCount) { return NULL; @@ -209,7 +209,7 @@ DialogString* DLGImporter::GetTransitionTrigger(unsigned int index) return ds; } -DialogString* DLGImporter::GetAction(unsigned int index) +DialogString* DLGImporter::GetAction(unsigned int index) const { if (index >= ActionsCount) { return NULL; @@ -264,7 +264,7 @@ int GetActionLength(const char* string) /* this function will break up faulty script strings that lack the CRLF between commands, common in PST dialog */ -char** DLGImporter::GetStrings(char* string, unsigned int& count) +char** DLGImporter::GetStrings(char* string, unsigned int& count) const { int col = 0; int level = 0; diff --git a/gemrb/plugins/DLGImporter/DLGImporter.h b/gemrb/plugins/DLGImporter/DLGImporter.h index edd5d0e24..df73cb257 100644 --- a/gemrb/plugins/DLGImporter/DLGImporter.h +++ b/gemrb/plugins/DLGImporter/DLGImporter.h @@ -70,16 +70,16 @@ public: DLGImporter(void); ~DLGImporter(void); bool Open(DataStream* stream, bool autoFree = true); - Dialog* GetDialog(); + Dialog* GetDialog() const; private: - DialogState* GetDialogState(Dialog *d, unsigned int index); - DialogTransition* GetTransition(unsigned int index); - DialogString* GetStateTrigger(unsigned int index); - DialogString* GetTransitionTrigger(unsigned int index); - DialogString* GetAction(unsigned int index); - char** GetStrings(char* string, unsigned int& count); + DialogState* GetDialogState(Dialog *d, unsigned int index) const; + DialogTransition* GetTransition(unsigned int index) const; + DialogString* GetStateTrigger(unsigned int index) const; + DialogString* GetTransitionTrigger(unsigned int index) const; + DialogString* GetAction(unsigned int index) const; + char** GetStrings(char* string, unsigned int& count) const; DialogTransition** GetTransitions(unsigned int firstIndex, - unsigned int count); + unsigned int count) const; }; #endif diff --git a/gemrb/plugins/IDSImporter/IDSImporter.cpp b/gemrb/plugins/IDSImporter/IDSImporter.cpp index 4e4fbee08..67e75bff4 100644 --- a/gemrb/plugins/IDSImporter/IDSImporter.cpp +++ b/gemrb/plugins/IDSImporter/IDSImporter.cpp @@ -90,7 +90,7 @@ bool IDSImporter::Open(DataStream* stream, bool autoFree) return true; } -int IDSImporter::GetValue(const char* txt) +int IDSImporter::GetValue(const char* txt) const { for (unsigned int i = 0; i < pairs.size(); i++) { if (stricmp( pairs[i].str, txt ) == 0) { @@ -100,7 +100,7 @@ int IDSImporter::GetValue(const char* txt) return -1; } -char* IDSImporter::GetValue(int val) +char* IDSImporter::GetValue(int val) const { for (unsigned int i = 0; i < pairs.size(); i++) { if (pairs[i].val == val) { @@ -110,7 +110,7 @@ char* IDSImporter::GetValue(int val) return NULL; } -char* IDSImporter::GetStringIndex(unsigned int Index) +char* IDSImporter::GetStringIndex(unsigned int Index) const { if (Index >= pairs.size()) { return NULL; @@ -118,7 +118,7 @@ char* IDSImporter::GetStringIndex(unsigned int Index) return pairs[Index].str; } -int IDSImporter::GetValueIndex(unsigned int Index) +int IDSImporter::GetValueIndex(unsigned int Index) const { if (Index >= pairs.size()) { return 0; @@ -126,7 +126,7 @@ int IDSImporter::GetValueIndex(unsigned int Index) return pairs[Index].val; } -int IDSImporter::FindString(char *str, int len) +int IDSImporter::FindString(char *str, int len) const { int i=pairs.size(); while(i--) { @@ -137,7 +137,7 @@ int IDSImporter::FindString(char *str, int len) return -1; } -int IDSImporter::FindValue(int val) +int IDSImporter::FindValue(int val) const { int i=pairs.size(); while(i--) { diff --git a/gemrb/plugins/IDSImporter/IDSImporter.h b/gemrb/plugins/IDSImporter/IDSImporter.h index a5a41fa4b..d91daf238 100644 --- a/gemrb/plugins/IDSImporter/IDSImporter.h +++ b/gemrb/plugins/IDSImporter/IDSImporter.h @@ -40,13 +40,13 @@ public: IDSImporter(void); ~IDSImporter(void); bool Open(DataStream* stream, bool autoFree = true); - int GetValue(const char* txt); - char* GetValue(int val); - char* GetStringIndex(unsigned int Index); - int GetValueIndex(unsigned int Index); - int FindString(char *str, int len); - int FindValue(int val); - int GetSize() { return pairs.size(); } + int GetValue(const char* txt) const; + char* GetValue(int val) const; + char* GetStringIndex(unsigned int Index) const; + int GetValueIndex(unsigned int Index) const; + int FindString(char *str, int len) const; + int FindValue(int val) const; + int GetSize() const { return pairs.size(); } }; #endif diff --git a/gemrb/plugins/INIImporter/INIImporter.cpp b/gemrb/plugins/INIImporter/INIImporter.cpp index fbb41b7ff..9bc1f5133 100644 --- a/gemrb/plugins/INIImporter/INIImporter.cpp +++ b/gemrb/plugins/INIImporter/INIImporter.cpp @@ -86,7 +86,7 @@ bool INIImporter::Open(DataStream* stream, bool autoFree) return true; } -int INIImporter::GetKeysCount(const char* Tag) +int INIImporter::GetKeysCount(const char* Tag) const { for (unsigned int i = 0; i < tags.size(); i++) { const char* TagName = tags[i]->GetTagName(); @@ -97,7 +97,7 @@ int INIImporter::GetKeysCount(const char* Tag) return 0; } -const char* INIImporter::GetKeyNameByIndex(const char* Tag, int index) +const char* INIImporter::GetKeyNameByIndex(const char* Tag, int index) const { for (unsigned int i = 0; i < tags.size(); i++) { const char* TagName = tags[i]->GetTagName(); @@ -109,7 +109,7 @@ const char* INIImporter::GetKeyNameByIndex(const char* Tag, int index) } const char* INIImporter::GetKeyAsString(const char* Tag, const char* Key, - const char* Default) + const char* Default) const { for (unsigned int i = 0; i < tags.size(); i++) { const char* TagName = tags[i]->GetTagName(); @@ -121,7 +121,7 @@ const char* INIImporter::GetKeyAsString(const char* Tag, const char* Key, } int INIImporter::GetKeyAsInt(const char* Tag, const char* Key, - const int Default) + const int Default) const { for (unsigned int i = 0; i < tags.size(); i++) { const char* TagName = tags[i]->GetTagName(); @@ -133,7 +133,7 @@ int INIImporter::GetKeyAsInt(const char* Tag, const char* Key, } float INIImporter::GetKeyAsFloat(const char* Tag, const char* Key, - const float Default) + const float Default) const { for (unsigned int i = 0; i < tags.size(); i++) { const char* TagName = tags[i]->GetTagName(); @@ -145,7 +145,7 @@ float INIImporter::GetKeyAsFloat(const char* Tag, const char* Key, } bool INIImporter::GetKeyAsBool(const char* Tag, const char* Key, - const bool Default) + const bool Default) const { for (unsigned int i = 0; i < tags.size(); i++) { const char* TagName = tags[i]->GetTagName(); diff --git a/gemrb/plugins/INIImporter/INIImporter.h b/gemrb/plugins/INIImporter/INIImporter.h index 4421a9622..64133ad17 100644 --- a/gemrb/plugins/INIImporter/INIImporter.h +++ b/gemrb/plugins/INIImporter/INIImporter.h @@ -50,17 +50,17 @@ public: } } - const char* GetTagName() + const char* GetTagName() const { return TagName; } - int GetKeyCount() + int GetKeyCount() const { return (int) pairs.size(); } - const char* GetKeyNameByIndex(int index) + const char* GetKeyNameByIndex(int index) const { return pairs[index].Name; } @@ -114,7 +114,7 @@ public: return false; } - const char* GetKeyAsString(const char* Key, const char* Default) + const char* GetKeyAsString(const char* Key, const char* Default) const { for (unsigned int i = 0; i < pairs.size(); i++) { if (stricmp( Key, pairs[i].Name ) == 0) { @@ -124,7 +124,7 @@ public: return Default; } - int GetKeyAsInt(const char* Key, const int Default) + int GetKeyAsInt(const char* Key, const int Default) const { const char* ret = NULL; for (unsigned int i = 0; i < pairs.size(); i++) { @@ -139,7 +139,7 @@ public: return atoi( ret ); } - float GetKeyAsFloat(const char* Key, const float Default) + float GetKeyAsFloat(const char* Key, const float Default) const { const char* ret = NULL; for (unsigned int i = 0; i < pairs.size(); i++) { @@ -154,7 +154,7 @@ public: return atof( ret ); } - bool GetKeyAsBool(const char* Key, const bool Default) + bool GetKeyAsBool(const char* Key, const bool Default) const { const char* ret = NULL; for (unsigned int i = 0; i < pairs.size(); i++) { @@ -186,25 +186,25 @@ public: INIImporter(void); ~INIImporter(void); bool Open(DataStream* stream, bool autoFree = true); - int GetTagsCount() + int GetTagsCount() const { return ( int ) tags.size(); } - const char* GetTagNameByIndex(int index) + const char* GetTagNameByIndex(int index) const { return tags[index]->GetTagName(); } - int GetKeysCount(const char* Tag); - const char* GetKeyNameByIndex(const char* Tag, int index); + int GetKeysCount(const char* Tag) const; + const char* GetKeyNameByIndex(const char* Tag, int index) const; const char* GetKeyAsString(const char* Tag, const char* Key, - const char* Default); + const char* Default) const; int GetKeyAsInt(const char* Tag, const char* Key, - const int Default); + const int Default) const; float GetKeyAsFloat(const char* Tag, const char* Key, - const float Default); + const float Default) const; bool GetKeyAsBool(const char* Tag, const char* Key, - const bool Default); + const bool Default) const; }; #endif diff --git a/gemrb/plugins/SDLVideo/SDLVideo.cpp b/gemrb/plugins/SDLVideo/SDLVideo.cpp index beab10fb8..455f48f17 100644 --- a/gemrb/plugins/SDLVideo/SDLVideo.cpp +++ b/gemrb/plugins/SDLVideo/SDLVideo.cpp @@ -636,7 +636,7 @@ void SDLVideoDriver::FreeSprite(Sprite2D*& spr) spr = NULL; } -Sprite2D* SDLVideoDriver::DuplicateSprite(Sprite2D* sprite) +Sprite2D* SDLVideoDriver::DuplicateSprite(const Sprite2D* sprite) { if (!sprite) return NULL; Sprite2D* dest = 0; @@ -668,8 +668,8 @@ Sprite2D* SDLVideoDriver::DuplicateSprite(Sprite2D* sprite) } -void SDLVideoDriver::BlitSpriteRegion(Sprite2D* spr, Region& size, int x, - int y, bool anchor, Region* clip) +void SDLVideoDriver::BlitSpriteRegion(const Sprite2D* spr, const Region& size, int x, + int y, bool anchor, const Region* clip) { if (!spr->vptr) return; @@ -850,7 +850,7 @@ void SDLVideoDriver::BlitSpriteRegion(Sprite2D* spr, Region& size, int x, } } -void SDLVideoDriver::BlitTile(Sprite2D* spr, Sprite2D* mask, int x, int y, Region* clip, bool trans) +void SDLVideoDriver::BlitTile(const Sprite2D* spr, const Sprite2D* mask, int x, int y, const Region* clip, bool trans) { if (spr->BAM) { printMessage( "SDLVideo", "Tile blit not supported for this sprite\n", LIGHT_RED ); @@ -944,8 +944,8 @@ void SDLVideoDriver::BlitTile(Sprite2D* spr, Sprite2D* mask, int x, int y, Regio } -void SDLVideoDriver::BlitSprite(Sprite2D* spr, int x, int y, bool anchor, - Region* clip) +void SDLVideoDriver::BlitSprite(const Sprite2D* spr, int x, int y, bool anchor, + const Region* clip) { if (!spr->vptr) return; @@ -1075,10 +1075,10 @@ void SDLVideoDriver::BlitSprite(Sprite2D* spr, int x, int y, bool anchor, } //cannot make const reference from tint, it is modified locally -void SDLVideoDriver::BlitGameSprite(Sprite2D* spr, int x, int y, - unsigned int flags, Color tint, - SpriteCover* cover, Palette *palette, - Region* clip, bool anchor) +void SDLVideoDriver::BlitGameSprite(const Sprite2D* spr, int x, int y, + unsigned int flags, Color tint, + SpriteCover* cover, Palette *palette, + const Region* clip, bool anchor) { if (!spr->vptr) return; @@ -1663,7 +1663,7 @@ void SDLVideoDriver::DrawRect(const Region& rgn, const Color& color, bool fill, } /** This function Draws a clipped sprite */ -void SDLVideoDriver::DrawRectSprite(const Region& rgn, const Color& color, Sprite2D* sprite) +void SDLVideoDriver::DrawRectSprite(const Region& rgn, const Color& color, const Sprite2D* sprite) { if (sprite->BAM) { printMessage( "SDLVideo", "DrawRectSprite not supported for this sprite\n", LIGHT_RED ); @@ -2240,7 +2240,7 @@ Palette* SDLVideoDriver::GetPalette(void *vptr) // flips its anchor (i.e. origin//base point) as well // returns new sprite -Sprite2D *SDLVideoDriver::MirrorSpriteVertical(Sprite2D* sprite, bool MirrorAnchor) +Sprite2D *SDLVideoDriver::MirrorSpriteVertical(const Sprite2D* sprite, bool MirrorAnchor) { if (!sprite || !sprite->vptr) return NULL; @@ -2278,7 +2278,7 @@ Sprite2D *SDLVideoDriver::MirrorSpriteVertical(Sprite2D* sprite, bool MirrorAnch // Flips given sprite horizontally (left-right). If MirrorAnchor=true, // flips its anchor (i.e. origin//base point) as well -Sprite2D *SDLVideoDriver::MirrorSpriteHorizontal(Sprite2D* sprite, bool MirrorAnchor) +Sprite2D *SDLVideoDriver::MirrorSpriteHorizontal(const Sprite2D* sprite, bool MirrorAnchor) { if (!sprite || !sprite->vptr) return NULL; diff --git a/gemrb/plugins/SDLVideo/SDLVideo.h b/gemrb/plugins/SDLVideo/SDLVideo.h index 82491f99b..1f3560f5e 100644 --- a/gemrb/plugins/SDLVideo/SDLVideo.h +++ b/gemrb/plugins/SDLVideo/SDLVideo.h @@ -79,16 +79,16 @@ public: Palette* palette, int transindex); bool SupportsBAMSprites() { return true; } void FreeSprite(Sprite2D* &spr); - Sprite2D* DuplicateSprite(Sprite2D* spr); - void BlitTile(Sprite2D* spr, Sprite2D* mask, int x, int y, Region* clip, bool trans); - void BlitSprite(Sprite2D* spr, int x, int y, bool anchor = false, - Region* clip = NULL); - void BlitSpriteRegion(Sprite2D* spr, Region& size, int x, int y, - bool anchor = true, Region* clip = NULL); - void BlitGameSprite(Sprite2D* spr, int x, int y, + Sprite2D* DuplicateSprite(const Sprite2D* spr); + void BlitTile(const Sprite2D* spr, const Sprite2D* mask, int x, int y, const Region* clip, bool trans); + void BlitSprite(const Sprite2D* spr, int x, int y, bool anchor = false, + const Region* clip = NULL); + void BlitSpriteRegion(const Sprite2D* spr, const Region& size, int x, int y, + bool anchor = true, const Region* clip = NULL); + void BlitGameSprite(const Sprite2D* spr, int x, int y, unsigned int flags, Color tint, SpriteCover* cover, Palette *palette = NULL, - Region* clip = NULL, bool anchor = false); + const Region* clip = NULL, bool anchor = false); void SetCursor(Sprite2D* up, Sprite2D* down); void SetDragCursor(Sprite2D* drag); Sprite2D* GetScreenshot( Region r ); @@ -97,7 +97,7 @@ public: void SetPalette(void* data, Palette* pal); /** This function Draws the Border of a Rectangle as described by the Region parameter. The Color used to draw the rectangle is passes via the Color parameter. */ void DrawRect(const Region& rgn, const Color& color, bool fill = true, bool clipped = false); - void DrawRectSprite(const Region& rgn, const Color& color, Sprite2D* sprite); + void DrawRectSprite(const Region& rgn, const Color& color, const Sprite2D* sprite); /** This functions Draws a Circle */ void SetPixel(short x, short y, const Color& color, bool clipped = true); /** Gets the pixel of the backbuffer surface */ @@ -117,15 +117,15 @@ public: inline void DrawVLine(short x, short y1, short y2, const Color& color, bool clipped = false); inline void DrawLine(short x1, short y1, short x2, short y2, const Color& color, bool clipped = false); /** Blits a Sprite filling the Region */ - void BlitTiled(Region rgn, Sprite2D* img, bool anchor = false); + void BlitTiled(Region rgn, const Sprite2D* img, bool anchor = false); /** Send a Quit Signal to the Event Queue */ bool Quit(); /** Get the Palette of a surface */ Palette* GetPalette(void *vptr); /** Flips sprite vertically */ - Sprite2D *MirrorSpriteVertical(Sprite2D *sprite, bool MirrorAnchor); + Sprite2D *MirrorSpriteVertical(const Sprite2D *sprite, bool MirrorAnchor); /** Flips sprite horizontally */ - Sprite2D *MirrorSpriteHorizontal(Sprite2D *sprite, bool MirrorAnchor); + Sprite2D *MirrorSpriteHorizontal(const Sprite2D *sprite, bool MirrorAnchor); /** Set Clip Rect */ void SetClipRect(const Region* clip); /** Get Clip Rect */ diff --git a/gemrb/plugins/ZLibManager/ZLibManager.cpp b/gemrb/plugins/ZLibManager/ZLibManager.cpp index b46566f5a..445ca8ca3 100644 --- a/gemrb/plugins/ZLibManager/ZLibManager.cpp +++ b/gemrb/plugins/ZLibManager/ZLibManager.cpp @@ -38,7 +38,7 @@ ZLibManager::~ZLibManager(void) #define OUTPUTSIZE 4096 // ZLib Decompression Routine -int ZLibManager::Decompress(FILE* dest, DataStream* source, unsigned int size_guess) +int ZLibManager::Decompress(FILE* dest, DataStream* source, unsigned int size_guess) const { unsigned char bufferin[INPUTSIZE], bufferout[OUTPUTSIZE]; z_stream stream; @@ -98,7 +98,7 @@ int ZLibManager::Decompress(FILE* dest, DataStream* source, unsigned int size_gu } } -int ZLibManager::Compress(DataStream* dest, DataStream* source) +int ZLibManager::Compress(DataStream* dest, DataStream* source) const { unsigned char bufferin[INPUTSIZE], bufferout[OUTPUTSIZE]; z_stream stream; diff --git a/gemrb/plugins/ZLibManager/ZLibManager.h b/gemrb/plugins/ZLibManager/ZLibManager.h index d8990eddd..784494cae 100644 --- a/gemrb/plugins/ZLibManager/ZLibManager.h +++ b/gemrb/plugins/ZLibManager/ZLibManager.h @@ -28,9 +28,9 @@ public: ZLibManager(void); ~ZLibManager(void); // ZLib Decompression Routine - int Decompress(FILE* dest, DataStream* source, unsigned int size_guess); + int Decompress(FILE* dest, DataStream* source, unsigned int size_guess) const; // ZLib Compression - int Compress(DataStream* dest, DataStream* source); + int Compress(DataStream* dest, DataStream* source) const; }; #endif -- 2.11.4.GIT