summaryrefslogtreecommitdiff
blob: 9f98b080f53d4fefe1cc558db6b076d277ebeef7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
Fix build failure with -Werror=format-security
--- ./src/Game.c
+++ ./src/Game.c
@@ -6,21 +6,14 @@ Game game;
 
 // path_sprintf should not be used by other .c files, as it does not fit for them.
 static void
-path_sprintf(char *path, char *formatted_name, int version)
+path_sprintf(char *path, const char *name, int version)
 {
-
-  int len;
-
-  printf("path_sprintf (%p, %s, %d)\n", path, formatted_name, version);
-
-  strcpy(path, getSaveGameDir());
-
-  len = strlen(path);
-
   if(1 == version) {
-    sprintf(path + len, formatted_name);
+    printf("path_sprintf (%p, %s.dat, %d)\n", path, name, version);
+    sprintf(path, "%s%s.dat", getSaveGameDir(), name);
   } else {
-    sprintf(path + len, formatted_name, version);
+    printf("path_sprintf (%p, %s%d.dat, %d)\n", path, name, version, version);
+    sprintf(path, "%s%s%d.dat", getSaveGameDir(), name, version);
   }
 
 }
@@ -30,14 +23,14 @@ deleteSavedGame()
 {
   char path[PATH_SIZE];
   // version 2
-  path_sprintf(path, "save%d.dat", GAME_VERSION);
+  path_sprintf(path, "save", GAME_VERSION);
   remove(path);
-  path_sprintf(path, "savedmap%d.dat", GAME_VERSION);
+  path_sprintf(path, "savedmap", GAME_VERSION);
   remove(path);
   // version 1
-  path_sprintf(path, "save.dat", 1);
+  path_sprintf(path, "save", 1);
   remove(path);
-  path_sprintf(path, "savedmap.dat", 1);
+  path_sprintf(path, "savedmap", 1);
   remove(path);
 }
 
@@ -51,7 +44,7 @@ saveGame()
 
   mkshuae();
 
-  path_sprintf(path, "save%d.dat", GAME_VERSION);
+  path_sprintf(path, "save", GAME_VERSION);
 
   if(!(fp = fopen(path, "wb"))) {
     err = strerror(errno);
@@ -79,7 +72,7 @@ saveGame()
   SDL_RWclose(rwop);
 
   // save the map
-  path_sprintf(path, "savedmap%d.dat", GAME_VERSION);
+  path_sprintf(path, "savedmap", GAME_VERSION);
   saveMapPath(path);
 }
 
@@ -96,7 +89,7 @@ loadGame()
   version = (int) GAME_VERSION;
 
   // load the map
-  path_sprintf(path, "savedmap%d.dat", GAME_VERSION);
+  path_sprintf(path, "savedmap", GAME_VERSION);
   if(!loadMapPath(path, 0)) {
     // if can't find saved map load static map
     fprintf(stderr,
@@ -112,9 +105,9 @@ loadGame()
   // try to find a saved game of any version
   while(version > 0) {
     if(version > 1) {
-      path_sprintf(path, "save%d.dat", version);
+      path_sprintf(path, "save", version);
     } else {                    // By Pedro: version==1
-      path_sprintf(path, "save.dat", version);
+      path_sprintf(path, "save", version);
     }
     fprintf(stderr, "Trying to load saved game: %s\n", path);
     fflush(stderr);