doom

a minimalistic implementation of doom
git clone git://ssnf.xyz/doom
Log | Files | Refs

commit 6b38d7667e280487d834ebd50e84daae53691cee
parent d50af960b6b3a4f0c59a5bd3713afd969ee83503
Author: ssnf <ssnf@ssnf.xyz>
Date:   Thu, 17 Jun 2021 03:45:50 +0000

really compile now

Diffstat:
Msrc/am_map.c | 23+++++------------------
Msrc/d_net.c | 22+++++++++-------------
Msrc/doomdef.h | 1+
Msrc/g_game.c | 17+++++------------
Msrc/hu_lib.c | 2--
Msrc/m_fixed.c | 2+-
Msrc/m_menu.c | 15+++++++--------
Msrc/p_doors.c | 2--
Msrc/p_enemy.c | 2--
Msrc/p_saveg.c | 23+++++++++++------------
Msrc/p_spec.c | 5+----
Msrc/r_draw.c | 2+-
Msrc/w_wad.c | 8+++-----
Msrc/wi_stuff.c | 3+--
Msrc/z_zone.c | 52+++-------------------------------------------------
15 files changed, 48 insertions(+), 131 deletions(-)

diff --git a/src/am_map.c b/src/am_map.c @@ -390,7 +390,6 @@ AM_Responder ( event_t* ev ) { int rc; - static int cheatstate=0; static int bigstate=0; static char buffer[20]; rc = false; @@ -465,7 +464,6 @@ AM_Responder plr->message = AMSTR_MARKSCLEARED; break; default: - cheatstate=0; rc = false; } if (!deathmatch && cht_CheckCheat(&cheat_amap, ev->data1)) @@ -523,18 +521,7 @@ void AM_doFollowPlayer(void) f_oldloc.y = plr->mo->y; } } -void AM_updateLightLev(void) -{ - static nexttic = 0; - static int litelevels[] = { 0, 4, 7, 10, 12, 14, 15, 15 }; - static int litelevelscnt = 0; - if (amclock>nexttic) - { - lightlev = litelevels[litelevelscnt++]; - if (litelevelscnt == sizeof(litelevels)/sizeof(int)) litelevelscnt = 0; - nexttic = amclock + 6 - (amclock % 6); - } -} + void AM_Ticker (void) { if (!automapactive) @@ -563,9 +550,9 @@ AM_clipMline BOTTOM =4, TOP =8 }; - register outcode1 = 0; - register outcode2 = 0; - register outside; + int outside; + int outcode1 = 0; + int outcode2 = 0; fpoint_t tmp; int dx; int dy; @@ -667,7 +654,7 @@ AM_drawFline register int ax; register int ay; register int d; - static fuck = 0; + static int fuck = 0; if ( fl->a.x < 0 || fl->a.x >= f_w || fl->a.y < 0 || fl->a.y >= f_h || fl->b.x < 0 || fl->b.x >= f_w diff --git a/src/d_net.c b/src/d_net.c @@ -32,23 +32,19 @@ void G_BuildTiccmd (ticcmd_t *cmd); void D_DoAdvanceDemo (void); boolean reboundpacket; doomdata_t reboundstore; -int NetbufferSize (void) + +int +NetbufferSize() { - return (int)&(((doomdata_t *)0)->cmds[netbuffer->numtics]); + return (long)&(((doomdata_t *)0)->cmds[netbuffer->numtics]); } -unsigned NetbufferChecksum (void) + +unsigned +NetbufferChecksum() { - unsigned c; - int i,l; - c = 0x1234567; -#ifdef NORMALUNIX return 0; -#endif - l = (NetbufferSize () - (int)&(((doomdata_t *)0)->retransmitfrom))/4; - for (i=0 ; i<l ; i++) - c += ((unsigned *)&netbuffer->retransmitfrom)[i] * (i+1); - return c & NCMD_CHECKSUM; } + int ExpandTics (int low) { int delta; @@ -296,7 +292,7 @@ void CheckAbort (void) I_StartTic (); I_StartTic (); for ( ; eventtail != eventhead - ; eventtail = (++eventtail)&(MAXEVENTS-1) ) + ; eventtail = (eventtail + 1)&(MAXEVENTS-1) ) { ev = &events[eventtail]; if (ev->type == ev_keydown && ev->data1 == KEY_ESCAPE) diff --git a/src/doomdef.h b/src/doomdef.h @@ -19,6 +19,7 @@ typedef enum pack_plut, none } GameMission_t; + typedef enum { english, diff --git a/src/g_game.c b/src/g_game.c @@ -300,10 +300,7 @@ void G_DoLoadLevel (void) { int i; skyflatnum = R_FlatNumForName ( SKYFLATNAME ); - if ( (gamemode == commercial) - || ( gamemode == pack_tnt ) - || ( gamemode == pack_plut ) ) - { + if ( (gamemode == commercial) || (gamemode == retail)) { skytexture = R_TextureNumForName ("SKY3"); if (gamemap < 12) skytexture = R_TextureNumForName ("SKY1"); @@ -330,8 +327,8 @@ void G_DoLoadLevel (void) joyxmove = joyymove = 0; mousex = mousey = 0; sendpause = sendsave = paused = false; - memset (mousebuttons, 0, sizeof(mousebuttons)); - memset (joybuttons, 0, sizeof(joybuttons)); + memset(mousebuttons, 0, sizeof(*mousebuttons)); + memset(joybuttons, 0, sizeof(*joybuttons)); } boolean G_Responder (event_t* ev) { @@ -540,8 +537,6 @@ void G_Ticker (void) } void G_InitPlayer (int player) { - player_t* p; - p = &players[player]; G_PlayerReborn (player); } void G_PlayerFinishLevel (int player) @@ -850,17 +845,15 @@ void G_LoadGame (char* name) #define VERSIONSIZE 16 void G_DoLoadGame (void) { - int length; int i; int a,b,c; char vcheck[VERSIONSIZE]; gameaction = ga_nothing; - length = M_ReadFile (savename, &savebuffer); save_p = savebuffer + SAVESTRINGSIZE; memset (vcheck,0,sizeof(vcheck)); sprintf (vcheck,"version %i",VERSION); - if (strcmp (save_p, vcheck)) - return; + if (strcmp((char*)save_p, vcheck)) + return; save_p += VERSIONSIZE; gameskill = *save_p++; gameepisode = *save_p++; diff --git a/src/hu_lib.c b/src/hu_lib.c @@ -96,7 +96,6 @@ void HUlib_eraseTextLine(hu_textline_t* l) int lh; int y; int yoffset; - static boolean lastautomapactive = true; if (!automapactive && viewwindowx && l->needsupdate) { @@ -112,7 +111,6 @@ void HUlib_eraseTextLine(hu_textline_t* l) } } } - lastautomapactive = automapactive; if (l->needsupdate) l->needsupdate--; } void diff --git a/src/m_fixed.c b/src/m_fixed.c @@ -10,7 +10,7 @@ FixedMul ( fixed_t a, fixed_t b ) { - return ((long long) a * (long long) b) >> FRACBITS; + return ((long) a * (long) b) >> FRACBITS; } fixed_t FixedDiv diff --git a/src/m_menu.c b/src/m_menu.c @@ -121,7 +121,7 @@ void M_WriteText(int x, int y, char *string); int M_StringWidth(char *string); int M_StringHeight(char *string); void M_StartControlPanel(void); -void M_StartMessage(char *string,void *routine,boolean input); +void M_StartMessage(char *string,void (*routine)(int),boolean input); void M_StopMessage(void); void M_ClearMenus (void); enum @@ -343,7 +343,6 @@ menu_t SaveDef = void M_ReadSaveStrings(void) { int handle; - int count; int i; char name[256]; for (i = 0;i < load_end;i++) @@ -359,7 +358,6 @@ void M_ReadSaveStrings(void) LoadMenu[i].status = 0; continue; } - count = read (handle, &savegamestrings[i], SAVESTRINGSIZE); close (handle); LoadMenu[i].status = 1; } @@ -448,7 +446,7 @@ void M_SaveGame (int choice) M_SetupNextMenu(&SaveDef); M_ReadSaveStrings(); } -char tempstring[80]; +char tempstring[84]; void M_QuickSaveResponse(int ch) { if (ch == 'y') @@ -475,9 +473,10 @@ void M_QuickSave(void) return; } sprintf(tempstring,QSPROMPT,savegamestrings[quickSaveSlot]); - M_StartMessage(tempstring,M_QuickSaveResponse,true); + M_StartMessage(tempstring, M_QuickSaveResponse, true); } -void M_QuickLoadResponse(int ch) +void +M_QuickLoadResponse(int ch) { if (ch == 'y') { @@ -497,7 +496,7 @@ void M_QuickLoad(void) M_StartMessage(QSAVESPOT,NULL,false); return; } - sprintf(tempstring,QLPROMPT,savegamestrings[quickSaveSlot]); + sprintf(tempstring, QLPROMPT, savegamestrings[quickSaveSlot]); M_StartMessage(tempstring,M_QuickLoadResponse,true); } void M_DrawReadThis1(void) @@ -837,7 +836,7 @@ M_DrawSelCell void M_StartMessage ( char* string, - void* routine, + void (*routine)(int), boolean input ) { messageLastMenuActive = menuactive; diff --git a/src/p_doors.c b/src/p_doors.c @@ -258,7 +258,6 @@ EV_VerticalDoor mobj_t* thing ) { player_t* player; - int secnum; sector_t* sec; vldoor_t* door; int side; @@ -302,7 +301,6 @@ EV_VerticalDoor break; } sec = sides[ line->sidenum[side^1]] .sector; - secnum = sec-sectors; if (sec->specialdata) { door = sec->specialdata; diff --git a/src/p_enemy.c b/src/p_enemy.c @@ -301,10 +301,8 @@ P_LookForPlayers int c; int stop; player_t* player; - sector_t* sector; angle_t an; fixed_t dist; - sector = actor->subsector->sector; c = 0; stop = (actor->lastlook-1)&3; for ( ; ; actor->lastlook = (actor->lastlook+1)&3 ) diff --git a/src/p_saveg.c b/src/p_saveg.c @@ -4,7 +4,7 @@ #include "doomstat.h" #include "r_state.h" byte* save_p; -#define PADSAVEP() save_p += (4 - ((int) save_p & 3)) & 3 +#define PADSAVEP() save_p += (4 - ((long)save_p & 3)) & 3 void P_ArchivePlayers (void) { int i; @@ -46,8 +46,7 @@ void P_UnArchivePlayers (void) { if (players[i]. psprites[j].state) { - players[i]. psprites[j].state - = &states[ (int)players[i].psprites[j].state ]; + players[i]. psprites[j].state = &states[(long)players[i].psprites[j].state]; } } } @@ -185,11 +184,11 @@ void P_UnArchiveThinkers (void) mobj = Z_Malloc (sizeof(*mobj), PU_LEVEL, NULL); memcpy (mobj, save_p, sizeof(*mobj)); save_p += sizeof(*mobj); - mobj->state = &states[(int)mobj->state]; + mobj->state = &states[(long)mobj->state]; mobj->target = NULL; if (mobj->player) { - mobj->player = &players[(int)mobj->player-1]; + mobj->player = &players[(long)mobj->player-1]; mobj->player->mo = mobj; } P_SetThingPosition (mobj); @@ -339,7 +338,7 @@ void P_UnArchiveSpecials (void) ceiling = Z_Malloc (sizeof(*ceiling), PU_LEVEL, NULL); memcpy (ceiling, save_p, sizeof(*ceiling)); save_p += sizeof(*ceiling); - ceiling->sector = &sectors[(int)ceiling->sector]; + ceiling->sector = &sectors[(long)ceiling->sector]; ceiling->sector->specialdata = ceiling; if (ceiling->thinker.function.acp1) ceiling->thinker.function.acp1 = (actionf_p1)T_MoveCeiling; @@ -351,7 +350,7 @@ void P_UnArchiveSpecials (void) door = Z_Malloc (sizeof(*door), PU_LEVEL, NULL); memcpy (door, save_p, sizeof(*door)); save_p += sizeof(*door); - door->sector = &sectors[(int)door->sector]; + door->sector = &sectors[(long)door->sector]; door->sector->specialdata = door; door->thinker.function.acp1 = (actionf_p1)T_VerticalDoor; P_AddThinker (&door->thinker); @@ -361,7 +360,7 @@ void P_UnArchiveSpecials (void) floor = Z_Malloc (sizeof(*floor), PU_LEVEL, NULL); memcpy (floor, save_p, sizeof(*floor)); save_p += sizeof(*floor); - floor->sector = &sectors[(int)floor->sector]; + floor->sector = &sectors[(long)floor->sector]; floor->sector->specialdata = floor; floor->thinker.function.acp1 = (actionf_p1)T_MoveFloor; P_AddThinker (&floor->thinker); @@ -371,7 +370,7 @@ void P_UnArchiveSpecials (void) plat = Z_Malloc (sizeof(*plat), PU_LEVEL, NULL); memcpy (plat, save_p, sizeof(*plat)); save_p += sizeof(*plat); - plat->sector = &sectors[(int)plat->sector]; + plat->sector = &sectors[(long)plat->sector]; plat->sector->specialdata = plat; if (plat->thinker.function.acp1) plat->thinker.function.acp1 = (actionf_p1)T_PlatRaise; @@ -383,7 +382,7 @@ void P_UnArchiveSpecials (void) flash = Z_Malloc (sizeof(*flash), PU_LEVEL, NULL); memcpy (flash, save_p, sizeof(*flash)); save_p += sizeof(*flash); - flash->sector = &sectors[(int)flash->sector]; + flash->sector = &sectors[(long)flash->sector]; flash->thinker.function.acp1 = (actionf_p1)T_LightFlash; P_AddThinker (&flash->thinker); break; @@ -392,7 +391,7 @@ void P_UnArchiveSpecials (void) strobe = Z_Malloc (sizeof(*strobe), PU_LEVEL, NULL); memcpy (strobe, save_p, sizeof(*strobe)); save_p += sizeof(*strobe); - strobe->sector = &sectors[(int)strobe->sector]; + strobe->sector = &sectors[(long)strobe->sector]; strobe->thinker.function.acp1 = (actionf_p1)T_StrobeFlash; P_AddThinker (&strobe->thinker); break; @@ -401,7 +400,7 @@ void P_UnArchiveSpecials (void) glow = Z_Malloc (sizeof(*glow), PU_LEVEL, NULL); memcpy (glow, save_p, sizeof(*glow)); save_p += sizeof(*glow); - glow->sector = &sectors[(int)glow->sector]; + glow->sector = &sectors[(long)glow->sector]; glow->thinker.function.acp1 = (actionf_p1)T_Glow; P_AddThinker (&glow->thinker); break; diff --git a/src/p_spec.c b/src/p_spec.c @@ -724,7 +724,7 @@ int EV_DoDonut(line_t* line) s2 = getNextSector(s1->lines[0],s1); for (i = 0;i < s2->linecount;i++) { - if ((!s2->lines[i]->flags & ML_TWOSIDED) || + if (((!s2->lines[i]->flags) & ML_TWOSIDED) || (s2->lines[i]->backsector == s1)) continue; s3 = s2->lines[i]->backsector; @@ -761,10 +761,7 @@ void P_SpawnSpecials (void) { sector_t* sector; int i; - int episode; - episode = 1; if (W_CheckNumForName("texture2") >= 0) - episode = 2; levelTimer = false; i = M_CheckParm("-avg"); if (i && deathmatch) diff --git a/src/r_draw.c b/src/r_draw.c @@ -241,7 +241,7 @@ void R_InitTranslationTables (void) { int i; translationtables = Z_Malloc (256*3+255, PU_STATIC, 0); - translationtables = (byte *)(( (int)translationtables + 255 )& ~255); + translationtables = (byte*)(((long)translationtables + 255 )& ~255); for (i=0 ; i<256 ; i++) { if (i >= 0x70 && i<= 0x7f) diff --git a/src/w_wad.c b/src/w_wad.c @@ -249,13 +249,11 @@ W_CacheLumpNum ( int lump, int tag ) { - byte* ptr; if ((unsigned)lump >= numlumps) I_Error ("W_CacheLumpNum: %i >= numlumps",lump); - if (!lumpcache[lump]) - { - ptr = Z_Malloc (W_LumpLength (lump), tag, &lumpcache[lump]); - W_ReadLump (lump, lumpcache[lump]); + if (!lumpcache[lump]) { + Z_Malloc(W_LumpLength (lump), tag, &lumpcache[lump]); + W_ReadLump(lump, lumpcache[lump]); } else { diff --git a/src/wi_stuff.c b/src/wi_stuff.c @@ -599,8 +599,7 @@ void WI_drawDeathmatchStats(void) int x; int y; int w; - int lh; - lh = WI_SPACINGY; + WI_slamBackground(); WI_drawAnimatedBack(); WI_drawLF(); diff --git a/src/z_zone.c b/src/z_zone.c @@ -161,53 +161,7 @@ Z_FreeTags Z_Free ( (byte *)block+sizeof(memblock_t)); } } -void -Z_DumpHeap -( int lowtag, - int hightag ) -{ - memblock_t* block; - printf ("zone size: %i location: %p\n", - mainzone->size,mainzone); - printf ("tag range: %i to %i\n", - lowtag, hightag); - for (block = mainzone->blocklist.next ; ; block = block->next) - { - if (block->tag >= lowtag && block->tag <= hightag) - printf ("block:%p size:%7i user:%p tag:%3i\n", - block, block->size, block->user, block->tag); - if (block->next == &mainzone->blocklist) - { - break; - } - if ( (byte *)block + block->size != (byte *)block->next) - printf ("ERROR: block size does not touch the next block\n"); - if ( block->next->prev != block) - printf ("ERROR: next block doesn't have proper back link\n"); - if (!block->user && !block->next->user) - printf ("ERROR: two consecutive free blocks\n"); - } -} -void Z_FileDumpHeap (FILE* f) -{ - memblock_t* block; - fprintf (f,"zone size: %i location: %p\n",mainzone->size,mainzone); - for (block = mainzone->blocklist.next ; ; block = block->next) - { - fprintf (f,"block:%p size:%7i user:%p tag:%3i\n", - block, block->size, block->user, block->tag); - if (block->next == &mainzone->blocklist) - { - break; - } - if ( (byte *)block + block->size != (byte *)block->next) - fprintf (f,"ERROR: block size does not touch the next block\n"); - if ( block->next->prev != block) - fprintf (f,"ERROR: next block doesn't have proper back link\n"); - if (!block->user && !block->next->user) - fprintf (f,"ERROR: two consecutive free blocks\n"); - } -} + void Z_CheckHeap (void) { memblock_t* block; @@ -234,9 +188,9 @@ Z_ChangeTag2 block = (memblock_t *) ( (byte *)ptr - sizeof(memblock_t)); if (block->id != ZONEID) I_Error ("Z_ChangeTag: freed a pointer without ZONEID"); - if (tag >= PU_PURGELEVEL && (unsigned)block->user < 0x100) + if (tag >= PU_PURGELEVEL && (unsigned long)block->user < 0x100) I_Error ("Z_ChangeTag: an owner is required for purgable blocks"); - block->tag = tag; + block->tag = tag; } int Z_FreeMemory (void) {