Skip to content

Commit

Permalink
establish an int type variable naming scheme (#50)
Browse files Browse the repository at this point in the history
* short int -> short, long int -> long

* unsigned -> unsigned int

* longword -> unsigned int

* word -> unsigned short
  • Loading branch information
fabiangreffrath authored Feb 6, 2024
1 parent 687f3cb commit ec15323
Show file tree
Hide file tree
Showing 43 changed files with 311 additions and 313 deletions.
2 changes: 1 addition & 1 deletion rott/_rt_acto.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ enum {

typedef struct sat
{ int x,y,z;
unsigned flags;
unsigned int flags;
int hitpoints;
int targetx,targety;
int angle;
Expand Down
6 changes: 3 additions & 3 deletions rott/_rt_stat.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ typedef struct sas
int flags;
signed char ticcount;
int hitpoints;
short int shapenum;
short shapenum;
signed char ammo;
signed char count;
signed char itemnumber;
short int areanumber;
short int whichstat;
short areanumber;
short whichstat;
byte numanims;
int linked_to;
}saved_stat_type;
Expand Down
4 changes: 2 additions & 2 deletions rott/_rt_ted.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ typedef struct
typedef struct
{
int planestart[3];
word planelength[3];
word width,height;
unsigned short planelength[3];
unsigned short width,height;
char name[16];
} maptype;

Expand Down
2 changes: 1 addition & 1 deletion rott/fx_man.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ enum FX_ERRORS

char *FX_ErrorString( int ErrorNumber );
int FX_SetupCard( int SoundCard, fx_device *device );
int FX_Init( int SoundCard, int numvoices, int numchannels, int samplebits, unsigned mixrate );
int FX_Init( int SoundCard, int numvoices, int numchannels, int samplebits, unsigned int mixrate );
int FX_Shutdown( void );
int FX_SetCallBack( void ( *function )( unsigned long ) );
void FX_SetVolume( int volume );
Expand Down
2 changes: 1 addition & 1 deletion rott/fx_mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ int FX_Shutdown(void)
extern int SoundNumber(int x);

int FX_Init(int SoundCard, int numvoices, int numchannels, int samplebits,
unsigned mixrate)
unsigned int mixrate)
{
int i;

Expand Down
18 changes: 9 additions & 9 deletions rott/rt_actor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,7 @@ void GetMomenta(objtype *target, objtype *source, int *newmomx,



void SpawnNewObj (unsigned tilex, unsigned tiley, statetype *state, classtype which)
void SpawnNewObj (unsigned int tilex, unsigned int tiley, statetype *state, classtype which)
{
int newarea;

Expand Down Expand Up @@ -4476,7 +4476,7 @@ void T_PlayDead(objtype *ob)
}


void AdjustAngle(int maxadjust, short int *currangle,int targetangle)
void AdjustAngle(int maxadjust, short *currangle,int targetangle)
{
int dangle,i,magangle;

Expand Down Expand Up @@ -8478,7 +8478,7 @@ void T_Heinrich_Out_of_Control(objtype*ob)
{
ob->dir = dirorder[ob->dir][PREV];
ob->angle = dirangle8[ob->dir];
if (ob->dir == (unsigned)ob->temp2)
if (ob->dir == (unsigned int)ob->temp2)
{
if (ob->temp1 > 1)
ob->temp1--;
Expand Down Expand Up @@ -8648,7 +8648,7 @@ void T_KristLeft(objtype*ob)
ActorMovement(ob);
if (!ob->ticcount)
{SD_PlaySoundRTP(SD_KRISTTURNSND,ob->x,ob->y);
if (ob->dir != (unsigned)ob->temp1)
if (ob->dir != (unsigned int)ob->temp1)
ob->dir = dirorder[ob->dir][NEXT];
else
{ob->temp1 = 0;
Expand All @@ -8663,7 +8663,7 @@ void T_KristRight(objtype*ob)
ActorMovement(ob);
if (!ob->ticcount)
{SD_PlaySoundRTP(SD_KRISTTURNSND,ob->x,ob->y);
if (ob->dir != (unsigned)ob->temp1)
if (ob->dir != (unsigned int)ob->temp1)
ob->dir = dirorder[ob->dir][PREV];
else
{ob->temp1 = 0;
Expand Down Expand Up @@ -9035,7 +9035,7 @@ void SelectOrobotChaseDir(objtype*ob) // this code is for head
{
tdir = (ob->temp1 & 0xf);

if ((head->dir == (unsigned)tdir) && (ob->dir == (unsigned)tdir)) // increment
if ((head->dir == (unsigned int)tdir) && (ob->dir == (unsigned int)tdir)) // increment
// tried dir if robot will attempt to move at tdir =>
// head and body are at move try dir
{//Debug("\ntrying next queue dir %d",tdir);
Expand Down Expand Up @@ -9254,7 +9254,7 @@ void T_NME_SpinFire(objtype*ob)
head = (objtype*)(ob->whatever);
wheels = (objtype*)(ob->target);

if (ob->dir != (unsigned)ob->targettilex)
if (ob->dir != (unsigned int)ob->targettilex)
{ob->dir = head->dir = wheels->dir = dirorder16[ob->dir][ob->temp3];
return;
}
Expand Down Expand Up @@ -9568,7 +9568,7 @@ void SelectSnakeDir (objtype *ob)

spot = MAPSPOT(ob->tilex,ob->tiley,1)-ICONARROWS;

if ((spot >= 0) && (spot<= 7) && ((ob->dir!=(unsigned)spot)||(!(ob->flags & FL_DONE))))
if ((spot >= 0) && (spot<= 7) && ((ob->dir!=(unsigned int)spot)||(!(ob->flags & FL_DONE))))
{ centerx= (ob->tilex << 16) + HALFGLOBAL1;
centery= (ob->tiley << 16) + HALFGLOBAL1;
dx = abs(centerx - ob->x);
Expand Down Expand Up @@ -9792,7 +9792,7 @@ void T_DarkSnakeChase(objtype*ob)

angle = AngleBetween(ob,PLAYER[0]);
tdir = angletodir[angle];
if (Near(ob,PLAYER[0],6) && (ob->dir == (unsigned)tdir) && (!(ob->state->condition & SF_DOWN)))
if (Near(ob,PLAYER[0],6) && (ob->dir == (unsigned int)tdir) && (!(ob->state->condition & SF_DOWN)))
{
NewState(ob,&s_snakefire1);
SD_PlaySoundRTP(SD_SNAKEREADYSND,ob->x,ob->y);
Expand Down
12 changes: 6 additions & 6 deletions rott/rt_actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ typedef struct objstruct
byte tilex,tiley;
fixed x,y,z;
int shapenum;
unsigned flags;
unsigned int flags;
short ticcount;
signed short hitpoints;
word whichactor;
unsigned short whichactor;

signed short dirchoosetime;
fixed drawx,drawy;
Expand All @@ -233,8 +233,8 @@ typedef struct objstruct


dirtype dir;
short int angle;
short int yzangle;
short angle;
short yzangle;

int soundhandle;
int speed;
Expand Down Expand Up @@ -366,7 +366,7 @@ void SpawnDeadGuard (int tilex, int tiley);
void SpawnWallfire(int tilex, int tiley, int dir);
void SpawnMissile(objtype*,classtype,int,int,statetype*,int);

void InitHitRect (objtype *ob, unsigned radius);
void InitHitRect (objtype *ob, unsigned int radius);
void NewState (objtype *ob, statetype *state);
void SelectPathDir(objtype*);
void SelectChaseDir (objtype *ob);
Expand Down Expand Up @@ -399,7 +399,7 @@ void T_Roll(objtype*);
void T_BossDied (objtype *ob);
boolean QuickSpaceCheck(objtype*,int,int);
void PushWallMove(int num);
void SpawnNewObj(unsigned,unsigned,statetype*,classtype);
void SpawnNewObj(unsigned int,unsigned int,statetype*,classtype);
void SpawnSpring(int,int);
void SpawnFourWayGun(int,int);
void SpawnSnake(int tilex,int tiley);
Expand Down
30 changes: 15 additions & 15 deletions rott/rt_battl.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,23 +174,23 @@ enum
//
typedef struct
{
unsigned Gravity;
unsigned Speed;
unsigned Ammo;
unsigned HitPoints;
unsigned SpawnDangers;
unsigned SpawnHealth;
unsigned SpawnWeapons;
unsigned SpawnMines;
unsigned RespawnItems;
unsigned WeaponPersistence;
unsigned RandomWeapons;
unsigned FriendlyFire;
unsigned LightLevel;
unsigned int Gravity;
unsigned int Speed;
unsigned int Ammo;
unsigned int HitPoints;
unsigned int SpawnDangers;
unsigned int SpawnHealth;
unsigned int SpawnWeapons;
unsigned int SpawnMines;
unsigned int RespawnItems;
unsigned int WeaponPersistence;
unsigned int RandomWeapons;
unsigned int FriendlyFire;
unsigned int LightLevel;
int Kills;
int DangerDamage;
unsigned TimeLimit;
unsigned RespawnTime;
unsigned int TimeLimit;
unsigned int RespawnTime;
} battle_type;

#define bo_normal_respawn_time 30
Expand Down
2 changes: 1 addition & 1 deletion rott/rt_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void ReadUnsigned (const char * s1, unsigned long * val)

temp = (int)(*val);
ReadInt (s1,&temp);
*val = (unsigned) temp;
*val = (unsigned int) temp;
}

//******************************************************************************
Expand Down
20 changes: 10 additions & 10 deletions rott/rt_com.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void InitROTTNET (void)

if (!quiet)
{
printf("ROTTNET: consoleplayer=%ld\n",(long int)rottcom->consoleplayer);
printf("ROTTNET: consoleplayer=%ld\n",(long)rottcom->consoleplayer);
}
}

Expand All @@ -195,8 +195,8 @@ void InitROTTNET (void)

boolean ReadPacket (void)
{
word crc;
word sentcrc;
unsigned short crc;
unsigned short sentcrc;

// Set command (Get Packet)
rottcom->command=CMD_GET;
Expand All @@ -214,10 +214,10 @@ boolean ReadPacket (void)
if (rottcom->remotenode!=-1)
{
// calculate crc on packet
crc=CalculateCRC ((byte *)&rottcom->data[0], rottcom->datalength-sizeof(word));
crc=CalculateCRC ((byte *)&rottcom->data[0], rottcom->datalength-sizeof(unsigned short));

// get crc inside packet
sentcrc=*((word *)(&rottcom->data[rottcom->datalength-sizeof(word)]));
sentcrc=*((unsigned short *)(&rottcom->data[rottcom->datalength-sizeof(unsigned short)]));

// are the crcs the same?
if (crc!=sentcrc)
Expand Down Expand Up @@ -255,7 +255,7 @@ boolean ReadPacket (void)

void WritePacket (void * buffer, int len, int destination)
{
word crc;
unsigned short crc;

if (!rottcom)
return;
Expand All @@ -266,7 +266,7 @@ void WritePacket (void * buffer, int len, int destination)
// set destination
rottcom->remotenode=destination;

if (len>(int)(MAXCOMBUFFERSIZE-sizeof(word)))
if (len>(int)(MAXCOMBUFFERSIZE-sizeof(unsigned short)))
{
Error("WritePacket: Overflowed buffer\n");
}
Expand All @@ -278,10 +278,10 @@ void WritePacket (void * buffer, int len, int destination)
crc=CalculateCRC (buffer, len);

// put CRC into realmode buffer packet
*((word *)&rottcom->data[len])=crc;
*((unsigned short *)&rottcom->data[len])=crc;

// set size of realmode packet including crc
rottcom->datalength=len+sizeof(word);
rottcom->datalength=len+sizeof(unsigned short);

if (*((byte *)buffer)==0)
Error("Packet type = 0\n");
Expand Down Expand Up @@ -447,7 +447,7 @@ void ComSetTime ( void )
else if (i!=consoleplayer)
SyncTime(i);
if (standalone==true)
printf("ComSetTime: player#%ld\n",(long int)i);
printf("ComSetTime: player#%ld\n",(long)i);
}
}
else
Expand Down
8 changes: 4 additions & 4 deletions rott/rt_crc.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "rt_crc.h"

/* variables */
static const unsigned short int crc16tab[256] =
static const unsigned short crc16tab[256] =
{
0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
Expand Down Expand Up @@ -76,9 +76,9 @@ int updatecrc(int crc, int c)
//
//******************************************************************************

word CalculateCRC (byte *source, unsigned size)
unsigned short CalculateCRC (byte *source, unsigned int size)
{
unsigned i;
unsigned int i;
int checksum;
int tmp;

Expand All @@ -90,7 +90,7 @@ word CalculateCRC (byte *source, unsigned size)
checksum=(checksum>>8)^crc16tab[tmp & 0xff];
}

return ((word)checksum);
return ((unsigned short)checksum);

}

Expand Down
2 changes: 1 addition & 1 deletion rott/rt_crc.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "rt_def.h"

int updatecrc(int,int);
word CalculateCRC (byte *source, unsigned size);
unsigned short CalculateCRC (byte *source, unsigned int size);

2 changes: 0 additions & 2 deletions rott/rt_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,6 @@ long filelength(int handle);


typedef unsigned char byte;
typedef unsigned short int word;
typedef unsigned int longword;
typedef int fixed;


Expand Down
4 changes: 2 additions & 2 deletions rott/rt_dmand.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void SD_StopIncomingSound ( void )
//
//***************************************************************************

void SD_UpdateIncomingSound ( byte * ptr, word length )
void SD_UpdateIncomingSound ( byte * ptr, unsigned short length )
{
int amount;

Expand Down Expand Up @@ -330,7 +330,7 @@ boolean SD_RecordingActive ( void )
//
//***************************************************************************

recordstate SD_GetSoundData ( byte * data, word length )
recordstate SD_GetSoundData ( byte * data, unsigned short length )
{
recordstate status=rs_data;
int amount;
Expand Down
4 changes: 2 additions & 2 deletions rott/rt_dmand.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void SD_StopIncomingSound ( void );
//
//***************************************************************************

void SD_UpdateIncomingSound ( byte * data, word length );
void SD_UpdateIncomingSound ( byte * data, unsigned short length );

//***************************************************************************
//
Expand All @@ -62,7 +62,7 @@ void SD_UpdateIncomingSound ( byte * data, word length );
//
//***************************************************************************

recordstate SD_GetSoundData ( byte * data, word length );
recordstate SD_GetSoundData ( byte * data, unsigned short length );

//***************************************************************************
//
Expand Down
Loading

0 comments on commit ec15323

Please sign in to comment.