|
| 1 | +Loading custom levels from ~/.freegish/level/ |
| 2 | +Index: freegish-1.53+git20101011+dfsg/src/game/editor.c |
| 3 | +=================================================================== |
| 4 | +--- freegish-1.53+git20101011+dfsg.orig/src/game/editor.c 2014-02-23 23:06:53.000000000 +0100 |
| 5 | ++++ freegish-1.53+git20101011+dfsg/src/game/editor.c 2014-02-23 23:19:52.000000000 +0100 |
| 6 | +@@ -420,7 +420,7 @@ |
| 7 | + { |
| 8 | + if (keyboard[SCAN_F7] && !prevkeyboard[SCAN_F7]) |
| 9 | + { |
| 10 | +- loadlevel(editor.filename); |
| 11 | ++ loadlevelcustom(editor.filename); |
| 12 | + setuplevel(); |
| 13 | + setupgame(); |
| 14 | + } |
| 15 | +Index: freegish-1.53+git20101011+dfsg/src/game/level.c |
| 16 | +=================================================================== |
| 17 | +--- freegish-1.53+git20101011+dfsg.orig/src/game/level.c 2014-02-23 23:06:53.000000000 +0100 |
| 18 | ++++ freegish-1.53+git20101011+dfsg/src/game/level.c 2014-02-23 23:19:52.000000000 +0100 |
| 19 | +@@ -286,7 +286,51 @@ |
| 20 | + } |
| 21 | + } |
| 22 | + |
| 23 | ++/* |
| 24 | ++void printcwd(void) |
| 25 | ++{ |
| 26 | ++ char path [PATH_MAX]; |
| 27 | ++ getcwd(path,PATH_MAX); |
| 28 | ++ printf ("cwd: %s\n", path); |
| 29 | ++} |
| 30 | ++*/ |
| 31 | ++ |
| 32 | + void loadlevel(char *filename) |
| 33 | ++{ |
| 34 | ++ int changeddir; |
| 35 | ++ int retval; |
| 36 | ++ |
| 37 | ++// printcwd(); |
| 38 | ++ |
| 39 | ++ changeddir=chdir("level"); |
| 40 | ++ retval = loadlevelprivate(filename, NULL, NULL); |
| 41 | ++// if (changeddir==0) |
| 42 | ++// chdir(".."); |
| 43 | ++ |
| 44 | ++// printf ("loadlevelprivate: %d\n", retval); |
| 45 | ++ |
| 46 | ++ return; |
| 47 | ++} |
| 48 | ++ |
| 49 | ++void loadlevelcustom(char *filename) |
| 50 | ++{ |
| 51 | ++ char levelpath [PATH_MAX]; |
| 52 | ++#ifdef DATAPATH |
| 53 | ++ char *datapath=DATAPATH; |
| 54 | ++#else |
| 55 | ++ char datapath[PATH_MAX]; |
| 56 | ++ |
| 57 | ++ getcwd(datapath,PATH_MAX); |
| 58 | ++#endif |
| 59 | ++ |
| 60 | ++ chdir(userpath(levelpath,"level",NULL)); |
| 61 | ++ loadlevelprivate(filename, levelpath, datapath); |
| 62 | ++// chdir(datapath); |
| 63 | ++ |
| 64 | ++ return; |
| 65 | ++} |
| 66 | ++ |
| 67 | ++int loadlevelprivate(char *filename, char *levelpath, char *datapath) |
| 68 | + { |
| 69 | + int count,count2; |
| 70 | + int changeddir; |
| 71 | +@@ -296,11 +340,10 @@ |
| 72 | + |
| 73 | + x=0x17AF2E03; |
| 74 | + |
| 75 | +- changeddir=chdir("level"); |
| 76 | +- |
| 77 | + if ((fp=fopen(filename,"rb"))!=NULL) |
| 78 | + { |
| 79 | + fread2(&version,4,1,fp); |
| 80 | ++ printf ( "ver: %i - %s\n", version, filename ); |
| 81 | + |
| 82 | + if (version==9) |
| 83 | + { |
| 84 | +@@ -334,9 +377,7 @@ |
| 85 | + if (level.numofobjects<0 || level.numofobjects>=256) |
| 86 | + { |
| 87 | + fclose(fp); |
| 88 | +- if (changeddir==0) |
| 89 | +- chdir(".."); |
| 90 | +- return; |
| 91 | ++ return 1; |
| 92 | + } |
| 93 | + for (count=0;count<level.numofobjects;count++) |
| 94 | + { |
| 95 | +@@ -357,9 +398,7 @@ |
| 96 | + if (level.numofropes<0 || level.numofropes>=1024) |
| 97 | + { |
| 98 | + fclose(fp); |
| 99 | +- if (changeddir==0) |
| 100 | +- chdir(".."); |
| 101 | +- return; |
| 102 | ++ return 2; |
| 103 | + } |
| 104 | + for (count=0;count<level.numofropes;count++) |
| 105 | + { |
| 106 | +@@ -376,9 +415,7 @@ |
| 107 | + if (texture[count].sizex<0 || texture[count].sizex>=1024) |
| 108 | + { |
| 109 | + fclose(fp); |
| 110 | +- if (changeddir==0) |
| 111 | +- chdir(".."); |
| 112 | +- return; |
| 113 | ++ return 3; |
| 114 | + } |
| 115 | + if (texture[count].sizex!=0) |
| 116 | + { |
| 117 | +@@ -411,9 +448,7 @@ |
| 118 | + if (block[count].numoflines<0 || block[count].numoflines>=64) |
| 119 | + { |
| 120 | + fclose(fp); |
| 121 | +- if (changeddir==0) |
| 122 | +- chdir(".."); |
| 123 | +- return; |
| 124 | ++ return 4; |
| 125 | + } |
| 126 | + for (count2=0;count2<block[count].numoflines;count2++) |
| 127 | + fread2(block[count].line[count2],4,8,fp); |
| 128 | +@@ -450,9 +485,7 @@ |
| 129 | + if (level.numofobjects<0 || level.numofobjects>=256) |
| 130 | + { |
| 131 | + fclose(fp); |
| 132 | +- if (changeddir==0) |
| 133 | +- chdir(".."); |
| 134 | +- return; |
| 135 | ++ return 5; |
| 136 | + } |
| 137 | + for (count=0;count<level.numofobjects;count++) |
| 138 | + { |
| 139 | +@@ -473,9 +506,7 @@ |
| 140 | + if (level.numofropes<0 || level.numofropes>=1024) |
| 141 | + { |
| 142 | + fclose(fp); |
| 143 | +- if (changeddir==0) |
| 144 | +- chdir(".."); |
| 145 | +- return; |
| 146 | ++ return 6; |
| 147 | + } |
| 148 | + for (count=0;count<level.numofropes;count++) |
| 149 | + { |
| 150 | +@@ -492,9 +523,7 @@ |
| 151 | + if (texture[count].sizex<0 || texture[count].sizex>=1024) |
| 152 | + { |
| 153 | + fclose(fp); |
| 154 | +- if (changeddir==0) |
| 155 | +- chdir(".."); |
| 156 | +- return; |
| 157 | ++ return 7; |
| 158 | + } |
| 159 | + if (texture[count].sizex!=0) |
| 160 | + { |
| 161 | +@@ -524,9 +553,7 @@ |
| 162 | + if (block[count].numoflines<0 || block[count].numoflines>=64) |
| 163 | + { |
| 164 | + fclose(fp); |
| 165 | +- if (changeddir==0) |
| 166 | +- chdir(".."); |
| 167 | +- return; |
| 168 | ++ return 8; |
| 169 | + } |
| 170 | + for (count2=0;count2<block[count].numoflines;count2++) |
| 171 | + fread2(block[count].line[count2],4,8,fp); |
| 172 | +@@ -563,9 +590,7 @@ |
| 173 | + if (level.numofobjects<0 || level.numofobjects>=256) |
| 174 | + { |
| 175 | + fclose(fp); |
| 176 | +- if (changeddir==0) |
| 177 | +- chdir(".."); |
| 178 | +- return; |
| 179 | ++ return 9; |
| 180 | + } |
| 181 | + for (count=0;count<level.numofobjects;count++) |
| 182 | + { |
| 183 | +@@ -586,9 +611,7 @@ |
| 184 | + if (level.numofropes<0 || level.numofropes>=1024) |
| 185 | + { |
| 186 | + fclose(fp); |
| 187 | +- if (changeddir==0) |
| 188 | +- chdir(".."); |
| 189 | +- return; |
| 190 | ++ return 10; |
| 191 | + } |
| 192 | + for (count=0;count<level.numofropes;count++) |
| 193 | + { |
| 194 | +@@ -611,11 +634,16 @@ |
| 195 | + fread2(filename, 1, filenameLength, fp); |
| 196 | + |
| 197 | + if (debug_level_saveload) printf("\"%s\"...\n", filename); |
| 198 | +- if (changeddir==0) |
| 199 | +- chdir(".."); |
| 200 | ++//TODO: correct? |
| 201 | ++ if (levelpath == NULL) |
| 202 | ++ chdir(".."); |
| 203 | ++ else |
| 204 | ++ chdir (datapath); |
| 205 | + loadtexture(count, filename,0,GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE,GL_LINEAR,GL_LINEAR); |
| 206 | +- if (changeddir==0) |
| 207 | +- changeddir = chdir("level"); |
| 208 | ++ if (levelpath == NULL) |
| 209 | ++ chdir("level"); |
| 210 | ++ else |
| 211 | ++ chdir(levelpath); |
| 212 | + } |
| 213 | + else |
| 214 | + { |
| 215 | +@@ -625,9 +653,7 @@ |
| 216 | + { |
| 217 | + if (debug_level_saveload) printf("Invalid blob!\n"); |
| 218 | + fclose(fp); |
| 219 | +- if (changeddir==0) |
| 220 | +- chdir(".."); |
| 221 | +- return; |
| 222 | ++ return 12; |
| 223 | + } |
| 224 | + if (texture[count].sizex==0) |
| 225 | + { |
| 226 | +@@ -664,9 +690,7 @@ |
| 227 | + if (block[count].numoflines<0 || block[count].numoflines>=64) |
| 228 | + { |
| 229 | + fclose(fp); |
| 230 | +- if (changeddir==0) |
| 231 | +- chdir(".."); |
| 232 | +- return; |
| 233 | ++ return 13; |
| 234 | + } |
| 235 | + for (count2=0;count2<block[count].numoflines;count2++) |
| 236 | + fread2(block[count].line[count2],4,8,fp); |
| 237 | +@@ -681,10 +705,12 @@ |
| 238 | + } |
| 239 | + } |
| 240 | + |
| 241 | +- fclose(fp); |
| 242 | ++ fclose(fp); |
| 243 | + |
| 244 | +- if (changeddir==0) |
| 245 | ++ if (levelpath == NULL) |
| 246 | + chdir(".."); |
| 247 | ++ else |
| 248 | ++ chdir(datapath); |
| 249 | + |
| 250 | + if (version<7) |
| 251 | + loadleveltextures(); |
| 252 | +@@ -700,6 +726,10 @@ |
| 253 | + loadtexture(254,"amber2.png",0,GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE,GL_LINEAR,GL_LINEAR); |
| 254 | + loadtexture(255,"amber3.png",0,GL_CLAMP_TO_EDGE,GL_CLAMP_TO_EDGE,GL_LINEAR,GL_LINEAR); |
| 255 | + } |
| 256 | ++ else |
| 257 | ++ printf ("can't open %s\n", filename); |
| 258 | ++ |
| 259 | ++ return 0; |
| 260 | + } |
| 261 | + |
| 262 | + void createlevel(void) |
| 263 | +Index: freegish-1.53+git20101011+dfsg/src/game/level.h |
| 264 | +=================================================================== |
| 265 | +--- freegish-1.53+git20101011+dfsg.orig/src/game/level.h 2014-02-23 23:06:53.000000000 +0100 |
| 266 | ++++ freegish-1.53+git20101011+dfsg/src/game/level.h 2014-02-23 23:19:52.000000000 +0100 |
| 267 | +@@ -21,9 +21,13 @@ |
| 268 | + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 269 | + */ |
| 270 | + |
| 271 | ++//void pintcwd (void); |
| 272 | ++ |
| 273 | + int lineintersectlevel(float *intersectpoint,float *normal,float *scale,float *startpoint,float *endpoint); |
| 274 | + void savelevel(char *filename); |
| 275 | + void loadlevel(char *filename); |
| 276 | ++int loadlevelprivate(char *filename, char *levelpath, char *datapath); |
| 277 | ++void loadlevelcustom(char *filename); |
| 278 | + void createlevel(void); |
| 279 | + void getlevellines(int objectnum); |
| 280 | + void setuplevellines(int xstart,int ystart,int xend,int yend); |
| 281 | +Index: freegish-1.53+git20101011+dfsg/src/game/mappack.c |
| 282 | +=================================================================== |
| 283 | +--- freegish-1.53+git20101011+dfsg.orig/src/game/mappack.c 2014-02-23 23:06:53.000000000 +0100 |
| 284 | ++++ freegish-1.53+git20101011+dfsg/src/game/mappack.c 2014-02-23 23:19:52.000000000 +0100 |
| 285 | +@@ -211,7 +211,7 @@ |
| 286 | + |
| 287 | + game.editing=0; |
| 288 | + game.levelnum=0; |
| 289 | +- loadlevel(mappack.level[playermappack[playernum].levelnum-1]); |
| 290 | ++ loadlevelcustom(mappack.level[playermappack[playernum].levelnum-1]); |
| 291 | + |
| 292 | + mappack.active=1; |
| 293 | + |
| 294 | +Index: freegish-1.53+git20101011+dfsg/src/game/custom.c |
| 295 | +=================================================================== |
| 296 | +--- freegish-1.53+git20101011+dfsg.orig/src/game/custom.c 2014-02-23 23:23:23.000000000 +0100 |
| 297 | ++++ freegish-1.53+git20101011+dfsg/src/game/custom.c 2014-02-23 23:24:34.000000000 +0100 |
| 298 | +@@ -234,7 +234,7 @@ |
| 299 | + { |
| 300 | + game.editing=0; |
| 301 | + game.levelnum=0; |
| 302 | +- loadlevel(levellist[pagenum+count-1]); |
| 303 | ++ loadlevelcustom(levellist[pagenum+count-1]); |
| 304 | + gameloop(); |
| 305 | + |
| 306 | + joymenunum=count; |
0 commit comments