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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,10 @@
#pragma once
#include <SDL2/SDL.h>
#include <libintl.h>
extern SDL_Window *g_window;
extern SDL_Window *g_window;
extern SDL_Renderer *g_renderer;
struct POINT
@ -30,21 +31,21 @@ typedef Uint32 WPARAM;
typedef Sint32 LPARAM;
#endif
#define LOWORD(l) ((Uint16)(((Uint32)(l)) & 0xffff))
#define HIWORD(l) ((Uint16)((((Uint32)(l)) >> 16) & 0xffff))
#define LOWORD(l) ((Uint16) (((Uint32) (l)) & 0xffff))
#define HIWORD(l) ((Uint16) ((((Uint32) (l)) >> 16) & 0xffff))
#define MAX_PATH 260
#define VK_END 0x23
#define VK_LEFT 0x25
#define VK_UP 0x26
#define VK_RIGHT 0x27
#define VK_DOWN 0x28
#define VK_END 0x23
#define VK_LEFT 0x25
#define VK_UP 0x26
#define VK_RIGHT 0x27
#define VK_DOWN 0x28
#define WM_KEYDOWN 0x0100
#define WM_KEYUP 0x0101
#define WM_MOUSEMOVE 0x0200
#define WM_LBUTTONDOWN 0x0201
#define WM_LBUTTONUP 0x0202
#define WM_RBUTTONDOWN 0x0204
#define WM_RBUTTONUP 0x0205
#define WM_KEYDOWN 0x0100
#define WM_KEYUP 0x0101
#define WM_MOUSEMOVE 0x0200
#define WM_LBUTTONDOWN 0x0201
#define WM_LBUTTONUP 0x0202
#define WM_RBUTTONDOWN 0x0204
#define WM_RBUTTONUP 0x0205

View File

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

View File

@ -1,39 +1,37 @@
// Button.h
#pragma once
#include <vector>
/////////////////////////////////////////////////////////////////////////////
class CButton
{
public:
CButton();
~CButton();
bool Create (CPixmap *pPixmap, CSound *pSound,
POINT pos, Sint32 type, bool bMinimizeRedraw,
Sint32 *pMenu, Sint32 nbMenu,
const char **pToolTips,
Sint32 region, Uint32 message);
void Draw();
void Redraw();
bool Create (CPixmap *pPixmap, CSound *pSound,
POINT pos, Sint32 type, bool bMinimizeRedraw,
Sint32 *pMenu, Sint32 nbMenu,
const char **pToolTips,
Sint32 region, Uint32 message);
void Draw();
void Redraw();
Sint32 GetState();
void SetState (Sint32 state);
Sint32 GetState();
void SetState (Sint32 state);
Sint32 GetMenu();
void SetMenu (Sint32 menu);
Sint32 GetMenu();
void SetMenu (Sint32 menu);
bool GetEnable();
void SetEnable (bool bEnable);
bool GetEnable();
void SetEnable (bool bEnable);
bool GetHide();
void SetHide (bool bHide);
bool GetHide();
void SetHide (bool bHide);
bool TreatEvent (const SDL_Event &event);
bool MouseOnButton (POINT pos);
bool TreatEvent (const SDL_Event &event);
bool MouseOnButton (POINT pos);
const char *GetToolTips (POINT pos);
@ -44,25 +42,27 @@ protected:
bool MouseUp (POINT pos);
protected:
CPixmap *m_pPixmap;
CDecor *m_pDecor;
CSound *m_pSound;
Sint32 m_type; // type de bouton
bool m_bEnable; // true si bouton actif
bool m_bHide; // true si bouton caché
Uint32 m_message; // message envoyé si bouton actionné
POINT m_pos; // coin sup/gauche
POINT m_dim; // dimensions
Sint32 m_state; // 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
const char **m_toolTips; // info-bulles
Sint32 m_nbMenu; // nb de case du sous-menu
Sint32 m_nbToolTips; // nb d'info-bulles
Sint32 m_selMenu; // sous-menu sélectionné
bool m_bMouseDown; // true -> bouton souris pressé
bool m_bMinimizeRedraw;
bool m_bRedraw; // true -> doit être redessiné
};
CPixmap *m_pPixmap;
CDecor *m_pDecor;
CSound *m_pSound;
/////////////////////////////////////////////////////////////////////////////
Sint32 m_type; // type de bouton
bool m_bEnable; // true si bouton actif
bool m_bHide; // true si bouton caché
Uint32 m_message; // message envoyé si bouton actionné
POINT m_pos; // coin sup/gauche
POINT m_dim; // dimensions
Sint32 m_state; // 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
const char **m_toolTips; // info-bulles
Sint32 m_nbMenu; // nb de case du sous-menu
Sint32 m_nbToolTips; // nb d'info-bulles
Sint32 m_selMenu; // sous-menu sélectionné
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
@ -56,7 +55,6 @@ bool CDecor::CheminTestPos (POINT pos, Sint32 &rank)
return false;
}
// une fois le but trouvé, reprend en arrière
// à la recherche du chemin le plus court
@ -100,17 +98,16 @@ bis:
}
}
// troisième méthode de recherche
// semblable à la précédente,
// mais les points à explorer sont classés selon leur distance à la cible
void CDecor::CheminFillTerrain (Sint32 rank)
{
Sint32 pos, last, dest, dist;
Sint32 step, dir, cout, action, max, next, ampli;
Sint32 dx, dy;
Sint32 but = 1000;
Sint32 pos, last, dest, dist;
Sint32 step, dir, cout, action, max, next, ampli;
Sint32 dx, dy;
Sint32 but = 1000;
if (m_blupi[rank].cel.x == m_blupi[rank].goalCel.x &&
m_blupi[rank].cel.y == m_blupi[rank].goalCel.y)
@ -179,7 +176,6 @@ void CDecor::CheminFillTerrain (Sint32 rank)
}
}
// routine déterninant si une direction est possible
// retourne l'incrément pour passer à la nouvelle case
// et le "prix à payer" pour aller dans cette direction
@ -189,9 +185,9 @@ bool CDecor::CheminTestDirection (Sint32 rank, Sint32 pos, Sint32 dir,
Sint32 &next, Sint32 &ampli,
Sint32 &cout, Sint32 &action)
{
POINT cel, vector, newCel;
bool bFree;
Sint32 tryDirect, workBlupi, rankHere;
POINT cel, vector, newCel;
bool bFree;
Sint32 tryDirect, workBlupi, rankHere;
cel.x = pos % MAXCELX;
cel.y = pos / MAXCELX;
@ -269,9 +265,8 @@ bool CDecor::CheminTestDirection (Sint32 rank, Sint32 pos, Sint32 dir,
return false;
}
// Retourne true si on a assigné une nouvelle direction à blupi.
bool CDecor::CheminCherche (Sint32 rank, Sint32 &action)
{
Sint32 cout; // prix pour aller dans une direction
@ -310,14 +305,13 @@ bool CDecor::CheminCherche (Sint32 rank, Sint32 &action)
return false;
}
// Teste s'il est possible de se rendre à un endroit donné.
bool CDecor::IsCheminFree (Sint32 rank, POINT dest, Sint32 button)
{
Sint32 action, sDirect;
POINT goalCel, passCel, limit;
bool bOK;
Sint32 action, sDirect;
POINT goalCel, passCel, limit;
bool bOK;
if (button == BUTTON_STOP)
return true;
@ -365,4 +359,3 @@ bool CDecor::IsCheminFree (Sint32 rank, POINT dest, Sint32 button)
return bOK;
}

View File

@ -1,7 +1,6 @@
// DecBlupi.cpp
//
#include <unordered_map>
#include "gettext.h"
#include "def.h"
#include "decor.h"
@ -12,7 +11,7 @@
// Cette table donne l'action à effectuer pour un bouton
// enfoncé.
Sint16 table_actions[] =
const Sint16 table_actions[] =
{
WM_ACTION_GO,
WM_ACTION_STOP,
@ -51,15 +50,11 @@ Sint16 table_actions[] =
WM_ACTION_FABARMURE,
};
// Supprime tous les blupi.
void CDecor::BlupiFlush()
{
Sint32 i;
Sint32 i;
memset (m_blupi, 0, sizeof (Blupi)*MAXBLUPI);
@ -72,7 +67,7 @@ void CDecor::BlupiFlush()
Sint32 CDecor::BlupiCreate (POINT cel, Sint32 action, Sint32 direct,
Sint32 perso, Sint32 energy)
{
Sint32 rank;
Sint32 rank;
if (perso == 0 && action == ACTION_STOP && // blupi ?
energy <= MAXENERGY / 4)
@ -173,7 +168,7 @@ Sint32 CDecor::BlupiCreate (POINT cel, Sint32 action, Sint32 direct,
bool CDecor::BlupiDelete (POINT cel, Sint32 perso)
{
Sint32 rank;
Sint32 rank;
for (rank = 0 ; rank < MAXBLUPI ; rank++)
{
@ -225,7 +220,7 @@ void CDecor::BlupiDelete (Sint32 rank)
void CDecor::BlupiKill (Sint32 exRank, POINT cel, Sint32 type)
{
Sint32 rank, action, x, y, icon;
Sint32 rank, action, x, y, icon;
for (rank = 0 ; rank < MAXBLUPI ; rank++)
{
@ -290,8 +285,6 @@ void CDecor::BlupiKill (Sint32 exRank, POINT cel, Sint32 type)
}
}
// Test si un blupi existe.
bool CDecor::BlupiIfExist (Sint32 rank)
@ -299,7 +292,6 @@ bool CDecor::BlupiIfExist (Sint32 rank)
return !!m_blupi[rank].bExist;
}
// Triche pour tous les blupi.
// #1 -> (POWER) redonne l'énergie maximale
// #2 -> (LONESOME) tue toutes les araignées/virus/etc.
@ -330,12 +322,11 @@ void CDecor::BlupiCheat (Sint32 cheat)
}
}
// Actualise un blupi pour pouvoir le dessiner dans son état.
void CDecor::BlupiActualise (Sint32 rank)
{
Sint16 sound;
Sint16 sound;
Action (m_blupi[rank].action,
m_blupi[rank].aDirect,
@ -359,7 +350,7 @@ void CDecor::BlupiActualise (Sint32 rank)
void CDecor::BlupiAdaptIcon (Sint32 rank)
{
Sint32 direct;
Sint32 direct;
if (m_blupi[rank].icon == -1)
return;
@ -444,14 +435,13 @@ void CDecor::BlupiAdaptIcon (Sint32 rank)
}
}
// Fait entendre un son pour un blupi.
// Si bStop=true, on stoppe le son précédent associé
// à ce blupi (rank), si nécessaire.
void CDecor::BlupiSound (Sint32 rank, Sint32 sound, POINT pos, bool bStop)
{
Sint32 newSound;
Sint32 newSound;
if (rank == -1)
rank = m_rankBlupiHili;
@ -513,7 +503,7 @@ void CDecor::BlupiSound (Sint32 rank, Sint32 sound, POINT pos, bool bStop)
// Sons associés à des actions.
static Sint16 tableSound[] =
static const Sint16 tableSound[] =
{
ACTION_BRULE, SOUND_BRULE,
ACTION_TCHAO, SOUND_TCHAO,
@ -528,9 +518,9 @@ static Sint16 tableSound[] =
void CDecor::BlupiInitAction (Sint32 rank, Sint32 action, Sint32 direct)
{
Sint16 *pTable = tableSound;
POINT pos;
Sint32 rand;
const auto *pTable = tableSound;
POINT pos;
Sint32 rand;
while (*pTable != -1)
{
@ -809,6 +799,7 @@ void CDecor::BlupiChangeAction (Sint32 rank, Sint32 action, Sint32 direct)
{
if (rank < 0)
return;
BlupiInitAction (rank, action, direct);
BlupiDestCel (rank);
m_blupi[rank].phase = 0;
@ -817,13 +808,11 @@ void CDecor::BlupiChangeAction (Sint32 rank, Sint32 action, Sint32 direct)
BlupiNextAction (rank);
}
// Vide la liste des actions.
void CDecor::ListFlush (Sint32 rank)
{
Sint32 i;
Sint32 i;
for (i = 0 ; i < MAXLIST ; i++)
m_blupi[rank].listButton[i] = -1;
@ -860,7 +849,7 @@ Sint32 CDecor::ListGetParam (Sint32 rank, Sint32 button, POINT cel)
bool CDecor::ListPut (Sint32 rank, Sint32 button, POINT cel, POINT cMem)
{
Sint32 i, last;
Sint32 i, last;
if (button == BUTTON_REPEAT ||
button == BUTTON_GO)
@ -903,7 +892,7 @@ bool CDecor::ListPut (Sint32 rank, Sint32 button, POINT cel, POINT cMem)
void CDecor::ListRemove (Sint32 rank)
{
Sint32 i;
Sint32 i;
if (m_blupi[rank].listButton[0] == BUTTON_CULTIVE)
return;
@ -925,7 +914,7 @@ void CDecor::ListRemove (Sint32 rank)
Sint32 CDecor::ListSearch (Sint32 rank, Sint32 button, POINT cel,
const char *&textForButton)
{
Sint32 i, j, param, nb;
Sint32 i, j, param, nb;
static const char *errors[] = {
/* 0 */ translate ("1: Grow tomatoes\n2: Eat"),
@ -1031,8 +1020,8 @@ next:
bool CDecor::RepeatAdjust (Sint32 rank, Sint32 button,
POINT &cel, POINT &cMem, Sint32 param, Sint32 list)
{
Sint32 i, channel, icon, icon1, icon2, flags;
POINT test;
Sint32 i, channel, icon, icon1, icon2, flags;
POINT test;
static Sint32 table_object[] =
{
@ -1186,8 +1175,6 @@ ok:
return true;
}
// Démarre une action.
void CDecor::GoalStart (Sint32 rank, Sint32 action, POINT cel)
@ -1208,7 +1195,7 @@ void CDecor::GoalStart (Sint32 rank, Sint32 action, POINT cel)
bool CDecor::GoalNextPhase (Sint32 rank)
{
Sint16 *pTable;
Sint32 i, nb;
Sint32 i, nb;
if (m_blupi[rank].goalAction == 0)
return false;
@ -2186,7 +2173,7 @@ error:
void CDecor::GoalUnwork (Sint32 rank)
{
Sint32 x, y;
Sint32 x, y;
for (x = 0 ; x < MAXCELX / 2 ; x++)
{
@ -2204,7 +2191,7 @@ void CDecor::GoalUnwork (Sint32 rank)
void CDecor::GoalStop (Sint32 rank, bool bError, bool bSound)
{
POINT pos;
POINT pos;
static Sint32 table_sound_term[6] =
{
@ -2268,13 +2255,12 @@ void CDecor::GoalStop (Sint32 rank, bool bError, bool bSound)
}
}
// Teste si une cellule est déjà utilisée comme but pour
// n'importe quel blupi.
bool CDecor::BlupiIsGoalUsed (POINT cel)
{
Sint32 rank;
Sint32 rank;
for (rank = 0 ; rank < MAXBLUPI ; rank++)
{
@ -2287,15 +2273,14 @@ bool CDecor::BlupiIsGoalUsed (POINT cel)
return false;
}
// Démarre ou stoppe un rayon entre deux tours.
void CDecor::BlupiStartStopRayon (Sint32 rank, POINT startCel, POINT endCel)
{
Sint32 i, icon, icon2;
POINT cel, cel2, vector, pos;
Sint32 i, icon, icon2;
POINT cel, cel2, vector, pos;
if (m_blupi[rank].perso == 1 || // araignée ?
if (m_blupi[rank].perso == 1 || // araignée ?
m_blupi[rank].perso == 2) // virus ?
return;
@ -2362,13 +2347,12 @@ void CDecor::BlupiStartStopRayon (Sint32 rank, POINT startCel, POINT endCel)
}
}
// Tourne un blupi, si nécessaire.
// Retourne false si ce n'est pas nécessaire.
bool CDecor::BlupiRotate (Sint32 rank)
{
Sint32 aDirect, sDirect, ip, in, sens;
Sint32 aDirect, sDirect, ip, in, sens;
bool bOK;
POINT pos;
@ -3231,7 +3215,7 @@ void CDecor::BlupiDestCel (Sint32 rank)
void CDecor::BlupiStep (bool bFirst)
{
Sint32 rank;
Sint32 rank;
for (rank = 0 ; rank < MAXBLUPI ; rank++)
{
@ -3254,7 +3238,6 @@ void CDecor::BlupiStep (bool bFirst)
m_time ++; // avance le temps absolu global
}
// Retourne le rectangle occupé par un blupi,
// pour les sélections (pas exact).
@ -3276,7 +3259,6 @@ void CDecor::BlupiGetRect (Sint32 rank, RECT &rect)
Sint32 CDecor::GetTargetBlupi (POINT pos)
{
#if 1
Sint32 rank, found, prof;
POINT test, rel, cel;
@ -3321,67 +3303,13 @@ Sint32 CDecor::GetTargetBlupi (POINT pos)
}
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.
void CDecor::BlupiDeselect()
void CDecor::BlupiDeselect ()
{
Sint32 rank;
Sint32 rank;
for (rank = 0 ; rank < MAXBLUPI ; rank++)
{
@ -3465,19 +3393,19 @@ void CDecor::BlupiHiliDown (POINT pos, bool bAdd)
// 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 ?
{
m_p2Hili = ConvPosToCel (pos);
InitOutlineRect();
InitOutlineRect ();
}
}
// Sélectionne un blupi lorsque le bouton est relâché.
// 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;
bool bEnerve = false;
@ -3613,13 +3541,13 @@ void CDecor::BlupiHiliUp (POINT pos, bool bAdd)
// Dessine le rectangle de sélection, si nécessaire.
void CDecor::BlupiDrawHili()
void CDecor::BlupiDrawHili ()
{
POINT c1, c2, cc;
POINT p1, p2, p3, p4;
POINT start, pos;
RECT rect;
Sint32 shift;
POINT c1, c2, cc;
POINT p1, p2, p3, p4;
POINT start, pos;
RECT rect;
Sint32 shift;
if (!m_bHiliRect)
return;
@ -3761,15 +3689,14 @@ void CDecor::BlupiDrawHili()
m_shiftHili += 3;
}
// Retourne le bouton par défaut à un endroit donné.
// Est utilisé pour trouver que faire lors d'un clic
// avec le bouton de droite.
Sint32 CDecor::GetDefButton (POINT cel)
{
Sint32 button, rank, channel, icon;
POINT iCel;
Sint32 button, rank, channel, icon;
POINT iCel;
iCel = cel;
cel.x = (cel.x / 2) * 2;
@ -3780,6 +3707,7 @@ Sint32 CDecor::GetDefButton (POINT cel)
return -1;
if (m_nbBlupiHili > 1)
return BUTTON_GO;
rank = m_rankBlupiHili;
button = BUTTON_GO;
@ -3870,9 +3798,9 @@ Sint32 CDecor::GetDefButton (POINT cel)
bool CDecor::BlupiGoal (Sint32 rank, Sint32 button, POINT cel, POINT cMem)
{
POINT goalHili, goalHili2, goal, test;
Sint32 i, action, channel, icon, error, direct, step;
bool bRepeat = false;
POINT goalHili, goalHili2, goal, test;
Sint32 i, action, channel, icon, error, direct, step;
bool bRepeat = false;
// Si plusieurs blupi sont sélectionnés, ils ne vont pas
// tous à la même destination.

View File

@ -285,8 +285,8 @@ public:
void BlupiSetArrow (Sint32 rank, bool bArrow);
void InitOutlineRect();
void BlupiHiliDown (POINT pos, bool bAdd = false);
void BlupiHiliMove (POINT pos, bool bAdd = false);
void BlupiHiliUp (POINT pos, bool bAdd = false);
void BlupiHiliMove (POINT pos);
void BlupiHiliUp (POINT pos);
void BlupiDrawHili();
Sint32 GetDefButton (POINT cel);
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);
POINT GetVector (Sint32 direct);
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_bHili)
m_pDecor->BlupiHiliMove (pos, !! (mod & KMOD_SHIFT));
m_pDecor->BlupiHiliMove (pos);
else
m_pDecor->CelHili (pos, 0);
}
@ -3393,7 +3393,7 @@ bool CEvent::PlayUp (POINT pos, Uint16 mod)
if (m_bMouseDown) // bouton souris pressé ?
{
if (m_bHili)
m_pDecor->BlupiHiliUp (pos, !! (mod & KMOD_SHIFT));
m_pDecor->BlupiHiliUp (pos);
else
{
m_pDecor->BlupiGetButtons (pos, m_menuNb, m_menuButtons,