[lgeneral] 04/07: Imported Upstream version 1.3.1
Markus Koschany
apo-guest at moszumanska.debian.org
Wed Jan 13 19:26:38 UTC 2016
This is an automated email from the git hooks/post-receive script.
apo-guest pushed a commit to branch master
in repository lgeneral.
commit 9d802c8ff3cb3fd32ef36ed6b47385cd4bd060a1
Author: Markus Koschany <apo at debian.org>
Date: Wed Jan 13 17:24:01 2016 +0100
Imported Upstream version 1.3.1
---
ChangeLog | 6 ++++++
TODO | 1 -
acconfig.h | 3 ++-
config.h.in | 3 ++-
configure | 2 +-
configure.in | 2 +-
intl/localealias.c | 2 +-
lgc-pg/main.c | 16 ++++++++++++++++
lgc-pg/maps.c | 6 +++---
lgc-pg/misc.c | 8 ++++----
lgc-pg/nations.c | 2 +-
lgc-pg/parser.c | 2 +-
lgc-pg/scenarios.c | 10 +++++-----
lgc-pg/shp.c | 2 +-
lgc-pg/terrain.c | 21 ++++++++++++---------
lgc-pg/units.c | 8 ++++----
lged/lged.c | 4 ++--
lgeneral-redit/src/misc.c | 6 +++---
lgeneral-redit/src/parser.c | 2 +-
po/lgeneral/POTFILES.in | 2 +-
src/Makefile.am | 4 ++--
src/Makefile.in | 10 +++++-----
src/config.c | 8 ++------
src/file.c | 4 ++--
src/image.c | 2 +-
src/{sdl.c => lg-sdl.c} | 4 ++--
src/{sdl.h => lg-sdl.h} | 0
src/lgeneral.h | 2 +-
src/map.c | 7 +++++--
src/misc.c | 2 +-
src/nation.c | 2 +-
src/parser.c | 2 +-
src/purchase_dlg.c | 2 +-
src/scenario.c | 2 +-
src/slot.c | 9 +++------
35 files changed, 95 insertions(+), 73 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index eabdcb1..2aebd47 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+1.3.1:
+- bridge terrain type is now optional for compatibility (2016/01/08 MS)
+- adjusted file access mode and other stuff for portability (2015/09/13 Ivan Baidakou)
+- fixed seg fault on loading game (2015/09/13 Galland)
+- fixed seg fault that could occur on mounting unit (2015/09/13 Galland)
+
1.3.0:
- fixed seg fault in lgc-pg when running headless (2015/07/26 Markus Koschany)
- compatibility flag added for GCC5 (2015/07/26 Markus Koschany)
diff --git a/TODO b/TODO
index 7c5ae5c..c353ec6 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,3 @@
-- core units can be deployed later???
- transfer prestige?
- strat map icon for deploy window
diff --git a/acconfig.h b/acconfig.h
index 15175c2..bf1adda 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -15,5 +15,6 @@
@BOTTOM@
#ifdef HAVE_BROKEN_MKDIR
-# define mkdir(s,p) mkdir(s)
+# include <direct.h>
+# define mkdir(s,p) _mkdir(s)
#endif
diff --git a/config.h.in b/config.h.in
index 7bbe7d4..a0ec8c5 100644
--- a/config.h.in
+++ b/config.h.in
@@ -443,5 +443,6 @@
#ifdef HAVE_BROKEN_MKDIR
-# define mkdir(s,p) mkdir(s)
+# include <direct.h>
+# define mkdir(s,p) _mkdir(s)
#endif
diff --git a/configure b/configure
index 5cc6772..39e357b 100755
--- a/configure
+++ b/configure
@@ -4547,7 +4547,7 @@ fi
# Define the identity of the package.
PACKAGE=lgeneral
- VERSION=1.3.0
+ VERSION=1.3.1
cat >>confdefs.h <<_ACEOF
diff --git a/configure.in b/configure.in
index b786521..e009eff 100644
--- a/configure.in
+++ b/configure.in
@@ -4,7 +4,7 @@ AC_INIT(Makefile.am)
AC_CANONICAL_TARGET
AC_USE_SYSTEM_EXTENSIONS
-AM_INIT_AUTOMAKE(lgeneral,1.3.0)
+AM_INIT_AUTOMAKE(lgeneral,1.3.1)
AM_CONFIG_HEADER(config.h)
diff --git a/intl/localealias.c b/intl/localealias.c
index bca555a..001ce13 100644
--- a/intl/localealias.c
+++ b/intl/localealias.c
@@ -235,7 +235,7 @@ read_alias_file (fname, fname_len)
memcpy (&full_fname[fname_len], aliasfile, sizeof aliasfile);
#endif
- fp = fopen (full_fname, "r");
+ fp = fopen (full_fname, "rb");
if (fp == NULL)
{
FREE_BLOCKS (block_list);
diff --git a/lgc-pg/main.c b/lgc-pg/main.c
index 2017af0..8773365 100644
--- a/lgc-pg/main.c
+++ b/lgc-pg/main.c
@@ -41,10 +41,14 @@ int use_def_pal = 0; /* always use default PG palette regardless of whether
int map_or_scen_files_missing = 0; /* some map/scenario files were missing */
int apply_unit_mods = 0; /* apply PG specific modifications (e.g., determine
nation by name, mirror images, correct spelling) */
+int separate_bridges = 0; /* split of bridges into separate terrain type */
/* unofficial options */
const char *axis_name = 0, *allies_name = 0;
const char *axis_nations = 0, *allies_nations = 0; /* comma-separated */
+extern int terrain_tile_count;
+extern char tile_type[];
+
void print_help()
{
printf(
@@ -62,6 +66,7 @@ void print_help()
" or custom campaign assuming it uses the PG unit database\n"\
" (maybe slightly changed) \n"\
" --help this help\n"\
+ " --separate-bridges split bridges and roads into two terrain types\n" \
"Example:\n lgc-pg -s /mnt/cdrom/DAT\n"\
"See README.lgc-pg for more information.\n" );
exit( 0 );
@@ -91,6 +96,8 @@ int parse_args( int argc, char **argv )
apply_unit_mods = 1;
if ( !strcmp( "-h", argv[i] ) || !strcmp( "--help", argv[i] ) )
print_help(); /* will exit */
+ if ( !strcmp( "--separate-bridges", argv[i] ) )
+ separate_bridges = 1;
/* unoffical options */
if ( !strcmp( "--axis_name", argv[i] ) )
axis_name = argv[i + 1];
@@ -131,6 +138,13 @@ int parse_args( int argc, char **argv )
apply_unit_mods = 1; /* always for PG campaign of course */
if (tacicons_name[0] == 0)
sprintf( tacicons_name, "%s.bmp", target_name );
+
+ if (separate_bridges == 0) {
+ /* b -> r */
+ for (i = 0; i < terrain_tile_count; i++)
+ if (tile_type[i] == 'b')
+ tile_type[i] = 'r';
+ }
printf( "Settings:\n" );
printf( " Source: %s\n", source_path );
@@ -148,6 +162,8 @@ int parse_args( int argc, char **argv )
printf( " Use Individual Palettes\n" );
if ( apply_unit_mods )
printf( " Apply PG unit modifications\n" );
+ if (separate_bridges)
+ printf( " Have separate terrain type 'bridge'\n");
return 1;
}
diff --git a/lgc-pg/maps.c b/lgc-pg/maps.c
index e0880c2..7fb9d87 100644
--- a/lgc-pg/maps.c
+++ b/lgc-pg/maps.c
@@ -117,7 +117,7 @@ int maps_convert( int map_id )
printf( "Maps...\n" );
/* name file (try the one in lgc-pg as fallback) */
snprintf( path, MAXPATHLEN, "%s/mapnames.str", source_path );
- if ( (name_file = fopen_ic( path, "r" )) == NULL ) {
+ if ( (name_file = fopen_ic( path, "rb" )) == NULL ) {
fprintf( stderr, "ERROR: mapnames not found in %s?\n", source_path);
return 0;
}
@@ -133,7 +133,7 @@ int maps_convert( int map_id )
for ( i = start; i <=end; i++ ) {
/* open set file */
snprintf( path, MAXPATHLEN, "%s/map%02d.set", source_path, i );
- if (( source_file = fopen_ic( path, "r" ) ) == NULL) {
+ if (( source_file = fopen_ic( path, "rb" ) ) == NULL) {
fprintf( stderr, "%s: file not found\n", path );
/* for custom campaign not all maps/scenarios may be present so
* don't consider this fatal, just continue */
@@ -151,7 +151,7 @@ int maps_convert( int map_id )
else
snprintf( path, MAXPATHLEN, "%s/scenarios/%s",
dest_path, target_name );
- if ( ( dest_file = fopen( path, (map_id==-1)?"w":"a" ) ) == NULL ) {
+ if ( ( dest_file = fopen( path, (map_id==-1)?"wb":"ab" ) ) == NULL ) {
fprintf( stderr, "%s: access denied\n", path );
fclose( source_file );
return 0;
diff --git a/lgc-pg/misc.c b/lgc-pg/misc.c
index 5b40ab3..6d57de6 100644
--- a/lgc-pg/misc.c
+++ b/lgc-pg/misc.c
@@ -357,11 +357,11 @@ void copy_ic( char *sname, char *dname )
int size;
char *buffer;
FILE *source, *dest;
- if ( ( source = fopen_ic( sname, "r" ) ) == 0 ){
+ if ( ( source = fopen_ic( sname, "rb" ) ) == 0 ){
fprintf( stderr, "%s: file not found\n", sname );
return;
}
- if ( ( dest = fopen( dname, "w" ) ) == 0 ) {
+ if ( ( dest = fopen( dname, "wb" ) ) == 0 ) {
fprintf( stderr, "%s: write access denied\n", dname );
return;
}
@@ -380,11 +380,11 @@ void copy( char *sname, char *dname )
int size;
char *buffer;
FILE *source, *dest;
- if ( ( source = fopen( sname, "r" ) ) == 0 ){
+ if ( ( source = fopen( sname, "rb" ) ) == 0 ){
fprintf( stderr, "%s: file not found\n", sname );
return;
}
- if ( ( dest = fopen( dname, "w" ) ) == 0 ) {
+ if ( ( dest = fopen( dname, "wb" ) ) == 0 ) {
fprintf( stderr, "%s: write access denied\n", dname );
return;
}
diff --git a/lgc-pg/nations.c b/lgc-pg/nations.c
index 5eaa9ec..3673549 100644
--- a/lgc-pg/nations.c
+++ b/lgc-pg/nations.c
@@ -85,7 +85,7 @@ int nations_convert( void )
/* nation database */
printf( "Nation database...\n" );
snprintf( path, MAXPATHLEN, "%s/nations/%s.ndb", dest_path, target_name );
- if ( ( file = fopen( path, "w" ) ) == 0 ) {
+ if ( ( file = fopen( path, "wb" ) ) == 0 ) {
fprintf( stderr, "%s: access denied\n", path );
return 0;
}
diff --git a/lgc-pg/parser.c b/lgc-pg/parser.c
index 0cfc459..37d2111 100644
--- a/lgc-pg/parser.c
+++ b/lgc-pg/parser.c
@@ -489,7 +489,7 @@ PData* parser_read_file( char *tree_name, char *fname )
FILE *file = 0;
PData *top = 0;
/* open file */
- if ( ( file = fopen( fname, "r" ) ) == 0 ) {
+ if ( ( file = fopen( fname, "rb" ) ) == 0 ) {
sprintf( parser_error, "%s: file not found", fname );
return 0;
}
diff --git a/lgc-pg/scenarios.c b/lgc-pg/scenarios.c
index 81815d9..04c2961 100644
--- a/lgc-pg/scenarios.c
+++ b/lgc-pg/scenarios.c
@@ -271,7 +271,7 @@ int scen_add_flags( FILE *dest_file, FILE *scen_file, int id )
}
/* open set file */
snprintf( path, MAXPATHLEN, "%s/map%02i.set", source_path, id );
- if ( ( map_file = fopen_ic( path, "r" ) ) == 0 ) {
+ if ( ( map_file = fopen_ic( path, "rb" ) ) == 0 ) {
fprintf( stderr, "%s: file not found\n", path );
return 0;
}
@@ -909,7 +909,7 @@ int scenarios_convert( int scen_id )
if (strcmp(target_name, "pg") == 0) {
/* write out order of preferred listing */
snprintf( path, MAXPATHLEN, "%s/scenarios/pg/.order", dest_path );
- aux_file = fopen( path, "w" );
+ aux_file = fopen( path, "wb" );
if ( aux_file ) {
for (i = 0; i < sizeof fnames/sizeof fnames[0]; i++)
fprintf( aux_file, "%s\n", fnames[i] );
@@ -938,7 +938,7 @@ int scenarios_convert( int scen_id )
/* open scen stat file containing scenario names and descriptions */
if ( scen_id == -1 ) {
snprintf( path, MAXPATHLEN, "%s/scenstat.bin", source_path );
- if ((scenstat_file = fopen_ic(path, "r")) == NULL)
+ if ((scenstat_file = fopen_ic(path, "rb")) == NULL)
goto failure;
}
@@ -946,7 +946,7 @@ int scenarios_convert( int scen_id )
for ( i = start; i <=end; i++ ) {
/* open scenario file */
snprintf( path, MAXPATHLEN, "%s/game%03d.scn", source_path, i );
- if ((scen_file = fopen_ic(path, "r")) == NULL) {
+ if ((scen_file = fopen_ic(path, "rb")) == NULL) {
fprintf( stderr, "%s: file not found\n", path );
if (scen_id == -1 && strcmp(target_name,"pg")) {
map_or_scen_files_missing = 1;
@@ -994,7 +994,7 @@ int scenarios_convert( int scen_id )
} else
snprintf( path, MAXPATHLEN, "%s/scenarios/%s",
dest_path, target_name );
- if ( ( dest_file = fopen( path, "w" ) ) == 0 ) {
+ if ( ( dest_file = fopen( path, "wb" ) ) == 0 ) {
fprintf( stderr, "%s: access denied\n", path );
goto failure;
}
diff --git a/lgc-pg/shp.c b/lgc-pg/shp.c
index 28ba84b..8b8fedd 100644
--- a/lgc-pg/shp.c
+++ b/lgc-pg/shp.c
@@ -299,7 +299,7 @@ PG_Shp *shp_load( const char *fname )
int icon_maxw = 60, icon_maxh = 50;
snprintf( path, MAXPATHLEN, "%s/%s", source_path, fname );
- if ( ( file = fopen_ic( path, "r" ) ) == NULL ) {
+ if ( ( file = fopen_ic( path, "rb" ) ) == NULL ) {
printf("Could not open file %s\n",path);
return NULL;
}
diff --git a/lgc-pg/terrain.c b/lgc-pg/terrain.c
index 4980d5e..3ffb9ea 100644
--- a/lgc-pg/terrain.c
+++ b/lgc-pg/terrain.c
@@ -34,6 +34,7 @@ extern char *dest_path;
extern char target_name[128];
extern char *move_types[];
extern int move_type_count;
+extern int separate_bridges;
/*
====================================================================
@@ -190,7 +191,7 @@ static int terrain_convert_tiles( char id, PG_Shp *shp, char *fname )
SDL_Surface *surf;
char path[MAXPATHLEN];
int count = 0;
- int is_road = !strcmp( fname, "road" );
+ int broken_pos = 0;
/* count occurence */
for ( i = 0; i < terrain_tile_count; i++ )
@@ -218,16 +219,17 @@ static int terrain_convert_tiles( char id, PG_Shp *shp, char *fname )
pos = 0; count = 0;
for ( i = 0; i < terrain_tile_count; i++ )
if ( tile_type[i] == id ) {
- /* road tile no 0 is buggy ... */
- if (!is_road || count != 0) {
+ /* road tile #37 is buggy ... */
+ if (i != 37) {
srect.y = i * 50;
drect.x = pos;
SDL_BlitSurface( shp->surf, &srect, surf, &drect );
- }
- /* ... but can be repaired by mirroring tile no 3 */
- if (is_road && count == 3) {
+ } else
+ broken_pos = pos;
+ /* ... but can be repaired by mirroring tile #49 */
+ if (i == 49) {
srect.y = i * 50;
- drect.x = 0 * 60;
+ drect.x = broken_pos;
copy_surf_mirrored(shp->surf, &srect, surf, &drect);
}
pos += 60;
@@ -293,7 +295,7 @@ int terrain_convert_database( void )
printf( "Terrain database...\n" );
snprintf( path, MAXPATHLEN, "%s/maps/%s.tdb", dest_path, target_name );
- if ( ( file = fopen( path, "w" ) ) == 0 ) {
+ if ( ( file = fopen( path, "wb" ) ) == 0 ) {
fprintf( stderr, "%s: access denied\n", path );
return 0;
}
@@ -429,7 +431,8 @@ int terrain_convert_graphics( void )
if ( ( shp = shp_load( "TACMAP.SHP" ) ) == 0 ) goto failure;
if ( !terrain_convert_tiles( 'c', shp, "clear" ) ) goto failure;
if ( !terrain_convert_tiles( 'r', shp, "road" ) ) goto failure;
- if ( !terrain_convert_tiles( 'b', shp, "bridge" ) ) goto failure;
+ if (separate_bridges) /* if not, it's replaced with r ids */
+ if ( !terrain_convert_tiles( 'b', shp, "bridge" ) ) goto failure;
if ( !terrain_convert_tiles( '#', shp, "fields" ) ) goto failure;
if ( !terrain_convert_tiles( '~', shp, "rough" ) ) goto failure;
if ( !terrain_convert_tiles( 'R', shp, "river" ) ) goto failure;
diff --git a/lgc-pg/units.c b/lgc-pg/units.c
index 248f3fa..af69384 100644
--- a/lgc-pg/units.c
+++ b/lgc-pg/units.c
@@ -374,7 +374,7 @@ int units_find_panzequp()
char path[MAXPATHLEN];
snprintf( path, MAXPATHLEN, "%s/panzequp.eqp", source_path );
- if ( ( file = fopen_ic( path, "r" ) ) ) {
+ if ( ( file = fopen_ic( path, "rb" ) ) ) {
fclose( file );
return 1;
}
@@ -392,7 +392,7 @@ int units_find_tacicons()
char path[MAXPATHLEN];
snprintf( path, MAXPATHLEN, "%s/tacicons.shp", source_path );
- if ( ( file = fopen_ic( path, "r" ) ) ) {
+ if ( ( file = fopen_ic( path, "rb" ) ) ) {
fclose( file );
return 1;
}
@@ -460,14 +460,14 @@ int units_convert_database( char *tac_icons )
snprintf( path, MAXPATHLEN, "%s/scenarios/%s", dest_path, target_name );
else
snprintf( path, MAXPATHLEN, "%s/units/%s.udb", dest_path, target_name );
- if ( ( dest_file = fopen( path, single_scen?"a":"w" ) ) == 0 ) {
+ if ( ( dest_file = fopen( path, single_scen?"ab":"wb" ) ) == 0 ) {
fprintf( stderr, "%s: write access denied\n", path );
goto failure;
}
/* open file 'panzequp.eqp' */
snprintf( path, MAXPATHLEN, "%s/panzequp.eqp", source_path );
- if ( ( source_file = fopen_ic( path, "r" ) ) == NULL ) {
+ if ( ( source_file = fopen_ic( path, "rb" ) ) == NULL ) {
fprintf( stderr, "%s: can't open file\n", path );
goto failure;
}
diff --git a/lged/lged.c b/lged/lged.c
index 843c371..a1fe5cf 100644
--- a/lged/lged.c
+++ b/lged/lged.c
@@ -350,7 +350,7 @@ static void init_tool(int argc, char **argv) {
/* check whether we're started from within the source directory */
{
const char *path = srcdir_path_from_bindir("README.lgeneral");
- FILE *f = fopen(path, "r");
+ FILE *f = fopen(path, "rb");
within_source_tree = !!f;
if (f) fclose(f);
free((void *)path);
@@ -378,7 +378,7 @@ static void init_tool(int argc, char **argv) {
/* check whether reinforcements file exists */
{
- FILE *f = fopen(reinfrc, "r");
+ FILE *f = fopen(reinfrc, "rb");
if (!f)
fprintf(stderr, "Warning: No reinforcements file at %s. New list created.\n", reinfrc);
if (f) fclose(f);
diff --git a/lgeneral-redit/src/misc.c b/lgeneral-redit/src/misc.c
index cc8885d..64c2bf8 100644
--- a/lgeneral-redit/src/misc.c
+++ b/lgeneral-redit/src/misc.c
@@ -174,7 +174,7 @@ int load_reinf()
char *line;
Unit *unit;
int i, j, k, count;
- FILE *file = fopen( reinfrc, "r" );
+ FILE *file = fopen( reinfrc, "rb" );
List *list, *args;
if ( file )
list = file_read_lines( file );
@@ -227,7 +227,7 @@ int save_reinf()
{
Unit *unit;
int i, j;
- FILE *file = fopen( reinfrc, "w" );
+ FILE *file = fopen( reinfrc, "wb" );
if ( file == 0 ) return 0;
for ( i = 0; i < SCEN_COUNT; i++ )
{
@@ -271,7 +271,7 @@ void build_reinf()
{
Unit *unit;
int i, j, nat;
- FILE *file = fopen( reinf_output, "w" );
+ FILE *file = fopen( reinf_output, "wb" );
if ( file ) {
for ( i = 0; i < SCEN_COUNT; i++ ) {
if ( reinf[AXIS][i]->count == 0 )
diff --git a/lgeneral-redit/src/parser.c b/lgeneral-redit/src/parser.c
index b460df4..fd6c747 100644
--- a/lgeneral-redit/src/parser.c
+++ b/lgeneral-redit/src/parser.c
@@ -494,7 +494,7 @@ PData* parser_read_file( const char *tree_name, const char *fname )
FILE *file = 0;
PData *top = 0;
/* open file */
- if ( ( file = fopen( fname, "r" ) ) == 0 ) {
+ if ( ( file = fopen( fname, "rb" ) ) == 0 ) {
sprintf( parser_error, "%s: file not found", fname );
return 0;
}
diff --git a/po/lgeneral/POTFILES.in b/po/lgeneral/POTFILES.in
index 07da812..b0402c2 100644
--- a/po/lgeneral/POTFILES.in
+++ b/po/lgeneral/POTFILES.in
@@ -3,7 +3,7 @@ src/windows.c
src/nation.c
src/gui.c
src/map.c
-src/sdl.c
+src/lg-sdl.c
src/campaign.c
src/unit_lib.c
src/scenario.c
diff --git a/src/Makefile.am b/src/Makefile.am
index ac9b83f..99b1234 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,7 +6,7 @@ INCLUDES = -I$(top_srcdir)/util $(INTLINCLUDES)
lgeneral_SOURCES = main.c \
config.c date.c \
file.c map.c nation.c \
-player.c scenario.c sdl.c misc.c unit.c \
+player.c scenario.c lg-sdl.c misc.c unit.c \
audio.c parser.c list.c unit_lib.c \
terrain.c image.c slot.c gui.c purchase_dlg.c \
event.c windows.c action.c campaign.c \
@@ -21,7 +21,7 @@ man_MANS = lgeneral.6
EXTRA_DIST = lgeneral.h \
config.h date.h engine.h \
file.h map.h nation.h player.h \
-player.h scenario.h sdl.h misc.h unit.h unit.h \
+player.h scenario.h lg-sdl.h misc.h unit.h unit.h \
audio.h parser.h list.h unit_lib.h \
terrain.h image.h slot.h gui.h purchase_dlg.h \
event.h windows.h action.h campaign.h \
diff --git a/src/Makefile.in b/src/Makefile.in
index 8ddf778..bbd4269 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -97,8 +97,8 @@ am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man6dir)"
PROGRAMS = $(bin_PROGRAMS)
am_lgeneral_OBJECTS = main.$(OBJEXT) config.$(OBJEXT) date.$(OBJEXT) \
file.$(OBJEXT) map.$(OBJEXT) nation.$(OBJEXT) player.$(OBJEXT) \
- scenario.$(OBJEXT) sdl.$(OBJEXT) misc.$(OBJEXT) unit.$(OBJEXT) \
- audio.$(OBJEXT) parser.$(OBJEXT) list.$(OBJEXT) \
+ scenario.$(OBJEXT) lg-sdl.$(OBJEXT) misc.$(OBJEXT) \
+ unit.$(OBJEXT) audio.$(OBJEXT) parser.$(OBJEXT) list.$(OBJEXT) \
unit_lib.$(OBJEXT) terrain.$(OBJEXT) image.$(OBJEXT) \
slot.$(OBJEXT) gui.$(OBJEXT) purchase_dlg.$(OBJEXT) \
event.$(OBJEXT) windows.$(OBJEXT) action.$(OBJEXT) \
@@ -420,7 +420,7 @@ INCLUDES = -I$(top_srcdir)/util $(INTLINCLUDES)
lgeneral_SOURCES = main.c \
config.c date.c \
file.c map.c nation.c \
-player.c scenario.c sdl.c misc.c unit.c \
+player.c scenario.c lg-sdl.c misc.c unit.c \
audio.c parser.c list.c unit_lib.c \
terrain.c image.c slot.c gui.c purchase_dlg.c \
event.c windows.c action.c campaign.c \
@@ -434,7 +434,7 @@ man_MANS = lgeneral.6
EXTRA_DIST = lgeneral.h \
config.h date.h engine.h \
file.h map.h nation.h player.h \
-player.h scenario.h sdl.h misc.h unit.h unit.h \
+player.h scenario.h lg-sdl.h misc.h unit.h unit.h \
audio.h parser.h list.h unit_lib.h \
terrain.h image.h slot.h gui.h purchase_dlg.h \
event.h windows.h action.h campaign.h \
@@ -553,6 +553,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/file.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/gui.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/image.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/lg-sdl.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/list.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/main.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/map.Po at am__quote@
@@ -562,7 +563,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/player.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/purchase_dlg.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/scenario.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/sdl.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/slot.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/strat_map.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/terrain.Po at am__quote@
diff --git a/src/config.c b/src/config.c
index 5baa759..3b1dfef 100644
--- a/src/config.c
+++ b/src/config.c
@@ -22,7 +22,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
-#include "sdl.h"
+#include "lg-sdl.h"
#include "config.h"
#include "parser.h"
#include "localize.h"
@@ -44,11 +44,7 @@ void check_config_dir_name()
fprintf( stderr, tr("Couldn't find/open config directory '%s'\n"
"Attempting to create it... "), config.dir_name );
-#ifdef WIN32
- res = mkdir( config.dir_name );
-#else
res = mkdir( config.dir_name, S_IRWXU );
-#endif
if ( res != 0 )
fprintf( stderr, tr("failed\n") );
else
@@ -127,7 +123,7 @@ void save_config( )
char file_name[512];
sprintf( file_name, "%s/%s", config.dir_name, "lgeneral.conf" );
- if ( ( file = fopen( file_name, "w" ) ) == 0 )
+ if ( ( file = fopen( file_name, "wb" ) ) == 0 )
fprintf( stderr, tr("Cannot access config file '%s' to save settings\n"), file_name );
else {
fprintf( file, "@\n" );
diff --git a/src/file.c b/src/file.c
index 92fac28..3a1c7e1 100644
--- a/src/file.c
+++ b/src/file.c
@@ -61,7 +61,7 @@ Returns a list of files, or 0 if error.
static List *file_get_order_list( const char *orderfile )
{
List *l = 0;
- FILE *f = fopen( orderfile, "r" );
+ FILE *f = fopen( orderfile, "rb" );
if (!f) {
fprintf( stderr, tr("%s cannot be opened\n"), orderfile );
return 0;
@@ -179,7 +179,7 @@ List* dir_get_entries( const char *path, const char *root, const char *ext )
/* check regular file */
if ( S_ISREG( fstat.st_mode ) ) {
/* test it */
- if ( ( file = fopen( file_name, "r" ) ) == 0 ) continue;
+ if ( ( file = fopen( file_name, "rb" ) ) == 0 ) continue;
fclose( file );
/* check if this file has the proper extension */
if ( ext )
diff --git a/src/image.c b/src/image.c
index 8f3f812..a30182f 100644
--- a/src/image.c
+++ b/src/image.c
@@ -17,7 +17,7 @@
#include <SDL.h>
#include <stdlib.h>
-#include "sdl.h"
+#include "lg-sdl.h"
#include "image.h"
/*
diff --git a/src/sdl.c b/src/lg-sdl.c
similarity index 99%
rename from src/sdl.c
rename to src/lg-sdl.c
index bedb9c1..e5e056e 100644
--- a/src/sdl.c
+++ b/src/lg-sdl.c
@@ -1,5 +1,5 @@
/***************************************************************************
- sdl.c - description
+ lg-sdl - description
-------------------
begin : Thu Apr 20 2000
copyright : (C) 2000 by Michael Speck
@@ -15,7 +15,7 @@
* *
***************************************************************************/
-#include "sdl.h"
+#include "lg-sdl.h"
#include "misc.h"
diff --git a/src/sdl.h b/src/lg-sdl.h
similarity index 100%
rename from src/sdl.h
rename to src/lg-sdl.h
diff --git a/src/lgeneral.h b/src/lgeneral.h
index 51b4c28..990b7ed 100644
--- a/src/lgeneral.h
+++ b/src/lgeneral.h
@@ -38,7 +38,7 @@ General system includes.
Important local includes
====================================================================
*/
-#include "sdl.h"
+#include "lg-sdl.h"
#include "image.h"
#include "misc.h"
#include "list.h"
diff --git a/src/map.c b/src/map.c
index ad3bfa4..971ed56 100644
--- a/src/map.c
+++ b/src/map.c
@@ -730,8 +730,11 @@ Way_Point* map_get_unit_way_points( Unit *unit, int x, int y, int *count, Unit *
/* same tile ? */
if ( unit->x == x && unit->y == y ) return 0;
/* allocate memory */
- way = calloc( unit->cur_mov + 1, sizeof( Way_Point ) );
- reverse = calloc( unit->cur_mov + 1, sizeof( Way_Point ) );
+ int maxpoints = unit->cur_mov;
+ if (mask[x][y].mount == 1)
+ maxpoints = (unit->trsp_prop.mov>unit->prop.mov?unit->trsp_prop.mov:unit->prop.mov);
+ way = calloc( maxpoints + 1, sizeof( Way_Point ) );
+ reverse = calloc( maxpoints + 1, sizeof( Way_Point ) );
/* it's easiest to get positions in reverse order */
next_x = x; next_y = y; *count = 0;
while ( next_x != unit->x || next_y != unit->y ) {
diff --git a/src/misc.c b/src/misc.c
index 08a96fb..110b00f 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -19,7 +19,7 @@
#include "parser.h"
#include "localize.h"
#include "paths.h"
-#include "sdl.h"
+#include "lg-sdl.h"
#include <time.h>
#include <stdlib.h>
diff --git a/src/nation.c b/src/nation.c
index abfac0f..a8d1a1f 100644
--- a/src/nation.c
+++ b/src/nation.c
@@ -19,7 +19,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include "sdl.h"
+#include "lg-sdl.h"
#include "list.h"
#include "misc.h"
#include "file.h"
diff --git a/src/parser.c b/src/parser.c
index 0bab296..e762400 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -503,7 +503,7 @@ PData* parser_read_file( const char *tree_name, const char *fname )
ParserState *st = &state;
PData *top = 0;
/* open file */
- if ( ( state.file = fopen( fname, "r" ) ) == 0 ) {
+ if ( ( state.file = fopen( fname, "rb" ) ) == 0 ) {
sprintf( parser_error, tr("%s: file not found"), fname );
return 0;
}
diff --git a/src/purchase_dlg.c b/src/purchase_dlg.c
index 4149203..0cb6d3f 100644
--- a/src/purchase_dlg.c
+++ b/src/purchase_dlg.c
@@ -10,7 +10,7 @@
#include <SDL.h>
#include <stdlib.h>
#include "lgeneral.h"
-#include "sdl.h"
+#include "lg-sdl.h"
#include "date.h"
#include "event.h"
#include "image.h"
diff --git a/src/scenario.c b/src/scenario.c
index 28c1334..276f7e1 100644
--- a/src/scenario.c
+++ b/src/scenario.c
@@ -969,7 +969,7 @@ int scen_check_result( int after_last_turn )
char fname[512];
FILE *f;
snprintf(fname, sizeof fname, "%s/.lgames/.scenresult", getenv("HOME"));
- f = fopen(fname, "r");
+ f = fopen(fname, "rb");
if (f) {
unsigned len;
scen_result[0] = '\0';
diff --git a/src/slot.c b/src/slot.c
index 55a499d..2573617 100644
--- a/src/slot.c
+++ b/src/slot.c
@@ -615,6 +615,7 @@ Unit* load_unit( FILE *file )
unit->nation = nation_find( str );
free( str );
/* recalculate members that aren't stored */
+ unit->terrain = map[unit->x][unit->y].terrain;
unit_adjust_icon( unit );
unit->exp_level = unit->exp / 100;
unit_update_bar( unit );
@@ -851,7 +852,7 @@ void slots_init()
while ( ( entry = readdir( dir ) ) != 0 ) {
if ( is_saved_game( entry->d_name, &i ) ) {
sprintf( slots[i].fname, "%s/%s", config.dir_name, entry->d_name );
- if ( ( file = fopen( slots[i].fname, "r" ) ) == 0 ) {
+ if ( ( file = fopen( slots[i].fname, "rb" ) ) == 0 ) {
fprintf( stderr, tr("'%s': file not found\n"), slots[i].fname );
break;
}
@@ -932,7 +933,7 @@ int slot_save( int id, char *name )
/* get file name */
sprintf( path, "%s/lg_save_%i", config.dir_name, id );
/* open file */
- if ( ( file = fopen( path, "w" ) ) == 0 ) {
+ if ( ( file = fopen( path, "wb" ) ) == 0 ) {
fprintf( stderr, tr("%s: not found\n"), path );
return 0;
}
@@ -1004,11 +1005,7 @@ int slot_load( int id )
/* get file name */
sprintf( path, "%s/lg_save_%i", config.dir_name, id );
/* open file */
-#ifdef WIN32
if ( ( file = fopen( path, "rb" ) ) == 0 ) {
-#else
- if ( ( file = fopen( path, "r" ) ) == 0 ) {
-#endif
fprintf( stderr, tr("%s: not found\n"), path );
return 0;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/lgeneral.git
More information about the Pkg-games-commits
mailing list