From bc4139356a6adba62ce50e23c3413ce5f522ce8b Mon Sep 17 00:00:00 2001 From: terminx Date: Wed, 20 Dec 2006 03:27:25 +0000 Subject: [PATCH] Prefer passing things between functions as int rather than short or char to avoid the overhead of converting back and forth between formats git-svn-id: https://svn.eduke32.com/eduke32@432 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/actors.c | 15 ++-- polymer/eduke32/source/duke3d.h | 9 +- polymer/eduke32/source/funct.h | 78 ++++++++-------- polymer/eduke32/source/game.c | 22 ++--- polymer/eduke32/source/gamedef.c | 15 ++-- polymer/eduke32/source/gamedef.h | 4 +- polymer/eduke32/source/gameexec.c | 122 +++++++++++-------------- polymer/eduke32/source/gamevars.c | 42 ++++----- polymer/eduke32/source/global.c | 2 +- polymer/eduke32/source/menus.c | 15 ++-- polymer/eduke32/source/player.c | 142 +++++++++++++++--------------- polymer/eduke32/source/premap.c | 17 ++-- polymer/eduke32/source/sector.c | 62 ++++++------- 13 files changed, 260 insertions(+), 285 deletions(-) diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index 32858d554..c1a5b0127 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -153,8 +153,7 @@ void addweaponnoswitch(struct player_struct *p, short weapon) void addweapon(struct player_struct *p,short weapon) { - short snum; - snum = sprite[p->i].yvel; + int snum = sprite[p->i].yvel; addweaponnoswitch(p,weapon); @@ -549,7 +548,7 @@ int movesprite(short spritenum, long xchange, long ychange, long zchange, unsign return(retval); } -short ssp(short i,unsigned long cliptype) //The set sprite function +int ssp(int i,unsigned long cliptype) //The set sprite function { spritetype *s; long movetype; @@ -834,11 +833,9 @@ static void movefta(void) } } -short ifhitsectors(short sectnum) +int ifhitsectors(int sectnum) { - short i; - - i = headspritestat[5]; + int i = headspritestat[5]; while (i >= 0) { if (PN == EXPLOSION2 && sectnum == SECT) @@ -848,9 +845,9 @@ short ifhitsectors(short sectnum) return -1; } -short ifhitbyweapon(short sn) +int ifhitbyweapon(int sn) { - short j,p; + int j,p; spritetype *npc; if (hittype[sn].extra >= 0) diff --git a/polymer/eduke32/source/duke3d.h b/polymer/eduke32/source/duke3d.h index 131068981..917a42bb8 100644 --- a/polymer/eduke32/source/duke3d.h +++ b/polymer/eduke32/source/duke3d.h @@ -322,7 +322,8 @@ long tag; extern struct animwalltype animwall[MAXANIMWALLS]; -extern short numanimwalls,probey,lastprobey; +extern short numanimwalls; +extern int probey,lastprobey; extern char typebuflen,typebuf[141]; extern char MusicPtr[72000*2]; @@ -468,7 +469,7 @@ extern char sounds[NUM_SOUNDS][BMAX_PATH]; // JBF 20040531: adding 16 extra to the script so we have some leeway // to (hopefully) safely abort when hitting the limit extern long script[MAXSCRIPTSIZE+16],*scriptptr,*insptr,*labelcode,labelcnt,defaultlabelcnt,*labeltype; -extern char *label,*textptr,error,warning,killit_flag; +extern char *label; extern long *actorscrptr[MAXTILES],*parsing_actor; extern long *actorLoadEventScrptr[MAXTILES]; extern char actortype[MAXTILES]; @@ -567,10 +568,10 @@ extern char *level_file_names[MAXVOLUMES*MAXLEVELS]; extern char num_volumes; extern int32 SoundToggle,MusicToggle; -extern short last_threehundred,lastsavedpos; +extern int last_threehundred,lastsavedpos; extern char restorepalette; -extern short buttonstat; +extern int buttonstat; extern long cachecount; extern char boardfilename[BMAX_PATH],waterpal[768],slimepal[768],titlepal[768],drealms[768],endingpal[768],animpal[768]; extern char cachedebug,earthquaketime; diff --git a/polymer/eduke32/source/funct.h b/polymer/eduke32/source/funct.h index eb8092d97..ec5c8a5e2 100644 --- a/polymer/eduke32/source/funct.h +++ b/polymer/eduke32/source/funct.h @@ -46,16 +46,16 @@ extern void stopenvsound(short num,short i); extern void pan3dsound(void); extern void testcallback(unsigned long num); extern void clearsoundlocks(void); -extern short callsound(short sn,short whatsprite); -extern short check_activator_motion(short lotag); -extern char isadoorwall(short dapic); -extern char isanunderoperator(short lotag); -extern char isanearoperator(short lotag); -extern short checkcursectnums(short sect); +extern int callsound(int sn,int whatsprite); +extern int check_activator_motion(int lotag); +extern int isadoorwall(int dapic); +extern int isanunderoperator(int lotag); +extern int isanearoperator(int lotag); +extern int checkcursectnums(int sect); extern long ldist(spritetype *s1,spritetype *s2); extern long dist(spritetype *s1,spritetype *s2); -extern short findplayer(spritetype *s,long *d); -extern short findotherplayer(short p,long *d); +extern int findplayer(spritetype *s,long *d); +extern int findotherplayer(int p,long *d); extern void doanimations(void); extern int getanimationgoal(long *animptr); extern int setanimation(short animsect,long *animptr,long thegoal,long thevel); @@ -63,19 +63,19 @@ extern void animatecamsprite(void); extern void animatewalls(void); extern char activatewarpelevators(short s,short d); extern void operatesectors(short sn,short ii); -extern void operaterespawns(short low); -extern void operateactivators(short low,short snum); -extern void operatemasterswitches(short low); -extern void operateforcefields(short s,short low); -extern char checkhitswitch(short snum,long w,char switchtype); +extern void operaterespawns(int low); +extern void operateactivators(int low,int snum); +extern void operatemasterswitches(int low); +extern void operateforcefields(short s,int low); +extern char checkhitswitch(int snum,long w,int switchtype); extern void activatebysector(short sect,short j); extern void checkhitwall(short spr,short dawallnum,long x,long y,long z,short atwith); extern void checkplayerhurt(struct player_struct *p,short j); extern char checkhitceiling(short sn); extern void checkhitsprite(short i,short sn); extern void allignwarpelevators(void); -extern void sharedkeys(short snum); -extern void checksectors(short snum); +extern void sharedkeys(int snum); +extern void checksectors(int snum); extern int32 RTS_AddFile(char *filename); extern void RTS_Init(char *filename); extern int32 RTS_NumSounds(void); @@ -86,9 +86,9 @@ extern void *RTS_GetSound(int32 lump); extern void docacheit(void); extern void xyzmirror(short i,short wn); extern void vscrn(void); -extern void pickrandomspot(short snum); -extern void resetweapons(short snum); -extern void resetinventory(short snum); +extern void pickrandomspot(int snum); +extern void resetweapons(int snum); +extern void resetinventory(int snum); extern void newgame(char vn,char ln,char sk); extern void resettimevars(void); extern void waitforeverybody(void); @@ -101,13 +101,13 @@ extern void setpal(struct player_struct *p); extern void quickkill(struct player_struct *p); extern long hits(short i); extern long hitasprite(short i,short *hitsp); -extern short shoot(short i,short atwith); -extern void displaymasks(short snum); -extern void displayweapon(short snum); -extern void getinput(short snum); +extern int shoot(int i,int atwith); +extern void displaymasks(int snum); +extern void displayweapon(int snum); +extern void getinput(int snum); extern void checkweapons(struct player_struct *p); -extern void processinput(short snum); -extern void cmenu(short cm); +extern void processinput(int snum); +extern void cmenu(int cm); extern void savetemp(char *fn,long daptr,long dasiz); // extern int loadpheader(char spot,int32 *vn,int32 *ln,int32 *psk,int32 *numplr); extern int loadplayer(signed char spot); @@ -117,11 +117,11 @@ extern int getfilenames(char *path, char kind[]); extern void menus(void); extern void palto(char r,char g,char b,long e); extern void playanm(char *fn,char); -extern short getincangle(short a,short na); -extern void getglobalz(short sActor); -extern void makeitfall(short sActor); +extern int getincangle(int a,int na); +extern void getglobalz(int iActor); +extern void makeitfall(int iActor); extern void loadefs(char *fn); -extern short furthestangle(short sActor,short angs); +extern int furthestangle(int iActor,int angs); extern void execute(int iActor,int iPlayer,long lDist); extern void overwritesprite(long thex,long they,short tilenum,signed char shade,char stat,char dapalnum); extern inline int gametext(int x,int y,char *t,char s,short dabits); @@ -143,10 +143,10 @@ extern inline int strget(short x,short y,char *t,short dalen,short c); extern void displayrest(long smoothratio); extern void updatesectorz(long x,long y,long z,short *sectnum); extern void drawbackground(void); -extern void displayrooms(short snum,long smoothratio); -extern short EGS(short whatsect,long s_x,long s_y,long s_z,short s_pn,signed char s_s,signed char s_xr,signed char s_yr,short s_a,short s_ve,long s_zv,short s_ow,signed char s_ss); +extern void displayrooms(int snum,long smoothratio); +extern int EGS(int whatsect,long s_x,long s_y,long s_z,int s_pn,int s_s,int s_xr,int s_yr,int s_a,int s_ve,long s_zv,int s_ow,int s_ss); extern char wallswitchcheck(short i); -extern short spawn(short j,short pn); +extern int spawn(int j,int pn); extern void animatesprites(long x,long y,short a,long smoothratio); extern int main(int argc,char **argv); extern void opendemowrite(void); @@ -181,7 +181,7 @@ extern void checkavailinven(struct player_struct *p); extern void checkavailweapon(struct player_struct *p); extern void hitradius(short i,long r,long hp1,long hp2,long hp3,long hp4); extern int movesprite(short spritenum,long xchange,long ychange,long zchange,unsigned long cliptype); -extern short ssp(short i,unsigned long cliptype); +extern int ssp(int i,unsigned long cliptype); extern void insertspriteq(short i); extern void lotsofmoney(spritetype *s,short n); extern void lotsofmail(spritetype *s, short n); @@ -189,8 +189,8 @@ extern void lotsofpaper(spritetype *s, short n); extern void guts(spritetype *s,short gtype,short n,short p); extern void setsectinterpolate(short i); extern void clearsectinterpolate(short i); -extern short ifhitsectors(short sectnum); -extern short ifhitbyweapon(short sn); +extern int ifhitsectors(int sectnum); +extern int ifhitbyweapon(int sn); extern void moveobjects(void); extern void movecyclers(void); extern void movedummyplayers(void); @@ -207,14 +207,14 @@ extern void txdigitalnumber(short starttile, long x,long y,long n,char s,char pa extern void myosx(long x,long y,short tilenum,signed char shade,char orientation); extern void myospalx(long x,long y,short tilenum,signed char shade,char orientation,char p); extern void ResetGameVars(void); -extern void ResetActorGameVars(short sActor); +extern void ResetActorGameVars(int iActor); extern void setupdynamictostatic(); extern void processnames(char *szLabel, long lValue); extern void LoadActor(long sActor); -extern long GetGameVar(char *szGameLabel, long lDefault, short sActor, short sPlayer); +extern long GetGameVar(char *szGameLabel, long lDefault, int iActor, int iPlayer); extern void DumpGameVars(FILE *fp); extern void AddLog(char *psz); @@ -224,14 +224,14 @@ extern void InitGameVars(void); extern void SaveGameVars(FILE *fil); extern int ReadGameVars(long fil); -extern long GetGameVarID(int id, short sActor, short sPlayer); -extern void SetGameVarID(int id, long lValue, short sActor, short sPlayer); +extern long GetGameVarID(int id, int iActor, int iPlayer); +extern void SetGameVarID(int id, long lValue, int iActor, int iPlayer); extern char AddGameVar(char *pszLabel, long lValue, unsigned long dwFlags); extern void ReportError(int iError); extern void onvideomodechange(int newmode); -extern void OnEvent(int iEventID, short sActor,short sPlayer,long lDist); +extern void OnEvent(int iEventID, int sActor, int sPlayer, long lDist); extern int isspritemakingsound(short i, int num); extern int issoundplaying(short i, int num); diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index b2abc63c5..bb6731f1b 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -1882,11 +1882,11 @@ void displayfragbar(void) #define SBY (200-tilesizy[BOTTOMSTATUSBAR]) -static void coolgaugetext(short snum) +static void coolgaugetext(int snum) { struct player_struct *p; long i, j, o, ss, u; - char permbit; + int permbit; p = &ps[snum]; @@ -2348,9 +2348,9 @@ static void tics(void) framecnt = ((framecnt+1)&(AVERAGEFRAMES-1)); } -static void coords(short snum) +static void coords(int snum) { - short y = 8; + int y = 8; if ((gametype_flags[ud.coop] & GAMETYPE_FLAG_FRAGBAR)) { @@ -3838,12 +3838,12 @@ static void se40code(long x,long y,long z,long a,long h, long smoothratio) static long oyrepeat=-1; -void displayrooms(short snum,long smoothratio) +void displayrooms(int snum,long smoothratio) { long cposx,cposy,cposz,dst,j,fz,cz; + long tposx,tposy,i; short sect, cang, k, choriz; struct player_struct *p; - long tposx,tposy,i; short tang; long tiltcx,tiltcy,tiltcs=0; // JBF 20030807 #ifdef POLYMOST @@ -4164,9 +4164,9 @@ static void dumpdebugdata(void) saveboard("debug.map",&ps[myconnectindex].posx,&ps[myconnectindex].posy,&ps[myconnectindex].posz,&ps[myconnectindex].ang,&ps[myconnectindex].cursectnum); } -short EGS(short whatsect,long s_x,long s_y,long s_z,short s_pn,signed char s_s,signed char s_xr,signed char s_yr,short s_a,short s_ve,long s_zv,short s_ow,signed char s_ss) +int EGS(int whatsect,long s_x,long s_y,long s_z,int s_pn,int s_s,int s_xr,int s_yr,int s_a,int s_ve,long s_zv,int s_ow,int s_ss) { - short i; + int i; long p; spritetype *s; @@ -4316,9 +4316,9 @@ char wallswitchcheck(short i) return 0; } -short spawn(short j, short pn) +int spawn(int j, int pn) { - short i, s, startwall, endwall, sect, clostest=0; + int i, s, startwall, endwall, sect, clostest=0; long x, y, d, p; spritetype *sp; @@ -5036,7 +5036,7 @@ short spawn(short j, short pn) case SHOTGUNSHELL__STATIC: if (j >= 0) { - short snum,a; + int snum,a; if (sprite[j].picnum == APLAYER) { diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index 9ecd0ed5d..27d5b312b 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -30,16 +30,16 @@ int conversion = 13; char compilefile[BMAX_PATH] = "(none)"; // file we're currently compiling static char parsing_item_name[MAXVARLABEL] = "(none)", previous_item_name[MAXVARLABEL] = "NULL"; -short total_lines,line_number; -static short checking_ifelse,parsing_state; +int total_lines,line_number; +static int checking_ifelse,parsing_state; char g_szBuf[1024]; long *casescriptptr=NULL; // the pointer to the start of the case table in a switch statement // first entry is 'default' code. -int casecount = 0; -signed short checking_switch = 0, current_event = -1; -char labelsonly = 0, nokeywordcheck = 0, dynamicremap = 0; -static short num_braces = 0; // init to some sensible defaults +static int casecount = 0; +static int checking_switch = 0, current_event = -1; +static int labelsonly = 0, nokeywordcheck = 0, dynamicremap = 0; +static int num_braces = 0; // init to some sensible defaults int redefined_quote_count = 0; @@ -84,6 +84,9 @@ MATTGAMEVAR aDefaultGameVars[MAXGAMEVARS]; // the 'original' values extern long qsetmode; +char *textptr; +int error,warning; + enum labeltypes { LABEL_ANY = -1, diff --git a/polymer/eduke32/source/gamedef.h b/polymer/eduke32/source/gamedef.h index 098fc696b..83cac6f76 100644 --- a/polymer/eduke32/source/gamedef.h +++ b/polymer/eduke32/source/gamedef.h @@ -53,8 +53,8 @@ extern long lastvisinc; extern void adduserquote(char *daquote); extern char cheatquotes[][MAXCHEATLEN]; extern char compilefile[BMAX_PATH]; -extern short total_lines,line_number; - +extern int total_lines,line_number; +extern int error,warning; typedef struct _labels { char *name; long lId; diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 1da82be3e..d1dc5d83d 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -28,9 +28,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "osd.h" -static short g_i,g_p; +static int g_i,g_p; static long g_x,*g_t; static spritetype *g_sp; +int killit_flag; extern int32 scripthandle; @@ -3002,16 +3003,11 @@ static void DoProjectile(int iSet, int lVar1, int lLabelID, int lVar2) static int parse(void); -void OnEvent(int iEventID, short sActor,short sPlayer,long lDist) +void OnEvent(int iEventID, int iActor, int iPlayer, long lDist) { - short og_i,og_p; - long og_x; - long *og_t; + int og_i, og_p, okillit_flag; + long og_x, *og_t, *oinsptr; spritetype *og_sp; - char okillit_flag; - long *oinsptr; - - int done; if (iEventID >= MAXGAMEEVENTS) { @@ -3035,8 +3031,8 @@ void OnEvent(int iEventID, short sActor,short sPlayer,long lDist) okillit_flag=killit_flag; oinsptr=insptr; - g_i = sActor; // current sprite ID - g_p = sPlayer; // current player ID + g_i = iActor; // current sprite ID + g_p = iPlayer; // current player ID g_x = lDist; // ? g_sp = &sprite[g_i]; g_t = &hittype[g_i].temp_data[0]; @@ -3046,9 +3042,8 @@ void OnEvent(int iEventID, short sActor,short sPlayer,long lDist) //AddLog(g_szBuf); killit_flag = 0; - do - done = parse(); - while (done == 0); + + while (1) if (parse()) break; if (killit_flag == 1) { @@ -3114,9 +3109,7 @@ static long ifsquished(short i, short p) static void forceplayerangle(struct player_struct *p) { - short n; - - n = 128-(TRAND&255); + int n = 128-(TRAND&255); p->horiz += 64; p->return_to_center = 9; @@ -3126,13 +3119,10 @@ static void forceplayerangle(struct player_struct *p) static char dodge(spritetype *s) { - short i; - long bx,by,mx,my,bxvect,byvect,mxvect,myvect,d; - - mx = s->x; - my = s->y; - mxvect = sintable[(s->ang+512)&2047]; - myvect = sintable[s->ang&2047]; + long bx,by,bxvect,byvect,d,i; + long mx = s->x, my = s->y; + long mxvect = sintable[(s->ang+512)&2047]; + long myvect = sintable[s->ang&2047]; for (i=headspritestat[4];i>=0;i=nextspritestat[i]) //weapons list { @@ -3158,14 +3148,13 @@ static char dodge(spritetype *s) return 0; } -short furthestangle(short sActor,short angs) +int furthestangle(int iActor,int angs) { - short j, hitsect,hitwall,hitspr,furthest_angle=0, angincs; - long hx, hy, hz, d, greatestd; - spritetype *s = &sprite[sActor]; - - greatestd = -(1<<30); - angincs = 2048/angs; + short hitsect,hitwall,hitspr,furthest_angle=0; + long hx, hy, hz, d; + spritetype *s = &sprite[iActor]; + long greatestd = -(1<<30); + int angincs = 2048/angs,j; if (s->picnum != APLAYER) if ((g_t[0]&63) > 2) return(s->ang + 1024); @@ -3188,11 +3177,12 @@ short furthestangle(short sActor,short angs) return (furthest_angle&2047); } -short furthestcanseepoint(short sActor,spritetype *ts,long *dax,long *day) +int furthestcanseepoint(int iActor,spritetype *ts,long *dax,long *day) { - short j, hitsect,hitwall,hitspr, angincs; + short hitsect,hitwall,hitspr, angincs; long hx, hy, hz, d, da;//, d, cd, ca,tempx,tempy,cx,cy; - spritetype *s = &sprite[sActor]; + int j; + spritetype *s = &sprite[iActor]; if ((g_t[0]&63)) return -1; @@ -3221,11 +3211,11 @@ short furthestcanseepoint(short sActor,spritetype *ts,long *dax,long *day) return -1; } -void getglobalz(short sActor) +void getglobalz(int iActor) { long hz,lz,zr; - spritetype *s = &sprite[sActor]; + spritetype *s = &sprite[iActor]; if (s->statnum == 10 || s->statnum == 6 || s->statnum == 2 || s->statnum == 1 || s->statnum == 4) { @@ -3234,7 +3224,7 @@ void getglobalz(short sActor) if (s->statnum == 4) zr = 4L; - getzrange(s->x,s->y,s->z-(FOURSLEIGHT),s->sectnum,&hittype[sActor].ceilingz,&hz,&hittype[sActor].floorz,&lz,zr,CLIPMASK0); + getzrange(s->x,s->y,s->z-(FOURSLEIGHT),s->sectnum,&hittype[iActor].ceilingz,&hz,&hittype[iActor].floorz,&lz,zr,CLIPMASK0); if ((lz&49152) == 49152 && (sprite[lz&(MAXSPRITES-1)].cstat&48) == 0) { @@ -3243,35 +3233,35 @@ void getglobalz(short sActor) { if (s->statnum != 4) { - hittype[sActor].dispicnum = -4; // No shadows on actors + hittype[iActor].dispicnum = -4; // No shadows on actors s->xvel = -256; - ssp(sActor,CLIPMASK0); + ssp(iActor,CLIPMASK0); } } else if (sprite[lz].picnum == APLAYER && badguy(s)) { - hittype[sActor].dispicnum = -4; // No shadows on actors + hittype[iActor].dispicnum = -4; // No shadows on actors s->xvel = -256; - ssp(sActor,CLIPMASK0); + ssp(iActor,CLIPMASK0); } else if (s->statnum == 4 && sprite[lz].picnum == APLAYER) if (s->owner == lz) { - hittype[sActor].ceilingz = sector[s->sectnum].ceilingz; - hittype[sActor].floorz = sector[s->sectnum].floorz; + hittype[iActor].ceilingz = sector[s->sectnum].ceilingz; + hittype[iActor].floorz = sector[s->sectnum].floorz; } } } else { - hittype[sActor].ceilingz = sector[s->sectnum].ceilingz; - hittype[sActor].floorz = sector[s->sectnum].floorz; + hittype[iActor].ceilingz = sector[s->sectnum].ceilingz; + hittype[iActor].floorz = sector[s->sectnum].floorz; } } -void makeitfall(short sActor) +void makeitfall(int iActor) { - spritetype *s = &sprite[sActor]; + spritetype *s = &sprite[iActor]; long hz,lz,c; if (floorspace(s->sectnum)) @@ -3284,14 +3274,14 @@ void makeitfall(short sActor) } if ((s->statnum == 1 || s->statnum == 10 || s->statnum == 2 || s->statnum == 6)) - getzrange(s->x,s->y,s->z-(FOURSLEIGHT),s->sectnum,&hittype[sActor].ceilingz,&hz,&hittype[sActor].floorz,&lz,127L,CLIPMASK0); + getzrange(s->x,s->y,s->z-(FOURSLEIGHT),s->sectnum,&hittype[iActor].ceilingz,&hz,&hittype[iActor].floorz,&lz,127L,CLIPMASK0); else { - hittype[sActor].ceilingz = sector[s->sectnum].ceilingz; - hittype[sActor].floorz = sector[s->sectnum].floorz; + hittype[iActor].ceilingz = sector[s->sectnum].ceilingz; + hittype[iActor].floorz = sector[s->sectnum].floorz; } - if (s->z < hittype[sActor].floorz-(FOURSLEIGHT)) + if (s->z < hittype[iActor].floorz-(FOURSLEIGHT)) { if (sector[s->sectnum].lotag == 2 && s->zvel > 3122) s->zvel = 3144; @@ -3300,14 +3290,14 @@ void makeitfall(short sActor) else s->zvel = 6144; s->z += s->zvel; } - if (s->z >= hittype[sActor].floorz-(FOURSLEIGHT)) + if (s->z >= hittype[iActor].floorz-(FOURSLEIGHT)) { - s->z = hittype[sActor].floorz - FOURSLEIGHT; + s->z = hittype[iActor].floorz - FOURSLEIGHT; s->zvel = 0; } } -short getincangle(short a,short na) +int getincangle(int a,int na) { a &= 2047; na &= 2047; @@ -3323,10 +3313,11 @@ short getincangle(short a,short na) return (na-a); } -static void alterang(short a) +static void alterang(int a) { - short aang, angdif, goalang,j; + short aang, angdif, goalang; long ticselapsed, *moveptr; + int j; moveptr = (long *)g_t[1]; @@ -6405,12 +6396,10 @@ static int parse(void) return 0; } -void LoadActor(long sActor) +void LoadActor(long iActor) { - char done; - - g_i = sActor; // Sprite ID - g_p = -1; // sPlayer; // Player ID + g_i = iActor; // Sprite ID + g_p = -1; // iPlayer; // Player ID g_x = -1; // lDist; // ?? g_sp = &sprite[g_i]; // Pointer to sprite structure g_t = &hittype[g_i].temp_data[0]; // Sprite's 'extra' data @@ -6428,9 +6417,8 @@ void LoadActor(long sActor) deletesprite(g_i); return; } - do - done = parse(); - while (done == 0); + + while (1) if (parse()) break; if (killit_flag == 1) { @@ -6446,8 +6434,6 @@ void LoadActor(long sActor) void execute(int iActor,int iPlayer,long lDist) { - char done; - g_i = iActor; // Sprite ID g_p = iPlayer; // Player ID g_x = lDist; // ?? @@ -6483,9 +6469,7 @@ void execute(int iActor,int iPlayer,long lDist) g_t[3] = 0; } - do - done = parse(); - while (done == 0); + while (1) if (parse()) break; if (killit_flag == 1) { diff --git a/polymer/eduke32/source/gamevars.c b/polymer/eduke32/source/gamevars.c index 66b39a812..5e9c92a48 100755 --- a/polymer/eduke32/source/gamevars.c +++ b/polymer/eduke32/source/gamevars.c @@ -382,15 +382,15 @@ char AddGameVar(char *pszLabel, long lValue, unsigned long dwFlags) } } -void ResetActorGameVars(short sActor) +void ResetActorGameVars(int iActor) { int i; - // OSD_Printf("resetting vars for actor %d\n",sActor); + // OSD_Printf("resetting vars for actor %d\n",iActor); for (i=0;i= iGameVarCount) { @@ -436,12 +436,12 @@ long GetGameVarID(int id, short sActor, short sPlayer) if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERPLAYER) { // for the current player - if (sPlayer >=0 && sPlayer < MAXPLAYERS) + if (iPlayer >=0 && iPlayer < MAXPLAYERS) { - //Bsprintf(g_szBuf,"GetGameVarID(%d, %d, %d) returns %ld\n",id,sActor,sPlayer, aGameVars[id].plValues[sPlayer]); + //Bsprintf(g_szBuf,"GetGameVarID(%d, %d, %d) returns %ld\n",id,iActor,iPlayer, aGameVars[id].plValues[iPlayer]); //AddLog(g_szBuf); - if (inv) return (-aGameVars[id].plValues[sPlayer]); - return (aGameVars[id].plValues[sPlayer]); + if (inv) return (-aGameVars[id].plValues[iPlayer]); + return (aGameVars[id].plValues[iPlayer]); } if (inv) return (-aGameVars[id].lValue); @@ -451,10 +451,10 @@ long GetGameVarID(int id, short sActor, short sPlayer) if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR) { // for the current actor - if (sActor >= 0 && sActor <=MAXSPRITES) + if (iActor >= 0 && iActor <=MAXSPRITES) { - if (inv) return (-aGameVars[id].plValues[sActor]); - return (aGameVars[id].plValues[sActor]); + if (inv) return (-aGameVars[id].plValues[iActor]); + return (aGameVars[id].plValues[iActor]); } if (inv) return (-aGameVars[id].lValue); @@ -471,26 +471,26 @@ long GetGameVarID(int id, short sActor, short sPlayer) return (aGameVars[id].lValue); } -void SetGameVarID(int id, long lValue, short sActor, short sPlayer) +void SetGameVarID(int id, long lValue, int iActor, int iPlayer) { if (id<0 || id >= iGameVarCount) { AddLog("Invalid Game ID"); return; } - //Bsprintf(g_szBuf,"SGVI: %d ('%s') to %ld for %d %d",id,aGameVars[id].szLabel,lValue,sActor,sPlayer); + //Bsprintf(g_szBuf,"SGVI: %d ('%s') to %ld for %d %d",id,aGameVars[id].szLabel,lValue,iActor,iPlayer); //AddLog(g_szBuf); - if ((aGameVars[id].dwFlags & GAMEVAR_FLAG_PERPLAYER) && (sPlayer != -1)) + if ((aGameVars[id].dwFlags & GAMEVAR_FLAG_PERPLAYER) && (iPlayer != -1)) { // for the current player - aGameVars[id].plValues[sPlayer]=lValue; + aGameVars[id].plValues[iPlayer]=lValue; return; } - if ((aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR) && (sActor != -1)) + if ((aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR) && (iActor != -1)) { // for the current actor - aGameVars[id].plValues[sActor]=lValue; + aGameVars[id].plValues[iActor]=lValue; return; } @@ -504,7 +504,7 @@ void SetGameVarID(int id, long lValue, short sActor, short sPlayer) aGameVars[id].lValue=lValue; } -long GetGameVar(char *szGameLabel, long lDefault, short sActor, short sPlayer) +long GetGameVar(char *szGameLabel, long lDefault, int iActor, int iPlayer) { int i=0; for (;i 32) fisti = 32; if (fisti <= 0) return 0; - looking_arc = klabs(ps[*snum].look_ang)/9; + looking_arc = klabs(ps[snum].look_ang)/9; fistzoom = 65536L - (sintable[(512+(fisti<<6))&2047]<<2); if (fistzoom > 90612L) @@ -1830,61 +1830,61 @@ static int animatefist(const short *gs,const short *snum) fistzoom = 40290; fistz = 194 + (sintable[((6+fisti)<<7)&2047]>>9); - if (sprite[ps[*snum].i].pal == 1) + if (sprite[ps[snum].i].pal == 1) fistpal = 1; else - fistpal = sector[ps[*snum].cursectnum].floorpal; + fistpal = sector[ps[snum].cursectnum].floorpal; rotatesprite( - (-fisti+222+(sync[*snum].avel>>4))<<16, + (-fisti+222+(sync[snum].avel>>4))<<16, (looking_arc+fistz)<<16, - fistzoom,0,FIST,*gs,fistpal,2,0,0,xdim-1,ydim-1); + fistzoom,0,FIST,gs,fistpal,2,0,0,xdim-1,ydim-1); return 1; } -static int animateknee(const short *gs,const short *snum) +static int animateknee(int gs,int snum) { short knee_y[] = {0,-8,-16,-32,-64,-84,-108,-108,-108,-72,-32,-8}; - short looking_arc, pal; + int looking_arc, pal; - if (ps[*snum].knee_incs > 11 || ps[*snum].knee_incs == 0 || sprite[ps[*snum].i].extra <= 0) return 0; + if (ps[snum].knee_incs > 11 || ps[snum].knee_incs == 0 || sprite[ps[snum].i].extra <= 0) return 0; - looking_arc = knee_y[ps[*snum].knee_incs] + klabs(ps[*snum].look_ang)/9; + looking_arc = knee_y[ps[snum].knee_incs] + klabs(ps[snum].look_ang)/9; - looking_arc -= (ps[*snum].hard_landing<<3); + looking_arc -= (ps[snum].hard_landing<<3); - if (sprite[ps[*snum].i].pal == 1) + if (sprite[ps[snum].i].pal == 1) pal = 1; else { - pal = sector[ps[*snum].cursectnum].floorpal; + pal = sector[ps[snum].cursectnum].floorpal; if (pal == 0) - pal = ps[*snum].palookup; + pal = ps[snum].palookup; } - myospal(105+(sync[*snum].avel>>4)-(ps[*snum].look_ang>>1)+(knee_y[ps[*snum].knee_incs]>>2),looking_arc+280-((ps[*snum].horiz-ps[*snum].horizoff)>>4),KNEE,*gs,4,pal); + myospal(105+(sync[snum].avel>>4)-(ps[snum].look_ang>>1)+(knee_y[ps[snum].knee_incs]>>2),looking_arc+280-((ps[snum].horiz-ps[snum].horizoff)>>4),KNEE,gs,4,pal); return 1; } -static int animateknuckles(const short *gs,const short *snum) +static int animateknuckles(int gs,int snum) { short knuckle_frames[] = {0,1,2,2,3,3,3,2,2,1,0}; - short looking_arc, pal; + int looking_arc, pal; - if (ps[*snum].knuckle_incs == 0 || sprite[ps[*snum].i].extra <= 0) return 0; + if (ps[snum].knuckle_incs == 0 || sprite[ps[snum].i].extra <= 0) return 0; - looking_arc = klabs(ps[*snum].look_ang)/9; + looking_arc = klabs(ps[snum].look_ang)/9; - looking_arc -= (ps[*snum].hard_landing<<3); + looking_arc -= (ps[snum].hard_landing<<3); - if (sprite[ps[*snum].i].pal == 1) + if (sprite[ps[snum].i].pal == 1) pal = 1; else - pal = sector[ps[*snum].cursectnum].floorpal; + pal = sector[ps[snum].cursectnum].floorpal; - myospal(160+(sync[*snum].avel>>4)-(ps[*snum].look_ang>>1),looking_arc+180-((ps[*snum].horiz-ps[*snum].horizoff)>>4),CRACKKNUCKLES+knuckle_frames[ps[*snum].knuckle_incs>>1],*gs,4,pal); + myospal(160+(sync[snum].avel>>4)-(ps[snum].look_ang>>1),looking_arc+180-((ps[snum].horiz-ps[snum].horizoff)>>4),CRACKKNUCKLES+knuckle_frames[ps[snum].knuckle_incs>>1],gs,4,pal); return 1; } @@ -1893,9 +1893,7 @@ long lastvisinc; void DoFire(struct player_struct *p) { - int i; - - short snum = sprite[p->i].yvel; + int i, snum = sprite[p->i].yvel; SetGameVarID(g_iReturnVarID,0,p->i,snum); OnEvent(EVENT_DOFIRE, p->i, snum, -1); @@ -1948,9 +1946,7 @@ void DoFire(struct player_struct *p) void DoSpawn(struct player_struct *p) { - int j; - - short snum = sprite[p->i].yvel; + int j, snum = sprite[p->i].yvel; if (!aplWeaponSpawn[p->curr_weapon][snum]) return; @@ -1970,9 +1966,9 @@ void DoSpawn(struct player_struct *p) } -void displaymasks(short snum) +void displaymasks(int snum) { - short p; + int p; if (sprite[ps[snum].i].pal == 1) p = 1; @@ -1986,53 +1982,53 @@ void displaymasks(short snum) } } -static int animatetip(const short *gs,const short *snum) +static int animatetip(int gs,int snum) { - short p,looking_arc; + int p,looking_arc; short tip_y[] = {0,-8,-16,-32,-64,-84,-108,-108,-108,-108,-108,-108,-108,-108,-108,-108,-96,-72,-64,-32,-16}; - if (ps[*snum].tipincs == 0) return 0; + if (ps[snum].tipincs == 0) return 0; - looking_arc = klabs(ps[*snum].look_ang)/9; - looking_arc -= (ps[*snum].hard_landing<<3); + looking_arc = klabs(ps[snum].look_ang)/9; + looking_arc -= (ps[snum].hard_landing<<3); - if (sprite[ps[*snum].i].pal == 1) + if (sprite[ps[snum].i].pal == 1) p = 1; else - p = sector[ps[*snum].cursectnum].floorpal; + p = sector[ps[snum].cursectnum].floorpal; /* if(ps[snum].access_spritenum >= 0) p = sprite[ps[snum].access_spritenum].pal; else p = wall[ps[snum].access_wallnum].pal; */ - myospal(170+(sync[*snum].avel>>4)-(ps[*snum].look_ang>>1), - (tip_y[ps[*snum].tipincs]>>1)+looking_arc+240-((ps[*snum].horiz-ps[*snum].horizoff)>>4),TIP+((26-ps[*snum].tipincs)>>4),*gs,0,p); + myospal(170+(sync[snum].avel>>4)-(ps[snum].look_ang>>1), + (tip_y[ps[snum].tipincs]>>1)+looking_arc+240-((ps[snum].horiz-ps[snum].horizoff)>>4),TIP+((26-ps[snum].tipincs)>>4),gs,0,p); return 1; } -static int animateaccess(const short *gs,const short *snum) +static int animateaccess(int gs,int snum) { short access_y[] = {0,-8,-16,-32,-64,-84,-108,-108,-108,-108,-108,-108,-108,-108,-108,-108,-96,-72,-64,-32,-16}; - short looking_arc; - char p; + int looking_arc; + int p; - if (ps[*snum].access_incs == 0 || sprite[ps[*snum].i].extra <= 0) return 0; + if (ps[snum].access_incs == 0 || sprite[ps[snum].i].extra <= 0) return 0; - looking_arc = access_y[ps[*snum].access_incs] + klabs(ps[*snum].look_ang)/9; - looking_arc -= (ps[*snum].hard_landing<<3); + looking_arc = access_y[ps[snum].access_incs] + klabs(ps[snum].look_ang)/9; + looking_arc -= (ps[snum].hard_landing<<3); - if (ps[*snum].access_spritenum >= 0) - p = sprite[ps[*snum].access_spritenum].pal; + if (ps[snum].access_spritenum >= 0) + p = sprite[ps[snum].access_spritenum].pal; else p = 0; // else - // p = wall[ps[*snum].access_wallnum].pal; + // p = wall[ps[snum].access_wallnum].pal; - if ((ps[*snum].access_incs-3) > 0 && (ps[*snum].access_incs-3)>>3) - myospal(170+(sync[*snum].avel>>4)-(ps[*snum].look_ang>>1)+(access_y[ps[*snum].access_incs]>>2),looking_arc+266-((ps[*snum].horiz-ps[*snum].horizoff)>>4),HANDHOLDINGLASER+(ps[*snum].access_incs>>3),*gs,0,p); + if ((ps[snum].access_incs-3) > 0 && (ps[snum].access_incs-3)>>3) + myospal(170+(sync[snum].avel>>4)-(ps[snum].look_ang>>1)+(access_y[ps[snum].access_incs]>>2),looking_arc+266-((ps[snum].horiz-ps[snum].horizoff)>>4),HANDHOLDINGLASER+(ps[snum].access_incs>>3),gs,0,p); else - myospal(170+(sync[*snum].avel>>4)-(ps[*snum].look_ang>>1)+(access_y[ps[*snum].access_incs]>>2),looking_arc+266-((ps[*snum].horiz-ps[*snum].horizoff)>>4),HANDHOLDINGACCESS,*gs,4,p); + myospal(170+(sync[snum].avel>>4)-(ps[snum].look_ang>>1)+(access_y[ps[snum].access_incs]>>2),looking_arc+266-((ps[snum].horiz-ps[snum].horizoff)>>4),HANDHOLDINGACCESS,gs,4,p); return 1; } @@ -2068,14 +2064,14 @@ short fistsign; char last_quick_kick[MAXPLAYERS]; -void displayweapon(short snum) +void displayweapon(int snum) { long gun_pos, looking_arc, cw; long weapon_xoffset, i, j; - char o,pal; + int o,pal; struct player_struct *p; short *kb; - short gs; + int gs; p = &ps[snum]; kb = &p->kickback_pic; @@ -2087,10 +2083,10 @@ void displayweapon(short snum) gs = sprite[p->i].shade; if (gs > 24) gs = 24; - if (p->newowner >= 0 || ud.camerasprite >= 0 || p->over_shoulder_on > 0 || (sprite[p->i].pal != 1 && sprite[p->i].extra <= 0) || animatefist(&gs,&snum) || animateknuckles(&gs,&snum) || animatetip(&gs,&snum) || animateaccess(&gs,&snum)) + if (p->newowner >= 0 || ud.camerasprite >= 0 || p->over_shoulder_on > 0 || (sprite[p->i].pal != 1 && sprite[p->i].extra <= 0) || animatefist(gs,snum) || animateknuckles(gs,snum) || animatetip(gs,snum) || animateaccess(gs,snum)) return; - animateknee(&gs,&snum); + animateknee(gs,snum); gun_pos = 80-(p->weapon_pos*p->weapon_pos); @@ -2665,9 +2661,9 @@ static ControlInfo lastinfo = char jump_input = 0; -void getinput(short snum) +void getinput(int snum) { - short j, daang; + int j, daang; ControlInfo info; int32 tics; boolean running; @@ -2984,9 +2980,8 @@ void getinput(short snum) static char doincrements(struct player_struct *p) { - short snum; - - snum = sprite[p->i].yvel; + int snum = sprite[p->i].yvel; + // j = sync[snum].avel; // p->weapon_ang = -(j/5); @@ -3190,8 +3185,7 @@ short weapon_sprites[MAX_WEAPONS] = { KNEE__STATIC, FIRSTGUNSPRITE__STATIC, SHOT void checkweapons(struct player_struct *p) { - short cw; - short snum = sprite[p->i].yvel; + int cw, snum = sprite[p->i].yvel; cw = aplWeaponWorksLike[p->curr_weapon][snum]; @@ -3211,14 +3205,16 @@ void checkweapons(struct player_struct *p) } } -void processinput(short snum) +void processinput(int snum) { long j, i, k, doubvel, fz, cz, hz, lz, truefdist, x, y; - char shrunk; + int shrunk; unsigned long sb_snum; - short psect, psectlotag,*kb, tempsect, pi; - struct player_struct *p; - spritetype *s; + int psect, psectlotag; + short *kb, tempsect; + struct player_struct *p = &ps[snum]; + int pi = p->i; + spritetype *s = &sprite[pi]; p = &ps[snum]; pi = p->i; diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index 3b9598007..21fef1d2e 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -523,15 +523,14 @@ void vscrn(void) pus = NUMPAGES; } -void pickrandomspot(short snum) +void pickrandomspot(int snum) { struct player_struct *p; - short i=0,j,k; + int i=snum,j,k; unsigned long dist,pdist = -1; p = &ps[snum]; - i = snum; if (ud.multimode > 1 && !(gametype_flags[ud.coop] & GAMETYPE_FLAG_FIXEDRESPAWN)) { i = TRAND%numplayersprites; @@ -560,7 +559,7 @@ void pickrandomspot(short snum) p->cursectnum = po[i].os; } -static void resetplayerstats(short snum) +static void resetplayerstats(int snum) { struct player_struct *p; @@ -670,9 +669,9 @@ static void resetplayerstats(short snum) OnEvent(EVENT_RESETPLAYER, p->i, snum, -1); } -void resetweapons(short snum) +void resetweapons(int snum) { - short weapon; + int weapon; struct player_struct *p; p = &ps[snum]; @@ -697,7 +696,7 @@ void resetweapons(short snum) OnEvent(EVENT_RESETWEAPONS, p->i, snum, -1); } -void resetinventory(short snum) +void resetinventory(int snum) { struct player_struct *p; @@ -720,10 +719,10 @@ void resetinventory(short snum) OnEvent(EVENT_RESETINVENTORY, p->i, snum, -1); } -static void resetprestat(short snum,char g) +static void resetprestat(int snum,int g) { struct player_struct *p; - short i; + int i; p = &ps[snum]; diff --git a/polymer/eduke32/source/sector.c b/polymer/eduke32/source/sector.c index 0257b7404..c816f55cb 100644 --- a/polymer/eduke32/source/sector.c +++ b/polymer/eduke32/source/sector.c @@ -26,9 +26,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // PRIMITIVE char haltsoundhack; -short callsound(short sn,short whatsprite) +int callsound(int sn,int whatsprite) { - short i; + int i; if (haltsoundhack) { haltsoundhack = 0; @@ -72,9 +72,9 @@ short callsound(short sn,short whatsprite) return -1; } -short check_activator_motion(short lotag) +int check_activator_motion(int lotag) { - short i, j; + int i, j; spritetype *s; i = headspritestat[8]; @@ -116,7 +116,7 @@ short check_activator_motion(short lotag) return(0); } -char isadoorwall(short dapic) +int isadoorwall(int dapic) { switch (dynamictostatic[dapic]) { @@ -147,7 +147,7 @@ char isadoorwall(short dapic) return 0; } -char isanunderoperator(short lotag) +int isanunderoperator(int lotag) { switch (lotag&0xff) { @@ -163,7 +163,7 @@ char isanunderoperator(short lotag) return 0; } -char isanearoperator(short lotag) +int isanearoperator(int lotag) { switch (lotag&0xff) { @@ -185,9 +185,9 @@ char isanearoperator(short lotag) return 0; } -short checkcursectnums(short sect) +int checkcursectnums(int sect) { - short i; + int i; for (i=connecthead;i>=0;i=connectpoint2[i]) if (sprite[ps[i].i].sectnum == sect) return i; return -1; @@ -210,9 +210,9 @@ long dist(spritetype *s1,spritetype *s2) return(FindDistance3D(vx,vy,vz>>4)); } -short findplayer(spritetype *s,long *d) +int findplayer(spritetype *s,long *d) { - short j, closest_player; + int j, closest_player; long x, closest; if (ud.multimode < 2) @@ -238,9 +238,9 @@ short findplayer(spritetype *s,long *d) return closest_player; } -short findotherplayer(short p,long *d) +int findotherplayer(int p,long *d) { - short j, closest_player; + int j, closest_player; long x, closest; closest = 0x7fffffff; @@ -982,11 +982,10 @@ REDODOOR: } } -void operaterespawns(short low) +void operaterespawns(int low) { - short i, j, nexti; + int j, nexti, i = headspritestat[11]; - i = headspritestat[11]; while (i >= 0) { nexti = nextspritestat[i]; @@ -1003,9 +1002,10 @@ void operaterespawns(short low) } } -void operateactivators(short low,short snum) +void operateactivators(int low,int snum) { - short i, j, k, *p; + int i, j, k; + short *p; walltype *wal; for (i=numcyclers-1;i>=0;i--) @@ -1096,11 +1096,9 @@ void operateactivators(short low,short snum) operaterespawns(low); } -void operatemasterswitches(short low) +void operatemasterswitches(int low) { - short i; - - i = headspritestat[6]; + int i = headspritestat[6]; while (i >= 0) { if (PN == MASTERSWITCH && SLT == low && SP == 0) @@ -1109,9 +1107,9 @@ void operatemasterswitches(short low) } } -void operateforcefields(short s, short low) +void operateforcefields(short s, int low) { - short i, p; + int i, p; for (p=numanimwalls;p>=0;p--) { @@ -1138,10 +1136,10 @@ void operateforcefields(short s, short low) } } -char checkhitswitch(short snum,long w,char switchtype) +char checkhitswitch(int snum,long w,int switchtype) { char switchpal; - short i, x, lotag,hitag,picnum,correctdips,numdips; + int i, x, lotag,hitag,picnum,correctdips,numdips; long sx,sy; int switchpicnum; @@ -1597,11 +1595,9 @@ char checkhitswitch(short snum,long w,char switchtype) void activatebysector(short sect,short j) { - short i,didit; + int i = headspritesect[sect]; + int didit = 0; - didit = 0; - - i = headspritesect[sect]; while (i >= 0) { if (PN == ACTIVATOR) @@ -2524,9 +2520,9 @@ void allignwarpelevators(void) } } -void sharedkeys(short snum) +void sharedkeys(int snum) { - short i, k; + int i, k; char dainv; unsigned long sb_snum, j; struct player_struct *p; @@ -3215,7 +3211,7 @@ static long hitawall(struct player_struct *p,short *hitw) } -void checksectors(short snum) +void checksectors(int snum) { long i = -1,oldz; struct player_struct *p;