From 8d6f8eecda3343a29c4b5317c474c0683fde59c3 Mon Sep 17 00:00:00 2001 From: terminx Date: Sun, 23 Apr 2006 02:20:42 +0000 Subject: [PATCH] Made fta_quotes dynamically allocated at compile time git-svn-id: https://svn.eduke32.com/eduke32@92 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/duke3d.h | 2 +- polymer/eduke32/source/game.c | 28 ++++++++++++---------------- polymer/eduke32/source/gamedef.c | 31 +++++++++++++++++++++---------- polymer/eduke32/source/gamedef.h | 2 +- polymer/eduke32/source/gameexec.c | 17 ++++++++++------- polymer/eduke32/source/global.c | 2 +- polymer/eduke32/source/player.c | 10 +++++----- polymer/eduke32/source/savegame.c | 1 - polymer/eduke32/source/sector.c | 11 +++-------- polymer/eduke32/source/sounds.c | 2 +- 10 files changed, 55 insertions(+), 51 deletions(-) diff --git a/polymer/eduke32/source/duke3d.h b/polymer/eduke32/source/duke3d.h index 6ab314e52..86732198f 100644 --- a/polymer/eduke32/source/duke3d.h +++ b/polymer/eduke32/source/duke3d.h @@ -431,7 +431,7 @@ extern short int global_random; extern long scaredfallz; extern char buf[1024]; //My own generic input buffer -extern char fta_quotes[NUMOFFIRSTTIMEACTIVE][64]; +extern char *fta_quotes[NUMOFFIRSTTIMEACTIVE]; extern char scantoasc[128],ready2send; extern char scantoascwithshift[128]; diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 1d96e62df..1b8c0dc41 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -2076,7 +2076,8 @@ void FTA(short q,struct player_struct *p) p->ftq = q; pub = NUMPAGES; pus = NUMPAGES; - if (p == &ps[screenpeek]) OSD_Printf("%s\n",fta_quotes[q]); + if (p == &ps[screenpeek]) + OSD_Printf("%s\n",fta_quotes[q]); } } } @@ -6648,10 +6649,8 @@ FOUNDCHEAT: sprite[ps[myconnectindex].i].hitag = 0; sprite[ps[myconnectindex].i].lotag = 0; - sprite[ps[myconnectindex].i].pal = - ps[myconnectindex].palookup; - - Bsprintf(fta_quotes[122],"Scream for me, Long Beach!"); + sprite[ps[myconnectindex].i].pal = ps[myconnectindex].palookup; + Bstrcpy(fta_quotes[122],"Scream for me, Long Beach!"); FTA(122,&ps[myconnectindex]); } else @@ -7054,8 +7053,7 @@ void nonsharedkeys(void) music_select++; if(music_select == i) music_select = 0; - Bstrcpy(&fta_quotes[26][0],"PLAYING "); - Bstrcat(&fta_quotes[26][0],&music_fn[0][music_select][0]); + Bsprintf(fta_quotes[26],"PLAYING %s",&music_fn[0][music_select][0]); FTA(26,&ps[myconnectindex]); playmusic(&music_fn[0][music_select][0]); return; @@ -7273,9 +7271,8 @@ FAKE_F3: if( KB_KeyPressed( sc_F5 ) && MusicDevice >= 0 ) { KB_ClearKeyDown( sc_F5 ); - strcpy(&tempbuf[0],&music_fn[0][music_select][0]); - strcat(&tempbuf[0],". USE SHIFT-F5 TO CHANGE."); - strcpy(&fta_quotes[26][0],&tempbuf[0]); + Bstrcpy(fta_quotes[26],&music_fn[0][music_select][0]); + Bstrcat(fta_quotes[26],". USE SHIFT-F5 TO CHANGE."); FTA(26,&ps[myconnectindex]); } @@ -9618,13 +9615,12 @@ char domovethings(void) if(multiwho != myconnectindex) { - strcpy(fta_quotes[122],&ud.user_name[multiwho][0]); - strcat(fta_quotes[122]," SAVED A MULTIPLAYER GAME"); + Bsprintf(fta_quotes[122],"%s SAVED A MULTIPLAYER GAME",&ud.user_name[multiwho][0]); FTA(122,&ps[myconnectindex]); } else { - strcpy(fta_quotes[122],"MULTIPLAYER GAME SAVED"); + Bstrcpy(fta_quotes[122],"MULTIPLAYER GAME SAVED"); FTA(122,&ps[myconnectindex]); } break; @@ -9641,13 +9637,12 @@ char domovethings(void) { if(multiwho != myconnectindex) { - strcpy(fta_quotes[122],&ud.user_name[multiwho][0]); - strcat(fta_quotes[122]," LOADED A MULTIPLAYER GAME"); + Bsprintf(fta_quotes[122],"%s LOADED A MULTIPLAYER GAME",&ud.user_name[multiwho][0]); FTA(122,&ps[myconnectindex]); } else { - strcpy(fta_quotes[122],"MULTIPLAYER GAME LOADED"); + Bstrcpy(fta_quotes[122],"MULTIPLAYER GAME LOADED"); FTA(122,&ps[myconnectindex]); } return 1; @@ -9712,6 +9707,7 @@ char domovethings(void) Bsprintf(buf,"%s is history!",ud.user_name[i]); adduserquote(buf); Bstrcpy(fta_quotes[116],buf); + ps[myconnectindex].ftq = 116, ps[myconnectindex].fta = 60; if(j < 0 && networkmode == 0 ) diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index 34163ce2c..7c890a562 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -41,8 +41,8 @@ signed char checking_switch = 0, current_event = -1; char labelsonly = 0, nokeywordcheck = 0, dynamicremap = 0; static short num_braces = 0; // init to some sensible defaults -char redefined_fta_quotes[NUMOFFIRSTTIMEACTIVE][64]; -int redefined_quotes = 0; +char *redefined_quotes[NUMOFFIRSTTIMEACTIVE]; +int redefined_quote_count = 0; long *aplWeaponClip[MAX_WEAPONS]; // number of items in magazine long *aplWeaponReload[MAX_WEAPONS]; // delay to reload (include fire) @@ -4539,7 +4539,11 @@ repeatcase: } if (tw == CON_DEFINEQUOTE) + { + if(fta_quotes[k] == NULL) + fta_quotes[k] = Bmalloc(sizeof(char) * 64); scriptptr--; + } i = 0; @@ -4547,7 +4551,11 @@ repeatcase: textptr++; if (tw == CON_REDEFINEQUOTE) - redefined_quotes++; + { + redefined_quote_count++; + if(redefined_quotes[redefined_quote_count] == NULL) + redefined_quotes[redefined_quote_count] = Bmalloc(sizeof(char) * 64); + } while( *textptr != 0x0a && *textptr != 0x0d && *textptr != 0 ) { @@ -4559,23 +4567,26 @@ repeatcase: break; } if (tw == CON_DEFINEQUOTE) - fta_quotes[k][i] = *textptr; - else redefined_fta_quotes[redefined_quotes][i] = *textptr; + *(fta_quotes[k]+i) = *textptr; + else + *(redefined_quotes[redefined_quote_count]+i) = *textptr; textptr++,i++; - if(i >= (signed)sizeof(fta_quotes[k])-1) + if(i >= 63) { - initprintf("%s:%ld: error: quote text exceeds limit of %ld characters.\n",compilefile,line_number,sizeof(fta_quotes[k])-1); + initprintf("%s:%ld: error: quote text exceeds limit of %ld characters.\n",compilefile,line_number,63); error++; while( *textptr != 0x0a && *textptr != 0x0d && *textptr != 0 ) textptr++; break; } } if (tw == CON_DEFINEQUOTE) - fta_quotes[k][i] = '\0'; + { + *(fta_quotes[k]+i) = '\0'; + } else { - redefined_fta_quotes[redefined_quotes][i] = '\0'; - *scriptptr++=redefined_quotes; + *(fta_quotes[redefined_quote_count]+i) = '\0'; + *scriptptr++=redefined_quote_count; } return 0; diff --git a/polymer/eduke32/source/gamedef.h b/polymer/eduke32/source/gamedef.h index 007bf4a55..cd4c95301 100644 --- a/polymer/eduke32/source/gamedef.h +++ b/polymer/eduke32/source/gamedef.h @@ -39,7 +39,7 @@ extern long *actorLoadEventScrptr[MAXTILES]; extern long *apScriptGameEvent[MAXGAMEEVENTS]; -extern char redefined_fta_quotes[NUMOFFIRSTTIMEACTIVE][64]; +extern char *redefined_quotes[NUMOFFIRSTTIMEACTIVE]; extern short otherp; extern long g_currentweapon; diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index d5bb0ff48..4832a059f 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -3408,7 +3408,7 @@ char parse(void) insptr++; q = *insptr++; i = *insptr++; - Bstrcpy(fta_quotes[q],redefined_fta_quotes[i]); + Bstrcpy(fta_quotes[q],redefined_quotes[i]); break; } @@ -4107,15 +4107,19 @@ SKIPJIBS: switch(tw) { case CON_GETPNAME: - if (ud.user_name[j][0] != 0) - Bsprintf(fta_quotes[i],ud.user_name[j]); - else Bsprintf(fta_quotes[i],"%d",j); + if (ud.user_name[j][0]) + Bsprintf(fta_quotes[i],"%s",ud.user_name[j]); + else + Bsprintf(fta_quotes[i],"%d",j); break; case CON_QSTRCAT: - Bstrncat(fta_quotes[i],fta_quotes[j],63-Bstrlen(fta_quotes[i])); + Bmemcpy(tempbuf,fta_quotes[i],64); + Bmemcpy(buf,fta_quotes[j],64); + Bstrncat(tempbuf,buf,63-Bstrlen(tempbuf)); + Bmemcpy(fta_quotes[i],tempbuf,64); break; case CON_QSTRCPY: - Bstrcpy(fta_quotes[i],fta_quotes[j]); + Bstrcpy(fta_quotes[j],fta_quotes[i]); break; case CON_CHANGESPRITESTAT: changespritestat(i,j); @@ -4613,7 +4617,6 @@ SKIPJIBS: x2=GetGameVarID(*insptr++,g_i,g_p); y2=GetGameVarID(*insptr++,g_i,g_p); } - if (tw == CON_MINITEXT) minitextshade(x,y,fta_quotes[q],shade,pal,26); else if (tw == CON_GAMETEXT) txgametext(tilenum,x>>1,y,fta_quotes[q],shade,pal,orientation,x1,y1,x2,y2); else if (tw == CON_DIGITALNUMBER) txdigitalnumber(tilenum,x,y,q,shade,pal,orientation,x1,y1,x2,y2); diff --git a/polymer/eduke32/source/global.c b/polymer/eduke32/source/global.c index 59a90043d..07e90be89 100644 --- a/polymer/eduke32/source/global.c +++ b/polymer/eduke32/source/global.c @@ -42,7 +42,7 @@ short animatesect[MAXANIMATES]; long msx[2048],msy[2048]; short cyclers[MAXCYCLERS][6],numcyclers; -char fta_quotes[NUMOFFIRSTTIMEACTIVE][64]; +char *fta_quotes[NUMOFFIRSTTIMEACTIVE]; char tempbuf[2048], packbuf[576]; diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index b26ca8063..33b56de39 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -3468,16 +3468,16 @@ void processinput(short snum) ps[p->frag_ps].frag++; frags[p->frag_ps][snum]++; - if( ud.user_name[p->frag_ps][0] != 0) + if(ud.user_name[p->frag_ps][0]) { if(snum == screenpeek) { - Bsprintf(&fta_quotes[115][0],"KILLED BY %s",&ud.user_name[p->frag_ps][0]); + Bsprintf(fta_quotes[115],"KILLED BY %s",&ud.user_name[p->frag_ps][0]); FTA(115,p); } else { - Bsprintf(&fta_quotes[116][0],"KILLED %s",&ud.user_name[snum][0]); + Bsprintf(fta_quotes[116],"KILLED %s",&ud.user_name[snum][0]); FTA(116,&ps[p->frag_ps]); } } @@ -3485,12 +3485,12 @@ void processinput(short snum) { if(snum == screenpeek) { - Bsprintf(&fta_quotes[115][0],"KILLED BY PLAYER %d",1+p->frag_ps); + Bsprintf(fta_quotes[115],"KILLED BY PLAYER %d",p->frag_ps); FTA(115,p); } else { - Bsprintf(&fta_quotes[116][0],"KILLED PLAYER %d",1+snum); + Bsprintf(fta_quotes[116],"KILLED PLAYER %d",snum); FTA(116,&ps[p->frag_ps]); } } diff --git a/polymer/eduke32/source/savegame.c b/polymer/eduke32/source/savegame.c index bc63d4939..7a2245932 100644 --- a/polymer/eduke32/source/savegame.c +++ b/polymer/eduke32/source/savegame.c @@ -24,7 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. int loadpheader(char spot,struct savehead *saveh) { - long i; char fn[13]; long fil; long bv; diff --git a/polymer/eduke32/source/sector.c b/polymer/eduke32/source/sector.c index 9e0f7baf0..8c68169b0 100644 --- a/polymer/eduke32/source/sector.c +++ b/polymer/eduke32/source/sector.c @@ -1002,7 +1002,7 @@ void operaterespawns(short low) void operateactivators(short low,short snum) { - short i, j, k, *p, nexti; + short i, j, k, *p; walltype *wal; for(i=numcyclers-1;i>=0;i--) @@ -1610,10 +1610,7 @@ void breakwall(short newpn,short spr,short dawallnum) void checkhitwall(short spr,short dawallnum,long x,long y,long z,short atwith) { short j, i, sn = -1, darkestwall; - signed char nfloors,nceilings; - short nextj; walltype *wal; - spritetype *s; wal = &wall[dawallnum]; @@ -1932,9 +1929,7 @@ void checkplayerhurt(struct player_struct *p,short j) char checkhitceiling(short sn) { - short i, j, q, darkestwall, darkestceiling; - signed char nfloors,nceilings; - walltype *wal; + short i, j; switch(dynamictostatic[sector[sn].ceilingpicnum]) { @@ -2007,7 +2002,7 @@ char checkhitceiling(short sn) void checkhitsprite(short i,short sn) { - short j, k, l, nextj, p, rpg=0; + short j, k, p, rpg=0; spritetype *s; int switchpicnum; diff --git a/polymer/eduke32/source/sounds.c b/polymer/eduke32/source/sounds.c index 40c06839d..7ab504c84 100644 --- a/polymer/eduke32/source/sounds.c +++ b/polymer/eduke32/source/sounds.c @@ -232,7 +232,7 @@ char loadsound(unsigned short num) fp = kopen4load(sounds[num],loadfromgrouponly); if(fp == -1) { - sprintf(&fta_quotes[113][0],"Sound %s(#%d) not found.",sounds[num],num); + Bsprintf(fta_quotes[113],"Sound %s(#%d) not found.",sounds[num],num); FTA(113,&ps[myconnectindex]); return 0; }