{
protected:
- //! Draw style, one of the three enumerated values specifying how particles will be drawn.
ParticleDrawStyle rStyle;
- //! Image to draw (only used if rStyle is DS_IMAGE).
ZImage rImage;
- //! Minimum X value for starting position.
float rMinX;
- //! Maximum X value for starting position.
float rMaxX;
- //! Minimum Y value for starting position.
float rMinY;
- //! Maximum Y value for starting position.
float rMaxY;
- //! Minimum X velocity, particle moves it's velocity every second.
float rMinXVel;
- //! Maximum X velocity, particle moves it's velocity every second.
float rMaxXVel;
- //! Minimum Y velocity, particle moves it's velocity every second.
- float rMinYVel;
- //! Maximum Y velocity, particle moves it's velocity every second.
+ float rMinYVel;
float rMaxYVel;
- //! Minimum starting energy. (Remember particles with energy values <= 0 are removed.)
float rMinEnergy;
- //! Maximum starting energy.
float rMaxEnergy;
- //! Minimum energy change per second.
float rMinEnergyDelta;
- //! Maximum energy change per second.
float rMaxEnergyDelta;
- //! Minimum starting size.
float rMinSize;
- //! Maximum starting size.
float rMaxSize;
- //! Minimum size change per second.
float rMinSizeDelta;
- //! Maximum size change per second.
float rMaxSizeDelta;
- //! Minimum red component of color, 0-255.
Uint8 rMinRed;
- //! Maximum red component of color, 0-255.
Uint8 rMaxRed;
- //! Minimum green component of color, 0-255.
Uint8 rMinGreen;
- //! Maximum green component of color, 0-255.
Uint8 rMaxGreen;
- //! Minimum blue component of color, 0-255.
Uint8 rMinBlue;
- //! Maximum blue component of color, 0-255.
Uint8 rMaxBlue;
- //! Minimum alpha of particle, 0-255.
Uint8 rMinAlpha;
- //! Maximum alpha of particle, 0-255.
Uint8 rMaxAlpha;
-
- /*!
- \brief Function which creates a new particle.
-
- Implementation of pure virtual NewParticle from ZBaseParticleSystem, creates a new particle with
- it's members set to values between their min and max value as set by the system.
- **/
+
virtual particleType NewParticle();
-
- /*!
- \brief Updates a given particle given it's index and the elapsedTime.
-
- Implementation of pure virtual UpdateParticle from ZBaseParticleSystem, updates a given particle
- relative to the elapsed time.
- \param index Index of particle in rParticles array to update.
- \param elapsedTime Decimal portion of a second since last call.
- **/
virtual void UpdateParticle(int index, float elapsedTime);
public:
- /*!
- \brief Draws all particles.
-
- Implementation of pure virtual Render from ZBaseParticleSystem, draws all particles in specified
- ParticleDrawStyle.
- **/
virtual void Render();
- /*!
- \brief Reload image.
-
- Reload image if mode is DS_IMAGE, usage is same as ZImage::Reload.
- **/
void ReloadImage();
- /*!
- \brief Sets ParticleDrawStyle for this system.
-
- Sets the method of drawing particles, point, line, or image particles.
- \param style ParticleDrawStyle for this particle system to use.
- **/
void SetDrawStyle(ParticleDrawStyle style);
-
- /*!
- \brief Sets image for particle system.
-
- Sets image for particle system to use, assuming the drawing style is DS_IMAGE.
- \brief filename Filename of image to load for the system.
- **/
void SetImage(std::string filename);
-
- /*!
- \brief Sets the range of initial positions.
-
- Sets the range of initial positions for a new particle.
- \param minX Minimum X coordinate for new particles.
- \param minY Minimum Y coordinate for new particles.
- \param maxX Maximum X coordinate for new particles.
- \param maxY Maximum Y coordinate for new particles.
- **/
void SetPosRange(float minX, float minY, float maxX, float maxY);
-
- /*!
- \brief Sets range of velocities for particles.
-
- Sets range from which a new particle obtains it's random velocity,
- \param minXVel Minimum X velocity of a particle.
- \param minYVel Minimum Y velocity of a particle.
- \param maxXVel Maximum X velocity of a particle.
- \param maxYVel Maximum Y velocity of a particle.
- **/
void SetVelocityRange(float minXVel, float minYVel, float maxXVel, float maxYVel);
-
- /*!
- \brief Sets range of initial energy and energyDelta.
-
- Sets the possible ranges for a particles starting energy and it's energyDelta. Particles with
- energy less than or equal to 0 are deleted by ZBaseParticleSystem::Update.
- \param minEnergy Minimum initial energy.
- \param maxEnergy Maximum initial energy.
- \param minEnergyDelta Minimum energy delta.
- \param maxEnergyDelta Maximum energy delta.
- **/
void SetEnergyRange(float minEnergy, float maxEnergy, float minEnergyDelta=0, float maxEnergyDelta=0);
-
- /*!
- \brief Sets range of initial size and sizeDelta.
- Sets the possible ranges for a particles starting size and it's sizeDelta.
- \param minSize Minimum initial size.
- \param maxSize Maximum initial size.
- \param minSizeDelta Minimum size delta.
- \param maxSizeDelta Maximum size delta.
- **/
void SetSizeRange(float minSize, float maxSize, float minSizeDelta=0, float maxSizeDelta=0);
-
- /*!
- \brief Set range of color for a new particle.
-
- Sets range of possible colors, by component, for a new particle.
- \param minRed Minimum value of red component (0-255).
- \param maxRed Minimum value of red component (0-255).
- \param minGreen Minimum value of green component (0-255).
- \param maxGreen Minimum value of green component (0-255).
- \param minBlue Minimum value of blue component (0-255).
- \param maxBlue Minimum value of blue component (0-255).
- \param minAlpha Minimum value of alpha value (0-255).
- \param maxAlpha Minimum value of alpha value (0-255).
- **/
void SetColorRange(Uint8 minRed, Uint8 maxRed, Uint8 minGreen, Uint8 maxGreen,
Uint8 minBlue, Uint8 maxBlue, Uint8 minAlpha, Uint8 maxAlpha);
};
diff --git a/include/ZE_ZSound.h b/include/ZE_ZSound.h
index 8b8a112..fab1dda 100644
--- a/include/ZE_ZSound.h
+++ b/include/ZE_ZSound.h
@@ -1,6 +1,6 @@
/*******************************************************************************
This file is Part of the ZEngine Library for 2D game development.
- Copyright (C) 2002, 2003 James Turk
+ Copyright (C) 2002-2004 James Turk
Licensed under a BSD-style license.
@@ -8,15 +8,6 @@
and the home of this Library is http://www.zengine.sourceforge.net
*******************************************************************************/
-/*!
- \file ZE_ZSound.h
- \brief Definition file for ZSound.
-
- Definition file for ZSound, the Sound Effect wrapper for ZEngine.
-
$Id: ZE_ZSound.h,v 1.12 2003/12/24 04:46:48 cozman Exp $
- \author James Turk
-**/
-
#ifndef __ze_zsound_h__
#define __ze_zsound_h__
@@ -27,164 +18,37 @@
namespace ZE
{
-/*!
- \brief ZSound class for playing sound effects. (WAV)
-
- ZSound music class, class wraps common features for SDL_Mixer's Mix_Chunk. Inherited from ZObject.
-**/
class ZSound
{
protected:
- //! Pointer to ZEngine Object
ZEngine* rEngine;
- //! Pointer to music data.
Mix_Chunk* rSound;
- //! Channel ID Number from SDL_Mixer.
int rChannelID;
public:
- //! Static Variable For Infinite loop of sound. (Defined as -1)
static const int LoopInfinite;
- ///////////////////////
- //Opening and Closing//
- ///////////////////////
-
- /*!
- \brief Default Constructor.
-
- Default Constructor, does nothing.
- **/
ZSound();
-
- /*!
- \brief Constructor that opens a sound effect file.
-
- Constructor simply calls ZSound::Open() with same filename. (WAV,MOD,MID,OGG)
- \param filename Sound effect to open.
- **/
ZSound(std::string filename);
-
- /*!
- \brief Destructor, frees memory.
-
- Destructor calls ZSound::Release().
- **/
virtual ~ZSound();
- /*!
- \brief Opens a sound effect file.
-
- Open a music file to be used.
- \param filename Music to open.
- **/
void Open(std::string filename);
-
- /*!
- \brief Opens a sound effect file from within a zip archive.
-
- Open a sound effect file from within a zip archive using zlib and SDL_RWops.
- \param zipname Zip file to open sound effect from.
- \param filename File to open as new sound effect.
- **/
void OpenFromZip(std::string zipname, std::string filename);
-
- /*!
- \brief Opens a sound effect file from the current ZEngine Resource File.
-
- Open sound effect file from the current ZEngine Resource File, the XML resource file set via ZEngine::SetResourceFile.
- **/
void OpenFromZRF(std::string resourceId);
-
- /*!
- \brief Release sound effect.
-
- Release memory held by sample data.
- **/
void Release();
- /////////////////
- //Play Controls//
- /////////////////
-
- /*!
- \brief Play currently loaded sound effect.
-
- Play sound effect, looping loopNum times. (use ZSound::LoopInfinite to loop forever.)
- If fade is not zero (which it defaults to) music will fade in over specified number of milliseconds.
- \param loopNum Number of times to loop song, defaults to zero.
- \param fadeTime Milliseconds to fade to full volume, defaults to zero for no fade.
- **/
void Play(int loopNum=0, int fadeTime=0);
-
- /*!
- \brief Pause sound.
-
- Pause currently playing sound.
- **/
void Pause() const;
-
- /*!
- \brief Unpause sound.
-
- Unpause currently playing sound.
- **/
void Unpause() const;
-
- /*!
- \brief Stop sound.
-
- Stop currently playing sound, if fadeTime is not zero, fade out over specified time.
- \param fadeTime Milliseconds to fade out over, defaults to zero for immediate stop.
- **/
void Stop(int fadeTime=0) const;
-
- /*!
- \brief Change Volume.
-
- Change volume of currently playing sample.
- \param volume Volume to change to, can be in a range from 0 to 128.
- **/
void SetVolume(int volume);
- /////////////
- //Accessors//
- /////////////
-
- /*!
- \brief Check if file is loaded.
-
- Check if file is loaded and pointer to data is non-NULL.
- \return Loaded or Unloaded state of data.
- **/
bool IsLoaded() const;
-
- /*!
- \brief Check if sound is Playing.
-
- Check if sound is playing, specifically if it is not stopped. (Paused state should be checked for by IsPaused)
- \return Playing / Not Playing State of sound.
- **/
bool IsPlaying() const;
-
- /*!
- \brief Check if sound is Paused.
-
- Check if sound is "playing" but currently paused.
- \return Paused / Not Paused State of Sound.
- **/
bool IsPaused() const;
-
- /*!
- \brief Find Current Volume of Sound Channel.
-
- Get current volume of sound channel represented as a value from 0-128.
- \return Volume of sound channel, 0-128.
- **/
- int Volume() const;
+ int GetVolume() const;
};
-
}
#endif //USE_SDL_MIXER
diff --git a/include/ZE_ZTimer.h b/include/ZE_ZTimer.h
index 67c9875..663beac 100644
--- a/include/ZE_ZTimer.h
+++ b/include/ZE_ZTimer.h
@@ -1,6 +1,6 @@
/*******************************************************************************
This file is Part of the ZEngine Library for 2D game development.
- Copyright (C) 2002, 2003 James Turk
+ Copyright (C) 2002-2004 James Turk
Licensed under a BSD-style license.
@@ -8,15 +8,6 @@
and the home of this Library is http://www.zengine.sourceforge.net
*******************************************************************************/
-/*!
- \file ZE_ZTimer.h
- \brief Definition file for ZTimer.
-
- Definition file for ZTimer, the Timer class for ZEngine.
-
$Id: ZE_ZTimer.h,v 1.10 2003/11/24 22:24:33 cozman Exp $
- \author James Turk
-**/
-
#ifndef __ze_ztimer_h__
#define __ze_ztimer_h__
@@ -25,85 +16,26 @@
namespace ZE
{
-/*!
- \brief ZTimer class for Timer use.
-
- ZTimer timing class, class wraps common features of SDL timer. Inherited from ZObject and tied to ZEngine main timer.
-**/
class ZTimer
{
protected:
- //! Pointer to ZEngine Object
ZEngine* rEngine;
- //! Paused / Unpaused state of Timer
bool rPaused;
- //! Using ZEngine timer or SDL global timer.
bool rUseZEngine;
- //! Total time this timer has been paused.
Uint32 rPausedTime;
- //! Time this Timer was paused.
Uint32 rLastPause;
- /*!
- \brief Get time from parent timer.
-
- Protected method to get time from whichever timer is parent.
- \return Time on parent timer.
- **/
Uint32 GetParentTime() const;
public:
-
- /*!
- \brief Constructs a new Timer.
-
- Sets TimePaused to current ZEngine time if useZEngine is true, otherwise uses SDL timer.
- \param useZEngine Tells if timer should use ZEngine or SDL.
- **/
ZTimer(bool useZEngine=true);
-
- /*!
- \brief Virtual Destructor.
-
- Virtual destructor making future inheritance safe.
- **/
virtual ~ZTimer();
- /*!
- \brief Reset Timer.
-
- Set Timer back to Zero, will also unpause timer if it was paused.
- **/
void Reset();
-
- /*!
- \brief Pause Timer.
-
- Pause the timer if it is unpaused.
- **/
void Pause();
-
- /*!
- \brief Unpause Timer.
-
- Unpause the timer if it is paused.
- **/
void Unpause();
- /*!
- \brief Get Time of Timer.
-
- Get current time accounting for time paused.
- \return Current Timer Time.
- **/
Uint32 GetTime() const;
-
- /*!
- \brief Get paused state.
-
- Find out paused state of timer.
- \return Paused state for timer.
- **/
bool IsPaused() const;
};
diff --git a/include/ZEngine.h b/include/ZEngine.h
index 79bbd80..0da6f3d 100644
--- a/include/ZEngine.h
+++ b/include/ZEngine.h
@@ -1,53 +1,3 @@
-/*!
- \file ZEngine.h
- \brief Header file for ZEngine.
-
- Public header file for ZEngine, this is the file that programs that wish to utilize ZEngine should include.
-
$Id: ZEngine.h,v 1.38 2003/11/25 01:02:17 cozman Exp $
- \author James Turk
-**/
-
-/*!
- \mainpage ZEngine Documentation
-
- \author James Turk
- \version 0.8.5
- \date October 5th, 2003
-
- \section ZEngine About ZEngine
-
- -ZEngine is designed to provide a powerful yet easy to use 2D game engine in a well designed
- Object Oriented manner, and uses cross platform libraries such as SDL and OpenGL. (ZEngine can use SDL_ttf,SDL_image,
- and SDL_mixer all of which are cross platform as well as Open Source.)
- -It is licensed under a BSD-style license, and anyone is free to suggest or implement changes
- to be added to the Engine, as well as modify the engine to their own needs or use it however they like.
- -ZEngine now uses OpenGL rather than SDL to do 2D drawing, thus increasing the uses of the engine
- and making the engine much faster in all test cases, and the engine was tested for memory leaks with MSVC and is known
- to have no leaks.
- -ZEngine homepage : http://zengine.sourceforge.net/.
- -ZEngine tutorials : http://zengine.sourceforge.net/tutorials/.
- -ZEngine forums : http://sourceforge.net/forum/?group_id=62098.
-
- \section Licensing Licensing
-
- This file is Part of the ZEngine Library for 2D game development.
- Copyright (C) 2002, 2003 James Turk
-
- Licensed under a BSD-style license.
-
- The maintainer of this library is James Turk (james@conceptofzero.net)
- and the home of this Library is http://zengine.sourceforge.net
-
- \section Authors Contributing Authors
-
- James Turk james@conceptofzero.net - Core Engine, Design, Docs, and Classes
- Gamer Tazar tazar@conceptofzero.net - OpenGL assistance
- Sean sean@conceptofzero.net - MSVC++6 Project Files
- Kevin Watters kwatters@adelphia.net - Fix to ZImage::SetColorKey
- Atani atani@atani-software.net - Revised Linux Build System
- Stinus Petersen bison@flytlet.dk - Fix for ZImage::OpenFromImage with alpha images
-**/
-
#ifndef __zengine_h__
#define __zengine_h__
diff --git a/src/VersionInfo.cpp b/src/VersionInfo.cpp
index 00415e5..999c1e8 100755
--- a/src/VersionInfo.cpp
+++ b/src/VersionInfo.cpp
@@ -1,26 +1,30 @@
+/*******************************************************************************
+ This file is Part of the ZEngine Library for 2D game development.
+ Copyright (C) 2002-2004 James Turk
+
+ Licensed under a BSD-style license.
+
+ The maintainer of this library is James Turk (james@conceptofzero.net)
+ and the home of this Library is http://www.zengine.sourceforge.net
+*******************************************************************************/
+
#include "VersionInfo.h"
-/*!
- \file VersionInfo.cpp
- \brief Implementation file for VersionInfo class.
-
- Implementation file for VersinInfo class, simple class for containing and comparing
- version numbers.
-
$Id: VersionInfo.cpp,v 1.6 2003/07/12 09:22:13 cozman Exp $
- \author James Turk
-**/
-
VersionInfo::VersionInfo(unsigned int maj, unsigned int min, unsigned int rel, std::string ext) :
Major(maj), Minor(min), Release(rel), Extra(ext)
{
}
-std::string VersionInfo::GetString() const
+char* VersionInfo::GetString() const
{
+ static char verStr[100];
+
if(Extra.length())
- return ZE::FormatStr("%d.%d.%d [%s]",Major,Minor,Release,Extra.c_str());
+ sprintf(verStr,"%d.%d.%d [%s]",Major,Minor,Release,Extra.c_str());
else
- return ZE::FormatStr("%d.%d.%d",Major,Minor,Release);
+ sprintf(verStr,"%d.%d.%d",Major,Minor,Release);
+
+ return verStr;
}
bool VersionInfo::operator<(const VersionInfo &rhs) const
diff --git a/src/ZE_Utility.cpp b/src/ZE_Utility.cpp
index 8908430..58ecc41 100755
--- a/src/ZE_Utility.cpp
+++ b/src/ZE_Utility.cpp
@@ -1,6 +1,6 @@
/*******************************************************************************
This file is Part of the ZEngine Library for 2D game development.
- Copyright (C) 2002, 2003 James Turk
+ Copyright (C) 2002-2004 James Turk
Licensed under a BSD-style license.
@@ -8,27 +8,18 @@
and the home of this Library is http://www.zengine.sourceforge.net
*******************************************************************************/
-/**
- \file ZE_Utility.cpp
- \brief Source file for ZEngine utility functions.
-
- Source file containing open utilities for use inside and alongside ZEngine.
-
$Id: ZE_Utility.cpp,v 1.14 2003/11/24 02:07:03 cozman Exp $
- \author James Turk
-**/
-
#include "ZE_Utility.h"
namespace ZE
{
-std::string FormatStr(const std::string fmtstr, ...)
+std::string FormatStr(std::string fmtStr, ...)
{
- char buf[512];
- va_list args;
- //simply puts args into the buffer using standard parsing rules
- va_start(args,fmtstr);
- vsprintf(buf, fmtstr.c_str(), args);
+ std::va_list args;
+ char buf[1024];
+
+ va_start(args,fmtStr);
+ std::vsprintf(buf,fmtStr.c_str(),args);
va_end(args);
return buf;
@@ -76,6 +67,85 @@ SDL_RWops* RWFromZip(std::string zipname, std::string filename)
return SDL_RWFromMem(buffer, info.uncompressed_size); //return buffer in RW form
}
+#if (GFX_BACKEND == ZE_OGL)
+
+//from SDL's testgl.c power_of_two
+int PowerOfTwo(int num)
+{
+ int value = 1;
+
+ while(value < num) //texture coord must be >= input
+ value <<= 1; //value <<= 1 is the same as value *= 2
+ return value;
+}
+
+//from SDL's testgl.c SDL_GL_LoadTexture
+GLuint SurfaceToTexture(SDL_Surface *surface, GLfloat *texcoord)
+{
+ GLuint texture;
+ int w, h;
+ SDL_Surface *temp;
+ SDL_Rect area;
+ Uint32 saved_flags;
+ Uint8 saved_alpha;
+
+ //expand width and height to nearest powers of 2
+ w = PowerOfTwo(surface->w);
+ h = PowerOfTwo(surface->h);
+ texcoord[0] = 0.0f; //min X
+ texcoord[1] = 0.0f; //min Y
+ texcoord[2] = (GLfloat)surface->w / w; //max X
+ texcoord[3] = (GLfloat)surface->h / h; //max Y
+
+ temp = SDL_CreateRGBSurface(
+ SDL_SWSURFACE,
+ w, h,
+ 32,
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN //endian specific color masks
+ 0x000000FF,
+ 0x0000FF00,
+ 0x00FF0000,
+ 0xFF000000
+#else
+ 0xFF000000,
+ 0x00FF0000,
+ 0x0000FF00,
+ 0x000000FF
+#endif
+ );
+ if(!temp) //failure in CreateRGBSurface
+ return 0;
+
+ //save alpha
+ saved_flags = surface->flags&(SDL_SRCALPHA|SDL_RLEACCELOK);
+ saved_alpha = surface->format->alpha;
+ if((saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA)
+ SDL_SetAlpha(surface, 0, 0);
+
+ //copy surface (do not alter passed surface to allow this function to be used in special situations)
+ area.x = 0;
+ area.y = 0;
+ area.w = static_cast(surface->w);
+ area.h = static_cast(surface->h);
+ SDL_BlitSurface(surface, &area, temp, &area);
+
+ //restore saved alpha
+ if((saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA)
+ SDL_SetAlpha(surface, saved_flags, saved_alpha);
+
+ //create the OpenGL texture
+ glGenTextures(1, &texture);
+ //setup texture parmaters
+ glBindTexture(GL_TEXTURE_2D, texture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, temp->pixels);
+ SDL_FreeSurface(temp); //temp surface no longer needed
+
+ return texture;
+}
+#endif //GFX_BACKEND == ZE_OGL
+
//Each of the Free*s safely frees & NULLs the pointer
void FreeImage(SDL_Surface *&image)
{
diff --git a/src/ZE_ZAnimation.cpp b/src/ZE_ZAnimation.cpp
index 111736c..dbf6443 100644
--- a/src/ZE_ZAnimation.cpp
+++ b/src/ZE_ZAnimation.cpp
@@ -1,6 +1,6 @@
/*******************************************************************************
This file is Part of the ZEngine Library for 2D game development.
- Copyright (C) 2002, 2003 James Turk
+ Copyright (C) 2002-2004 James Turk
Licensed under a BSD-style license.
@@ -8,15 +8,6 @@
and the home of this Library is http://www.zengine.sourceforge.net
*******************************************************************************/
-/**
- \file ZE_ZAnimation.cpp
- \brief Source file for ZAnimation.
-
- Implementation of ZAnimation, ZEngine's class for ZImage based animations.
-
$Id: ZE_ZAnimation.cpp,v 1.2 2003/12/24 04:44:41 cozman Exp $
- \author James Turk
-**/
-
#include "ZE_ZAnimation.h"
namespace ZE
@@ -37,6 +28,10 @@ ZAnimation::ZAnimation(ZImage *images, int numFrames, Uint32 frameDelay, ZAnimTy
Create(images,numFrames,frameDelay,type,backwards);
}
+ZAnimation::~ZAnimation()
+{
+}
+
void ZAnimation::Create(ZImage *images, int numFrames, Uint32 frameDelay, ZAnimType type, bool backwards)
{
rAnimImages = images;
@@ -138,7 +133,7 @@ void ZAnimation::Draw(float x, float y) const
//error: images not loaded
}
-bool ZAnimation::Running() const
+bool ZAnimation::IsRunning() const
{
return rFrameStep != 0;
}
diff --git a/src/ZE_ZConfigFile.cpp b/src/ZE_ZConfigFile.cpp
index 891a5aa..54455d4 100644
--- a/src/ZE_ZConfigFile.cpp
+++ b/src/ZE_ZConfigFile.cpp
@@ -1,6 +1,6 @@
/*******************************************************************************
This file is Part of the ZEngine Library for 2D game development.
- Copyright (C) 2002, 2003 James Turk
+ Copyright (C) 2002-2004 James Turk
Licensed under a BSD-style license.
@@ -8,15 +8,6 @@
and the home of this Library is http://www.zengine.sourceforge.net
*******************************************************************************/
-/**
- \file ZE_ZConfigFile.cpp
- \brief Source file for ZConfigFile.
-
- Implementation of ZConfigFile, the ZEngine INI-Style Config File.
-
$Id: ZE_ZConfigFile.cpp,v 1.15 2003/11/24 22:20:49 cozman Exp $
- \author James Turk
-**/
-
#include "ZE_ZConfigFile.h"
namespace ZE
@@ -177,11 +168,12 @@ ZConfigFile::~ZConfigFile()
void ZConfigFile::Process(std::string filename)
{
rFilename = filename;
- int commentNum=0;
- int newlineNum=0;
-
- std::ifstream cfile(rFilename.c_str());
+ int commentNum,newlineNum;
+ char commentStr[15],newlineStr[15];
std::string section, str, var, tmp;
+ std::ifstream cfile(rFilename.c_str());
+
+ commentNum = newlineNum = 0; //comment/newline support is a bit of a hack
rFileLayout.clear(); //layout must be cleared, in case variable is being used multiple times
@@ -200,12 +192,14 @@ void ZConfigFile::Process(std::string filename)
}
else if(tmp[0] == '#' || tmp[0] == ';') //acceptable comment characters
{
- SetVariable(section,FormatStr("__comment%d",commentNum),str);
+ sprintf(commentStr,"__comment%d",commentNum);
+ SetVariable(section,commentStr,str);
++commentNum;
}
- else if(tmp.length() == 0 && !cfile.eof()) //prevent writing a new newline with every write to disk
+ else if(tmp.length() == 0 && !cfile.eof()) //avoid adding a line to end of file each time
{
- SetVariable(section,FormatStr("__newline%d",newlineNum),"");
+ sprintf(newlineStr,"__newline%d",newlineNum);
+ SetVariable(section,newlineStr,str);
++newlineNum;
}
diff --git a/src/ZE_ZEngine.cpp b/src/ZE_ZEngine.cpp
index 043c393..b0e1d14 100644
--- a/src/ZE_ZEngine.cpp
+++ b/src/ZE_ZEngine.cpp
@@ -1,6 +1,6 @@
/*******************************************************************************
This file is Part of the ZEngine Library for 2D game development.
- Copyright (C) 2002, 2003 James Turk
+ Copyright (C) 2002-2004 James Turk
Licensed under a BSD-style license.
@@ -8,15 +8,6 @@
and the home of this Library is http://www.zengine.sourceforge.net
*******************************************************************************/
-/**
- \file ZE_ZEngine.cpp
- \brief Central source file for ZEngine.
-
- Actual implementation of ZEngine singleton class, the core of ZEngine.
-
$Id: ZE_ZEngine.cpp,v 1.67 2003/12/24 04:43:36 cozman Exp $
- \author James Turk
-**/
-
#include "ZE_ZEngine.h"
#include "ZE_ZRect.h"
@@ -65,7 +56,7 @@ ZEngine* ZEngine::GetInstance()
{
if(!sInstance) //first time through, gets new instance, each time after returns same one
sInstance = new ZEngine;
-
+ atexit(ZEngine::ReleaseInstance);
return sInstance;
}
@@ -73,7 +64,13 @@ void ZEngine::ReleaseInstance()
{
if(sInstance)
{
- sInstance->CloseDisplay();
+ if(sInstance->mErrlog && sInstance->mLogStyle == ZLOG_HTML)
+ {
+ fprintf(sInstance->mErrlog,"