From: DeaDDooMER Date: Sat, 6 Nov 2021 11:25:34 +0000 (+0300) Subject: portability: avoid errors on some compilers X-Git-Url: https://deadsoftware.ru/gitweb?p=flatwaifu.git;a=commitdiff_plain;h=HEAD portability: avoid errors on some compilers --- diff --git a/src/args.c b/src/args.c index 00df73a..99410f4 100644 --- a/src/args.c +++ b/src/args.c @@ -20,13 +20,13 @@ #include void ARG_parse (int argc, char **argv, int n, const cfg_t **list) { + int i, j; + char *key; + const cfg_t *c; assert(argc >= 0); assert(argv != NULL); assert(n >= 0); assert(list != NULL); - int i, j; - char *key; - const cfg_t *c; for (i = 1; i < argc; i++) { if (argv[i][0] == '-' && argv[i][1] != 0) { j = 0; diff --git a/src/bmap.c b/src/bmap.c index 0b165f2..89a36e2 100644 --- a/src/bmap.c +++ b/src/bmap.c @@ -47,8 +47,8 @@ void BM_clear(byte f) void BM_remapfld(void) { - BM_clear(BM_WALL); int x,y; + BM_clear(BM_WALL); for(x=0; x. */ -#include "cp866.h" +#include "common/cp866.h" int cp866_isalpha (int ch) { return (ch >= 0x41 && ch <= 0x5A) || (ch >= 0x61 && ch <= 0x7A) || (ch >= 0x80 && ch <= 0xAF) || (ch >= 0xE0 && ch <= 0xF7); diff --git a/src/common/endianness.h b/src/common/endianness.h index f4708b2..a70e20b 100644 --- a/src/common/endianness.h +++ b/src/common/endianness.h @@ -5,7 +5,7 @@ #define SWAP_VAR(a, b) do { unsigned char t = a; a = b; b = t; } while(0) -static inline int16_t short2swap (int16_t x) { +static /*inline*/ int16_t short2swap (int16_t x) { union { uint8_t a[2]; int16_t x; @@ -15,7 +15,7 @@ static inline int16_t short2swap (int16_t x) { return y.x; } -static inline int32_t int2swap (int32_t x) { +static /*inline*/ int32_t int2swap (int32_t x) { union { uint8_t a[4]; int32_t x; @@ -28,7 +28,7 @@ static inline int32_t int2swap (int32_t x) { #undef SWAP_VAR -static inline int16_t short2host (int16_t x) { +static /*inline*/ int16_t short2host (int16_t x) { #if __BIG_ENDIAN__ return short2swap(x); #else @@ -36,7 +36,7 @@ static inline int16_t short2host (int16_t x) { #endif } -static inline int32_t int2host (int32_t x) { +static /*inline*/ int32_t int2host (int32_t x) { #if __BIG_ENDIAN__ return int2swap(x); #else diff --git a/src/common/files.c b/src/common/files.c index 8961c03..f1eeb59 100644 --- a/src/common/files.c +++ b/src/common/files.c @@ -1,36 +1,40 @@ -#include "files.h" +#include "common/files.h" #include #include #include static long FILE_Stream_GetPos (Stream *r) { + long pos; FILE_Stream *rd = (FILE_Stream*)r; assert(rd != NULL); assert(rd->fp != NULL); - long pos = ftell(rd->fp); + pos = ftell(rd->fp); assert(pos != -1); // fail return pos; } static void FILE_Stream_SetPos (Stream *r, long pos) { + int res; FILE_Stream *rd = (FILE_Stream*)r; assert(rd != NULL); assert(rd->fp != NULL); assert(pos >= 0); - int res = fseek(rd->fp, pos, SEEK_SET); + res = fseek(rd->fp, pos, SEEK_SET); assert(res == 0); // fail } static long FILE_Stream_GetLen (Stream *r) { + int res; + long pos, len; FILE_Stream *rd = (FILE_Stream*)r; assert(rd != NULL); assert(rd->fp != NULL); - long pos = ftell(rd->fp); + pos = ftell(rd->fp); assert(pos != -1); // fail get cur pos - int res = fseek(rd->fp, 0, SEEK_END); + res = fseek(rd->fp, 0, SEEK_END); assert(res == 0); // fail jump to end - long len = ftell(rd->fp); + len = ftell(rd->fp); res = fseek(rd->fp, pos, SEEK_SET); assert(res == 0); // fail return assert(len != -1); // fail get length @@ -38,18 +42,20 @@ static long FILE_Stream_GetLen (Stream *r) { } static void FILE_Stream_Read (Stream *r, void *data, size_t size, size_t n) { + size_t res; FILE_Stream *rd = (FILE_Stream*)r; assert(rd != NULL); assert(rd->fp != NULL); - size_t res = fread(data, size, n, rd->fp); + res = fread(data, size, n, rd->fp); assert(res == n); // fail } static void FILE_Stream_Write (Stream *w, const void *data, size_t size, size_t n) { + size_t res; FILE_Stream *wr = (FILE_Stream*)w; assert(wr != NULL); assert(wr->fp != NULL); - size_t res = fwrite(data, size, n, wr->fp); + res = fwrite(data, size, n, wr->fp); assert(res == n); // fail } @@ -65,9 +71,10 @@ void FILE_Assign (FILE_Stream *r, FILE *fp) { } int FILE_Open (FILE_Stream *r, const char *name, const char *mode) { + FILE *fp; assert(r != NULL); assert(name != NULL); - FILE *fp = fopen(name, mode); + fp = fopen(name, mode); if (fp) { FILE_Assign(r, fp); } diff --git a/src/common/files.h b/src/common/files.h index a575ec1..e10798d 100644 --- a/src/common/files.h +++ b/src/common/files.h @@ -2,7 +2,7 @@ #define COMMON_FILES_H_INCLUDED #include -#include "streams.h" +#include "common/streams.h" typedef struct FILE_Stream { Stream base; diff --git a/src/common/streams.c b/src/common/streams.c index 995dac5..685ace1 100644 --- a/src/common/streams.c +++ b/src/common/streams.c @@ -1,5 +1,5 @@ -#include "streams.h" -#include "endianness.h" +#include "common/streams.h" +#include "common/endianness.h" #include #include diff --git a/src/common/wadres.c b/src/common/wadres.c index 43251c8..6ff943a 100644 --- a/src/common/wadres.c +++ b/src/common/wadres.c @@ -3,9 +3,9 @@ #include #include -#include "wadres.h" -#include "streams.h" -#include "cp866.h" +#include "common/wadres.h" +#include "common/streams.h" +#include "common/cp866.h" typedef struct Entry { long offset, size; @@ -28,8 +28,8 @@ static Block *blocks[MAX_RESOURCES]; static int s_start, s_end; static int check_header (Stream *r) { - assert(r != NULL); char ident[4]; + assert(r != NULL); stream_setpos(r, 0); // !!! stream_read(ident, 4, 1, r); return (memcmp(ident, "IWAD", 4) == 0) || (memcmp(ident, "PWAD", 4) == 0); @@ -47,8 +47,9 @@ int WADRES_addwad (Stream *r) { } static int WADRES_addresource (const Entry *e) { + int i; assert(e != NULL); - for (int i = 0; i < n_resources; ++i) { + for (i = 0; i < n_resources; ++i) { if (cp866_strncasecmp(resources[i].name, e->name, 8) == 0) { memcpy(&resources[i], e, sizeof(Entry)); return i; @@ -63,13 +64,14 @@ static int WADRES_addresource (const Entry *e) { } static int WADRES_read (int f) { + int ok = 1; + int32_t n, dir, i; Stream *r = wads[f]; stream_setpos(r, 4); // skip magic - int32_t n = stream_read32(r); - int32_t dir = stream_read32(r); + n = stream_read32(r); + dir = stream_read32(r); stream_setpos(r, dir); - int ok = 1; - for (int32_t i = 0; ok && i < n; ++i) { + for (i = 0; ok && i < n; ++i) { Entry e; e.offset = stream_read32(r); e.size = stream_read32(r); @@ -81,8 +83,9 @@ static int WADRES_read (int f) { } int WADRES_rehash (void) { + int i; int ok = 1; - for (int i = 0; i < n_wads; ++i) { + for (i = 0; i < n_wads; ++i) { if (!WADRES_read(i)) { ok = 0; } @@ -105,9 +108,10 @@ int WADRES_maxids (void) { } int WADRES_findsprite (const char n[4], int s, int d, char *dir) { + int i; s += 'A'; d += '0'; - for (int i = s_start + 1; i < s_end; i++) { + for (i = s_start + 1; i < s_end; i++) { char a, b; char *wn = resources[i].name; if (cp866_strncasecmp(wn, n, 4) == 0 && (wn[4] == s || wn[6] == s)) { @@ -145,9 +149,11 @@ void WADRES_getname (int id, char *name) { } void WADRES_getdata (int id, void *data) { + long pos; + Stream *r; assert(id >= 0 && id < n_resources); - Stream *r = wads[resources[id].f]; - long pos = stream_getpos(r); + r = wads[resources[id].f]; + pos = stream_getpos(r); stream_setpos(r, resources[id].offset); stream_read(data, resources[id].size, 1, r); stream_setpos(r, pos); @@ -175,9 +181,11 @@ void *WADRES_lock (int id) { } void WADRES_unlock (void *data) { + int id; + Block *x; if (data) { - Block *x = data - sizeof(Block); - int id = x->id; + x = (Block*)((uintptr_t)data - sizeof(Block)); + id = x->id; assert(id >= 0 && id < MAX_RESOURCES); x->ref -= 1; assert(x->ref >= 0); diff --git a/src/common/wadres.h b/src/common/wadres.h index c1be63a..8ca3835 100644 --- a/src/common/wadres.h +++ b/src/common/wadres.h @@ -1,7 +1,7 @@ #ifndef COMMON_WADRES_H_INCLUDED #define COMMON_WADRES_H_INCLUDED -#include "streams.h" +#include "common/streams.h" #define MAX_WADS 20 #define MAX_RESOURCES 2000 diff --git a/src/config.c b/src/config.c index 86b6d22..78664aa 100644 --- a/src/config.c +++ b/src/config.c @@ -42,9 +42,10 @@ const cfg_t *CFG_find_entry (const char *key, const cfg_t *cfg) { } int CFG_update_key (const char *key, const char *value, const cfg_t *cfg) { + const cfg_t *entry; assert(key != NULL); assert(value != NULL); - const cfg_t *entry = CFG_find_entry(key, cfg); + entry = CFG_find_entry(key, cfg); if (entry != NULL) { void *p = entry->p; switch (entry->t) { @@ -92,12 +93,12 @@ static void CFG_skip_line (void) { } int CFG_scan_iterator (char *key, int keylen, char *value, int valuelen) { + int i; + int found = 0; assert(key != NULL); assert(keylen > 0); assert(value != NULL); assert(valuelen > 0); - int i; - int found = 0; while (feof(f) == 0 && found == 0) { CFG_skip_space(); if (ch == ';') { @@ -142,13 +143,13 @@ void CFG_close_iterator (void) { /* --- reader --- */ int CFG_read_config (const char *name, int n, const cfg_t **cfg) { - assert(name != NULL); - assert(n >= 0); - assert(cfg != NULL); int i; char key[64]; char value[64]; assert(name != NULL); + assert(n >= 0); + assert(cfg != NULL); + assert(name != NULL); if (CFG_open_iterator(name)) { while (CFG_scan_iterator(key, 64, value, 64)) { i = 0; @@ -178,11 +179,12 @@ static void CFG_write_key_value (FILE *f, const char *key, const char *value) { } static int CFG_write_entry (FILE *f, const cfg_t *entry) { - assert(f != NULL); - assert(entry != NULL); char buf[16]; const char *str; - const char *key = entry->cfg; + const char *key; + assert(f != NULL); + assert(entry != NULL); + key = entry->cfg; if (key != NULL) { switch (entry->t) { case Y_BYTE: @@ -218,14 +220,15 @@ static int CFG_write_entry (FILE *f, const cfg_t *entry) { } int CFG_update_config (const char *old, const char *new, int n, const cfg_t **cfg, const char *msg) { + int i, j; + char key[64]; + char value[64]; + FILE *nf; assert(old != NULL); assert(new != NULL); assert(n >= 0); assert(cfg != NULL); - int i, j; - char key[64]; - char value[64]; - FILE *nf = fopen(new, "wb"); + nf = fopen(new, "wb"); if (nf != NULL) { if (msg != NULL) { fwrite("; ", 2, 1, nf); diff --git a/src/map.c b/src/map.c index 8f1fb68..d70a4fb 100644 --- a/src/map.c +++ b/src/map.c @@ -271,9 +271,10 @@ static int W_load (Stream *h) { } int MAP_load (Stream *r) { - assert(r != NULL); int ok = 0; + long off; map_header_t hdr; + assert(r != NULL); W_init(); // reset all game data stream_read(hdr.id, 8, 1, r); hdr.ver = stream_read16(r); @@ -283,7 +284,7 @@ int MAP_load (Stream *r) { blk.t = stream_read16(r); blk.st = stream_read16(r); blk.sz = stream_read32(r); - long off = stream_getpos(r) + blk.sz; + off = stream_getpos(r) + blk.sz; switch (blk.t) { case MB_MUSIC: ok = G_load(r); diff --git a/src/menu.c b/src/menu.c index 688fc25..037782a 100644 --- a/src/menu.c +++ b/src/menu.c @@ -157,7 +157,7 @@ static int start_game (int twoplayers, int dm, int level) { static int new_game_menu_handler (menu_msg_t *msg, const menu_t *m, int i) { static int cur; - enum { ONEPLAYER, TWOPLAYERS, DEATHMATCH, __NUM__ }; + enum { ONEPLAYER, TWOPLAYERS, DEATHMATCH, NG__NUM__ }; static const simple_menu_t sm = { GM_BIG, "New Game", "_NEWGAME", { @@ -174,7 +174,7 @@ static int new_game_menu_handler (menu_msg_t *msg, const menu_t *m, int i) { // GM_say("_COOP"); } } - return simple_menu_handler(msg, i, __NUM__, &sm, &cur); + return simple_menu_handler(msg, i, NG__NUM__, &sm, &cur); } static int load_game_menu_handler (menu_msg_t *msg, const menu_t *m, int i) { @@ -263,7 +263,11 @@ static int controls_menu_handler (menu_msg_t *msg, const menu_t *m, int i) { case GM_GETCAPTION: return GM_init_str(msg, (char*)captions[i], strlen(captions[i])); case GM_GETSTR: - str = state == 0 || i != cur ? I_key_to_string(mm->pl_keys[i]) : "..."; + if (state == 0 || i != cur) { + str = I_key_to_string(mm->pl_keys[i]); + } else { + str = "..."; + } return GM_init_str(msg, (char*)str, strlen(str)); case GM_SELECT: state = state == 0 ? 1 : 0; @@ -275,7 +279,7 @@ static int controls_menu_handler (menu_msg_t *msg, const menu_t *m, int i) { static int options_menu_handler (menu_msg_t *msg, const menu_t *m, int i) { static int cur; const menu_t *mm; - enum { VIDEO, SOUND, MUSIC, CONTROLS_1, CONTROLS_2, __NUM__ }; + enum { VIDEO, SOUND, MUSIC, CONTROLS_1, CONTROLS_2, OPT__NUM__ }; static const controls_menu_t c1 = { { controls_menu_handler }, &pl1.ku @@ -305,12 +309,12 @@ static int options_menu_handler (menu_msg_t *msg, const menu_t *m, int i) { return GM_push(mm); } } - return simple_menu_handler(msg, i, __NUM__, &sm, &cur); + return simple_menu_handler(msg, i, OPT__NUM__, &sm, &cur); } static int exit_menu_handler (menu_msg_t *msg, const menu_t *m, int i) { static int cur; - enum { YES, NO, __NUM__ }; + enum { YES, NO, EXIT__NUM__ }; static const simple_menu_t sm = { GM_SMALL, "You are sure?", NULL, { @@ -333,14 +337,13 @@ static int exit_menu_handler (menu_msg_t *msg, const menu_t *m, int i) { return GM_pop(); } } - return simple_menu_handler(msg, i, __NUM__, &sm, &cur); + return simple_menu_handler(msg, i, EXIT__NUM__, &sm, &cur); } static int main_menu_handler (menu_msg_t *msg, const menu_t *m, int i) { - enum { NEWGAME, OLDGAME, SAVEGAME, OPTIONS, EXIT, __NUM__ }; - assert(i >= 0 && i < __NUM__); + enum { NEWGAME, OLDGAME, SAVEGAME, OPTIONS, EXIT, MAIN__NUM__ }; static int cur; - static const menu_t hm[__NUM__] = { + static const menu_t hm[MAIN__NUM__] = { { new_game_menu_handler }, { load_game_menu_handler }, { save_game_menu_handler }, @@ -357,16 +360,17 @@ static int main_menu_handler (menu_msg_t *msg, const menu_t *m, int i) { { "Exit", &hm[EXIT] } } }; - return simple_menu_handler(msg, i, __NUM__, &sm, &cur); + assert(i >= 0 && i < MAIN__NUM__); + return simple_menu_handler(msg, i, MAIN__NUM__, &sm, &cur); } static const menu_t main_menu = { &main_menu_handler }; int GM_push (const menu_t *m) { + menu_msg_t msg; assert(m != NULL); assert(stack_p >= -1); assert(stack_p < MAX_STACK - 1); - menu_msg_t msg; stack_p += 1; stack[stack_p].m = m; msg.type = GM_ENTER; @@ -375,8 +379,8 @@ int GM_push (const menu_t *m) { } int GM_pop (void) { - assert(stack_p >= 0); menu_msg_t msg; + assert(stack_p >= 0); stack_p -= 1; msg.type = GM_LEAVE; GM_send_this(stack[stack_p + 1].m, &msg); diff --git a/src/monster.c b/src/monster.c index 48bf8f4..77a161d 100644 --- a/src/monster.c +++ b/src/monster.c @@ -91,28 +91,28 @@ static void *snd[MN_TN][5],*impsitsnd[2],*impdthsnd[2],*firsnd,*slopsnd,*gsnd[4] static void *swgsnd,*pchsnd,*telesnd; static void *positsnd[3],*podthsnd[3]; static mnsz_t mnsz[MN_TN+1]={ -//rad ht life pain rv jv slop min_pn - 0, 0, 0, 0, 0, 0, 0, 0, // none - 15, 28, 60, 20, 7,10, 0, 10, // demon - 10, 28, 25, 15, 3,10, 30, 0, // imp - 10, 28, 15, 10, 3,10, 30, 0, // zomby - 10, 28, 20, 10, 3,10, 30, 0, // sergeant - 20, 55, 500, 70, 5,10, 0, 50, // cyberdemon - 12, 28, 60, 20, 3,10, 30, 10, // chaingunner - 12, 32, 150, 40, 3,10, 0, 30, // baron of hell - 12, 32, 75, 40, 3,10, 0, 30, // hell knight - 15, 28, 100, 10, 4, 4, 0, 0, // cacodemon - 8, 18, 60, 10, 4, 4, 0, 0, // lost soul - 15, 28, 100, 10, 4, 4, 0, 0, // pain elemental - 64, 50, 500, 70, 4,10, 0, 50, // spider mastermind - 25, 27, 150, 20, 4,10, 0, 0, // arachnotron - 18, 30, 200, 40, 3, 7, 0, 20, // mancubus - 17, 36, 200, 40, 6,11, 0, 20, // revenant - 17, 36, 150, 30, 7,12, 0, 10, // archvile - 5, 5, 35, 20,14, 6, 0, 10, // fish - 5, 17, 20, 0, 7, 6, 0, 0, // barrel - 17, 38, 20, 40, 3, 6, 0, 20, // robot - 8, 26, 400, 70, 8,10, 30, 50 // man + /* rad ht life pain rv jv slop min_pn */ + { 0, 0, 0, 0, 0, 0, 0, 0 }, // none + { 15, 28, 60, 20, 7, 10, 0, 10 }, // demon + { 10, 28, 25, 15, 3, 10, 30, 0 }, // imp + { 10, 28, 15, 10, 3, 10, 30, 0 }, // zomby + { 10, 28, 20, 10, 3, 10, 30, 0 }, // sergeant + { 20, 55, 500, 70, 5, 10, 0, 50 }, // cyberdemon + { 12, 28, 60, 20, 3, 10, 30, 10 }, // chaingunner + { 12, 32, 150, 40, 3, 10, 0, 30 }, // baron of hell + { 12, 32, 75, 40, 3, 10, 0, 30 }, // hell knight + { 15, 28, 100, 10, 4, 4, 0, 0 }, // cacodemon + { 8, 18, 60, 10, 4, 4, 0, 0 }, // lost soul + { 15, 28, 100, 10, 4, 4, 0, 0 }, // pain elemental + { 64, 50, 500, 70, 4, 10, 0, 50 }, // spider mastermind + { 25, 27, 150, 20, 4, 10, 0, 0 }, // arachnotron + { 18, 30, 200, 40, 3, 7, 0, 20 }, // mancubus + { 17, 36, 200, 40, 6, 11, 0, 20 }, // revenant + { 17, 36, 150, 30, 7, 12, 0, 10 }, // archvile + { 5, 5, 35, 20, 14, 6, 0, 10 }, // fish + { 5, 17, 20, 0, 7, 6, 0, 0 }, // barrel + { 17, 38, 20, 40, 3, 6, 0, 20 }, // robot + { 8, 26, 400, 70, 8, 10, 30, 50 } // man }; void setst (int i, int st) { diff --git a/src/save.c b/src/save.c index a219fdf..1fc4441 100644 --- a/src/save.c +++ b/src/save.c @@ -111,6 +111,7 @@ static void FX_loadgame (Stream *h) { } static void G_savegame (Stream *h) { + int i = 0; stream_write8(_2pl, h); stream_write8(g_dm, h); stream_write8(g_exit, h); @@ -119,7 +120,6 @@ static void G_savegame (Stream *h) { stream_write32(dm_pl1p, h); stream_write32(dm_pl2p, h); stream_write32(dm_pnum, h); - int i = 0; while (i < dm_pnum) { stream_write32(dm_pos[i].x, h); stream_write32(dm_pos[i].y, h); @@ -131,6 +131,7 @@ static void G_savegame (Stream *h) { } static void G_loadgame (Stream *h) { + int i = 0; _2pl = stream_read8(h); g_dm = stream_read8(h); g_exit = stream_read8(h); @@ -139,7 +140,6 @@ static void G_loadgame (Stream *h) { dm_pl1p = stream_read32(h); dm_pl2p = stream_read32(h); dm_pnum = stream_read32(h); - int i = 0; while (i < dm_pnum) { dm_pos[i].x = stream_read32(h); dm_pos[i].y = stream_read32(h); @@ -567,7 +567,8 @@ void SAVE_load (Stream *h) { } int SAVE_getname (Stream *r, char name[24]) { + int16_t version; stream_read(name, 24, 1, r); - int16_t version = stream_read16(r); + version = stream_read16(r); return version == 3; } diff --git a/src/stubsys/files.c b/src/stubsys/files.c index 7ccfe4e..5400544 100644 --- a/src/stubsys/files.c +++ b/src/stubsys/files.c @@ -167,10 +167,11 @@ static char *getsavfpname (int n, int ro) { void F_getsavnames (void) { int i; + char *p; FILE_Stream rd; for (i = 0; i < SAVE_MAX; ++i) { savok[i] = 0; - char *p = getsavfpname(i, 1); + p = getsavfpname(i, 1); if (FILE_Open(&rd, p, "rb")) { savok[i] = SAVE_getname(&rd.base, savname[i]); FILE_Close(&rd); diff --git a/src/stubsys/main.c b/src/stubsys/main.c index 75ddd86..c3e1b40 100644 --- a/src/stubsys/main.c +++ b/src/stubsys/main.c @@ -93,18 +93,30 @@ static const cfg_t cfg[] = { }; static void CFG_args (int argc, char **argv) { - const cfg_t *list[] = { arg, R_args(), S_args(), MUS_args() }; + const cfg_t *list[4]; + list[0] = arg; + list[1] = R_args(); + list[2] = S_args(); + list[3] = MUS_args(); ARG_parse(argc, argv, 4, list); } static void CFG_load (void) { - const cfg_t *list[] = { cfg, R_conf(), S_conf(), MUS_conf() }; + const cfg_t *list[4]; + list[0] = cfg; + list[1] = R_conf(); + list[2] = S_conf(); + list[3] = MUS_conf(); CFG_read_config("default.cfg", 4, list); CFG_read_config("doom2d.cfg", 4, list); } static void CFG_save (void) { - const cfg_t *list[] = { cfg, R_conf(), S_conf(), MUS_conf() }; + const cfg_t *list[4]; + list[0] = cfg; + list[1] = R_conf(); + list[2] = S_conf(); + list[3] = MUS_conf(); CFG_update_config("doom2d.cfg", "doom2d.cfg", 4, list, "generated by doom2d, do not modify"); } @@ -160,9 +172,10 @@ int Y_set_videomode_opengl (int w, int h, int fullscreen) { } int Y_set_videomode_software (int w, int h, int fullscreen) { + void *buf; assert(w > 0); assert(h > 0); - void *buf = softbuffer ? realloc(softbuffer, w * h) : malloc(w * h); + buf = softbuffer ? realloc(softbuffer, w * h) : malloc(w * h); if (buf) { mode = MODE_SOFTWARE; softbuffer = buf; @@ -214,8 +227,7 @@ void Y_swap_buffers (void) { void Y_get_buffer (byte **buf, int *w, int *h, int *pitch) { assert(mode == MODE_SOFTWARE); - // *buf = surf->pixels; - *buf = NULL; // fix this + *buf = softbuffer; *w = width; *h = height; *pitch = width; @@ -223,7 +235,7 @@ void Y_get_buffer (byte **buf, int *w, int *h, int *pitch) { void Y_set_vga_palette (byte *vgapal) { int i; - byte *p = vgapal; + //byte *p = vgapal; assert(vgapal != NULL); assert(mode == MODE_SOFTWARE); } @@ -251,9 +263,10 @@ static void poll_events (void) { } static void step (void) { + clock_t t; poll_events(); MUS_update(); - clock_t t = clock(); + t = clock(); if ((t - ticks) * 1000 / CLOCKS_PER_SEC > DELAY) { ticks = t; G_act();