1
0
mirror of https://github.com/blupi-games/planetblupi synced 2024-12-30 10:15:36 +01:00

Cosmetics: fix style, remove deadcode, const

This commit is contained in:
Mathieu Schroeter 2017-02-12 14:36:34 +01:00
parent 01c8b5a042
commit ebec94b32b
11 changed files with 187 additions and 332 deletions

View File

@ -1,30 +1,25 @@
// Action.cpp
//
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "def.h" #include "def.h"
#include "action.h" #include "action.h"
#include "misc.h" #include "misc.h"
#define MAXICON (1 + 50)
#define MAXMOVE (2 + 30 * 3)
#define MAXSOUND (1 + 50)
struct DescAction
#define MAXICON (1+50)
#define MAXMOVE (2+30*3)
#define MAXSOUND (1+50)
typedef struct
{ {
Sint16 action; Sint16 action;
Sint16 channel; Sint16 channel;
Sint16 icons[8][MAXICON]; // nb, icones, Sint16 icons[8][MAXICON]; // nb, icones,
Sint16 moves[8][MAXMOVE]; // nb, nb, x,y, Sint16 moves[8][MAXMOVE]; // nb, nb, x,y,
Sint16 sounds[MAXSOUND]; // nb, sons, Sint16 sounds[MAXSOUND]; // nb, sons,
} };
DescAction;
static const DescAction action_table[] =
static DescAction action_table[] =
{ {
{ {
ACTION_STOP, ACTION_STOP,
@ -2712,7 +2707,6 @@ static DescAction action_table[] =
} }
}; };
// Calcule l'action suivante. // Calcule l'action suivante.
// Retourne false lorsque l'action est terminée. // Retourne false lorsque l'action est terminée.
@ -2721,7 +2715,7 @@ bool Action (Sint16 action, Sint16 direct,
Sint16 &channel, Sint16 &icon, POINT &pos, Sint16 &posZ, Sint16 &channel, Sint16 &icon, POINT &pos, Sint16 &posZ,
Sint16 &sound) Sint16 &sound)
{ {
DescAction *pTable = action_table; const auto *pTable = action_table;
Sint16 nbIcon, nbPhase, nbMove, nbSound, i; Sint16 nbIcon, nbPhase, nbMove, nbSound, i;
pos.x = 0; pos.x = 0;
@ -2773,9 +2767,7 @@ bool Action (Sint16 action, Sint16 direct,
return false; return false;
} }
static const Sint16 rotate_table[] =
static Sint16 rotate_table[] =
{ {
0, 6, 12, 18, 24, 30, 36, 42, 0, 6, 12, 18, 24, 30, 36, 42,
1, 7, 13, 19, 25, 31, 37, 43, 1, 7, 13, 19, 25, 31, 37, 43,
@ -2804,7 +2796,7 @@ static Sint16 rotate_table[] =
bool Rotate (Sint16 &icon, Sint16 direct) bool Rotate (Sint16 &icon, Sint16 direct)
{ {
Sint16 *pTable = rotate_table; const auto *pTable = rotate_table;
Sint16 i; Sint16 i;
Sint16 offset = 0; Sint16 offset = 0;
@ -2865,7 +2857,7 @@ bool Rotate (Sint16 &icon, Sint16 direct)
Sint32 GetIconDirect (Sint16 icon) Sint32 GetIconDirect (Sint16 icon)
{ {
Sint16 *pTable = rotate_table; const auto *pTable = rotate_table;
Sint16 i; Sint16 i;
if (icon >= 169 && icon <= 192) // blupi malade ? if (icon >= 169 && icon <= 192) // blupi malade ?
@ -2883,10 +2875,8 @@ Sint32 GetIconDirect (Sint16 icon)
while (pTable[0] != -1) while (pTable[0] != -1)
{ {
for (i = 0 ; i < 8 ; i++) for (i = 0 ; i < 8 ; i++)
{
if (icon == pTable[i]) if (icon == pTable[i])
return i * 16; return i * 16;
}
pTable += 8; pTable += 8;
} }
@ -2894,20 +2884,22 @@ Sint32 GetIconDirect (Sint16 icon)
return -1; return -1;
} }
// Retourne l'amplitude d'une action, en nombre // Retourne l'amplitude d'une action, en nombre
// de cellules. // de cellules.
Sint32 GetAmplitude (Sint16 action) Sint32 GetAmplitude (Sint16 action)
{ {
if (action == ACTION_SAUTE2) switch (action)
{
case ACTION_SAUTE2:
return 2; return 2;
if (action == ACTION_SAUTE3) case ACTION_SAUTE3:
return 3; return 3;
if (action == ACTION_SAUTE4) case ACTION_SAUTE4:
return 4; return 4;
if (action == ACTION_SAUTE5) case ACTION_SAUTE5:
return 5; return 5;
}
return 1; return 1;
} }

View File

@ -1,5 +1,3 @@
// Action.h
//
#pragma once #pragma once
@ -10,13 +8,6 @@ bool Action (Sint16 action, Sint16 direct,
Sint16 &phase, Sint16 &step, Sint16 &phase, Sint16 &step,
Sint16 &channel, Sint16 &icon, POINT &pos, Sint16 &posZ, Sint16 &channel, Sint16 &icon, POINT &pos, Sint16 &posZ,
Sint16 &sound); Sint16 &sound);
extern
bool Rotate (Sint16 &icon, Sint16 direct); bool Rotate (Sint16 &icon, Sint16 direct);
extern
Sint32 GetIconDirect (Sint16 icon); Sint32 GetIconDirect (Sint16 icon);
extern
Sint32 GetAmplitude (Sint16 action); Sint32 GetAmplitude (Sint16 action);

View File

@ -1,5 +1,3 @@
// Arrange.cpp
//
#include "decor.h" #include "decor.h"
#include "misc.h" #include "misc.h"
@ -8,7 +6,7 @@
// l'eau lorsque la valeur est à un. // l'eau lorsque la valeur est à un.
// 0 1 // 0 1
// 2 3 // 2 3
static char tableSee[14 * 4] = static const char tableSee[14 * 4] =
{ {
0, 0, 0, 0, // 1 0, 0, 0, 0, // 1
0, 1, 0, 1, // 2 0, 1, 0, 1, // 2
@ -30,7 +28,7 @@ static char tableSee[14 * 4] =
// la mousse ou de la terre lorsque la valeur est à un. // la mousse ou de la terre lorsque la valeur est à un.
// 0 1 // 0 1
// 2 3 // 2 3
static char tableDark[13 * 4] = static const char tableDark[13 * 4] =
{ {
1, 1, 1, 1, // 20 1, 1, 1, 1, // 20
0, 1, 0, 1, // 21 0, 1, 0, 1, // 21
@ -121,13 +119,13 @@ bool CDecor::GetSeeBits (POINT cel, char *pBits, Sint32 index)
return true; return true;
} }
void CopyBits (char *pDst, char *pSrc) static void CopyBits (char *pDst, char *pSrc)
{ {
for (Sint32 i = 0 ; i < 4 ; i++) for (Sint32 i = 0 ; i < 4 ; i++)
*pDst++ = *pSrc++; *pDst++ = *pSrc++;
} }
bool ChangeBits (char *pDst, char *pSrc) static bool ChangeBits (char *pDst, char *pSrc)
{ {
for (Sint32 i = 0 ; i < 4 ; i++) for (Sint32 i = 0 ; i < 4 ; i++)
{ {
@ -371,11 +369,9 @@ void CDecor::ArrangeFloor (POINT cel)
} }
} }
// Cette table donne les directions dans l'ordre // Cette table donne les directions dans l'ordre
// est-sud-ouest-nord pour les murs. // est-sud-ouest-nord pour les murs.
static char tableMur[5 * 15] = static const char tableMur[5 * 15] =
{ {
20, 1, 0, 1, 0, 20, 1, 0, 1, 0,
21, 0, 1, 0, 1, 21, 0, 1, 0, 1,
@ -396,7 +392,7 @@ static char tableMur[5 * 15] =
21, 0, 0, 0, 1, 21, 0, 0, 0, 1,
}; };
static Sint16 tableMurDir[4 * 2] = static const Sint16 tableMurDir[4 * 2] =
{ {
+2, 0, // est +2, 0, // est
0, +2, // sur 0, +2, // sur
@ -685,8 +681,6 @@ void CDecor::ArrangeObject (POINT cel)
} }
} }
// Test s'il faut remplir le sol ici. // Test s'il faut remplir le sol ici.
bool CDecor::ArrangeFillTestFloor (POINT cel1, POINT cel2) bool CDecor::ArrangeFillTestFloor (POINT cel1, POINT cel2)
@ -907,7 +901,6 @@ void CDecor::ArrangeFill (POINT pos, Sint32 channel, Sint32 icon, bool bFloor)
free (m_pFillMap); free (m_pFillMap);
} }
// Supprime tous les personnages bloqués dans des murs // Supprime tous les personnages bloqués dans des murs
// ou debout sur l'eau. // ou debout sur l'eau.
@ -924,4 +917,3 @@ void CDecor::ArrangeBlupi()
} }
} }
} }

View File

@ -1,8 +1,7 @@
// blupi.cpp
//
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "blupi.h" #include "blupi.h"
#include "def.h" #include "def.h"
#include "resource.h" #include "resource.h"
@ -17,36 +16,33 @@
#include "misc.h" #include "misc.h"
// D�finitions globales // Global definitions
#define NAME "Blupi" #define NAME "Blupi"
#define TITLE "Blupi" #define TITLE "Blupi"
// Global variables
// Variables globales
SDL_Window *g_window; SDL_Window *g_window;
SDL_Renderer *g_renderer; SDL_Renderer *g_renderer;
CEvent *g_pEvent = nullptr; CEvent *g_pEvent = nullptr;
CPixmap *g_pPixmap = nullptr; // pixmap principal CPixmap *g_pPixmap = nullptr; // pixmap principal
CSound *g_pSound = nullptr; // sound principal CSound *g_pSound = nullptr; // sound principal
CMovie *g_pMovie = nullptr; // movie principal CMovie *g_pMovie = nullptr; // movie principal
CDecor *g_pDecor = nullptr; CDecor *g_pDecor = nullptr;
bool g_bFullScreen = false; // false si mode de test bool g_bFullScreen = false; // false si mode de test
Sint32 g_speedRate = 1; Sint32 g_speedRate = 1;
Sint32 g_timerInterval = 50; // inverval = 50ms Sint32 g_timerInterval = 50; // inverval = 50ms
Sint32 g_mouseType = MOUSETYPEGRA; Sint32 g_mouseType = MOUSETYPEGRA;
bool g_bActive = true; // is application active ? bool g_bActive = true; // is application active ?
bool g_bTermInit = false; // initialisation en cours bool g_bTermInit = false; // initialisation en cours
Uint32 g_lastPhase = 999; Uint32 g_lastPhase = 999;
// Lit un num�ro d�cimal. // Lit un num�ro d�cimal.
Sint32 GetNum (char *p) static Sint32 GetNum (char *p)
{ {
Sint32 n = 0; Sint32 n = 0;
@ -61,7 +57,7 @@ Sint32 GetNum (char *p)
// Lit le fichier de configuration. // Lit le fichier de configuration.
bool ReadConfig (Sint32 argc, char *argv[]) static bool ReadConfig ()
{ {
FILE *file = nullptr; FILE *file = nullptr;
char buffer[200]; char buffer[200];
@ -118,10 +114,9 @@ bool ReadConfig (Sint32 argc, char *argv[])
return true; return true;
} }
// Main frame update
// Mise � jour principale. static void UpdateFrame (void)
void UpdateFrame (void)
{ {
RECT clip, rcRect; RECT clip, rcRect;
Uint32 phase; Uint32 phase;
@ -218,46 +213,27 @@ void UpdateFrame (void)
} }
} }
// Restore the game after a fullscreen enabling
void Benchmark() static bool RestoreGame ()
{
Sint32 i;
POINT pos = { 0, 0 };
g_pPixmap->DrawIcon (-1, 2, 10, pos, 0);
pos.x = 300;
pos.y = 350;
for (i = 0 ; i < 10000 ; i++)
g_pPixmap->DrawIcon (-1, 2, i % 4, pos, 0);
g_pPixmap->DrawIcon (-1, 2, 10, pos, 0);
g_pSound->Play (0);
}
// Restitue le jeu apr�s une activation en mode fullScreen.
bool RestoreGame()
{ {
if (g_pPixmap == nullptr) if (g_pPixmap == nullptr)
return false; return false;
g_pEvent->RestoreGame(); g_pEvent->RestoreGame ();
return true; return true;
} }
// Lib�re le jeu avant une d�sactivation en mode fullScreen. // Flush the game before a fullscreen disabling
bool FlushGame() static bool FlushGame ()
{ {
if (g_pPixmap == nullptr) if (g_pPixmap == nullptr)
return false; return false;
return g_pPixmap->Flush(); return g_pPixmap->Flush ();
} }
// Finished with all objects we use; release them. // Finished with all objects we use; release them.
static void FinishObjects (void) static void FinishObjects (void)
@ -295,7 +271,7 @@ static void FinishObjects (void)
} }
} }
void WindowProc2 (const SDL_Event &event) static void WindowProc2 (const SDL_Event &event)
{ {
POINT totalDim, iconDim; POINT totalDim, iconDim;
@ -419,7 +395,7 @@ static bool DoInit (Sint32 argc, char *argv[])
RECT rcRect; RECT rcRect;
bool bOK; bool bOK;
bOK = ReadConfig (argc, argv); // lit le fichier config.ini bOK = ReadConfig (); // lit le fichier config.ini
auto res = SDL_Init (SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER); auto res = SDL_Init (SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER);
if (res < 0) if (res < 0)
@ -435,7 +411,7 @@ static bool DoInit (Sint32 argc, char *argv[])
if (!g_window) if (!g_window)
{ {
printf (SDL_GetError()); printf ("%s", SDL_GetError ());
return false; return false;
} }
@ -444,7 +420,7 @@ static bool DoInit (Sint32 argc, char *argv[])
SDL_RENDERER_PRESENTVSYNC); SDL_RENDERER_PRESENTVSYNC);
if (!g_renderer) if (!g_renderer)
{ {
printf (SDL_GetError()); printf ("%s", SDL_GetError ());
SDL_DestroyWindow (g_window); SDL_DestroyWindow (g_window);
return false; return false;
} }
@ -617,10 +593,9 @@ static bool DoInit (Sint32 argc, char *argv[])
return true; return true;
} }
// Programme principal. // Programme principal.
Sint32 main (Sint32 argc, char *argv[]) int main (int argc, char *argv[])
{ {
if (!DoInit (argc, argv)) if (!DoInit (argc, argv))
return -1; return -1;

View File

@ -1,3 +1,4 @@
#pragma once #pragma once
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
@ -30,8 +31,8 @@ typedef Uint32 WPARAM;
typedef Sint32 LPARAM; typedef Sint32 LPARAM;
#endif #endif
#define LOWORD(l) ((Uint16)(((Uint32)(l)) & 0xffff)) #define LOWORD(l) ((Uint16) (((Uint32) (l)) & 0xffff))
#define HIWORD(l) ((Uint16)((((Uint32)(l)) >> 16) & 0xffff)) #define HIWORD(l) ((Uint16) ((((Uint32) (l)) >> 16) & 0xffff))
#define MAX_PATH 260 #define MAX_PATH 260

View File

@ -1,8 +1,7 @@
// Button.cpp
//
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "gettext.h" #include "gettext.h"
#include "def.h" #include "def.h"
#include "pixmap.h" #include "pixmap.h"
@ -13,10 +12,6 @@
#include "event.h" #include "event.h"
/////////////////////////////////////////////////////////////////////////////
// Constructeur.
CButton::CButton() CButton::CButton()
{ {
m_type = 0; m_type = 0;
@ -33,12 +28,7 @@ CButton::CButton()
m_message = static_cast<Uint32> (-1); m_message = static_cast<Uint32> (-1);
} }
// Destructeur. CButton::~CButton () {}
CButton::~CButton()
{
}
// Crée un nouveau bouton. // Crée un nouveau bouton.
@ -134,7 +124,7 @@ bool CButton::Create (CPixmap *pPixmap, CSound *pSound,
// Dessine un bouton dans son état. // Dessine un bouton dans son état.
void CButton::Draw() void CButton::Draw ()
{ {
Sint32 i; Sint32 i;
POINT pos; POINT pos;
@ -182,12 +172,12 @@ void CButton::Draw()
} }
} }
void CButton::Redraw() void CButton::Redraw ()
{ {
m_bRedraw = true; m_bRedraw = true;
} }
Sint32 CButton::GetState() Sint32 CButton::GetState ()
{ {
return m_state; return m_state;
} }
@ -202,7 +192,7 @@ void CButton::SetState (Sint32 state)
m_mouseState = state; m_mouseState = state;
} }
Sint32 CButton::GetMenu() Sint32 CButton::GetMenu ()
{ {
return m_selMenu; return m_selMenu;
} }
@ -216,7 +206,7 @@ void CButton::SetMenu (Sint32 menu)
} }
bool CButton::GetEnable() bool CButton::GetEnable ()
{ {
return m_bEnable; return m_bEnable;
} }
@ -229,8 +219,7 @@ void CButton::SetEnable (bool bEnable)
m_bEnable = bEnable; m_bEnable = bEnable;
} }
bool CButton::GetHide ()
bool CButton::GetHide()
{ {
return m_bHide; return m_bHide;
} }
@ -243,7 +232,6 @@ void CButton::SetHide (bool bHide)
m_bHide = bHide; m_bHide = bHide;
} }
// Traitement d'un événement. // Traitement d'un événement.
bool CButton::TreatEvent (const SDL_Event &event) bool CButton::TreatEvent (const SDL_Event &event)
@ -292,7 +280,6 @@ bool CButton::TreatEvent (const SDL_Event &event)
// (*) Tous les boutons doivent recevoir l'événement BUTTONUP ! // (*) Tous les boutons doivent recevoir l'événement BUTTONUP !
// Indique si la souris est sur ce bouton. // Indique si la souris est sur ce bouton.
bool CButton::MouseOnButton (POINT pos) bool CButton::MouseOnButton (POINT pos)
@ -300,7 +287,6 @@ bool CButton::MouseOnButton (POINT pos)
return Detect (pos); return Detect (pos);
} }
// Retourne le tooltips pour un bouton, en fonction // Retourne le tooltips pour un bouton, en fonction
// de la position de la souris. // de la position de la souris.
@ -338,7 +324,6 @@ const char *CButton::GetToolTips (POINT pos)
return gettext (m_toolTips[rank]); return gettext (m_toolTips[rank]);
} }
// Détecte si la souris est dans le bouton. // Détecte si la souris est dans le bouton.
bool CButton::Detect (POINT pos) bool CButton::Detect (POINT pos)
@ -442,5 +427,3 @@ bool CButton::MouseUp (POINT pos)
return true; return true;
} }

View File

@ -1,11 +1,8 @@
// Button.h
#pragma once #pragma once
#include <vector> #include <vector>
/////////////////////////////////////////////////////////////////////////////
class CButton class CButton
{ {
public: public:
@ -34,6 +31,7 @@ public:
bool TreatEvent (const SDL_Event &event); bool TreatEvent (const SDL_Event &event);
bool MouseOnButton (POINT pos); bool MouseOnButton (POINT pos);
const char *GetToolTips (POINT pos); const char *GetToolTips (POINT pos);
@ -47,6 +45,7 @@ protected:
CPixmap *m_pPixmap; CPixmap *m_pPixmap;
CDecor *m_pDecor; CDecor *m_pDecor;
CSound *m_pSound; CSound *m_pSound;
Sint32 m_type; // type de bouton Sint32 m_type; // type de bouton
bool m_bEnable; // true si bouton actif bool m_bEnable; // true si bouton actif
bool m_bHide; // true si bouton caché bool m_bHide; // true si bouton caché
@ -56,13 +55,14 @@ protected:
Sint32 m_state; // 0=relâché, 1=pressé, +2=survollé Sint32 m_state; // 0=relâché, 1=pressé, +2=survollé
Sint32 m_mouseState; // 0=relâché, 1=pressé, +2=survollé Sint32 m_mouseState; // 0=relâché, 1=pressé, +2=survollé
Sint32 m_iconMenu[20]; // icônes du sous-menu Sint32 m_iconMenu[20]; // icônes du sous-menu
const char **m_toolTips; // info-bulles const char **m_toolTips; // info-bulles
Sint32 m_nbMenu; // nb de case du sous-menu Sint32 m_nbMenu; // nb de case du sous-menu
Sint32 m_nbToolTips; // nb d'info-bulles Sint32 m_nbToolTips; // nb d'info-bulles
Sint32 m_selMenu; // sous-menu sélectionné Sint32 m_selMenu; // sous-menu sélectionné
bool m_bMouseDown; // true -> bouton souris pressé
bool m_bMinimizeRedraw;
bool m_bRedraw; // true -> doit être redessiné
};
///////////////////////////////////////////////////////////////////////////// bool m_bMouseDown; // true -> bouton souris pressé
bool m_bRedraw; // true -> doit être redessiné
bool m_bMinimizeRedraw;
};

View File

@ -1,4 +1,3 @@
// chemin.cpp
// (c) 1997, Denis Dumoulin // (c) 1997, Denis Dumoulin
@ -56,7 +55,6 @@ bool CDecor::CheminTestPos (POINT pos, Sint32 &rank)
return false; return false;
} }
// une fois le but trouvé, reprend en arrière // une fois le but trouvé, reprend en arrière
// à la recherche du chemin le plus court // à la recherche du chemin le plus court
@ -100,7 +98,6 @@ bis:
} }
} }
// troisième méthode de recherche // troisième méthode de recherche
// semblable à la précédente, // semblable à la précédente,
// mais les points à explorer sont classés selon leur distance à la cible // mais les points à explorer sont classés selon leur distance à la cible
@ -179,7 +176,6 @@ void CDecor::CheminFillTerrain (Sint32 rank)
} }
} }
// routine déterninant si une direction est possible // routine déterninant si une direction est possible
// retourne l'incrément pour passer à la nouvelle case // retourne l'incrément pour passer à la nouvelle case
// et le "prix à payer" pour aller dans cette direction // et le "prix à payer" pour aller dans cette direction
@ -269,9 +265,8 @@ bool CDecor::CheminTestDirection (Sint32 rank, Sint32 pos, Sint32 dir,
return false; return false;
} }
// Retourne true si on a assigné une nouvelle direction à blupi. // Retourne true si on a assigné une nouvelle direction à blupi.
bool CDecor::CheminCherche (Sint32 rank, Sint32 &action) bool CDecor::CheminCherche (Sint32 rank, Sint32 &action)
{ {
Sint32 cout; // prix pour aller dans une direction Sint32 cout; // prix pour aller dans une direction
@ -310,7 +305,6 @@ bool CDecor::CheminCherche (Sint32 rank, Sint32 &action)
return false; return false;
} }
// Teste s'il est possible de se rendre à un endroit donné. // Teste s'il est possible de se rendre à un endroit donné.
bool CDecor::IsCheminFree (Sint32 rank, POINT dest, Sint32 button) bool CDecor::IsCheminFree (Sint32 rank, POINT dest, Sint32 button)
@ -365,4 +359,3 @@ bool CDecor::IsCheminFree (Sint32 rank, POINT dest, Sint32 button)
return bOK; return bOK;
} }

View File

@ -1,7 +1,6 @@
// DecBlupi.cpp
//
#include <unordered_map> #include <unordered_map>
#include "gettext.h" #include "gettext.h"
#include "def.h" #include "def.h"
#include "decor.h" #include "decor.h"
@ -12,7 +11,7 @@
// Cette table donne l'action à effectuer pour un bouton // Cette table donne l'action à effectuer pour un bouton
// enfoncé. // enfoncé.
Sint16 table_actions[] = const Sint16 table_actions[] =
{ {
WM_ACTION_GO, WM_ACTION_GO,
WM_ACTION_STOP, WM_ACTION_STOP,
@ -51,10 +50,6 @@ Sint16 table_actions[] =
WM_ACTION_FABARMURE, WM_ACTION_FABARMURE,
}; };
// Supprime tous les blupi. // Supprime tous les blupi.
void CDecor::BlupiFlush() void CDecor::BlupiFlush()
@ -290,8 +285,6 @@ void CDecor::BlupiKill (Sint32 exRank, POINT cel, Sint32 type)
} }
} }
// Test si un blupi existe. // Test si un blupi existe.
bool CDecor::BlupiIfExist (Sint32 rank) bool CDecor::BlupiIfExist (Sint32 rank)
@ -299,7 +292,6 @@ bool CDecor::BlupiIfExist (Sint32 rank)
return !!m_blupi[rank].bExist; return !!m_blupi[rank].bExist;
} }
// Triche pour tous les blupi. // Triche pour tous les blupi.
// #1 -> (POWER) redonne l'énergie maximale // #1 -> (POWER) redonne l'énergie maximale
// #2 -> (LONESOME) tue toutes les araignées/virus/etc. // #2 -> (LONESOME) tue toutes les araignées/virus/etc.
@ -330,7 +322,6 @@ void CDecor::BlupiCheat (Sint32 cheat)
} }
} }
// Actualise un blupi pour pouvoir le dessiner dans son état. // Actualise un blupi pour pouvoir le dessiner dans son état.
void CDecor::BlupiActualise (Sint32 rank) void CDecor::BlupiActualise (Sint32 rank)
@ -444,7 +435,6 @@ void CDecor::BlupiAdaptIcon (Sint32 rank)
} }
} }
// Fait entendre un son pour un blupi. // Fait entendre un son pour un blupi.
// Si bStop=true, on stoppe le son précédent associé // Si bStop=true, on stoppe le son précédent associé
// à ce blupi (rank), si nécessaire. // à ce blupi (rank), si nécessaire.
@ -513,7 +503,7 @@ void CDecor::BlupiSound (Sint32 rank, Sint32 sound, POINT pos, bool bStop)
// Sons associés à des actions. // Sons associés à des actions.
static Sint16 tableSound[] = static const Sint16 tableSound[] =
{ {
ACTION_BRULE, SOUND_BRULE, ACTION_BRULE, SOUND_BRULE,
ACTION_TCHAO, SOUND_TCHAO, ACTION_TCHAO, SOUND_TCHAO,
@ -528,7 +518,7 @@ static Sint16 tableSound[] =
void CDecor::BlupiInitAction (Sint32 rank, Sint32 action, Sint32 direct) void CDecor::BlupiInitAction (Sint32 rank, Sint32 action, Sint32 direct)
{ {
Sint16 *pTable = tableSound; const auto *pTable = tableSound;
POINT pos; POINT pos;
Sint32 rand; Sint32 rand;
@ -809,6 +799,7 @@ void CDecor::BlupiChangeAction (Sint32 rank, Sint32 action, Sint32 direct)
{ {
if (rank < 0) if (rank < 0)
return; return;
BlupiInitAction (rank, action, direct); BlupiInitAction (rank, action, direct);
BlupiDestCel (rank); BlupiDestCel (rank);
m_blupi[rank].phase = 0; m_blupi[rank].phase = 0;
@ -817,8 +808,6 @@ void CDecor::BlupiChangeAction (Sint32 rank, Sint32 action, Sint32 direct)
BlupiNextAction (rank); BlupiNextAction (rank);
} }
// Vide la liste des actions. // Vide la liste des actions.
void CDecor::ListFlush (Sint32 rank) void CDecor::ListFlush (Sint32 rank)
@ -1186,8 +1175,6 @@ ok:
return true; return true;
} }
// Démarre une action. // Démarre une action.
void CDecor::GoalStart (Sint32 rank, Sint32 action, POINT cel) void CDecor::GoalStart (Sint32 rank, Sint32 action, POINT cel)
@ -2268,7 +2255,6 @@ void CDecor::GoalStop (Sint32 rank, bool bError, bool bSound)
} }
} }
// Teste si une cellule est déjà utilisée comme but pour // Teste si une cellule est déjà utilisée comme but pour
// n'importe quel blupi. // n'importe quel blupi.
@ -2287,7 +2273,6 @@ bool CDecor::BlupiIsGoalUsed (POINT cel)
return false; return false;
} }
// Démarre ou stoppe un rayon entre deux tours. // Démarre ou stoppe un rayon entre deux tours.
void CDecor::BlupiStartStopRayon (Sint32 rank, POINT startCel, POINT endCel) void CDecor::BlupiStartStopRayon (Sint32 rank, POINT startCel, POINT endCel)
@ -2362,7 +2347,6 @@ void CDecor::BlupiStartStopRayon (Sint32 rank, POINT startCel, POINT endCel)
} }
} }
// Tourne un blupi, si nécessaire. // Tourne un blupi, si nécessaire.
// Retourne false si ce n'est pas nécessaire. // Retourne false si ce n'est pas nécessaire.
@ -3254,7 +3238,6 @@ void CDecor::BlupiStep (bool bFirst)
m_time ++; // avance le temps absolu global m_time ++; // avance le temps absolu global
} }
// Retourne le rectangle occupé par un blupi, // Retourne le rectangle occupé par un blupi,
// pour les sélections (pas exact). // pour les sélections (pas exact).
@ -3276,7 +3259,6 @@ void CDecor::BlupiGetRect (Sint32 rank, RECT &rect)
Sint32 CDecor::GetTargetBlupi (POINT pos) Sint32 CDecor::GetTargetBlupi (POINT pos)
{ {
#if 1
Sint32 rank, found, prof; Sint32 rank, found, prof;
POINT test, rel, cel; POINT test, rel, cel;
@ -3321,65 +3303,11 @@ Sint32 CDecor::GetTargetBlupi (POINT pos)
} }
return found; return found;
#else
Sint32 rank, found, prof;
RECT rect;
POINT cel;
found = -1;
prof = 0;
for (rank = 0 ; rank < MAXBLUPI ; rank++)
{
if (m_blupi[rank].bExist &&
(m_blupi[rank].perso == 0 || // blupi ?
m_blupi[rank].perso == 8)) // disciple ?
{
BlupiGetRect (rank, rect);
if (pos.x >= rect.left &&
pos.x <= rect.right &&
pos.y >= rect.top &&
pos.y <= rect.bottom)
{
if (found != -1 &&
rect.top < prof)
continue;
found = rank;
prof = rect.top;
}
}
}
if (found != -1)
return found;
cel = ConvPosToCel (pos);
for (rank = 0 ; rank < MAXBLUPI ; rank++)
{
if (m_blupi[rank].bExist &&
(m_blupi[rank].perso == 0 || // blupi ?
m_blupi[rank].perso == 8)) // disciple ?
{
if (cel.x == m_blupi[rank].cel.x &&
cel.y == m_blupi[rank].cel.y)
return rank;
if (cel.x == m_blupi[rank].destCel.x &&
cel.y == m_blupi[rank].destCel.y)
return rank;
}
}
return -1;
#endif
} }
// Déslectionne tous les blupi. // Déslectionne tous les blupi.
void CDecor::BlupiDeselect() void CDecor::BlupiDeselect ()
{ {
Sint32 rank; Sint32 rank;
@ -3465,19 +3393,19 @@ void CDecor::BlupiHiliDown (POINT pos, bool bAdd)
// Sélectionne un blupi lorsque la souris est déplacée. // Sélectionne un blupi lorsque la souris est déplacée.
void CDecor::BlupiHiliMove (POINT pos, bool bAdd) void CDecor::BlupiHiliMove (POINT pos)
{ {
if (m_bHiliRect) // rectangle de sélection existe ? if (m_bHiliRect) // rectangle de sélection existe ?
{ {
m_p2Hili = ConvPosToCel (pos); m_p2Hili = ConvPosToCel (pos);
InitOutlineRect(); InitOutlineRect ();
} }
} }
// Sélectionne un blupi lorsque le bouton est relâché. // Sélectionne un blupi lorsque le bouton est relâché.
// Retourne false si la sélection n'a pas changé ! // Retourne false si la sélection n'a pas changé !
void CDecor::BlupiHiliUp (POINT pos, bool bAdd) void CDecor::BlupiHiliUp (POINT pos)
{ {
Sint32 rank, r, nb, sound; Sint32 rank, r, nb, sound;
bool bEnerve = false; bool bEnerve = false;
@ -3613,7 +3541,7 @@ void CDecor::BlupiHiliUp (POINT pos, bool bAdd)
// Dessine le rectangle de sélection, si nécessaire. // Dessine le rectangle de sélection, si nécessaire.
void CDecor::BlupiDrawHili() void CDecor::BlupiDrawHili ()
{ {
POINT c1, c2, cc; POINT c1, c2, cc;
POINT p1, p2, p3, p4; POINT p1, p2, p3, p4;
@ -3761,7 +3689,6 @@ void CDecor::BlupiDrawHili()
m_shiftHili += 3; m_shiftHili += 3;
} }
// Retourne le bouton par défaut à un endroit donné. // Retourne le bouton par défaut à un endroit donné.
// Est utilisé pour trouver que faire lors d'un clic // Est utilisé pour trouver que faire lors d'un clic
// avec le bouton de droite. // avec le bouton de droite.
@ -3780,6 +3707,7 @@ Sint32 CDecor::GetDefButton (POINT cel)
return -1; return -1;
if (m_nbBlupiHili > 1) if (m_nbBlupiHili > 1)
return BUTTON_GO; return BUTTON_GO;
rank = m_rankBlupiHili; rank = m_rankBlupiHili;
button = BUTTON_GO; button = BUTTON_GO;

View File

@ -285,8 +285,8 @@ public:
void BlupiSetArrow (Sint32 rank, bool bArrow); void BlupiSetArrow (Sint32 rank, bool bArrow);
void InitOutlineRect(); void InitOutlineRect();
void BlupiHiliDown (POINT pos, bool bAdd = false); void BlupiHiliDown (POINT pos, bool bAdd = false);
void BlupiHiliMove (POINT pos, bool bAdd = false); void BlupiHiliMove (POINT pos);
void BlupiHiliUp (POINT pos, bool bAdd = false); void BlupiHiliUp (POINT pos);
void BlupiDrawHili(); void BlupiDrawHili();
Sint32 GetDefButton (POINT cel); Sint32 GetDefButton (POINT cel);
bool BlupiGoal (Sint32 rank, Sint32 button, POINT cel, POINT cMem); bool BlupiGoal (Sint32 rank, Sint32 button, POINT cel, POINT cMem);
@ -550,4 +550,4 @@ POINT GetCel (POINT cel, Sint32 x, Sint32 y);
bool IsValid (POINT cel); bool IsValid (POINT cel);
POINT GetVector (Sint32 direct); POINT GetVector (Sint32 direct);
extern Sint32 table_multi_goal[]; extern Sint32 table_multi_goal[];
extern Sint16 table_actions[]; extern const Sint16 table_actions[];

View File

@ -3367,7 +3367,7 @@ bool CEvent::PlayMove (POINT pos, Uint16 mod)
if (m_bMouseDown) // bouton souris pressé ? if (m_bMouseDown) // bouton souris pressé ?
{ {
if (m_bHili) if (m_bHili)
m_pDecor->BlupiHiliMove (pos, !! (mod & KMOD_SHIFT)); m_pDecor->BlupiHiliMove (pos);
else else
m_pDecor->CelHili (pos, 0); m_pDecor->CelHili (pos, 0);
} }
@ -3393,7 +3393,7 @@ bool CEvent::PlayUp (POINT pos, Uint16 mod)
if (m_bMouseDown) // bouton souris pressé ? if (m_bMouseDown) // bouton souris pressé ?
{ {
if (m_bHili) if (m_bHili)
m_pDecor->BlupiHiliUp (pos, !! (mod & KMOD_SHIFT)); m_pDecor->BlupiHiliUp (pos);
else else
{ {
m_pDecor->BlupiGetButtons (pos, m_menuNb, m_menuButtons, m_pDecor->BlupiGetButtons (pos, m_menuNb, m_menuButtons,