Skip to content

Commit

Permalink
adapt to C99
Browse files Browse the repository at this point in the history
Strategy being:
- Remove unused variables, unless they are ref'd in some block of
  '#if 0' or commented code, in which case move the decls to inside
  those regions, or comment out.
- Mark any function/block-level function prototypes as extern if not
  already, which I'll use to collate later to decide whether there's
  merit in moving them.
  • Loading branch information
jonof committed Dec 18, 2022
1 parent 65bd2bb commit 015df7b
Show file tree
Hide file tree
Showing 73 changed files with 816 additions and 1,838 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ CC?=gcc
CXX?=g++
NASM?=nasm
RC?=windres
OURCFLAGS=$(debug) -W -Wall -Wimplicit -Wno-unused \
-fno-strict-aliasing -DNO_GCC_BUILTINS \
OURCFLAGS=$(debug) -W -Wall -fno-strict-aliasing \
-I$(INC) -I$(EINC) -I$(MACTROOT) -I$(AUDIOLIBROOT)/include
OURCXXFLAGS=-fno-exceptions -fno-rtti
OURCCFLAGS=-std=c99
OURCXXFLAGS=-fno-exceptions -fno-rtti -std=c++98
LIBS=-lm
GAMELIBS=
NASMFLAGS=-s #-g
Expand Down Expand Up @@ -260,20 +260,20 @@ $(SRC)/%.$o: $(SRC)/%.nasm
nasm $(NASMFLAGS) $< -o $@

$(SRC)/%.$o: $(SRC)/%.c
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@
$(CC) $(CFLAGS) $(OURCFLAGS) $(OURCCFLAGS) -c $< -o $@
$(SRC)/%.$o: $(SRC)/%.cpp
$(CXX) $(CXXFLAGS) $(OURCXXFLAGS) $(OURCFLAGS) -c $< -o $@
$(MACTROOT)/%.$o: $(MACTROOT)/%.c
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@
$(CC) $(CFLAGS) $(OURCFLAGS) $(OURCCFLAGS) -c $< -o $@

$(SRC)/%.$(res): $(SRC)/%.rc
$(RC) -i $< -o $@ --include-dir=$(EINC) --include-dir=$(SRC)

$(SRC)/%.$o: $(SRC)/util/%.c
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@
$(CC) $(CFLAGS) $(OURCFLAGS) $(OURCCFLAGS) -c $< -o $@

$(RSRC)/%.$o: $(RSRC)/%.c
$(CC) $(CFLAGS) $(OURCFLAGS) -c $< -o $@
$(CC) $(CFLAGS) $(OURCFLAGS) $(OURCCFLAGS) -c $< -o $@

$(RSRC)/%_gresource.c: $(RSRC)/%.gresource.xml
glib-compile-resources --generate --manual-register --c-name=startgtk --target=$@ --sourcedir=$(RSRC) $<
Expand Down
2 changes: 1 addition & 1 deletion jfbuild
Submodule jfbuild updated 56 files
+6 −6 Makefile
+12 −11 Makefile.msvc
+1 −1 include/build.h
+7 −7 include/cache1d.h
+197 −252 include/compat.h
+0 −1 include/msinttypes/README.build
+0 −138 include/msinttypes/changelog.txt
+0 −305 include/msinttypes/inttypes.h
+0 −247 include/msinttypes/stdint.h
+0 −1 include/watcomhax/cerrno
+0 −2 include/watcomhax/cmath
+0 −1 include/watcomhax/cstdarg
+0 −1 include/watcomhax/cstdio
+0 −1 include/watcomhax/cstdlib
+0 −1 include/watcomhax/cstring
+0 −1 include/watcomhax/ctime
+2 −2 kenbuild/StartupWinController.m
+10 −11 kenbuild/bstub.c
+2 −8 kenbuild/config.c
+150 −147 kenbuild/game.c
+5 −4 kenbuild/kdmsound.c
+1 −0 kenbuild/kdmsound_stub.c
+1 −8 kenbuild/startgtk_game.c
+4 −0 kenbuild/startwin_game.c
+4 −4 src/EditorStartupWinController.m
+7 −4 src/a-c.c
+10 −8 src/asmprot.c
+7 −8 src/baselayer.c
+76 −147 src/build.c
+69 −64 src/cache1d.c
+44 −319 src/compat.c
+16 −7 src/config.c
+7 −6 src/defs.c
+61 −77 src/engine.c
+152 −99 src/glbuild.c
+127 −106 src/glbuild_priv.h
+1 −7 src/gtkbits.c
+66 −70 src/kplib.c
+26 −28 src/mdsprite.c
+20 −24 src/mmulti.c
+13 −16 src/osd.c
+39 −63 src/polymost.c
+3 −4 src/polymosttex.c
+21 −17 src/polymosttexcache.c
+16 −14 src/scriptfile.c
+23 −22 src/sdlayer2.c
+1 −8 src/startgtk_editor.c
+4 −0 src/startwin_editor.c
+10 −7 src/winlayer.c
+12 −7 tools/arttool.cc
+1 −1 tools/kextract.c
+3 −16 tools/kgroup.c
+5 −5 tools/transpal.c
+1 −1 tools/wad2art.c
+17 −11 xcode/engine.xcodeproj/project.pbxproj
+7 −5 xcode/game.xcodeproj/project.pbxproj
2 changes: 1 addition & 1 deletion jfmact
Submodule jfmact updated 5 files
+10 −20 control.c
+3 −7 file_lib.c
+0 −1 keyboard.c
+21 −13 scriplib.c
+2 −2 util_lib.c
7 changes: 3 additions & 4 deletions src/StartupWinController.m
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ - (void)populateVideoModes:(BOOL)firstTime
fullscreen = settings->fullscreen;
} else {
fullscreen = ([fullscreenButton state] == NSOnState);
mode3d = [[videoMode3DPUButton selectedItem] tag];
mode3d = (int)[[videoMode3DPUButton selectedItem] tag];
if (mode3d >= 0) {
xdim = validmode[mode3d].xdim;
ydim = validmode[mode3d].ydim;
Expand Down Expand Up @@ -407,9 +407,8 @@ - (IBAction)start:(id)sender
int mode = -1;
NSTableView *table;
NSValue *grpvalue;
struct grpfile const *grpfile;

mode = [[videoMode3DPUButton selectedItem] tag];
mode = (int)[[videoMode3DPUButton selectedItem] tag];
if (mode >= 0) {
settings->xdim3d = validmode[mode].xdim;
settings->ydim3d = validmode[mode].ydim;
Expand All @@ -420,7 +419,7 @@ - (IBAction)start:(id)sender
settings->usemouse = [useMouseButton state] == NSOnState;
settings->usejoy = [useJoystickButton state] == NSOnState;

mode = [[soundQualityPUButton selectedItem] tag];
mode = (int)[[soundQualityPUButton selectedItem] tag];
if (mode >= 0) {
settings->samplerate = soundQualities[mode].frequency;
settings->bitspersample = soundQualities[mode].samplesize;
Expand Down
21 changes: 5 additions & 16 deletions src/actor.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ DoActorDie(short SpriteNum, short weapon)
VOID
DoDebrisCurrent(SPRITEp sp)
{
int xvect, yvect;
int nx, ny;
int ret=0;
USERp u = User[sp - sprite];
Expand Down Expand Up @@ -381,9 +380,7 @@ DoActorSectorDamage(short SpriteNum)
int
move_debris(short SpriteNum, int xchange, int ychange, int zchange)
{
SPRITEp sp = &sprite[SpriteNum];
USERp u = User[SpriteNum];
int nx, ny;

u->ret = move_sprite(SpriteNum, xchange, ychange, zchange,
u->ceiling_dist, u->floor_dist, 0, ACTORMOVETICS);
Expand Down Expand Up @@ -483,8 +480,8 @@ DoFireFly(short SpriteNum)
int
DoGenerateSewerDebris(short SpriteNum)
{
SPRITEp sp = &sprite[SpriteNum], np;
USERp u = User[SpriteNum], nu;
SPRITEp sp = &sprite[SpriteNum];
USERp u = User[SpriteNum];
short n;

static STATEp Debris[] =
Expand All @@ -502,8 +499,6 @@ DoGenerateSewerDebris(short SpriteNum)
u->Tics = u->WaitTics;

n = SpawnSprite(STAT_DEAD_ACTOR, 0, Debris[RANDOM_P2(4<<8)>>8], sp->sectnum, sp->x, sp->y, sp->z, sp->ang, 200);
np = &sprite[n];
nu = User[n];

SetOwner(SpriteNum, n);
}
Expand Down Expand Up @@ -603,7 +598,6 @@ int
DoActorBeginSlide(short SpriteNum, short ang, short vel, short dec)
{
USERp u = User[SpriteNum];
SPRITEp sp = User[SpriteNum]->SpriteP;

SET(u->Flags, SPR_SLIDING);

Expand All @@ -623,7 +617,6 @@ int
DoActorSlide(short SpriteNum)
{
USERp u = User[SpriteNum];
SPRITEp sp = User[SpriteNum]->SpriteP;
int nx, ny;

nx = u->slide_vel * (int) sintable[NORM_ANGLE(u->slide_ang + 512)] >> 14;
Expand Down Expand Up @@ -651,7 +644,6 @@ int
DoActorBeginJump(short SpriteNum)
{
USERp u = User[SpriteNum];
SPRITEp sp = User[SpriteNum]->SpriteP;

SET(u->Flags, SPR_JUMPING);
RESET(u->Flags, SPR_FALLING);
Expand Down Expand Up @@ -694,7 +686,7 @@ DoActorJump(short SpriteNum)
if ((u->jump_speed += jump_adj) > 0)
{
//DSPRINTF(ds,"Actor Jump Height %d", labs(sp->z - sector[sp->sectnum].floorz)>>8 );
MONO_PRINT(ds);
//MONO_PRINT(ds);

// Start falling
DoActorBeginFall(SpriteNum);
Expand All @@ -714,7 +706,7 @@ DoActorJump(short SpriteNum)
u->jump_speed = -u->jump_speed;

//DSPRINTF(ds,"Jump: sp_num %d, hi_num %d, hi_sect %d",SpriteNum, u->hi_sp - sprite, u->hi_sectp - sector);
MONO_PRINT(ds);
//MONO_PRINT(ds);

// Change sprites state to falling
DoActorBeginFall(SpriteNum);
Expand Down Expand Up @@ -791,14 +783,12 @@ DoActorStopFall(short SpriteNum)
// don't stand on face or wall sprites - jump again
if (u->lo_sp && !TEST(u->lo_sp->cstat, CSTAT_SPRITE_FLOOR))
{
USERp tu = User[u->lo_sp - sprite];

//sp->ang = NORM_ANGLE(sp->ang + (RANDOM_P2(64<<8)>>8) - 32);
sp->ang = NORM_ANGLE(sp->ang + 1024 + (RANDOM_P2(512<<8)>>8));
u->jump_speed = -350;

//DSPRINTF(ds,"StopFall: sp_num %d, sp->picnum %d, lo_num %d, lo_sp->picnum %d",SpriteNum, sp->picnum, u->lo_sp - sprite, u->lo_sp->picnum);
MONO_PRINT(ds);
//MONO_PRINT(ds);

DoActorBeginJump(SpriteNum);
return(0);
Expand Down Expand Up @@ -864,7 +854,6 @@ int
DoBeginJump(short SpriteNum)
{
USERp u = User[SpriteNum];
SPRITEp sp = User[SpriteNum]->SpriteP;

SET(u->Flags, SPR_JUMPING);
RESET(u->Flags, SPR_FALLING);
Expand Down
34 changes: 8 additions & 26 deletions src/ai.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ short AttackOrRun = 200;

VOID DebugMoveHit(short SpriteNum)
{
SPRITEp sp;
USERp u = User[SpriteNum];
extern BOOL DebugActor;

//SPRITEp sp;
//USERp u = User[SpriteNum];
(void)SpriteNum;
return;

//if (u->ret == -1)
Expand Down Expand Up @@ -88,15 +87,14 @@ VOID DebugMoveHit(short SpriteNum)
break;
}
MONO_PRINT(ds);
//MONO_PRINT(ds);
*/
}


BOOL ActorMoveHitReact(short SpriteNum)
{
USERp u = User[SpriteNum];
SPRITEp sp = User[SpriteNum]->SpriteP;

// Should only return TRUE if there is a reaction to what was hit that
// would cause the calling function to abort
Expand All @@ -106,11 +104,9 @@ BOOL ActorMoveHitReact(short SpriteNum)
case HIT_SPRITE:
{
short HitSprite = NORM_SPRITE(u->ret);
SPRITEp hsp;
USERp hu;
ANIMATORp action;

hsp = &sprite[HitSprite];
hu = User[HitSprite];


Expand Down Expand Up @@ -156,7 +152,7 @@ BOOL ActorFlaming(short SpriteNum)
size = SPRITEp_SIZE_Z(sp) - DIV4(SPRITEp_SIZE_Z(sp));

//DSPRINTF(ds,"enemy size %d, flame size %d",size>>8,SPRITEp_SIZE_Z(fp)>>8);
MONO_PRINT(ds);
//MONO_PRINT(ds);

if (SPRITEp_SIZE_Z(fp) > size)
return(TRUE);
Expand Down Expand Up @@ -319,12 +315,12 @@ CanSeePlayer(short SpriteNum)
int
CanHitPlayer(short SpriteNum)
{
USERp u = User[SpriteNum], hu;
USERp u = User[SpriteNum];
SPRITEp sp = User[SpriteNum]->SpriteP, hp;
int hitx, hity, hitz;
short hitsect, hitwall, hitsprite;
int xvect,yvect,zvect;
short ang,ret=FALSE;
short ang;
// if actor can still see the player
int zhs, zhh;

Expand All @@ -334,7 +330,6 @@ CanHitPlayer(short SpriteNum)
zhs = sp->z - DIV2(SPRITEp_SIZE_Z(sp));

hp = u->tgt_sp;
hu = User[u->tgt_sp - sprite];

// get angle to target
ang = getangle(hp->x - sp->x, hp->y - sp->y);
Expand Down Expand Up @@ -389,10 +384,9 @@ DoActorPickClosePlayer(short SpriteNum)
SPRITEp sp = User[SpriteNum]->SpriteP;
int dist, near_dist = MAX_ACTIVE_RANGE, a,b,c;
short pnum;
PLAYERp pp,tp;
PLAYERp pp;
// if actor can still see the player
int look_height = SPRITEp_TOS(sp);
BOOL ICanSee = FALSE;
BOOL found = FALSE;
int i,nexti;

Expand Down Expand Up @@ -469,7 +463,6 @@ DoActorPickClosePlayer(short SpriteNum)

DISTANCE(sp->x, sp->y, pp->posx, pp->posy, dist, a, b, c);

//ICanSee = FAFcansee(sp->x, sp->y, look_height, sp->sectnum, pp->SpriteP->x, pp->SpriteP->y, SPRITEp_UPPER(pp->SpriteP), pp->SpriteP->sectnum);
if (dist < near_dist && FAFcansee(sp->x, sp->y, look_height, sp->sectnum, pp->SpriteP->x, pp->SpriteP->y, SPRITEp_UPPER(pp->SpriteP), pp->SpriteP->sectnum))
{
near_dist = dist;
Expand Down Expand Up @@ -510,7 +503,6 @@ int
GetPlayerSpriteNum(short SpriteNum)
{
USERp u = User[SpriteNum];
SPRITEp sp = User[SpriteNum]->SpriteP;
short pnum;
PLAYERp pp;

Expand Down Expand Up @@ -632,9 +624,7 @@ DoActorActionDecide(short SpriteNum)
USERp u = User[SpriteNum];
SPRITEp sp = User[SpriteNum]->SpriteP;
int dist;
short pnum;
ANIMATORp action;
PLAYERp pp;
USERp pu=NULL;
BOOL ICanSee=FALSE;

Expand Down Expand Up @@ -1261,8 +1251,6 @@ FindTrackToPlayer(USERp u)
short
FindTrackAwayFromPlayer(USERp u)
{
SPRITEp sp = u->SpriteP;

short point, track_dir, track;
unsigned int i;

Expand Down Expand Up @@ -1308,8 +1296,6 @@ FindTrackAwayFromPlayer(USERp u)
short
FindWanderTrack(USERp u)
{
SPRITEp sp = u->SpriteP;

short point, track_dir, track;
unsigned int i;

Expand Down Expand Up @@ -1382,7 +1368,6 @@ int
InitActorRunToward(short SpriteNum)
{
USERp u = User[SpriteNum];
SPRITEp sp = User[SpriteNum]->SpriteP;

//MONO_PRINT("InitActorRunToward\n");

Expand Down Expand Up @@ -1671,7 +1656,6 @@ int
DoActorDuck(short SpriteNum)
{
USERp u = User[SpriteNum];
SPRITEp sp = User[SpriteNum]->SpriteP;

if ((u->WaitTics -= ACTORMOVETICS) < 0)
{
Expand Down Expand Up @@ -2054,7 +2038,6 @@ int
InitActorPause(short SpriteNum)
{
USERp u = User[SpriteNum];
SPRITEp sp = User[SpriteNum]->SpriteP;

u->ActorActionFunc = DoActorPause;

Expand All @@ -2071,7 +2054,6 @@ int
DoActorPause(short SpriteNum)
{
USERp u = User[SpriteNum];
SPRITEp sp = User[SpriteNum]->SpriteP;

// Using Vis instead of WaitTics, var name sucks, but it's the same type
// WaitTics is used by too much other actor code and causes problems here
Expand Down
6 changes: 2 additions & 4 deletions src/anim.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,7 @@ unsigned char * LoadAnm(short anim_num)
{
int handle;
int length;
unsigned char *animbuf, *palptr;
int i,j,k;
unsigned char *animbuf;

DSPRINTF(ds,"LoadAnm");
MONO_PRINT(ds);
Expand Down Expand Up @@ -286,8 +285,7 @@ void
playanm(short anim_num)
{
unsigned char *animbuf, *palptr;
int i, j, k, length = 0, numframes = 0;
int32 handle = -1;
int i, numframes = 0;
unsigned char ANIMvesapal[4*256];
unsigned char tempbuf[256];
unsigned char *palook_bak = palookup[0];
Expand Down
Loading

0 comments on commit 015df7b

Please sign in to comment.