Commit c490bb6d authored by Albert Ziegenhagel's avatar Albert Ziegenhagel

New branch for refactoring of SDL event handling and the menu system

git-svn-id: svn://maxr.org/MAX/branches/menu_event_refactoring@3506 c3bd5e88-ca0b-48cf-b972-da51c77c4c1b
parents
/build/
/config.*
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Deutsch (Deutschland) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
#ifdef _WIN32
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON ICON "maxr.ico"
IDI_SMALL ICON "maxr.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDB_BITMAP1 BITMAP "maxr.bmp"
#endif // Deutsch (Deutschland) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
/*
SDL_flic - renders FLIC animations
Copyright (C) 2003 Andre de Leiradella
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For information about SDL_flic contact leiradella@bigfoot.com
Version 1.0: first public release.
Version 1.1: fixed bug to set *error to FLI_OK when returning successfully from FLI_Open
added function FLI_Reset to reset the animation to the first frame
Version 1.2: added function FLI_Skip to skip the current frame without rendering
FLI_Animation->surface is now correctly locked and unlocked
the rwops stream is now part of the FLI_Animation structure and is closed inside FLI_Close
renamed FLI_Reset to FLI_Rewind
added function FLI_Version that returns the library version
*/
#ifndef __SDL_flic_h__
#define __SDL_flic_h__
#include <SDL.h>
#include <setjmp.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Supported formats. */
#define FLI_FLI 0xAF11
#define FLI_FLC 0xAF12
/* Error codes. */
/* No error. */
#define FLI_OK 0
/* Error reading the file. */
#define FLI_READERROR 1
/* Invalid frame size (corrupted file). */
#define FLI_CORRUPTEDFILE 2
/* Error in SDL operation. */
#define FLI_SDLERROR 3
/* Out of memory. */
#define FLI_OUTOFMEMORY 4
/*
The animation structure, all members are read-only, don't try to longjmp to
error.
*/
typedef struct {
Uint32 format, numframes, width, height, depth, delay, offframe1, nextframe, offnextframe;
/* rwops is where the animation is read from. */
SDL_RWops *rwops;
/* surface is where the frames is rendered to. */
SDL_Surface *surface;
/* error is used to longjmp in case of error so to avoid a chain of if's. */
jmp_buf error;
} FLI_Animation;
/*
Returns the library version in the format MAJOR << 16 | MINOR.
*/
extern int FLI_Version(void);
/*
Opens a FLIC animation and return a pointer to it. rwops is left at the same
point it was before the the call. error receives the result of the call.
*/
extern FLI_Animation *FLI_Open(SDL_RWops *rwops, int *error);
/*
Closes the animation, closes the stream and frees all used memory.
*/
extern void FLI_Close(FLI_Animation *flic);
/*
Renders the next frame of the animation returning an int to indicate if it was
successfull or not.
*/
extern int FLI_NextFrame(FLI_Animation *flic);
/*
Rewinds the animation to the first frame.
*/
extern int FLI_Rewind(FLI_Animation *flic);
/*
Skips the current frame of the animation without rendering it.
*/
extern int FLI_Skip(FLI_Animation *flic);
#ifdef __cplusplus
};
#endif
#endif
# config file for AStyle ( http://astyle.sourceforge.net/ )
# AStyle version : 2.0.4
# typical run: AStyle --options=astylerc --recursive "*.cpp" "*.h"
# style
--style=ansi
--indent=force-tab=4
#--lineend=linux
--lineend=windows
--min-conditional-indent=0
--max-instatement-indent=60
--keep-one-line-statements
--keep-one-line-blocks
--indent-preprocessor
--indent-col1-comments
--indent-switches
--unpad-paren
--pad-oper
--pad-header
#--pad-paren-out
--pad-first-paren-out
#--add-brackets
--align-pointer=type
--align-reference=type
--mode=c
# extra options
# do not modify 'extern' files
--exclude=SDL_flic.c
--exclude=SDL_flic.h
--exclude=mveplayer.cpp
--exclude=mveplayer.h
--exclude=tinyxml2.cpp
--exclude=tinyxml2.h
--ignore-exclude-errors-x
--preserve-date
--suffix=none
--formatted
This diff is collapsed.
/***************************************************************************
* Mechanized Assault and Exploration Reloaded Projectfile *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef attackjobsH
#define attackjobsH
#include <vector>
class cBuilding;
class cClient;
class cMap;
class cMenu;
class cNetMessage;
class cPlayer;
class cServer;
class cUnit;
class cVehicle;
/**
* selects a target unit from a map field, depending on the attack mode.
*/
cUnit* selectTarget (int x, int y, char attackMode, cMap* map);
//--------------------------------------------------------------------------
class cServerAttackJob
{
public:
cServerAttackJob (cServer& server_, cUnit* _unit, int targetOff, bool sentry);
~cServerAttackJob();
void sendFireCommand (cPlayer* player);
void clientFinished (int playerNr);
//--------------------------------------------------------------------------
private:
/** syncronizes positions of target, locks target and suspents move job if necessary
* @author Eiko
*/
void lockTarget (int offset);
void lockTargetCluster();
void sendFireCommand();
void makeImpact (int x, int y);
void makeImpactCluster();
void sendAttackJobImpact (int offset, int remainingHP, int id);
bool isMuzzleTypeRocket() const;
public:
/** the clients on which the attack job is currently running */
std::vector<cPlayer*> executingClients;
cUnit* unit;
int iID;
private:
static int iNextID;
cServer* server;
bool sentryFire;
int iAgressorOff;
int iMuzzleType;
bool bMuzzlePlayed;
int iTargetOff;
int damage;
char attackMode;
/** these lists are only used to sort out duplicate targets,
* when making a cluster impact */
std::vector<cUnit*> targets;
};
//--------------------------------------------------------------------------
class cClientAttackJob
{
private:
int iID;
cUnit* unit;
int iFireDir;
int iMuzzleType;
int iAgressorOffset;
int iTargetOffset;
int wait;
int length;
enum eAJStates { ROTATING, PLAYING_MUZZLE, FINISHED };
eAJStates state;
public:
/** prepares a mapsquare to be attacked
* @author Eiko
*/
static void lockTarget (cClient& client, cNetMessage* message);
static void handleAttackJobs (cClient& client, cMenu* activeMenu);
static void makeImpact (cClient& client, int offset, int remainingHP, int id);
public:
cClientAttackJob (cClient* client, cNetMessage* message);
void rotate();
void playMuzzle (cClient& client, cMenu* activeMenu);
void sendFinishMessage (cClient& client);
void onRemoveUnit (cUnit& unit_) { if (unit == &unit_) unit = 0; }
};
#endif //#ifndef attackjobsH
This diff is collapsed.
/***************************************************************************
* Mechanized Assault and Exploration Reloaded Projectfile *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef automjobsH
#define automjobsH
class cClient;
class cClientMoveJob;
class cVehicle;
class cAutoMJob
{
private:
int lastDestX; // last destination generated by the AI.
int lastDestY;
// needed to check if the move job was changed from outside the AI (i.e. by the player)
cClient* client;
cVehicle* vehicle; // the vehicle the auto move job belongs to
int n; // frame delay counter
bool finished; // true when the job can be deleted
// the operation point of the surveyor
// the surveyor tries to stay near this coordinates
int OPX;
int OPY;
bool playerMJob; //the player has changed the move job
private:
float calcScoreDistToOtherSurveyor (const std::vector<cAutoMJob*>& jobs, int PosX, int PosY, float e) const;
void DoAutoMove (const std::vector<cAutoMJob*>& jobs, int iNumber);
float CalcFactor (int PosX, int PosY, const std::vector<cAutoMJob*>& jobs);
void PlanNextMove (const std::vector<cAutoMJob*>& jobs);
void PlanLongMove (const std::vector<cAutoMJob*>& jobs);
void changeOP();
bool isFinished() const { return finished; }
public:
cAutoMJob (cClient& client, cVehicle* vehicle);
~cAutoMJob();
public:
static void handleAutoMoveJobs();
};
#endif //automjobsH
#ifndef AUTOOBJ_H
#define AUTOOBJ_H
#if __cplusplus >= 201103L || defined __GXX_EXPERIMENTAL_CXX0X__
# define DELETE_CPP11 = delete
#else
# define DELETE_CPP11
#endif
template <typename T, void (&dealloc) (T*) > class AutoObj
{
public:
explicit AutoObj (T* const p = 0) : p_ (p) {}
~AutoObj() { if (p_) dealloc (p_); }
T* Release()
{
T* const p = p_;
p_ = 0;
return p;
}
void operator = (T* const p)
{
if (p_) dealloc (p_);
p_ = p;
}
T* operator ->() const { return p_; }
operator T* () const { return p_; }
private:
T* p_;
AutoObj (AutoObj const&) DELETE_CPP11; // No copy.
void operator = (AutoObj&) DELETE_CPP11; // No assignment.
};
#endif
#ifndef AUTOPTR_H
#define AUTOPTR_H
#include "autoobj.h"
template <typename T>
class AutoPtr
{
public:
explicit AutoPtr (T* const p_ = NULL) : p (p_) {}
~AutoPtr() { delete p; }
T* Release()
{
T* const p_ = p;
p = NULL;
return p_;
}
void operator = (T* const p_)
{
delete p;
p = p_;
}
T* operator ->() const { return p; }
operator T* () const { return p; }
private:
T* p;
AutoPtr (const AutoPtr&) DELETE_CPP11; // No copy.
void operator = (AutoPtr&) DELETE_CPP11; // No assignment.
};
#endif
#ifndef AUTOSURFACE_H
#define AUTOSURFACE_H
#include <SDL.h>
#include "autoobj.h"
typedef AutoObj<SDL_Surface, SDL_FreeSurface> AutoSurface;
/* Prevent accidentally freeing the SDL_Surface owned by an AutoSurface */
void SDL_FreeSurface (AutoSurface const&) DELETE_CPP11;
#endif
This diff is collapsed.
/***************************************************************************
* Mechanized Assault and Exploration Reloaded Projectfile *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef baseH
#define baseH
#include <vector>
#include "main.h" // for sUnitData and sUnitData::eStorageResType
class cBuilding;
class cMap;
class cNetMessage;
class cPlayer;
class cServer;
struct sSubBase
{
public:
explicit sSubBase (cPlayer* owner_);
/**
* integrates all building of the given subbase in the own one
* @author eiko
*/
void merge (sSubBase* sb);
/**
* returns an unique number to identify the subbase
* @author eiko
*/
int getID() const;
void addBuilding (cBuilding* b);
/**
* adds/subtracts a ressource to/from the subbase
* @author eiko
*/
void addMetal (cServer& server, int value);
void addOil (cServer& server, int value);
void addGold (cServer& server, int value);
/**
* recalculates the values of all subbases
* @author eiko
*/
void refresh();
/**
* inreases the energy production of the subbase by
* starting offline generators/stations
* @author eiko
*/
bool increaseEnergyProd (cServer& server, int value);
//-----------------------------------
//turn end management:
/**
* checks if consumers have to be switched off, due to a lack of ressources
* @return returns true, if consumers have been shut down
* @author eiko
*/
bool checkGoldConsumer (cServer& server);
bool checkHumanConsumer (cServer& server);
bool checkMetalConsumer (cServer& server);
/**
* - switches off unneeded fuel consumers(=energy producers)
* - sets the optimal amount of generators and stations
* to minimize fuel consumption
* - increases oil production, if necessary
* - switches off oil consumers, if too few oil is available
* @return: returns true, if oil consumers have been shut down,
* due to a lack of oil
* @author eiko
*/
bool checkOil (cServer& server);
/**
* switches off energy consumers, if necessary
* @return returns true, if a energy consumers have been shut down
* @author eiko
*/
bool checkEnergy (cServer& server);
/**
* checks, if there are consumers, that have to be shut down,
* due to a lack of a ressources
* @author eiko
*/
void prepareTurnend (cServer& server);
/**
* produce ressources, repair/reload buildings etc.
* @author eiko
*/
void makeTurnend (cServer& server);
//------------------------------------
//ressource management:
/** returns the maximum production of a ressource */
int getMaxMetalProd() const;
int getMaxGoldProd() const;
int getMaxOilProd() const;
/** returns the maximum allowed production
* (without decreasing one of the other ones) of a ressource */
int getMaxAllowedMetalProd() const;
int getMaxAllowedGoldProd() const;
int getMaxAllowedOilProd() const;
/** returns the current production of a ressource */
int getMetalProd() const;
int getGoldProd() const;
int getOilProd() const;
/** sets the production of a ressource.
* If value is bigger then maxAllowed,
* it will be reduced to the maximum allowed value */
void setMetalProd (int value);
void setGoldProd (int value);
void setOilProd (int value);
/** changes the production of a ressource by value. */
void changeMetalProd (int value);
void changeGoldProd (int value);
void changeOilProd (int value);
bool isDitributionMaximized() const;
void pushInto (cNetMessage& message) const;
void popFrom (cNetMessage& message);
private:
void makeTurnend_reparation (cServer& server, cBuilding& building);
void makeTurnend_reload (cServer& server, cBuilding& building);
void makeTurnend_build (cServer& server, cBuilding& building);
/**
* calcs the maximum allowed production of a ressource,
* without decreasing the production of the other two
* @author eiko
*/
int calcMaxAllowedProd (int ressourceType) const;
/**
* calcs the maximum possible production of a ressource