comparison src/wads2.cc @ 79:0602d9bf474a

Various cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 26 Sep 2011 17:14:54 +0300
parents a68786b9c74b
children 2f1ecc1c5f72
comparison
equal deleted inserted replaced
78:626678d4ecf3 79:0602d9bf474a
53 { 53 {
54 MDirPtr lastp, newp; 54 MDirPtr lastp, newp;
55 long n; 55 long n;
56 Wad_file *wf; 56 Wad_file *wf;
57 57
58 /* open the wad file */ 58 /* open the wad file */
59 printf("Loading iwad: %s...\n", filename); 59 printf("Loading iwad: %s...\n", filename);
60 wf = BasicWadOpen(filename, yg_picture_format); 60 wf = BasicWadOpen(filename, yg_picture_format);
61 if (wf == 0) 61 if (wf == 0)
62 return 1; 62 return 1;
63 if (strncmp(wf->type, "IWAD", 4)) 63 if (strncmp(wf->type, "IWAD", 4))
64 warn("%.128s: is a pwad, not an iwad. Will use it anyway.\n", 64 warn("%.128s: is a pwad, not an iwad. Will use it anyway.\n",
65 filename); 65 filename);
66 66
67 /* create the master directory */ 67 /* create the master directory */
68 lastp = NULL; 68 lastp = NULL;
69 for (n = 0; n < wf->dirsize; n++) 69 for (n = 0; n < wf->dirsize; n++)
70 { 70 {
71 newp = (MDirPtr) GetMemory(sizeof(struct MasterDirectory)); 71 newp = (MDirPtr) GetMemory(sizeof(struct MasterDirectory));
72 newp->next = NULL; 72 newp->next = NULL;
86 && FindMasterDir(MasterDir, "MAP33") == NULL 86 && FindMasterDir(MasterDir, "MAP33") == NULL
87 && strcmp(Game, "doom02") 87 && strcmp(Game, "doom02")
88 && strcmp(Game, "doom04") 88 && strcmp(Game, "doom04")
89 && strcmp(Game, "doom05") && strcmp(Game, "doompr")) 89 && strcmp(Game, "doom05") && strcmp(Game, "doompr"))
90 { 90 {
91 printf
92 (" *-----------------------------------------------------*\n");
93 printf
94 (" | Warning: this is the shareware version of the game. |\n");
95 printf
96 (" | You won't be allowed to save your changes. |\n");
97 printf
98 (" | PLEASE REGISTER YOUR COPY OF THE GAME. |\n");
99 printf
100 (" *-----------------------------------------------------*\n");
101 Registered = false; // If you remove this, bad things will happen to you... 91 Registered = false; // If you remove this, bad things will happen to you...
92 printf(" *-----------------------------------------------------*\n");
93 printf(" | Warning: this is the shareware version of the game. |\n");
94 printf(" | You won't be allowed to save your changes. |\n");
95 printf(" | PLEASE REGISTER YOUR COPY OF THE GAME. |\n");
96 printf(" *-----------------------------------------------------*\n");
102 } 97 }
103 else 98 else
104 Registered = true; 99 Registered = true;
105 return 0; 100 return 0;
106 } 101 }
158 int state_prev; 153 int state_prev;
159 int replaces_prev; 154 int replaces_prev;
160 int names = 0; // Number of names already printed on current line 155 int names = 0; // Number of names already printed on current line
161 const char *entry_type_prev; 156 const char *entry_type_prev;
162 typedef char level_list_item_t[WAD_NAME]; 157 typedef char level_list_item_t[WAD_NAME];
163 level_list_item_t *level_list = 0; 158 level_list_item_t *level_list = NULL;
164 size_t nlevels = 0; 159 size_t nlevels = 0;
165 for (n = 0; n < wad->dirsize; n++) 160 for (n = 0; n < wad->dirsize; n++)
166 { 161 {
167 strncpy(entryname, wad->directory[n].name, WAD_NAME); 162 strncpy(entryname, wad->directory[n].name, WAD_NAME);
168 entryname[WAD_NAME] = '\0'; 163 entryname[WAD_NAME] = '\0';
329 } 324 }
330 verbmsg("\n"); 325 verbmsg("\n");
331 master_dir_serial.bump(); 326 master_dir_serial.bump();
332 327
333 // Print list of levels found in this pwad 328 // Print list of levels found in this pwad
334 if (level_list != 0) 329 if (level_list != NULL)
335 { 330 {
336 printf(" Levels: "); 331 printf(" Levels: ");
337 qsort(level_list, nlevels, sizeof *level_list, level_name_order); 332 qsort(level_list, nlevels, sizeof *level_list, level_name_order);
338 for (size_t n = 0; n < nlevels; n++) 333 for (size_t n = 0; n < nlevels; n++)
339 { 334 {
622 fatal_error("unable to open file \"%s\"", filename); 617 fatal_error("unable to open file \"%s\"", filename);
623 if (patchonly) 618 if (patchonly)
624 WriteBytes(file, "PWAD", 4); 619 WriteBytes(file, "PWAD", 4);
625 else 620 else
626 WriteBytes(file, "IWAD", 4); 621 WriteBytes(file, "IWAD", 4);
622
627 file_write_i32(file, 0xdeadbeef); /* put true value in later */ 623 file_write_i32(file, 0xdeadbeef); /* put true value in later */
628 file_write_i32(file, 0xdeadbeef); /* put true value in later */ 624 file_write_i32(file, 0xdeadbeef); /* put true value in later */
629 625
630 /* output the directory data chunks */ 626 /* output the directory data chunks */
631 const Wad_file *iwad = 0; // FIXME unreliable way of knowing the iwad 627 const Wad_file *iwad = 0; // FIXME unreliable way of knowing the iwad