From ee924d93abf8b24a4d11f80b230b489af6177bc3 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 26 May 2021 20:01:10 +0200 Subject: [PATCH] SAGA2: Cleanup and fixing warnings --- engines/saga2/errlist.cpp | 4 +- engines/saga2/errlist.h | 26 ++----- engines/saga2/errors.cpp | 150 +------------------------------------- engines/saga2/objproto.h | 63 ++++++++-------- 4 files changed, 41 insertions(+), 202 deletions(-) diff --git a/engines/saga2/errlist.cpp b/engines/saga2/errlist.cpp index 923218abaa7..ad39a9a1c5f 100644 --- a/engines/saga2/errlist.cpp +++ b/engines/saga2/errlist.cpp @@ -51,7 +51,7 @@ SequentialErrorList::SequentialErrorList(ErrType et, uint32 ec, char *es[]) : // ------------------------------------------------------------------ // -SequentialErrorList::SequentialErrorList(ErrType et, char *es[]) : +SequentialErrorList::SequentialErrorList(ErrType et, const char *es[]) : ErrorList(et, stringCount(es)) { for (int i = 0; i < eLimit(); i++) setEntry(i, i, es[i]); @@ -60,7 +60,7 @@ SequentialErrorList::SequentialErrorList(ErrType et, char *es[]) : // ------------------------------------------------------------------ // -uint32 SequentialErrorList::stringCount(char *es[]) { +uint32 SequentialErrorList::stringCount(const char *es[]) { uint32 rv = 0; if (es == NULL) return 0; diff --git a/engines/saga2/errlist.h b/engines/saga2/errlist.h index 05317217a33..f0f1f856fb9 100644 --- a/engines/saga2/errlist.h +++ b/engines/saga2/errlist.h @@ -27,41 +27,27 @@ #ifndef SAGA2_ERRLIST_H #define SAGA2_ERRLIST_H -/* ===================================================================== * - Includes - * ===================================================================== */ - #include "saga2/errbase.h" namespace Saga2 { -/* ===================================================================== * - Class definitions - * ===================================================================== */ - -// ------------------------------------------------------------------ -// - -class SequentialErrorList: public ErrorList { - static uint32 stringCount(char *es[]); +class SequentialErrorList : public ErrorList { + static uint32 stringCount(const char *es[]); protected: virtual uint32 lookupMessage(ErrorID id); public: SequentialErrorList(ErrType et, uint32 ec, char *es[]); - SequentialErrorList(ErrType et, char *es[]); - + SequentialErrorList(ErrType et, const char *es[]); + virtual ~SequentialErrorList() {} }; -// ------------------------------------------------------------------ -// - -class SparseErrorList: public ErrorList { +class SparseErrorList : public ErrorList { protected: virtual uint32 lookupMessage(ErrorID id); public: SparseErrorList(ErrType et, uint32 ec, ErrorID ei[], const char *es[]); SparseErrorList(ErrType et, uint32 ec, ErrorRec er[]); - + virtual ~SparseErrorList() {} }; } diff --git a/engines/saga2/errors.cpp b/engines/saga2/errors.cpp index 317528d4905..d22b5367d04 100644 --- a/engines/saga2/errors.cpp +++ b/engines/saga2/errors.cpp @@ -24,12 +24,6 @@ * (c) 1993-1996 The Wyrmkeep Entertainment Co. */ -/* ===================================================================== * - Includes - * ===================================================================== */ - -#define FORBIDDEN_SYMBOL_ALLOW_ALL // FIXME: Remove - #include "saga2/std.h" #include "saga2/errlist.h" #include "saga2/errtype.h" @@ -39,7 +33,7 @@ namespace Saga2 { // ------------------------------------------------------------------ // FTA2 error text -char *FTA2ProgramErrors[] = { +const char *FTA2ProgramErrors[] = { "No Error", "Unknown command line argument", @@ -101,146 +95,6 @@ char *FTA2ProgramErrors[] = { "" }; -// ------------------------------------------------------------------ -// FTA2 error list - -SequentialErrorList -programErrors(etiFTA2ErrorList, FTA2ProgramErrors); - -#ifdef _WIN32 - -// ------------------------------------------------------------------ -// WIN32 exceptions - -ErrorRec win32Exceptions[] = { - { EXCEPTION_ACCESS_VIOLATION, "General Access Violation" }, - { EXCEPTION_BREAKPOINT, "A debugger breakpoint" }, - { EXCEPTION_DATATYPE_MISALIGNMENT, "Data Alignment error" }, - { EXCEPTION_SINGLE_STEP, "Debugger single-step" }, - { EXCEPTION_ARRAY_BOUNDS_EXCEEDED, "Array index out of bounds" }, - { EXCEPTION_FLT_DENORMAL_OPERAND, "FP: Denormal operand" }, - { EXCEPTION_FLT_DIVIDE_BY_ZERO, "FP: Division by zero" }, - { EXCEPTION_FLT_INEXACT_RESULT, "FP: inexact result" }, - { EXCEPTION_FLT_INVALID_OPERATION, "FP: invalid operand" }, - { EXCEPTION_FLT_OVERFLOW, "FP: overflow" }, - { EXCEPTION_FLT_STACK_CHECK, "FP: stack overflow" }, - { EXCEPTION_FLT_UNDERFLOW, "FP: underflow" }, - { EXCEPTION_INT_DIVIDE_BY_ZERO, "Int: division by zero" }, - { EXCEPTION_INT_OVERFLOW, "Int: overflow" }, - { EXCEPTION_PRIV_INSTRUCTION, "Priviledged instruction" }, - { EXCEPTION_NONCONTINUABLE_EXCEPTION, "Attempt to continue after last exception was unsucessful" } -}; - -// ------------------------------------------------------------------ -// WIN32 exception error list - -SparseErrorList -win32ExceptionList(etiWin32ExceptionList, 16, win32Exceptions); - - -#include "ddraw.h" - -#ifndef __WATCOMC__ -#pragma warning(disable : 4245) -#endif - -ErrorRec directDrawErrors[] = { - { DDERR_ALREADYINITIALIZED, "This object is already initialized " }, - { DDERR_BLTFASTCANTCLIP, "Return if a clipper object is attached to the source surface passed into a BltFast call." }, - { DDERR_CANNOTATTACHSURFACE, "This surface can not be attached to the requested surface." }, - { DDERR_CANNOTDETACHSURFACE, "This surface can not be detached from the requested surface." }, - { DDERR_CANTCREATEDC, "Windows can not create any more DCs" }, - { DDERR_CANTDUPLICATE, "Can't duplicate primary & 3D surfaces, or surfaces that are implicitly created." }, - { DDERR_CLIPPERISUSINGHWND, "An attempt was made to set a cliplist for a clipper object that is already monitoring an hwnd." }, - { DDERR_COLORKEYNOTSET, "No src color key specified for this operation." }, - { DDERR_CURRENTLYNOTAVAIL, "Support is currently not available." }, - { DDERR_DIRECTDRAWALREADYCREATED, "A DirectDraw object representing this driver has already been created for this process." }, - { DDERR_EXCEPTION, "An exception was encountered while performing the requested operation." }, - { DDERR_EXCLUSIVEMODEALREADYSET, "An attempt was made to set the cooperative level when it was already set to exclusive." }, - { DDERR_GENERIC, "Generic failure." }, - { DDERR_HEIGHTALIGN, "Height of rectangle provided is not a multiple of reqd alignment." }, - { DDERR_HWNDALREADYSET, "The CooperativeLevel HWND has already been set. It can not be reset while the process has surfaces or palettes created." }, - { DDERR_HWNDSUBCLASSED, "HWND used by DirectDraw CooperativeLevel has been subclassed, this prevents DirectDraw from restoring state." }, - { DDERR_IMPLICITLYCREATED, "This surface can not be restored because it is an implicitly created surface." }, - { DDERR_INCOMPATIBLEPRIMARY, "Unable to match primary surface creation request with existing primary surface." }, - { DDERR_INVALIDCAPS, "One or more of the caps bits passed to the callback are incorrect." }, - { DDERR_INVALIDCLIPLIST, "DirectDraw does not support the provided cliplist." }, - { DDERR_INVALIDDIRECTDRAWGUID, "The GUID passed to DirectDrawCreate is not a valid DirectDraw driver identifier." }, - { DDERR_INVALIDMODE, "DirectDraw does not support the requested mode." }, - { DDERR_INVALIDOBJECT, "DirectDraw received a pointer that was an invalid DIRECTDRAW object." }, - { DDERR_INVALIDPARAMS, "One or more of the parameters passed to the function are incorrect." }, - { DDERR_INVALIDPIXELFORMAT, "The pixel format was invalid as specified." }, - { DDERR_INVALIDPOSITION, "Returned when the position of the overlay on the destination is no longer legal for that destination." }, - { DDERR_INVALIDRECT, "Rectangle provided was invalid." }, - { DDERR_LOCKEDSURFACES, "Operation could not be carried out because one or more surfaces are locked." }, - { DDERR_NO3D, "There is no 3D present." }, - { DDERR_NOALPHAHW, "Operation could not be carried out because there is no alpha accleration hardware present or available." }, - { DDERR_NOBLTHW, "No blter hardware present." }, - { DDERR_NOCLIPLIST, "No cliplist available." }, - { DDERR_NOCLIPPERATTACHED, "No clipper object attached to surface object." }, - { DDERR_NOCOLORCONVHW, "Operation could not be carried out because there is no color conversion hardware present or available." }, - { DDERR_NOCOLORKEY, "Surface doesn't currently have a color key" }, - { DDERR_NOCOLORKEYHW, "Operation could not be carried out because there is no hardware support of the destination color key." }, - { DDERR_NOCOOPERATIVELEVELSET, "Create function called without DirectDraw object method SetCooperativeLevel being called." }, - { DDERR_NODC, "No DC was ever created for this surface." }, - { DDERR_NODDROPSHW, "No DirectDraw ROP hardware." }, - { DDERR_NODIRECTDRAWHW, "A hardware-only DirectDraw object creation was attempted but the driver did not support any hardware." }, - { DDERR_NOEMULATION, "Software emulation not available." }, - { DDERR_NOEXCLUSIVEMODE, "Operation requires the application to have exclusive mode but the application does not have exclusive mode." }, - { DDERR_NOFLIPHW, "Flipping visible surfaces is not supported." }, - { DDERR_NOGDI, "There is no GDI present." }, - { DDERR_NOHWND, "Clipper notification requires an HWND or no HWND has previously been set as the CooperativeLevel HWND." }, - { DDERR_NOMIRRORHW, "Operation could not be carried out because there is no hardware present or available." }, - { DDERR_NOOVERLAYDEST, "Returned when GetOverlayPosition is called on an overlay that UpdateOverlay has never been called on to establish a destination." }, - { DDERR_NOOVERLAYHW, "Operation could not be carried out because there is no overlay hardware present or available." }, - { DDERR_NOPALETTEATTACHED, "No palette object attached to this surface." }, - { DDERR_NOPALETTEHW, "No hardware support for 16 or 256 color palettes." }, - { DDERR_NORASTEROPHW, "Operation could not be carried out because there is no appropriate raster op hardware present or available." }, - { DDERR_NOROTATIONHW, "Operation could not be carried out because there is no rotation hardware present or available." }, - { DDERR_NOSTRETCHHW, "Operation could not be carried out because there is no hardware support for stretching." }, - { DDERR_NOT4BITCOLOR, "DirectDrawSurface is not in 4 bit color palette and the requested operation requires 4 bit color palette." }, - { DDERR_NOT4BITCOLORINDEX, "DirectDrawSurface is not in 4 bit color index palette and the requested operation requires 4 bit color index palette." }, - { DDERR_NOT8BITCOLOR, "DirectDrawSurface is not in 8 bit color mode and the requested operation requires 8 bit color" }, - { DDERR_NOTAOVERLAYSURFACE, "Returned when an overlay member is called for a non-overlay surface." }, - { DDERR_NOTEXTUREHW, "Operation could not be carried out because there is no texture mapping hardware present or available." }, - { DDERR_NOTFLIPPABLE, "An attempt has been made to flip a surface that is not flippable." }, - { DDERR_NOTFOUND, "Requested item was not found." }, - { DDERR_NOTLOCKED, "Surface was not locked. An attempt to unlock a surface that was not locked at all, or by this process, has been attempted." }, - { DDERR_NOTPALETTIZED, "The surface being used is not a palette-based surface." }, - { DDERR_NOVSYNCHW, "Operation could not be carried out because there is no hardware support for vertical blank synchronized operations." }, - { DDERR_NOZBUFFERHW, "Operation could not be carried out because there is no hardware support for zbuffer blting." }, - { DDERR_NOZOVERLAYHW, "Overlay surfaces could not be z layered based on their BltOrder because the hardware does not support z layering of overlays." }, - { DDERR_OUTOFCAPS, "The hardware needed for the requested operation has already been allocated." }, - { DDERR_OUTOFMEMORY, "DirectDraw does not have enough memory to perform the operation." }, - { DDERR_OUTOFVIDEOMEMORY, "DirectDraw does not have enough memory to perform the operation." }, - { DDERR_OVERLAYCANTCLIP, "The hardware does not support clipped overlays." }, - { DDERR_OVERLAYCOLORKEYONLYONEACTIVE, "Can only have ony color key active at one time for overlays." }, - { DDERR_OVERLAYNOTVISIBLE, "Returned when GetOverlayPosition is called on a hidden overlay." }, - { DDERR_PALETTEBUSY, "Access to this palette is being refused because the palette is already locked by another thread." }, - { DDERR_PRIMARYSURFACEALREADYEXISTS, "This process already has created a primary surface." }, - { DDERR_REGIONTOOSMALL, "Region passed to Clipper::GetClipList is too small." }, - { DDERR_SURFACEALREADYATTACHED, "This surface is already attached to the surface it is being attached to." }, - { DDERR_SURFACEALREADYDEPENDENT, "This surface is already a dependency of the surface it is being made a dependency of." }, - { DDERR_SURFACEBUSY, "Access to this surface is being refused because the surface is already locked by another thread." }, - { DDERR_SURFACEISOBSCURED, "Access to surface refused because the surface is obscured." }, - { DDERR_SURFACELOST, "Access to this surface is being refused because the surface memory is gone. The DirectDrawSurface object representing this surface should have Restore called on it." }, - { DDERR_SURFACENOTATTACHED, "The requested surface is not attached." }, - { DDERR_TOOBIGHEIGHT, "Height requested by DirectDraw is too large." }, - { DDERR_TOOBIGSIZE, "Size requested by DirectDraw is too large -- the individual height and width are OK." }, - { DDERR_TOOBIGWIDTH, "Width requested by DirectDraw is too large." }, - { DDERR_UNSUPPORTED, "Action not supported." }, - { DDERR_UNSUPPORTEDFORMAT, "FOURCC format requested is unsupported by DirectDraw." }, - { DDERR_UNSUPPORTEDMASK, "Bitmask in the pixel format requested is unsupported by DirectDraw." }, - { DDERR_VERTICALBLANKINPROGRESS, "Vertical blank is in progress." }, - { DDERR_WASSTILLDRAWING, "Informs DirectDraw that the previous Blt which is transfering information to or from this Surface is incomplete." }, - { DDERR_WRONGMODE, "This surface can not be restored because it was created in a different mode." }, - { DDERR_XALIGN, "Rectangle provided was not horizontally aligned on required boundary." } -}; - -SparseErrorList -directDrawErrorList(etiDDrawErrorList, 90, directDrawErrors); - - -#endif +SequentialErrorList programErrors(etiFTA2ErrorList, FTA2ProgramErrors); } diff --git a/engines/saga2/objproto.h b/engines/saga2/objproto.h index bd28a1b489f..3b1e4d1451c 100644 --- a/engines/saga2/objproto.h +++ b/engines/saga2/objproto.h @@ -304,8 +304,8 @@ public: // A constructor which takes the data loaded from the file // and loads it into the various fields... - ProtoObj(ResourceObjectPrototype &proto) : - ResourceObjectPrototype(proto) {} + ProtoObj(ResourceObjectPrototype &proto) : ResourceObjectPrototype(proto) {} + virtual ~ProtoObj() {} // returns the containment type flags for this object virtual uint16 containmentSet(void); @@ -343,9 +343,6 @@ public: ObjectID indirectObj, int16 value); - // Create A Container Window -// virtual ContainerWindow *makeWindow( GameObject *Obj ); - // generic actions // Use this object bool use(ObjectID dObj, ObjectID enactor); @@ -642,6 +639,7 @@ public: class InventoryProto : public ProtoObj { public: InventoryProto(ResourceObjectPrototype &proto) : ProtoObj(proto) {} + virtual ~InventoryProto() {} virtual uint16 containmentSet(void); @@ -686,7 +684,6 @@ public: // Prototype class for physical object container class PhysicalContainerProto : public InventoryProto { - private: enum { ViewableRows = 4, @@ -696,8 +693,8 @@ private: }; public: - PhysicalContainerProto(ResourceObjectPrototype &proto) : - InventoryProto(proto) {} + PhysicalContainerProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {} + virtual ~PhysicalContainerProto() {} virtual uint16 containmentSet(void); @@ -739,9 +736,6 @@ public: const TilePoint &where, int16 num = 1); -// virtual ContainerWindow *makeWindow( GameObject *Obj ); - - public: virtual uint16 getViewableRows(void) { return ViewableRows; @@ -774,6 +768,7 @@ public: class KeyProto : public InventoryProto { public: KeyProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {} + virtual ~KeyProto() {} // Set up targeting cursor virtual bool setUseCursor(ObjectID dObj); @@ -792,9 +787,10 @@ public: // hierarchy: // ProtoObj, InventoryProto, BottleProto -class BottleProto : public InventoryProto { +class BottleProto : public InventoryProto { public: BottleProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {} + virtual ~BottleProto() {} virtual uint16 containmentSet(void); @@ -810,9 +806,10 @@ public: // hierarchy: // ProtoObj, InventoryProto, FoodProto -class FoodProto : public InventoryProto { +class FoodProto : public InventoryProto { public: FoodProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {} + virtual ~FoodProto() {} virtual uint16 containmentSet(void); @@ -828,9 +825,10 @@ public: // hierarchy: // ProtoObj, InventoryProto, WearbleProto -class WearableProto : public InventoryProto { +class WearableProto : public InventoryProto { public: WearableProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {} + virtual ~WearableProto() {} virtual uint16 containmentSet(void); }; @@ -851,6 +849,7 @@ protected: public: WeaponProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {} + virtual ~WeaponProto() {} virtual uint16 containmentSet(void); @@ -877,8 +876,8 @@ public: class MeleeWeaponProto : public WeaponProto { public: - MeleeWeaponProto(ResourceObjectPrototype &proto) : - WeaponProto(proto) {} + MeleeWeaponProto(ResourceObjectPrototype &proto) : WeaponProto(proto) {} + virtual ~MeleeWeaponProto() {} virtual bool useAction(ObjectID dObj, ObjectID enactor); virtual bool useOnAction(ObjectID dObj, ObjectID enactor, ObjectID item); @@ -944,8 +943,8 @@ public: class BludgeoningWeaponProto : public MeleeWeaponProto { public: - BludgeoningWeaponProto(ResourceObjectPrototype &proto) : - MeleeWeaponProto(proto) {} + BludgeoningWeaponProto(ResourceObjectPrototype &proto) : MeleeWeaponProto(proto) {} + virtual ~BludgeoningWeaponProto() {} // Get the value of the wielder's skill which applies to this // weapon @@ -965,8 +964,8 @@ public: class SlashingWeaponProto : public MeleeWeaponProto { public: - SlashingWeaponProto(ResourceObjectPrototype &proto) : - MeleeWeaponProto(proto) {} + SlashingWeaponProto(ResourceObjectPrototype &proto) : MeleeWeaponProto(proto) {} + virtual ~SlashingWeaponProto() {} // Get the value of the wielder's skill which applies to this // weapon @@ -985,8 +984,8 @@ public: class BowProto : public WeaponProto { public: - BowProto(ResourceObjectPrototype &proto) : - WeaponProto(proto) {} + BowProto(ResourceObjectPrototype &proto) : WeaponProto(proto) {} + virtual ~BowProto() {} virtual bool useAction(ObjectID dObj, ObjectID enactor); @@ -1022,8 +1021,8 @@ public: class WeaponWandProto : public WeaponProto { public: - WeaponWandProto(ResourceObjectPrototype &proto) : - WeaponProto(proto) {} + WeaponWandProto(ResourceObjectPrototype &proto) : WeaponProto(proto) {} + virtual ~WeaponWandProto() {} virtual bool useAction(ObjectID dObj, ObjectID enactor); @@ -1211,7 +1210,7 @@ public: // hierarchy: // ProtoObj, InventoryProto, DocumentProto -class DocumentProto : public InventoryProto { +class DocumentProto : public InventoryProto { public: DocumentProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {} virtual ~DocumentProto() {} @@ -1234,7 +1233,7 @@ public: // hierarchy: // ProtoObj, InventoryProto, DocumentProto, BookProto -class BookProto : public DocumentProto { +class BookProto : public DocumentProto { public: BookProto(ResourceObjectPrototype &proto) : DocumentProto(proto) {} virtual ~BookProto() {} @@ -1250,7 +1249,7 @@ public: // hierarchy: // ProtoObj, InventoryProto, DocumentProto, ScrollProto -class ScrollProto : public DocumentProto { +class ScrollProto : public DocumentProto { public: ScrollProto(ResourceObjectPrototype &proto) : DocumentProto(proto) {} virtual ~ScrollProto() {} @@ -1267,7 +1266,7 @@ public: // hierarchy: // ProtoObj, InventoryProto, AutoMapProto -class AutoMapProto : public InventoryProto { +class AutoMapProto : public InventoryProto { public: AutoMapProto(ResourceObjectPrototype &proto) : InventoryProto(proto) {} virtual ~AutoMapProto() {} @@ -1326,7 +1325,7 @@ public: // hierarchy: // ProtoObj, IntangibleObjProto, IdeaProto -class IdeaProto : public IntangibleObjProto { +class IdeaProto : public IntangibleObjProto { public: IdeaProto(ResourceObjectPrototype &proto) : IntangibleObjProto(proto) {} virtual ~IdeaProto() {} @@ -1343,7 +1342,7 @@ public: // hierarchy: // ProtoObj, IntangibleObjProto, MemoryProto -class MemoryProto : public IntangibleObjProto { +class MemoryProto : public IntangibleObjProto { public: MemoryProto(ResourceObjectPrototype &proto) : IntangibleObjProto(proto) {} virtual ~MemoryProto() {} @@ -1360,7 +1359,7 @@ public: // hierarchy: // ProtoObj, IntangibleObjProto, PsychProto -class PsychProto : public IntangibleObjProto { +class PsychProto : public IntangibleObjProto { public: PsychProto(ResourceObjectPrototype &proto) : IntangibleObjProto(proto) {} virtual ~PsychProto() {} @@ -1379,7 +1378,7 @@ public: // hierarchy: // ProtoObj, IntagibleObjProto, SkillProto -class SkillProto : public IntangibleObjProto { +class SkillProto : public IntangibleObjProto { public: SkillProto(ResourceObjectPrototype &proto) : IntangibleObjProto(proto) {} virtual ~SkillProto() {}