Permalink
Browse files

Cosmetics again

  • Loading branch information...
Keruspe committed Jun 27, 2010
1 parent bf11028 commit ee872c0a4a1e7e7438f74a01649ad9669c44982c
Showing with 47 additions and 47 deletions.
  1. +6 −5 src/game/AI.cpp
  2. +1 −1 src/game/AI.hpp
  3. +4 −5 src/game/game.cpp
  4. +3 −3 src/game/menu.cpp
  5. +2 −2 src/game/menu.hpp
  6. +31 −31 src/game/player.cpp
View
@@ -24,15 +24,15 @@ using namespace bombherman;
AI::AI() :
Player(),
playerMap(std::vector<map::Coords>())
playerMap(std::vector< map::Coords >())
{
this->init();
}
void
AI::newAI()
{
if (Player::players.size() >= static_cast<unsigned>(Config::getInt("maxPlayers")))
if ( Player::players.size() >= static_cast< unsigned >(Config::getInt("maxPlayers")) )
throw exceptions::TooManyPlayersException();
Player::players.push_back(new AI());
}
@@ -47,7 +47,7 @@ AI::init()
int
AI::run(void * param)
{
AI * ai = static_cast<AI *>(param);
AI * ai = static_cast< AI * >(param);
// Keep alive the thread during entire game
while (true)
@@ -65,7 +65,7 @@ AI::run(void * param)
void
AI::findPath()
{
Uint32 maxRange = static_cast<Uint32>(Config::getInt("maxRange"));
const Uint32 maxRange = static_cast< Uint32 >(Config::getInt("maxRange"));
//Uint32 maxItems = maxRange*maxRange*4;
// Max points with setting maxRange
@@ -80,7 +80,8 @@ AI::findPath()
map::Coords current = this->coords;
while (current.x > maxLeft && current.x < maxRight && current.y > maxTop && current.y < maxBottom)
while ( current.x > maxLeft && current.x < maxRight
&& current.y > maxTop && current.y < maxBottom )
{
// A* algorithm
View
@@ -41,7 +41,7 @@ namespace bombherman
void init();
static int run(void *);
void findPath();
std::vector<map::Coords> playerMap;
std::vector< map::Coords > playerMap;
};
}
View
@@ -60,7 +60,8 @@ void Game::init()
void
Game::main()
{
if ( ! Game::isInit ) init();
if ( ! Game::isInit )
init();
SDL_Event event;
while ( Game::playing && SDL_WaitEvent(&event) )
@@ -124,9 +125,7 @@ Game::nextMap()
Game::waitThreads();
map::Map::deleteMap();
if ( --Game::mapCount < 0 )
{
Display::displayScores();
}
else
{
// We still have maps to play on !
@@ -149,7 +148,7 @@ int
Game::eventMenu(void * event)
{
// Handle events in menus
switch ( reinterpret_cast<SDL_KeyboardEvent *>(event)->keysym.sym )
switch ( reinterpret_cast< SDL_KeyboardEvent * >(event)->keysym.sym )
{
case SDLK_ESCAPE:
currentMenu->quit();
@@ -181,7 +180,7 @@ int
Game::eventGame(void * event)
{
// Handle events in game (moves, bomb planting ...)
switch ( reinterpret_cast<SDL_KeyboardEvent *>(event)->keysym.sym )
switch ( reinterpret_cast< SDL_KeyboardEvent * >(event)->keysym.sym )
{
case SDLK_ESCAPE:
changeMenu(Menu::MAIN);
View
@@ -25,7 +25,7 @@
using namespace bombherman;
// Initialize statics
std::map<Menu::Type, Menu *> Menu::menus;
std::map< Menu::Type, Menu * > Menu::menus;
Menu::Menu(Type type) :
type(type),
@@ -76,7 +76,7 @@ void
Menu::clear()
{
// Delete the menus from the map
for ( std::map<Menu::Type, Menu *>::iterator i = Menu::menus.begin(),
for ( std::map< Menu::Type, Menu * >::iterator i = Menu::menus.begin(),
e = Menu::menus.end(); i != e ; ++i )
delete(i->second);
}
@@ -141,7 +141,7 @@ Menu::action()
void
Menu::quit()
{
switch (this->type)
switch ( this->type )
{
case MAIN: // Exit the application
Game::stop();
View
@@ -81,9 +81,9 @@ namespace bombherman
private:
Menu(Type type);
void setContent();
static std::map<Type, Menu *> menus;
static std::map< Type, Menu * > menus;
Type type;
std::vector<std::string> content;
std::vector< std::string > content;
unsigned int current;
};
}
View
@@ -28,17 +28,17 @@
using namespace bombherman;
// Initialize statics
std::vector<Player * > Player::players;
std::vector< Player * > Player::players;
unsigned Player::icyDeadPeople = 0;
Player::Player() :
plantableBombs (Config::getInt("defaultPlantableBombs")),
range (Config::getInt("defaultRange")),
plantedBombs (0),
score (0),
id (Player::players.size() + 1),
Player::Player() :
plantableBombs(Config::getInt("defaultPlantableBombs")),
range(Config::getInt("defaultRange")),
plantedBombs(0),
score(0),
id(Player::players.size() + 1),
alive(true),
coords (map::Coords()),
coords(map::Coords()),
orient(map::DOWN),
move_mutex(SDL_CreateMutex()),
currentMoves(0)
@@ -78,24 +78,24 @@ Player::operator=(const Player & other)
Player *
Player::getPlayer(int id)
{
if (Player::players.size() < static_cast<unsigned>(id) || 0 >= id)
if ( Player::players.size() < static_cast<unsigned>(id) || 0 >= id )
return 0;
return Player::players[id - 1];
}
void
Player::newPlayer()
{
if (Player::players.size() >= static_cast<unsigned>(Config::getInt("maxPlayers")))
if ( Player::players.size() >= static_cast< unsigned >(Config::getInt("maxPlayers")) )
throw exceptions::TooManyPlayersException();
Player::players.push_back(new Player());
}
void
Player::clean()
{
for (std::vector< Player * >::iterator i = Player::players.begin(),
i_end = Player::players.end(); i != i_end ; ++i)
for ( std::vector< Player * >::iterator i = Player::players.begin(),
i_end = Player::players.end(); i != i_end ; ++i )
{
delete(*i);
}
@@ -105,7 +105,7 @@ Player::clean()
bool
Player::kill(Player * killed)
{
if (! killed->alive)
if ( ! killed->alive )
return false;
if ( killed == this )
this->addToScore(Config::getInt("suicideMalus"));
@@ -139,8 +139,8 @@ Player::reInit(void *)
Player::icyDeadPeople = 0;
// Reset players' defaults
for (std::vector< Player * > ::iterator i = Player::players.begin(),
i_end = Player::players.end() ; i != i_end ; ++i)
for ( std::vector< Player * > ::iterator i = Player::players.begin(),
i_end = Player::players.end() ; i != i_end ; ++i )
(*i)->resetToDefaultStats();
// Go to next map
@@ -151,36 +151,36 @@ Player::reInit(void *)
void
Player::setRange(Uint32 range)
{
if (range < static_cast<Uint32>(Config::getInt("minRange")))
this->range = static_cast<Uint32>(Config::getInt("minRange"));
else if (range > static_cast<Uint32>(Config::getInt("maxRange")))
this->range = static_cast<Uint32>(Config::getInt("maxRange"));
if (range < static_cast< Uint32 >(Config::getInt("minRange")))
this->range = static_cast< Uint32 >(Config::getInt("minRange"));
else if (range > static_cast< Uint32 >(Config::getInt("maxRange")))
this->range = static_cast< Uint32 >(Config::getInt("maxRange"));
else
this->range = range;
}
void
Player::go(map::Direction direction)
{
if (! this)
if ( ! this )
// If we don't exist (new Game), nothing'll happen
return;
if ( this->currentMoves < 2 )
++this->currentMoves;
else
return;
SDL_LockMutex(move_mutex);
if (! this->alive)
if ( ! this->alive )
{
// We-re dead
SDL_UnlockMutex(this->move_mutex);
return;
}
bool orientChanged = (this->orient != direction);
if (orientChanged)
bool orientChanged = ( this->orient != direction );
if ( orientChanged )
this->orient = direction;
map::MoveResult moveResult = map::Map::movePlayer(this->coords, direction);
if (moveResult == map::NOTHINGHAPPENED && orientChanged)
if ( moveResult == map::NOTHINGHAPPENED && orientChanged )
Display::movePlayer(this, map::ORIENTCHANGED);
Display::movePlayer(this, moveResult);
SDL_UnlockMutex(this->move_mutex);
@@ -192,16 +192,16 @@ Player::addToScore(int score)
{
if ( (this->score += score) < Config::getInt("minimumScore") )
this->score = -9;
else if (this->score > Config::getInt("maximumScore"))
else if ( this->score > Config::getInt("maximumScore") )
this->score = 99;
}
void
Player::setPlantableBombs(int plantableBombs)
{
if(plantableBombs < Config::getInt("minCapacity"))
if ( plantableBombs < Config::getInt("minCapacity") )
this->plantableBombs = Config::getInt("minCapacity");
else if (plantableBombs > Config::getInt("maxCapacity"))
else if ( plantableBombs > Config::getInt("maxCapacity") )
this->plantableBombs = Config::getInt("maxCapacity");
else
this->plantableBombs = plantableBombs;
@@ -219,7 +219,7 @@ Player::resetToDefaultStats()
void
Player::plantBomb()
{
if (! this->isAbleToPlantBomb())
if ( ! this->isAbleToPlantBomb() )
return;
if ( bomb::AtomicCenter::plantBomb(this->id, this->coords, this->range) )
{ // The bomb has been planted !
@@ -232,10 +232,10 @@ Player *
Player::playerAt(map::Coords & c)
{
// We read all players
for (std::vector< Player * >::iterator i = Player::players.begin(),
i_end = Player::players.end() ; i != i_end ; ++i)
for ( std::vector< Player * >::iterator i = Player::players.begin(),
i_end = Player::players.end() ; i != i_end ; ++i )
// Coords are equal ? That's the one we're looking for !
if((*i)->getCoords() == c)
if ( (*i)->getCoords() == c )
return *i;
return 0;
}

0 comments on commit ee872c0

Please sign in to comment.