Mercurial > hg > forks > yadex
changeset 79:0602d9bf474a
Various cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 26 Sep 2011 17:14:54 +0300 |
parents | 626678d4ecf3 |
children | 2f1ecc1c5f72 |
files | src/acolours.cc src/aym.cc src/colour4.cc src/dialog.cc src/game.cc src/l_prop.cc src/l_super.h src/s_prop.cc src/t_prop.cc src/wadres.h src/wads.cc src/wads2.cc src/yadex.h |
diffstat | 13 files changed, 34 insertions(+), 65 deletions(-) [+] |
line wrap: on
line diff
--- a/src/acolours.cc Mon Sep 26 17:05:58 2011 +0300 +++ b/src/acolours.cc Mon Sep 26 17:14:54 2011 +0300 @@ -70,10 +70,9 @@ if (i == table_size) { table_size++; - table = - (ac_table_entry_t *) realloc(table, table_size * sizeof *table); + table = (ac_table_entry_t *) realloc(table, table_size * sizeof *table); if (table == NULL) - fatal_error(msg_nomem); + fatal_error("Not enough memory."); } ac_count++; table[i].rgb = rgb;
--- a/src/aym.cc Mon Sep 26 17:05:58 2011 +0300 +++ b/src/aym.cc Mon Sep 26 17:14:54 2011 +0300 @@ -273,7 +273,7 @@ for (;;) { const char *haystack = va_arg(args, const char *); - if (haystack == Y_NULL) + if (haystack == NULL) break; if (!strcmp(needle, haystack)) return 1;
--- a/src/colour4.cc Mon Sep 26 17:05:58 2011 +0300 +++ b/src/colour4.cc Mon Sep 26 17:14:54 2011 +0300 @@ -58,7 +58,7 @@ * Convert an 8-bit RGB component value to a 16-bit one. * Will convert 00h to 0000h, 80h to 8080h and FFh to FFFFh. */ -inline u16 eight2sixteen(u8 v) +static inline u16 eight2sixteen(u8 v) { return (v << 8) | v; } @@ -75,7 +75,7 @@ pcolour_t *pcn_table = (pcolour_t *) malloc(count * sizeof *pcn_table); if (pcn_table == NULL) - fatal_error(msg_nomem); + fatal_error("Not enough memory."); /* Allocate the physical colours if necessary. Should not do it for static visuals (StaticColor, TrueColor). It does no @@ -113,7 +113,7 @@ pcolours = (pcolours_table_entry_t *) realloc(pcolours, physical_colours * sizeof *pcolours); if (pcolours == NULL) - fatal_error(msg_nomem); + fatal_error("Not enough memory."); pcolours[physical_colours - 1].pcn = (pcolour_t) xc.pixel; pcolours[physical_colours - 1].rgb = rgb_values[n]; pcolours[physical_colours - 1].usage_count = 1; @@ -217,7 +217,7 @@ pcolours_table_entry_t *new_pcolours = (pcolours_table_entry_t *) malloc(new_physical_colours * sizeof *new_pcolours); if (new_pcolours == NULL) - fatal_error(msg_nomem); + fatal_error("Not enough memory."); new_item = new_pcolours; for (size_t i = 0; i < physical_colours; i++) if (pcolours[i].pcn != PCOLOUR_NONE)
--- a/src/dialog.cc Mon Sep 26 17:05:58 2011 +0300 +++ b/src/dialog.cc Mon Sep 26 17:14:54 2011 +0300 @@ -176,27 +176,6 @@ /* - * debmes - Display a message in a box only if in debug mode - * - * Simple wrapper around Notify(). Don't try to make it display - * more than 200 characters or you'll crash the program. - * BUG: if result of formatting contains "%"'s, it will be - * formatted again... - */ -void debmes(const char *fmt, ...) -{ - char buf[200]; - va_list arglist; - - if (Debug != 1) - return; - va_start(arglist, fmt); - y_vsnprintf(buf, sizeof buf, fmt, arglist); - Notify(-1, -1, buf, NULL); -} - - -/* * DisplayMessage - clear the screen and display a message */ void DisplayMessage(int x0, int y0, const char *msg, ...)
--- a/src/game.cc Mon Sep 26 17:05:58 2011 +0300 +++ b/src/game.cc Mon Sep 26 17:14:54 2011 +0300 @@ -34,7 +34,6 @@ #include "gamesky.h" #include "locate.h" #include "things.h" -#include "trace.h" const char ygd_file_magic[] = "# Yadex game definition file version 4";
--- a/src/l_prop.cc Mon Sep 26 17:05:58 2011 +0300 +++ b/src/l_prop.cc Mon Sep 26 17:14:54 2011 +0300 @@ -487,7 +487,7 @@ PrintLdtgroup, &ldtgno) < 0) return 1; if (al_lseek(ldtgroup, ldtgno, SEEK_SET)) - fatal_error("%s ILT1 (%s)", msg_unexpected, + fatal_error("%s ILT1 (%s)", "unexpected error", al_astrerror(al_aerrno)); ldtg = CUR_LDTGROUP->ldtgroup; @@ -521,7 +521,7 @@ if (r < 0) goto again; if (al_lseek(list, r, SEEK_SET)) - fatal_error("%s ILT2 (%s)", msg_unexpected, + fatal_error("%s ILT2 (%s)", "unexpected error", al_astrerror(al_aerrno)); *number = (*((ldtdef_t **) al_lptr(list)))->number; al_ldiscard(list);
--- a/src/l_super.h Mon Sep 26 17:05:58 2011 +0300 +++ b/src/l_super.h Mon Sep 26 17:14:54 2011 +0300 @@ -98,7 +98,6 @@ if (!is_linedef(refldno)) return -1; - const struct LineDef *const pmax = LineDefs + NumLineDefs; const struct LineDef *const pref = LineDefs + refldno; const wad_vn_t refv0 = pref->start;
--- a/src/s_prop.cc Mon Sep 26 17:05:58 2011 +0300 +++ b/src/s_prop.cc Mon Sep 26 17:14:54 2011 +0300 @@ -231,7 +231,7 @@ { if (al_lseek(stdef, val, SEEK_SET)) fatal_error("%s SP1 (%s)\n", - msg_unexpected, al_astrerror(al_aerrno)); + "unexpected error", al_astrerror(al_aerrno)); val = CUR_STDEF->number; } for (cur = obj; cur; cur = cur->next) @@ -308,7 +308,7 @@ { if (al_lseek(stdef, val, SEEK_SET)) fatal_error("%s SP1 (%s)\n", - msg_unexpected, al_astrerror(al_aerrno)); + "unexpected error", al_astrerror(al_aerrno)); val = CUR_STDEF->number; } if (val < 0)
--- a/src/t_prop.cc Mon Sep 26 17:05:58 2011 +0300 +++ b/src/t_prop.cc Mon Sep 26 17:14:54 2011 +0300 @@ -264,7 +264,7 @@ PrintThinggroup, &tgno) < 0) return 1; if (al_lseek(thinggroup, tgno, SEEK_SET)) - fatal_error("%s ITT1 (%s)", msg_unexpected, + fatal_error("%s ITT1 (%s)", "unexpected error", al_astrerror(al_aerrno)); tg = CUR_THINGGROUP->thinggroup; @@ -297,7 +297,7 @@ if (r < 0) goto again; if (al_lseek(list, r, SEEK_SET)) - fatal_error("%s ITT2 (%s)", msg_unexpected, + fatal_error("%s ITT2 (%s)", "unexpected error", al_astrerror(al_aerrno)); *number = (*((thingdef_t **) al_lptr(list)))->number; al_ldiscard(list);
--- a/src/wadres.h Mon Sep 26 17:05:58 2011 +0300 +++ b/src/wadres.h Mon Sep 26 17:14:54 2011 +0300 @@ -48,7 +48,8 @@ - Lump_cache textures (TEXTURE[12]) - Lump_cache pnames (PNAMES) - Lump_cache palette (PLAYPAL, first 768 bytes) */ - private:}; + private: +}; extern Wad_res wad_res;
--- a/src/wads.cc Mon Sep 26 17:05:58 2011 +0300 +++ b/src/wads.cc Mon Sep 26 17:14:54 2011 +0300 @@ -172,13 +172,13 @@ MDirPtr FindMasterDir(MDirPtr from, const char *name) { - while (from) + while (from != NULL) { if (!y_strnicmp(from->dir.name, name, WAD_NAME)) - break; + return from; from = from->next; } - return from; + return NULL; } @@ -187,14 +187,14 @@ */ MDirPtr FindMasterDir(MDirPtr from, const char *name1, const char *name2) { - while (from) + while (from != NULL) { - if (!y_strnicmp(from->dir.name, name1, WAD_NAME) - || !y_strnicmp(from->dir.name, name2, WAD_NAME)) - break; + if (!y_strnicmp(from->dir.name, name1, WAD_NAME) || + !y_strnicmp(from->dir.name, name2, WAD_NAME)) + return from; from = from->next; } - return from; + return NULL; } @@ -262,7 +262,6 @@ } byebye: - if (data != 0) - FreeMemory(data); + FreeMemory(data); return rc; }
--- a/src/wads2.cc Mon Sep 26 17:05:58 2011 +0300 +++ b/src/wads2.cc Mon Sep 26 17:14:54 2011 +0300 @@ -55,7 +55,7 @@ long n; Wad_file *wf; -/* open the wad file */ + /* open the wad file */ printf("Loading iwad: %s...\n", filename); wf = BasicWadOpen(filename, yg_picture_format); if (wf == 0) @@ -64,7 +64,7 @@ warn("%.128s: is a pwad, not an iwad. Will use it anyway.\n", filename); -/* create the master directory */ + /* create the master directory */ lastp = NULL; for (n = 0; n < wf->dirsize; n++) { @@ -88,17 +88,12 @@ && strcmp(Game, "doom04") && strcmp(Game, "doom05") && strcmp(Game, "doompr")) { - printf - (" *-----------------------------------------------------*\n"); - printf - (" | Warning: this is the shareware version of the game. |\n"); - printf - (" | You won't be allowed to save your changes. |\n"); - printf - (" | PLEASE REGISTER YOUR COPY OF THE GAME. |\n"); - printf - (" *-----------------------------------------------------*\n"); Registered = false; // If you remove this, bad things will happen to you... + printf(" *-----------------------------------------------------*\n"); + printf(" | Warning: this is the shareware version of the game. |\n"); + printf(" | You won't be allowed to save your changes. |\n"); + printf(" | PLEASE REGISTER YOUR COPY OF THE GAME. |\n"); + printf(" *-----------------------------------------------------*\n"); } else Registered = true; @@ -160,7 +155,7 @@ int names = 0; // Number of names already printed on current line const char *entry_type_prev; typedef char level_list_item_t[WAD_NAME]; - level_list_item_t *level_list = 0; + level_list_item_t *level_list = NULL; size_t nlevels = 0; for (n = 0; n < wad->dirsize; n++) { @@ -331,7 +326,7 @@ master_dir_serial.bump(); // Print list of levels found in this pwad - if (level_list != 0) + if (level_list != NULL) { printf(" Levels: "); qsort(level_list, nlevels, sizeof *level_list, level_name_order); @@ -624,6 +619,7 @@ WriteBytes(file, "PWAD", 4); else WriteBytes(file, "IWAD", 4); + file_write_i32(file, 0xdeadbeef); /* put true value in later */ file_write_i32(file, 0xdeadbeef); /* put true value in later */
--- a/src/yadex.h Mon Sep 26 17:05:58 2011 +0300 +++ b/src/yadex.h Mon Sep 26 17:14:54 2011 +0300 @@ -115,7 +115,6 @@ */ #define y_min(a,b) ((a) < (b) ? (a) : (b)) #define y_max(a,b) ((a) > (b) ? (a) : (b)) -const char *const Y_NULL = 0; // NULL (const char *) /* @@ -300,8 +299,6 @@ */ extern const char *const log_file; // "yadex.log" -extern const char *const msg_unexpected; // "unexpected error" -extern const char *const msg_nomem; // "Not enough memory" // Convert screen/window coordinates to map coordinates #define MAPX(x) (OrigX + (int) (((int) (x) - ScrCenterX) / Scale))