diff options
| author | Eugene Sandulenko | 2018-05-26 20:55:34 +0200 | 
|---|---|---|
| committer | Eugene Sandulenko | 2019-11-13 22:07:08 +0100 | 
| commit | c8769b384601c0e6d14b43f36887cbf8d2bd595a (patch) | |
| tree | 2ace2a85735ef82f035077d0bf818d2580d4e097 | |
| parent | f73cd4e57a2c17137aec378f8769a8bca010f3dc (diff) | |
| download | scummvm-rg350-c8769b384601c0e6d14b43f36887cbf8d2bd595a.tar.gz scummvm-rg350-c8769b384601c0e6d14b43f36887cbf8d2bd595a.tar.bz2 scummvm-rg350-c8769b384601c0e6d14b43f36887cbf8d2bd595a.zip  | |
GRIFFON: Added namespaces and include guards
| -rw-r--r-- | engines/griffon/config.cpp | 11 | ||||
| -rw-r--r-- | engines/griffon/config.h | 10 | ||||
| -rw-r--r-- | engines/griffon/engine.cpp | 19 | ||||
| -rw-r--r-- | engines/griffon/engine.h | 10 | ||||
| -rw-r--r-- | engines/griffon/state.cpp | 540 | ||||
| -rw-r--r-- | engines/griffon/state.h | 10 | 
6 files changed, 299 insertions, 301 deletions
diff --git a/engines/griffon/config.cpp b/engines/griffon/config.cpp index 8a53b4b787..aa57429a89 100644 --- a/engines/griffon/config.cpp +++ b/engines/griffon/config.cpp @@ -34,15 +34,10 @@   *   */ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <math.h> -#include <sys/stat.h> -#include <SDL/SDL.h> +#include "griffon/config.h" -#include "config.h" +namespace Griffon {  CONFIG config = {  	320, 240, 16, 0, 0, 0, 1, 127, 1, 127 @@ -138,3 +133,5 @@ void config_save(CONFIG *config) {  		fclose(fp);  	}  } + +} // end of namespace Griffon diff --git a/engines/griffon/config.h b/engines/griffon/config.h index 3ff469ff9d..776591837f 100644 --- a/engines/griffon/config.h +++ b/engines/griffon/config.h @@ -34,8 +34,10 @@   *   */ -#ifndef _CONFIG_H_ -#define _CONFIG_H_ +#ifndef GRIFFON_CONFIG_H +#define GRIFFON_CONFIG_H + +namespace Griffon {  typedef struct {  	int scr_width; @@ -56,4 +58,6 @@ extern char config_ini[];  void config_load(CONFIG *config);  void config_save(CONFIG *config); -#endif // _CONFIG_H_ +} // end of namespace Griffon + +#endif diff --git a/engines/griffon/engine.cpp b/engines/griffon/engine.cpp index cc913cb6e4..188fb34b99 100644 --- a/engines/griffon/engine.cpp +++ b/engines/griffon/engine.cpp @@ -34,20 +34,11 @@   *   */ -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <math.h> -#include <sys/stat.h> +#include "griffon/griffon.h" +#include "griffon/config.h" +#include "griffon/state.h" -#include <SDL/SDL.h> -#include <SDL/SDL_image.h> -#include <SDL/SDL_mixer.h> -#include <SDL/SDL_rotozoom.h> - -#include "griffon.h" -#include "config.h" -#include "state.h" +namespace Griffon {  // memo  /* @@ -8204,3 +8195,5 @@ void sys_update() {  	for (int i = 0; i <= 4; i++)  		if (player.inventory[i] > 9) player.inventory[i] = 9;  } + +} // end of namespace Griffon diff --git a/engines/griffon/engine.h b/engines/griffon/engine.h index e76e08857e..1599866ff9 100644 --- a/engines/griffon/engine.h +++ b/engines/griffon/engine.h @@ -34,8 +34,10 @@   *   */ -#ifndef _GRIFFON_H_ -#define _GRIFFON_H_ +#ifndef GRIFFON_ENGINE_H +#define GRIFFON_ENGINE_H + +namespace Griffon {  #define MAXNPC      32  #define MAXFLOAT    32 @@ -270,4 +272,6 @@ void sys_LoadObjectDB();  void sys_setupAudio();  void sys_update(); -#endif // _GRIFFON_H_ +} // end of namespace Griffon + +#endif diff --git a/engines/griffon/state.cpp b/engines/griffon/state.cpp index 372a454e00..a1ec297ecf 100644 --- a/engines/griffon/state.cpp +++ b/engines/griffon/state.cpp @@ -1,272 +1,268 @@ -/* ScummVM - Graphic Adventure Engine
 - *
 - * ScummVM is the legal property of its developers, whose names
 - * are too numerous to list here. Please refer to the COPYRIGHT
 - * file distributed with this source distribution.
 - *
 - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 - *
 - *
 - *              Originally written by Syn9 in FreeBASIC with SDL
 - *              http://syn9.thehideoutgames.com/index_backup.php
 - *
 - *            Ported to plain C for GCW-Zero handheld by Dmitry Smagin
 - *                http://github.com/dmitrysmagin/griffon_legend
 - *
 - *
 - *                 Programming/Graphics: Daniel "Syn9" Kennedy
 - *                     Music/Sound effects: David Turner
 - *
 - *                   Beta testing and gameplay design help:
 - *                    Deleter, Cha0s, Aether Fox, and Kiz
 - *
 - */
 -
 -#include <stdlib.h>
 -#include <stdio.h>
 -#include <string.h>
 -#include <math.h>
 -#include <sys/stat.h>
 -
 -#include <SDL/SDL.h>
 -
 -#include "griffon.h"
 -#include "state.h"
 -
 -char player_sav[256] = "data/player%i.sav";
 -
 -#define PRINT(A,B)          \
 -	do {                    \
 -		char line[256];         \
 -		sprintf(line, A "\n", B);   \
 -		fputs(line, fp);        \
 -	} while(0)
 -
 -#define INPUT(A, B)         \
 -	do {                    \
 -		char line[256];         \
 -		fgets(line, sizeof(line), fp);  \
 -		sscanf(line, A, B);     \
 -	} while(0)
 -
 -// externs (to be removed later)
 -extern PLAYERTYPE playera;
 -extern int asecstart;
 -
 -int state_load(int slotnum) {
 -	FILE *fp;
 -	char line[256];
 -
 -	sprintf(line, player_sav, slotnum);
 -
 -	fp = fopen(line, "r");
 -	if (fp) {
 -		INPUT("%i", &player.level);
 -
 -		if (player.level > 0) {
 -			INPUT("%i", &secstart);
 -			INPUT("%s", line);
 -
 -			INPUT("%f", &player.px);
 -			INPUT("%f", &player.py);
 -			INPUT("%f", &player.opx);
 -			INPUT("%f", &player.opy);
 -			INPUT("%i", &player.walkdir);
 -			INPUT("%f", &player.walkframe);
 -			INPUT("%f", &player.walkspd);
 -			INPUT("%f", &player.attackframe);
 -			INPUT("%f", &player.attackspd);
 -			INPUT("%i", &player.hp);
 -			INPUT("%i", &player.maxhp);
 -			INPUT("%f", &player.hpflash);
 -			INPUT("%i", &player.level);
 -			INPUT("%i", &player.maxlevel);
 -			INPUT("%i", &player.sword);
 -			INPUT("%i", &player.shield);
 -			INPUT("%i", &player.armour);
 -			for (int i = 0; i < 5; i++) {
 -				INPUT("%i", &player.foundspell[i]);
 -				INPUT("%f", &player.spellcharge[i]);
 -			}
 -			for (int a = 0; a < 5; a++) {
 -				INPUT("%i", &player.inventory[a]);
 -			}
 -			INPUT("%f", &player.attackstrength);
 -			INPUT("%i", &player.spelldamage);
 -			INPUT("%i", &player.sworddamage);
 -			INPUT("%i", &player.exp);
 -			INPUT("%i", &player.nextlevel);
 -			for (int a = 0; a <= 99; a++) {
 -				for (int b = 0; b <= 9; b++) {
 -					INPUT("%i", &scriptflag[a][b]);
 -				}
 -			}
 -			INPUT("%i", &curmap);
 -
 -			for (int a = 0; a <= 999; a++) {
 -				for (int b = 0; b <= 20; b++) {
 -					for (int c = 0; c <= 14; c++) {
 -						INPUT("%i", &objmapf[a][b][c]);
 -					}
 -				}
 -			}
 -
 -			for (int a = 0; a <= 200; a++) {
 -				INPUT("%i", &roomlocks[a]);
 -			}
 -
 -			INPUT("%f", &player.spellstrength);
 -
 -			fclose(fp);
 -
 -			return 1; // success
 -		}
 -
 -		fclose(fp);
 -	}
 -
 -	return 0; // fail
 -}
 -
 -/* fill PLAYERTYPE playera; */
 -int state_load_player(int slotnum) {
 -	FILE *fp;
 -	char line[256];
 -
 -	sprintf(line, player_sav, slotnum);
 -
 -	playera.level = 0;
 -
 -	fp = fopen(line, "r");
 -	if (fp) {
 -		INPUT("%i", &playera.level);
 -
 -		if (playera.level > 0) {
 -			INPUT("%i", &asecstart);
 -			INPUT("%s", line);
 -
 -			INPUT("%f", &playera.px);
 -			INPUT("%f", &playera.py);
 -			INPUT("%f", &playera.opx);
 -			INPUT("%f", &playera.opy);
 -			INPUT("%i", &playera.walkdir);
 -			INPUT("%f", &playera.walkframe);
 -			INPUT("%f", &playera.walkspd);
 -			INPUT("%f", &playera.attackframe);
 -			INPUT("%f", &playera.attackspd);
 -			INPUT("%i", &playera.hp);
 -			INPUT("%i", &playera.maxhp);
 -			INPUT("%f", &playera.hpflash);
 -			INPUT("%i", &playera.level);
 -			INPUT("%i", &playera.maxlevel);
 -			INPUT("%i", &playera.sword);
 -			INPUT("%i", &playera.shield);
 -			INPUT("%i", &playera.armour);
 -			for (int i = 0; i < 5; i++) {
 -				INPUT("%i", &playera.foundspell[i]);
 -				INPUT("%f", &playera.spellcharge[i]);
 -			}
 -			for (int a = 0; a < 5; a++) {
 -				INPUT("%i", &playera.inventory[a]);
 -			}
 -			INPUT("%f", &playera.attackstrength);
 -			INPUT("%i", &playera.spelldamage);
 -			INPUT("%i", &playera.sworddamage);
 -			INPUT("%i", &playera.exp);
 -			INPUT("%i", &playera.nextlevel);
 -
 -			fclose(fp);
 -
 -			return 1; // success
 -		}
 -
 -		fclose(fp);
 -	}
 -
 -	return 0; // fail
 -}
 -
 -int state_save(int slotnum) {
 -	FILE *fp;
 -	char line[256];
 -
 -	sprintf(line, player_sav, slotnum);
 -
 -	fp = fopen(line, "w");
 -	if (fp) {
 -		PRINT("%i", player.level);
 -
 -		if (player.level > 0) {
 -			PRINT("%i", (secstart + secsingame));
 -			PRINT("%s", "a");
 -
 -			PRINT("%f", player.px);
 -			PRINT("%f", player.py);
 -			PRINT("%f", player.opx);
 -			PRINT("%f", player.opy);
 -			PRINT("%i", player.walkdir);
 -			PRINT("%f", player.walkframe);
 -			PRINT("%f", player.walkspd);
 -			PRINT("%f", player.attackframe);
 -			PRINT("%f", player.attackspd);
 -			PRINT("%i", player.hp);
 -			PRINT("%i", player.maxhp);
 -			PRINT("%f", player.hpflash);
 -			PRINT("%i", player.level);
 -			PRINT("%i", player.maxlevel);
 -			PRINT("%i", player.sword);
 -			PRINT("%i", player.shield);
 -			PRINT("%i", player.armour);
 -			for (int i = 0; i < 5; i++) {
 -				PRINT("%i", player.foundspell[i]);
 -				PRINT("%f", player.spellcharge[i]);
 -			}
 -			for (int a = 0; a < 5; a++) {
 -				PRINT("%i", player.inventory[a]);
 -			}
 -			PRINT("%f", player.attackstrength);
 -			PRINT("%i", player.spelldamage);
 -			PRINT("%i", player.sworddamage);
 -			PRINT("%i", player.exp);
 -			PRINT("%i", player.nextlevel);
 -			for (int a = 0; a <= 99; a++) {
 -				for (int b = 0; b <= 9; b++) {
 -					PRINT("%i", scriptflag[a][b]);
 -				}
 -			}
 -			PRINT("%i", curmap);
 -
 -			for (int a = 0; a <= 999; a++) {
 -				for (int b = 0; b <= 20; b++) {
 -					for (int c = 0; c <= 14; c++) {
 -						PRINT("%i", objmapf[a][b][c]);
 -					}
 -				}
 -			}
 -
 -			for (int a = 0; a <= 200; a++) {
 -				PRINT("%i", roomlocks[a]);
 -			}
 -
 -			PRINT("%f", player.spellstrength);
 -		}
 -
 -		fclose(fp);
 -
 -		return 1; // success
 -	}
 -
 -	return 0; // fail
 -}
 +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + *              Originally written by Syn9 in FreeBASIC with SDL + *              http://syn9.thehideoutgames.com/index_backup.php + * + *            Ported to plain C for GCW-Zero handheld by Dmitry Smagin + *                http://github.com/dmitrysmagin/griffon_legend + * + * + *                 Programming/Graphics: Daniel "Syn9" Kennedy + *                     Music/Sound effects: David Turner + * + *                   Beta testing and gameplay design help: + *                    Deleter, Cha0s, Aether Fox, and Kiz + * + */ + +#include "griffon/griffon.h" +#include "griffon/state.h" + +namespace Griffon { + +char player_sav[256] = "data/player%i.sav"; + +#define PRINT(A,B)          \ +	do {                    \ +		char line[256];         \ +		sprintf(line, A "\n", B);   \ +		fputs(line, fp);        \ +	} while(0) + +#define INPUT(A, B)         \ +	do {                    \ +		char line[256];         \ +		fgets(line, sizeof(line), fp);  \ +		sscanf(line, A, B);     \ +	} while(0) + +// externs (to be removed later) +extern PLAYERTYPE playera; +extern int asecstart; + +int state_load(int slotnum) { +	FILE *fp; +	char line[256]; + +	sprintf(line, player_sav, slotnum); + +	fp = fopen(line, "r"); +	if (fp) { +		INPUT("%i", &player.level); + +		if (player.level > 0) { +			INPUT("%i", &secstart); +			INPUT("%s", line); + +			INPUT("%f", &player.px); +			INPUT("%f", &player.py); +			INPUT("%f", &player.opx); +			INPUT("%f", &player.opy); +			INPUT("%i", &player.walkdir); +			INPUT("%f", &player.walkframe); +			INPUT("%f", &player.walkspd); +			INPUT("%f", &player.attackframe); +			INPUT("%f", &player.attackspd); +			INPUT("%i", &player.hp); +			INPUT("%i", &player.maxhp); +			INPUT("%f", &player.hpflash); +			INPUT("%i", &player.level); +			INPUT("%i", &player.maxlevel); +			INPUT("%i", &player.sword); +			INPUT("%i", &player.shield); +			INPUT("%i", &player.armour); +			for (int i = 0; i < 5; i++) { +				INPUT("%i", &player.foundspell[i]); +				INPUT("%f", &player.spellcharge[i]); +			} +			for (int a = 0; a < 5; a++) { +				INPUT("%i", &player.inventory[a]); +			} +			INPUT("%f", &player.attackstrength); +			INPUT("%i", &player.spelldamage); +			INPUT("%i", &player.sworddamage); +			INPUT("%i", &player.exp); +			INPUT("%i", &player.nextlevel); +			for (int a = 0; a <= 99; a++) { +				for (int b = 0; b <= 9; b++) { +					INPUT("%i", &scriptflag[a][b]); +				} +			} +			INPUT("%i", &curmap); + +			for (int a = 0; a <= 999; a++) { +				for (int b = 0; b <= 20; b++) { +					for (int c = 0; c <= 14; c++) { +						INPUT("%i", &objmapf[a][b][c]); +					} +				} +			} + +			for (int a = 0; a <= 200; a++) { +				INPUT("%i", &roomlocks[a]); +			} + +			INPUT("%f", &player.spellstrength); + +			fclose(fp); + +			return 1; // success +		} + +		fclose(fp); +	} + +	return 0; // fail +} + +/* fill PLAYERTYPE playera; */ +int state_load_player(int slotnum) { +	FILE *fp; +	char line[256]; + +	sprintf(line, player_sav, slotnum); + +	playera.level = 0; + +	fp = fopen(line, "r"); +	if (fp) { +		INPUT("%i", &playera.level); + +		if (playera.level > 0) { +			INPUT("%i", &asecstart); +			INPUT("%s", line); + +			INPUT("%f", &playera.px); +			INPUT("%f", &playera.py); +			INPUT("%f", &playera.opx); +			INPUT("%f", &playera.opy); +			INPUT("%i", &playera.walkdir); +			INPUT("%f", &playera.walkframe); +			INPUT("%f", &playera.walkspd); +			INPUT("%f", &playera.attackframe); +			INPUT("%f", &playera.attackspd); +			INPUT("%i", &playera.hp); +			INPUT("%i", &playera.maxhp); +			INPUT("%f", &playera.hpflash); +			INPUT("%i", &playera.level); +			INPUT("%i", &playera.maxlevel); +			INPUT("%i", &playera.sword); +			INPUT("%i", &playera.shield); +			INPUT("%i", &playera.armour); +			for (int i = 0; i < 5; i++) { +				INPUT("%i", &playera.foundspell[i]); +				INPUT("%f", &playera.spellcharge[i]); +			} +			for (int a = 0; a < 5; a++) { +				INPUT("%i", &playera.inventory[a]); +			} +			INPUT("%f", &playera.attackstrength); +			INPUT("%i", &playera.spelldamage); +			INPUT("%i", &playera.sworddamage); +			INPUT("%i", &playera.exp); +			INPUT("%i", &playera.nextlevel); + +			fclose(fp); + +			return 1; // success +		} + +		fclose(fp); +	} + +	return 0; // fail +} + +int state_save(int slotnum) { +	FILE *fp; +	char line[256]; + +	sprintf(line, player_sav, slotnum); + +	fp = fopen(line, "w"); +	if (fp) { +		PRINT("%i", player.level); + +		if (player.level > 0) { +			PRINT("%i", (secstart + secsingame)); +			PRINT("%s", "a"); + +			PRINT("%f", player.px); +			PRINT("%f", player.py); +			PRINT("%f", player.opx); +			PRINT("%f", player.opy); +			PRINT("%i", player.walkdir); +			PRINT("%f", player.walkframe); +			PRINT("%f", player.walkspd); +			PRINT("%f", player.attackframe); +			PRINT("%f", player.attackspd); +			PRINT("%i", player.hp); +			PRINT("%i", player.maxhp); +			PRINT("%f", player.hpflash); +			PRINT("%i", player.level); +			PRINT("%i", player.maxlevel); +			PRINT("%i", player.sword); +			PRINT("%i", player.shield); +			PRINT("%i", player.armour); +			for (int i = 0; i < 5; i++) { +				PRINT("%i", player.foundspell[i]); +				PRINT("%f", player.spellcharge[i]); +			} +			for (int a = 0; a < 5; a++) { +				PRINT("%i", player.inventory[a]); +			} +			PRINT("%f", player.attackstrength); +			PRINT("%i", player.spelldamage); +			PRINT("%i", player.sworddamage); +			PRINT("%i", player.exp); +			PRINT("%i", player.nextlevel); +			for (int a = 0; a <= 99; a++) { +				for (int b = 0; b <= 9; b++) { +					PRINT("%i", scriptflag[a][b]); +				} +			} +			PRINT("%i", curmap); + +			for (int a = 0; a <= 999; a++) { +				for (int b = 0; b <= 20; b++) { +					for (int c = 0; c <= 14; c++) { +						PRINT("%i", objmapf[a][b][c]); +					} +				} +			} + +			for (int a = 0; a <= 200; a++) { +				PRINT("%i", roomlocks[a]); +			} + +			PRINT("%f", player.spellstrength); +		} + +		fclose(fp); + +		return 1; // success +	} + +	return 0; // fail +} + +} // end of namespace Griffon diff --git a/engines/griffon/state.h b/engines/griffon/state.h index 88ff083785..c479f9dd53 100644 --- a/engines/griffon/state.h +++ b/engines/griffon/state.h @@ -34,8 +34,10 @@   *
   */
 -#ifndef _STATE_H_
 -#define _STATE_H_
 +#ifndef GRIFFON_STATE_H
 +#define GRIFFON_STATE_H
 +
 +namespace Griffon {
  extern char player_sav[];
 @@ -43,4 +45,6 @@ int state_load(int slotnum);  int state_load_player(int slotnum);
  int state_save(int slotnum);
 -#endif // _STATE_H_
 +} // end of namespace Griffon
 +
 +#endif
  | 
